textmode.js 0.7.0-beta.1 → 0.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
1
  var jt = Object.defineProperty;
2
- var Vt = (n, t, e) => t in n ? jt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var a = (n, t, e) => Vt(n, typeof t != "symbol" ? t + "" : t, e);
4
- class N extends Error {
2
+ var Qt = (n, t, e) => t in n ? jt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var a = (n, t, e) => Qt(n, typeof t != "symbol" ? t + "" : t, e);
4
+ class U extends Error {
5
5
  constructor(t, e = {}) {
6
- super(N.i(t, e)), this.name = "TextmodeError";
6
+ super(U.i(t, e)), this.name = "TextmodeError";
7
7
  }
8
8
  static i(t, e) {
9
9
  return `${t}${e && Object.keys(e).length > 0 ? `
10
10
 
11
11
  📋 Context:` + Object.entries(e).map(([i, r]) => `
12
- - ${i}: ${N.o(r)}`).join("") : ""}
12
+ - ${i}: ${U.o(r)}`).join("") : ""}
13
13
 
14
14
  ${"↓".repeat(24)}
15
15
  `;
@@ -19,21 +19,21 @@ ${"↓".repeat(24)}
19
19
  if (t === void 0) return "undefined";
20
20
  if (typeof t == "string") return `"${t}"`;
21
21
  if (typeof t == "number" || typeof t == "boolean") return t + "";
22
- if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => N.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => N.o(e)).join(", ")}, ... +${t.length - 3} more]`;
22
+ if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => U.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => U.o(e)).join(", ")}, ... +${t.length - 3} more]`;
23
23
  if (typeof t == "object") {
24
24
  const e = Object.keys(t);
25
- return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${N.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${N.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
25
+ return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${U.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${U.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
26
26
  }
27
27
  return t + "";
28
28
  }
29
29
  }
30
30
  var Kt = ((n) => (n[n.SILENT = 0] = "SILENT", n[n.WARNING = 1] = "WARNING", n[n.ERROR = 2] = "ERROR", n[n.THROW = 3] = "THROW", n))(Kt || {});
31
- const B = class B {
31
+ const X = class X {
32
32
  constructor() {
33
33
  a(this, "l", { globalLevel: 3 });
34
34
  }
35
35
  static u() {
36
- return B.h || (B.h = new B()), B.h;
36
+ return X.h || (X.h = new X()), X.h;
37
37
  }
38
38
  v(t, e) {
39
39
  const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", r = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
@@ -41,11 +41,11 @@ const B = class B {
41
41
  case 0:
42
42
  return !1;
43
43
  case 1:
44
- return console.group(i, r), console.warn(N.i(t, e)), console.groupEnd(), !1;
44
+ return console.group(i, r), console.warn(U.i(t, e)), console.groupEnd(), !1;
45
45
  case 2:
46
- return console.group(i, r), console.error(N.i(t, e)), console.groupEnd(), !1;
46
+ return console.group(i, r), console.error(U.i(t, e)), console.groupEnd(), !1;
47
47
  default:
48
- throw new N(t, e);
48
+ throw new U(t, e);
49
49
  }
50
50
  }
51
51
  m(t, e, i) {
@@ -55,21 +55,21 @@ const B = class B {
55
55
  this.l.globalLevel = t;
56
56
  }
57
57
  };
58
- a(B, "h", null);
59
- let ft = B;
60
- const pt = ft.u();
58
+ a(X, "h", null);
59
+ let lt = X;
60
+ const mt = lt.u();
61
61
  class k {
62
62
  constructor(t, e, i) {
63
63
  a(this, "A");
64
64
  a(this, "C");
65
65
  a(this, "M", /* @__PURE__ */ new Map());
66
66
  a(this, "F", /* @__PURE__ */ new Map());
67
- a(this, "U", 0);
68
- a(this, "P", /* @__PURE__ */ new Map());
69
- a(this, "$");
70
- this.A = t, this.$ = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS) ?? 16, this.C = this.S(e, i), this.R();
67
+ a(this, "P", 0);
68
+ a(this, "$", /* @__PURE__ */ new Map());
69
+ a(this, "U");
70
+ this.A = t, this.U = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS) ?? 16, this.C = this.R(e, i), this.S();
71
71
  }
72
- R() {
72
+ S() {
73
73
  const t = this.A.getProgramParameter(this.C, this.A.ACTIVE_UNIFORMS);
74
74
  for (let e = 0; e < t; e++) {
75
75
  const i = this.A.getActiveUniform(this.C, e);
@@ -79,7 +79,7 @@ class k {
79
79
  }
80
80
  }
81
81
  }
82
- S(t, e) {
82
+ R(t, e) {
83
83
  const i = this.k(this.A.VERTEX_SHADER, t), r = this.k(this.A.FRAGMENT_SHADER, e), s = this.A.createProgram();
84
84
  if (this.A.attachShader(s, i), this.A.attachShader(s, r), this.A.linkProgram(s), !this.A.getProgramParameter(s, this.A.LINK_STATUS)) {
85
85
  const h = this.A.getProgramInfoLog(s);
@@ -99,7 +99,7 @@ class k {
99
99
  this.A.useProgram(this.C), this.L();
100
100
  }
101
101
  L() {
102
- this.U = 0, this.P.clear();
102
+ this.P = 0, this.$.clear();
103
103
  }
104
104
  I(t) {
105
105
  for (const e in t) this.O(e, t[e]);
@@ -115,7 +115,7 @@ class k {
115
115
  const u = this.H(t);
116
116
  return o.uniform1i(i, u), o.activeTexture(o.TEXTURE0 + u), void o.bindTexture(o.TEXTURE_2D, e);
117
117
  }
118
- if (e instanceof j) {
118
+ if (e instanceof H) {
119
119
  const u = this.H(t);
120
120
  return o.uniform1i(i, u), o.activeTexture(o.TEXTURE0 + u), void o.bindTexture(o.TEXTURE_2D, e.textures[0]);
121
121
  }
@@ -130,11 +130,11 @@ class k {
130
130
  }
131
131
  }
132
132
  H(t) {
133
- const e = this.P.get(t);
133
+ const e = this.$.get(t);
134
134
  if (e !== void 0) return e;
135
- if (this.U >= this.$) throw Error(`[textmode.js] Shader attempted to bind more than ${this.$} texture samplers. Uniform "${t}" cannot be assigned.`);
136
- const i = this.U++;
137
- return this.P.set(t, i), i;
135
+ if (this.P >= this.U) throw Error(`[textmode.js] Shader attempted to bind more than ${this.U} texture samplers. Uniform "${t}" cannot be assigned.`);
136
+ const i = this.P++;
137
+ return this.$.set(t, i), i;
138
138
  }
139
139
  get G() {
140
140
  return this.C;
@@ -143,32 +143,32 @@ class k {
143
143
  this.A.deleteProgram(this.C);
144
144
  }
145
145
  }
146
- function bt(n, t, e, i) {
146
+ function yt(n, t, e, i) {
147
147
  return 180 * Math.atan2(i - t, e - n) / Math.PI;
148
148
  }
149
- function G(n, t, e, i) {
149
+ function z(n, t, e, i) {
150
150
  return Math.hypot(e - n, i - t);
151
151
  }
152
- function Z(n, t, e) {
152
+ function I(n, t, e) {
153
153
  return Math.min(Math.max(n, t), e);
154
154
  }
155
- function Rt(n) {
155
+ function Tt(n) {
156
156
  return (n % 360 + 360) % 360 / 360;
157
157
  }
158
- function Ct(n, t, e) {
158
+ function Rt(n, t, e) {
159
159
  n.bindTexture(n.TEXTURE_2D, t), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 1), n.texImage2D(n.TEXTURE_2D, 0, n.RGBA, n.RGBA, n.UNSIGNED_BYTE, e), n.bindTexture(n.TEXTURE_2D, null);
160
160
  }
161
- function rt(n, t, e, i, r) {
161
+ function et(n, t, e, i, r) {
162
162
  n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, t), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, i), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, r);
163
163
  }
164
- function dt(n, t, e, i, r, s = 0, h = WebGL2RenderingContext.FLOAT, o = !1) {
164
+ function ut(n, t, e, i, r, s = 0, h = WebGL2RenderingContext.FLOAT, o = !1) {
165
165
  n.enableVertexAttribArray(t), n.vertexAttribPointer(t, e, h, o, i, r), n.vertexAttribDivisor(t, s);
166
166
  }
167
- function Pt(n, t, e, i, r) {
167
+ function Ct(n, t, e, i, r) {
168
168
  n.bindBuffer(t, e), n.bufferData(t, i, r), n.bindBuffer(t, null);
169
169
  }
170
- const st = `#version 300 es
171
- in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in vec4 A7;in vec3 A8;in vec3 A9;in vec4 Aa;in vec4 Ab;in vec3 Ac;uniform vec2 Ug;uniform float Uh;uniform float Ui;out vec2 v_uv;out vec3 v_glyphIndex;out vec4 v_glyphColor;out vec4 v_cellColor;out vec4 v_glyphFlags;out vec3 v_worldPosition;out vec3 v_normal;out float v_geometryType;const float A=6.28318530718f;const int B=2;const int C=3;const int D=4;vec2 E(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float M=L*K;float N=F*F;float O=N*F;return M*G+3.0f*L*F*H+3.0f*K*N*I+O*J;}vec2 P(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float N=F*F;return-3.0f*L*G+3.0f*(L-2.0f*K*F)*H+3.0f*(2.0f*K*F-N)*I+3.0f*N*J;}vec3 Q(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x,R.y*T-R.z*U,R.y*U+R.z*T);}vec3 V(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T+R.z*U,R.y,-R.x*U+R.z*T);}vec3 W(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T-R.y*U,R.x*U+R.y*T,R.z);}vec3 X(vec3 R,vec3 Y){vec3 Z=R;if(Y.z!=0.0f){Z=W(Z,Y.z);}if(Y.y!=0.0f){Z=V(Z,Y.y);}if(Y.x!=0.0f){Z=Q(Z,Y.x);}return Z;}void main(){v_uv=A1;v_glyphIndex=A4;v_glyphColor=A5;v_cellColor=A6;v_glyphFlags=A7;vec4 a=Aa;vec4 b=Ab;vec2 c=A3;vec2 d=A2;float e=Ac.x;float f=Ac.y;int g=int(Ac.z);vec2 h=d;vec2 i=h+c*0.5f;float j=f+e*0.5f;vec3 k=vec3(i,j);vec3 l;if(g==D){float F=clamp(A0.x,0.0f,1.0f);vec2 G=b.xy;vec2 H=a.xy;vec2 I=a.zw;vec2 J=b.zw;vec2 m=E(F,G,H,I,J);vec2 n=P(F,G,H,I,J);float o=length(n);vec2 p=o>0.0f?n/o:vec2(1.0f,0.0f);vec2 q=vec2(-p.y,p.x);vec2 r=m;vec2 s=r+q*A0.y*c.y;l=vec3(s,f);}else if(g==C){float t=mod(a.x,A);if(t<0.0f){t+=A;}float u=mod(a.y,A);if(u<0.0f){u+=A;}float v=t-u;if(v<=0.0f){v+=A;}float S=t-A0.x*v;vec2 w=vec2(cos(S),sin(S))*A0.y;vec2 s=w*c+h;l=vec3(s,f);}else if(g==B){vec2 s=A0.xy*c+h;l=vec3(s,f);}vec3 x=X(l,A9);vec3 y=x+A8;vec3 z=vec3(0.0f,0.0f,1.0f);v_worldPosition=y;v_normal=z;v_geometryType=float(g);vec2 AA=(y.xy/Ug)*2.0f;AA.y=-AA.y;float AB=y.z/Ug.y;float AC=clamp(-AB*Uh,-0.99f,0.99f);if(Ui>0.5f){gl_Position=vec4(AA,AC,1.0f);}else{float AD=0.5f;float AE=1.0f/(1.0f-AB*AD);AA*=AE;gl_Position=vec4(AA,AC,1.0f);}}`, Y = class Y {
170
+ const it = `#version 300 es
171
+ in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in vec4 A7;in vec3 A8;in vec3 A9;in vec4 Aa;in vec4 Ab;in vec3 Ac;uniform vec2 Uc;uniform float Ud;uniform float Ue;out vec2 v_uv;out vec3 v_glyphIndex;out vec4 v_glyphColor;out vec4 v_cellColor;out vec4 v_glyphFlags;out vec3 v_worldPosition;out vec3 v_normal;out float v_geometryType;const float A=6.28318530718f;const int B=2;const int C=3;const int D=4;vec2 E(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float M=L*K;float N=F*F;float O=N*F;return M*G+3.0f*L*F*H+3.0f*K*N*I+O*J;}vec2 P(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float N=F*F;return-3.0f*L*G+3.0f*(L-2.0f*K*F)*H+3.0f*(2.0f*K*F-N)*I+3.0f*N*J;}vec3 Q(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x,R.y*T-R.z*U,R.y*U+R.z*T);}vec3 V(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T+R.z*U,R.y,-R.x*U+R.z*T);}vec3 W(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T-R.y*U,R.x*U+R.y*T,R.z);}vec3 X(vec3 R,vec3 Y){vec3 Z=R;if(Y.z!=0.0f){Z=W(Z,Y.z);}if(Y.y!=0.0f){Z=V(Z,Y.y);}if(Y.x!=0.0f){Z=Q(Z,Y.x);}return Z;}void main(){v_uv=A1;v_glyphIndex=A4;v_glyphColor=A5;v_cellColor=A6;v_glyphFlags=A7;vec4 a=Aa;vec4 b=Ab;vec2 c=A3;vec2 d=A2;float e=Ac.x;float f=Ac.y;int g=int(Ac.z);vec2 h=d;vec2 i=h+c*0.5f;float j=f+e*0.5f;vec3 k=vec3(i,j);vec3 l;if(g==D){float F=clamp(A0.x,0.0f,1.0f);vec2 G=b.xy;vec2 H=a.xy;vec2 I=a.zw;vec2 J=b.zw;vec2 m=E(F,G,H,I,J);vec2 n=P(F,G,H,I,J);float o=length(n);vec2 p=o>0.0f?n/o:vec2(1.0f,0.0f);vec2 q=vec2(-p.y,p.x);vec2 r=m;vec2 s=r+q*A0.y*c.y;l=vec3(s,f);}else if(g==C){float t=mod(a.x,A);if(t<0.0f){t+=A;}float u=mod(a.y,A);if(u<0.0f){u+=A;}float v=t-u;if(v<=0.0f){v+=A;}float S=t-A0.x*v;vec2 w=vec2(cos(S),sin(S))*A0.y;vec2 s=w*c+h;l=vec3(s,f);}else if(g==B){vec2 s=A0.xy*c+h;l=vec3(s,f);}vec3 x=X(l,A9);vec3 y=x+A8;vec3 z=vec3(0.0f,0.0f,1.0f);v_worldPosition=y;v_normal=z;v_geometryType=float(g);vec2 AA=(y.xy/Uc)*2.0f;AA.y=-AA.y;float AB=y.z/Uc.y;float AC=clamp(-AB*Ud,-0.99f,0.99f);if(Ue>0.5f){gl_Position=vec4(AA,AC,1.0f);}else{float AD=0.5f;float AE=1.0f/(1.0f-AB*AD);AA*=AE;gl_Position=vec4(AA,AC,1.0f);}}`, Z = class Z {
172
172
  constructor(t, e, i = e, r = 1, s = {}, h) {
173
173
  a(this, "N");
174
174
  a(this, "X");
@@ -181,8 +181,8 @@ in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in
181
181
  a(this, "Z");
182
182
  a(this, "q", null);
183
183
  a(this, "V", /* @__PURE__ */ new Map());
184
- this.N = e, this.X = i, this.A = t, this.W = Z(r, 1, 8), this.Z = h, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", depth: !0, ...s }, Y.J || (Y.J = new k(t, st, `#version 300 es
185
- precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uniform sampler2D Ul;uniform sampler2D Um;uniform vec2 Un;uniform bool Uo;uniform bool Up;uniform bool Uq;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 A;void main(){vec2 B=vec2(v_uv.x,1.-v_uv.y);vec2 C=B*Un;vec2 D=(floor(C)+0.5f)/Un;vec4 E=texture(Uj,D);vec4 F=Uo?texture(Uk,D):vec4(0.);if(Uo&&F.a==0.){discard;}vec4 G=Up?texture(Ul,D):vec4(0.);vec4 H=Uq?texture(Um,D):vec4(0.);o_character=E;o_primaryColor=F;o_secondaryColor=G;A=H;}`));
184
+ this.N = e, this.X = i, this.A = t, this.W = I(r, 1, 8), this.Z = h, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", depth: !0, ...s }, Z.J || (Z.J = new k(t, it, `#version 300 es
185
+ precision highp float;in vec2 v_uv;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U6;uniform sampler2D U7;uniform vec2 U8;uniform bool U9;uniform bool Ua;uniform bool Ub;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 A;void main(){vec2 B=vec2(v_uv.x,1.-v_uv.y);vec2 C=B*U8;vec2 D=(floor(C)+0.5f)/U8;vec4 E=texture(U4,D);vec4 F=U9?texture(U5,D):vec4(0.);if(U9&&F.a==0.){discard;}vec4 G=Ua?texture(U6,D):vec4(0.);vec4 H=Ub?texture(U7,D):vec4(0.);o_character=E;o_primaryColor=F;o_secondaryColor=G;A=H;}`));
186
186
  const o = t.getParameter(t.MAX_DRAW_BUFFERS), c = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
187
187
  this.W = Math.min(this.W, o, c), this.Y = t.createFramebuffer(), this.tt(), this.st(), this.l.depth && this.et();
188
188
  }
@@ -190,7 +190,7 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uni
190
190
  const t = this.A, e = this.l.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.l.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, r = this.l.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE, s = r === t.FLOAT ? t.RGBA32F : t.RGBA8, h = t.RGBA;
191
191
  for (let o = 0; o < this.W; o++) {
192
192
  const c = t.createTexture();
193
- t.bindTexture(t.TEXTURE_2D, c), rt(t, e, e, i, i), t.texImage2D(t.TEXTURE_2D, 0, s, this.N, this.X, 0, h, r, null), this.j.push(c);
193
+ t.bindTexture(t.TEXTURE_2D, c), et(t, e, e, i, i), t.texImage2D(t.TEXTURE_2D, 0, s, this.N, this.X, 0, h, r, null), this.j.push(c);
194
194
  }
195
195
  t.bindTexture(t.TEXTURE_2D, null);
196
196
  }
@@ -212,7 +212,7 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uni
212
212
  this.K = t.createRenderbuffer(), t.bindRenderbuffer(t.RENDERBUFFER, this.K), t.renderbufferStorage(t.RENDERBUFFER, t.DEPTH_COMPONENT24, this.N, this.X), t.bindFramebuffer(t.FRAMEBUFFER, this.Y), t.framebufferRenderbuffer(t.FRAMEBUFFER, t.DEPTH_ATTACHMENT, t.RENDERBUFFER, this.K), t.bindFramebuffer(t.FRAMEBUFFER, null), t.bindRenderbuffer(t.RENDERBUFFER, null);
213
213
  }
214
214
  it(t) {
215
- Ct(this.A, this.j[0], t);
215
+ Rt(this.A, this.j[0], t);
216
216
  }
217
217
  resize(t, e) {
218
218
  this.N = t, this.X = e, this.V.clear();
@@ -227,8 +227,8 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uni
227
227
  i.bindFramebuffer(i.READ_FRAMEBUFFER, this.Y), i.readBuffer(i.COLOR_ATTACHMENT0 + t), i.readPixels(0, 0, r, s, i.RGBA, i.UNSIGNED_BYTE, h), i.bindFramebuffer(i.READ_FRAMEBUFFER, o);
228
228
  const c = 4 * r, l = new Uint8Array(h.length);
229
229
  for (let u = 0; u < s; u++) {
230
- const f = (s - 1 - u) * c, v = u * c;
231
- l.set(h.subarray(f, f + c), v);
230
+ const f = (s - 1 - u) * c, g = u * c;
231
+ l.set(h.subarray(f, f + c), g);
232
232
  }
233
233
  return this.V.set(t, l), l;
234
234
  }
@@ -244,7 +244,7 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uni
244
244
  }
245
245
  ft() {
246
246
  if (!this.Z) return;
247
- const t = this.W > 1, e = this.W > 2, i = this.W > 3, r = { Uj: this.j[0], Uk: t ? this.j[1] : this.j[0], Ul: e ? this.j[2] : this.j[0], Um: i ? this.j[3] : this.j[0], Un: [this.N, this.X], Uo: t, Up: e, Uq: i }, s = Y.J;
247
+ const t = this.W > 1, e = this.W > 2, i = this.W > 3, r = { U4: this.j[0], U5: t ? this.j[1] : this.j[0], U6: e ? this.j[2] : this.j[0], U7: i ? this.j[3] : this.j[0], U8: [this.N, this.X], U9: t, Ua: e, Ub: i }, s = Z.J;
248
248
  this.q = this.Z.vt.dt(s, r, !0);
249
249
  }
250
250
  gt() {
@@ -266,23 +266,23 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform sampler2D Uk;uni
266
266
  return this.W;
267
267
  }
268
268
  };
269
- a(Y, "J", null);
270
- let j = Y;
271
- const Mt = /* @__PURE__ */ new WeakMap();
272
- function ot(n, t) {
273
- Mt.set(n, t);
269
+ a(Z, "J", null);
270
+ let H = Z;
271
+ const Ft = /* @__PURE__ */ new WeakMap();
272
+ function nt(n, t) {
273
+ Ft.set(n, t);
274
274
  }
275
- function Ut(n) {
276
- return Mt.get(n);
275
+ function Pt(n) {
276
+ return Ft.get(n);
277
277
  }
278
- function it(n, t, e, i, r = 255) {
278
+ function tt(n, t, e, i, r = 255) {
279
279
  n[0] = t / 255, n[1] = (e ?? t) / 255, n[2] = (i ?? t) / 255, n[3] = r / 255;
280
280
  }
281
- class nt {
281
+ class rt {
282
282
  constructor() {
283
283
  a(this, "_t", 1);
284
- a(this, "yt", 0);
285
284
  a(this, "At", 0);
285
+ a(this, "yt", 0);
286
286
  a(this, "wt", 0);
287
287
  a(this, "bt", 0);
288
288
  a(this, "Ct", 0);
@@ -293,24 +293,24 @@ class nt {
293
293
  a(this, "$t", !1);
294
294
  a(this, "Tt", !1);
295
295
  a(this, "Et", !1);
296
- a(this, "St", 0);
297
- a(this, "Rt", [0, 0, 0, 1]);
296
+ a(this, "Rt", 0);
297
+ a(this, "St", [0, 0, 0, 1]);
298
298
  a(this, "kt", !1);
299
299
  a(this, "zt", []);
300
300
  a(this, "Dt", []);
301
301
  }
302
302
  static Lt() {
303
- return { It: 1, Ot: 0, Bt: 0, Ht: 0, bt: 0, Ct: 0, xt: 0, St: 0, Gt: !1, Qt: !1, Et: !1, kt: !1, Nt: [0, 0, 0], Xt: [1, 1, 1, 1], Yt: [0, 0, 0, 1] };
303
+ return { It: 1, Bt: 0, Ot: 0, Ht: 0, bt: 0, Ct: 0, xt: 0, Rt: 0, Gt: !1, Qt: !1, Et: !1, kt: !1, Nt: [0, 0, 0], Xt: [1, 1, 1, 1], Yt: [0, 0, 0, 1] };
304
304
  }
305
305
  jt(t) {
306
- t.It = this._t, t.Ot = this.yt, t.Bt = this.At, t.Ht = this.wt, t.bt = this.bt, t.Ct = this.Ct, t.xt = this.xt, t.Gt = this.$t, t.Qt = this.Tt, t.Et = this.Et, t.St = this.St, t.kt = this.kt, t.Nt[0] = this.Mt[0], t.Nt[1] = this.Mt[1], t.Nt[2] = this.Mt[2], t.Xt[0] = this.Ft[0], t.Xt[1] = this.Ft[1], t.Xt[2] = this.Ft[2], t.Xt[3] = this.Ft[3], t.Yt[0] = this.Pt[0], t.Yt[1] = this.Pt[1], t.Yt[2] = this.Pt[2], t.Yt[3] = this.Pt[3];
306
+ t.It = this._t, t.Bt = this.At, t.Ot = this.yt, t.Ht = this.wt, t.bt = this.bt, t.Ct = this.Ct, t.xt = this.xt, t.Gt = this.$t, t.Qt = this.Tt, t.Et = this.Et, t.Rt = this.Rt, t.kt = this.kt, t.Nt[0] = this.Mt[0], t.Nt[1] = this.Mt[1], t.Nt[2] = this.Mt[2], t.Xt[0] = this.Ft[0], t.Xt[1] = this.Ft[1], t.Xt[2] = this.Ft[2], t.Xt[3] = this.Ft[3], t.Yt[0] = this.Pt[0], t.Yt[1] = this.Pt[1], t.Yt[2] = this.Pt[2], t.Yt[3] = this.Pt[3];
307
307
  }
308
308
  Kt(t) {
309
- this._t = t.It, this.yt = t.Ot, this.At = t.Bt, this.wt = t.Ht, this.bt = t.bt, this.Ct = t.Ct, this.xt = t.xt, this.$t = t.Gt, this.Tt = t.Qt, this.Et = t.Et, this.St = t.St, this.kt = t.kt, this.Mt[0] = t.Nt[0], this.Mt[1] = t.Nt[1], this.Mt[2] = t.Nt[2], this.Ft[0] = t.Xt[0], this.Ft[1] = t.Xt[1], this.Ft[2] = t.Xt[2], this.Ft[3] = t.Xt[3], this.Pt[0] = t.Yt[0], this.Pt[1] = t.Yt[1], this.Pt[2] = t.Yt[2], this.Pt[3] = t.Yt[3];
309
+ this._t = t.It, this.At = t.Bt, this.yt = t.Ot, this.wt = t.Ht, this.bt = t.bt, this.Ct = t.Ct, this.xt = t.xt, this.$t = t.Gt, this.Tt = t.Qt, this.Et = t.Et, this.Rt = t.Rt, this.kt = t.kt, this.Mt[0] = t.Nt[0], this.Mt[1] = t.Nt[1], this.Mt[2] = t.Nt[2], this.Ft[0] = t.Xt[0], this.Ft[1] = t.Xt[1], this.Ft[2] = t.Xt[2], this.Ft[3] = t.Xt[3], this.Pt[0] = t.Yt[0], this.Pt[1] = t.Yt[1], this.Pt[2] = t.Yt[2], this.Pt[3] = t.Yt[3];
310
310
  }
311
311
  ot() {
312
312
  let t = this.Dt.pop();
313
- t || (t = nt.Lt()), this.jt(t), this.zt.push(t);
313
+ t || (t = rt.Lt()), this.jt(t), this.zt.push(t);
314
314
  }
315
315
  ht() {
316
316
  const t = this.zt.pop();
@@ -323,7 +323,7 @@ class nt {
323
323
  this._t = Math.abs(t);
324
324
  }
325
325
  qt() {
326
- this.yt = 0, this.At = 0, this.wt = 0, this.bt = 0, this.Ct = 0, this.xt = 0, this.kt = !1;
326
+ this.At = 0, this.yt = 0, this.wt = 0, this.bt = 0, this.Ct = 0, this.xt = 0, this.kt = !1;
327
327
  }
328
328
  Vt(t) {
329
329
  t !== 0 && (this.bt += t * Math.PI / 180);
@@ -335,7 +335,7 @@ class nt {
335
335
  t !== 0 && (this.xt += t * Math.PI / 180);
336
336
  }
337
337
  ss(t = 0, e = 0, i = 0) {
338
- t === 0 && e === 0 && i === 0 || (this.yt += t, this.At += e, this.wt += i);
338
+ t === 0 && e === 0 && i === 0 || (this.At += t, this.yt += e, this.wt += i);
339
339
  }
340
340
  es(t) {
341
341
  this.ss(t, 0, 0);
@@ -350,10 +350,10 @@ class nt {
350
350
  this.Mt[0] = t[0], this.Mt[1] = t[1], this.Mt[2] = t[2];
351
351
  }
352
352
  cs(t, e, i, r = 255) {
353
- it(this.Ft, t, e, i, r);
353
+ tt(this.Ft, t, e, i, r);
354
354
  }
355
355
  ls(t, e, i, r = 255) {
356
- it(this.Pt, t, e, i, r);
356
+ tt(this.Pt, t, e, i, r);
357
357
  }
358
358
  us(t) {
359
359
  this.$t = t;
@@ -365,16 +365,16 @@ class nt {
365
365
  this.Et = t;
366
366
  }
367
367
  vs(t) {
368
- this.St = Rt(t);
368
+ this.Rt = Tt(t);
369
369
  }
370
370
  ps(t, e, i, r) {
371
- it(this.Rt, t, e, i, r);
371
+ tt(this.St, t, e, i, r);
372
372
  }
373
373
  gs(t) {
374
374
  this.kt = t;
375
375
  }
376
376
  get canvasBackgroundColor() {
377
- return this.Rt;
377
+ return this.St;
378
378
  }
379
379
  get useOrtho() {
380
380
  return this.kt;
@@ -389,19 +389,19 @@ class nt {
389
389
  return this.xt;
390
390
  }
391
391
  }
392
- const gt = new Float32Array([-0.5, -0.5, 0, 0, 0.5, -0.5, 1, 0, -0.5, 0.5, 0, 1, -0.5, 0.5, 0, 1, 0.5, -0.5, 1, 0, 0.5, 0.5, 1, 1]), Q = { _s: 16, As: WebGL2RenderingContext.TRIANGLES, ws: { bs: { size: 2, offset: 0 }, Cs: { size: 2, offset: 8 } } };
393
- class Jt {
392
+ const ft = new Float32Array([-0.5, -0.5, 0, 0, 0.5, -0.5, 1, 0, -0.5, 0.5, 0, 1, -0.5, 0.5, 0, 1, 0.5, -0.5, 1, 0, 0.5, 0.5, 1, 1]), O = { _s: 16, As: WebGL2RenderingContext.TRIANGLES, ws: { bs: { size: 2, offset: 0 }, Cs: { size: 2, offset: 8 } } };
393
+ class qt {
394
394
  constructor(t) {
395
395
  a(this, "A");
396
396
  a(this, "Ms");
397
397
  a(this, "Fs");
398
- this.A = t, this.Ms = t.createBuffer(), this.Fs = new Float32Array(gt.length);
398
+ this.A = t, this.Ms = t.createBuffer(), this.Fs = new Float32Array(ft.length);
399
399
  }
400
400
  Ps(t, e, i, r) {
401
- const s = this.A, h = Ut(this.A), o = h[2], c = h[3], l = t / o * 2 - 1, u = (t + i) / o * 2 - 1, f = 1 - (e + r) / c * 2, v = 1 - e / c * 2, m = gt, d = this.Fs;
402
- for (let g = 0; g < m.length; g += 4) {
403
- const A = m[g], p = m[g + 1], y = m[g + 2], E = m[g + 3], x = l + (A + 0.5) * (u - l), b = f + (p + 0.5) * (v - f);
404
- d[g] = x, d[g + 1] = b, d[g + 2] = y, d[g + 3] = E;
401
+ const s = this.A, h = Pt(this.A), o = h[2], c = h[3], l = t / o * 2 - 1, u = (t + i) / o * 2 - 1, f = 1 - (e + r) / c * 2, g = 1 - e / c * 2, m = ft, d = this.Fs;
402
+ for (let v = 0; v < m.length; v += 4) {
403
+ const p = m[v], A = m[v + 1], w = m[v + 2], y = m[v + 3], x = l + (p + 0.5) * (u - l), E = f + (A + 0.5) * (g - f);
404
+ d[v] = x, d[v + 1] = E, d[v + 2] = w, d[v + 3] = y;
405
405
  }
406
406
  s.bindBuffer(s.ARRAY_BUFFER, this.Ms), s.bufferData(s.ARRAY_BUFFER, d, s.DYNAMIC_DRAW), s.enableVertexAttribArray(0), s.vertexAttribPointer(0, 2, s.FLOAT, !1, 16, 0), s.enableVertexAttribArray(1), s.vertexAttribPointer(1, 2, s.FLOAT, !1, 16, 8), s.drawArrays(s.TRIANGLES, 0, 6), s.disableVertexAttribArray(1), s.disableVertexAttribArray(0), s.bindBuffer(s.ARRAY_BUFFER, null);
407
407
  }
@@ -409,9 +409,9 @@ class Jt {
409
409
  this.A.deleteBuffer(this.Ms);
410
410
  }
411
411
  }
412
- var w = ((n) => (n.RECTANGLE = "rectangle", n.LINE = "line", n.ELLIPSE = "ellipse", n.ARC = "arc", n.TRIANGLE = "triangle", n.BEZIER_CURVE = "bezier_curve", n))(w || {});
413
- const $t = { rectangle: 2, line: 2, ellipse: 2, triangle: 2, arc: 3, bezier_curve: 4 };
414
- class te {
412
+ var b = ((n) => (n.RECTANGLE = "rectangle", n.LINE = "line", n.ELLIPSE = "ellipse", n.ARC = "arc", n.TRIANGLE = "triangle", n.BEZIER_CURVE = "bezier_curve", n))(b || {});
413
+ const Jt = { rectangle: 2, line: 2, ellipse: 2, triangle: 2, arc: 3, bezier_curve: 4 };
414
+ class $t {
415
415
  constructor(t) {
416
416
  a(this, "A");
417
417
  a(this, "$s", /* @__PURE__ */ new Map());
@@ -425,9 +425,9 @@ class te {
425
425
  if (!o) {
426
426
  o = s.createVertexArray(), h.set(e, o), s.bindVertexArray(o), s.bindBuffer(s.ARRAY_BUFFER, r);
427
427
  const c = s.getAttribLocation(t, "A0");
428
- c !== -1 && dt(s, c, i.ws.bs.size, i._s, i.ws.bs.offset, 0, s.FLOAT, !1);
428
+ c !== -1 && ut(s, c, i.ws.bs.size, i._s, i.ws.bs.offset, 0, s.FLOAT, !1);
429
429
  const l = s.getAttribLocation(t, "A1");
430
- l !== -1 && dt(s, l, i.ws.Cs.size, i._s, i.ws.Cs.offset, 0, s.FLOAT, !1);
430
+ l !== -1 && ut(s, l, i.ws.Cs.size, i._s, i.ws.Cs.offset, 0, s.FLOAT, !1);
431
431
  }
432
432
  s.bindVertexArray(o);
433
433
  }
@@ -439,22 +439,22 @@ class te {
439
439
  }
440
440
  }
441
441
  const _ = class _ {
442
- static Ss(t, e, i = 0) {
442
+ static Rs(t, e, i = 0) {
443
443
  const r = e || new Float32Array(_.FLOATS_PER_INSTANCE);
444
444
  let s = i;
445
- r[s++] = t.bs[0], r[s++] = t.bs[1], r[s++] = t.Rs[0], r[s++] = t.Rs[1], r[s++] = t.Nt[0], r[s++] = t.Nt[1], r[s++] = t.Nt[2], r[s++] = t.Xt[0], r[s++] = t.Xt[1], r[s++] = t.Xt[2], r[s++] = t.Xt[3], r[s++] = t.Yt[0], r[s++] = t.Yt[1], r[s++] = t.Yt[2], r[s++] = t.Yt[3], r[s++] = t.ks[0], r[s++] = t.ks[1], r[s++] = t.ks[2], r[s++] = t.St;
445
+ r[s++] = t.bs[0], r[s++] = t.bs[1], r[s++] = t.Ss[0], r[s++] = t.Ss[1], r[s++] = t.Nt[0], r[s++] = t.Nt[1], r[s++] = t.Nt[2], r[s++] = t.Xt[0], r[s++] = t.Xt[1], r[s++] = t.Xt[2], r[s++] = t.Xt[3], r[s++] = t.Yt[0], r[s++] = t.Yt[1], r[s++] = t.Yt[2], r[s++] = t.Yt[3], r[s++] = t.ks[0], r[s++] = t.ks[1], r[s++] = t.ks[2], r[s++] = t.Rt;
446
446
  const h = t.zs;
447
447
  r[s++] = (h == null ? void 0 : h[0]) ?? 0, r[s++] = (h == null ? void 0 : h[1]) ?? 0, r[s++] = (h == null ? void 0 : h[2]) ?? 0;
448
448
  const o = t.Ds;
449
449
  r[s++] = (o == null ? void 0 : o[0]) ?? 0, r[s++] = (o == null ? void 0 : o[1]) ?? 0, r[s++] = (o == null ? void 0 : o[2]) ?? 0;
450
- const c = t.Ls, l = t.Is, u = t.Os, f = t.Bs, v = t.Hs, m = !(!l || !u);
451
- return m ? (r[s++] = (f == null ? void 0 : f[0]) ?? 0, r[s++] = (f == null ? void 0 : f[1]) ?? 0, r[s++] = (v == null ? void 0 : v[0]) ?? 0, r[s++] = (v == null ? void 0 : v[1]) ?? 0, r[s++] = l[0], r[s++] = l[1], r[s++] = u[0], r[s++] = u[1]) : !m && !!c ? (r[s++] = c[0], r[s++] = c[1], r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0) : (r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0), r[s++] = t.Gs ?? 0, r[s++] = t.Qs ?? 0, r[s++] = t.Ns ?? 0, r;
450
+ const c = t.Ls, l = t.Is, u = t.Bs, f = t.Os, g = t.Hs, m = !(!l || !u);
451
+ return m ? (r[s++] = (f == null ? void 0 : f[0]) ?? 0, r[s++] = (f == null ? void 0 : f[1]) ?? 0, r[s++] = (g == null ? void 0 : g[0]) ?? 0, r[s++] = (g == null ? void 0 : g[1]) ?? 0, r[s++] = l[0], r[s++] = l[1], r[s++] = u[0], r[s++] = u[1]) : !m && !!c ? (r[s++] = c[0], r[s++] = c[1], r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0) : (r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0, r[s++] = 0), r[s++] = t.Gs ?? 0, r[s++] = t.Qs ?? 0, r[s++] = t.Ns ?? 0, r;
452
452
  }
453
453
  static Xs(t, e) {
454
454
  const i = t.length * _.FLOATS_PER_INSTANCE, r = e || new Float32Array(i);
455
455
  for (let s = 0; s < t.length; s++) {
456
456
  const h = s * _.FLOATS_PER_INSTANCE;
457
- _.Ss(t[s], r, h);
457
+ _.Rs(t[s], r, h);
458
458
  }
459
459
  return r;
460
460
  }
@@ -464,8 +464,8 @@ let L = _;
464
464
  const P = class P {
465
465
  };
466
466
  a(P, "STRIDE", L.BYTES_PER_INSTANCE), a(P, "ATTRIBUTES", { A2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 0, divisor: 1 }, A3: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 8, divisor: 1 }, A4: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 16, divisor: 1 }, A5: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 28, divisor: 1 }, A6: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 44, divisor: 1 }, A7: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 60, divisor: 1 }, A8: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 76, divisor: 1 }, A9: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 88, divisor: 1 }, Aa: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 100, divisor: 1 }, Ab: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 116, divisor: 1 }, Ac: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: P.STRIDE, offset: 132, divisor: 1 } });
467
- let H = P;
468
- class ee {
467
+ let W = P;
468
+ class te {
469
469
  constructor(t = 1e3, e = 1.5) {
470
470
  a(this, "Ys");
471
471
  a(this, "js");
@@ -508,7 +508,7 @@ class ee {
508
508
  return this.Zs === 0;
509
509
  }
510
510
  }
511
- class ie {
511
+ class ee {
512
512
  constructor(t) {
513
513
  a(this, "Ys");
514
514
  this.Ys = t;
@@ -524,7 +524,7 @@ class ie {
524
524
  return this.Ys.ee;
525
525
  }
526
526
  }
527
- class re {
527
+ class ie {
528
528
  constructor(t, e = 1e3) {
529
529
  a(this, "A");
530
530
  a(this, "he", null);
@@ -536,7 +536,7 @@ class re {
536
536
  const e = this.A;
537
537
  this.he && e.deleteBuffer(this.he), this.he = e.createBuffer();
538
538
  const i = t * L.BYTES_PER_INSTANCE;
539
- Pt(e, e.ARRAY_BUFFER, this.he, i, e.DYNAMIC_DRAW), this.ae = t;
539
+ Ct(e, e.ARRAY_BUFFER, this.he, i, e.DYNAMIC_DRAW), this.ae = t;
540
540
  }
541
541
  ue(t) {
542
542
  this.le(t);
@@ -556,7 +556,7 @@ class re {
556
556
  if (!e) {
557
557
  e = /* @__PURE__ */ new Map();
558
558
  const i = this.A;
559
- for (const r in H.ATTRIBUTES) {
559
+ for (const r in W.ATTRIBUTES) {
560
560
  const s = i.getAttribLocation(t, r);
561
561
  s !== -1 && e.set(r, s);
562
562
  }
@@ -567,43 +567,43 @@ class re {
567
567
  ve(t) {
568
568
  const e = this.A, i = t.G, r = this.de(i);
569
569
  for (const [s, h] of r) {
570
- const o = H.ATTRIBUTES[s];
571
- o && dt(e, h, o.size, o.stride, o.offset, o.divisor, o.type, o.normalized);
570
+ const o = W.ATTRIBUTES[s];
571
+ o && ut(e, h, o.size, o.stride, o.offset, o.divisor, o.type, o.normalized);
572
572
  }
573
573
  }
574
574
  pe(t) {
575
575
  const e = this.A, i = this.de(t.G);
576
576
  for (const [r, s] of i)
577
- H.ATTRIBUTES[r] && (e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0));
577
+ W.ATTRIBUTES[r] && (e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0));
578
578
  }
579
579
  gt() {
580
580
  this.he && (this.A.deleteBuffer(this.he), this.he = null), this.ce.clear();
581
581
  }
582
582
  }
583
- class se {
583
+ class re {
584
584
  constructor(t, e = 1e3, i = 1.5) {
585
585
  a(this, "A");
586
586
  a(this, "Ys");
587
587
  a(this, "ge");
588
588
  a(this, "me");
589
- this.A = t, this.Ys = new ee(e, i), this.ge = new ie(this.Ys), this.me = new re(t, e);
589
+ this.A = t, this.Ys = new te(e, i), this.ge = new ee(this.Ys), this.me = new ie(t, e);
590
590
  }
591
591
  _e(t) {
592
- var r, s, h, o, c, l, u, f, v, m;
592
+ var r, s, h, o, c, l, u, f, g, m;
593
593
  const e = [0, 0, 0, 0], i = [0, 0, 0, 0];
594
- return t.Is && t.Os ? (e[0] = ((r = t.Bs) == null ? void 0 : r[0]) ?? 0, e[1] = ((s = t.Bs) == null ? void 0 : s[1]) ?? 0, e[2] = ((h = t.Hs) == null ? void 0 : h[0]) ?? 0, e[3] = ((o = t.Hs) == null ? void 0 : o[1]) ?? 0, i[0] = t.Is[0], i[1] = t.Is[1], i[2] = t.Os[0], i[3] = t.Os[1]) : t.Ls && (e[0] = t.Ls[0], e[1] = t.Ls[1]), this.oe({ x: t.bs[0], y: t.bs[1], width: t.Rs[0], height: t.Rs[1], char0: t.Nt[0], char1: t.Nt[1], char2: t.Nt[2], r1: t.Xt[0], g1: t.Xt[1], b1: t.Xt[2], a1: t.Xt[3], r2: t.Yt[0], g2: t.Yt[1], b2: t.Yt[2], a2: t.Yt[3], invert: t.ks[0], flipX: t.ks[1], flipY: t.ks[2], charRot: t.St, translationX: ((c = t.zs) == null ? void 0 : c[0]) ?? 0, translationY: ((l = t.zs) == null ? void 0 : l[1]) ?? 0, translationZ: ((u = t.zs) == null ? void 0 : u[2]) ?? 0, rotationX: ((f = t.Ds) == null ? void 0 : f[0]) ?? 0, rotationY: ((v = t.Ds) == null ? void 0 : v[1]) ?? 0, rotationZ: ((m = t.Ds) == null ? void 0 : m[2]) ?? 0, curveParams0: e, curveParams1: i, depth: t.Gs || 0, baseZ: t.Qs || 0, geometryType: t.Ns || 0 });
594
+ return t.Is && t.Bs ? (e[0] = ((r = t.Os) == null ? void 0 : r[0]) ?? 0, e[1] = ((s = t.Os) == null ? void 0 : s[1]) ?? 0, e[2] = ((h = t.Hs) == null ? void 0 : h[0]) ?? 0, e[3] = ((o = t.Hs) == null ? void 0 : o[1]) ?? 0, i[0] = t.Is[0], i[1] = t.Is[1], i[2] = t.Bs[0], i[3] = t.Bs[1]) : t.Ls && (e[0] = t.Ls[0], e[1] = t.Ls[1]), this.oe({ x: t.bs[0], y: t.bs[1], width: t.Ss[0], height: t.Ss[1], char0: t.Nt[0], char1: t.Nt[1], char2: t.Nt[2], r1: t.Xt[0], g1: t.Xt[1], b1: t.Xt[2], a1: t.Xt[3], r2: t.Yt[0], g2: t.Yt[1], b2: t.Yt[2], a2: t.Yt[3], invert: t.ks[0], flipX: t.ks[1], flipY: t.ks[2], charRot: t.Rt, translationX: ((c = t.zs) == null ? void 0 : c[0]) ?? 0, translationY: ((l = t.zs) == null ? void 0 : l[1]) ?? 0, translationZ: ((u = t.zs) == null ? void 0 : u[2]) ?? 0, rotationX: ((f = t.Ds) == null ? void 0 : f[0]) ?? 0, rotationY: ((g = t.Ds) == null ? void 0 : g[1]) ?? 0, rotationZ: ((m = t.Ds) == null ? void 0 : m[2]) ?? 0, curveParams0: e, curveParams1: i, depth: t.Gs || 0, baseZ: t.Qs || 0, geometryType: t.Ns || 0 });
595
595
  }
596
596
  oe(t) {
597
597
  const e = this.ge.oe(t);
598
598
  return this.Ys.ie > this.me.ie && this.me.ue(this.Ys.ie), e;
599
599
  }
600
- get ye() {
600
+ get Ae() {
601
601
  return this.Ys.ee;
602
602
  }
603
603
  get ne() {
604
604
  return this.Ys.ne;
605
605
  }
606
- Ae() {
606
+ ye() {
607
607
  this.Ys.te();
608
608
  }
609
609
  ve(t) {
@@ -623,7 +623,7 @@ class se {
623
623
  this.me.gt();
624
624
  }
625
625
  }
626
- class I {
626
+ class B {
627
627
  constructor(t, e, i, r) {
628
628
  a(this, "A");
629
629
  a(this, "we");
@@ -632,7 +632,7 @@ class I {
632
632
  a(this, "xe", null);
633
633
  this.A = t, this.we = e, this.be = i, this.Ce = r;
634
634
  const s = this.A.createBuffer();
635
- Pt(this.A, this.A.ARRAY_BUFFER, s, this.Ce.Me, this.A.STATIC_DRAW), this.xe = s;
635
+ Ct(this.A, this.A.ARRAY_BUFFER, s, this.Ce.Me, this.A.STATIC_DRAW), this.xe = s;
636
636
  }
637
637
  get type() {
638
638
  return this.be;
@@ -647,7 +647,7 @@ class I {
647
647
  return this.we;
648
648
  }
649
649
  Fe() {
650
- this.we.Ae();
650
+ this.we.ye();
651
651
  }
652
652
  Pe() {
653
653
  return !this.we.ne;
@@ -659,90 +659,90 @@ class I {
659
659
  return this.we._e(t);
660
660
  }
661
661
  Te(t, e, i, r, s, h) {
662
- const o = s.Ot ?? 0, c = s.Bt ?? 0, l = s.Ht ?? 0, u = s.bt ?? 0, f = s.Ct ?? 0, v = s.xt ?? 0, m = [0, 0, 0, 0], d = [0, 0, 0, 0];
662
+ const o = s.Bt ?? 0, c = s.Ot ?? 0, l = s.Ht ?? 0, u = s.bt ?? 0, f = s.Ct ?? 0, g = s.xt ?? 0, m = [0, 0, 0, 0], d = [0, 0, 0, 0];
663
663
  h && (h.bezStartX !== void 0 && h.bezStartY !== void 0 && h.bezEndX !== void 0 && h.bezEndY !== void 0 ? (m[0] = h.cp1x ?? 0, m[1] = h.cp1y ?? 0, m[2] = h.cp2x ?? 0, m[3] = h.cp2y ?? 0, d[0] = h.bezStartX ?? 0, d[1] = h.bezStartY ?? 0, d[2] = h.bezEndX ?? 0, d[3] = h.bezEndY ?? 0) : h.arcStart === void 0 && h.arcStop === void 0 || (m[0] = h.arcStart ?? 0, m[1] = h.arcStop ?? 0));
664
- const g = { x: t, y: e, width: i, height: r, char0: s.Nt[0], char1: s.Nt[1], char2: s.Nt[2], r1: s.Xt[0], g1: s.Xt[1], b1: s.Xt[2], a1: s.Xt[3], r2: s.Yt[0], g2: s.Yt[1], b2: s.Yt[2], a2: s.Yt[3], invert: s.Et ? 1 : 0, flipX: s.Gt ? 1 : 0, flipY: s.Qt ? 1 : 0, charRot: s.St, translationX: o, translationY: c, translationZ: l, rotationX: u, rotationY: f, rotationZ: v, curveParams0: m, curveParams1: d, depth: (h == null ? void 0 : h.depth) ?? 0, baseZ: (h == null ? void 0 : h.baseZ) ?? 0, geometryType: $t[this.be] ?? 0 };
665
- return this.we.oe(g);
664
+ const v = { x: t, y: e, width: i, height: r, char0: s.Nt[0], char1: s.Nt[1], char2: s.Nt[2], r1: s.Xt[0], g1: s.Xt[1], b1: s.Xt[2], a1: s.Xt[3], r2: s.Yt[0], g2: s.Yt[1], b2: s.Yt[2], a2: s.Yt[3], invert: s.Et ? 1 : 0, flipX: s.Gt ? 1 : 0, flipY: s.Qt ? 1 : 0, charRot: s.Rt, translationX: o, translationY: c, translationZ: l, rotationX: u, rotationY: f, rotationZ: g, curveParams0: m, curveParams1: d, depth: (h == null ? void 0 : h.depth) ?? 0, baseZ: (h == null ? void 0 : h.baseZ) ?? 0, geometryType: Jt[this.be] ?? 0 };
665
+ return this.we.oe(v);
666
666
  }
667
667
  }
668
- const ne = { Me: gt, Ee: 6, ...Q }, he = { Me: 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]), Ee: 6, ...Q }, oe = { Me: function(n = 32) {
668
+ const se = { Me: ft, Ee: 6, ...O }, ne = { Me: 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]), Ee: 6, ...O }, he = { Me: function(n = 32) {
669
669
  const t = [], e = 2 * Math.PI / n;
670
670
  for (let i = 0; i < n; i++) {
671
- const r = i * e, s = (i + 1) % n * e, h = Math.cos(r), o = Math.sin(r), c = 0.5 * (h + 1), l = 0.5 * (o + 1), u = Math.cos(s), f = Math.sin(s), v = 0.5 * (u + 1), m = 0.5 * (f + 1);
672
- t.push(0, 0, 0.5, 0.5, h, o, c, l, u, f, v, m);
671
+ const r = i * e, s = (i + 1) % n * e, h = Math.cos(r), o = Math.sin(r), c = 0.5 * (h + 1), l = 0.5 * (o + 1), u = Math.cos(s), f = Math.sin(s), g = 0.5 * (u + 1), m = 0.5 * (f + 1);
672
+ t.push(0, 0, 0.5, 0.5, h, o, c, l, u, f, g, m);
673
673
  }
674
674
  return new Float32Array(t);
675
- }(32), Ee: 96, ...Q };
676
- let ae = { Me: function(n) {
675
+ }(32), Ee: 96, ...O };
676
+ let oe = { Me: function(n) {
677
677
  const t = [];
678
678
  for (let e = 0; e < n; e++) {
679
679
  const i = e / n, r = (e + 1) / n;
680
680
  t.push(i, 0, i, 0, i, 1, i, 1, r, 1, r, 1);
681
681
  }
682
682
  return new Float32Array(t);
683
- }(32), Ee: 96, ...Q };
684
- const ce = { Me: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Ee: 3, ...Q }, le = { Me: function(n = 16) {
683
+ }(32), Ee: 96, ...O };
684
+ const ae = { Me: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Ee: 3, ...O }, ce = { Me: function(n = 16) {
685
685
  const t = [];
686
686
  for (let e = 0; e < n; e++) {
687
687
  const i = e / n, r = (e + 1) / n;
688
688
  t.push(i, -0.5, i, 0, r, -0.5, r, 0, i, 0.5, i, 1, i, 0.5, i, 1, r, -0.5, r, 0, r, 0.5, r, 1);
689
689
  }
690
690
  return new Float32Array(t);
691
- }(16), Ee: 96, ...Q }, ue = { [w.RECTANGLE]: class extends I {
691
+ }(16), Ee: 96, ...O }, le = { [b.RECTANGLE]: class extends B {
692
692
  constructor(n, t) {
693
- super(n, t, w.RECTANGLE, ne);
693
+ super(n, t, b.RECTANGLE, se);
694
694
  }
695
695
  _e(n, t) {
696
696
  return this.Te(0, 0, n.width, n.height, t);
697
697
  }
698
- }, [w.LINE]: class extends I {
698
+ }, [b.LINE]: class extends B {
699
699
  constructor(n, t) {
700
- super(n, t, w.LINE, he);
700
+ super(n, t, b.LINE, ne);
701
701
  }
702
702
  _e(n, t) {
703
703
  const e = n.x2 - n.x1, i = n.y2 - n.y1, r = Math.hypot(e, i), s = Math.atan2(i, e), h = t.It || 1, o = n.x1 + e / 2 - r / 2, c = n.y1 + i / 2, l = { ...t, xt: (t.xt || 0) + s };
704
704
  return this.Te(o, c, r, h, l);
705
705
  }
706
- }, [w.ELLIPSE]: class extends I {
706
+ }, [b.ELLIPSE]: class extends B {
707
707
  constructor(n, t) {
708
- super(n, t, w.ELLIPSE, oe);
708
+ super(n, t, b.ELLIPSE, he);
709
709
  }
710
710
  _e(n, t) {
711
711
  return this.Te(0, 0, n.width, n.height, t);
712
712
  }
713
- }, [w.ARC]: class extends I {
713
+ }, [b.ARC]: class extends B {
714
714
  constructor(n, t) {
715
- super(n, t, w.ARC, ae);
715
+ super(n, t, b.ARC, oe);
716
716
  }
717
717
  _e(n, t) {
718
718
  const e = n.start * Math.PI / 180, i = n.stop * Math.PI / 180;
719
719
  return this.Te(0, 0, n.width, n.height, t, { arcStart: e, arcStop: i });
720
720
  }
721
- }, [w.TRIANGLE]: class extends I {
721
+ }, [b.TRIANGLE]: class extends B {
722
722
  constructor(n, t) {
723
- super(n, t, w.TRIANGLE, ce);
723
+ super(n, t, b.TRIANGLE, ae);
724
724
  }
725
725
  _e(n, t) {
726
726
  const e = Math.min(n.x1, n.x2, n.x3), i = Math.max(n.x1, n.x2, n.x3), r = Math.min(n.y1, n.y2, n.y3), s = i - e, h = Math.max(n.y1, n.y2, n.y3) - r;
727
727
  return this.Te(e, r, s, h, t);
728
728
  }
729
- }, [w.BEZIER_CURVE]: class extends I {
729
+ }, [b.BEZIER_CURVE]: class extends B {
730
730
  constructor(n, t) {
731
- super(n, t, w.BEZIER_CURVE, le);
731
+ super(n, t, b.BEZIER_CURVE, ce);
732
732
  }
733
733
  _e(n, t) {
734
734
  return this.Te(0, 0, 1, t.It || 1, t, { cp1x: n.cp1x, cp1y: n.cp1y, cp2x: n.cp2x, cp2y: n.cp2y, bezStartX: n.x1, bezStartY: n.y1, bezEndX: n.x2, bezEndY: n.y2 });
735
735
  }
736
736
  } };
737
- class fe {
737
+ class ue {
738
738
  constructor(t) {
739
739
  a(this, "A");
740
- a(this, "Se");
741
740
  a(this, "Re");
742
- this.A = t, this.Re = new te(t), this.Se = /* @__PURE__ */ new Map();
743
- for (const e of Object.values(w)) {
744
- const i = new se(t), r = new ue[e](t, i);
745
- this.Se.set(e, r);
741
+ a(this, "Se");
742
+ this.A = t, this.Se = new $t(t), this.Re = /* @__PURE__ */ new Map();
743
+ for (const e of Object.values(b)) {
744
+ const i = new re(t), r = new le[e](t, i);
745
+ this.Re.set(e, r);
746
746
  }
747
747
  }
748
748
  ke(t) {
@@ -756,71 +756,71 @@ class fe {
756
756
  return i && i.length > 0 && e.push({ material: r, type: s, commands: i }), e;
757
757
  }
758
758
  De(t) {
759
- const { material: e, type: i, commands: r } = t, s = this.Se.get(i);
759
+ const { material: e, type: i, commands: r } = t, s = this.Re.get(i);
760
760
  e.shader.D(), e.shader.I(e.uniforms);
761
- const h = Ut(this.A), o = r.length > 0 && r[0].state.kt;
762
- e.shader.I({ Uz: h[2] / h[3], Ug: [h[2], h[3]], Uh: 1, Ui: o ? 1 : 0 }), s.Fe();
761
+ const h = Pt(this.A), o = r.length > 0 && r[0].state.kt;
762
+ e.shader.I({ Uw: h[2] / h[3], Uc: [h[2], h[3]], Ud: 1, Ue: o ? 1 : 0 }), s.Fe();
763
763
  for (const c of r) s._e(c.params, c.state);
764
764
  if (s.Pe()) {
765
765
  const c = s.unitGeometry, l = s.unitBuffer;
766
766
  try {
767
- this.Re.Ts(e.shader.G, i + "", c, l), s.batch.ve(e.shader), s.batch.Ps(c.As, c.Ee);
767
+ this.Se.Ts(e.shader.G, i + "", c, l), s.batch.ve(e.shader), s.batch.Ps(c.As, c.Ee);
768
768
  } finally {
769
- s.batch.pe(e.shader), this.Re.Es(), s.Fe();
769
+ s.batch.pe(e.shader), this.Se.Es(), s.Fe();
770
770
  }
771
771
  }
772
772
  }
773
773
  gt() {
774
- for (const t of this.Se.values()) t.gt();
775
- this.Se.clear(), this.Re.gt();
774
+ for (const t of this.Re.values()) t.gt();
775
+ this.Re.clear(), this.Se.gt();
776
776
  }
777
777
  }
778
- function Nt(n) {
778
+ function Mt(n) {
779
779
  let t = 0;
780
780
  for (let e = 0; e < n.length; e++)
781
781
  t = (t << 5) - t + n.charCodeAt(e), t &= t;
782
782
  return t;
783
783
  }
784
784
  const wt = /* @__PURE__ */ new WeakMap();
785
- let de = 1;
786
- function xt(n) {
785
+ let fe = 1;
786
+ function Et(n) {
787
787
  if (n == null) return 0;
788
- if (typeof n != "object" && typeof n != "function") return Nt(n + "");
788
+ if (typeof n != "object" && typeof n != "function") return Mt(n + "");
789
789
  let t = wt.get(n);
790
- return t || (t = de++, wt.set(n, t)), t;
790
+ return t || (t = fe++, wt.set(n, t)), t;
791
791
  }
792
- function q(n, t) {
792
+ function V(n, t) {
793
793
  return (n << 5) - n + t;
794
794
  }
795
- class ge {
795
+ class de {
796
796
  constructor(t) {
797
797
  a(this, "Le", 0);
798
798
  a(this, "Ie");
799
- a(this, "Oe");
800
- a(this, "Be", /* @__PURE__ */ new Map());
801
- this.Ie = new k(t, st, `#version 300 es
802
- precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellColor;in vec4 v_glyphFlags;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 A;void main(){int B=int(v_glyphFlags.r>0.5?1:0);int C=int(v_glyphFlags.g>0.5?1:0);int D=int(v_glyphFlags.b>0.5?1:0);float E=float(B|(C<<1)|(D<<2))/255.;o_character=vec4(v_glyphIndex.xy,E,clamp(v_glyphFlags.a,0.,1.));o_primaryColor=vec4(v_glyphColor.rgb,v_glyphColor.a);o_secondaryColor=vec4(v_cellColor.rgb,v_cellColor.a);A=vec4(0.);}`), this.Oe = { id: this.Le++, shader: this.Ie, uniforms: Object.freeze({}), hash: this.He(this.Ie, {}), isBuiltIn: !0 };
799
+ a(this, "Be");
800
+ a(this, "Oe", /* @__PURE__ */ new Map());
801
+ this.Ie = new k(t, it, `#version 300 es
802
+ precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellColor;in vec4 v_glyphFlags;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 A;void main(){int B=int(v_glyphFlags.r>0.5?1:0);int C=int(v_glyphFlags.g>0.5?1:0);int D=int(v_glyphFlags.b>0.5?1:0);float E=float(B|(C<<1)|(D<<2))/255.;o_character=vec4(v_glyphIndex.xy,E,clamp(v_glyphFlags.a,0.,1.));o_primaryColor=vec4(v_glyphColor.rgb,v_glyphColor.a);o_secondaryColor=vec4(v_cellColor.rgb,v_cellColor.a);A=vec4(0.);}`), this.Be = { id: this.Le++, shader: this.Ie, uniforms: Object.freeze({}), hash: this.He(this.Ie, {}), isBuiltIn: !0 };
803
803
  }
804
804
  get Ge() {
805
- return this.Oe;
805
+ return this.Be;
806
806
  }
807
807
  dt(t, e = {}, i = !1) {
808
- const r = this.He(t, e), s = this.Be.get(r);
808
+ const r = this.He(t, e), s = this.Oe.get(r);
809
809
  if (s) return s;
810
810
  const h = { id: this.Le++, shader: t, uniforms: Object.freeze({ ...e }), hash: r, isBuiltIn: i };
811
- return this.Be.set(r, h), h;
811
+ return this.Oe.set(r, h), h;
812
812
  }
813
813
  Qe(t, e = {}) {
814
814
  return { id: this.Le++, shader: t, uniforms: Object.freeze({ ...e }), hash: 0, isBuiltIn: !1 };
815
815
  }
816
816
  He(t, e) {
817
- const i = xt(t.G), r = function(s, h) {
817
+ const i = Et(t.G), r = function(s, h) {
818
818
  let o = 0;
819
819
  const c = Object.keys(s).sort();
820
- for (const l of c) o = q(o, Nt(l)), o = q(o, h(s[l]));
820
+ for (const l of c) o = V(o, Mt(l)), o = V(o, h(s[l]));
821
821
  return o;
822
822
  }(e, this.Ne.bind(this));
823
- return q(i, r);
823
+ return V(i, r);
824
824
  }
825
825
  Ne(t) {
826
826
  return typeof t == "number" || typeof t == "boolean" ? function(e) {
@@ -828,63 +828,63 @@ precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellCo
828
828
  }(t) : Array.isArray(t) ? function(e) {
829
829
  let i = 0;
830
830
  const r = Array.isArray(e[0]) ? e.flat() : e;
831
- for (const s of r) i = q(i, typeof s == "number" ? s : 0);
831
+ for (const s of r) i = V(i, typeof s == "number" ? s : 0);
832
832
  return i;
833
833
  }(t) : t instanceof Float32Array || t instanceof Int32Array ? function(e) {
834
834
  let i = 0;
835
835
  const r = Math.min(e.length, 16);
836
- for (let s = 0; s < r; s++) i = q(i, e[s]);
836
+ for (let s = 0; s < r; s++) i = V(i, e[s]);
837
837
  return i;
838
- }(t) : t instanceof WebGLTexture ? xt(t) : 0;
838
+ }(t) : t instanceof WebGLTexture ? Et(t) : 0;
839
839
  }
840
840
  gt() {
841
- this.Ie != this.Ie && this.Ie.dispose(), this.Ie.dispose(), this.Be.clear();
841
+ this.Ie != this.Ie && this.Ie.dispose(), this.Ie.dispose(), this.Oe.clear();
842
842
  }
843
843
  }
844
- class ve {
844
+ class ge {
845
845
  constructor() {
846
846
  a(this, "Xe", []);
847
847
  a(this, "Ye", 1);
848
- a(this, "Rs", 0);
848
+ a(this, "Ss", 0);
849
849
  }
850
850
  je(t, e) {
851
- if (this.Rs >= this.Xe.length) {
852
- const r = { id: this.Ye++, type: t, params: {}, state: nt.Lt(), material: e };
851
+ if (this.Ss >= this.Xe.length) {
852
+ const r = { id: this.Ye++, type: t, params: {}, state: rt.Lt(), material: e };
853
853
  this.Xe.push(r);
854
854
  }
855
- const i = this.Xe[this.Rs];
856
- return i.id = this.Ye++, i.type = t, i.material = e, this.Rs++, i;
855
+ const i = this.Xe[this.Ss];
856
+ return i.id = this.Ye++, i.type = t, i.material = e, this.Ss++, i;
857
857
  }
858
858
  Ke(t, e, i) {
859
- const r = this.je(w.RECTANGLE, i), s = r.params;
859
+ const r = this.je(b.RECTANGLE, i), s = r.params;
860
860
  return s.width = t.width, s.height = t.height, e.Wt(r.state), r.id;
861
861
  }
862
862
  We(t, e, i) {
863
- const r = this.je(w.LINE, i), s = r.params;
863
+ const r = this.je(b.LINE, i), s = r.params;
864
864
  return s.x1 = t.x1, s.y1 = t.y1, s.x2 = t.x2, s.y2 = t.y2, s.thickness = t.thickness, e.Wt(r.state), r.id;
865
865
  }
866
866
  Ze(t, e, i) {
867
- const r = this.je(w.ELLIPSE, i), s = r.params;
867
+ const r = this.je(b.ELLIPSE, i), s = r.params;
868
868
  return s.width = t.width, s.height = t.height, s.startAngle = t.startAngle, s.endAngle = t.endAngle, s.segments = t.segments, e.Wt(r.state), r.id;
869
869
  }
870
870
  qe(t, e, i) {
871
- const r = this.je(w.ARC, i), s = r.params;
871
+ const r = this.je(b.ARC, i), s = r.params;
872
872
  return s.width = t.width, s.height = t.height, s.start = t.start, s.stop = t.stop, e.Wt(r.state), r.id;
873
873
  }
874
874
  Ve(t, e, i) {
875
- const r = this.je(w.TRIANGLE, i), s = r.params;
875
+ const r = this.je(b.TRIANGLE, i), s = r.params;
876
876
  return s.x1 = t.x1, s.y1 = t.y1, s.x2 = t.x2, s.y2 = t.y2, s.x3 = t.x3, s.y3 = t.y3, e.Wt(r.state), r.id;
877
877
  }
878
878
  Je(t, e, i) {
879
- const r = this.je(w.BEZIER_CURVE, i), s = r.params;
879
+ const r = this.je(b.BEZIER_CURVE, i), s = r.params;
880
880
  return s.x1 = t.x1, s.y1 = t.y1, s.cp1x = t.cp1x, s.cp1y = t.cp1y, s.cp2x = t.cp2x, s.cp2y = t.cp2y, s.x2 = t.x2, s.y2 = t.y2, s.thickness = t.thickness, s.segments = t.segments, e.Wt(r.state), r.id;
881
881
  }
882
- Ae() {
883
- this.Rs = 0;
882
+ ye() {
883
+ this.Ss = 0;
884
884
  }
885
885
  [Symbol.iterator]() {
886
886
  let t = 0;
887
- const e = this.Rs, i = this.Xe;
887
+ const e = this.Ss, i = this.Xe;
888
888
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
889
889
  }
890
890
  }
@@ -905,9 +905,9 @@ class me {
905
905
  a(this, "li", null);
906
906
  a(this, "ui", [0, 0, 0, 0]);
907
907
  a(this, "fi", 1);
908
- this.A = t, t.enable(t.DEPTH_TEST), t.depthFunc(t.LEQUAL), t.clearDepth(1), t.depthMask(!0), t.disable(t.CULL_FACE), this.ei = new nt(), this.vt = new ge(t), this.ii = new ve(), this.si = new fe(t), this.ri = new Jt(t);
908
+ this.A = t, t.enable(t.DEPTH_TEST), t.depthFunc(t.LEQUAL), t.clearDepth(1), t.depthMask(!0), t.disable(t.CULL_FACE), this.ei = new rt(), this.vt = new de(t), this.ii = new ge(), this.si = new ue(t), this.ri = new qt(t);
909
909
  const e = [0, 0, t.canvas.width, t.canvas.height];
910
- ot(t, e), this.hi.push(null), this.ai.push(e), this.ci.push(1), this.li = null, this.ui = e, this.fi = 1;
910
+ nt(t, e), this.hi.push(null), this.ai.push(e), this.ci.push(1), this.li = null, this.ui = e, this.fi = 1;
911
911
  }
912
912
  rt() {
913
913
  this.hi.push(this.li), this.ai.push([...this.ui]), this.ci.push(this.fi);
@@ -920,7 +920,7 @@ class me {
920
920
  const s = this.A;
921
921
  this.li !== t && (s.bindFramebuffer(s.FRAMEBUFFER, t), this.li = t), this.fi = r;
922
922
  const h = [0, 0, e, i];
923
- this.ui[0] === h[0] && this.ui[1] === h[1] && this.ui[2] === h[2] && this.ui[3] === h[3] || (s.viewport(...h), ot(s, h), this.ui = h);
923
+ this.ui[0] === h[0] && this.ui[1] === h[1] && this.ui[2] === h[2] && this.ui[3] === h[3] || (s.viewport(...h), nt(s, h), this.ui = h);
924
924
  }
925
925
  di(t) {
926
926
  this.ti !== t && (this.ti = t, t.D());
@@ -938,12 +938,12 @@ class me {
938
938
  Object.assign(this.oi, t);
939
939
  }
940
940
  _i(t) {
941
- return new k(this.A, st, t);
941
+ return new k(this.A, it, t);
942
942
  }
943
- yi(t, e, i) {
943
+ Ai(t, e, i) {
944
944
  this.ii.Ke({ width: e ?? t.width, height: i ?? t.height }, this.ei, t.ut());
945
945
  }
946
- Ai(t, e, i, r) {
946
+ yi(t, e, i, r) {
947
947
  this.ri.Ps(t, e, i, r);
948
948
  }
949
949
  wi(t, e) {
@@ -968,14 +968,14 @@ class me {
968
968
  this.ii.qe({ width: t, height: e, start: i, stop: r }, this.ei, this.vt.Ge);
969
969
  }
970
970
  Pi(t, e, i = 1, r = {}) {
971
- return new j(this.A, t, e, i, r, this);
971
+ return new H(this.A, t, e, i, r, this);
972
972
  }
973
973
  $i(t, e = t, i = t, r = 255) {
974
974
  this.ei.ps(t, e ?? t, i ?? t, r);
975
975
  const [s, h, o, c] = this.ei.canvasBackgroundColor;
976
976
  this.Ti(s, h, o, c, !1);
977
977
  }
978
- Ae(t = 0, e = 0, i = 0, r = 0) {
978
+ ye(t = 0, e = 0, i = 0, r = 0) {
979
979
  this.Ti(t, e, i, r, !0);
980
980
  }
981
981
  Ti(t, e, i, r, s) {
@@ -988,11 +988,11 @@ class me {
988
988
  }
989
989
  Ei() {
990
990
  const t = [0, 0, this.A.canvas.width, this.A.canvas.height];
991
- this.A.viewport(...t), ot(this.A, t), this.ui = t, this.ai.length > 0 && (this.ai[0] = t);
991
+ this.A.viewport(...t), nt(this.A, t), this.ui = t, this.ai.length > 0 && (this.ai[0] = t);
992
992
  }
993
993
  ct() {
994
994
  const t = this.ii;
995
- this.si.ke(t), t.Ae(), this.ti = null;
995
+ this.si.ke(t), t.ye(), this.ti = null;
996
996
  }
997
997
  gt() {
998
998
  this.vt.gt(), this.si.gt(), this.ri.gt();
@@ -1007,13 +1007,13 @@ class me {
1007
1007
  return this.vt;
1008
1008
  }
1009
1009
  }
1010
- const F = { readShort: (n, t) => (F.t.uint16[0] = n[t] << 8 | n[t + 1], F.t.int16[0]), readUshort: (n, t) => n[t] << 8 | n[t + 1], readUshorts(n, t, e) {
1010
+ const R = { readShort: (n, t) => (R.t.uint16[0] = n[t] << 8 | n[t + 1], R.t.int16[0]), readUshort: (n, t) => n[t] << 8 | n[t + 1], readUshorts(n, t, e) {
1011
1011
  const i = [];
1012
- for (let r = 0; r < e; r++) i.push(F.readUshort(n, t + 2 * r));
1012
+ for (let r = 0; r < e; r++) i.push(R.readUshort(n, t + 2 * r));
1013
1013
  return i;
1014
1014
  }, readUint(n, t) {
1015
- const e = F.t.uint8;
1016
- return e[3] = n[t], e[2] = n[t + 1], e[1] = n[t + 2], e[0] = n[t + 3], F.t.uint32[0];
1015
+ const e = R.t.uint8;
1016
+ return e[3] = n[t], e[2] = n[t + 1], e[1] = n[t + 2], e[0] = n[t + 3], R.t.uint32[0];
1017
1017
  }, readASCII(n, t, e) {
1018
1018
  let i = "";
1019
1019
  for (let r = 0; r < e; r++) i += String.fromCharCode(n[t + r]);
@@ -1022,22 +1022,22 @@ const F = { readShort: (n, t) => (F.t.uint16[0] = n[t] << 8 | n[t + 1], F.t.int1
1022
1022
  const n = new ArrayBuffer(8);
1023
1023
  return { uint8: new Uint8Array(n), int16: new Int16Array(n), uint16: new Uint16Array(n), uint32: new Uint32Array(n) };
1024
1024
  })() };
1025
- function $(n) {
1025
+ function q(n) {
1026
1026
  return n + 3 & -4;
1027
1027
  }
1028
- function tt(n, t, e) {
1028
+ function J(n, t, e) {
1029
1029
  n[t] = e >>> 8 & 255, n[t + 1] = 255 & e;
1030
1030
  }
1031
1031
  function D(n, t, e) {
1032
1032
  n[t] = e >>> 24 & 255, n[t + 1] = e >>> 16 & 255, n[t + 2] = e >>> 8 & 255, n[t + 3] = 255 & e;
1033
1033
  }
1034
- function pe(n, t, e) {
1034
+ function ve(n, t, e) {
1035
1035
  for (let i = 0; i < e.length; i++) n[t + i] = 255 & e.charCodeAt(i);
1036
1036
  }
1037
- function at(n, t, e) {
1037
+ function ht(n, t, e) {
1038
1038
  const i = t + e;
1039
1039
  let r = 0;
1040
- const s = F.t;
1040
+ const s = R.t;
1041
1041
  for (let h = t; h < i; h += 4) s.uint8[3] = n[h] || 0, s.uint8[2] = n[h + 1] || 0, s.uint8[1] = n[h + 2] || 0, s.uint8[0] = n[h + 3] || 0, r = r + (s.uint32[0] >>> 0) >>> 0;
1042
1042
  return r >>> 0;
1043
1043
  }
@@ -1064,7 +1064,7 @@ class Ae {
1064
1064
  return this.p;
1065
1065
  }
1066
1066
  }
1067
- function W(n) {
1067
+ function G(n) {
1068
1068
  let t = 32, e = 0;
1069
1069
  for (const o of n) o && (o < t && (t = o), o > e && (e = o));
1070
1070
  if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
@@ -1080,11 +1080,11 @@ function W(n) {
1080
1080
  if (!c) continue;
1081
1081
  const l = r[c]++;
1082
1082
  let u = h.get(c);
1083
- u || (u = [], h.set(c, u)), u[Ee(l, c)] = o;
1083
+ u || (u = [], h.set(c, u)), u[pe(l, c)] = o;
1084
1084
  }
1085
1085
  return { min: t, max: e, table: h };
1086
1086
  }
1087
- function ct(n, t) {
1087
+ function ot(n, t) {
1088
1088
  let e = 0;
1089
1089
  for (let i = 1; i <= t.max; i++) {
1090
1090
  e |= n.readBits(1) << i - 1;
@@ -1096,7 +1096,7 @@ function ct(n, t) {
1096
1096
  }
1097
1097
  throw Error("Invalid Huffman code");
1098
1098
  }
1099
- function Ee(n, t) {
1099
+ function pe(n, t) {
1100
1100
  let e = 0;
1101
1101
  for (let i = 0; i < t; i++) e = e << 1 | 1 & n, n >>>= 1;
1102
1102
  return e >>> 0;
@@ -1114,66 +1114,66 @@ function ye(n) {
1114
1114
  let f = 0;
1115
1115
  for (; !f; ) {
1116
1116
  f = s.readBits(1);
1117
- const v = s.readBits(2);
1118
- if (v === 0) {
1117
+ const g = s.readBits(2);
1118
+ if (g === 0) {
1119
1119
  s.alignToByte();
1120
1120
  const m = s.readBits(16);
1121
1121
  if ((65535 & (65535 ^ m)) !== s.readBits(16)) throw Error("DEFLATE uncompressed LEN/NLEN mismatch");
1122
1122
  for (let d = 0; d < m; d++) h.push(s.readBits(8));
1123
1123
  } else {
1124
- if (v !== 1 && v !== 2) throw Error("Unsupported DEFLATE type");
1124
+ if (g !== 1 && g !== 2) throw Error("Unsupported DEFLATE type");
1125
1125
  {
1126
1126
  let m, d;
1127
- if (v === 1) {
1128
- const g = Array(288).fill(0);
1129
- for (let A = 0; A <= 143; A++) g[A] = 8;
1130
- for (let A = 144; A <= 255; A++) g[A] = 9;
1131
- for (let A = 256; A <= 279; A++) g[A] = 7;
1132
- for (let A = 280; A <= 287; A++) g[A] = 8;
1133
- m = W(g), d = W(Array(32).fill(5));
1127
+ if (g === 1) {
1128
+ const v = Array(288).fill(0);
1129
+ for (let p = 0; p <= 143; p++) v[p] = 8;
1130
+ for (let p = 144; p <= 255; p++) v[p] = 9;
1131
+ for (let p = 256; p <= 279; p++) v[p] = 7;
1132
+ for (let p = 280; p <= 287; p++) v[p] = 8;
1133
+ m = G(v), d = G(Array(32).fill(5));
1134
1134
  } else {
1135
- const g = s.readBits(5) + 257, A = s.readBits(5) + 1, p = s.readBits(4) + 4, y = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], E = Array(19).fill(0);
1136
- for (let T = 0; T < p; T++) E[y[T]] = s.readBits(3);
1137
- const x = W(E), b = [];
1138
- for (; b.length < g + A; ) {
1139
- const T = ct(s, x);
1140
- if (T <= 15) b.push(T);
1135
+ const v = s.readBits(5) + 257, p = s.readBits(5) + 1, A = s.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);
1136
+ for (let T = 0; T < A; T++) y[w[T]] = s.readBits(3);
1137
+ const x = G(y), E = [];
1138
+ for (; E.length < v + p; ) {
1139
+ const T = ot(s, x);
1140
+ if (T <= 15) E.push(T);
1141
1141
  else if (T === 16) {
1142
- const S = s.readBits(2) + 3, C = b[b.length - 1] || 0;
1143
- for (let J = 0; J < S; J++) b.push(C);
1142
+ const S = s.readBits(2) + 3, F = E[E.length - 1] || 0;
1143
+ for (let K = 0; K < S; K++) E.push(F);
1144
1144
  } else if (T === 17) {
1145
1145
  const S = s.readBits(3) + 3;
1146
- for (let C = 0; C < S; C++) b.push(0);
1146
+ for (let F = 0; F < S; F++) E.push(0);
1147
1147
  } else {
1148
1148
  if (T !== 18) throw Error("Invalid code length symbol");
1149
1149
  {
1150
1150
  const S = s.readBits(7) + 11;
1151
- for (let C = 0; C < S; C++) b.push(0);
1151
+ for (let F = 0; F < S; F++) E.push(0);
1152
1152
  }
1153
1153
  }
1154
1154
  }
1155
- const R = b.slice(0, g), U = b.slice(g, g + A);
1156
- m = W(R), d = W(U);
1155
+ const C = E.slice(0, v), N = E.slice(v, v + p);
1156
+ m = G(C), d = G(N);
1157
1157
  }
1158
1158
  for (; ; ) {
1159
- const g = ct(s, m);
1160
- if (g < 256) h.push(g);
1159
+ const v = ot(s, m);
1160
+ if (v < 256) h.push(v);
1161
1161
  else {
1162
- if (g === 256) break;
1163
- if (g > 256 && g < 286) {
1164
- const A = g - 257;
1165
- let p = o[A];
1166
- const y = c[A];
1167
- y && (p += s.readBits(y));
1168
- const E = ct(s, d);
1169
- if (E >= 30) throw Error("Invalid distance symbol");
1170
- let x = l[E];
1171
- const b = u[E];
1172
- b && (x += s.readBits(b));
1173
- const R = h.length - x;
1174
- if (R < 0) throw Error("Invalid distance");
1175
- for (let U = 0; U < p; U++) h.push(h[R + U] || 0);
1176
- } else if (g === 286 || g === 287) throw Error("Reserved length symbol");
1162
+ if (v === 256) break;
1163
+ if (v > 256 && v < 286) {
1164
+ const p = v - 257;
1165
+ let A = o[p];
1166
+ const w = c[p];
1167
+ w && (A += s.readBits(w));
1168
+ const y = ot(s, d);
1169
+ if (y >= 30) throw Error("Invalid distance symbol");
1170
+ let x = l[y];
1171
+ const E = u[y];
1172
+ E && (x += s.readBits(E));
1173
+ const C = h.length - x;
1174
+ if (C < 0) throw Error("Invalid distance");
1175
+ for (let N = 0; N < A; N++) h.push(h[C + N] || 0);
1176
+ } else if (v === 286 || v === 287) throw Error("Reserved length symbol");
1177
1177
  }
1178
1178
  }
1179
1179
  }
@@ -1181,62 +1181,62 @@ function ye(n) {
1181
1181
  }
1182
1182
  }(new Ae(n.subarray(i)), r), new Uint8Array(r);
1183
1183
  }
1184
- function be(n) {
1185
- const t = F, e = new Uint8Array(n);
1184
+ function we(n) {
1185
+ const t = R, e = new Uint8Array(n);
1186
1186
  if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
1187
1187
  const i = t.readUint(e, 4), r = t.readUshort(e, 12), s = t.readUint(e, 16), h = [];
1188
1188
  let o = 44;
1189
- for (let p = 0; p < r; p++) {
1190
- const y = t.readASCII(e, o, 4), E = t.readUint(e, o + 4), x = t.readUint(e, o + 8), b = t.readUint(e, o + 12), R = t.readUint(e, o + 16);
1191
- h.push({ tag: y, offset: E, compLength: x, origLength: b, checksum: R }), o += 20;
1192
- }
1193
- for (const p of h) {
1194
- const y = new Uint8Array(e.buffer, p.offset, p.compLength);
1195
- if (p.compLength === p.origLength) p.data = new Uint8Array(y);
1196
- else if (p.data = ye(y), p.data.length !== p.origLength) if (p.data.length < p.origLength) {
1197
- const E = new Uint8Array(p.origLength);
1198
- E.set(p.data), p.data = E;
1199
- } else p.data = p.data.subarray(0, p.origLength);
1189
+ for (let A = 0; A < r; A++) {
1190
+ const w = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), x = t.readUint(e, o + 8), E = t.readUint(e, o + 12), C = t.readUint(e, o + 16);
1191
+ h.push({ tag: w, offset: y, compLength: x, origLength: E, checksum: C }), o += 20;
1192
+ }
1193
+ for (const A of h) {
1194
+ const w = new Uint8Array(e.buffer, A.offset, A.compLength);
1195
+ if (A.compLength === A.origLength) A.data = new Uint8Array(w);
1196
+ else if (A.data = ye(w), A.data.length !== A.origLength) if (A.data.length < A.origLength) {
1197
+ const y = new Uint8Array(A.origLength);
1198
+ y.set(A.data), A.data = y;
1199
+ } else A.data = A.data.subarray(0, A.origLength);
1200
1200
  }
1201
1201
  const c = r;
1202
1202
  let l = 1, u = 0;
1203
1203
  for (; l << 1 <= c; ) l <<= 1, u++;
1204
- const f = 16 * l, v = 16 * c - f;
1204
+ const f = 16 * l, g = 16 * c - f;
1205
1205
  let m = 12 + 16 * c;
1206
1206
  const d = {};
1207
- for (const p of h) d[p.tag] = m, m = $(m + p.data.length);
1208
- const g = new Uint8Array(Math.max(s || 0, m));
1209
- D(g, 0, i), tt(g, 4, c), tt(g, 6, f), tt(g, 8, u), tt(g, 10, v);
1210
- let A = 12;
1211
- for (const p of h) {
1212
- pe(g, A, p.tag), A += 4;
1213
- let y = p.data;
1214
- if (p.tag === "head" && y.length >= 12) {
1215
- const E = new Uint8Array(y);
1216
- D(E, 8, 0), D(g, A, at(E, 0, $(E.length))), A += 4;
1207
+ for (const A of h) d[A.tag] = m, m = q(m + A.data.length);
1208
+ const v = new Uint8Array(Math.max(s || 0, m));
1209
+ D(v, 0, i), J(v, 4, c), J(v, 6, f), J(v, 8, u), J(v, 10, g);
1210
+ let p = 12;
1211
+ for (const A of h) {
1212
+ ve(v, p, A.tag), p += 4;
1213
+ let w = A.data;
1214
+ if (A.tag === "head" && w.length >= 12) {
1215
+ const y = new Uint8Array(w);
1216
+ D(y, 8, 0), D(v, p, ht(y, 0, q(y.length))), p += 4;
1217
1217
  } else
1218
- D(g, A, at(y, 0, $(y.length))), A += 4;
1219
- D(g, A, d[p.tag]), A += 4, D(g, A, p.data.length), A += 4;
1218
+ D(v, p, ht(w, 0, q(w.length))), p += 4;
1219
+ D(v, p, d[A.tag]), p += 4, D(v, p, A.data.length), p += 4;
1220
1220
  }
1221
- for (const p of h) {
1222
- const y = d[p.tag];
1223
- g.set(p.data, y);
1221
+ for (const A of h) {
1222
+ const w = d[A.tag];
1223
+ v.set(A.data, w);
1224
1224
  }
1225
- if (h.find((p) => p.tag === "head")) {
1226
- const p = d.head, y = function(E, x) {
1227
- const b = x + 8, R = [E[b], E[b + 1], E[b + 2], E[b + 3]];
1228
- D(E, b, 0);
1229
- const U = 2981146554 - (at(E, 0, $(E.length)) >>> 0) >>> 0;
1230
- return E[b] = R[0], E[b + 1] = R[1], E[b + 2] = R[2], E[b + 3] = R[3], U >>> 0;
1231
- }(g, p);
1232
- D(g, p + 8, y);
1225
+ if (h.find((A) => A.tag === "head")) {
1226
+ const A = d.head, w = function(y, x) {
1227
+ const E = x + 8, C = [y[E], y[E + 1], y[E + 2], y[E + 3]];
1228
+ D(y, E, 0);
1229
+ const N = 2981146554 - (ht(y, 0, q(y.length)) >>> 0) >>> 0;
1230
+ return y[E] = C[0], y[E + 1] = C[1], y[E + 2] = C[2], y[E + 3] = C[3], N >>> 0;
1231
+ }(v, A);
1232
+ D(v, A + 8, w);
1233
1233
  }
1234
- return g.buffer;
1234
+ return v.buffer;
1235
1235
  }
1236
- const we = { parseTab(n, t, e) {
1236
+ const Ee = { parseTab(n, t, e) {
1237
1237
  const i = { tables: [], ids: {}, off: t };
1238
1238
  n = new Uint8Array(n.buffer, t, e), t = 0;
1239
- const r = F, s = r.readUshort, h = s(n, t += 2);
1239
+ const r = R, s = r.readUshort, h = s(n, t += 2);
1240
1240
  t += 2;
1241
1241
  const o = [];
1242
1242
  for (let c = 0; c < h; c++) {
@@ -1244,34 +1244,34 @@ const we = { parseTab(n, t, e) {
1244
1244
  t += 2;
1245
1245
  const f = r.readUint(n, t);
1246
1246
  t += 4;
1247
- const v = `p${l}e${u}`;
1247
+ const g = `p${l}e${u}`;
1248
1248
  let m = o.indexOf(f);
1249
1249
  if (m === -1) {
1250
1250
  let d;
1251
1251
  m = i.tables.length, o.push(f);
1252
- const g = s(n, f);
1253
- d = g === 4 ? this.parse4(n, f) : g === 12 ? this.parse12(n, f) : { format: g }, i.tables.push(d);
1252
+ const v = s(n, f);
1253
+ d = v === 4 ? this.parse4(n, f) : v === 12 ? this.parse12(n, f) : { format: v }, i.tables.push(d);
1254
1254
  }
1255
- i.ids[v] = m;
1255
+ i.ids[g] = m;
1256
1256
  }
1257
1257
  return i;
1258
1258
  }, parse4(n, t) {
1259
- const e = F, i = e.readUshort, r = e.readUshorts, s = t, h = i(n, t += 2);
1259
+ const e = R, i = e.readUshort, r = e.readUshorts, s = t, h = i(n, t += 2);
1260
1260
  t += 2;
1261
1261
  const o = i(n, t += 2) >>> 1, c = { format: 4, searchRange: i(n, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
1262
1262
  t += 2, c.entrySelector = i(n, t), t += 2, c.rangeShift = i(n, t), t += 2, c.endCount = r(n, t, o), t += 2 * o, t += 2, c.startCount = r(n, t, o), t += 2 * o;
1263
1263
  for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(n, t)), t += 2;
1264
1264
  return c.idRangeOffset = r(n, t, o), t += 2 * o, c.glyphIdArray = r(n, t, s + h - t >> 1), c;
1265
1265
  }, parse12(n, t) {
1266
- const e = F.readUint;
1266
+ const e = R.readUint;
1267
1267
  e(n, t += 4), e(n, t += 4);
1268
1268
  const i = e(n, t += 4);
1269
1269
  t += 4;
1270
1270
  const r = new Uint32Array(3 * i);
1271
1271
  for (let s = 0; s < 3 * i; s += 3) r[s] = e(n, t + (s << 2)), r[s + 1] = e(n, t + (s << 2) + 4), r[s + 2] = e(n, t + (s << 2) + 8);
1272
1272
  return { format: 12, groups: r };
1273
- } }, xe = { parseTab(n, t, e) {
1274
- const i = F;
1273
+ } }, be = { parseTab(n, t, e) {
1274
+ const i = R;
1275
1275
  t += 18;
1276
1276
  const r = i.readUshort(n, t);
1277
1277
  t += 2, t += 16;
@@ -1283,8 +1283,8 @@ const we = { parseTab(n, t, e) {
1283
1283
  t += 2;
1284
1284
  const c = i.readShort(n, t);
1285
1285
  return t += 2, t += 6, { unitsPerEm: r, xMin: s, yMin: h, xMax: o, yMax: c, indexToLocFormat: i.readShort(n, t) };
1286
- } }, Te = { parseTab(n, t, e) {
1287
- const i = F;
1286
+ } }, xe = { parseTab(n, t, e) {
1287
+ const i = R;
1288
1288
  t += 4;
1289
1289
  const r = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], s = {};
1290
1290
  for (let h = 0; h < r.length; h++) {
@@ -1292,17 +1292,17 @@ const we = { parseTab(n, t, e) {
1292
1292
  s[o] = c(n, t + 2 * h);
1293
1293
  }
1294
1294
  return s;
1295
- } }, Fe = { parseTab(n, t, e, i) {
1296
- const r = F, s = [], h = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1295
+ } }, Te = { parseTab(n, t, e, i) {
1296
+ const r = R, s = [], h = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1297
1297
  let l = 0, u = 0, f = 0;
1298
1298
  for (; f < c; ) l = r.readUshort(n, t + (f << 2)), u = r.readShort(n, t + (f << 2) + 2), s.push(l), h.push(u), f++;
1299
1299
  for (; f < o; ) s.push(l), h.push(u), f++;
1300
1300
  return { aWidth: s, lsBearing: h };
1301
- } }, Tt = { cmap: we, head: xe, hhea: Te, maxp: { parseTab(n, t, e) {
1302
- const i = F;
1301
+ } }, bt = { cmap: Ee, head: be, hhea: xe, maxp: { parseTab(n, t, e) {
1302
+ const i = R;
1303
1303
  return i.readUint(n, t), t += 4, { numGlyphs: i.readUshort(n, t) };
1304
- } }, hmtx: Fe, loca: { parseTab(n, t, e, i) {
1305
- const r = F, s = [], h = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1304
+ } }, hmtx: Te, loca: { parseTab(n, t, e, i) {
1305
+ const r = R, s = [], h = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1306
1306
  if (h === 0) for (let c = 0; c < o; c++) s.push(r.readUshort(n, t + (c << 1)) << 1);
1307
1307
  else if (h === 1) for (let c = 0; c < o; c++) s.push(r.readUint(n, t + (c << 2)));
1308
1308
  return s;
@@ -1310,50 +1310,50 @@ const we = { parseTab(n, t, e) {
1310
1310
  const r = [], s = i.maxp.numGlyphs;
1311
1311
  for (let h = 0; h < s; h++) r.push(null);
1312
1312
  return r;
1313
- }, Si(n, t) {
1314
- const e = F, i = n.Ri, r = n.loca;
1313
+ }, Ri(n, t) {
1314
+ const e = R, i = n.Si, r = n.loca;
1315
1315
  if (r[t] === r[t + 1]) return null;
1316
- const s = V.findTable(i, "glyf", n.ki);
1316
+ const s = j.findTable(i, "glyf", n.ki);
1317
1317
  if (!s) return null;
1318
1318
  let h = s[0] + r[t];
1319
1319
  const o = {};
1320
1320
  if (o.noc = e.readShort(i, h), h += 2, o.xMin = e.readShort(i, h), h += 2, o.yMin = e.readShort(i, h), h += 2, o.xMax = e.readShort(i, h), h += 2, o.yMax = e.readShort(i, h), h += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
1321
1321
  if (o.noc > 0) {
1322
1322
  o.endPts = [];
1323
- for (let v = 0; v < o.noc; v++) o.endPts.push(e.readUshort(i, h)), h += 2;
1323
+ for (let g = 0; g < o.noc; g++) o.endPts.push(e.readUshort(i, h)), h += 2;
1324
1324
  const c = e.readUshort(i, h);
1325
1325
  if (h += 2, i.length - h < c) return null;
1326
1326
  h += c;
1327
1327
  const l = o.endPts[o.noc - 1] + 1;
1328
1328
  o.flags = [];
1329
- for (let v = 0; v < l; v++) {
1329
+ for (let g = 0; g < l; g++) {
1330
1330
  const m = i[h];
1331
1331
  if (h++, o.flags.push(m), 8 & m) {
1332
1332
  const d = i[h];
1333
1333
  h++;
1334
- for (let g = 0; g < d; g++) o.flags.push(m), v++;
1334
+ for (let v = 0; v < d; v++) o.flags.push(m), g++;
1335
1335
  }
1336
1336
  }
1337
1337
  o.xs = [];
1338
- for (let v = 0; v < l; v++) {
1339
- const m = o.flags[v], d = !!(16 & m);
1338
+ for (let g = 0; g < l; g++) {
1339
+ const m = o.flags[g], d = !!(16 & m);
1340
1340
  2 & m ? (o.xs.push(d ? i[h] : -i[h]), h++) : d ? o.xs.push(0) : (o.xs.push(e.readShort(i, h)), h += 2);
1341
1341
  }
1342
1342
  o.ys = [];
1343
- for (let v = 0; v < l; v++) {
1344
- const m = o.flags[v], d = !!(32 & m);
1343
+ for (let g = 0; g < l; g++) {
1344
+ const m = o.flags[g], d = !!(32 & m);
1345
1345
  4 & m ? (o.ys.push(d ? i[h] : -i[h]), h++) : d ? o.ys.push(0) : (o.ys.push(e.readShort(i, h)), h += 2);
1346
1346
  }
1347
1347
  let u = 0, f = 0;
1348
- for (let v = 0; v < l; v++) u += o.xs[v], f += o.ys[v], o.xs[v] = u, o.ys[v] = f;
1348
+ for (let g = 0; g < l; g++) u += o.xs[g], f += o.ys[g], o.xs[g] = u, o.ys[g] = f;
1349
1349
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1350
1350
  return o;
1351
- } } }, V = { parse(n) {
1351
+ } } }, j = { parse(n) {
1352
1352
  const t = new Uint8Array(n);
1353
- F.readASCII(t, 0, 4) === "wOFF" && (n = be(n));
1354
- const e = new Uint8Array(n), i = Tt, r = {}, s = { Ri: e, zi: 0, ki: 0 };
1353
+ R.readASCII(t, 0, 4) === "wOFF" && (n = we(n));
1354
+ const e = new Uint8Array(n), i = bt, r = {}, s = { Si: e, zi: 0, ki: 0 };
1355
1355
  for (const h in i) {
1356
- const o = h, c = V.findTable(e, o, 0);
1356
+ const o = h, c = j.findTable(e, o, 0);
1357
1357
  if (c) {
1358
1358
  const [l, u] = c;
1359
1359
  let f = r[l];
@@ -1362,7 +1362,7 @@ const we = { parseTab(n, t, e) {
1362
1362
  }
1363
1363
  return [s];
1364
1364
  }, findTable(n, t, e) {
1365
- const i = F, r = i.readUshort(n, e + 4);
1365
+ const i = R, r = i.readUshort(n, e + 4);
1366
1366
  let s = e + 12;
1367
1367
  for (let h = 0; h < r; h++) {
1368
1368
  const o = i.readASCII(n, s, 4);
@@ -1372,7 +1372,7 @@ const we = { parseTab(n, t, e) {
1372
1372
  s += 16;
1373
1373
  }
1374
1374
  return null;
1375
- }, T: Tt, B: F };
1375
+ }, T: bt, B: R };
1376
1376
  class Re {
1377
1377
  Di(t) {
1378
1378
  var i;
@@ -1394,7 +1394,7 @@ class Re {
1394
1394
  const r = t.startCount[i], s = t.endCount[i];
1395
1395
  if (r !== 65535 || s !== 65535) {
1396
1396
  for (let h = r; h <= s; h++)
1397
- if (this.Oi(t, h, i) > 0) try {
1397
+ if (this.Bi(t, h, i) > 0) try {
1398
1398
  const o = String.fromCodePoint(h);
1399
1399
  e.push(o);
1400
1400
  } catch {
@@ -1417,7 +1417,7 @@ class Re {
1417
1417
  }
1418
1418
  return e;
1419
1419
  }
1420
- Oi(t, e, i) {
1420
+ Bi(t, e, i) {
1421
1421
  if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
1422
1422
  {
1423
1423
  const r = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
@@ -1431,27 +1431,27 @@ class Re {
1431
1431
  }
1432
1432
  class Ce {
1433
1433
  constructor(t) {
1434
- a(this, "Bi");
1434
+ a(this, "Oi");
1435
1435
  a(this, "Hi");
1436
1436
  a(this, "Z");
1437
- this.Z = t, this.Bi = document.createElement("canvas"), this.Hi = this.Bi.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1437
+ this.Z = t, this.Oi = document.createElement("canvas"), this.Hi = this.Oi.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1438
1438
  }
1439
1439
  Gi(t, e, i, r) {
1440
1440
  const s = t.length, h = Math.ceil(Math.sqrt(s)), o = Math.ceil(s / h), c = e.width * h, l = e.height * o;
1441
1441
  this.Qi(c, l), this.Ni(t, e, h, i, r);
1442
1442
  const u = this.Z.Pi(c, l, 1, { filter: "nearest" });
1443
- return u.it(this.Bi), { framebuffer: u, columns: h, rows: o };
1443
+ return u.it(this.Oi), { framebuffer: u, columns: h, rows: o };
1444
1444
  }
1445
1445
  Qi(t, e) {
1446
- this.Bi.width = t, this.Bi.height = e, this.Bi.style.width = t + "px", this.Bi.style.height = e + "px", this.Hi.imageSmoothingEnabled = !1, this.Bi.style.imageRendering = "pixelated", this.Hi.clearRect(0, 0, t, e), this.Hi.textBaseline = "top", this.Hi.textAlign = "left", this.Hi.fillStyle = "white";
1446
+ this.Oi.width = t, this.Oi.height = e, this.Oi.style.width = t + "px", this.Oi.style.height = e + "px", this.Hi.imageSmoothingEnabled = !1, this.Oi.style.imageRendering = "pixelated", this.Hi.clearRect(0, 0, t, e), this.Hi.textBaseline = "top", this.Hi.textAlign = "left", this.Hi.fillStyle = "white";
1447
1447
  }
1448
1448
  Ni(t, e, i, r, s) {
1449
1449
  const h = r / s.head.unitsPerEm;
1450
1450
  for (let o = 0; o < t.length; o++) {
1451
1451
  const c = o % i, l = Math.floor(o / i), u = t[o].glyphData;
1452
1452
  if (!u) continue;
1453
- const f = u.advanceWidth * h, v = c * e.width, m = l * e.height, d = v + 0.5 * e.width, g = m + 0.5 * e.height, A = Math.round(d - 0.5 * e.width), p = Math.round(g - 0.5 * r), y = A + 0.5 * (e.width - f), E = p + s.hhea.ascender * h;
1454
- this.Xi(u, y, E, h);
1453
+ const f = u.advanceWidth * h, g = c * e.width, m = l * e.height, d = g + 0.5 * e.width, v = m + 0.5 * e.height, p = Math.round(d - 0.5 * e.width), A = Math.round(v - 0.5 * r), w = p + 0.5 * (e.width - f), y = A + s.hhea.ascender * h;
1454
+ this.Xi(u, w, y, h);
1455
1455
  }
1456
1456
  }
1457
1457
  Xi(t, e, i, r) {
@@ -1464,31 +1464,31 @@ class Ce {
1464
1464
  const f = o[u];
1465
1465
  if (!(f < l)) {
1466
1466
  if (f >= l) {
1467
- const v = e + s[l] * r, m = i - h[l] * r;
1468
- this.Hi.moveTo(v, m);
1467
+ const g = e + s[l] * r, m = i - h[l] * r;
1468
+ this.Hi.moveTo(g, m);
1469
1469
  let d = l + 1;
1470
1470
  for (; d <= f; )
1471
1471
  if (1 & c[d]) {
1472
- const g = e + s[d] * r, A = i - h[d] * r;
1473
- this.Hi.lineTo(g, A), d++;
1472
+ const v = e + s[d] * r, p = i - h[d] * r;
1473
+ this.Hi.lineTo(v, p), d++;
1474
1474
  } else {
1475
- const g = e + s[d] * r, A = i - h[d] * r;
1475
+ const v = e + s[d] * r, p = i - h[d] * r;
1476
1476
  if (d + 1 > f) {
1477
- const y = e + s[l] * r, E = i - h[l] * r;
1478
- if (1 & c[l]) this.Hi.quadraticCurveTo(g, A, y, E);
1477
+ const w = e + s[l] * r, y = i - h[l] * r;
1478
+ if (1 & c[l]) this.Hi.quadraticCurveTo(v, p, w, y);
1479
1479
  else {
1480
- const x = (g + y) / 2, b = (A + E) / 2;
1481
- this.Hi.quadraticCurveTo(g, A, x, b);
1480
+ const x = (v + w) / 2, E = (p + y) / 2;
1481
+ this.Hi.quadraticCurveTo(v, p, x, E);
1482
1482
  }
1483
1483
  break;
1484
1484
  }
1485
- const p = d + 1;
1486
- if (1 & c[p]) {
1487
- const y = e + s[p] * r, E = i - h[p] * r;
1488
- this.Hi.quadraticCurveTo(g, A, y, E), d = p + 1;
1485
+ const A = d + 1;
1486
+ if (1 & c[A]) {
1487
+ const w = e + s[A] * r, y = i - h[A] * r;
1488
+ this.Hi.quadraticCurveTo(v, p, w, y), d = A + 1;
1489
1489
  } else {
1490
- const y = (g + (e + s[p] * r)) / 2, E = (A + (i - h[p] * r)) / 2;
1491
- this.Hi.quadraticCurveTo(g, A, y, E), d = p;
1490
+ const w = (v + (e + s[A] * r)) / 2, y = (p + (i - h[A] * r)) / 2;
1491
+ this.Hi.quadraticCurveTo(v, p, w, y), d = A;
1492
1492
  }
1493
1493
  }
1494
1494
  this.Hi.closePath();
@@ -1499,7 +1499,7 @@ class Ce {
1499
1499
  this.Hi.fill();
1500
1500
  }
1501
1501
  }
1502
- class St {
1502
+ class Nt {
1503
1503
  Yi(t, e) {
1504
1504
  const i = t.cmap;
1505
1505
  if (!i || !i.tables) return 0;
@@ -1546,10 +1546,10 @@ class St {
1546
1546
  return 0;
1547
1547
  }
1548
1548
  }
1549
- class Pe {
1549
+ class Fe {
1550
1550
  constructor() {
1551
1551
  a(this, "Vi");
1552
- this.Vi = new St();
1552
+ this.Vi = new Nt();
1553
1553
  }
1554
1554
  Ji(t, e, i) {
1555
1555
  let r = 0;
@@ -1563,10 +1563,10 @@ class Pe {
1563
1563
  return { width: Math.ceil(r), height: Math.ceil(h) };
1564
1564
  }
1565
1565
  }
1566
- class Me {
1566
+ class Pe {
1567
1567
  constructor() {
1568
1568
  a(this, "tr");
1569
- this.tr = new St();
1569
+ this.tr = new Nt();
1570
1570
  }
1571
1571
  sr(t, e) {
1572
1572
  const i = [], r = /* @__PURE__ */ new Map();
@@ -1583,11 +1583,11 @@ class Me {
1583
1583
  if (r === 0) return null;
1584
1584
  let s = 0;
1585
1585
  t.hmtx && t.hmtx.aWidth && r > 0 && t.hmtx.aWidth[r] !== void 0 && (s = t.hmtx.aWidth[r]);
1586
- const h = V.T.glyf.Si(t, r);
1586
+ const h = j.T.glyf.Ri(t, r);
1587
1587
  return h ? { ...h, advanceWidth: s } : null;
1588
1588
  }
1589
1589
  }
1590
- class At {
1590
+ class vt {
1591
1591
  constructor(t, e = 16) {
1592
1592
  a(this, "rr");
1593
1593
  a(this, "nr", []);
@@ -1602,17 +1602,17 @@ class At {
1602
1602
  a(this, "gr");
1603
1603
  a(this, "mr");
1604
1604
  a(this, "_r");
1605
- this.cr = e, this.pr = new Re(), this.gr = new Ce(t), this.mr = new Pe(), this._r = new Me();
1605
+ this.cr = e, this.pr = new Re(), this.gr = new Ce(t), this.mr = new Fe(), this._r = new Pe();
1606
1606
  }
1607
- async yr(t) {
1607
+ async Ar(t) {
1608
1608
  let e;
1609
1609
  if (t) {
1610
1610
  const i = await fetch(t);
1611
- if (!i.ok) throw new N(`Failed to load font file: ${i.status} ${i.statusText}`);
1611
+ if (!i.ok) throw new U(`Failed to load font file: ${i.status} ${i.statusText}`);
1612
1612
  e = await i.arrayBuffer();
1613
1613
  } else
1614
1614
  e = await (await fetch("data:font/woff;base64,d09GRgABAAAAABbwAAoAAAAAfywAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABjbWFwAAAA9AAAAbsAAAkgIO8lSWdseWYAAAKwAAAOfgAAaLS4ctN0aGVhZAAAETAAAAAsAAAAOCi8/PVoaGVhAAARXAAAABkAAAAkCwEFAmhtdHgAABF4AAAAhQAABAQEAIOAbG9jYQAAEgAAAAKUAAAECAAy54BtYXhwAAAUlAAAABgAAAAgASIAgm5hbWUAABSsAAAB5wAAA6RWz85KT1MvMgAAFpQAAABFAAAAYM+QEyRwb3N0AAAW3AAAABQAAAAgAGkANHja7dRPSFRRFMfx38wdXblw4cJC7M0bz60gWlULGUFctWgR0UIQQkmDyn27kpAQaaEO2jhWJuafiQFtcDJtSqGhiFZtot5x3jzEVQQhlRJcOb0khiRc1+J94R64uw8cOADCAJT/avwZAiIpRCK3/P999KAS9biOSUxhBhlksYjnWMFrvME7vMca1vEF37ANAwkNqYRKqkk1rdLqscqpVVVQryzbils3rJnocHTWPmgfso/ap+0OuysWjlXHogQKUxVVUw3VUh010DE6QXHqph7qpT66TQmaoAxlaZnyVKC39FHHdbNu0e36or6kr4r4TgsTu75HmEcOy76vUPaVsIFNbOHHX74F3/fyD9+A7ztg1//2de76rH18Z8u+AXqwx/dBN5Z9XfqKiKzLqqzIC8nLkixKThZkXuZkVh7KuNyTuzImKRmVO1KxU7ETMtvmu/lqPptPxjOuKXo3vcveYQ+l2lKlO+Im3H632z3vnis+KaaLKc7zM87yHGc4zdM8zkke5H6+xp3cwRe4jVv5DLdwE5/ik3ycj3Cdk3eWnKfOmDPqJJ3hX9sOCvpPC65QcIWCgv5pPwGY9ak7AHja3V07ryQ5FT62axjQaDWsVmiCFQJpA4QINiAgICDYgICAgICAgICAgICAgIAA//AuF9Xlsn2etqv67iIY6apv3+6yj31e33nYA95FiD4uAAHeA7jyLzoA2Paf/Lp/Dun5W8x/Be/AxyCfO79fnj+e25/ZZzlewcM+3wIhwpfwE/Sc9e8YDyLU1ycF5XUD+to+L98O/An8VKQj0lnOtYdM776OJ71fTVC8//N1rLKDGsXl863OjSl5/iyIUu0HjJ+d+uO3rX3rXd33d/DjfR0/h6/n1iK5kWf36Hf2AxpVa6zU7ZLTnt3Q3wN7+tK6MVcBjUP/3vj56diHuT3YxVbKSvl9FdJHeFE4jfmJn2DSSOS9fuJ27SH7umuoL3oLWGOLxh3f2b8bnn/5Ql8n5SEYFD33q/0lKXxwjQfDOZtGgyEz+W8X5txl2zVb9MXO2S8HfD3ncbHousP6WPV2i/R7C+c06HK5ye/lfdl3Bj5Q2qitaLYhgLQWZY+fr/65A9Ly1r10jI783HOffJWZJ6ee8uuB0nmMXeSqWvRz5Dx/tiWf7H0OF+1DuK7vhy4ffP8An/doofqbQNXTqmlNT1c0v4/Eqpy29eBMLHty0PKZoCMW6VqRlDXNwvbD4RW2MYfyjNdXV3LaJuEdKgXcHvX2nHiz27RxHmC9w/qn0AbS+mJbSeX8pO1zlbbogPK7zJxAs3iFtrV8W/LHsHVZvxJ6Rlt7gum1nvjpnHNO4gFJqaoBWOKFVwKqAangorb2j5KKvG5N31O1ownZdhcZH7FuT9nznoxRv4ylrbfvzA9D88GO8uGDtgN0/1O09ntFlv3YhbIf/ml3/dPGqvi6rCMw6jNd53PM07BnK2eCJXmnzxrruI8ObOuxmZ/dxbd5nS77U7I/xaMdLm5/DXzuLLcwXlOLIVQ0an722pou6raGnpp/QYiwR0V5nwDL0Gk/f2TSUalIGOkSvfNAcVNCesV9a2q675FtsVAk4c5GPEfZT27XVqT9PmpxXtVn0577KO3MGrkXs+xKkHZk6EMUS440uO01t+Ark8yGYYjtsleqoPQksLuF0kOd/7TtbZ3XvNalNRNLqK+90fEDTAfy1FWWOBcT9fkTmrExe+viDNccYF+JqHeIbyBtlYxhStbmSc8DSX9/rICoXkkGSMfEJR7QsYAjNlhgn6iNS7T0AtakNnvaJ+W1TeQdeIxHaHtXaMtU+GP3CL5v+2RqHfc5JC6k9DJ6HhFaHHfu9Lc1Z5HlB5JWNOc8NupiUSlpa/7NIx0W0Ra10YcOVWnDfqhodmgI1CM5nrJS1DYKlMmyeAmoZaLrQnmNSRxAV7qZ0u0sr2Q8WbzUrRivE200nZ+x371Yj+idQH+bsOAFD16woZXuheBJI85UYyA+Ht17bJsTKLHHG+tuQpJX/AGX4eu2lq+vh8gQPgaLUpk1h7fcb1SJ4LEnGb+rdUHRHw96riVV36L5EgdqHNByqCTy82hnkrSSk3k5KTNWnJZ/buTlOvQngiceAkd4OHPz0K+tdOmGUYwJht2kcuBEntSRPOmZfyc40tFqD40IQeb2goGZvKIVzW4G5DMcQ4qOY3zVRzpmo1sMg+U1VemumtLofjFeCcxqJIUnM2vJuQeCHiOOwx4ss7pF6u+PtXxmZApbjCti22JtA+hVxUw7z6Xs2sSzMkeklSLPfwalYkjjt/0bHye4gKkXeaig5MpILVRiAd1vCrtP5Aj5uaN2PF1zxrE7koOgaY2PPL9FkccCKlprUZGr+zr0tw56iCvwGBTs+MFFxVbWeTaCQTj2WCBM1NnoWNxOBpBZU8f00hPsFDr+15wPevNsJG4IN+OGwKyWzKnW8S/GDUHZOd+44SsvbDvCuhYUTQSaQSFeWtoR4Xc833VimVzRvgm58QwZFQTthQ+awgQTeuVI7gLrF638Yixi+ot4RVZ5niDPFxBediyXNj++jUWDgkU3Zc96fDKwv4iiylyA4nalMkLX9C1hf24DNNkZyNDkflOPF4BqwdYbv1vLG9VX03W96PVKiCq+A01i5utY2d9YfSMP0qvQ7eFQUHSKvNfpCl21nqNafqf1UQksqfVe1PEPPNiJpY81iZoP119ZTUHojdpseMYqec5zr/2Jgo695rmycZWzSgOpXzMpbFrHu1Zmq/xA8pX3cgEQZU1/YzaexuQbXIoxF9THdaEzz9VaE5fgNVIPR/sIS8fQyipam9JXqHdOtPEIRllqzP7Ewh9063Z2IYH+GiLNUPFXJIcEM4RYc7bEkjwQL4/1fx+aHL8/62Of5vo3y+p92QX2fh18zrNFcPX9sfZAdBDZu8vxCM4clX31Qr9RrLPkDDDau8v8LZRar2N8lSOj1NGsLJeBZam1TIuwpzwepL3CJAvyANsPnj3BAzsD3a5X6ydEaZUSs50b7g2JrYcyG2lRL+xl+jD+Gfod33w82P0FTuYREa3c70CRS82XCtxIueJHXuIMB6tMt+x7lf7m5U4tyK9L3smuLrxqDxYPI30rYzk2h2NzgPXqAvPrQdqUxvdWF2zVwDrHCq0RoI0Hcrzcn9D8BMxYEMszZBzooqa/jsTxSeTthXTm9FC2n+pYEh8uVqyL9436quMD6pnK7njZM6msy4uYsunVquBSi4clVn8gblYc96TFyF04ll2oqCB300cDIbPxrZoqXZ1DHWvNh2irrNxstSaZYa2VB333tOr9mRcx7ETmXKmSFz6GkidstKjZFE8qIX26eG8KoS/b9uij9GFOiwFIVj5NyErT8rZGstdmD4lc4/xaNevd1uwOPCLX7Ems2TTc81MrUVmzyqdOr1v1PCPat9jmQfUYJEEbzNCSse4DevSYCIXal+bDCC3I2+EeTFKd7ltnFNN0sGLIfRcGfSWKD0BPANWTQIqcNtsaAON/1A/BeywPGhybs2ZEA1sH9FbgDMpTQx5L5k4fN/RR8lBHvif2ftB7oa8isVdrdWDxp/Hp6N8MsdUgqdS0M12EZrhC7TpJZZLZOZelRdeDUyffq3s6xPhztK4Xd9h6f4pIieNu4lI/jEN1XEMjbafK6lry/jkOYedyVMyp2vaHGlM8zBjCkdi28NdrNldgLa/a0orYtN6OwoMh7vPAsxb9eNTDrOdJBWuXsb6En8Evb5yTrJw1Y1XTHnmCFNtPkhHnuN+8QwHGi3JUJf4zeaTJsBpFdnik5V4fZq510ifEHMf7M55f2fteR1DJ73gzf4vyO42Or3Z5mZcWdlY6wb3sRvd0olKfGeaCWm5yGEtDwzLH6yPS95wmcVb2BBrYzig5tGb7Bvb5fkyfvW2nRhlxF3cyz8qGOF//eVLXq7P4oQTop9UASTKPr91h1zu5wu753DbqtXUO8pOT6wzdnQfWn2X3Csr5ktxP4FUmlBHHPThBO0mQ6wTFVxbM5mPCeXWP7ha4YDf8BdvAeaGd/XntlgHlW2eMFAR2CBPYAQzPrGeVy1ieYCOQdtpXGZyss4F2rkr5W8tJh06NTd/HGi+1vbiPN6JTeSfP5k0ihAhRQwgad9wQ1dhoKAntU87DfZy/K8SuEsPg82VQRU5xUGU+ZVrp8SMYtOHiwFC+Z1jLG2dqRuhAw01cZ2qeXBk/ROjaAS1TIuKHVp+Fi5YMrHqqahlY3YbJ0E/N2uUTq/0Cvt717Vfwa/gNfAO/hd/B7+EP8Ef4E/wZ/gJ/hb/B3+Ef8E/4F/z7nla+5T+Afp1wHdQRH/F/+/lF6VrSbuP4v/18VHMVmm7q6TX/Czha0mxJrf+YyNyOfRcYeKSap3+b8UufB8GnJSdec6Iu+toF6nHkaeZxvJ5h4PVgj3ILMz5teArdxnr8/PPoCXqiuvR91zoh2pvS8b0SqUD1FLPubHPaK9Q5lU+GzwI3PgfCOsB9NORgqm5OqfVxLMd1L9+A/s2s+0/0a93MTd3NNRHapruGQLnhZTSzpBMuYFNaz7N5RffPo/MnV2zac3wfRX6Vng0As1cTmE5M38U0eS+H0rvZxXtg6460jlQTZ3Snxw+pO9TKz+mOB5vffTs6umGj+UjMb3/QKfndvlP47UsVAO9Drzo11h+T/rF09Po0st98jHsKh31Ruj2UnbYWLuEd/pM9wOwpZ+KqccfWNZsc4F6c3jtf2ou7Ca6akqXRPThzsadua+/4hq7vgmn6uqux6bXw6AjnLMJbXMM5Ixwi8mR2rc3AOfg2nrs4zZlnDFaChbCtk/bwilwMfBxc0iMYy0MX40x2o/ft9D2Znn9Kl+3MO90HUb747jnzjpyCKVeTuij6DllsctyiUzXN0dgE9We1yK54WBffFqtew9TXpbYfy7dILWH/SXxmqeg4zlvRsZfIbuFnic0SHfRtfj4vsaVq532jl/QpYBykzpe/jec7n1uOmhuETi2xzM5vfy01xQC0vkp6PiKpDd07x6qcUc719K0A1YZjpvLivftqNpzxV/tDtXPTWFrbaowzXj+czsG+nmMt/bQspzj7fnvxeeuG4O/s/Xe412VW3+5VuPT+EV97/r++14Gc3ZvQRHrXMz91IrWHZ4FnK7WOVGjJPfAO3R0BczdLKuevQd5LPVsXd/X8PK6Ll2jK0/NM7P4V1PuI51FvsEMV+KhV4T2+22IQF85a0FlLWXs/IHTOX1B5CGCeEDh6V2ZiTK+eee/dnNjOa2xXz2zndd7sq+XYEZ/Gx/exoK5PoOceWNdnef9W9KCT9EYXqkrPxuhC9GA7faMXpHef1smLTDe1qaDY1N4ozLI4fqsHlwpf+3Cu9F1E/Z4AajG3V8430/6bCdq8QQs9b4OqJyQa1+6BACWaTPI8zrROa//7QGJ19U4tHeTTtePNqu3PnVhXJFSjzZFz4eo3Ndqidi/O6J5Z7X+VsS3cYki51T35Iv+merFeuGe69cbJM3Jq1Fn4kUA5rze4o9CRs22iy5jMsYLMS8g5/wOjbDW/AAB42mNgZGBgAOIzT9tXxvPbfGVgYGEAgZokCXVkmgUizsHABFLNwAAACJYG1HjaY2BkYGBhAAEIyc7AwMiAAhgZAQHPABQAAAB42r1TwRaAIAgD88P59PRA0hxUlw578mBDQOwi0i+oDUzb7nC/xyKH8SuwHH/jSx83jnE745c1RO44G9E1WTE14AQtYvKO6PN6BXRW5EONgCazSS4VXiere+sp7F7cQeSp7Pe2YkaxN7fVFhg/8z/1hfnfaBXnZ8k7wNzp/y13+wRWwErCAAAAeNpl0ylUVVEUBuCtoiKgoiIzAjIIMj9mZBZYMsmMjwcuBhEIBoPBYDAYDAaDwWA0GAwGgsFgMBgMBoPBYDAYDAaDweBnlrX+9e6955x/2oeI//664HbEgTL4HnHwZ8Sh1/AlIm0W3kUc3oN9+BFxJBva4E3E0SvwLCIdR/qniGO98Coiw3vG04hMv5n/fj9GZBUD3iz8xx9FnMiBJxEn0+E+/IrIppNt/VQzvITfEadH4HnEmUG4BV8jchaBn7NZgCMXdy7uXGfzeMjjKZ/PfBwF9hTYU/AhotC5QtpFtIt4K7oLnyOK6RXTKP4TUcJDCe5zNXAHcJTiKOWxlEZZPeAo00U5b+XyltM9vw24KvBWyFzpTOWLiCr5qu6BPdV0qx+Cni+sAc4a3mvw1nqu/RZxsRJkrEsDWeo2wAzq8dY/iGgwpwbfGvTdaA6NOmnUb5PnpiTY00S3SXfN/DU/BustdFrMq8VagqcE/YReEjK3+t4qayuPbTTbdNH2PqJdL+06a5e33VoHjg7vHdY7cXTK2ekedPHWha+b5279ddPo1ndPPuDrkbkH3yX5e/XXy3OvzH34+sy132+//P14B/AO6GuA3qBOB3U6hH/It2Haw2Y2rI9hHV6WdcSsR6eAl1GZx3Qwpr9xcxv3PqGDCbyTvE3KM+muT+lwypkpe6bNaZqfaX6v8j7D8wyNGbwzbyNmdTMrzxxfc9bndDFn5vM8zds37x4smMeCHhf5WTKHJb0uuc/L/C7bs4zrGr2kO5m0ntRZkv8VfazIkvI9RSelg5ReUrKvOrvqHq7p4Lr5retx3fcN/5Mb+Dfs25RpE/8mji0etqzfwLHteZufmzrZobfj/K5ednna0/fe/l+Pca7seNpjYGRgYGRkaGBQYAABJgY0AAAP+ACmeNp1ksFO20AQhv8NgRJaUApSy61LDxVc4uAjNxoJReoNKdCrYy8hZb1rrTcIuPMKfaY+QM899RH6AP3tDJEKqlcefzvzz/xrywD21ScoLK9N3ktW5E3hDl6hL7zG7HvhLrMfhNfxGonwBjUnwj2uz8JbzH4R3sZbPArvIMV34T28wQ+6qG6Puz5+Civyb+EOO/4Ir6GvOsJdaLUrvI53KhXeoGYs3MOu+iq8hai+CW/jo/olvIOiA+E97HeKw/xIp8M0nYQ6O/MunpvZwmbhafv01JK/MKGee6ePB8N/JCFzN6dO+8o4bee5cbnRM+NMyKyuFqHytdHR3MXSF0ZfNQOn93rVORoNm4l64ua3NMjsdYxVfZIkeTBZZC73ZeldPfBhllSLKR0KX2ZzlzyY4BO2JmNjrdeXPtjiAIfIcQTNbz/knWKCgBoZzuDhEHEOgxkWsMyFF9Xne/1Mf8Fdo5i3dY1jDOjz/ymB0eEGp63ao2J/Q5YT8pabqOnQsGn1lvuKjoHRc05Tj4x3jCUzRZu5Wp1winvGl54jruHqjI3C0fVW3qDxuWZ/pEvNPzjhylkxrETR5fQoW09HzYDPwJMm7emm8g5Fq8nIjpWHdronLV0TjJmxXJ4nuGwnWPYcAH8BoeumrAB42mNgYmFgnMDAysDCxMDEAAIQGoiNGc6A+CwMENDAwNDNwFDwGMpliHT00WNwYFBQy4aogJCMgSCSGcJTYGAAAEBYBpIAAAB42mNgZoCANAZjIMnIgAYADecAng==")).arrayBuffer();
1615
- await this.Ar(e), this.rr = V.parse(e)[0], await this.wr();
1615
+ await this.yr(e), this.rr = j.parse(e)[0], await this.wr();
1616
1616
  }
1617
1617
  br(t) {
1618
1618
  if (t === void 0) return this.cr;
@@ -1623,17 +1623,17 @@ class At {
1623
1623
  async Cr(t) {
1624
1624
  try {
1625
1625
  const e = await fetch(t);
1626
- if (!e.ok) throw new N(`Failed to load font file: ${e.status} ${e.statusText}`);
1626
+ if (!e.ok) throw new U(`Failed to load font file: ${e.status} ${e.statusText}`);
1627
1627
  const i = await e.arrayBuffer();
1628
- await this.Ar(i);
1629
- const r = V.parse(i);
1628
+ await this.yr(i);
1629
+ const r = j.parse(i);
1630
1630
  if (!r || r.length === 0) throw Error("Failed to parse font file");
1631
1631
  this.rr = r[0], await this.wr();
1632
1632
  } catch (e) {
1633
- throw new N("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1633
+ throw new U("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1634
1634
  }
1635
1635
  }
1636
- async Ar(t) {
1636
+ async yr(t) {
1637
1637
  const e = Date.now();
1638
1638
  this.vr = new FontFace("CustomFont_" + e, t), await this.vr.load(), document.fonts.add(this.vr);
1639
1639
  }
@@ -1681,36 +1681,36 @@ class At {
1681
1681
  return this.rr;
1682
1682
  }
1683
1683
  }
1684
- class Lt {
1684
+ class Ut {
1685
1685
  constructor(t, e, i) {
1686
- a(this, "Ur");
1687
1686
  a(this, "Pr");
1687
+ a(this, "$r");
1688
1688
  a(this, "N");
1689
1689
  a(this, "X");
1690
- a(this, "$r");
1691
1690
  a(this, "Tr");
1692
1691
  a(this, "Er");
1693
- a(this, "Sr");
1694
1692
  a(this, "Rr");
1695
- this.Er = t, this.Sr = e, this.Rr = i, this.te();
1693
+ a(this, "Sr");
1694
+ a(this, "kr");
1695
+ this.Rr = t, this.Sr = e, this.kr = i, this.te();
1696
1696
  }
1697
1697
  te() {
1698
- this.Ur = Math.floor(this.Er.width / this.Sr), this.Pr = Math.floor(this.Er.height / this.Rr), this.N = this.Ur * this.Sr, this.X = this.Pr * this.Rr, this.$r = Math.floor((this.Er.width - this.N) / 2), this.Tr = Math.floor((this.Er.height - this.X) / 2);
1698
+ this.Pr = Math.floor(this.Rr.width / this.Sr), this.$r = Math.floor(this.Rr.height / this.kr), this.N = this.Pr * this.Sr, this.X = this.$r * this.kr, this.Tr = Math.floor((this.Rr.width - this.N) / 2), this.Er = Math.floor((this.Rr.height - this.X) / 2);
1699
1699
  }
1700
- kr(t, e) {
1701
- this.Sr = t, this.Rr = e, this.te();
1700
+ zr(t, e) {
1701
+ this.Sr = t, this.kr = e, this.te();
1702
1702
  }
1703
1703
  get cellWidth() {
1704
1704
  return this.Sr;
1705
1705
  }
1706
1706
  get cellHeight() {
1707
- return this.Rr;
1707
+ return this.kr;
1708
1708
  }
1709
1709
  get cols() {
1710
- return this.Ur;
1710
+ return this.Pr;
1711
1711
  }
1712
1712
  get rows() {
1713
- return this.Pr;
1713
+ return this.$r;
1714
1714
  }
1715
1715
  get width() {
1716
1716
  return this.N;
@@ -1719,14 +1719,14 @@ class Lt {
1719
1719
  return this.X;
1720
1720
  }
1721
1721
  get offsetX() {
1722
- return this.$r;
1722
+ return this.Tr;
1723
1723
  }
1724
1724
  get offsetY() {
1725
- return this.Tr;
1725
+ return this.Er;
1726
1726
  }
1727
1727
  }
1728
- const Ue = /^rgba?\(([^)]+)\)$/i;
1729
- function lt(n) {
1728
+ const Me = /^rgba?\(([^)]+)\)$/i;
1729
+ function at(n) {
1730
1730
  return Number.isNaN(n) ? 0 : Math.max(0, Math.min(255, n));
1731
1731
  }
1732
1732
  function Ne(n) {
@@ -1735,50 +1735,50 @@ function Ne(n) {
1735
1735
  if (!t) return null;
1736
1736
  let e = null;
1737
1737
  return t.startsWith("rgb") && (e = function(i) {
1738
- const r = Ue.exec(i.trim());
1738
+ const r = Me.exec(i.trim());
1739
1739
  if (!r) return null;
1740
1740
  const s = r[1].split(",").map((u) => u.trim());
1741
1741
  if (s.length < 3) return null;
1742
- const h = lt(parseFloat(s[0])), o = lt(parseFloat(s[1])), c = lt(parseFloat(s[2])), l = s[3] !== void 0 ? 255 * Math.max(0, Math.min(1, parseFloat(s[3]))) : 255;
1742
+ const h = at(parseFloat(s[0])), o = at(parseFloat(s[1])), c = at(parseFloat(s[2])), l = s[3] !== void 0 ? 255 * Math.max(0, Math.min(1, parseFloat(s[3]))) : 255;
1743
1743
  return [h, o, c, Math.round(l)];
1744
1744
  }(t)), e ? e[3] === 0 ? null : e : null;
1745
1745
  }
1746
- class Se {
1746
+ class Ue {
1747
1747
  constructor(t = {}) {
1748
- a(this, "Er");
1749
- a(this, "zr", null);
1750
- a(this, "Dr", !1);
1751
- a(this, "Lr");
1752
- this.Dr = t.overlay ?? !1, this.Dr && t.canvas ? (this.zr = t.canvas, this.Er = this.Ir(), this.Lr = !0, this.Or()) : t.canvas ? (this.Er = t.canvas, this.Lr = !1) : (this.Er = this.Br(t.width, t.height), this.Lr = !0), this.Er.style.imageRendering = "pixelated";
1748
+ a(this, "Rr");
1749
+ a(this, "Dr", null);
1750
+ a(this, "Lr", !1);
1751
+ a(this, "Ir");
1752
+ this.Lr = t.overlay ?? !1, this.Lr && t.canvas ? (this.Dr = t.canvas, this.Rr = this.Br(), this.Ir = !0, this.Or()) : t.canvas ? (this.Rr = t.canvas, this.Ir = !1) : (this.Rr = this.Hr(t.width, t.height), this.Ir = !0), this.Rr.style.imageRendering = "pixelated";
1753
1753
  }
1754
- Br(t, e) {
1754
+ Hr(t, e) {
1755
1755
  const i = document.createElement("canvas");
1756
1756
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1757
1757
  }
1758
- Ir() {
1758
+ Br() {
1759
1759
  const t = document.createElement("canvas");
1760
1760
  t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1761
- const e = this.zr.getBoundingClientRect();
1761
+ const e = this.Dr.getBoundingClientRect();
1762
1762
  let i = Math.round(e.width), r = Math.round(e.height);
1763
- if (this.zr instanceof HTMLVideoElement) {
1764
- const o = this.zr;
1763
+ if (this.Dr instanceof HTMLVideoElement) {
1764
+ const o = this.Dr;
1765
1765
  (i === 0 || r === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, r = o.videoHeight);
1766
1766
  }
1767
1767
  t.width = i, t.height = r, t.style.position = "absolute", t.style.pointerEvents = "none";
1768
- const s = window.getComputedStyle(this.zr);
1768
+ const s = window.getComputedStyle(this.Dr);
1769
1769
  let h = parseInt(s.zIndex || "0", 10);
1770
1770
  return isNaN(h) && (h = 0), t.style.zIndex = "" + (h + 1), t;
1771
1771
  }
1772
1772
  Or() {
1773
1773
  var t;
1774
- this.Hr(), (t = this.zr.parentNode) == null || t.insertBefore(this.Er, this.zr.nextSibling);
1774
+ this.Gr(), (t = this.Dr.parentNode) == null || t.insertBefore(this.Rr, this.Dr.nextSibling);
1775
1775
  }
1776
- Gr() {
1776
+ Qr() {
1777
1777
  const t = [];
1778
- return this.Dr && this.zr instanceof HTMLElement && (t.push(this.zr), this.zr.parentElement && t.push(this.zr.parentElement)), this.Er.parentElement && t.push(this.Er.parentElement), t.push(this.Er), t.push(document.body), t.push(document.documentElement), t;
1778
+ return this.Lr && this.Dr instanceof HTMLElement && (t.push(this.Dr), this.Dr.parentElement && t.push(this.Dr.parentElement)), this.Rr.parentElement && t.push(this.Rr.parentElement), t.push(this.Rr), t.push(document.body), t.push(document.documentElement), t;
1779
1779
  }
1780
- Qr() {
1781
- const t = this.Gr();
1780
+ Nr() {
1781
+ const t = this.Qr();
1782
1782
  for (const e of t) {
1783
1783
  if (!e) continue;
1784
1784
  const i = Ne(window.getComputedStyle(e).backgroundColor);
@@ -1786,154 +1786,154 @@ class Se {
1786
1786
  }
1787
1787
  return [255, 255, 255, 255];
1788
1788
  }
1789
- Hr() {
1790
- if (!this.zr) return;
1791
- const t = this.zr.getBoundingClientRect();
1792
- let e = this.zr.offsetParent;
1789
+ Gr() {
1790
+ if (!this.Dr) return;
1791
+ const t = this.Dr.getBoundingClientRect();
1792
+ let e = this.Dr.offsetParent;
1793
1793
  if (e && e !== document.body) {
1794
1794
  const i = e.getBoundingClientRect();
1795
- this.Er.style.top = t.top - i.top + "px", this.Er.style.left = t.left - i.left + "px";
1796
- } else this.Er.style.top = t.top + window.scrollY + "px", this.Er.style.left = t.left + window.scrollX + "px";
1797
- }
1798
- Nr(t, e) {
1799
- if (this.Dr) {
1800
- const i = this.zr.getBoundingClientRect();
1801
- this.Er.width = Math.round(i.width), this.Er.height = Math.round(i.height), this.Hr();
1802
- } else this.Er.width = t ?? this.Er.width, this.Er.height = e ?? this.Er.height;
1803
- }
1804
- Xr() {
1805
- const t = this.Er.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !0, stencil: !1, powerPreference: "high-performance" });
1806
- if (!t) throw new N("`textmode.js` requires WebGL2 support.");
1795
+ this.Rr.style.top = t.top - i.top + "px", this.Rr.style.left = t.left - i.left + "px";
1796
+ } else this.Rr.style.top = t.top + window.scrollY + "px", this.Rr.style.left = t.left + window.scrollX + "px";
1797
+ }
1798
+ Xr(t, e) {
1799
+ if (this.Lr) {
1800
+ const i = this.Dr.getBoundingClientRect();
1801
+ this.Rr.width = Math.round(i.width), this.Rr.height = Math.round(i.height), this.Gr();
1802
+ } else this.Rr.width = t ?? this.Rr.width, this.Rr.height = e ?? this.Rr.height;
1803
+ }
1804
+ Yr() {
1805
+ const t = this.Rr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !0, stencil: !1, powerPreference: "high-performance" });
1806
+ if (!t) throw new U("`textmode.js` requires WebGL2 support.");
1807
1807
  return t;
1808
1808
  }
1809
1809
  gt() {
1810
- const t = this.Er.getContext("webgl") || this.Er.getContext("webgl2");
1810
+ const t = this.Rr.getContext("webgl") || this.Rr.getContext("webgl2");
1811
1811
  if (t) {
1812
1812
  const e = t.getExtension("WEBGL_lose_context");
1813
1813
  e == null || e.loseContext();
1814
1814
  }
1815
- this.Lr && this.Er.parentNode && this.Er.parentNode.removeChild(this.Er);
1815
+ this.Ir && this.Rr.parentNode && this.Rr.parentNode.removeChild(this.Rr);
1816
1816
  }
1817
1817
  get canvas() {
1818
- return this.Er;
1818
+ return this.Rr;
1819
1819
  }
1820
1820
  get targetCanvas() {
1821
- return this.zr;
1821
+ return this.Dr;
1822
1822
  }
1823
1823
  get width() {
1824
- return this.Er.width;
1824
+ return this.Rr.width;
1825
1825
  }
1826
1826
  get height() {
1827
- return this.Er.height;
1827
+ return this.Rr.height;
1828
1828
  }
1829
1829
  }
1830
- function et(n) {
1831
- return Z(parseInt(n, 16), 0, 255);
1830
+ function $(n) {
1831
+ return I(parseInt(n, 16), 0, 255);
1832
1832
  }
1833
1833
  class M {
1834
1834
  constructor(t, e, i, r) {
1835
- a(this, "Yr");
1836
1835
  a(this, "jr");
1836
+ a(this, "Kr");
1837
1837
  a(this, "r");
1838
1838
  a(this, "g");
1839
1839
  a(this, "b");
1840
1840
  a(this, "a");
1841
- this.r = Z(t, 0, 255), this.g = Z(e, 0, 255), this.b = Z(i, 0, 255), this.a = Z(r, 0, 255), this.Yr = [this.r, this.g, this.b, this.a], this.jr = [this.r / 255, this.g / 255, this.b / 255, this.a / 255];
1841
+ this.r = I(t, 0, 255), this.g = I(e, 0, 255), this.b = I(i, 0, 255), this.a = I(r, 0, 255), this.jr = [this.r, this.g, this.b, this.a], this.Kr = [this.r / 255, this.g / 255, this.b / 255, this.a / 255];
1842
1842
  }
1843
- static Kr(t, e, i, r) {
1844
- if (M.Wr(t)) return t;
1843
+ static Wr(t, e, i, r) {
1844
+ if (M.Zr(t)) return t;
1845
1845
  if (Array.isArray(t)) {
1846
1846
  if (t.length < 3) throw Error("Component tuples must include at least RGB values.");
1847
1847
  const [s, h, o] = t, c = t.length === 4 ? t[3] : 255;
1848
- return M.Zr(s, h, o, c);
1848
+ return M.qr(s, h, o, c);
1849
1849
  }
1850
1850
  if (typeof t == "string") {
1851
1851
  const s = t.trim();
1852
1852
  if (s.length === 0) throw Error("Color strings cannot be empty.");
1853
- return M.qr(s);
1853
+ return M.Vr(s);
1854
1854
  }
1855
- if (typeof t == "number") return typeof e == "number" && typeof i == "number" ? M.Zr(t, e, i, r ?? 255) : M.Vr(t);
1855
+ if (typeof t == "number") return typeof e == "number" && typeof i == "number" ? M.qr(t, e, i, r ?? 255) : M.Jr(t);
1856
1856
  throw Error("Unsupported color input passed to TextmodeColor.$from.");
1857
1857
  }
1858
- static Zr(t, e, i, r = 255) {
1858
+ static qr(t, e, i, r = 255) {
1859
1859
  return new M(t, e, i, r);
1860
1860
  }
1861
- static Vr(t, e = 255) {
1861
+ static Jr(t, e = 255) {
1862
1862
  return new M(t, t, t, e);
1863
1863
  }
1864
- static qr(t) {
1864
+ static Vr(t) {
1865
1865
  return new M(...function(e) {
1866
1866
  const i = e.replace(/^#|0x/gi, ""), r = (s = i).length === 3 || s.length === 4 ? s.split("").map((h) => h + h).join("") : s;
1867
1867
  var s;
1868
1868
  if (r.length !== 6 && r.length !== 8) throw Error("Invalid hex color: " + e);
1869
- return [et(r.slice(0, 2)), et(r.slice(2, 4)), et(r.slice(4, 6)), r.length === 8 ? et(r.slice(6, 8)) : 255];
1869
+ return [$(r.slice(0, 2)), $(r.slice(2, 4)), $(r.slice(4, 6)), r.length === 8 ? $(r.slice(6, 8)) : 255];
1870
1870
  }(t));
1871
1871
  }
1872
1872
  get rgb() {
1873
1873
  return [this.r, this.g, this.b];
1874
1874
  }
1875
1875
  get rgba() {
1876
- return [...this.Yr];
1876
+ return [...this.jr];
1877
1877
  }
1878
1878
  get normalized() {
1879
- return [...this.jr];
1879
+ return [...this.Kr];
1880
1880
  }
1881
1881
  withAlpha(t) {
1882
1882
  return new M(this.r, this.g, this.b, t);
1883
1883
  }
1884
- static Wr(t) {
1884
+ static Zr(t) {
1885
1885
  return t instanceof M;
1886
1886
  }
1887
1887
  }
1888
- const Et = /* @__PURE__ */ new Map();
1889
- function Le(n) {
1890
- Et.set(n.id, n);
1888
+ const At = /* @__PURE__ */ new Map();
1889
+ function Se(n) {
1890
+ At.set(n.id, n);
1891
1891
  }
1892
- function si(n) {
1893
- Et.delete(n);
1892
+ function Je(n) {
1893
+ At.delete(n);
1894
1894
  }
1895
- function De(n) {
1896
- return Et.get(n);
1895
+ function Le(n) {
1896
+ return At.get(n);
1897
1897
  }
1898
- class Dt {
1898
+ class St {
1899
1899
  constructor(t, e, i, r, s, h, o, c) {
1900
1900
  a(this, "A");
1901
1901
  a(this, "Z");
1902
- a(this, "Jr");
1903
1902
  a(this, "tn");
1904
1903
  a(this, "sn");
1904
+ a(this, "en");
1905
1905
  a(this, "N");
1906
1906
  a(this, "X");
1907
1907
  a(this, "q", null);
1908
1908
  a(this, "rr");
1909
- a(this, "en", "brightness");
1910
- a(this, "rn", null);
1909
+ a(this, "rn", "brightness");
1910
+ a(this, "nn", null);
1911
1911
  a(this, "Et", 0);
1912
1912
  a(this, "Gt", 0);
1913
1913
  a(this, "Qt", 0);
1914
- a(this, "St", 0);
1915
- a(this, "nn", "sampled");
1916
- a(this, "hn", "fixed");
1914
+ a(this, "Rt", 0);
1915
+ a(this, "hn", "sampled");
1916
+ a(this, "an", "fixed");
1917
1917
  a(this, "Xt", [1, 1, 1, 1]);
1918
1918
  a(this, "Yt", [0, 0, 0, 1]);
1919
- a(this, "an", [0, 0, 0, 1]);
1920
- a(this, "cn", [[0.1, 0, 0]]);
1921
- a(this, "ln", null);
1922
- a(this, "un", /* @__PURE__ */ new Set());
1923
- a(this, "fn", [[0, 0, 0, 0]]);
1924
- a(this, "dn", 0);
1925
- this.A = t, this.Z = e, this.Jr = i, this.rr = r, this.tn = s, this.sn = h, this.N = o, this.X = c;
1919
+ a(this, "cn", [0, 0, 0, 1]);
1920
+ a(this, "ln", [[0.1, 0, 0]]);
1921
+ a(this, "un", null);
1922
+ a(this, "fn", /* @__PURE__ */ new Set());
1923
+ a(this, "dn", [[0, 0, 0, 0]]);
1924
+ a(this, "vn", 0);
1925
+ this.A = t, this.Z = e, this.tn = i, this.rr = r, this.sn = s, this.en = h, this.N = o, this.X = c;
1926
1926
  }
1927
1927
  conversionMode(t) {
1928
- return this.en = t, this.rn = null, this.q = null, this;
1928
+ return this.rn = t, this.nn = null, this.q = null, this;
1929
1929
  }
1930
1930
  gt() {
1931
- this.A.deleteTexture(this.Jr);
1932
- for (const t of this.un) t();
1933
- this.un.clear();
1931
+ this.A.deleteTexture(this.tn);
1932
+ for (const t of this.fn) t();
1933
+ this.fn.clear();
1934
1934
  }
1935
- vn(t) {
1936
- this.un.add(t);
1935
+ pn(t) {
1936
+ this.fn.add(t);
1937
1937
  }
1938
1938
  invert(t = !0) {
1939
1939
  return this.Et = t ? 1 : 0, this.q = null, this;
@@ -1945,41 +1945,41 @@ class Dt {
1945
1945
  return this.Qt = t ? 1 : 0, this.q = null, this;
1946
1946
  }
1947
1947
  charRotation(t) {
1948
- return this.St = Rt(t), this.q = null, this;
1948
+ return this.Rt = Tt(t), this.q = null, this;
1949
1949
  }
1950
1950
  charColorMode(t) {
1951
- return this.nn = t, this.q = null, this;
1951
+ return this.hn = t, this.q = null, this;
1952
1952
  }
1953
1953
  cellColorMode(t) {
1954
- return this.hn = t, this.q = null, this;
1954
+ return this.an = t, this.q = null, this;
1955
1955
  }
1956
1956
  charColor(t, e, i, r) {
1957
- return this.pn(this.Xt, t, e, i, r), this.q = null, this;
1957
+ return this.gn(this.Xt, t, e, i, r), this.q = null, this;
1958
1958
  }
1959
1959
  cellColor(t, e, i, r) {
1960
- return this.pn(this.Yt, t, e, i, r), this.q = null, this;
1960
+ return this.gn(this.Yt, t, e, i, r), this.q = null, this;
1961
1961
  }
1962
1962
  background(t, e, i, r) {
1963
- return this.pn(this.an, t, e, i, r), this.q = null, this;
1963
+ return this.gn(this.cn, t, e, i, r), this.q = null, this;
1964
1964
  }
1965
1965
  colorFilter(t) {
1966
- if (!t || t.length === 0) return this.dn = 0, this.fn = [[0, 0, 0, 0]], this.q = null, this;
1966
+ if (!t || t.length === 0) return this.vn = 0, this.dn = [[0, 0, 0, 0]], this.q = null, this;
1967
1967
  const e = [];
1968
1968
  for (const i of t) {
1969
1969
  if (e.length >= 64) break;
1970
- let r = M.Kr(i);
1970
+ let r = M.Wr(i);
1971
1971
  e.push(r.normalized);
1972
1972
  }
1973
- return this.fn = e, this.dn = e.length, this.q = null, this;
1973
+ return this.dn = e, this.vn = e.length, this.q = null, this;
1974
1974
  }
1975
1975
  characters(t) {
1976
- return this.ln = t, this.gn(t), this.q = null, this;
1976
+ return this.un = t, this.mn(t), this.q = null, this;
1977
1977
  }
1978
- mn(t) {
1979
- this.rr = t, this.ln && this.gn(this.ln), this.q = null;
1978
+ _n(t) {
1979
+ this.rr = t, this.un && this.mn(this.un), this.q = null;
1980
1980
  }
1981
1981
  get texture() {
1982
- return this.Jr;
1982
+ return this.tn;
1983
1983
  }
1984
1984
  get width() {
1985
1985
  return this.N;
@@ -1988,191 +1988,188 @@ class Dt {
1988
1988
  return this.X;
1989
1989
  }
1990
1990
  get originalWidth() {
1991
- return this.tn;
1991
+ return this.sn;
1992
1992
  }
1993
1993
  get originalHeight() {
1994
- return this.sn;
1994
+ return this.en;
1995
1995
  }
1996
1996
  ut() {
1997
1997
  return this.q || this.ft(), this.q;
1998
1998
  }
1999
- _n() {
1999
+ An() {
2000
2000
  }
2001
2001
  ft() {
2002
- this._n();
2003
- const t = this.yn(), e = this.An(), i = t.createShader(e), r = t.createUniforms(e);
2002
+ this.An();
2003
+ const t = this.yn(), e = this.wn(), i = t.createShader(e), r = t.createUniforms(e);
2004
2004
  this.q = this.Z.materialManager.Qe(i, r);
2005
2005
  }
2006
- pn(t, e, i, r, s) {
2007
- const h = M.Kr(e, i, r, s);
2008
- it(t, h.r, h.g, h.b, h.a);
2006
+ gn(t, e, i, r, s) {
2007
+ const h = M.Wr(e, i, r, s);
2008
+ tt(t, h.r, h.g, h.b, h.a);
2009
2009
  }
2010
- gn(t) {
2010
+ mn(t) {
2011
2011
  const e = this.rr.Fr(t).filter((i) => Array.isArray(i)).slice(0, 255);
2012
- this.cn = e.length > 0 ? e : this.cn;
2012
+ this.ln = e.length > 0 ? e : this.ln;
2013
2013
  }
2014
2014
  createBaseConversionUniforms() {
2015
- const t = this.dn > 0;
2016
- return { u_image: this.wn(), u_invert: !!this.Et, u_flipX: !!this.Gt, u_flipY: !!this.Qt, u_charRotation: this.St, u_charColorFixed: this.nn === "fixed", u_charColor: this.Xt, u_cellColorFixed: this.hn === "fixed", u_cellColor: this.Yt, u_backgroundColor: this.an, u_charCount: this.cn.length, u_charList: this.cn, u_colorFilterEnabled: t, u_colorFilterSize: t ? this.dn : 0, u_colorFilterPalette: this.fn };
2015
+ const t = this.vn > 0;
2016
+ return { u_image: this.bn(), u_invert: !!this.Et, u_flipX: !!this.Gt, u_flipY: !!this.Qt, u_charRotation: this.Rt, u_charColorFixed: this.hn === "fixed", u_charColor: this.Xt, u_cellColorFixed: this.an === "fixed", u_cellColor: this.Yt, u_backgroundColor: this.cn, u_charCount: this.ln.length, u_charList: this.ln, u_colorFilterEnabled: t, u_colorFilterSize: t ? this.vn : 0, u_colorFilterPalette: this.dn };
2017
2017
  }
2018
2018
  yn() {
2019
- if (this.rn && this.rn.id === this.en) return this.rn;
2020
- const t = De(this.en);
2021
- if (!t) throw Error(`[textmode.js] Conversion mode "${this.en}" is not registered. If this mode is provided by an add-on, make sure its plugin is installed before loading sources.`);
2022
- return this.rn = t, t;
2019
+ if (this.nn && this.nn.id === this.rn) return this.nn;
2020
+ const t = Le(this.rn);
2021
+ if (!t) throw Error(`[textmode.js] Conversion mode "${this.rn}" is not registered. If this mode is provided by an add-on, make sure its plugin is installed before loading sources.`);
2022
+ return this.nn = t, t;
2023
2023
  }
2024
- An() {
2024
+ wn() {
2025
2025
  return { renderer: this.Z, gl: this.A, font: this.rr, source: this, gridWidth: this.N, gridHeight: this.X };
2026
2026
  }
2027
2027
  }
2028
- class z extends Dt {
2028
+ class Y extends St {
2029
2029
  constructor(t, e, i, r, s, h, o, c) {
2030
2030
  const l = Math.min(o / s, c / h);
2031
2031
  super(t, e, i, r, s, h, Math.max(1, Math.floor(s * l)), Math.max(1, Math.floor(h * l)));
2032
2032
  }
2033
- static bn(t, e, i, r, s) {
2033
+ static Cn(t, e, i, r, s) {
2034
2034
  const h = t.context, o = h.createTexture();
2035
- h.bindTexture(h.TEXTURE_2D, o), h.pixelStorei(h.UNPACK_FLIP_Y_WEBGL, 1), rt(h, h.NEAREST, h.NEAREST, h.CLAMP_TO_EDGE, h.CLAMP_TO_EDGE), h.texImage2D(h.TEXTURE_2D, 0, h.RGBA, h.RGBA, h.UNSIGNED_BYTE, i), h.bindTexture(h.TEXTURE_2D, null);
2035
+ h.bindTexture(h.TEXTURE_2D, o), h.pixelStorei(h.UNPACK_FLIP_Y_WEBGL, 1), et(h, h.NEAREST, h.NEAREST, h.CLAMP_TO_EDGE, h.CLAMP_TO_EDGE), h.texImage2D(h.TEXTURE_2D, 0, h.RGBA, h.RGBA, h.UNSIGNED_BYTE, i), h.bindTexture(h.TEXTURE_2D, null);
2036
2036
  const c = i.naturalWidth ?? i.width ?? i.videoWidth ?? 0, l = i.naturalHeight ?? i.height ?? i.videoHeight ?? 0;
2037
- return new z(h, t, o, e, c, l, r, s);
2037
+ return new Y(h, t, o, e, c, l, r, s);
2038
2038
  }
2039
- wn() {
2040
- return this.Jr;
2039
+ bn() {
2040
+ return this.tn;
2041
2041
  }
2042
2042
  }
2043
- class _t {
2043
+ class Lt {
2044
2044
  constructor(t = 60) {
2045
- a(this, "Cn");
2046
- a(this, "xn", null);
2047
- a(this, "Mn", 0);
2048
- a(this, "Fn", !0);
2049
- a(this, "Pn", 0);
2045
+ a(this, "xn");
2046
+ a(this, "Mn", null);
2047
+ a(this, "Fn", 0);
2048
+ a(this, "Pn", !0);
2050
2049
  a(this, "$n", 0);
2051
- a(this, "Tn", []);
2052
- a(this, "En", 10);
2050
+ a(this, "Tn", 0);
2051
+ a(this, "En", []);
2052
+ a(this, "Rn", 10);
2053
2053
  a(this, "Sn", 0);
2054
- this.Cn = 1e3 / t;
2054
+ this.xn = 1e3 / t;
2055
2055
  }
2056
- Rn(t) {
2057
- if (!this.Fn) return;
2058
- this.Mn = performance.now();
2056
+ kn(t) {
2057
+ if (!this.Pn) return;
2058
+ this.Fn = performance.now();
2059
2059
  const e = (i) => {
2060
- if (!this.Fn) return void (this.xn = null);
2061
- const r = i - this.Mn;
2062
- r >= this.Cn && (t(), this.Mn = i - r % this.Cn), this.Fn && (this.xn = requestAnimationFrame(e));
2060
+ if (!this.Pn) return void (this.Mn = null);
2061
+ const r = i - this.Fn;
2062
+ r >= this.xn && (t(), this.Fn = i - r % this.xn), this.Pn && (this.Mn = requestAnimationFrame(e));
2063
2063
  };
2064
- this.xn = requestAnimationFrame(e);
2065
- }
2066
- kn() {
2067
- this.xn && (cancelAnimationFrame(this.xn), this.xn = null);
2064
+ this.Mn = requestAnimationFrame(e);
2068
2065
  }
2069
2066
  zn() {
2070
- this.Fn && (this.Fn = !1, this.kn());
2067
+ this.Mn && (cancelAnimationFrame(this.Mn), this.Mn = null);
2068
+ }
2069
+ Dn() {
2070
+ this.Pn && (this.Pn = !1, this.zn());
2071
2071
  }
2072
- Dn(t) {
2073
- this.Fn || (this.Fn = !0, this.Rn(t));
2072
+ Ln(t) {
2073
+ this.Pn || (this.Pn = !0, this.kn(t));
2074
2074
  }
2075
- Ln(t, e) {
2076
- if (t === void 0) return this.Pn;
2077
- this.Cn = 1e3 / t, this.Fn && e && (this.kn(), this.Rn(e));
2075
+ In(t, e) {
2076
+ if (t === void 0) return this.$n;
2077
+ this.xn = 1e3 / t, this.Pn && e && (this.zn(), this.kn(e));
2078
2078
  }
2079
- In() {
2079
+ Bn() {
2080
2080
  const t = performance.now();
2081
- if (this.$n > 0) {
2082
- const e = t - this.$n;
2083
- this.Tn.push(e), this.Tn.length > this.En && this.Tn.shift();
2084
- const i = this.Tn.reduce((r, s) => r + s, 0) / this.Tn.length;
2085
- this.Pn = 1e3 / i;
2081
+ if (this.Tn > 0) {
2082
+ const e = t - this.Tn;
2083
+ this.En.push(e), this.En.length > this.Rn && this.En.shift();
2084
+ const i = this.En.reduce((r, s) => r + s, 0) / this.En.length;
2085
+ this.$n = 1e3 / i;
2086
2086
  }
2087
- this.$n = t;
2087
+ this.Tn = t;
2088
2088
  }
2089
2089
  get On() {
2090
- return this.Fn;
2091
- }
2092
- get Bn() {
2093
2090
  return this.Pn;
2094
2091
  }
2095
2092
  get Hn() {
2093
+ return this.$n;
2094
+ }
2095
+ get Gn() {
2096
2096
  return this.Sn;
2097
2097
  }
2098
- set Hn(t) {
2098
+ set Gn(t) {
2099
2099
  this.Sn = t;
2100
2100
  }
2101
- Gn() {
2101
+ Qn() {
2102
2102
  this.Sn++;
2103
2103
  }
2104
2104
  }
2105
- class Bt {
2105
+ class Dt {
2106
2106
  constructor(t) {
2107
- a(this, "Er");
2108
- a(this, "Qn");
2109
- a(this, "Nn", { x: -1, y: -1 });
2107
+ a(this, "Rr");
2108
+ a(this, "Nn");
2110
2109
  a(this, "Xn", { x: -1, y: -1 });
2111
- a(this, "Yn", null);
2112
- a(this, "jn", 0);
2113
- a(this, "Kn");
2110
+ a(this, "Yn", { x: -1, y: -1 });
2111
+ a(this, "jn", null);
2112
+ a(this, "Kn", 0);
2114
2113
  a(this, "Wn");
2115
2114
  a(this, "Zn");
2116
2115
  a(this, "qn");
2117
2116
  a(this, "Vn");
2118
2117
  a(this, "Jn");
2119
- a(this, "so", !1);
2120
- a(this, "eo");
2118
+ a(this, "so");
2119
+ a(this, "eo", !1);
2121
2120
  a(this, "io");
2122
2121
  a(this, "ro");
2123
2122
  a(this, "no");
2124
2123
  a(this, "oo");
2125
- this.Er = t;
2124
+ a(this, "ho");
2125
+ this.Rr = t;
2126
2126
  }
2127
- ho(t) {
2127
+ ao(t) {
2128
2128
  const e = performance.now() + Math.max(0, t);
2129
- e > this.jn && (this.jn = e);
2129
+ e > this.Kn && (this.Kn = e);
2130
2130
  }
2131
- ao() {
2132
- return performance.now() < this.jn;
2131
+ co() {
2132
+ return performance.now() < this.Kn;
2133
2133
  }
2134
- co(t) {
2135
- const e = this.Er.canvas;
2134
+ lo(t) {
2135
+ const e = this.Rr.canvas;
2136
2136
  e.style.cursor = t == null || t === "" ? "" : t;
2137
2137
  }
2138
- yr(t) {
2139
- this.Qn = t, this.lo();
2138
+ Ar(t) {
2139
+ this.Nn = t, this.uo();
2140
2140
  }
2141
- uo() {
2142
- if (this.so) return;
2143
- const t = this.Er.canvas;
2144
- this.Kn = (e) => {
2145
- this.fo(e), this.do(e);
2146
- }, this.Wn = () => {
2147
- this.Xn = { ...this.Nn }, this.Nn.x = -1, this.Nn.y = -1, this.Yn = null;
2148
- }, this.Zn = (e) => {
2149
- this.fo(e), this.vo(e);
2141
+ fo() {
2142
+ if (this.eo) return;
2143
+ const t = this.Rr.canvas;
2144
+ this.Wn = (e) => {
2145
+ this.do(e), this.vo(e);
2146
+ }, this.Zn = () => {
2147
+ this.Yn = { ...this.Xn }, this.Xn.x = -1, this.Xn.y = -1, this.jn = null;
2150
2148
  }, this.qn = (e) => {
2151
- this.fo(e), this.po(e);
2149
+ this.do(e), this.po(e);
2152
2150
  }, this.Vn = (e) => {
2153
- this.fo(e), this.mo(e);
2151
+ this.do(e), this.mo(e);
2154
2152
  }, this.Jn = (e) => {
2155
- this.fo(e), this._o(e);
2156
- }, t.addEventListener("mousemove", this.Kn, { passive: !0 }), t.addEventListener("mouseleave", this.Wn, { passive: !0 }), t.addEventListener("mousedown", this.Zn, { passive: !0 }), t.addEventListener("mouseup", this.qn, { passive: !0 }), t.addEventListener("click", this.Vn, { passive: !0 }), t.addEventListener("wheel", this.Jn, { passive: !1 }), this.so = !0;
2153
+ this.do(e), this._o(e);
2154
+ }, this.so = (e) => {
2155
+ this.do(e), this.Ao(e);
2156
+ }, t.addEventListener("mousemove", this.Wn, { passive: !0 }), t.addEventListener("mouseleave", this.Zn, { passive: !0 }), t.addEventListener("mousedown", this.qn, { passive: !0 }), t.addEventListener("mouseup", this.Vn, { passive: !0 }), t.addEventListener("click", this.Jn, { passive: !0 }), t.addEventListener("wheel", this.so, { passive: !1 }), this.eo = !0;
2157
2157
  }
2158
2158
  yo() {
2159
- if (!this.so) return;
2160
- const t = this.Er.canvas;
2161
- t.removeEventListener("mousemove", this.Kn), t.removeEventListener("mouseleave", this.Wn), t.removeEventListener("mousedown", this.Zn), t.removeEventListener("mouseup", this.qn), t.removeEventListener("click", this.Vn), t.removeEventListener("wheel", this.Jn), this.so = !1;
2162
- }
2163
- lo() {
2164
- if (this.so) try {
2165
- if (this.Yn) {
2166
- const t = new MouseEvent("mousemove", { clientX: this.Yn.x, clientY: this.Yn.y, bubbles: !1, cancelable: !1 });
2167
- this.fo(t);
2168
- } else this.Nn.x !== -1 && this.Nn.y !== -1 && (this.Nn.x >= this.Qn.cols || this.Nn.y >= this.Qn.rows) && (this.Nn.x = -1, this.Nn.y = -1);
2159
+ if (!this.eo) return;
2160
+ const t = this.Rr.canvas;
2161
+ t.removeEventListener("mousemove", this.Wn), t.removeEventListener("mouseleave", this.Zn), t.removeEventListener("mousedown", this.qn), t.removeEventListener("mouseup", this.Vn), t.removeEventListener("click", this.Jn), t.removeEventListener("wheel", this.so), this.eo = !1;
2162
+ }
2163
+ uo() {
2164
+ if (this.eo) try {
2165
+ if (this.jn) {
2166
+ const t = new MouseEvent("mousemove", { clientX: this.jn.x, clientY: this.jn.y, bubbles: !1, cancelable: !1 });
2167
+ this.do(t);
2168
+ } else this.Xn.x !== -1 && this.Xn.y !== -1 && (this.Xn.x >= this.Nn.cols || this.Xn.y >= this.Nn.rows) && (this.Xn.x = -1, this.Xn.y = -1);
2169
2169
  } catch {
2170
- this.Nn.x = -1, this.Nn.y = -1;
2170
+ this.Xn.x = -1, this.Xn.y = -1;
2171
2171
  }
2172
2172
  }
2173
- Ao(t) {
2174
- this.eo = t;
2175
- }
2176
2173
  wo(t) {
2177
2174
  this.io = t;
2178
2175
  }
@@ -2185,136 +2182,138 @@ class Bt {
2185
2182
  xo(t) {
2186
2183
  this.oo = t;
2187
2184
  }
2188
- Mo() {
2189
- return { x: this.Nn.x, y: this.Nn.y };
2185
+ Mo(t) {
2186
+ this.ho = t;
2190
2187
  }
2191
- do(t) {
2192
- if (this.no && !this.ao()) {
2193
- const e = { position: { ...this.Nn }, previousPosition: { ...this.Xn }, originalEvent: t };
2194
- this.no(e);
2195
- }
2188
+ Fo() {
2189
+ return { x: this.Xn.x, y: this.Xn.y };
2196
2190
  }
2197
2191
  vo(t) {
2198
- if (this.io && !this.ao()) {
2199
- const e = { position: { ...this.Nn }, previousPosition: { ...this.Xn }, button: t.button, originalEvent: t };
2200
- this.io(e);
2192
+ if (this.oo && !this.co()) {
2193
+ const e = { position: { ...this.Xn }, previousPosition: { ...this.Yn }, originalEvent: t };
2194
+ this.oo(e);
2201
2195
  }
2202
2196
  }
2203
2197
  po(t) {
2204
- if (this.ro && !this.ao()) {
2205
- const e = { position: { ...this.Nn }, previousPosition: { ...this.Xn }, button: t.button, originalEvent: t };
2198
+ if (this.ro && !this.co()) {
2199
+ const e = { position: { ...this.Xn }, previousPosition: { ...this.Yn }, button: t.button, originalEvent: t };
2206
2200
  this.ro(e);
2207
2201
  }
2208
2202
  }
2209
2203
  mo(t) {
2210
- if (this.eo && !this.ao()) {
2211
- const e = { position: { ...this.Nn }, previousPosition: { ...this.Xn }, button: t.button, originalEvent: t };
2212
- this.eo(e);
2204
+ if (this.no && !this.co()) {
2205
+ const e = { position: { ...this.Xn }, previousPosition: { ...this.Yn }, button: t.button, originalEvent: t };
2206
+ this.no(e);
2213
2207
  }
2214
2208
  }
2215
2209
  _o(t) {
2216
- if (this.oo && !this.ao()) {
2217
- const e = { position: { ...this.Nn }, previousPosition: { ...this.Xn }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2218
- this.oo(e);
2210
+ if (this.io && !this.co()) {
2211
+ const e = { position: { ...this.Xn }, previousPosition: { ...this.Yn }, button: t.button, originalEvent: t };
2212
+ this.io(e);
2219
2213
  }
2220
2214
  }
2221
- fo(t) {
2222
- const e = this.Er.canvas;
2223
- this.Xn = { ...this.Nn }, this.Yn = { x: t.clientX, y: t.clientY };
2224
- const i = e.getBoundingClientRect(), r = t.clientX - i.left, s = t.clientY - i.top, h = e.width / i.width, o = s * (e.height / i.height), c = r * h - this.Qn.offsetX, l = o - this.Qn.offsetY, u = Math.floor(c / this.Qn.cellWidth), f = Math.floor(l / this.Qn.cellHeight);
2225
- u >= 0 && u < this.Qn.cols && f >= 0 && f < this.Qn.rows ? (this.Nn.x = u, this.Nn.y = f) : (this.Nn.x = -1, this.Nn.y = -1);
2215
+ Ao(t) {
2216
+ if (this.ho && !this.co()) {
2217
+ const e = { position: { ...this.Xn }, previousPosition: { ...this.Yn }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2218
+ this.ho(e);
2219
+ }
2220
+ }
2221
+ do(t) {
2222
+ const e = this.Rr.canvas;
2223
+ this.Yn = { ...this.Xn }, this.jn = { x: t.clientX, y: t.clientY };
2224
+ const i = e.getBoundingClientRect(), r = t.clientX - i.left, s = t.clientY - i.top, h = e.width / i.width, o = s * (e.height / i.height), c = r * h - this.Nn.offsetX, l = o - this.Nn.offsetY, u = Math.floor(c / this.Nn.cellWidth), f = Math.floor(l / this.Nn.cellHeight);
2225
+ u >= 0 && u < this.Nn.cols && f >= 0 && f < this.Nn.rows ? (this.Xn.x = u, this.Xn.y = f) : (this.Xn.x = -1, this.Xn.y = -1);
2226
2226
  }
2227
2227
  }
2228
- const _e = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: Bt }, Symbol.toStringTag, { value: "Module" }));
2229
- class Xt {
2228
+ const De = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: Dt }, Symbol.toStringTag, { value: "Module" }));
2229
+ class _t {
2230
2230
  constructor() {
2231
- a(this, "Fo", /* @__PURE__ */ new Map());
2232
- a(this, "Po", null);
2231
+ a(this, "Po", /* @__PURE__ */ new Map());
2233
2232
  a(this, "$o", null);
2234
- a(this, "To");
2233
+ a(this, "To", null);
2235
2234
  a(this, "Eo");
2236
- a(this, "so", !1);
2237
- a(this, "So");
2238
2235
  a(this, "Ro");
2239
- a(this, "ko", { 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" });
2236
+ a(this, "eo", !1);
2237
+ a(this, "So");
2238
+ a(this, "ko");
2239
+ a(this, "zo", { 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" });
2240
2240
  }
2241
- uo() {
2242
- this.so || (this.To = (t) => {
2243
- this.zo(t);
2244
- }, this.Eo = (t) => {
2241
+ fo() {
2242
+ this.eo || (this.Eo = (t) => {
2245
2243
  this.Do(t);
2246
- }, window.addEventListener("keydown", this.To, { passive: !1 }), window.addEventListener("keyup", this.Eo, { passive: !1 }), this.so = !0);
2244
+ }, this.Ro = (t) => {
2245
+ this.Lo(t);
2246
+ }, window.addEventListener("keydown", this.Eo, { passive: !1 }), window.addEventListener("keyup", this.Ro, { passive: !1 }), this.eo = !0);
2247
2247
  }
2248
2248
  yo() {
2249
- this.so && (window.removeEventListener("keydown", this.To), window.removeEventListener("keyup", this.Eo), this.so = !1, this.Fo.clear(), this.Po = null, this.$o = null);
2249
+ this.eo && (window.removeEventListener("keydown", this.Eo), window.removeEventListener("keyup", this.Ro), this.eo = !1, this.Po.clear(), this.$o = null, this.To = null);
2250
2250
  }
2251
- wo(t) {
2251
+ bo(t) {
2252
2252
  this.So = t;
2253
2253
  }
2254
- bo(t) {
2255
- this.Ro = t;
2254
+ Co(t) {
2255
+ this.ko = t;
2256
2256
  }
2257
- Lo(t) {
2258
- const e = this.Io(t), i = this.Fo.get(t) || this.Fo.get(e);
2257
+ Io(t) {
2258
+ const e = this.Bo(t), i = this.Po.get(t) || this.Po.get(e);
2259
2259
  return (i == null ? void 0 : i.isPressed) || !1;
2260
2260
  }
2261
2261
  Oo() {
2262
- return this.Po;
2263
- }
2264
- Bo() {
2265
2262
  return this.$o;
2266
2263
  }
2267
2264
  Ho() {
2268
- const t = [];
2269
- for (const [e, i] of this.Fo) i.isPressed && t.push(e);
2270
- return t;
2265
+ return this.To;
2271
2266
  }
2272
2267
  Go() {
2273
- return { ctrl: this.Lo("Control"), shift: this.Lo("Shift"), alt: this.Lo("Alt"), meta: this.Lo("Meta") };
2268
+ const t = [];
2269
+ for (const [e, i] of this.Po) i.isPressed && t.push(e);
2270
+ return t;
2274
2271
  }
2275
2272
  Qo() {
2276
- this.Fo.clear(), this.Po = null, this.$o = null;
2273
+ return { ctrl: this.Io("Control"), shift: this.Io("Shift"), alt: this.Io("Alt"), meta: this.Io("Meta") };
2274
+ }
2275
+ No() {
2276
+ this.Po.clear(), this.$o = null, this.To = null;
2277
2277
  }
2278
- zo(t) {
2278
+ Do(t) {
2279
2279
  const e = t.key, i = Date.now();
2280
- this.Fo.has(e) || this.Fo.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2281
- const r = this.Fo.get(e);
2282
- if (!r.isPressed && (r.isPressed = !0, r.lastPressTime = i, this.Po = e, this.So)) {
2280
+ this.Po.has(e) || this.Po.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2281
+ const r = this.Po.get(e);
2282
+ if (!r.isPressed && (r.isPressed = !0, r.lastPressTime = i, this.$o = e, this.So)) {
2283
2283
  const s = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
2284
2284
  this.So(s);
2285
2285
  }
2286
2286
  }
2287
- Do(t) {
2287
+ Lo(t) {
2288
2288
  const e = t.key, i = Date.now();
2289
- this.Fo.has(e) || this.Fo.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2290
- const r = this.Fo.get(e);
2291
- if (r.isPressed = !1, r.lastReleaseTime = i, this.$o = e, this.Ro) {
2289
+ this.Po.has(e) || this.Po.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2290
+ const r = this.Po.get(e);
2291
+ if (r.isPressed = !1, r.lastReleaseTime = i, this.To = e, this.ko) {
2292
2292
  const s = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
2293
- this.Ro(s);
2293
+ this.ko(s);
2294
2294
  }
2295
2295
  }
2296
- Io(t) {
2297
- return this.ko[t] || t.toLowerCase();
2296
+ Bo(t) {
2297
+ return this.zo[t] || t.toLowerCase();
2298
2298
  }
2299
2299
  }
2300
- const Be = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: Xt }, Symbol.toStringTag, { value: "Module" }));
2301
- class It {
2300
+ const _e = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: _t }, Symbol.toStringTag, { value: "Module" }));
2301
+ class Xt {
2302
2302
  constructor(t, e) {
2303
- a(this, "Er");
2304
- a(this, "No");
2305
- a(this, "Qn");
2306
- a(this, "Xo", /* @__PURE__ */ new Map());
2303
+ a(this, "Rr");
2304
+ a(this, "Xo");
2305
+ a(this, "Nn");
2307
2306
  a(this, "Yo", /* @__PURE__ */ new Map());
2308
2307
  a(this, "jo", /* @__PURE__ */ new Map());
2309
- a(this, "Ko", null);
2310
- a(this, "Wo");
2308
+ a(this, "Ko", /* @__PURE__ */ new Map());
2309
+ a(this, "Wo", null);
2311
2310
  a(this, "Zo");
2312
2311
  a(this, "qo");
2313
2312
  a(this, "Vo");
2314
2313
  a(this, "Jo");
2315
2314
  a(this, "th");
2316
- a(this, "so", !1);
2317
2315
  a(this, "sh");
2316
+ a(this, "eo", !1);
2318
2317
  a(this, "eh");
2319
2318
  a(this, "ih");
2320
2319
  a(this, "rh");
@@ -2324,64 +2323,62 @@ class It {
2324
2323
  a(this, "ah");
2325
2324
  a(this, "uh");
2326
2325
  a(this, "fh");
2327
- a(this, "dh", 320);
2328
- a(this, "ph", 350);
2329
- a(this, "gh", 10);
2330
- a(this, "mh", 550);
2331
- a(this, "_h", 14);
2326
+ a(this, "dh");
2327
+ a(this, "ph", 320);
2328
+ a(this, "gh", 350);
2329
+ a(this, "mh", 10);
2330
+ a(this, "_h", 550);
2331
+ a(this, "Ah", 14);
2332
2332
  a(this, "yh", 48);
2333
- a(this, "Ah", 650);
2334
- a(this, "wh", 0.02);
2335
- a(this, "bh", 2);
2336
- a(this, "Ch", 600);
2337
- a(this, "xh", 0);
2338
- a(this, "Mh", null);
2339
- this.Er = t, this.No = e;
2340
- const i = this.Er.canvas;
2341
- this.Wo = i.style.touchAction, this.Zo = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2342
- }
2343
- yr(t) {
2344
- this.Qn = t, this.lo();
2345
- }
2346
- uo() {
2347
- if (this.so) return;
2348
- const t = this.Er.canvas;
2349
- this.qo = (e) => {
2350
- this.Fh(e);
2351
- }, this.Vo = (e) => {
2333
+ a(this, "wh", 650);
2334
+ a(this, "bh", 0.02);
2335
+ a(this, "Ch", 2);
2336
+ a(this, "xh", 600);
2337
+ a(this, "Mh", 0);
2338
+ a(this, "Fh", null);
2339
+ this.Rr = t, this.Xo = e;
2340
+ const i = this.Rr.canvas;
2341
+ this.Zo = i.style.touchAction, this.qo = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2342
+ }
2343
+ Ar(t) {
2344
+ this.Nn = t, this.uo();
2345
+ }
2346
+ fo() {
2347
+ if (this.eo) return;
2348
+ const t = this.Rr.canvas;
2349
+ this.Vo = (e) => {
2352
2350
  this.Ph(e);
2353
2351
  }, this.Jo = (e) => {
2354
2352
  this.$h(e);
2355
2353
  }, this.th = (e) => {
2356
2354
  this.Th(e);
2357
- }, t.addEventListener("touchstart", this.qo, { passive: !1 }), t.addEventListener("touchmove", this.Vo, { passive: !1 }), t.addEventListener("touchend", this.Jo, { passive: !1 }), t.addEventListener("touchcancel", this.th, { passive: !1 }), this.so = !0;
2355
+ }, this.sh = (e) => {
2356
+ this.Eh(e);
2357
+ }, t.addEventListener("touchstart", this.Vo, { passive: !1 }), t.addEventListener("touchmove", this.Jo, { passive: !1 }), t.addEventListener("touchend", this.th, { passive: !1 }), t.addEventListener("touchcancel", this.sh, { passive: !1 }), this.eo = !0;
2358
2358
  }
2359
2359
  yo() {
2360
- if (!this.so) return;
2361
- const t = this.Er.canvas;
2362
- t.removeEventListener("touchstart", this.qo), t.removeEventListener("touchmove", this.Vo), t.removeEventListener("touchend", this.Jo), t.removeEventListener("touchcancel", this.th), this.so = !1, this.Ko = null, this.Xo.clear(), this.Yo.clear(), this.jo.forEach((e) => {
2360
+ if (!this.eo) return;
2361
+ const t = this.Rr.canvas;
2362
+ t.removeEventListener("touchstart", this.Vo), t.removeEventListener("touchmove", this.Jo), t.removeEventListener("touchend", this.th), t.removeEventListener("touchcancel", this.sh), this.eo = !1, this.Wo = null, this.Yo.clear(), this.jo.clear(), this.Ko.forEach((e) => {
2363
2363
  e.longPressTimer !== null && window.clearTimeout(e.longPressTimer);
2364
- }), this.jo.clear(), this.Mh = null, this.xh = 0, t.style.touchAction = this.Wo, t.style.userSelect = this.Zo;
2364
+ }), this.Ko.clear(), this.Fh = null, this.Mh = 0, t.style.touchAction = this.Zo, t.style.userSelect = this.qo;
2365
2365
  }
2366
- lo() {
2367
- if (!this.Qn || this.Xo.size === 0) return;
2366
+ uo() {
2367
+ if (!this.Nn || this.Yo.size === 0) return;
2368
2368
  const t = /* @__PURE__ */ new Map();
2369
- for (const e of this.Xo.values()) {
2370
- const i = this.Eh(e.clientX, e.clientY, e.id, e);
2369
+ for (const e of this.Yo.values()) {
2370
+ const i = this.Rh(e.clientX, e.clientY, e.id, e);
2371
2371
  t.set(e.id, i);
2372
2372
  }
2373
- this.Xo = t;
2373
+ this.Yo = t;
2374
2374
  }
2375
2375
  Sh() {
2376
- return Array.from(this.Xo.values()).map((t) => ({ ...t }));
2376
+ return Array.from(this.Yo.values()).map((t) => ({ ...t }));
2377
2377
  }
2378
- Rh(t) {
2379
- this.sh = t;
2380
- }
2381
- Co(t) {
2378
+ kh(t) {
2382
2379
  this.eh = t;
2383
2380
  }
2384
- kh(t) {
2381
+ xo(t) {
2385
2382
  this.ih = t;
2386
2383
  }
2387
2384
  zh(t) {
@@ -2396,222 +2393,225 @@ class It {
2396
2393
  Ih(t) {
2397
2394
  this.hh = t;
2398
2395
  }
2399
- Oh(t) {
2396
+ Bh(t) {
2400
2397
  this.ah = t;
2401
2398
  }
2402
- Bh(t) {
2399
+ Oh(t) {
2403
2400
  this.uh = t;
2404
2401
  }
2405
2402
  Hh(t) {
2406
2403
  this.fh = t;
2407
2404
  }
2408
- Fh(t) {
2405
+ Gh(t) {
2406
+ this.dh = t;
2407
+ }
2408
+ Ph(t) {
2409
2409
  var r;
2410
- if (!this.Qn) return;
2411
- t.preventDefault(), (r = this.No) == null || r.ho(this.Ch);
2412
- const e = performance.now(), i = this.Gh(t.changedTouches);
2410
+ if (!this.Nn) return;
2411
+ t.preventDefault(), (r = this.Xo) == null || r.ao(this.xh);
2412
+ const e = performance.now(), i = this.Qh(t.changedTouches);
2413
2413
  for (const s of i) {
2414
- const h = this.Xo.get(s.id);
2415
- h && this.Yo.set(s.id, this.Qh(h)), this.Xo.set(s.id, s);
2414
+ const h = this.Yo.get(s.id);
2415
+ h && this.jo.set(s.id, this.Nh(h)), this.Yo.set(s.id, s);
2416
2416
  const o = { id: s.id, startPosition: s, lastPosition: s, startTime: e, lastTime: e, longPressTimer: null, longPressFired: !1 };
2417
- this.hh && (o.longPressTimer = window.setTimeout(() => {
2418
- const c = this.Xo.get(s.id);
2419
- c && (o.longPressFired = !0, this.hh({ touch: this.Qh(c), duration: performance.now() - o.startTime, originalEvent: t }));
2420
- }, this.mh)), this.jo.set(s.id, o), this.sh && this.sh(this.Nh(s, t, void 0, e));
2417
+ this.ah && (o.longPressTimer = window.setTimeout(() => {
2418
+ const c = this.Yo.get(s.id);
2419
+ c && (o.longPressFired = !0, this.ah({ touch: this.Nh(c), duration: performance.now() - o.startTime, originalEvent: t }));
2420
+ }, this._h)), this.Ko.set(s.id, o), this.eh && this.eh(this.Xh(s, t, void 0, e));
2421
2421
  }
2422
- this.Xo.size === 2 && this.Xh();
2422
+ this.Yo.size === 2 && this.Yh();
2423
2423
  }
2424
- Ph(t) {
2424
+ $h(t) {
2425
2425
  var r;
2426
- if (!this.Qn) return;
2427
- t.preventDefault(), (r = this.No) == null || r.ho(this.Ch);
2428
- const e = performance.now(), i = this.Gh(t.changedTouches);
2426
+ if (!this.Nn) return;
2427
+ t.preventDefault(), (r = this.Xo) == null || r.ao(this.xh);
2428
+ const e = performance.now(), i = this.Qh(t.changedTouches);
2429
2429
  for (const s of i) {
2430
- const h = this.Xo.get(s.id), o = h ? this.Qh(h) : void 0;
2431
- o && this.Yo.set(s.id, o), this.Xo.set(s.id, s);
2432
- const c = this.jo.get(s.id);
2433
- c && (c.lastPosition = s, c.lastTime = e, o) && G(o.clientX, o.clientY, s.clientX, s.clientY) > this._h && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.eh && this.eh(this.Nh(s, t, o, e));
2430
+ const h = this.Yo.get(s.id), o = h ? this.Nh(h) : void 0;
2431
+ o && this.jo.set(s.id, o), this.Yo.set(s.id, s);
2432
+ const c = this.Ko.get(s.id);
2433
+ c && (c.lastPosition = s, c.lastTime = e, o) && z(o.clientX, o.clientY, s.clientX, s.clientY) > this.Ah && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.ih && this.ih(this.Xh(s, t, o, e));
2434
2434
  }
2435
- this.Xo.size === 2 ? this.Yh(t) : this.Ko = null;
2435
+ this.Yo.size === 2 ? this.jh(t) : this.Wo = null;
2436
2436
  }
2437
- $h(t) {
2438
- if (!this.Qn) return;
2437
+ Th(t) {
2438
+ if (!this.Nn) return;
2439
2439
  t.preventDefault();
2440
- const e = performance.now(), i = this.Gh(t.changedTouches);
2440
+ const e = performance.now(), i = this.Qh(t.changedTouches);
2441
2441
  for (const r of i) {
2442
- const s = this.Xo.get(r.id), h = s ? this.Qh(s) : void 0, o = this.jo.get(r.id);
2443
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.ih && this.ih(this.Nh(r, t, h, e)), o && this.jh(o, t), this.jo.delete(r.id), this.Yo.delete(r.id), this.Xo.delete(r.id);
2442
+ const s = this.Yo.get(r.id), h = s ? this.Nh(s) : void 0, o = this.Ko.get(r.id);
2443
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.rh && this.rh(this.Xh(r, t, h, e)), o && this.Kh(o, t), this.Ko.delete(r.id), this.jo.delete(r.id), this.Yo.delete(r.id);
2444
2444
  }
2445
- this.Xo.size < 2 && (this.Ko = null);
2445
+ this.Yo.size < 2 && (this.Wo = null);
2446
2446
  }
2447
- Th(t) {
2448
- if (!this.Qn) return;
2447
+ Eh(t) {
2448
+ if (!this.Nn) return;
2449
2449
  t.preventDefault();
2450
- const e = performance.now(), i = this.Gh(t.changedTouches);
2450
+ const e = performance.now(), i = this.Qh(t.changedTouches);
2451
2451
  for (const r of i) {
2452
- const s = this.Xo.get(r.id), h = s ? this.Qh(s) : void 0, o = this.jo.get(r.id);
2453
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.rh && this.rh(this.Nh(r, t, h, e)), this.jo.delete(r.id), this.Yo.delete(r.id), this.Xo.delete(r.id);
2452
+ const s = this.Yo.get(r.id), h = s ? this.Nh(s) : void 0, o = this.Ko.get(r.id);
2453
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.nh && this.nh(this.Xh(r, t, h, e)), this.Ko.delete(r.id), this.jo.delete(r.id), this.Yo.delete(r.id);
2454
2454
  }
2455
- this.Xo.size < 2 && (this.Ko = null);
2455
+ this.Yo.size < 2 && (this.Wo = null);
2456
2456
  }
2457
- Gh(t) {
2457
+ Qh(t) {
2458
2458
  const e = [];
2459
2459
  for (let i = 0; i < t.length; i += 1) {
2460
2460
  const r = t.item(i);
2461
- r && e.push(this.Kh(r));
2461
+ r && e.push(this.Wh(r));
2462
2462
  }
2463
2463
  return e;
2464
2464
  }
2465
- Kh(t) {
2466
- return this.Eh(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 });
2465
+ Wh(t) {
2466
+ return this.Rh(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 });
2467
2467
  }
2468
- Eh(t, e, i, r) {
2469
- const s = this.Er.canvas, h = s.getBoundingClientRect(), o = t - h.left, c = e - h.top, l = s.width / h.width, u = c * (s.height / h.height), f = o * l - this.Qn.offsetX, v = u - this.Qn.offsetY, m = Math.floor(f / this.Qn.cellWidth), d = Math.floor(v / this.Qn.cellHeight), g = m >= 0 && m < this.Qn.cols && d >= 0 && d < this.Qn.rows;
2470
- return { id: i, x: g ? m : -1, y: g ? d : -1, clientX: t, clientY: e, pressure: r.pressure, radiusX: r.radiusX, radiusY: r.radiusY, rotationAngle: r.rotationAngle };
2468
+ Rh(t, e, i, r) {
2469
+ const s = this.Rr.canvas, h = s.getBoundingClientRect(), o = t - h.left, c = e - h.top, l = s.width / h.width, u = c * (s.height / h.height), f = o * l - this.Nn.offsetX, g = u - this.Nn.offsetY, m = Math.floor(f / this.Nn.cellWidth), d = Math.floor(g / this.Nn.cellHeight), v = m >= 0 && m < this.Nn.cols && d >= 0 && d < this.Nn.rows;
2470
+ return { id: i, x: v ? m : -1, y: v ? d : -1, clientX: t, clientY: e, pressure: r.pressure, radiusX: r.radiusX, radiusY: r.radiusY, rotationAngle: r.rotationAngle };
2471
2471
  }
2472
- Nh(t, e, i, r) {
2473
- const s = this.jo.get(t.id), h = Array.from(this.Yo.values()).map((l) => this.Qh(l)), o = Array.from(this.Xo.values()).map((l) => this.Qh(l)), c = this.Gh(e.changedTouches);
2474
- return { touch: this.Qh(t), previousTouch: i ? this.Qh(i) : void 0, touches: o, previousTouches: h, changedTouches: c, deltaTime: s ? r - s.lastTime : 0, originalEvent: e };
2472
+ Xh(t, e, i, r) {
2473
+ const s = this.Ko.get(t.id), h = Array.from(this.jo.values()).map((l) => this.Nh(l)), o = Array.from(this.Yo.values()).map((l) => this.Nh(l)), c = this.Qh(e.changedTouches);
2474
+ return { touch: this.Nh(t), previousTouch: i ? this.Nh(i) : void 0, touches: o, previousTouches: h, changedTouches: c, deltaTime: s ? r - s.lastTime : 0, originalEvent: e };
2475
2475
  }
2476
- Xh() {
2477
- if (this.Xo.size !== 2) return void (this.Ko = null);
2478
- const t = Array.from(this.Xo.values()), [e, i] = t, r = G(e.x, e.y, i.x, i.y), s = bt(e.clientX, e.clientY, i.clientX, i.clientY);
2479
- this.Ko = { ids: [e.id, i.id], initialDistance: Math.max(r, 1e-4), initialAngle: s, lastScale: 1, lastRotation: 0 };
2476
+ Yh() {
2477
+ if (this.Yo.size !== 2) return void (this.Wo = null);
2478
+ const t = Array.from(this.Yo.values()), [e, i] = t, r = z(e.x, e.y, i.x, i.y), s = yt(e.clientX, e.clientY, i.clientX, i.clientY);
2479
+ this.Wo = { ids: [e.id, i.id], initialDistance: Math.max(r, 1e-4), initialAngle: s, lastScale: 1, lastRotation: 0 };
2480
2480
  }
2481
- Yh(t) {
2482
- if (this.Ko || this.Xh(), !this.Ko) return;
2483
- const [e, i] = this.Ko.ids, r = this.Xo.get(e), s = this.Xo.get(i);
2481
+ jh(t) {
2482
+ if (this.Wo || this.Yh(), !this.Wo) return;
2483
+ const [e, i] = this.Wo.ids, r = this.Yo.get(e), s = this.Yo.get(i);
2484
2484
  if (!r || !s) return;
2485
- const h = G(r.x, r.y, s.x, s.y) / this.Ko.initialDistance, o = h - this.Ko.lastScale;
2486
- this.uh && Math.abs(o) > this.wh && (this.uh({ touches: [this.Qh(r), this.Qh(s)], scale: h, deltaScale: o, center: this.Wh(r, s), originalEvent: t }), this.Ko.lastScale = h);
2487
- let c = bt(r.clientX, r.clientY, s.clientX, s.clientY) - this.Ko.initialAngle;
2485
+ const h = z(r.x, r.y, s.x, s.y) / this.Wo.initialDistance, o = h - this.Wo.lastScale;
2486
+ this.fh && Math.abs(o) > this.bh && (this.fh({ touches: [this.Nh(r), this.Nh(s)], scale: h, deltaScale: o, center: this.Zh(r, s), originalEvent: t }), this.Wo.lastScale = h);
2487
+ let c = yt(r.clientX, r.clientY, s.clientX, s.clientY) - this.Wo.initialAngle;
2488
2488
  c = (c + 180) % 360 - 180;
2489
- const l = c - this.Ko.lastRotation;
2490
- this.fh && Math.abs(l) > this.bh && (this.fh({ touches: [this.Qh(r), this.Qh(s)], rotation: c, deltaRotation: l, center: this.Wh(r, s), originalEvent: t }), this.Ko.lastRotation = c);
2489
+ const l = c - this.Wo.lastRotation;
2490
+ this.dh && Math.abs(l) > this.Ch && (this.dh({ touches: [this.Nh(r), this.Nh(s)], rotation: c, deltaRotation: l, center: this.Zh(r, s), originalEvent: t }), this.Wo.lastRotation = c);
2491
2491
  }
2492
- Wh(t, e) {
2493
- const i = (t.clientX + e.clientX) / 2, r = (t.clientY + e.clientY) / 2, s = this.Eh(i, r, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: r });
2492
+ Zh(t, e) {
2493
+ const i = (t.clientX + e.clientX) / 2, r = (t.clientY + e.clientY) / 2, s = this.Rh(i, r, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: r });
2494
2494
  return { x: s.x, y: s.y };
2495
2495
  }
2496
- jh(t, e) {
2497
- const i = performance.now(), r = i - t.startTime, s = G(t.startPosition.clientX, t.startPosition.clientY, t.lastPosition.clientX, t.lastPosition.clientY);
2498
- if (!t.longPressFired && r <= this.dh && s <= this.gh)
2499
- this.Zh(t.lastPosition, i) && this.oh ? this.oh({ touch: this.Qh(t.lastPosition), taps: 2, originalEvent: e }) : this.nh && this.nh({ touch: this.Qh(t.lastPosition), taps: 1, originalEvent: e });
2500
- else if (!t.longPressFired && r <= this.Ah && s >= this.yh) {
2496
+ Kh(t, e) {
2497
+ const i = performance.now(), r = i - t.startTime, s = z(t.startPosition.clientX, t.startPosition.clientY, t.lastPosition.clientX, t.lastPosition.clientY);
2498
+ if (!t.longPressFired && r <= this.ph && s <= this.mh)
2499
+ this.qh(t.lastPosition, i) && this.hh ? this.hh({ touch: this.Nh(t.lastPosition), taps: 2, originalEvent: e }) : this.oh && this.oh({ touch: this.Nh(t.lastPosition), taps: 1, originalEvent: e });
2500
+ else if (!t.longPressFired && r <= this.wh && s >= this.yh) {
2501
2501
  const h = { x: t.lastPosition.clientX - t.startPosition.clientX, y: t.lastPosition.clientY - t.startPosition.clientY }, o = Math.max(Math.hypot(h.x, h.y), 1e-4), c = { x: h.x / o, y: h.y / o }, l = { x: h.x / r, y: h.y / r };
2502
- this.ah && this.ah({ touch: this.Qh(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2502
+ this.uh && this.uh({ touch: this.Nh(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2503
2503
  }
2504
- this.xh = i, this.Mh = this.Qh(t.lastPosition);
2504
+ this.Mh = i, this.Fh = this.Nh(t.lastPosition);
2505
2505
  }
2506
- Zh(t, e) {
2507
- return !this.Mh || e - this.xh > this.ph ? !1 : G(t.clientX, t.clientY, this.Mh.clientX, this.Mh.clientY) <= this.gh;
2506
+ qh(t, e) {
2507
+ return !this.Fh || e - this.Mh > this.gh ? !1 : z(t.clientX, t.clientY, this.Fh.clientX, this.Fh.clientY) <= this.mh;
2508
2508
  }
2509
- Qh(t) {
2509
+ Nh(t) {
2510
2510
  return { ...t };
2511
2511
  }
2512
2512
  }
2513
- const Xe = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: It }, Symbol.toStringTag, { value: "Module" }));
2514
- class Ie {
2513
+ const Xe = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: Xt }, Symbol.toStringTag, { value: "Module" }));
2514
+ class Be {
2515
2515
  constructor(t, e) {
2516
2516
  a(this, "A");
2517
- a(this, "qh");
2518
- a(this, "Pn", null);
2519
- a(this, "Vh", 0);
2520
- a(this, "Jh", !1);
2521
- a(this, "ta", []);
2522
- a(this, "sa", -1);
2523
- this.A = t, this.qh = e;
2517
+ a(this, "Vh");
2518
+ a(this, "$n", null);
2519
+ a(this, "Jh", 0);
2520
+ a(this, "ta", !1);
2521
+ a(this, "sa", []);
2522
+ a(this, "ea", -1);
2523
+ this.A = t, this.Vh = e;
2524
2524
  }
2525
2525
  get isPreloaded() {
2526
- return this.Jh;
2526
+ return this.ta;
2527
2527
  }
2528
2528
  get totalFrames() {
2529
- return this.Vh;
2529
+ return this.Jh;
2530
2530
  }
2531
2531
  get frameRate() {
2532
- return this.Pn;
2532
+ return this.$n;
2533
2533
  }
2534
2534
  get textures() {
2535
- return this.ta;
2535
+ return this.sa;
2536
2536
  }
2537
2537
  dispose() {
2538
- this.ea(), this.ta = [], this.Pn = null, this.Vh = 0, this.Jh = !1, this.sa = -1;
2538
+ this.ia(), this.sa = [], this.$n = null, this.Jh = 0, this.ta = !1, this.ea = -1;
2539
2539
  }
2540
2540
  async preload(t, e) {
2541
2541
  var i;
2542
2542
  try {
2543
2543
  if (t <= 0) throw Error("Video preload requires a frameRate greater than 0.");
2544
- const r = this.qh.duration;
2544
+ const r = this.Vh.duration;
2545
2545
  if (!isFinite(r) || r <= 0) throw Error("Video duration is invalid, cannot preload frames.");
2546
2546
  const s = Math.max(1, Math.ceil(r * t));
2547
- return this.ia(t, s), await this.ra(t, e) ? (this.na("captureStream", e), "captureStream") : (await this.oa(t, e), this.na("seeking", e), "seeking");
2547
+ return this.ra(t, s), await this.na(t, e) ? (this.oa("captureStream", e), "captureStream") : (await this.ha(t, e), this.oa("seeking", e), "seeking");
2548
2548
  } catch (r) {
2549
2549
  const s = r instanceof Error ? r : Error(r + "");
2550
2550
  throw (i = e == null ? void 0 : e.onError) == null || i.call(e, s), this.dispose(), s;
2551
2551
  }
2552
2552
  }
2553
- ia(t, e) {
2554
- this.ea(), this.Pn = t, this.Vh = e, this.ta = [], this.Jh = !1, this.sa = -1;
2553
+ ra(t, e) {
2554
+ this.ia(), this.$n = t, this.Jh = e, this.sa = [], this.ta = !1, this.ea = -1;
2555
2555
  }
2556
- na(t, e) {
2556
+ oa(t, e) {
2557
2557
  var i;
2558
- if (this.ta.length === 0) throw Error(`Video preload via ${t} completed but produced 0 frames.`);
2559
- this.Vh = this.ta.length, this.Jh = !0, this.sa = -1, this.qh.pause(), this.qh.currentTime = 0, e != null && e.onProgress && e.onProgress({ percent: 100, loadedFrames: this.Vh, totalFrames: this.Vh, strategy: t }), (i = e == null ? void 0 : e.onComplete) == null || i.call(e, { totalFrames: this.Vh, strategy: t });
2558
+ if (this.sa.length === 0) throw Error(`Video preload via ${t} completed but produced 0 frames.`);
2559
+ this.Jh = this.sa.length, this.ta = !0, this.ea = -1, this.Vh.pause(), this.Vh.currentTime = 0, e != null && e.onProgress && e.onProgress({ percent: 100, loadedFrames: this.Jh, totalFrames: this.Jh, strategy: t }), (i = e == null ? void 0 : e.onComplete) == null || i.call(e, { totalFrames: this.Jh, strategy: t });
2560
2560
  }
2561
- ha(t) {
2561
+ aa(t) {
2562
2562
  const e = this.A, i = e.createTexture();
2563
- return e.bindTexture(e.TEXTURE_2D, i), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), rt(e, e.LINEAR, e.LINEAR, e.CLAMP_TO_EDGE, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null), i;
2563
+ return e.bindTexture(e.TEXTURE_2D, i), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), et(e, e.LINEAR, e.LINEAR, e.CLAMP_TO_EDGE, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null), i;
2564
2564
  }
2565
- aa(t, e) {
2566
- if (!(e != null && e.onProgress) || this.Vh === 0) return;
2567
- const i = Math.min(99, Math.floor(this.ta.length / this.Vh * 100)), r = 10 * Math.floor(i / 10);
2568
- r > this.sa && (this.sa = r, e.onProgress({ percent: i, loadedFrames: this.ta.length, totalFrames: this.Vh, strategy: t }));
2565
+ ca(t, e) {
2566
+ if (!(e != null && e.onProgress) || this.Jh === 0) return;
2567
+ const i = Math.min(99, Math.floor(this.sa.length / this.Jh * 100)), r = 10 * Math.floor(i / 10);
2568
+ r > this.ea && (this.ea = r, e.onProgress({ percent: i, loadedFrames: this.sa.length, totalFrames: this.Jh, strategy: t }));
2569
2569
  }
2570
- async ra(t, e) {
2571
- const i = globalThis, r = i == null ? void 0 : i.MediaStreamTrackProcessor, s = this.qh.captureStream;
2570
+ async na(t, e) {
2571
+ const i = globalThis, r = i == null ? void 0 : i.MediaStreamTrackProcessor, s = this.Vh.captureStream;
2572
2572
  if (typeof r != "function" || typeof s != "function") return !1;
2573
2573
  let h, o = null;
2574
2574
  try {
2575
- const c = s.call(this.qh);
2575
+ const c = s.call(this.Vh);
2576
2576
  if (h = c.getVideoTracks()[0], !h) return c.getTracks().forEach((f) => f.stop()), !1;
2577
- if (o = new r({ track: h }).readable.getReader(), this.qh.currentTime = 0, this.qh.muted = !0, await this.qh.play().catch(() => {
2578
- }), this.qh.paused) return !1;
2577
+ if (o = new r({ track: h }).readable.getReader(), this.Vh.currentTime = 0, this.Vh.muted = !0, await this.Vh.play().catch(() => {
2578
+ }), this.Vh.paused) return !1;
2579
2579
  const l = 1e6 / t;
2580
2580
  let u = 0;
2581
- for (; this.ta.length < this.Vh; ) {
2581
+ for (; this.sa.length < this.Jh; ) {
2582
2582
  const f = await o.read();
2583
2583
  if (f.done) break;
2584
- const v = f.value;
2585
- if (v) try {
2586
- const m = typeof v.timestamp == "number" ? v.timestamp : u;
2587
- (this.ta.length === 0 || m >= u) && (this.ta.push(this.ha(v)), u = m + l, this.aa("captureStream", e));
2584
+ const g = f.value;
2585
+ if (g) try {
2586
+ const m = typeof g.timestamp == "number" ? g.timestamp : u;
2587
+ (this.sa.length === 0 || m >= u) && (this.sa.push(this.aa(g)), u = m + l, this.ca("captureStream", e));
2588
2588
  } finally {
2589
- v.close();
2589
+ g.close();
2590
2590
  }
2591
2591
  }
2592
- return o.releaseLock(), h.stop(), o = null, h = void 0, this.qh.pause(), this.qh.currentTime = 0, this.ta.length !== 0;
2592
+ return o.releaseLock(), h.stop(), o = null, h = void 0, this.Vh.pause(), this.Vh.currentTime = 0, this.sa.length !== 0;
2593
2593
  } catch {
2594
- return this.ea(), this.ta = [], this.sa = -1, !1;
2594
+ return this.ia(), this.sa = [], this.ea = -1, !1;
2595
2595
  } finally {
2596
2596
  if (o) try {
2597
2597
  await o.cancel();
2598
2598
  } catch {
2599
2599
  }
2600
- h && h.stop(), this.qh.pause(), this.qh.currentTime = 0;
2600
+ h && h.stop(), this.Vh.pause(), this.Vh.currentTime = 0;
2601
2601
  }
2602
2602
  }
2603
- async oa(t, e) {
2604
- const i = 1 / t, r = this.Vh, s = this.qh;
2603
+ async ha(t, e) {
2604
+ const i = 1 / t, r = this.Jh, s = this.Vh;
2605
2605
  s.pause();
2606
2606
  for (let h = 0; h < r; h++) {
2607
2607
  const o = Math.min(s.duration, h * i);
2608
- await this.ca(o), this.ta.push(this.ha(s)), this.aa("seeking", e);
2608
+ await this.la(o), this.sa.push(this.aa(s)), this.ca("seeking", e);
2609
2609
  }
2610
2610
  s.currentTime = 0;
2611
2611
  }
2612
- ca(t) {
2612
+ la(t) {
2613
2613
  return new Promise((e, i) => {
2614
- const r = this.qh, s = () => {
2614
+ const r = this.Vh, s = () => {
2615
2615
  r.removeEventListener("seeked", h), r.removeEventListener("error", o);
2616
2616
  }, h = () => {
2617
2617
  s(), e();
@@ -2624,86 +2624,86 @@ class Ie {
2624
2624
  r.currentTime = l;
2625
2625
  });
2626
2626
  }
2627
- ea() {
2628
- for (const t of this.ta) this.A.deleteTexture(t);
2627
+ ia() {
2628
+ for (const t of this.sa) this.A.deleteTexture(t);
2629
2629
  }
2630
2630
  }
2631
- class ht extends Dt {
2631
+ class st extends St {
2632
2632
  constructor(e, i, r, s, h, o, c, l, u) {
2633
2633
  const f = o / c;
2634
- let v, m;
2635
- f > 1 ? (v = l, m = Math.round(l / f)) : (m = u, v = Math.round(u * f));
2636
- super(e, i, r, s, o, c, v, m);
2637
- a(this, "qh");
2638
- a(this, "la", 0);
2639
- a(this, "ua", null);
2640
- this.qh = h;
2634
+ let g, m;
2635
+ f > 1 ? (g = l, m = Math.round(l / f)) : (m = u, g = Math.round(u * f));
2636
+ super(e, i, r, s, o, c, g, m);
2637
+ a(this, "Vh");
2638
+ a(this, "ua", 0);
2639
+ a(this, "fa", null);
2640
+ this.Vh = h;
2641
2641
  }
2642
2642
  gt() {
2643
2643
  var e;
2644
- super.gt(), (e = this.ua) == null || e.dispose(), this.ua = null, this.qh.pause(), this.qh.src = "", this.qh.load();
2644
+ super.gt(), (e = this.fa) == null || e.dispose(), this.fa = null, this.Vh.pause(), this.Vh.src = "", this.Vh.load();
2645
2645
  }
2646
- fa() {
2646
+ da() {
2647
2647
  var e;
2648
- if (!((e = this.ua) != null && e.isPreloaded) && this.qh.readyState >= this.qh.HAVE_CURRENT_DATA) {
2648
+ if (!((e = this.fa) != null && e.isPreloaded) && this.Vh.readyState >= this.Vh.HAVE_CURRENT_DATA) {
2649
2649
  const i = this.A;
2650
- i.bindTexture(i.TEXTURE_2D, this.Jr), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.qh), i.bindTexture(i.TEXTURE_2D, null);
2650
+ i.bindTexture(i.TEXTURE_2D, this.tn), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.Vh), i.bindTexture(i.TEXTURE_2D, null);
2651
2651
  }
2652
2652
  }
2653
- wn() {
2653
+ bn() {
2654
2654
  var i, r;
2655
- const e = (i = this.ua) == null ? void 0 : i.textures;
2656
- return e && e.length > 0 && ((r = this.ua) != null && r.isPreloaded) ? e[this.la % e.length] : this.Jr;
2655
+ const e = (i = this.fa) == null ? void 0 : i.textures;
2656
+ return e && e.length > 0 && ((r = this.fa) != null && r.isPreloaded) ? e[this.ua % e.length] : this.tn;
2657
2657
  }
2658
2658
  ut() {
2659
2659
  return this.q = null, super.ut();
2660
2660
  }
2661
- _n() {
2662
- this.fa();
2661
+ An() {
2662
+ this.da();
2663
2663
  }
2664
2664
  frame(e) {
2665
2665
  var r, s;
2666
- const i = ((r = this.ua) == null ? void 0 : r.totalFrames) ?? 0;
2667
- return (s = this.ua) != null && s.isPreloaded && e !== void 0 && i > 0 && (this.la = (e % i + i) % i, this.q = null), this;
2666
+ const i = ((r = this.fa) == null ? void 0 : r.totalFrames) ?? 0;
2667
+ return (s = this.fa) != null && s.isPreloaded && e !== void 0 && i > 0 && (this.ua = (e % i + i) % i, this.q = null), this;
2668
2668
  }
2669
- static async bn(e, i, r, s, h, o) {
2669
+ static async Cn(e, i, r, s, h, o) {
2670
2670
  const c = e.context, l = o == null ? void 0 : o.frameRate;
2671
2671
  let u;
2672
- u = document.createElement("video"), u.crossOrigin = "anonymous", u.loop = !0, u.muted = !0, u.playsInline = !0, await new Promise((g, A) => {
2673
- u.addEventListener("loadedmetadata", () => g(), { once: !0 }), u.addEventListener("error", (p) => {
2674
- var E;
2675
- const y = p.target;
2676
- A(Error("Failed to load video: " + (((E = y.error) == null ? void 0 : E.message) || "Unknown error")));
2672
+ u = document.createElement("video"), u.crossOrigin = "anonymous", u.loop = !0, u.muted = !0, u.playsInline = !0, await new Promise((v, p) => {
2673
+ u.addEventListener("loadedmetadata", () => v(), { once: !0 }), u.addEventListener("error", (A) => {
2674
+ var y;
2675
+ const w = A.target;
2676
+ p(Error("Failed to load video: " + (((y = w.error) == null ? void 0 : y.message) || "Unknown error")));
2677
2677
  }, { once: !0 }), u.src = r;
2678
2678
  });
2679
2679
  const f = c.createTexture();
2680
- c.bindTexture(c.TEXTURE_2D, f), c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL, 1), rt(c, c.LINEAR, c.LINEAR, c.CLAMP_TO_EDGE, c.CLAMP_TO_EDGE), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, c.RGBA, c.UNSIGNED_BYTE, u), c.bindTexture(c.TEXTURE_2D, null);
2681
- const v = u.videoWidth, m = u.videoHeight, d = new ht(c, e, f, i, u, v, m, s, h);
2682
- return l && l > 0 && (d.ua = new Ie(c, u), await d.ua.preload(l, o), d.la = 0), d;
2680
+ c.bindTexture(c.TEXTURE_2D, f), c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL, 1), et(c, c.LINEAR, c.LINEAR, c.CLAMP_TO_EDGE, c.CLAMP_TO_EDGE), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, c.RGBA, c.UNSIGNED_BYTE, u), c.bindTexture(c.TEXTURE_2D, null);
2681
+ const g = u.videoWidth, m = u.videoHeight, d = new st(c, e, f, i, u, g, m, s, h);
2682
+ return l && l > 0 && (d.fa = new Be(c, u), await d.fa.preload(l, o), d.ua = 0), d;
2683
2683
  }
2684
2684
  async play() {
2685
- await this.qh.play();
2685
+ await this.Vh.play();
2686
2686
  }
2687
2687
  pause() {
2688
- this.qh.pause();
2688
+ this.Vh.pause();
2689
2689
  }
2690
2690
  stop() {
2691
- this.qh.pause(), this.qh.currentTime = 0;
2691
+ this.Vh.pause(), this.Vh.currentTime = 0;
2692
2692
  }
2693
2693
  speed(e) {
2694
- return this.qh.playbackRate = e, this;
2694
+ return this.Vh.playbackRate = e, this;
2695
2695
  }
2696
2696
  loop(e = !0) {
2697
- return this.qh.loop = e, this;
2697
+ return this.Vh.loop = e, this;
2698
2698
  }
2699
2699
  time(e) {
2700
- return this.qh.currentTime = e, this;
2700
+ return this.Vh.currentTime = e, this;
2701
2701
  }
2702
2702
  volume(e) {
2703
- return this.qh.volume = Math.max(0, Math.min(1, e)), this;
2703
+ return this.Vh.volume = Math.max(0, Math.min(1, e)), this;
2704
2704
  }
2705
2705
  get texture() {
2706
- return this.Jr;
2706
+ return this.tn;
2707
2707
  }
2708
2708
  get width() {
2709
2709
  return this.N;
@@ -2712,31 +2712,31 @@ class ht extends Dt {
2712
2712
  return this.X;
2713
2713
  }
2714
2714
  get originalWidth() {
2715
- return this.tn;
2715
+ return this.sn;
2716
2716
  }
2717
2717
  get originalHeight() {
2718
- return this.sn;
2718
+ return this.en;
2719
2719
  }
2720
2720
  get videoElement() {
2721
- return this.qh;
2721
+ return this.Vh;
2722
2722
  }
2723
2723
  get currentTime() {
2724
- return this.qh.currentTime;
2724
+ return this.Vh.currentTime;
2725
2725
  }
2726
2726
  get duration() {
2727
- return this.qh.duration;
2727
+ return this.Vh.duration;
2728
2728
  }
2729
2729
  get isPlaying() {
2730
- return !this.qh.paused && !this.qh.ended;
2730
+ return !this.Vh.paused && !this.Vh.ended;
2731
2731
  }
2732
2732
  get totalFrames() {
2733
2733
  var e;
2734
- return ((e = this.ua) == null ? void 0 : e.totalFrames) ?? 0;
2734
+ return ((e = this.fa) == null ? void 0 : e.totalFrames) ?? 0;
2735
2735
  }
2736
2736
  }
2737
- const Oe = (n) => class extends n {
2738
- da(t, e, i, r) {
2739
- if (M.Wr(t)) return t;
2737
+ const Ie = (n) => class extends n {
2738
+ va(t, e, i, r) {
2739
+ if (M.Zr(t)) return t;
2740
2740
  if (typeof t == "number" || typeof t == "string") return this.color(t, e, i, r);
2741
2741
  throw Error("Unsupported color input passed to color-capable method.");
2742
2742
  }
@@ -2771,7 +2771,7 @@ const Oe = (n) => class extends n {
2771
2771
  this.Z.state.ht();
2772
2772
  }
2773
2773
  color(t, e, i, r) {
2774
- return M.Kr(t, e, i, r);
2774
+ return M.Wr(t, e, i, r);
2775
2775
  }
2776
2776
  rect(t = 1, e = 1) {
2777
2777
  this.Z.wi(t, e);
@@ -2786,7 +2786,7 @@ const Oe = (n) => class extends n {
2786
2786
  this.Z.state.Zt(t);
2787
2787
  }
2788
2788
  background(t, e, i, r = 255) {
2789
- const s = this.da(t, e, i, r);
2789
+ const s = this.va(t, e, i, r);
2790
2790
  this.Z.$i(s.r, s.g, s.b, s.a);
2791
2791
  }
2792
2792
  char(t) {
@@ -2795,11 +2795,11 @@ const Oe = (n) => class extends n {
2795
2795
  this.Z.state.hs(this.rr.Mr(e[0]));
2796
2796
  }
2797
2797
  charColor(t, e, i, r) {
2798
- const s = this.da(t, e, i, r);
2798
+ const s = this.va(t, e, i, r);
2799
2799
  this.Z.state.cs(s.r, s.g, s.b, s.a);
2800
2800
  }
2801
2801
  cellColor(t, e, i, r) {
2802
- const s = this.da(t, e, i, r);
2802
+ const s = this.va(t, e, i, r);
2803
2803
  this.Z.state.ls(s.r, s.g, s.b, s.a);
2804
2804
  }
2805
2805
  flipX(t) {
@@ -2815,7 +2815,7 @@ const Oe = (n) => class extends n {
2815
2815
  this.Z.state.ds(t);
2816
2816
  }
2817
2817
  clear() {
2818
- this.Z.Ae(0, 0, 0, 0);
2818
+ this.Z.ye(0, 0, 0, 0);
2819
2819
  }
2820
2820
  ellipse(t, e) {
2821
2821
  this.Z.Ci(t / 2, e / 2);
@@ -2862,326 +2862,326 @@ const Oe = (n) => class extends n {
2862
2862
  return this.Z.Pi(t.width ?? this.grid.cols, t.height ?? this.grid.rows, t.attachments ?? 3);
2863
2863
  }
2864
2864
  image(t, e, i) {
2865
- this.Z.yi(t, e, i), t instanceof j && this.Z.ct();
2865
+ this.Z.Ai(t, e, i), t instanceof H && this.Z.ct();
2866
2866
  }
2867
2867
  ortho() {
2868
2868
  this.Z.state.gs(!0);
2869
2869
  }
2870
2870
  async loadImage(t) {
2871
2871
  if (typeof t != "string") {
2872
- const s = z.bn(this.Z, this.rr, t, this.Qn.cols, this.Qn.rows);
2873
- return this.va(s), s;
2872
+ const s = Y.Cn(this.Z, this.rr, t, this.Nn.cols, this.Nn.rows);
2873
+ return this.pa(s), s;
2874
2874
  }
2875
2875
  const e = t, i = await new Promise((s, h) => {
2876
2876
  const o = new Image();
2877
2877
  o.crossOrigin = "anonymous", o.onload = () => s(o), o.onerror = (c) => h(c), o.src = e;
2878
- }), r = z.bn(this.Z, this.rr, i, this.Qn.cols, this.Qn.rows);
2879
- return this.va(r), r;
2878
+ }), r = Y.Cn(this.Z, this.rr, i, this.Nn.cols, this.Nn.rows);
2879
+ return this.pa(r), r;
2880
2880
  }
2881
2881
  async loadVideo(t, e) {
2882
- const i = await ht.bn(this.Z, this.rr, t, this.Qn.cols, this.Qn.rows, e);
2883
- return this.va(i), i;
2882
+ const i = await st.Cn(this.Z, this.rr, t, this.Nn.cols, this.Nn.rows, e);
2883
+ return this.pa(i), i;
2884
2884
  }
2885
2885
  }, Ze = (n) => class extends n {
2886
2886
  async loadFont(t) {
2887
2887
  return this.rr.Cr(t).then(() => {
2888
2888
  const e = this.rr.maxGlyphDimensions;
2889
- this.Qn.kr(e.width, e.height), this.pa.resize(this.Qn.cols, this.Qn.rows), this.Z.Ei(), this.No.lo(), this.ga.lo();
2890
- for (const i of this.ma) i.mn(this.rr);
2889
+ this.Nn.zr(e.width, e.height), this.ga.resize(this.Nn.cols, this.Nn.rows), this.Z.Ei(), this.Xo.uo(), this.ma.uo();
2890
+ for (const i of this._a) i._n(this.rr);
2891
2891
  });
2892
2892
  }
2893
2893
  fontSize(t) {
2894
- if (!pt.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.rr.fontSize === t) return;
2894
+ if (!mt.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.rr.fontSize === t) return;
2895
2895
  this.rr.br(t);
2896
2896
  const e = this.rr.maxGlyphDimensions;
2897
- this.Qn.kr(e.width, e.height), this.pa.resize(this.Qn.cols, this.Qn.rows), this.Z.Ei(), this.No.lo(), this.ga.lo();
2897
+ this.Nn.zr(e.width, e.height), this.ga.resize(this.Nn.cols, this.Nn.rows), this.Z.Ei(), this.Xo.uo(), this.ma.uo();
2898
2898
  }
2899
2899
  }, Ye = (n) => class extends n {
2900
2900
  get frameCount() {
2901
- return this._a.Hn;
2901
+ return this.ya.Gn;
2902
2902
  }
2903
2903
  set frameCount(t) {
2904
- this._a.Hn = t;
2904
+ this.ya.Gn = t;
2905
2905
  }
2906
2906
  frameRate(t) {
2907
- return t === void 0 ? this._a.Bn : this._a.Ln(t, () => this.ya());
2907
+ return t === void 0 ? this.ya.Hn : this.ya.In(t, () => this.wa());
2908
2908
  }
2909
2909
  noLoop() {
2910
- this._a.zn();
2910
+ this.ya.Dn();
2911
2911
  }
2912
2912
  loop() {
2913
- this._a.Dn(() => this.ya());
2913
+ this.ya.Ln(() => this.wa());
2914
2914
  }
2915
2915
  redraw(t = 1) {
2916
- if (pt.m(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.ya();
2916
+ if (mt.m(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.wa();
2917
2917
  }
2918
2918
  isLooping() {
2919
- return this._a.On;
2919
+ return this.ya.On;
2920
2920
  }
2921
- }, ze = (n) => class extends n {
2921
+ }, Oe = (n) => class extends n {
2922
2922
  constructor(...t) {
2923
2923
  super(...t);
2924
2924
  }
2925
2925
  mouseClicked(t) {
2926
- this.No.Ao(t);
2926
+ this.Xo.wo(t);
2927
2927
  }
2928
2928
  mousePressed(t) {
2929
- this.No.wo(t);
2929
+ this.Xo.bo(t);
2930
2930
  }
2931
2931
  mouseReleased(t) {
2932
- this.No.bo(t);
2932
+ this.Xo.Co(t);
2933
2933
  }
2934
2934
  mouseMoved(t) {
2935
- this.No.Co(t);
2935
+ this.Xo.xo(t);
2936
2936
  }
2937
2937
  mouseScrolled(t) {
2938
- this.No.xo(t);
2938
+ this.Xo.Mo(t);
2939
2939
  }
2940
2940
  get mouse() {
2941
- return this.No.Mo();
2941
+ return this.Xo.Fo();
2942
2942
  }
2943
2943
  cursor(t) {
2944
- this.No.co(t);
2944
+ this.Xo.lo(t);
2945
2945
  }
2946
- }, Qe = (n) => class extends n {
2946
+ }, ze = (n) => class extends n {
2947
2947
  constructor(...t) {
2948
2948
  super(...t);
2949
2949
  }
2950
2950
  touchStarted(t) {
2951
- this.ga.Rh(t);
2951
+ this.ma.kh(t);
2952
2952
  }
2953
2953
  touchMoved(t) {
2954
- this.ga.Co(t);
2954
+ this.ma.xo(t);
2955
2955
  }
2956
2956
  touchEnded(t) {
2957
- this.ga.kh(t);
2957
+ this.ma.zh(t);
2958
2958
  }
2959
2959
  touchCancelled(t) {
2960
- this.ga.zh(t);
2960
+ this.ma.Dh(t);
2961
2961
  }
2962
2962
  tap(t) {
2963
- this.ga.Dh(t);
2963
+ this.ma.Lh(t);
2964
2964
  }
2965
2965
  doubleTap(t) {
2966
- this.ga.Lh(t);
2966
+ this.ma.Ih(t);
2967
2967
  }
2968
2968
  longPress(t) {
2969
- this.ga.Ih(t);
2969
+ this.ma.Bh(t);
2970
2970
  }
2971
2971
  swipe(t) {
2972
- this.ga.Oh(t);
2972
+ this.ma.Oh(t);
2973
2973
  }
2974
2974
  pinch(t) {
2975
- this.ga.Bh(t);
2975
+ this.ma.Hh(t);
2976
2976
  }
2977
2977
  rotateGesture(t) {
2978
- this.ga.Hh(t);
2978
+ this.ma.Gh(t);
2979
2979
  }
2980
2980
  get touches() {
2981
- return this.ga.Sh();
2981
+ return this.ma.Sh();
2982
2982
  }
2983
- }, Ge = (n) => class extends n {
2983
+ }, Ve = (n) => class extends n {
2984
2984
  constructor(...t) {
2985
2985
  super(...t);
2986
2986
  }
2987
2987
  keyPressed(t) {
2988
- this.wa.wo(t);
2988
+ this.ba.bo(t);
2989
2989
  }
2990
2990
  keyReleased(t) {
2991
- this.wa.bo(t);
2991
+ this.ba.Co(t);
2992
2992
  }
2993
2993
  isKeyPressed(t) {
2994
- return this.wa.Lo(t);
2994
+ return this.ba.Io(t);
2995
2995
  }
2996
2996
  get lastKeyPressed() {
2997
- return this.wa.Oo();
2997
+ return this.ba.Oo();
2998
2998
  }
2999
2999
  get lastKeyReleased() {
3000
- return this.wa.Bo();
3000
+ return this.ba.Ho();
3001
3001
  }
3002
3002
  get pressedKeys() {
3003
- return this.wa.Ho();
3003
+ return this.ba.Go();
3004
3004
  }
3005
3005
  get modifierState() {
3006
- return this.wa.Go();
3006
+ return this.ba.Qo();
3007
3007
  }
3008
3008
  };
3009
- class qe {
3009
+ class Ge {
3010
3010
  constructor(t) {
3011
- a(this, "ba");
3012
- a(this, "Ca", /* @__PURE__ */ new Map());
3013
- a(this, "xa", []);
3014
- a(this, "Ma", /* @__PURE__ */ new Map());
3011
+ a(this, "Ca");
3012
+ a(this, "xa", /* @__PURE__ */ new Map());
3013
+ a(this, "Ma", []);
3015
3014
  a(this, "Fa", /* @__PURE__ */ new Map());
3016
- this.ba = t;
3015
+ a(this, "Pa", /* @__PURE__ */ new Map());
3016
+ this.Ca = t;
3017
3017
  }
3018
- async Pa(t) {
3018
+ async $a(t) {
3019
3019
  for (const e of t) {
3020
- if (this.Ca.has(e.name)) return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);
3021
- const i = this.$a(e.name);
3020
+ if (this.xa.has(e.name)) return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);
3021
+ const i = this.Ta(e.name);
3022
3022
  try {
3023
- await e.install(this.ba, i);
3023
+ await e.install(this.Ca, i);
3024
3024
  } catch (r) {
3025
- throw this.Ta(e.name), r;
3025
+ throw this.Ea(e.name), r;
3026
3026
  }
3027
- this.Ca.set(e.name, e), this.xa.push(e.name);
3027
+ this.xa.set(e.name, e), this.Ma.push(e.name);
3028
3028
  }
3029
3029
  }
3030
- async Ea(t) {
3031
- const e = this.Ca.get(t);
3030
+ async Ra(t) {
3031
+ const e = this.xa.get(t);
3032
3032
  if (!e) return;
3033
- const i = this.$a(t);
3034
- e.uninstall && await e.uninstall(this.ba, i), this.Ca.delete(t), this.xa.splice(this.xa.indexOf(t), 1), this.Ta(t);
3033
+ const i = this.Ta(t);
3034
+ e.uninstall && await e.uninstall(this.Ca, i), this.xa.delete(t), this.Ma.splice(this.Ma.indexOf(t), 1), this.Ea(t);
3035
3035
  }
3036
3036
  Sa() {
3037
- this.Ra(this.Ma);
3037
+ this.ka(this.Fa);
3038
3038
  }
3039
- ka() {
3040
- this.Ra(this.Fa);
3039
+ za() {
3040
+ this.ka(this.Pa);
3041
3041
  }
3042
- async za() {
3043
- const t = [...this.Ca.keys()];
3044
- for (const e of t) await this.Ea(e);
3042
+ async Da() {
3043
+ const t = [...this.xa.keys()];
3044
+ for (const e of t) await this.Ra(e);
3045
3045
  }
3046
- $a(t) {
3047
- return { renderer: this.ba.Z, font: this.ba.rr, grid: this.ba.Qn, canvas: this.ba.Er, drawFramebuffer: this.ba.pa, asciiFramebuffer: this.ba.Da, registerPreDrawHook: (e) => this.La(this.Ma, t, e), registerPostDrawHook: (e) => this.La(this.Fa, t, e) };
3046
+ Ta(t) {
3047
+ return { renderer: this.Ca.Z, font: this.Ca.rr, grid: this.Ca.Nn, canvas: this.Ca.Rr, drawFramebuffer: this.Ca.ga, asciiFramebuffer: this.Ca.La, registerPreDrawHook: (e) => this.Ia(this.Fa, t, e), registerPostDrawHook: (e) => this.Ia(this.Pa, t, e) };
3048
3048
  }
3049
- La(t, e, i) {
3049
+ Ia(t, e, i) {
3050
3050
  const r = t.get(e) ?? /* @__PURE__ */ new Set();
3051
3051
  return r.add(i), t.set(e, r), () => {
3052
3052
  const s = t.get(e);
3053
3053
  s && (s.delete(i), s.size === 0 && t.delete(e));
3054
3054
  };
3055
3055
  }
3056
- Ta(t) {
3057
- this.Ma.delete(t), this.Fa.delete(t);
3056
+ Ea(t) {
3057
+ this.Fa.delete(t), this.Pa.delete(t);
3058
3058
  }
3059
- Ra(t) {
3060
- for (const e of this.xa) {
3059
+ ka(t) {
3060
+ for (const e of this.Ma) {
3061
3061
  const i = t.get(e);
3062
3062
  i && i.forEach((r) => r());
3063
3063
  }
3064
3064
  }
3065
3065
  }
3066
- const K = `#version 300 es
3066
+ const Q = `#version 300 es
3067
3067
  in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;
3068
- class Ot {
3068
+ class Bt {
3069
3069
  constructor() {
3070
- a(this, "Ia", /* @__PURE__ */ new Map());
3070
+ a(this, "Ba", /* @__PURE__ */ new Map());
3071
3071
  a(this, "Oa", []);
3072
- a(this, "Ba", 0);
3073
3072
  a(this, "Ha", 0);
3074
- a(this, "Ga");
3075
- }
3076
- get Qa() {
3077
- return this.Ba;
3073
+ a(this, "Ga", 0);
3074
+ a(this, "Qa");
3078
3075
  }
3079
3076
  get Na() {
3080
- if (this.Ba === 0) return 0;
3077
+ return this.Ha;
3078
+ }
3079
+ get Xa() {
3080
+ if (this.Ha === 0) return 0;
3081
3081
  let t = 0;
3082
3082
  for (const e of this.Oa) {
3083
- const i = this.Ia.get(e);
3083
+ const i = this.Ba.get(e);
3084
3084
  i && (t += Math.min(1, Math.max(0, i.progress)) * i.weight);
3085
3085
  }
3086
- return Math.min(1, t / this.Ba);
3086
+ return Math.min(1, t / this.Ha);
3087
3087
  }
3088
- Xa(t) {
3089
- this.Ga = t;
3088
+ Ya(t) {
3089
+ this.Qa = t;
3090
3090
  }
3091
- Ya(t, e = 1) {
3091
+ ja(t, e = 1) {
3092
3092
  const i = `phase-${this.Oa.length + 1}-${Date.now()}`, r = { id: i, label: t, weight: Math.max(1e-3, e), progress: 0, status: "running" };
3093
- return this.Ia.set(i, r), this.Oa.push(i), this.Ba += r.weight, i;
3093
+ return this.Ba.set(i, r), this.Oa.push(i), this.Ha += r.weight, i;
3094
3094
  }
3095
- ja(t, e) {
3096
- const i = this.Ia.get(t);
3095
+ Ka(t, e) {
3096
+ const i = this.Ba.get(t);
3097
3097
  if (!i) return;
3098
3098
  i.progress = Math.max(0, Math.min(1, e)), i.status = i.progress >= 1 ? "complete" : "running";
3099
- const r = this.Na;
3100
- Math.abs(r - this.Ha) > 1e-3 && (this.Ha = r, this.Ga && this.Ga(r));
3101
- }
3102
- Ka(t) {
3103
- const e = this.Ia.get(t);
3104
- e && (e.progress = 1, e.status = "complete", this.ja(t, 1));
3099
+ const r = this.Xa;
3100
+ Math.abs(r - this.Ga) > 1e-3 && (this.Ga = r, this.Qa && this.Qa(r));
3105
3101
  }
3106
3102
  Wa(t) {
3107
- const e = this.Ia.get(t);
3103
+ const e = this.Ba.get(t);
3104
+ e && (e.progress = 1, e.status = "complete", this.Ka(t, 1));
3105
+ }
3106
+ Za(t) {
3107
+ const e = this.Ba.get(t);
3108
3108
  e && (e.status = "failed");
3109
3109
  }
3110
- Za() {
3110
+ qa() {
3111
3111
  return this.Oa.map((t) => {
3112
- const e = this.Ia.get(t);
3112
+ const e = this.Ba.get(t);
3113
3113
  return e ? { id: e.id, label: e.label, weight: e.weight, progress: e.progress, status: e.status } : { id: t, label: t, weight: 1, progress: 0, status: "pending" };
3114
3114
  });
3115
3115
  }
3116
3116
  }
3117
- class Zt {
3117
+ class It {
3118
3118
  constructor(t = "active") {
3119
- a(this, "qa");
3120
- a(this, "Va", "");
3119
+ a(this, "Va");
3121
3120
  a(this, "Ja", "");
3122
- this.qa = t;
3123
- }
3124
- get tc() {
3125
- return this.qa;
3121
+ a(this, "tc", "");
3122
+ this.Va = t;
3126
3123
  }
3127
3124
  get sc() {
3128
- return this.qa !== "disabled";
3125
+ return this.Va;
3129
3126
  }
3130
3127
  get ec() {
3131
- return this.qa === "active" || this.qa === "transitioning" || this.qa === "error";
3128
+ return this.Va !== "disabled";
3132
3129
  }
3133
3130
  get rc() {
3134
- return this.Va;
3131
+ return this.Va === "active" || this.Va === "transitioning" || this.Va === "error";
3135
3132
  }
3136
3133
  get nc() {
3137
3134
  return this.Ja;
3138
3135
  }
3139
- oc() {
3140
- this.qa !== "done" && this.qa !== "transitioning" || (this.qa = "active");
3136
+ get oc() {
3137
+ return this.tc;
3141
3138
  }
3142
3139
  hc() {
3143
- this.qa !== "disabled" && (this.qa = "done");
3140
+ this.Va !== "done" && this.Va !== "transitioning" || (this.Va = "active");
3144
3141
  }
3145
3142
  ac() {
3146
- this.qa !== "disabled" && (this.qa = "transitioning");
3143
+ this.Va !== "disabled" && (this.Va = "done");
3147
3144
  }
3148
3145
  cc() {
3149
- this.qa === "transitioning" && (this.qa = "done");
3146
+ this.Va !== "disabled" && (this.Va = "transitioning");
3150
3147
  }
3151
- lc(t) {
3152
- this.qa !== "disabled" && (this.qa = "error", t instanceof Error ? (this.Va = t.message, this.Ja = t.stack || "") : (this.Va = t, this.Ja = ""));
3148
+ lc() {
3149
+ this.Va === "transitioning" && (this.Va = "done");
3153
3150
  }
3154
- uc() {
3155
- this.qa = "disabled";
3151
+ uc(t) {
3152
+ this.Va !== "disabled" && (this.Va = "error", t instanceof Error ? (this.Ja = t.message, this.tc = t.stack || "") : (this.Ja = t, this.tc = ""));
3153
+ }
3154
+ fc() {
3155
+ this.Va = "disabled";
3156
3156
  }
3157
3157
  }
3158
- class Yt {
3158
+ class Zt {
3159
3159
  constructor(t, e) {
3160
- a(this, "fc", 0);
3161
- a(this, "dc", 1);
3162
- a(this, "vc");
3160
+ a(this, "dc", 0);
3161
+ a(this, "vc", 1);
3163
3162
  a(this, "gc");
3164
- this.vc = t, this.gc = e;
3165
- }
3166
- get mc() {
3167
- return this.dc;
3163
+ a(this, "mc");
3164
+ this.gc = t, this.mc = e;
3168
3165
  }
3169
3166
  get _c() {
3170
- return this.dc < 1;
3167
+ return this.vc;
3168
+ }
3169
+ get yc() {
3170
+ return this.vc < 1;
3171
3171
  }
3172
- Rn() {
3173
- this.vc !== "none" && this.gc > 0 && (this.fc = performance.now());
3172
+ kn() {
3173
+ this.gc !== "none" && this.mc > 0 && (this.dc = performance.now());
3174
3174
  }
3175
3175
  it() {
3176
- if (this.vc === "none" || this.gc === 0) return this.dc = 1, !1;
3177
- const t = performance.now() - this.fc, e = Math.min(1, t / this.gc);
3178
- return e >= 1 ? (this.dc = 0, !0) : (this.dc = 1 - e, !1);
3176
+ if (this.gc === "none" || this.mc === 0) return this.vc = 1, !1;
3177
+ const t = performance.now() - this.dc, e = Math.min(1, t / this.mc);
3178
+ return e >= 1 ? (this.vc = 0, !0) : (this.vc = 1 - e, !1);
3179
3179
  }
3180
3180
  te() {
3181
- this.dc = 1, this.fc = 0;
3181
+ this.vc = 1, this.dc = 0;
3182
3182
  }
3183
3183
  }
3184
- function vt(n, t) {
3184
+ function dt(n, t) {
3185
3185
  const e = n.tone ?? "auto";
3186
3186
  let i = "dark";
3187
3187
  return e === "light" || e === "dark" ? i = e : t && (i = function(r) {
@@ -3190,67 +3190,67 @@ function vt(n, t) {
3190
3190
  return 0.2126 * c(s) + 0.7152 * c(h) + 0.0722 * c(o);
3191
3191
  }(t) > 0.5 ? "light" : "dark"), { mode: i, background: t, textColor: i === "light" ? "#1A1A1A" : "#F8F8F8", subtleColor: i === "light" ? "#4A4A4A" : "#C0C0C0" };
3192
3192
  }
3193
- function zt(n) {
3193
+ function Yt(n) {
3194
3194
  return n.mode === "light" ? ["#E91E63", "#9C27B0", "#FF6F00"] : ["#8EF9F3", "#F15BB5", "#FF9B71"];
3195
3195
  }
3196
- function Qt(n, t) {
3196
+ function Ot(n, t) {
3197
3197
  return n.length ? n.map((e) => t.color(e)) : [t.color("#FFFFFF")];
3198
3198
  }
3199
3199
  const We = ({ textmodifier: n, grid: t, progress: e, frameCount: i, message: r, palette: s, theme: h, phases: o, transitionOpacity: c, isError: l, errorMessage: u }) => {
3200
- const f = "|/-\\", v = Math.floor(i / 6) % 4, m = n.color(h.textColor), d = Math.floor(255 * c), g = n.color(m.r, m.g, m.b, d);
3201
- if (n.charColor(g), n.cellColor(0, 0, 0, 0), l) {
3202
- const A = n.color(h.mode === "light" ? "#D32F2F" : "#FF6B6B", d);
3203
- n.charColor(A), n.push(), n.translate(0, -2, 0), n.char("X"), n.rect(1, 1), n.pop();
3204
- const p = "SETUP ERROR", y = -Math.floor(p.length / 2);
3205
- n.push(), n.translate(y, 0, 0);
3206
- for (const E of p) n.char(E), n.rect(1, 1), n.translateX(1);
3200
+ const f = "|/-\\", g = Math.floor(i / 6) % 4, m = n.color(h.textColor), d = Math.floor(255 * c), v = n.color(m.r, m.g, m.b, d);
3201
+ if (n.charColor(v), n.cellColor(0, 0, 0, 0), l) {
3202
+ const p = n.color(h.mode === "light" ? "#D32F2F" : "#FF6B6B", d);
3203
+ n.charColor(p), n.push(), n.translate(0, -2, 0), n.char("X"), n.rect(1, 1), n.pop();
3204
+ const A = "SETUP ERROR", w = -Math.floor(A.length / 2);
3205
+ n.push(), n.translate(w, 0, 0);
3206
+ for (const y of A) n.char(y), n.rect(1, 1), n.translateX(1);
3207
3207
  if (n.pop(), u) {
3208
- const E = n.color(h.subtleColor), x = n.color(E.r, E.g, E.b, d);
3208
+ const y = n.color(h.subtleColor), x = n.color(y.r, y.g, y.b, d);
3209
3209
  n.charColor(x);
3210
- const b = Math.floor(0.8 * t.cols), R = u.split(" "), U = [];
3210
+ const E = Math.floor(0.8 * t.cols), C = u.split(" "), N = [];
3211
3211
  let T = "";
3212
- for (const C of R) (T + " " + C).length <= b ? T = T ? T + " " + C : C : (T && U.push(T), T = C);
3213
- T && U.push(T);
3214
- const S = U.slice(0, 3);
3215
- U.length > 3 && (S[2] = S[2].substring(0, b - 3) + "..."), S.forEach((C, J) => {
3216
- const Ht = -Math.floor(C.length / 2);
3217
- n.push(), n.translate(Ht, 3 + J, 0);
3218
- for (const kt of C) n.char(kt), n.rect(1, 1), n.translateX(1);
3212
+ for (const F of C) (T + " " + F).length <= E ? T = T ? T + " " + F : F : (T && N.push(T), T = F);
3213
+ T && N.push(T);
3214
+ const S = N.slice(0, 3);
3215
+ N.length > 3 && (S[2] = S[2].substring(0, E - 3) + "..."), S.forEach((F, K) => {
3216
+ const kt = -Math.floor(F.length / 2);
3217
+ n.push(), n.translate(kt, 3 + K, 0);
3218
+ for (const Ht of F) n.char(Ht), n.rect(1, 1), n.translateX(1);
3219
3219
  n.pop();
3220
3220
  });
3221
3221
  }
3222
3222
  return;
3223
3223
  }
3224
- if (n.push(), n.translate(0, 0, 0), n.char(f[v]), n.rect(1, 1), n.pop(), e > 0 || o.some((A) => A.status !== "pending")) {
3225
- const A = Math.max(6, Math.floor(0.6 * t.cols)), p = -Math.floor(A / 2), y = Math.floor(A * e), E = s.length ? s : [n.color("#FFFFFF")];
3226
- n.push(), n.translate(p, 3, 0);
3227
- for (let x = 0; x < A; x++) {
3228
- const b = x < y ? "*" : ".", R = E[x % E.length], U = n.color(R.r, R.g, R.b, d);
3229
- n.charColor(U), n.char(b), n.rect(1, 1), n.translateX(1);
3224
+ if (n.push(), n.translate(0, 0, 0), n.char(f[g]), n.rect(1, 1), n.pop(), e > 0 || o.some((p) => p.status !== "pending")) {
3225
+ const p = Math.max(6, Math.floor(0.6 * t.cols)), A = -Math.floor(p / 2), w = Math.floor(p * e), y = s.length ? s : [n.color("#FFFFFF")];
3226
+ n.push(), n.translate(A, 3, 0);
3227
+ for (let x = 0; x < p; x++) {
3228
+ const E = x < w ? "*" : ".", C = y[x % y.length], N = n.color(C.r, C.g, C.b, d);
3229
+ n.charColor(N), n.char(E), n.rect(1, 1), n.translateX(1);
3230
3230
  }
3231
3231
  n.pop();
3232
3232
  }
3233
3233
  if (r) {
3234
- const A = n.color(h.subtleColor), p = n.color(A.r, A.g, A.b, d);
3235
- n.charColor(p);
3236
- const y = -Math.floor(r.length / 2);
3237
- n.push(), n.translate(y, 5, 0);
3238
- for (const E of r) n.char(E), n.rect(1, 1), n.translateX(1);
3234
+ const p = n.color(h.subtleColor), A = n.color(p.r, p.g, p.b, d);
3235
+ n.charColor(A);
3236
+ const w = -Math.floor(r.length / 2);
3237
+ n.push(), n.translate(w, 5, 0);
3238
+ for (const y of r) n.char(y), n.rect(1, 1), n.translateX(1);
3239
3239
  n.pop();
3240
3240
  }
3241
- }, He = { message: "LOADING...", tone: "auto", transition: "fade", transitionDuration: 500 };
3242
- class ke {
3241
+ }, ke = { message: "LOADING...", tone: "auto", transition: "fade", transitionDuration: 500 };
3242
+ class He {
3243
3243
  constructor(t, e, i) {
3244
- this.yc = t, this.id = e, this.label = i;
3244
+ this.wc = t, this.id = e, this.label = i;
3245
3245
  }
3246
3246
  report(t) {
3247
- this.yc.ja(this.id, t);
3247
+ this.wc.Ka(this.id, t);
3248
3248
  }
3249
3249
  complete() {
3250
- this.yc.Ka(this.id);
3250
+ this.wc.Wa(this.id);
3251
3251
  }
3252
3252
  fail(t) {
3253
- this.yc.Wa(this.id);
3253
+ this.wc.Za(this.id);
3254
3254
  }
3255
3255
  async track(t) {
3256
3256
  try {
@@ -3261,588 +3261,611 @@ class ke {
3261
3261
  }
3262
3262
  }
3263
3263
  }
3264
- class Gt {
3264
+ class zt {
3265
3265
  constructor(t, e, i) {
3266
- a(this, "ba");
3266
+ a(this, "Ca");
3267
3267
  a(this, "l");
3268
- a(this, "wc");
3269
- a(this, "yc");
3270
3268
  a(this, "bc");
3269
+ a(this, "wc");
3271
3270
  a(this, "Cc");
3272
3271
  a(this, "xc");
3273
3272
  a(this, "Mc");
3274
3273
  a(this, "Fc");
3275
3274
  a(this, "Pc");
3275
+ a(this, "$c");
3276
3276
  a(this, "Z");
3277
- a(this, "$c", []);
3278
- a(this, "Tc");
3279
- a(this, "Ec", performance.now());
3277
+ a(this, "Tc", []);
3278
+ a(this, "Ec");
3279
+ a(this, "Rc", performance.now());
3280
3280
  a(this, "Sc", 0);
3281
- a(this, "Rc", !1);
3282
3281
  a(this, "kc", !1);
3283
- a(this, "Ic");
3284
- this.ba = t, this.l = { ...He, ...e ?? {} }, this.wc = new Zt("active"), this.yc = new Ot(), this.bc = new Yt(this.l.transition, this.l.transitionDuration), this.Cc = new _t(60), this.Tc = vt(this.l, i);
3285
- const r = zt(this.Tc);
3286
- this.$c = Qt(r, this.ba), this.Z = this.zc(), this.yc.Xa((s) => {
3287
- s >= 0.999 && this.hc();
3282
+ a(this, "zc", !1);
3283
+ a(this, "Bc");
3284
+ this.Ca = t, this.l = { ...ke, ...e ?? {} }, this.bc = new It("active"), this.wc = new Bt(), this.Cc = new Zt(this.l.transition, this.l.transitionDuration), this.xc = new Lt(60), this.Ec = dt(this.l, i);
3285
+ const r = Yt(this.Ec);
3286
+ this.Tc = Ot(r, this.Ca), this.Z = this.Dc(), this.wc.Ya((s) => {
3287
+ s >= 0.999 && this.ac();
3288
3288
  });
3289
3289
  }
3290
- async yr(t) {
3291
- if (this.kc) return;
3292
- const e = this.ba.Z, i = this.ba.Er;
3293
- this.xc = new At(e, 16), await this.xc.yr(t);
3294
- const r = this.xc.maxGlyphDimensions;
3295
- this.Mc = new Lt(i.canvas, r.width, r.height), this.Fc = e.Pi(this.Mc.cols, this.Mc.rows, 3), this.Pc = e.Pi(this.Mc.width, this.Mc.height, 1), this.kc = !0;
3296
- }
3297
- get ec() {
3298
- return this.wc.ec && this.Rc;
3290
+ async Ar(t) {
3291
+ if (this.zc) return;
3292
+ const e = this.Ca.Z, i = this.Ca.Rr;
3293
+ this.Mc = new vt(e, 16), await this.Mc.Ar(t);
3294
+ const r = this.Mc.maxGlyphDimensions;
3295
+ this.Fc = new Ut(i.canvas, r.width, r.height), this.Pc = e.Pi(this.Fc.cols, this.Fc.rows, 3), this.$c = e.Pi(this.Fc.width, this.Fc.height, 1), this.zc = !0;
3299
3296
  }
3300
- Rn() {
3301
- this.Rc || (this.Rc = !0, this.Ec = performance.now(), this.Sc = 0, this.Cc.Rn(() => this.Dc()));
3297
+ get rc() {
3298
+ return this.bc.rc && this.kc;
3302
3299
  }
3303
3300
  kn() {
3304
- this.Rc && (this.Rc = !1, this.Cc.kn());
3301
+ this.kc || (this.kc = !0, this.Rc = performance.now(), this.Sc = 0, this.xc.kn(() => this.Lc()));
3305
3302
  }
3306
- Nr() {
3307
- this.kc && (this.Mc.te(), this.Fc.resize(this.Mc.cols, this.Mc.rows), this.Pc.resize(this.Mc.width, this.Mc.height));
3303
+ zn() {
3304
+ this.kc && (this.kc = !1, this.xc.zn());
3305
+ }
3306
+ Xr() {
3307
+ this.zc && (this.Fc.te(), this.Pc.resize(this.Fc.cols, this.Fc.rows), this.$c.resize(this.Fc.width, this.Fc.height));
3308
3308
  }
3309
3309
  gt() {
3310
- this.kn(), this.kc && (this.xc.gt(), this.Fc.gt(), this.Pc.gt(), this.kc = !1);
3310
+ this.zn(), this.zc && (this.Mc.gt(), this.Pc.gt(), this.$c.gt(), this.zc = !1);
3311
3311
  }
3312
3312
  get progress() {
3313
- return this.yc.Na;
3313
+ return this.wc.Xa;
3314
3314
  }
3315
3315
  message(t) {
3316
3316
  return typeof t == "string" && (this.l.message = t), this.l.message;
3317
3317
  }
3318
3318
  addPhase(t, e = 1) {
3319
- this.wc.oc();
3320
- const i = this.yc.Ya(t, e);
3321
- return new ke(this.yc, i, t);
3319
+ this.bc.hc();
3320
+ const i = this.wc.ja(t, e);
3321
+ return new He(this.wc, i, t);
3322
3322
  }
3323
- hc() {
3324
- this.l.transition !== "none" && this.l.transitionDuration > 0 ? (this.wc.ac(), this.bc.Rn()) : (this.wc.hc(), this.kn(), this.Lc());
3323
+ ac() {
3324
+ this.l.transition !== "none" && this.l.transitionDuration > 0 ? (this.bc.cc(), this.Cc.kn()) : (this.bc.ac(), this.zn(), this.Ic());
3325
3325
  }
3326
- Lc() {
3327
- this.Ic && this.Ic();
3326
+ Ic() {
3327
+ this.Bc && this.Bc();
3328
3328
  }
3329
3329
  Oc(t) {
3330
- this.Ic = t;
3330
+ this.Bc = t;
3331
3331
  }
3332
3332
  error(t) {
3333
- this.wc.lc(t);
3333
+ this.bc.uc(t);
3334
3334
  }
3335
- Dc() {
3336
- if (this.wc.ec) {
3337
- if (this.Sc++, this.wc.tc === "transitioning" && this.bc.it())
3338
- return this.wc.cc(), this.Lc(), void this.kn();
3339
- this.Bc();
3335
+ Lc() {
3336
+ if (this.bc.rc) {
3337
+ if (this.Sc++, this.bc.sc === "transitioning" && this.Cc.it())
3338
+ return this.bc.lc(), this.Ic(), void this.zn();
3339
+ this.Hc();
3340
3340
  }
3341
3341
  }
3342
- Bc() {
3343
- if (!this.kc) return;
3344
- const t = this.Fc, e = this.xc, i = this.Mc, r = this.Pc, s = this.ba.Z, h = this.ba.Er, o = this.ba.Hc, c = this.ba.Gc;
3345
- s.state.qt(), t.begin(), this.ba.clear(), this.ba.push();
3342
+ Hc() {
3343
+ if (!this.zc) return;
3344
+ const t = this.Pc, e = this.Mc, i = this.Fc, r = this.$c, s = this.Ca.Z, h = this.Ca.Rr, o = this.Ca.Gc, c = this.Ca.Qc;
3345
+ s.state.qt(), t.begin(), this.Ca.clear(), this.Ca.push();
3346
3346
  try {
3347
- const l = { textmodifier: this.ba, grid: i, progress: this.progress, elapsedMs: performance.now() - this.Ec, frameCount: this.Sc, message: this.l.message, palette: this.$c, theme: this.Tc, phases: this.yc.Za(), transitionOpacity: this.bc.mc, isError: this.wc.tc === "error", errorMessage: this.wc.rc || void 0, errorDetails: this.wc.nc || void 0 };
3347
+ const l = { textmodifier: this.Ca, grid: i, progress: this.progress, elapsedMs: performance.now() - this.Rc, frameCount: this.Sc, message: this.l.message, palette: this.Tc, theme: this.Ec, phases: this.wc.qa(), transitionOpacity: this.Cc._c, isError: this.bc.sc === "error", errorMessage: this.bc.nc || void 0, errorDetails: this.bc.oc || void 0 };
3348
3348
  this.Z(l);
3349
3349
  } finally {
3350
- this.ba.pop();
3350
+ this.Ca.pop();
3351
3351
  }
3352
- t.end(), r.begin(), s.di(o), o.I({ u_characterTexture: e.fontFramebuffer, u_charsetDimensions: [e.textureColumns, e.textureRows], U4: t.textures[0], U5: t.textures[1], U6: t.textures[2], U7: [i.cols, i.rows], U8: [r.width, r.height], U9: s.state.canvasBackgroundColor }), s.Ai(0, 0, h.width, h.height), r.end(), s.Ae(...s.state.canvasBackgroundColor), s.di(c), c.I({ U0: r.textures[0], U1: [r.width, r.height], U2: [i.offsetX, i.offsetY], U3: [i.width, i.height] }), s.Ai(i.offsetX, i.offsetY, i.width, i.height);
3352
+ t.end(), r.begin(), s.di(o), o.I({ u_characterTexture: e.fontFramebuffer, u_charsetDimensions: [e.textureColumns, e.textureRows], Uf: t.textures[0], Ug: t.textures[1], Uh: t.textures[2], Ui: [i.cols, i.rows], Uj: [r.width, r.height], Uk: s.state.canvasBackgroundColor }), s.yi(0, 0, h.width, h.height), r.end(), s.ye(...s.state.canvasBackgroundColor), s.di(c), c.I({ U0: r.textures[0], U1: [r.width, r.height], U2: [i.offsetX, i.offsetY], U3: [i.width, i.height] }), s.yi(i.offsetX, i.offsetY, i.width, i.height);
3353
3353
  }
3354
- Qc(t) {
3355
- this.Tc = vt(this.l, t);
3354
+ Nc(t) {
3355
+ this.Ec = dt(this.l, t);
3356
3356
  }
3357
- zc() {
3357
+ Dc() {
3358
3358
  const t = this.l.renderer || We;
3359
3359
  return (e) => {
3360
- t(e), this.Nc(e);
3360
+ t(e), this.Xc(e);
3361
3361
  };
3362
3362
  }
3363
- Nc(t) {
3363
+ Xc(t) {
3364
3364
  const { textmodifier: e, grid: i, frameCount: r, theme: s, transitionOpacity: h } = t, o = [116, 101, 120, 116, 109, 111, 100, 101, 46, 106, 115].map((f) => String.fromCharCode(f)).join(""), c = (i.rows + 1 >> 1) - 2, l = 2 - (i.cols + 1 >> 1), u = s.mode === "light" ? [[233, 30, 99], [156, 39, 176], [255, 111, 0]] : [[142, 249, 243], [241, 91, 181], [255, 155, 113]];
3365
3365
  e.push(), e.translate(l, c, 0);
3366
3366
  for (let f = 0; f < o.length; f++) {
3367
- const v = o[f], m = Math.floor(0.1 * r + 0.5 * f) % u.length, [d, g, A] = u[m], p = Math.floor(255 * h), y = e.color(d, g, A, p);
3368
- e.charColor(y), e.char(v), e.point(), e.translateX(1);
3367
+ const g = o[f], m = Math.floor(0.1 * r + 0.5 * f) % u.length, [d, v, p] = u[m], A = Math.floor(255 * h), w = e.color(d, v, p, A);
3368
+ e.charColor(w), e.char(g), e.point(), e.translateX(1);
3369
3369
  }
3370
3370
  e.pop();
3371
3371
  }
3372
3372
  }
3373
- class mt {
3373
+ class gt {
3374
3374
  constructor(t = {}) {
3375
- a(this, "Xc");
3376
- a(this, "mc");
3377
3375
  a(this, "Yc");
3376
+ a(this, "_c");
3378
3377
  a(this, "jc");
3379
3378
  a(this, "Kc");
3380
3379
  a(this, "Wc");
3381
3380
  a(this, "Zc");
3382
3381
  a(this, "qc");
3383
3382
  a(this, "Vc");
3384
- a(this, "Jc", null);
3385
- a(this, "tl", !1);
3386
- a(this, "sl", !0);
3387
- a(this, "el", []);
3388
- this.Xc = t.visible ?? !0, this.mc = Math.min(1, Math.max(0, t.opacity ?? 1)), this.Yc = t.blendMode ?? "normal", this.jc = Math.round(t.offsetX ?? 0), this.Kc = Math.round(t.offsetY ?? 0);
3389
- }
3390
- il() {
3391
- return this.Jc !== null;
3383
+ a(this, "Jc");
3384
+ a(this, "tl", null);
3385
+ a(this, "sl", !1);
3386
+ a(this, "el", !0);
3387
+ a(this, "il", []);
3388
+ this.Yc = t.visible ?? !0, this._c = Math.min(1, Math.max(0, t.opacity ?? 1)), this.jc = t.blendMode ?? "normal", this.Kc = Math.round(t.offsetX ?? 0), this.Wc = Math.round(t.offsetY ?? 0);
3392
3389
  }
3393
3390
  rl() {
3394
- const t = this.el;
3395
- return this.el = [], t;
3391
+ return this.tl !== null;
3396
3392
  }
3397
- nl(t) {
3398
- this.Jc && this.Jc.call(t);
3393
+ nl() {
3394
+ const t = this.il;
3395
+ return this.il = [], t;
3396
+ }
3397
+ ol(t) {
3398
+ this.tl && this.tl.call(t);
3399
3399
  }
3400
3400
  draw(t) {
3401
- this.Jc = t;
3401
+ this.tl = t;
3402
3402
  }
3403
3403
  show() {
3404
- this.Xc = !0;
3404
+ this.Yc = !0;
3405
3405
  }
3406
3406
  hide() {
3407
- this.Xc = !1;
3407
+ this.Yc = !1;
3408
3408
  }
3409
3409
  opacity(t) {
3410
- if (t === void 0) return this.mc;
3411
- this.mc = Math.min(1, Math.max(0, t));
3410
+ if (t === void 0) return this._c;
3411
+ this._c = Math.min(1, Math.max(0, t));
3412
3412
  }
3413
3413
  blendMode(t) {
3414
- if (t === void 0) return this.Yc;
3415
- this.Yc = t;
3414
+ if (t === void 0) return this.jc;
3415
+ this.jc = t;
3416
3416
  }
3417
3417
  offset(t, e = 0) {
3418
- if (t === void 0) return { x: this.jc, y: this.Kc };
3419
- this.jc = Math.round(t), this.Kc = Math.round(e);
3418
+ if (t === void 0) return { x: this.Kc, y: this.Wc };
3419
+ this.Kc = Math.round(t), this.Wc = Math.round(e);
3420
3420
  }
3421
3421
  filter(t, e) {
3422
- this.el.push({ name: t, params: e });
3422
+ this.il.push({ name: t, params: e });
3423
3423
  }
3424
- ol(t) {
3425
- this.Wc = t, this.hl(t.grid);
3424
+ hl(t) {
3425
+ this.Zc = t, this.al(t.grid);
3426
3426
  }
3427
- ya(t, e) {
3428
- if (!this.Xc || !this.Jc) return void (this.tl = !1);
3429
- const i = this.Wc.renderer;
3430
- this.el = [], this.Zc.begin(), i.state.qt(), this.Jc.call(t), this.Zc.end();
3431
- const r = this.el.length > 0, s = r ? this.Vc : this.qc;
3432
- s.begin(), i.di(e), e.I({ u_characterTexture: this.Wc.font.fontFramebuffer, u_charsetDimensions: [this.Wc.font.textureColumns, this.Wc.font.textureRows], U4: this.Zc.textures[0], U5: this.Zc.textures[1], U6: this.Zc.textures[2], U7: [this.Wc.grid.cols, this.Wc.grid.rows], U8: [s.width, s.height], U9: [0, 0, 0, 0] }), i.Ai(0, 0, this.Wc.grid.width, this.Wc.grid.height), s.end(), r && this.Wc.filterManager.al(this.Vc.textures[0], this.qc, this.el, this.qc.width, this.qc.height), this.tl = !0;
3427
+ wa(t, e) {
3428
+ if (!this.Yc || !this.tl) return void (this.sl = !1);
3429
+ const i = this.Zc.renderer;
3430
+ this.il = [], this.qc.begin(), i.state.qt(), this.tl.call(t), this.qc.end();
3431
+ const r = this.il.length > 0, s = r ? this.Jc : this.Vc;
3432
+ s.begin(), i.di(e), e.I({ u_characterTexture: this.Zc.font.fontFramebuffer, u_charsetDimensions: [this.Zc.font.textureColumns, this.Zc.font.textureRows], Uf: this.qc.textures[0], Ug: this.qc.textures[1], Uh: this.qc.textures[2], Ui: [this.Zc.grid.cols, this.Zc.grid.rows], Uj: [s.width, s.height], Uk: [0, 0, 0, 0] }), i.yi(0, 0, this.Zc.grid.width, this.Zc.grid.height), s.end(), r && this.Zc.filterManager.cl(this.Jc.textures[0], this.Vc, this.il, this.Vc.width, this.Vc.height), this.sl = !0;
3433
3433
  }
3434
- Nr(t) {
3434
+ Xr(t) {
3435
3435
  var e;
3436
- this.Wc && (this.Wc = { ...this.Wc, grid: t }), this.Zc && this.qc && (this.Zc.resize(t.cols, t.rows), this.qc.resize(t.width, t.height), (e = this.Vc) == null || e.resize(t.width, t.height));
3436
+ this.Zc && (this.Zc = { ...this.Zc, grid: t }), this.qc && this.Vc && (this.qc.resize(t.cols, t.rows), this.Vc.resize(t.width, t.height), (e = this.Jc) == null || e.resize(t.width, t.height));
3437
3437
  }
3438
3438
  gt() {
3439
3439
  var t, e, i;
3440
- this.sl && ((t = this.Zc) == null || t.gt(), (e = this.qc) == null || e.gt(), (i = this.Vc) == null || i.gt());
3440
+ this.el && ((t = this.qc) == null || t.gt(), (e = this.Vc) == null || e.gt(), (i = this.Jc) == null || i.gt());
3441
3441
  }
3442
3442
  get texture() {
3443
3443
  var t;
3444
- return (t = this.qc) == null ? void 0 : t.textures[0];
3444
+ return (t = this.Vc) == null ? void 0 : t.textures[0];
3445
3445
  }
3446
3446
  get width() {
3447
- return this.qc ? this.qc.width : 0;
3447
+ return this.Vc ? this.Vc.width : 0;
3448
3448
  }
3449
3449
  get height() {
3450
- return this.qc ? this.qc.height : 0;
3450
+ return this.Vc ? this.Vc.height : 0;
3451
3451
  }
3452
- get cl() {
3453
- return this.tl;
3452
+ get ll() {
3453
+ return this.sl;
3454
3454
  }
3455
3455
  get drawFramebuffer() {
3456
- return this.Zc;
3456
+ return this.qc;
3457
3457
  }
3458
- hl(t) {
3459
- this.Wc && (this.Zc = this.Wc.externalDrawFramebuffer ?? this.Wc.createFramebuffer(t.cols, t.rows, 4), this.qc = this.Wc.externalAsciiFramebuffer ?? this.Wc.createFramebuffer(t.width, t.height, 1), this.Wc.externalAsciiFramebuffer || (this.Vc = this.Wc.createFramebuffer(t.width, t.height, 1)), this.sl = !this.Wc.externalDrawFramebuffer && !this.Wc.externalAsciiFramebuffer, this.tl = !1);
3458
+ al(t) {
3459
+ this.Zc && (this.qc = this.Zc.externalDrawFramebuffer ?? this.Zc.createFramebuffer(t.cols, t.rows, 4), this.Vc = this.Zc.externalAsciiFramebuffer ?? this.Zc.createFramebuffer(t.width, t.height, 1), this.Zc.externalAsciiFramebuffer || (this.Jc = this.Zc.createFramebuffer(t.width, t.height, 1)), this.el = !this.Zc.externalDrawFramebuffer && !this.Zc.externalAsciiFramebuffer, this.sl = !1);
3460
3460
  }
3461
3461
  }
3462
- const Ft = { normal: 0, additive: 1, multiply: 2, screen: 3, subtract: 4, darken: 5, lighten: 6, overlay: 7, softLight: 8, hardLight: 9, colorDodge: 10, colorBurn: 11, difference: 12, exclusion: 13 };
3463
- class qt {
3462
+ const xt = { normal: 0, additive: 1, multiply: 2, screen: 3, subtract: 4, darken: 5, lighten: 6, overlay: 7, softLight: 8, hardLight: 9, colorDodge: 10, colorBurn: 11, difference: 12, exclusion: 13 };
3463
+ class Vt {
3464
3464
  constructor(t) {
3465
3465
  a(this, "Z");
3466
- a(this, "ll");
3467
- a(this, "ul", null);
3468
- a(this, "fl", 0);
3469
- this.Z = t, this.ll = t.pi(K, `#version 300 es
3470
- precision highp float;uniform sampler2D Ua;uniform sampler2D Ub;uniform vec2 Uc;uniform float Ud;uniform vec2 Ue;uniform vec4 Ur;uniform int Uf;in vec2 v_uv;out vec4 fragColor;const int A=0;const int B=1;const int C=2;const int D=3;const int E=4;const int F=5;const int G=6;const int H=7;const int I=8;const int J=9;const int K=10;const int L=11;const int M=12;const int N=13;vec3 O(vec3 P,vec3 Q){return Q;}vec3 R(vec3 P,vec3 Q){return P+Q;}vec3 S(vec3 P,vec3 Q){return P*Q;}vec3 T(vec3 P,vec3 Q){return 1.-(1.-P)*(1.-Q);}vec3 U(vec3 P,vec3 Q){return max(P-Q,0.);}vec3 V(vec3 P,vec3 Q){return min(P,Q);}vec3 W(vec3 P,vec3 Q){return max(P,Q);}vec3 X(vec3 P,vec3 Q){return mix(2.*P*Q,1.-2.*(1.-P)*(1.-Q),step(0.5,P));}vec3 Y(vec3 P,vec3 Q){return mix(P-(1.-2.*Q)*P*(1.-P),mix(P+(2.*Q-1.)*(P*(3.-2.*P)-P),P+(2.*Q-1.)*(sqrt(P)-P),step(0.25,P)),step(0.5,Q));}vec3 Z(vec3 P,vec3 Q){return mix(2.*P*Q,1.-2.*(1.-P)*(1.-Q),step(0.5,Q));}vec3 a(vec3 P,vec3 Q){return mix(min(vec3(1.),P/max(1.-Q,0.0001)),vec3(1.),step(1.,Q));}vec3 b(vec3 P,vec3 Q){return mix(1.-min(vec3(1.),(1.-P)/max(Q,0.0001)),vec3(0.),step(Q,vec3(0.)));}vec3 c(vec3 P,vec3 Q){return abs(P-Q);}vec3 d(vec3 P,vec3 Q){return P+Q-2.*P*Q;}vec3 e(int f,vec3 P,vec3 Q){if(f==A)return O(P,Q);if(f==B)return R(P,Q);if(f==C)return S(P,Q);if(f==D)return T(P,Q);if(f==E)return U(P,Q);if(f==F)return V(P,Q);if(f==G)return W(P,Q);if(f==H)return X(P,Q);if(f==I)return Y(P,Q);if(f==J)return Z(P,Q);if(f==K)return a(P,Q);if(f==L)return b(P,Q);if(f==M)return c(P,Q);if(f==N)return d(P,Q);return O(P,Q);}void main(){vec4 g=texture(Ub,v_uv);vec2 h=v_uv*Uc-Ue;bool i=any(lessThan(h,vec2(0.)))||any(greaterThanEqual(h,Uc));if(i){fragColor=g;return;}vec2 j=(floor(h)+0.5)/Uc;vec4 k=texture(Ua,j);float l=k.a*Ud;if(l<=0.){fragColor=g;return;}vec3 m=e(Uf,g.rgb,k.rgb);vec3 n=mix(g.rgb,m,l);float o=g.a+l*(1.-g.a);fragColor=vec4(n,o);}`);
3466
+ a(this, "ul");
3467
+ a(this, "fl", null);
3468
+ a(this, "dl", 0);
3469
+ this.Z = t, this.ul = t.pi(Q, `#version 300 es
3470
+ precision highp float;uniform sampler2D Ul;uniform sampler2D Um;uniform vec2 Un;uniform float Uo;uniform vec2 Up;uniform vec4 Uv;uniform int Uq;in vec2 v_uv;out vec4 fragColor;const int A=0;const int B=1;const int C=2;const int D=3;const int E=4;const int F=5;const int G=6;const int H=7;const int I=8;const int J=9;const int K=10;const int L=11;const int M=12;const int N=13;vec3 O(vec3 P,vec3 Q){return Q;}vec3 R(vec3 P,vec3 Q){return P+Q;}vec3 S(vec3 P,vec3 Q){return P*Q;}vec3 T(vec3 P,vec3 Q){return 1.-(1.-P)*(1.-Q);}vec3 U(vec3 P,vec3 Q){return max(P-Q,0.);}vec3 V(vec3 P,vec3 Q){return min(P,Q);}vec3 W(vec3 P,vec3 Q){return max(P,Q);}vec3 X(vec3 P,vec3 Q){return mix(2.*P*Q,1.-2.*(1.-P)*(1.-Q),step(0.5,P));}vec3 Y(vec3 P,vec3 Q){return mix(P-(1.-2.*Q)*P*(1.-P),mix(P+(2.*Q-1.)*(P*(3.-2.*P)-P),P+(2.*Q-1.)*(sqrt(P)-P),step(0.25,P)),step(0.5,Q));}vec3 Z(vec3 P,vec3 Q){return mix(2.*P*Q,1.-2.*(1.-P)*(1.-Q),step(0.5,Q));}vec3 a(vec3 P,vec3 Q){return mix(min(vec3(1.),P/max(1.-Q,0.0001)),vec3(1.),step(1.,Q));}vec3 b(vec3 P,vec3 Q){return mix(1.-min(vec3(1.),(1.-P)/max(Q,0.0001)),vec3(0.),step(Q,vec3(0.)));}vec3 c(vec3 P,vec3 Q){return abs(P-Q);}vec3 d(vec3 P,vec3 Q){return P+Q-2.*P*Q;}vec3 e(int f,vec3 P,vec3 Q){if(f==A)return O(P,Q);if(f==B)return R(P,Q);if(f==C)return S(P,Q);if(f==D)return T(P,Q);if(f==E)return U(P,Q);if(f==F)return V(P,Q);if(f==G)return W(P,Q);if(f==H)return X(P,Q);if(f==I)return Y(P,Q);if(f==J)return Z(P,Q);if(f==K)return a(P,Q);if(f==L)return b(P,Q);if(f==M)return c(P,Q);if(f==N)return d(P,Q);return O(P,Q);}void main(){vec4 g=texture(Um,v_uv);vec2 h=v_uv*Un-Up;bool i=any(lessThan(h,vec2(0.)))||any(greaterThanEqual(h,Un));if(i){fragColor=g;return;}vec2 j=(floor(h)+0.5)/Un;vec4 k=texture(Ul,j);float l=k.a*Uo;if(l<=0.){fragColor=g;return;}vec3 m=e(Uq,g.rgb,k.rgb);vec3 n=mix(g.rgb,m,l);float o=g.a+l*(1.-g.a);fragColor=vec4(n,o);}`);
3471
3471
  }
3472
- yr(t) {
3473
- this.ul || (this.ul = [this.Z.Pi(t.width, t.height, 1), this.Z.Pi(t.width, t.height, 1)]);
3472
+ Ar(t) {
3473
+ this.fl || (this.fl = [this.Z.Pi(t.width, t.height, 1), this.Z.Pi(t.width, t.height, 1)]);
3474
3474
  }
3475
- dl(t, e) {
3475
+ vl(t, e) {
3476
3476
  const i = this.Z.context, { baseTexture: r, targetFramebuffer: s, backgroundColor: h, baseLayer: o, layers: c } = t, l = i.isEnabled(i.DEPTH_TEST), u = i.getParameter(i.DEPTH_WRITEMASK);
3477
3477
  l && i.disable(i.DEPTH_TEST), u && i.depthMask(!1);
3478
- const f = e.width, v = e.height, m = this.ul[0];
3479
- m.begin(), this.Z.Ae(...h), m.end(), this.fl = 0, o.Xc && this.vl(r, f, v, o.mc, o.jc, o.Kc, "normal", i);
3480
- for (const d of c) d.Xc && d.cl && this.vl(d.texture, d.width, d.height, d.mc, d.jc, d.Kc, d.Yc, i);
3481
- this.pl(s, f, v, i), i.depthMask(u), l && i.enable(i.DEPTH_TEST);
3478
+ const f = e.width, g = e.height, m = this.fl[0];
3479
+ m.begin(), this.Z.ye(...h), m.end(), this.dl = 0, o.Yc && this.pl(r, f, g, o._c, o.Kc, o.Wc, "normal", i);
3480
+ for (const d of c) d.Yc && d.ll && this.pl(d.texture, d.width, d.height, d._c, d.Kc, d.Wc, d.jc, i);
3481
+ this.ml(s, f, g, i), i.depthMask(u), l && i.enable(i.DEPTH_TEST);
3482
3482
  }
3483
- vl(t, e, i, r, s, h, o, c) {
3484
- const l = this.ul[this.fl], u = this.fl === 0 ? 1 : 0, f = this.ul[u];
3485
- f.begin(), c.disable(c.BLEND), this.Z.di(this.ll), this.ll.I({ Ua: t, Ub: l.textures[0], Uc: [e, i], Ud: r, Ue: [s, h], Uf: Ft[o] }), this.Z.Ai(0, 0, l.width, l.height), f.end(), this.fl = u;
3483
+ pl(t, e, i, r, s, h, o, c) {
3484
+ const l = this.fl[this.dl], u = this.dl === 0 ? 1 : 0, f = this.fl[u];
3485
+ f.begin(), c.disable(c.BLEND), this.Z.di(this.ul), this.ul.I({ Ul: t, Um: l.textures[0], Un: [e, i], Uo: r, Up: [s, h], Uq: xt[o] }), this.Z.yi(0, 0, l.width, l.height), f.end(), this.dl = u;
3486
3486
  }
3487
- pl(t, e, i, r) {
3488
- const s = this.ul[this.fl];
3489
- t.begin(), r.disable(r.BLEND), this.Z.di(this.ll), this.ll.I({ Ua: s.textures[0], Ub: s.textures[0], Uc: [s.width, s.height], Ud: 1, Ue: [0, 0], Uf: Ft.normal }), this.Z.Ai(0, 0, e, i), t.end();
3487
+ ml(t, e, i, r) {
3488
+ const s = this.fl[this.dl];
3489
+ t.begin(), r.disable(r.BLEND), this.Z.di(this.ul), this.ul.I({ Ul: s.textures[0], Um: s.textures[0], Un: [s.width, s.height], Uo: 1, Up: [0, 0], Uq: xt.normal }), this.Z.yi(0, 0, e, i), t.end();
3490
3490
  }
3491
- Nr(t) {
3492
- this.ul && (this.ul[0].resize(t.width, t.height), this.ul[1].resize(t.width, t.height));
3491
+ Xr(t) {
3492
+ this.fl && (this.fl[0].resize(t.width, t.height), this.fl[1].resize(t.width, t.height));
3493
3493
  }
3494
3494
  gt() {
3495
- this.ll.dispose(), this.ul && (this.ul[0].gt(), this.ul[1].gt(), this.ul = null);
3496
- }
3497
- }
3498
- const X = /* @__PURE__ */ new Map();
3499
- function O(n, t, e = {}) {
3500
- const i = Object.entries(e), r = i.length > 0 ? i[0][1][0] : null;
3501
- return { id: n, createShader: (s) => s.renderer.pi(K, t), createUniforms: (s, h) => {
3502
- const o = { u_resolution: [h.width, h.height] };
3503
- for (const [c, [l, u]] of i) {
3504
- let f = u;
3505
- s != null && (typeof s == "number" && l === r ? f = s : typeof s == "object" && l in s && (f = s[l] ?? u)), o[c] = f;
3506
- }
3507
- return o;
3508
- } };
3509
- }
3510
- const je = [O("invert", `#version 300 es
3511
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(Uy,v_uv);fragColor=vec4(1.-A.rgb,A.a);}`, {}), O("grayscale", `#version 300 es
3512
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;uniform float Us;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(Uy,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));vec3 C=mix(A.rgb,vec3(B),Us);fragColor=vec4(C,A.a);}`, { Us: ["amount", 1] }), O("sepia", `#version 300 es
3513
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;uniform float Us;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(Uy,v_uv);vec3 B;B.r=dot(A.rgb,vec3(0.393,0.769,0.189));B.g=dot(A.rgb,vec3(0.349,0.686,0.168));B.b=dot(A.rgb,vec3(0.272,0.534,0.131));vec3 C=mix(A.rgb,B,Us);fragColor=vec4(C,A.a);}`, { Us: ["amount", 1] }), O("threshold", `#version 300 es
3514
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;uniform float Ut;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(Uy,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));float C=step(Ut,B);fragColor=vec4(vec3(C),A.a);}`, { Ut: ["threshold", 0.5] }), O("pixelate", `#version 300 es
3515
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;uniform float Uu;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uu)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(Uy,B);}`, { Uu: ["pixelSize", 4] }), O("chromaticAberration", `#version 300 es
3516
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;uniform float Us;uniform vec2 Uv;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=Uv*Us*A;float C=texture(Uy,v_uv+B).r;float D=texture(Uy,v_uv).g;float E=texture(Uy,v_uv-B).b;float F=texture(Uy,v_uv).a;fragColor=vec4(C,D,E,F);}`, { Us: ["amount", 3], Uv: ["direction", [1, 0]] })];
3517
- for (const n of je) X.set(n.id, n);
3518
- function Ve(n) {
3519
- if (X.has(n.id)) throw Error(`[textmode.js] Filter "${n.id}" is already registered. Use unregisterFilterStrategy() first if you want to replace it.`);
3520
- X.set(n.id, n);
3521
- }
3522
- function Ke(n) {
3523
- return X.delete(n);
3524
- }
3525
- function Je(n) {
3526
- return X.has(n);
3495
+ this.ul.dispose(), this.fl && (this.fl[0].gt(), this.fl[1].gt(), this.fl = null);
3496
+ }
3527
3497
  }
3528
- function $e() {
3529
- return Array.from(X.keys());
3498
+ class Gt {
3499
+ constructor(t) {
3500
+ a(this, "Z");
3501
+ a(this, "_l", /* @__PURE__ */ new Map());
3502
+ a(this, "Al", /* @__PURE__ */ new Map());
3503
+ this.Z = t, this.yl();
3504
+ }
3505
+ async wl(t, e, i = {}) {
3506
+ const r = Object.entries(i), s = r.length > 0 ? r[0][1][0] : null;
3507
+ let h;
3508
+ if (typeof e == "string") {
3509
+ let c = e;
3510
+ if (e.startsWith("./") || e.startsWith("../") || e.endsWith(".frag") || e.endsWith(".glsl")) {
3511
+ const l = await fetch(e);
3512
+ if (!l.ok) throw Error(`Failed to load shader from ${e}: ${l.statusText}`);
3513
+ c = await l.text();
3514
+ }
3515
+ h = this.Z.pi(Q, c), this.Al.set(t, h);
3516
+ } else h = e, this.Al.set(t, h);
3517
+ const o = { id: t, createShader: () => h, createUniforms: (c, l) => {
3518
+ const u = { u_resolution: [l.width, l.height] };
3519
+ for (const [f, [g, m]] of r) {
3520
+ let d = m;
3521
+ c != null && (typeof c == "number" && g === s ? d = c : typeof c == "object" && g in c && (d = c[g] ?? m)), u[f] = d;
3522
+ }
3523
+ return u;
3524
+ } };
3525
+ this._l.set(t, o);
3526
+ }
3527
+ bl(t) {
3528
+ const e = this.Al.get(t);
3529
+ return e && (e.dispose(), this.Al.delete(t)), this._l.delete(t);
3530
+ }
3531
+ Cl(t) {
3532
+ return this._l.get(t);
3533
+ }
3534
+ gt() {
3535
+ for (const t of this.Al.values()) t.dispose();
3536
+ this.Al.clear(), this._l.clear();
3537
+ }
3538
+ yl() {
3539
+ this.wl("invert", `#version 300 es
3540
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);fragColor=vec4(1.-A.rgb,A.a);}`, {}), this.wl("grayscale", `#version 300 es
3541
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ur;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));vec3 C=mix(A.rgb,vec3(B),Ur);fragColor=vec4(C,A.a);}`, { Ur: ["amount", 1] }), this.wl("sepia", `#version 300 es
3542
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ur;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B;B.r=dot(A.rgb,vec3(0.393,0.769,0.189));B.g=dot(A.rgb,vec3(0.349,0.686,0.168));B.b=dot(A.rgb,vec3(0.272,0.534,0.131));vec3 C=mix(A.rgb,B,Ur);fragColor=vec4(C,A.a);}`, { Ur: ["amount", 1] }), this.wl("threshold", `#version 300 es
3543
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Us;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));float C=step(Us,B);fragColor=vec4(vec3(C),A.a);}`, { Us: ["threshold", 0.5] }), this.wl("pixelate", `#version 300 es
3544
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ut;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Ut)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}`, { Ut: ["pixelSize", 4] }), this.wl("chromaticAberration", `#version 300 es
3545
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ur;uniform vec2 Uu;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=Uu*Ur*A;float C=texture(u_texture,v_uv+B).r;float D=texture(u_texture,v_uv).g;float E=texture(u_texture,v_uv-B).b;float F=texture(u_texture,v_uv).a;fragColor=vec4(C,D,E,F);}`, { Ur: ["amount", 3], Uu: ["direction", [1, 0]] });
3546
+ }
3530
3547
  }
3531
- class ti {
3548
+ class je {
3532
3549
  constructor(t) {
3533
3550
  a(this, "Z");
3534
- a(this, "ml", /* @__PURE__ */ new Map());
3551
+ a(this, "Al", /* @__PURE__ */ new Map());
3535
3552
  a(this, "J");
3536
- a(this, "ul");
3537
- a(this, "_l", 0);
3538
- a(this, "kc", !1);
3539
- this.Z = t, this.J = t.pi(K, `#version 300 es
3540
- precision highp float;uniform sampler2D Uy;uniform vec2 u_resolution;in vec2 v_uv;out vec4 fragColor;void main(){fragColor=texture(Uy,v_uv);}`);
3553
+ a(this, "fl");
3554
+ a(this, "xl", 0);
3555
+ a(this, "zc", !1);
3556
+ a(this, "Ml");
3557
+ this.Z = t, this.Ml = new Gt(this.Z), this.J = t.pi(Q, `#version 300 es
3558
+ precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;in vec2 v_uv;out vec4 fragColor;void main(){fragColor=texture(u_texture,v_uv);}`);
3559
+ }
3560
+ async register(t, e, i = {}) {
3561
+ await this.Ml.wl(t, e, i);
3562
+ }
3563
+ unregister(t) {
3564
+ return this.Ml.bl(t) ?? !1;
3541
3565
  }
3542
- yr(t, e) {
3543
- this.kc || (this.ul = [this.Z.Pi(t, e, 1, { depth: !1 }), this.Z.Pi(t, e, 1, { depth: !1 })], this.kc = !0);
3566
+ Ar(t, e) {
3567
+ this.zc || (this.fl = [this.Z.Pi(t, e, 1, { depth: !1 }), this.Z.Pi(t, e, 1, { depth: !1 })], this.zc = !0);
3544
3568
  }
3545
- al(t, e, i, r, s) {
3546
- if (this.ul[0].width === r && this.ul[0].height === s || (this.ul[0].resize(r, s), this.ul[1].resize(r, s)), i.length === 0) return void this.yl(t, e, r, s);
3569
+ cl(t, e, i, r, s) {
3570
+ if (this.fl[0].width === r && this.fl[0].height === s || (this.fl[0].resize(r, s), this.fl[1].resize(r, s)), i.length === 0) return void this.Fl(t, e, r, s);
3547
3571
  const h = this.Z.context, o = h.isEnabled(h.BLEND);
3548
- h.disable(h.BLEND), this.yl(t, this.ul[0], r, s), this._l = 0;
3572
+ h.disable(h.BLEND), this.Fl(t, this.fl[0], r, s), this.xl = 0;
3549
3573
  for (let c = 0; c < i.length; c++) {
3550
- const l = i[c], u = c === i.length - 1, f = u ? e : this.Al();
3551
- this.wl(l, f, r, s), u || this.bl();
3574
+ const l = i[c], u = c === i.length - 1, f = u ? e : this.Pl();
3575
+ this.$l(l, f, r, s), u || this.Tl();
3552
3576
  }
3553
3577
  o && h.enable(h.BLEND);
3554
3578
  }
3555
- wl(t, e, i, r) {
3556
- const s = (h = t.name, X.get(h));
3557
- var h;
3558
- if (!s) return console.warn(`[textmode.js] Unknown filter: "${t.name}". Skipping.`), void this.yl(this.ul[this._l].textures[0], e, i, r);
3559
- const o = this.Cl(t.name, s, i, r), c = this.ul[this._l], l = { renderer: this.Z, gl: this.Z.context, width: i, height: r };
3560
- e.begin(), this.Z.di(o), o.I({ Uy: c.textures[0] });
3561
- const u = s.createUniforms(t.params, l);
3562
- o.I(u), this.Z.Ai(0, 0, i, r), e.end();
3563
- }
3564
- Cl(t, e, i, r) {
3565
- let s = this.ml.get(t);
3579
+ $l(t, e, i, r) {
3580
+ const s = this.Ml.Cl(t.name);
3581
+ if (!s) return console.warn(`[textmode.js] Unknown filter: "${t.name}". Skipping.`), void this.Fl(this.fl[this.xl].textures[0], e, i, r);
3582
+ const h = this.El(t.name, s, i, r), o = this.fl[this.xl], c = { renderer: this.Z, gl: this.Z.context, width: i, height: r };
3583
+ e.begin(), this.Z.di(h), h.I({ u_texture: o.textures[0] });
3584
+ const l = s.createUniforms(t.params, c);
3585
+ h.I(l), this.Z.yi(0, 0, i, r), e.end();
3586
+ }
3587
+ El(t, e, i, r) {
3588
+ let s = this.Al.get(t);
3566
3589
  if (!s && e) {
3567
3590
  const h = { renderer: this.Z, gl: this.Z.context, width: i, height: r };
3568
- s = e.createShader(h), this.ml.set(t, s);
3591
+ s = e.createShader(h), this.Al.set(t, s);
3569
3592
  }
3570
3593
  return s;
3571
3594
  }
3572
- yl(t, e, i, r) {
3573
- e.begin(), this.Z.di(this.J), this.J.I({ Uy: t, u_resolution: [i, r] }), this.Z.Ai(0, 0, i, r), e.end();
3595
+ Fl(t, e, i, r) {
3596
+ e.begin(), this.Z.di(this.J), this.J.I({ u_texture: t, u_resolution: [i, r] }), this.Z.yi(0, 0, i, r), e.end();
3574
3597
  }
3575
- Al() {
3576
- return this.ul[this._l === 0 ? 1 : 0];
3598
+ Pl() {
3599
+ return this.fl[this.xl === 0 ? 1 : 0];
3577
3600
  }
3578
- bl() {
3579
- this._l = this._l === 0 ? 1 : 0;
3601
+ Tl() {
3602
+ this.xl = this.xl === 0 ? 1 : 0;
3580
3603
  }
3581
- Nr(t, e) {
3582
- this.ul && (this.ul[0].resize(t, e), this.ul[1].resize(t, e));
3604
+ Xr(t, e) {
3605
+ this.fl && (this.fl[0].resize(t, e), this.fl[1].resize(t, e));
3583
3606
  }
3584
3607
  gt() {
3585
- for (const t of this.ml.values()) t.dispose();
3586
- this.ml.clear(), this.J.dispose(), this.ul[0].gt(), this.ul[1].gt(), this.kc = !1;
3608
+ for (const t of this.Al.values()) t.dispose();
3609
+ this.Al.clear(), this.J.dispose(), this.Ml.gt(), this.fl[0].gt(), this.fl[1].gt(), this.zc = !1;
3587
3610
  }
3588
3611
  }
3589
3612
  class Wt {
3590
3613
  constructor(t) {
3591
- a(this, "ba");
3614
+ a(this, "Ca");
3592
3615
  a(this, "Z");
3593
- a(this, "xl");
3594
- a(this, "Ml");
3595
- a(this, "Fl");
3596
- a(this, "Pl", []);
3597
- a(this, "$l", []);
3598
- a(this, "Tl");
3599
- a(this, "El");
3616
+ a(this, "Rl");
3600
3617
  a(this, "Sl");
3601
- a(this, "Rl", !1);
3602
- this.ba = t, this.Z = t.Z, this.xl = t.Hc, this.Ml = new qt(this.Z), this.Fl = new ti(this.Z), this.Tl = new mt({ visible: !0, opacity: 1 });
3618
+ a(this, "kl");
3619
+ a(this, "zl", []);
3620
+ a(this, "Dl", []);
3621
+ a(this, "Ll");
3622
+ a(this, "Il");
3623
+ a(this, "Bl");
3624
+ a(this, "Ol", !1);
3625
+ this.Ca = t, this.Z = t.Z, this.Rl = t.Gc, this.Sl = new Vt(this.Z), this.kl = new je(this.Z), this.Ll = new gt({ visible: !0, opacity: 1 });
3603
3626
  }
3604
3627
  add(t = {}) {
3605
- const e = new mt(t);
3606
- return this.Rl ? (this.kl(e), this.$l.push(e)) : this.Pl.push(e), e;
3628
+ const e = new gt(t);
3629
+ return this.Ol ? (this.Hl(e), this.Dl.push(e)) : this.zl.push(e), e;
3607
3630
  }
3608
3631
  remove(t) {
3609
- this.zl(this.$l, t) || this.zl(this.Pl, t);
3632
+ this.Gl(this.Dl, t) || this.Gl(this.zl, t);
3610
3633
  }
3611
3634
  move(t, e) {
3612
- this.Dl(this.$l, t, e) || this.Dl(this.Pl, t, e);
3635
+ this.Ql(this.Dl, t, e) || this.Ql(this.zl, t, e);
3613
3636
  }
3614
3637
  swap(t, e) {
3615
- t !== e && (this.Ll(this.$l, t, e) || this.Ll(this.Pl, t, e));
3638
+ t !== e && (this.Nl(this.Dl, t, e) || this.Nl(this.zl, t, e));
3616
3639
  }
3617
- yr() {
3618
- if (this.Rl) return;
3619
- const t = this.ba.Qn;
3620
- this.El = this.Z.Pi(t.width, t.height, 1), this.Sl = this.Z.Pi(t.width, t.height, 1), this.Fl.yr(t.width, t.height), this.Il(), this.Ml.yr(t);
3621
- for (const e of this.Pl) this.kl(e), this.$l.push(e);
3622
- this.Pl.length = 0, this.Rl = !0;
3640
+ Ar() {
3641
+ if (this.Ol) return;
3642
+ const t = this.Ca.Nn;
3643
+ this.Il = this.Z.Pi(t.width, t.height, 1), this.Bl = this.Z.Pi(t.width, t.height, 1), this.kl.Ar(t.width, t.height), this.Xl(), this.Sl.Ar(t);
3644
+ for (const e of this.zl) this.Hl(e), this.Dl.push(e);
3645
+ this.zl.length = 0, this.Ol = !0;
3623
3646
  }
3624
- Ol(t, e) {
3625
- const i = this.ba.Qn, r = this.ba.font, s = this.ba.pa, h = this.Tl.rl(), o = h.length > 0, c = o ? this.Sl : this.El;
3626
- c.begin(), this.Z.di(this.xl), this.xl.I({ u_characterTexture: r.fontFramebuffer, u_charsetDimensions: [r.textureColumns, r.textureRows], U4: s.textures[0], U5: s.textures[1], U6: s.textures[2], U7: [i.cols, i.rows], U8: [c.width, c.height], U9: this.Z.state.canvasBackgroundColor }), this.Z.Ai(0, 0, i.width, i.height), c.end(), o && this.Fl.al(this.Sl.textures[0], this.El, h, this.El.width, this.El.height), this.Bl(), this.Hl(t, e);
3647
+ Yl(t, e) {
3648
+ const i = this.Ca.Nn, r = this.Ca.font, s = this.Ca.ga, h = this.Ll.nl(), o = h.length > 0, c = o ? this.Bl : this.Il;
3649
+ c.begin(), this.Z.di(this.Rl), this.Rl.I({ u_characterTexture: r.fontFramebuffer, u_charsetDimensions: [r.textureColumns, r.textureRows], Uf: s.textures[0], Ug: s.textures[1], Uh: s.textures[2], Ui: [i.cols, i.rows], Uj: [c.width, c.height], Uk: this.Z.state.canvasBackgroundColor }), this.Z.yi(0, 0, i.width, i.height), c.end(), o && this.kl.cl(this.Bl.textures[0], this.Il, h, this.Il.width, this.Il.height), this.jl(), this.Kl(t, e);
3627
3650
  }
3628
- Bl() {
3629
- if (this.$l.length !== 0) for (const t of this.$l) t.ya(this.ba, this.xl);
3651
+ jl() {
3652
+ if (this.Dl.length !== 0) for (const t of this.Dl) t.wa(this.Ca, this.Rl);
3630
3653
  }
3631
- Hl(t, e) {
3632
- this.Ml.dl({ baseTexture: this.El.textures[0], targetFramebuffer: t, backgroundColor: e, baseLayer: this.Tl, layers: this.$l }, this.ba.Qn);
3654
+ Kl(t, e) {
3655
+ this.Sl.vl({ baseTexture: this.Il.textures[0], targetFramebuffer: t, backgroundColor: e, baseLayer: this.Ll, layers: this.Dl }, this.Ca.Nn);
3633
3656
  }
3634
- Nr() {
3635
- if (!this.Rl) return;
3636
- const t = this.ba.Qn;
3637
- this.El.resize(t.width, t.height), this.Sl.resize(t.width, t.height), this.Tl.Nr(t), this.Fl.Nr(t.width, t.height);
3638
- for (const e of this.$l) e.Nr(t);
3639
- this.Ml.Nr(t);
3657
+ Xr() {
3658
+ if (!this.Ol) return;
3659
+ const t = this.Ca.Nn;
3660
+ this.Il.resize(t.width, t.height), this.Bl.resize(t.width, t.height), this.Ll.Xr(t), this.kl.Xr(t.width, t.height);
3661
+ for (const e of this.Dl) e.Xr(t);
3662
+ this.Sl.Xr(t);
3640
3663
  }
3641
3664
  gt() {
3642
3665
  var t, e;
3643
- for (const i of this.$l) i.gt();
3644
- for (const i of this.Pl) i.gt();
3645
- this.$l.length = 0, this.Pl.length = 0, this.Tl.gt(), (t = this.El) == null || t.gt(), (e = this.Sl) == null || e.gt(), this.Fl.gt(), this.Ml.gt();
3666
+ for (const i of this.Dl) i.gt();
3667
+ for (const i of this.zl) i.gt();
3668
+ this.Dl.length = 0, this.zl.length = 0, this.Ll.gt(), (t = this.Il) == null || t.gt(), (e = this.Bl) == null || e.gt(), this.kl.gt(), this.Sl.gt();
3646
3669
  }
3647
3670
  get all() {
3648
- return this.$l;
3671
+ return this.Dl;
3649
3672
  }
3650
3673
  get base() {
3651
- return this.Tl;
3674
+ return this.Ll;
3675
+ }
3676
+ get filters() {
3677
+ return this.kl;
3652
3678
  }
3653
- kl(t) {
3654
- const e = { renderer: this.Z, grid: this.ba.Qn, font: this.ba.font, filterManager: this.Fl, createFramebuffer: (i, r, s = 1) => this.Z.Pi(i, r, s) };
3655
- t.ol(e);
3679
+ Hl(t) {
3680
+ const e = { renderer: this.Z, grid: this.Ca.Nn, font: this.Ca.font, filterManager: this.kl, createFramebuffer: (i, r, s = 1) => this.Z.Pi(i, r, s) };
3681
+ t.hl(e);
3656
3682
  }
3657
- Il() {
3658
- const t = { renderer: this.Z, grid: this.ba.Qn, font: this.ba.font, filterManager: this.Fl, createFramebuffer: (e, i, r = 1) => this.Z.Pi(e, i, r), externalDrawFramebuffer: this.ba.pa, externalAsciiFramebuffer: this.El };
3659
- this.Tl.ol(t);
3683
+ Xl() {
3684
+ const t = { renderer: this.Z, grid: this.Ca.Nn, font: this.Ca.font, filterManager: this.kl, createFramebuffer: (e, i, r = 1) => this.Z.Pi(e, i, r), externalDrawFramebuffer: this.Ca.ga, externalAsciiFramebuffer: this.Il };
3685
+ this.Ll.hl(t);
3660
3686
  }
3661
- zl(t, e) {
3687
+ Gl(t, e) {
3662
3688
  const i = t.indexOf(e);
3663
3689
  if (i === -1) return !1;
3664
3690
  const [r] = t.splice(i, 1);
3665
3691
  return r.gt(), !0;
3666
3692
  }
3667
- Dl(t, e, i) {
3693
+ Ql(t, e, i) {
3668
3694
  const r = t.indexOf(e);
3669
3695
  if (r === -1) return !1;
3670
3696
  t.splice(r, 1);
3671
3697
  const s = Math.max(0, Math.min(t.length, i));
3672
3698
  return t.splice(s, 0, e), !0;
3673
3699
  }
3674
- Ll(t, e, i) {
3700
+ Nl(t, e, i) {
3675
3701
  const r = t.indexOf(e);
3676
3702
  if (r === -1) return !1;
3677
3703
  const s = t.indexOf(i);
3678
3704
  return s !== -1 && (t[r] = i, t[s] = e, !0);
3679
3705
  }
3680
3706
  }
3681
- class ei extends function(e, ...i) {
3707
+ class Qe extends function(e, ...i) {
3682
3708
  return i.reduce((r, s) => s(r), e);
3683
3709
  }(class {
3684
- }, Oe, Ze, Ye, ze, Qe, Ge) {
3710
+ }, Ie, Ze, Ye, Oe, ze, Ve) {
3685
3711
  constructor(e = {}) {
3686
3712
  super();
3687
3713
  a(this, "Z");
3688
3714
  a(this, "rr");
3689
- a(this, "Er");
3690
- a(this, "Qn");
3691
- a(this, "_a");
3692
- a(this, "No");
3715
+ a(this, "Rr");
3716
+ a(this, "Nn");
3717
+ a(this, "ya");
3718
+ a(this, "Xo");
3719
+ a(this, "ma");
3720
+ a(this, "ba");
3721
+ a(this, "Wl");
3693
3722
  a(this, "ga");
3694
- a(this, "wa");
3695
- a(this, "Gl");
3696
- a(this, "pa");
3697
- a(this, "Hc");
3698
- a(this, "Da");
3699
3723
  a(this, "Gc");
3700
- a(this, "Ql");
3701
- a(this, "Nl");
3702
- a(this, "Xl", !1);
3703
- a(this, "Yl", !1);
3704
- a(this, "jl", !1);
3705
- a(this, "Kl", !1);
3706
- a(this, "Wl", () => {
3724
+ a(this, "La");
3725
+ a(this, "Qc");
3726
+ a(this, "Zl");
3727
+ a(this, "ql");
3728
+ a(this, "Vl", !1);
3729
+ a(this, "Jl", !1);
3730
+ a(this, "tu", !1);
3731
+ a(this, "su", !1);
3732
+ a(this, "eu", () => {
3707
3733
  });
3708
- a(this, "Jc", () => {
3734
+ a(this, "tl", () => {
3709
3735
  });
3710
- a(this, "Zl", () => {
3736
+ a(this, "iu", () => {
3711
3737
  });
3712
- a(this, "ql");
3713
- a(this, "Vl");
3714
- a(this, "Dr", !1);
3715
- a(this, "Jl");
3716
- a(this, "ma", /* @__PURE__ */ new Set());
3717
- this.Nl = new qe(this), this.Dr = e.overlay ?? !1, this.Er = new Se(e), this.Z = new me(this.Er.Xr()), this.rr = new At(this.Z, e.fontSize ?? 16), this._a = new _t(e.frameRate ?? 60), this.Gl = new Gt(this, e.loadingScreen, this.Er.Qr()), this.Gl.Oc(() => {
3718
- this._a.Hn = 0, this.Kl = !0;
3719
- }), this.No = new Bt(this.Er), this.ga = new It(this.Er, this.No), this.wa = new Xt(), this.Hc = this.Z.pi(K, `#version 300 es
3720
- precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D U5;uniform sampler2D U6;uniform sampler2D U4;uniform vec2 U7;uniform vec2 U8;uniform vec4 U9;in vec2 v_uv;out vec4 fragColor;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=texture(U5,H);vec4 J=texture(U6,H);vec4 K=texture(U4,H);int L=int(K.b*255.+0.5);bool M=(L&1)!=0;bool N=(L&2)!=0;bool O=(L&4)!=0;int P=int(K.r*255.+0.5)+int(K.g*255.+0.5)*256;int Q=int(u_charsetDimensions.x);int R=P/Q;int S=P-(R*Q);float T=(u_charsetDimensions.y-1.)-float(R);vec2 U=1./u_charsetDimensions;vec2 V=vec2(float(S),T)*U;vec2 W=V+U;float X=-K.a*360.*0.017453292;vec2 Y=fract(F)-0.5f;vec2 Z=vec2(N?-1.:1.,O?-1.:1.);Y*=Z;Y=A(X)*Y+0.5;vec2 a=V+clamp(Y,0.,1.)*U;const float b=0.0001;if(any(lessThan(a,V-b))||any(greaterThan(a,W+b))){fragColor=M?I:J;return;}vec4 c=texture(u_characterTexture,a);if(M)c.rgb=mix(c.rgb,1.-c.rgb,float(M));vec4 d=mix(U9,J,J.a);fragColor=mix(d,I,c);}`), this.Ql = new Wt(this), this.Gl.Rn(), this.tu(e);
3721
- }
3722
- async tu(e) {
3723
- await Promise.all([this.rr.yr(e.fontSource), this.Gl.yr(e.fontSource)]);
3738
+ a(this, "ru");
3739
+ a(this, "nu");
3740
+ a(this, "Lr", !1);
3741
+ a(this, "ou");
3742
+ a(this, "_a", /* @__PURE__ */ new Set());
3743
+ this.ql = new Ge(this), this.Lr = e.overlay ?? !1, this.Rr = new Ue(e), this.Z = new me(this.Rr.Yr()), this.rr = new vt(this.Z, e.fontSize ?? 16), this.ya = new Lt(e.frameRate ?? 60), this.Wl = new zt(this, e.loadingScreen, this.Rr.Nr()), this.Wl.Oc(() => {
3744
+ this.ya.Gn = 0, this.su = !0;
3745
+ }), this.Xo = new Dt(this.Rr), this.ma = new Xt(this.Rr, this.Xo), this.ba = new _t(), this.Gc = this.Z.pi(Q, `#version 300 es
3746
+ precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Uf;uniform vec2 Ui;uniform vec2 Uj;uniform vec4 Uk;in vec2 v_uv;out vec4 fragColor;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/Uj;vec2 F=E*Ui;vec2 G=floor(F);vec2 H=(G+0.5)/Ui;vec4 I=texture(Ug,H);vec4 J=texture(Uh,H);vec4 K=texture(Uf,H);int L=int(K.b*255.+0.5);bool M=(L&1)!=0;bool N=(L&2)!=0;bool O=(L&4)!=0;int P=int(K.r*255.+0.5)+int(K.g*255.+0.5)*256;int Q=int(u_charsetDimensions.x);int R=P/Q;int S=P-(R*Q);float T=(u_charsetDimensions.y-1.)-float(R);vec2 U=1./u_charsetDimensions;vec2 V=vec2(float(S),T)*U;vec2 W=V+U;float X=-K.a*360.*0.017453292;vec2 Y=fract(F)-0.5f;vec2 Z=vec2(N?-1.:1.,O?-1.:1.);Y*=Z;Y=A(X)*Y+0.5;vec2 a=V+clamp(Y,0.,1.)*U;const float b=0.0001;if(any(lessThan(a,V-b))||any(greaterThan(a,W+b))){fragColor=M?I:J;return;}vec4 c=texture(u_characterTexture,a);if(M)c.rgb=mix(c.rgb,1.-c.rgb,float(M));vec4 d=mix(Uk,J,J.a);fragColor=mix(d,I,c);}`), this.Zl = new Wt(this), this.Wl.kn(), this.hu(e);
3747
+ }
3748
+ async hu(e) {
3749
+ await Promise.all([this.rr.Ar(e.fontSource), this.Wl.Ar(e.fontSource)]);
3724
3750
  const i = this.rr.maxGlyphDimensions;
3725
- this.Qn = new Lt(this.Er.canvas, i.width, i.height), this.No.yr(this.Qn), this.ga.yr(this.Qn), this.pa = this.Z.Pi(this.Qn.cols, this.Qn.rows, 3), this.Da = this.Z.Pi(this.Qn.width, this.Qn.height, 1), this.Ql.yr(), this.Dr && (this.Jl = z.bn(this.Z, this.rr, this.Er.targetCanvas, this.Qn.cols, this.Qn.rows), this.va(this.Jl)), this.Gc = this.Z.pi(K, `#version 300 es
3726
- precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform vec2 U2;uniform vec2 U3;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-U2;vec2 B=A*(U1/U3);vec2 C=(floor(B)+0.5)/U1;fragColor=texture(U0,C);}`), this.su(), this._a.Rn(() => this.ya()), await this.Nl.Pa(e.plugins ?? []);
3751
+ this.Nn = new Ut(this.Rr.canvas, i.width, i.height), this.Xo.Ar(this.Nn), this.ma.Ar(this.Nn), this.ga = this.Z.Pi(this.Nn.cols, this.Nn.rows, 3), this.La = this.Z.Pi(this.Nn.width, this.Nn.height, 1), this.Zl.Ar(), this.Lr && (this.ou = Y.Cn(this.Z, this.rr, this.Rr.targetCanvas, this.Nn.cols, this.Nn.rows), this.pa(this.ou)), this.Qc = this.Z.pi(Q, `#version 300 es
3752
+ precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform vec2 U2;uniform vec2 U3;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-U2;vec2 B=A*(U1/U3);vec2 C=(floor(B)+0.5)/U1;fragColor=texture(U0,C);}`), this.au(), this.ya.kn(() => this.wa()), await this.ql.$a(e.plugins ?? []);
3727
3753
  try {
3728
- await this.Wl(), this.Gl.hc();
3754
+ await this.eu(), this.Wl.ac();
3729
3755
  } catch (r) {
3730
- console.error("Error during setup:", r), this.Gl.error(r);
3756
+ console.error("Error during setup:", r), this.Wl.error(r);
3731
3757
  }
3732
3758
  }
3733
- su() {
3734
- this.ql = () => {
3735
- this.Dr && this.resizeCanvas(this.Er.targetCanvas.width, this.Er.targetCanvas.height), this.Zl();
3736
- }, window.addEventListener("resize", this.ql), this.No.uo(), this.ga.uo(), this.wa.uo(), window.addEventListener("blur", () => {
3737
- this.wa.Qo();
3738
- }), this.Dr && (this.Vl = new ResizeObserver(() => {
3739
- this.resizeCanvas(this.Er.targetCanvas.width, this.Er.targetCanvas.height);
3740
- }), this.Vl.observe(this.Er.targetCanvas));
3759
+ au() {
3760
+ this.ru = () => {
3761
+ this.Lr && this.resizeCanvas(this.Rr.targetCanvas.width, this.Rr.targetCanvas.height), this.iu();
3762
+ }, window.addEventListener("resize", this.ru), this.Xo.fo(), this.ma.fo(), this.ba.fo(), window.addEventListener("blur", () => {
3763
+ this.ba.No();
3764
+ }), this.Lr && (this.nu = new ResizeObserver(() => {
3765
+ this.resizeCanvas(this.Rr.targetCanvas.width, this.Rr.targetCanvas.height);
3766
+ }), this.nu.observe(this.Rr.targetCanvas));
3741
3767
  }
3742
- ya() {
3743
- if (!this.Gl.ec && this.Kl) {
3744
- this.Yl = !0;
3768
+ wa() {
3769
+ if (!this.Wl.rc && this.su) {
3770
+ this.Jl = !0;
3745
3771
  try {
3746
- this._a.In(), this._a.Gn(), this.Dr && Ct(this.Z.context, this.Jl.texture, this.Er.targetCanvas), this.Nl.Sa(), this.Z.state.qt(), this.pa.begin(), this.Ql.base.il() ? this.Ql.base.nl(this) : this.Jc(), this.pa.end();
3772
+ this.ya.Bn(), this.ya.Qn(), this.Lr && Rt(this.Z.context, this.ou.texture, this.Rr.targetCanvas), this.ql.Sa(), this.Z.state.qt(), this.ga.begin(), this.Zl.base.rl() ? this.Zl.base.ol(this) : this.tl(), this.ga.end();
3747
3773
  const e = [...this.Z.state.canvasBackgroundColor];
3748
- this.Ql.Ol(this.Da, e), this.Z.Ae(...e), this.Z.di(this.Gc), this.Gc.I({ U0: this.Da.textures[0], U1: [this.Da.width, this.Da.height], U2: [this.Qn.offsetX, this.Qn.offsetY], U3: [this.Qn.width, this.Qn.height] }), this.Z.Ai(this.Qn.offsetX, this.Qn.offsetY, this.Qn.width, this.Qn.height), this.Nl.ka();
3774
+ this.Zl.Yl(this.La, e), this.Z.ye(...e), this.Z.di(this.Qc), this.Qc.I({ U0: this.La.textures[0], U1: [this.La.width, this.La.height], U2: [this.Nn.offsetX, this.Nn.offsetY], U3: [this.Nn.width, this.Nn.height] }), this.Z.yi(this.Nn.offsetX, this.Nn.offsetY, this.Nn.width, this.Nn.height), this.ql.za();
3749
3775
  } finally {
3750
- this.Yl = !1, this.Xl && !this.jl && this.eu();
3776
+ this.Jl = !1, this.Vl && !this.tu && this.cu();
3751
3777
  }
3752
3778
  }
3753
3779
  }
3754
3780
  resizeCanvas(e, i) {
3755
3781
  var r;
3756
- this.Er.Nr(e, i), this.Gl.Qc(this.Er.Qr()), this.Qn.te(), this.Gl.Nr(), this.pa.resize(this.Qn.cols, this.Qn.rows), this.Da.resize(this.Qn.width, this.Qn.height), (r = this.Ql) == null || r.Nr(), this.Z.Ei(), this.No.lo(), this.ga.lo(), this.ya();
3782
+ this.Rr.Xr(e, i), this.Wl.Nc(this.Rr.Nr()), this.Nn.te(), this.Wl.Xr(), this.ga.resize(this.Nn.cols, this.Nn.rows), this.La.resize(this.Nn.width, this.Nn.height), (r = this.Zl) == null || r.Xr(), this.Z.Ei(), this.Xo.uo(), this.ma.uo(), this.wa();
3757
3783
  }
3758
3784
  destroy() {
3759
- this.jl || this.Xl || (this.Xl = !0, this._a.zn(), this.Yl || this.eu());
3785
+ this.tu || this.Vl || (this.Vl = !0, this.ya.Dn(), this.Jl || this.cu());
3760
3786
  }
3761
- eu() {
3787
+ cu() {
3762
3788
  var e, i, r;
3763
- this.Xl = !1, this.Gl.gt(), this.Nl.za(), window.removeEventListener("resize", this.ql), (e = this.Vl) == null || e.disconnect(), this.No.yo(), this.ga.yo(), this.wa.yo(), this.pa.gt(), this.Hc.dispose(), (i = this.Ql) == null || i.gt(), this.rr.gt(), this.Z.gt(), this.Da.gt(), this.Gc.dispose(), (r = this.Jl) == null || r.gt(), this.Er.gt(), this.jl = !0;
3789
+ this.Vl = !1, this.Wl.gt(), this.ql.Da(), window.removeEventListener("resize", this.ru), (e = this.nu) == null || e.disconnect(), this.Xo.yo(), this.ma.yo(), this.ba.yo(), this.ga.gt(), this.Gc.dispose(), (i = this.Zl) == null || i.gt(), this.rr.gt(), this.Z.gt(), this.La.gt(), this.Qc.dispose(), (r = this.ou) == null || r.gt(), this.Rr.gt(), this.tu = !0;
3764
3790
  }
3765
3791
  setup(e) {
3766
- this.Wl = e;
3792
+ this.eu = e;
3767
3793
  }
3768
3794
  draw(e) {
3769
- this.Jc = e;
3795
+ this.tl = e;
3770
3796
  }
3771
3797
  windowResized(e) {
3772
- this.Zl = e;
3798
+ this.iu = e;
3773
3799
  }
3774
3800
  get grid() {
3775
- return this.Qn;
3801
+ return this.Nn;
3776
3802
  }
3777
3803
  get font() {
3778
3804
  return this.rr;
3779
3805
  }
3780
3806
  get width() {
3781
- return this.Er.width;
3807
+ return this.Rr.width;
3782
3808
  }
3783
3809
  get height() {
3784
- return this.Er.height;
3810
+ return this.Rr.height;
3785
3811
  }
3786
3812
  get canvas() {
3787
- return this.Er.canvas;
3813
+ return this.Rr.canvas;
3788
3814
  }
3789
3815
  get drawFramebuffer() {
3790
- return this.pa;
3816
+ return this.ga;
3791
3817
  }
3792
3818
  get isDisposed() {
3793
- return this.jl;
3819
+ return this.tu;
3794
3820
  }
3795
3821
  get overlay() {
3796
- return this.Jl;
3822
+ return this.ou;
3797
3823
  }
3798
3824
  get loading() {
3799
- return this.Gl;
3825
+ return this.Wl;
3800
3826
  }
3801
3827
  get layers() {
3802
- return this.Ql;
3828
+ return this.Zl;
3803
3829
  }
3804
- va(e) {
3805
- this.ma.has(e) || this.ma.add(e);
3830
+ pa(e) {
3831
+ this._a.has(e) || this._a.add(e);
3806
3832
  }
3807
3833
  }
3808
- class yt {
3834
+ class pt {
3809
3835
  constructor() {
3810
3836
  }
3811
3837
  static create(t = {}) {
3812
- return new ei(t);
3838
+ return new Qe(t);
3813
3839
  }
3814
3840
  static setErrorLevel(t) {
3815
- pt._(t);
3841
+ mt._(t);
3816
3842
  }
3817
3843
  static get version() {
3818
- return "0.7.0-beta.1";
3844
+ return "0.7.0-beta.2";
3819
3845
  }
3820
3846
  }
3821
- let ut = null;
3822
- const ii = { id: "brightness", createShader: ({ gl: n }) => (ut || (ut = new k(n, st, `#version 300 es
3823
- precision highp float;in vec2 v_uv;uniform sampler2D u_image;uniform bool u_invert;uniform bool u_flipX;uniform bool u_flipY;uniform float u_charRotation;uniform bool u_charColorFixed;uniform vec4 u_charColor;uniform bool u_cellColorFixed;uniform vec4 u_cellColor;uniform vec4 u_backgroundColor;uniform int u_charCount;uniform vec3 u_charList[255];uniform bool u_colorFilterEnabled;uniform int u_colorFilterSize;uniform vec4 u_colorFilterPalette[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 A;float B(vec3 C){return dot(C,vec3(0.299f,0.587f,0.114f));}float D(vec3 E,vec3 F){vec3 G=E-F;return dot(G,G);}vec4 H(vec4 I){if(!u_colorFilterEnabled||u_colorFilterSize<=0){return I;}int J=min(u_colorFilterSize,64);vec3 K=u_colorFilterPalette[0].rgb;float L=D(I.rgb,K);for(int M=1;M<64;++M){if(M>=J){break;}vec3 N=u_colorFilterPalette[M].rgb;float O=D(I.rgb,N);if(O<L){L=O;K=N;}}return vec4(K,I.a);}void main(){vec2 P=vec2(v_uv.x,1.0f-v_uv.y);vec4 I=texture(u_image,P);I=H(I);float F=B(I.rgb);vec2 Q=vec2(0.);if(u_charCount>0){float R=float(u_charCount);float S=clamp(F*(R-1.0f),0.0f,R-1.0f);int T=int(floor(S+0.5f));vec3 U=u_charList[T];Q=U.xy;}else{Q=vec2(0.0f,0.0f);}vec4 V=u_charColorFixed?u_charColor:I;vec4 W=u_cellColorFixed?u_cellColor:I;if(I.a<0.01f){discard;}o_primaryColor=vec4(V.rgb,V.a);o_secondaryColor=vec4(W.rgb,W.a);A=vec4(0.);int X=int(u_invert?1:0);int Y=int(u_flipX?1:0);int Z=int(u_flipY?1:0);float a=float(X|(Y<<1)|(Z<<2))/255.;o_character=vec4(Q,a,clamp(u_charRotation,0.0f,1.0f));}`)), ut), createUniforms: ({ source: n }) => n.createBaseConversionUniforms() }, ni = Object.freeze(Object.defineProperty({ __proto__: null, LayerCompositor: qt, TextmodeLayer: mt, TextmodeLayerManager: Wt, getRegisteredFilters: $e, isFilterRegistered: Je, registerFilterStrategy: Ve, unregisterFilterStrategy: Ke }, Symbol.toStringTag, { value: "Module" })), hi = Object.freeze(Object.defineProperty({ __proto__: null, LoadingPhaseTracker: Ot, LoadingScreenManager: Gt, LoadingScreenStateMachine: Zt, LoadingScreenTransition: Yt, resolveColorInputs: Qt, resolveDefaultPalette: zt, resolveTheme: vt }, Symbol.toStringTag, { value: "Module" })), oi = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeFont: At, TextmodeImage: z, TextmodeVideo: ht }, Symbol.toStringTag, { value: "Module" })), ai = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: Be, mouse: _e, touch: Xe }, Symbol.toStringTag, { value: "Module" }));
3824
- Le(ii);
3825
- const ci = yt.create, li = yt.setErrorLevel, ui = yt.version;
3847
+ let ct = null;
3848
+ const Ke = { id: "brightness", createShader: ({ gl: n }) => (ct || (ct = new k(n, it, `#version 300 es
3849
+ precision highp float;in vec2 v_uv;uniform sampler2D u_image;uniform bool u_invert;uniform bool u_flipX;uniform bool u_flipY;uniform float u_charRotation;uniform bool u_charColorFixed;uniform vec4 u_charColor;uniform bool u_cellColorFixed;uniform vec4 u_cellColor;uniform vec4 u_backgroundColor;uniform int u_charCount;uniform vec3 u_charList[255];uniform bool u_colorFilterEnabled;uniform int u_colorFilterSize;uniform vec4 u_colorFilterPalette[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 A;float B(vec3 C){return dot(C,vec3(0.299f,0.587f,0.114f));}float D(vec3 E,vec3 F){vec3 G=E-F;return dot(G,G);}vec4 H(vec4 I){if(!u_colorFilterEnabled||u_colorFilterSize<=0){return I;}int J=min(u_colorFilterSize,64);vec3 K=u_colorFilterPalette[0].rgb;float L=D(I.rgb,K);for(int M=1;M<64;++M){if(M>=J){break;}vec3 N=u_colorFilterPalette[M].rgb;float O=D(I.rgb,N);if(O<L){L=O;K=N;}}return vec4(K,I.a);}void main(){vec2 P=vec2(v_uv.x,1.0f-v_uv.y);vec4 I=texture(u_image,P);I=H(I);float F=B(I.rgb);vec2 Q=vec2(0.);if(u_charCount>0){float R=float(u_charCount);float S=clamp(F*(R-1.0f),0.0f,R-1.0f);int T=int(floor(S+0.5f));vec3 U=u_charList[T];Q=U.xy;}else{Q=vec2(0.0f,0.0f);}vec4 V=u_charColorFixed?u_charColor:I;vec4 W=u_cellColorFixed?u_cellColor:I;if(I.a<0.01f){discard;}o_primaryColor=vec4(V.rgb,V.a);o_secondaryColor=vec4(W.rgb,W.a);A=vec4(0.);int X=int(u_invert?1:0);int Y=int(u_flipX?1:0);int Z=int(u_flipY?1:0);float a=float(X|(Y<<1)|(Z<<2))/255.;o_character=vec4(Q,a,clamp(u_charRotation,0.0f,1.0f));}`)), ct), createUniforms: ({ source: n }) => n.createBaseConversionUniforms() }, $e = Object.freeze(Object.defineProperty({ __proto__: null, FilterRegistry: Gt, LayerCompositor: Vt, TextmodeLayer: gt, TextmodeLayerManager: Wt }, Symbol.toStringTag, { value: "Module" })), ti = Object.freeze(Object.defineProperty({ __proto__: null, LoadingPhaseTracker: Bt, LoadingScreenManager: zt, LoadingScreenStateMachine: It, LoadingScreenTransition: Zt, resolveColorInputs: Ot, resolveDefaultPalette: Yt, resolveTheme: dt }, Symbol.toStringTag, { value: "Module" })), ei = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeFont: vt, TextmodeImage: Y, TextmodeVideo: st }, Symbol.toStringTag, { value: "Module" })), ii = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: _e, mouse: De, touch: Xe }, Symbol.toStringTag, { value: "Module" }));
3850
+ Se(Ke);
3851
+ const ri = pt.create, si = pt.setErrorLevel, ni = pt.version;
3826
3852
  export {
3827
- Se as TextmodeCanvas,
3853
+ Gt as FilterRegistry,
3854
+ Ue as TextmodeCanvas,
3828
3855
  M as TextmodeColor,
3829
3856
  Kt as TextmodeErrorLevel,
3830
- j as TextmodeFramebuffer,
3831
- Lt as TextmodeGrid,
3832
- ei as Textmodifier,
3833
- ci as create,
3834
- De as getConversionStrategy,
3835
- $e as getRegisteredFilters,
3836
- ai as input,
3837
- Je as isFilterRegistered,
3838
- ni as layering,
3839
- oi as loadables,
3840
- hi as loading,
3841
- Le as registerConversionStrategy,
3842
- Ve as registerFilterStrategy,
3843
- li as setErrorLevel,
3844
- yt as textmode,
3845
- si as unregisterConversionStrategy,
3846
- Ke as unregisterFilterStrategy,
3847
- ui as version
3857
+ H as TextmodeFramebuffer,
3858
+ Ut as TextmodeGrid,
3859
+ Qe as Textmodifier,
3860
+ ri as create,
3861
+ Le as getConversionStrategy,
3862
+ ii as input,
3863
+ $e as layering,
3864
+ ei as loadables,
3865
+ ti as loading,
3866
+ Se as registerConversionStrategy,
3867
+ si as setErrorLevel,
3868
+ pt as textmode,
3869
+ Je as unregisterConversionStrategy,
3870
+ ni as version
3848
3871
  };