textmode.js 0.7.1-beta.3 → 0.7.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/textmode.esm.js
CHANGED
|
@@ -164,11 +164,11 @@ function et(n, t, e, i, s) {
|
|
|
164
164
|
function ut(n, t, e, i, s, r = 0, h = WebGL2RenderingContext.FLOAT, o = !1) {
|
|
165
165
|
n.enableVertexAttribArray(t), n.vertexAttribPointer(t, e, h, o, i, s), n.vertexAttribDivisor(t, r);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function Ct(n, t, e, i, s) {
|
|
168
168
|
n.bindBuffer(t, e), n.bufferData(t, i, s), n.bindBuffer(t, null);
|
|
169
169
|
}
|
|
170
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
|
|
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 Ud;uniform float Ue;uniform float Uf;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/Ud)*2.0f;AA.y=-AA.y;float AB=y.z/Ud.y;float AC=clamp(-AB*Ue,-0.99f,0.99f);if(Uf>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);}}`, O = class O {
|
|
172
172
|
constructor(t, e, i = e, s = 1, r = {}, h) {
|
|
173
173
|
a(this, "N");
|
|
174
174
|
a(this, "X");
|
|
@@ -268,12 +268,12 @@ precision highp float;in vec2 v_uv;uniform sampler2D U5;uniform sampler2D U6;uni
|
|
|
268
268
|
};
|
|
269
269
|
a(O, "J", null);
|
|
270
270
|
let j = O;
|
|
271
|
-
const
|
|
271
|
+
const Ft = /* @__PURE__ */ new WeakMap();
|
|
272
272
|
function nt(n, t) {
|
|
273
|
-
|
|
273
|
+
Ft.set(n, t);
|
|
274
274
|
}
|
|
275
275
|
function Pt(n) {
|
|
276
|
-
return
|
|
276
|
+
return Ft.get(n);
|
|
277
277
|
}
|
|
278
278
|
function tt(n, t, e, i, s = 255) {
|
|
279
279
|
n[0] = t / 255, n[1] = (e ?? t) / 255, n[2] = (i ?? t) / 255, n[3] = s / 255;
|
|
@@ -536,7 +536,7 @@ class re {
|
|
|
536
536
|
const e = this.A;
|
|
537
537
|
this.oi && e.deleteBuffer(this.oi), this.oi = e.createBuffer();
|
|
538
538
|
const i = t * D.BYTES_PER_INSTANCE;
|
|
539
|
-
|
|
539
|
+
Ct(e, e.ARRAY_BUFFER, this.oi, i, e.DYNAMIC_DRAW), this.ai = t;
|
|
540
540
|
}
|
|
541
541
|
ui(t) {
|
|
542
542
|
this.li(t);
|
|
@@ -632,7 +632,7 @@ class X {
|
|
|
632
632
|
a(this, "Mi", null);
|
|
633
633
|
this.A = t, this.wi = e, this.Ci = i, this.xi = s;
|
|
634
634
|
const r = this.A.createBuffer();
|
|
635
|
-
|
|
635
|
+
Ct(this.A, this.A.ARRAY_BUFFER, r, this.xi.Fi, this.A.STATIC_DRAW), this.Mi = r;
|
|
636
636
|
}
|
|
637
637
|
get type() {
|
|
638
638
|
return this.Ci;
|
|
@@ -759,7 +759,7 @@ class de {
|
|
|
759
759
|
const { material: e, type: i, commands: s } = t, r = this.Si.get(i);
|
|
760
760
|
e.shader.D(), e.shader.O(e.uniforms);
|
|
761
761
|
const h = Pt(this.A), o = s.length > 0 && s[0].state.kt;
|
|
762
|
-
e.shader.O({ Uv: h[2] / h[3],
|
|
762
|
+
e.shader.O({ Uv: h[2] / h[3], Ud: [h[2], h[3]], Ue: 1, Uf: o ? 1 : 0 }), r.Pi();
|
|
763
763
|
for (const c of s) r.yi(c.params, c.state);
|
|
764
764
|
if (r.$i()) {
|
|
765
765
|
const c = r.unitGeometry, l = r.unitBuffer;
|
|
@@ -1139,21 +1139,21 @@ function xe(n) {
|
|
|
1139
1139
|
const T = ot(r, b);
|
|
1140
1140
|
if (T <= 15) x.push(T);
|
|
1141
1141
|
else if (T === 16) {
|
|
1142
|
-
const S = r.readBits(2) + 3,
|
|
1143
|
-
for (let Q = 0; Q < S; Q++) x.push(
|
|
1142
|
+
const S = r.readBits(2) + 3, F = x[x.length - 1] || 0;
|
|
1143
|
+
for (let Q = 0; Q < S; Q++) x.push(F);
|
|
1144
1144
|
} else if (T === 17) {
|
|
1145
1145
|
const S = r.readBits(3) + 3;
|
|
1146
|
-
for (let
|
|
1146
|
+
for (let F = 0; F < S; F++) x.push(0);
|
|
1147
1147
|
} else {
|
|
1148
1148
|
if (T !== 18) throw Error("Invalid code length symbol");
|
|
1149
1149
|
{
|
|
1150
1150
|
const S = r.readBits(7) + 11;
|
|
1151
|
-
for (let
|
|
1151
|
+
for (let F = 0; F < S; F++) x.push(0);
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
|
-
const
|
|
1156
|
-
g = V(
|
|
1155
|
+
const C = x.slice(0, v), N = x.slice(v, v + A);
|
|
1156
|
+
g = V(C), m = V(N);
|
|
1157
1157
|
}
|
|
1158
1158
|
for (; ; ) {
|
|
1159
1159
|
const v = ot(r, g);
|
|
@@ -1170,9 +1170,9 @@ function xe(n) {
|
|
|
1170
1170
|
let b = l[E];
|
|
1171
1171
|
const x = u[E];
|
|
1172
1172
|
x && (b += r.readBits(x));
|
|
1173
|
-
const
|
|
1174
|
-
if (
|
|
1175
|
-
for (let N = 0; N < p; N++) h.push(h[
|
|
1173
|
+
const C = h.length - b;
|
|
1174
|
+
if (C < 0) throw Error("Invalid distance");
|
|
1175
|
+
for (let N = 0; N < p; N++) h.push(h[C + N] || 0);
|
|
1176
1176
|
} else if (v === 286 || v === 287) throw Error("Reserved length symbol");
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
@@ -1187,8 +1187,8 @@ function we(n) {
|
|
|
1187
1187
|
const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), h = [];
|
|
1188
1188
|
let o = 44;
|
|
1189
1189
|
for (let p = 0; p < s; p++) {
|
|
1190
|
-
const y = t.readASCII(e, o, 4), E = t.readUint(e, o + 4), b = t.readUint(e, o + 8), x = t.readUint(e, o + 12),
|
|
1191
|
-
h.push({ tag: y, offset: E, compLength: b, origLength: x, checksum:
|
|
1190
|
+
const y = t.readASCII(e, o, 4), E = t.readUint(e, o + 4), b = t.readUint(e, o + 8), x = t.readUint(e, o + 12), C = t.readUint(e, o + 16);
|
|
1191
|
+
h.push({ tag: y, offset: E, compLength: b, origLength: x, checksum: C }), o += 20;
|
|
1192
1192
|
}
|
|
1193
1193
|
for (const p of h) {
|
|
1194
1194
|
const y = new Uint8Array(e.buffer, p.offset, p.compLength);
|
|
@@ -1224,10 +1224,10 @@ function we(n) {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
if (h.find((p) => p.tag === "head")) {
|
|
1226
1226
|
const p = m.head, y = function(E, b) {
|
|
1227
|
-
const x = b + 8,
|
|
1227
|
+
const x = b + 8, C = [E[x], E[x + 1], E[x + 2], E[x + 3]];
|
|
1228
1228
|
L(E, x, 0);
|
|
1229
1229
|
const N = 2981146554 - (ht(E, 0, q(E.length)) >>> 0) >>> 0;
|
|
1230
|
-
return E[x] =
|
|
1230
|
+
return E[x] = C[0], E[x + 1] = C[1], E[x + 2] = C[2], E[x + 3] = C[3], N >>> 0;
|
|
1231
1231
|
}(v, p);
|
|
1232
1232
|
L(v, p + 8, y);
|
|
1233
1233
|
}
|
|
@@ -1292,7 +1292,7 @@ const be = { parseTab(n, t, e) {
|
|
|
1292
1292
|
r[o] = c(n, t + 2 * h);
|
|
1293
1293
|
}
|
|
1294
1294
|
return r;
|
|
1295
|
-
} },
|
|
1295
|
+
} }, Ce = { parseTab(n, t, e, i) {
|
|
1296
1296
|
const s = R, r = [], h = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
|
|
1297
1297
|
let l = 0, u = 0, f = 0;
|
|
1298
1298
|
for (; f < c; ) l = s.readUshort(n, t + (f << 2)), u = s.readShort(n, t + (f << 2) + 2), r.push(l), h.push(u), f++;
|
|
@@ -1301,7 +1301,7 @@ const be = { parseTab(n, t, e) {
|
|
|
1301
1301
|
} }, wt = { cmap: be, head: Te, hhea: Re, maxp: { parseTab(n, t, e) {
|
|
1302
1302
|
const i = R;
|
|
1303
1303
|
return i.readUint(n, t), t += 4, { numGlyphs: i.readUshort(n, t) };
|
|
1304
|
-
} }, hmtx:
|
|
1304
|
+
} }, hmtx: Ce, loca: { parseTab(n, t, e, i) {
|
|
1305
1305
|
const s = R, r = [], h = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
|
|
1306
1306
|
if (h === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(n, t + (c << 1)) << 1);
|
|
1307
1307
|
else if (h === 1) for (let c = 0; c < o; c++) r.push(s.readUint(n, t + (c << 2)));
|
|
@@ -1373,7 +1373,7 @@ const be = { parseTab(n, t, e) {
|
|
|
1373
1373
|
}
|
|
1374
1374
|
return null;
|
|
1375
1375
|
}, T: wt, B: R };
|
|
1376
|
-
class
|
|
1376
|
+
class Fe {
|
|
1377
1377
|
De(t) {
|
|
1378
1378
|
var i;
|
|
1379
1379
|
const e = [];
|
|
@@ -1602,7 +1602,7 @@ class mt {
|
|
|
1602
1602
|
a(this, "gr");
|
|
1603
1603
|
a(this, "mr");
|
|
1604
1604
|
a(this, "_r");
|
|
1605
|
-
this.cr = e, this.pr = new
|
|
1605
|
+
this.cr = e, this.pr = new Fe(), this.gr = new Pe(t), this.mr = new Me(), this._r = new Ne();
|
|
1606
1606
|
}
|
|
1607
1607
|
async yr(t) {
|
|
1608
1608
|
let e;
|
|
@@ -3197,15 +3197,15 @@ const je = ({ textmodifier: n, grid: t, progress: e, frameCount: i, message: s,
|
|
|
3197
3197
|
if (n.pop(), u) {
|
|
3198
3198
|
const E = n.color(h.subtleColor), b = n.color(E.r, E.g, E.b, m);
|
|
3199
3199
|
n.charColor(b);
|
|
3200
|
-
const x = Math.floor(0.8 * t.cols),
|
|
3200
|
+
const x = Math.floor(0.8 * t.cols), C = u.split(" "), N = [];
|
|
3201
3201
|
let T = "";
|
|
3202
|
-
for (const
|
|
3202
|
+
for (const F of C) (T + " " + F).length <= x ? T = T ? T + " " + F : F : (T && N.push(T), T = F);
|
|
3203
3203
|
T && N.push(T);
|
|
3204
3204
|
const S = N.slice(0, 3);
|
|
3205
|
-
N.length > 3 && (S[2] = S[2].substring(0, x - 3) + "..."), S.forEach((
|
|
3206
|
-
const Wt = -Math.floor(
|
|
3205
|
+
N.length > 3 && (S[2] = S[2].substring(0, x - 3) + "..."), S.forEach((F, Q) => {
|
|
3206
|
+
const Wt = -Math.floor(F.length / 2);
|
|
3207
3207
|
n.push(), n.translate(Wt, 3 + Q, 0);
|
|
3208
|
-
for (const Kt of
|
|
3208
|
+
for (const Kt of F) n.char(Kt), n.rect(1, 1), n.translateX(1);
|
|
3209
3209
|
n.pop();
|
|
3210
3210
|
});
|
|
3211
3211
|
}
|
|
@@ -3215,7 +3215,7 @@ const je = ({ textmodifier: n, grid: t, progress: e, frameCount: i, message: s,
|
|
|
3215
3215
|
const A = Math.max(6, Math.floor(0.6 * t.cols)), p = -Math.floor(A / 2), y = Math.floor(A * e), E = r.length ? r : [n.color("#FFFFFF")];
|
|
3216
3216
|
n.push(), n.translate(p, 3, 0);
|
|
3217
3217
|
for (let b = 0; b < A; b++) {
|
|
3218
|
-
const x = b < y ? "*" : ".",
|
|
3218
|
+
const x = b < y ? "*" : ".", C = E[b % E.length], N = n.color(C.r, C.g, C.b, m);
|
|
3219
3219
|
n.charColor(N), n.char(x), n.rect(1, 1), n.translateX(1);
|
|
3220
3220
|
}
|
|
3221
3221
|
n.pop();
|
|
@@ -3339,7 +3339,7 @@ class Gt {
|
|
|
3339
3339
|
} finally {
|
|
3340
3340
|
this.xa.pop();
|
|
3341
3341
|
}
|
|
3342
|
-
t.end(), s.begin(), r.ve(o), o.O({ u_characterTexture: e.fontFramebuffer, u_charsetDimensions: [e.textureColumns, e.textureRows],
|
|
3342
|
+
t.end(), s.begin(), r.ve(o), o.O({ u_characterTexture: e.fontFramebuffer, u_charsetDimensions: [e.textureColumns, e.textureRows], Ug: t.textures[0], Uh: t.textures[1], Ui: t.textures[2], Uj: [i.cols, i.rows], Uk: [s.width, s.height], Ul: r.state.canvasBackgroundColor }), r.Ae(0, 0, h.width, h.height), s.end(), r.bi(...r.state.canvasBackgroundColor), r.ve(c), c.O({ u_texture: s.textures[0] }), r.Ae(i.offsetX, i.offsetY, i.width, i.height);
|
|
3343
3343
|
}
|
|
3344
3344
|
Xc(t) {
|
|
3345
3345
|
this.Ec = dt(this.l, t);
|
|
@@ -3424,7 +3424,7 @@ class gt {
|
|
|
3424
3424
|
const i = this.Vc.renderer;
|
|
3425
3425
|
this.nl = [], this.Jc.begin(), i.state.qt(), this.il.call(t), this.Jc.end();
|
|
3426
3426
|
const s = this.nl.length > 0, r = s ? this.sl : this.tl;
|
|
3427
|
-
r.begin(), i.bi(0, 0, 0, 0), i.ve(e), e.O({ u_characterTexture: this.Vc.font.fontFramebuffer, u_charsetDimensions: [this.Vc.font.textureColumns, this.Vc.font.textureRows],
|
|
3427
|
+
r.begin(), i.bi(0, 0, 0, 0), i.ve(e), e.O({ u_characterTexture: this.Vc.font.fontFramebuffer, u_charsetDimensions: [this.Vc.font.textureColumns, this.Vc.font.textureRows], Ug: this.Jc.textures[0], Uh: this.Jc.textures[1], Ui: this.Jc.textures[2], Uj: [this.Vc.grid.cols, this.Vc.grid.rows], Uk: [r.width, r.height], Ul: [0, 0, 0, 0] }), i.Ae(0, 0, this.Vc.grid.width, this.Vc.grid.height), r.end(), s && this.Vc.filterManager.ul(this.sl.textures[0], this.tl, this.nl, this.tl.width, this.tl.height, this.Vc.layerPingPongBuffers), this.el = !0;
|
|
3428
3428
|
}
|
|
3429
3429
|
Xr(t) {
|
|
3430
3430
|
var e;
|
|
@@ -3462,7 +3462,7 @@ class Vt {
|
|
|
3462
3462
|
a(this, "vl", null);
|
|
3463
3463
|
a(this, "pl", 0);
|
|
3464
3464
|
this.Z = t, this.dl = t.pe(K, `#version 300 es
|
|
3465
|
-
precision highp float;uniform sampler2D
|
|
3465
|
+
precision highp float;uniform sampler2D Um;uniform sampler2D Un;uniform vec2 Uo;uniform vec2 Up;uniform vec2 Uq;uniform float Ur;uniform vec2 Us;uniform float Ut;uniform int Uu;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(Un,v_uv);vec2 h=v_uv*Uo;vec2 i=h-Uq-Us;vec2 j=Up*0.5;vec2 k=i-j;float l=cos(-Ut);float m=sin(-Ut);vec2 n=vec2(k.x*l-k.y*m,k.x*m+k.y*l);i=n+j;bool o=any(lessThan(i,vec2(0.)))||any(greaterThanEqual(i,Up));if(o){fragColor=g;return;}vec2 p=(floor(i)+0.5)/Up;vec4 q=texture(Um,p);float r=q.a*Ur;if(r<=0.){fragColor=g;return;}vec3 s=e(Uu,g.rgb,q.rgb);vec3 t=mix(g.rgb,s,r);float u=g.a+r*(1.-g.a);fragColor=vec4(t,u);}`);
|
|
3466
3466
|
}
|
|
3467
3467
|
yr(t, e) {
|
|
3468
3468
|
this.vl || (this.vl = [this.Z.Pe(t, e, 1), this.Z.Pe(t, e, 1)]);
|
|
@@ -3477,11 +3477,11 @@ precision highp float;uniform sampler2D Uj;uniform sampler2D Uk;uniform vec2 Ul;
|
|
|
3477
3477
|
}
|
|
3478
3478
|
_l(t, e, i, s, r, h, o, c, l, u, f) {
|
|
3479
3479
|
const d = this.vl[this.pl], g = this.pl === 0 ? 1 : 0, m = this.vl[g], v = l * (Math.PI / 180);
|
|
3480
|
-
m.begin(), f.disable(f.BLEND), this.Z.ve(this.dl), this.dl.O({
|
|
3480
|
+
m.begin(), f.disable(f.BLEND), this.Z.ve(this.dl), this.dl.O({ Um: t, Un: d.textures[0], Uo: [e, i], Up: [s, r], Uq: [o, c], Ur: h, Us: [0, 0], Ut: v, Uu: bt[u] }), this.Z.Ae(0, 0, d.width, d.height), m.end(), this.pl = g;
|
|
3481
3481
|
}
|
|
3482
3482
|
yl(t, e, i, s) {
|
|
3483
3483
|
const r = this.vl[this.pl];
|
|
3484
|
-
t.begin(), s.disable(s.BLEND), this.Z.ve(this.dl), this.dl.O({
|
|
3484
|
+
t.begin(), s.disable(s.BLEND), this.Z.ve(this.dl), this.dl.O({ Um: r.textures[0], Un: r.textures[0], Uo: [e, i], Up: [r.width, r.height], Uq: [0, 0], Ur: 1, Us: [0, 0], Ut: 0, Uu: bt.normal }), this.Z.Ae(0, 0, e, i), t.end();
|
|
3485
3485
|
}
|
|
3486
3486
|
Xr(t, e) {
|
|
3487
3487
|
this.vl && (this.vl[0].resize(t, e), this.vl[1].resize(t, e));
|
|
@@ -3518,6 +3518,12 @@ class kt {
|
|
|
3518
3518
|
swap(t, e) {
|
|
3519
3519
|
t !== e && (this.Sl(this.Cl, t, e) || this.Sl(this.wl, t, e));
|
|
3520
3520
|
}
|
|
3521
|
+
clear() {
|
|
3522
|
+
for (const t of this.Cl) t.gt();
|
|
3523
|
+
this.Cl.length = 0;
|
|
3524
|
+
for (const t of this.wl) t.gt();
|
|
3525
|
+
this.wl.length = 0;
|
|
3526
|
+
}
|
|
3521
3527
|
yr() {
|
|
3522
3528
|
if (this.$l) return;
|
|
3523
3529
|
const t = this.xa.Nn;
|
|
@@ -3527,7 +3533,7 @@ class kt {
|
|
|
3527
3533
|
}
|
|
3528
3534
|
zl(t, e) {
|
|
3529
3535
|
const i = this.xa.Nn, s = this.xa.font, r = this.xa.ga, h = this.xl.ol(), o = h.length > 0, c = o ? this.Fl : this.Ml;
|
|
3530
|
-
c.begin(), this.Z.bi(0, 0, 0, 0), this.Z.ve(this.Al), this.Al.O({ u_characterTexture: s.fontFramebuffer, u_charsetDimensions: [s.textureColumns, s.textureRows],
|
|
3536
|
+
c.begin(), this.Z.bi(0, 0, 0, 0), this.Z.ve(this.Al), this.Al.O({ u_characterTexture: s.fontFramebuffer, u_charsetDimensions: [s.textureColumns, s.textureRows], Ug: r.textures[0], Uh: r.textures[1], Ui: r.textures[2], Uj: [i.cols, i.rows], Uk: [c.width, c.height], Ul: this.Z.state.canvasBackgroundColor }), this.Z.Ae(0, 0, i.width, i.height), c.end(), o && this.xa.Dl.ul(this.Fl.textures[0], this.Ml, h, this.Ml.width, this.Ml.height, this.Pl), this.Ll(), this.Ol(t, e);
|
|
3531
3537
|
}
|
|
3532
3538
|
Ll() {
|
|
3533
3539
|
if (this.Cl.length !== 0) for (const t of this.Cl) t.wa(this.xa, this.Al);
|
|
@@ -3738,7 +3744,7 @@ class Qe extends function(e, ...i) {
|
|
|
3738
3744
|
this.tu = new He(this), this.Lr = e.overlay ?? !1, this.Er = new De(e), this.Z = new pe(this.Er.Yr()), this.rr = new mt(this.Z, e.fontSize ?? 16), this.ba = new Dt(e.frameRate ?? 60), this.Zl = new Gt(this, e.loadingScreen, this.Er.Nr()), this.Zl.Hc(() => {
|
|
3739
3745
|
this.ba.Gn = 0, this.ru = !0;
|
|
3740
3746
|
}), this.Yh = new Lt(this.Er), this._a = new Bt(this.Er, this.Yh), this.Ca = new _t(), this.Qc = this.Z.pe(K, `#version 300 es
|
|
3741
|
-
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D
|
|
3747
|
+
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D Uh;uniform sampler2D Ui;uniform sampler2D Ug;uniform vec2 Uj;uniform vec2 Uk;uniform vec4 Ul;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/Uk;vec2 F=E*Uj;vec2 G=floor(F);vec2 H=(G+0.5)/Uj;vec4 I=texture(Uh,H);vec4 J=texture(Ui,H);vec4 K=texture(Ug,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(Ul,J,J.a);fragColor=mix(d,I,c);}`), this.ma = new kt(this), this.Dl = new jt(this.Z), this.Zl.kn(), this.lu(e);
|
|
3742
3748
|
}
|
|
3743
3749
|
async lu(e) {
|
|
3744
3750
|
await Promise.all([this.rr.yr(e.fontSource), this.Zl.yr(e.fontSource)]);
|
|
@@ -3843,7 +3849,7 @@ class At {
|
|
|
3843
3849
|
vt._(t);
|
|
3844
3850
|
}
|
|
3845
3851
|
static get version() {
|
|
3846
|
-
return "0.7.1-beta.
|
|
3852
|
+
return "0.7.1-beta.4";
|
|
3847
3853
|
}
|
|
3848
3854
|
}
|
|
3849
3855
|
let ct = null;
|
package/dist/textmode.umd.js
CHANGED
|
@@ -4,16 +4,16 @@ var oi=Object.defineProperty;var ai=(T,F,O)=>F in T?oi(T,F,{enumerable:!0,config
|
|
|
4
4
|
- ${r}: ${F.h(n)}`).join(""):""}
|
|
5
5
|
|
|
6
6
|
${"↓".repeat(24)}
|
|
7
|
-
`}static h(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="number"||typeof t=="boolean")return t+"";if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(e=>F.h(e)).join(", ")}]`:`[${t.slice(0,3).map(e=>F.h(e)).join(", ")}, ... +${t.length-3} more]`;if(typeof t=="object"){const e=Object.keys(t);return e.length===0?"{}":e.length<=3?`{ ${e.map(r=>`${r}: ${F.h(t[r])}`).join(", ")} }`:`{ ${e.slice(0,2).map(r=>`${r}: ${F.h(t[r])}`).join(", ")}, ... +${e.length-2} more }`}return t+""}}var O=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(O||{});const I=class I{constructor(){l(this,"l",{globalLevel:3})}static u(){return I.o||(I.o=new I),I.o}v(t,e){const r="%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.",n="color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";switch(this.l.globalLevel){case 0:return!1;case 1:return console.group(r,n),console.warn(F.i(t,e)),console.groupEnd(),!1;case 2:return console.group(r,n),console.error(F.i(t,e)),console.groupEnd(),!1;default:throw new F(t,e)}}m(t,e,r){return!!t||(this.v(e,r),!1)}_(t){this.l.globalLevel=t}};l(I,"o",null);let lt=I;const ut=lt.u();class
|
|
8
|
-
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
|
|
9
|
-
precision highp float;in vec2 v_uv;uniform sampler2D U5;uniform sampler2D U6;uniform sampler2D U7;uniform sampler2D U8;uniform vec2 U9;uniform bool Ua;uniform bool Ub;uniform bool Uc;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*U9;vec2 D=(floor(C)+0.5f)/U9;vec4 E=texture(U5,D);vec4 F=Ua?texture(U6,D):vec4(0.);if(Ua&&F.a==0.){discard;}vec4 G=Ub?texture(U7,D):vec4(0.);vec4 H=Uc?texture(U8,D):vec4(0.);o_character=E;o_primaryColor=F;o_secondaryColor=G;A=H;}`));const c=t.getParameter(t.MAX_DRAW_BUFFERS),u=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,c,u),this.Y=t.createFramebuffer(),this.tt(),this.st(),this.l.depth&&this.it()}tt(){const t=this.A,e=this.l.filter==="linear"?t.LINEAR:t.NEAREST,r=this.l.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,n=this.l.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,h=n===t.FLOAT?t.RGBA32F:t.RGBA8,a=t.RGBA;for(let c=0;c<this.K;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),tt(t,e,e,r,r),t.texImage2D(t.TEXTURE_2D,0,h,this.N,this.X,0,a,n,null),this.j.push(u)}t.bindTexture(t.TEXTURE_2D,null)}st(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.Y),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.j[0],0);else{const e=[];for(let r=0;r<this.K;r++){const n=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,n,t.TEXTURE_2D,this.j[r],0),e.push(n)}t.drawBuffers(e)}t.bindFramebuffer(t.FRAMEBUFFER,null)}it(){const t=this.A;this.W=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.W),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.W),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}et(t){Rt(this.A,this.j[0],t)}resize(t,e){this.N=t,this.X=e,this.V.clear();const r=this.A,n=this.l.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,h=n===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.j)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,h,this.N,this.X,0,a,n,null);r.bindTexture(r.TEXTURE_2D,null),this.W&&(r.bindRenderbuffer(r.RENDERBUFFER,this.W),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.N,this.X),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const e=this.V.get(t);if(e)return e;const r=this.A,n=this.N,h=this.X,a=new Uint8Array(n*h*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.Y),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,n,h,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.READ_FRAMEBUFFER,c);const u=4*n,f=new Uint8Array(a.length);for(let d=0;d<h;d++){const g=(h-1-d)*u,v=d*u;f.set(a.subarray(g,g+u),v)}return this.V.set(t,f),f}begin(){const t=this.A;this.V.clear(),this.Z.rt(),this.Z.nt(this.Y,this.N,this.X,this.K),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.Z.state.ht()}end(){this.Z.state.ot(),this.Z.ct(),this.Z.lt()}ut(){return this.q||this.ft(),this.q}ft(){if(!this.Z)return;const t=this.K>1,e=this.K>2,r=this.K>3,n={U5:this.j[0],U6:t?this.j[1]:this.j[0],U7:e?this.j[2]:this.j[0],U8:r?this.j[3]:this.j[0],U9:[this.N,this.X],Ua:t,Ub:e,Uc:r},h=H.J;this.q=this.Z.vt.dt(h,n,!0)}gt(){const t=this.A;t.deleteFramebuffer(this.Y);for(const e of this.j)t.deleteTexture(e);this.W&&t.deleteRenderbuffer(this.W)}get width(){return this.N}get height(){return this.X}get textures(){return this.j}get attachmentCount(){return this.K}};l(H,"J",null);let z=H;const Pt=new WeakMap;function dt(o,t){Pt.set(o,t)}function Mt(o){return Pt.get(o)}function it(o,t,e,r,n=255){o[0]=t/255,o[1]=(e??t)/255,o[2]=(r??t)/255,o[3]=n/255}class st{constructor(){l(this,"_t",1);l(this,"yt",0);l(this,"At",0);l(this,"bt",0);l(this,"wt",0);l(this,"Ct",0);l(this,"xt",0);l(this,"Mt",[0,0,0]);l(this,"Ft",[1,1,1,1]);l(this,"Pt",[0,0,0,1]);l(this,"$t",!1);l(this,"Tt",!1);l(this,"Rt",!1);l(this,"Et",0);l(this,"St",[0,0,0,1]);l(this,"kt",!1);l(this,"zt",[]);l(this,"Dt",[])}static Lt(){return{Ot:1,It:0,Bt:0,Ht:0,wt:0,Ct:0,xt:0,Et:0,Gt:!1,Qt:!1,Rt:!1,kt:!1,Nt:[0,0,0],Xt:[1,1,1,1],Yt:[0,0,0,1]}}jt(t){t.Ot=this._t,t.It=this.yt,t.Bt=this.At,t.Ht=this.bt,t.wt=this.wt,t.Ct=this.Ct,t.xt=this.xt,t.Gt=this.$t,t.Qt=this.Tt,t.Rt=this.Rt,t.Et=this.Et,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]}Wt(t){this._t=t.Ot,this.yt=t.It,this.At=t.Bt,this.bt=t.Ht,this.wt=t.wt,this.Ct=t.Ct,this.xt=t.xt,this.$t=t.Gt,this.Tt=t.Qt,this.Rt=t.Rt,this.Et=t.Et,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]}ht(){let t=this.Dt.pop();t||(t=st.Lt()),this.jt(t),this.zt.push(t)}ot(){const t=this.zt.pop();t?(this.Wt(t),this.Dt.push(t)):console.warn("pop() called without matching push()")}Kt(t){this.jt(t)}Zt(t){this._t=Math.abs(t)}qt(){this.yt=0,this.At=0,this.bt=0,this.wt=0,this.Ct=0,this.xt=0,this.kt=!1}Vt(t){t!==0&&(this.wt+=t*Math.PI/180)}Jt(t){t!==0&&(this.Ct+=t*Math.PI/180)}ts(t){t!==0&&(this.xt+=t*Math.PI/180)}ss(t=0,e=0,r=0){t===0&&e===0&&r===0||(this.yt+=t,this.At+=e,this.bt+=r)}es(t){this.ss(t,0,0)}rs(t){this.ss(0,t,0)}ns(t){this.ss(0,0,t)}hs(t){this.Mt[0]=t[0],this.Mt[1]=t[1],this.Mt[2]=t[2]}cs(t,e,r,n=255){it(this.Ft,t,e,r,n)}ls(t,e,r,n=255){it(this.Pt,t,e,r,n)}us(t){this.$t=t}fs(t){this.Tt=t}ds(t){this.Rt=t}vs(t){this.Et=Ft(t)}ps(t,e,r,n){it(this.St,t,e,r,n)}gs(t){this.kt=t}get canvasBackgroundColor(){return this.St}get useOrtho(){return this.kt}get rotationX(){return this.wt}get rotationY(){return this.Ct}get rotationZ(){return this.xt}}const gt=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,-.5,.5,0,1,-.5,.5,0,1,.5,-.5,1,0,.5,.5,1,1]),G={_s:16,As:WebGL2RenderingContext.TRIANGLES,bs:{ws:{size:2,offset:0},Cs:{size:2,offset:8}}};class ie{constructor(t){l(this,"A");l(this,"Ms");l(this,"Fs");this.A=t,this.Ms=t.createBuffer(),this.Fs=new Float32Array(gt.length)}Ps(t,e,r,n){const h=this.A,a=Mt(this.A),c=a[2],u=a[3],f=t/c*2-1,d=(t+r)/c*2-1,g=1-(e+n)/u*2,v=1-e/u*2,m=gt,A=this.Fs;for(let p=0;p<m.length;p+=4){const y=m[p],E=m[p+1],w=m[p+2],x=m[p+3],P=f+(y+.5)*(d-f),b=g+(E+.5)*(v-g);A[p]=P,A[p+1]=b,A[p+2]=w,A[p+3]=x}h.bindBuffer(h.ARRAY_BUFFER,this.Ms),h.bufferData(h.ARRAY_BUFFER,A,h.DYNAMIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,16,0),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,16,8),h.drawArrays(h.TRIANGLES,0,6),h.disableVertexAttribArray(1),h.disableVertexAttribArray(0),h.bindBuffer(h.ARRAY_BUFFER,null)}gt(){this.A.deleteBuffer(this.Ms)}}var R=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(R||{});const se={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class re{constructor(t){l(this,"A");l(this,"$s",new Map);this.A=t}Ts(t,e,r,n){const h=this.A;let a=this.$s.get(t);a||(a=new Map,this.$s.set(t,a));let c=a.get(e)||null;if(!c){c=h.createVertexArray(),a.set(e,c),h.bindVertexArray(c),h.bindBuffer(h.ARRAY_BUFFER,n);const u=h.getAttribLocation(t,"A0");u!==-1&&ft(h,u,r.bs.ws.size,r._s,r.bs.ws.offset,0,h.FLOAT,!1);const f=h.getAttribLocation(t,"A1");f!==-1&&ft(h,f,r.bs.Cs.size,r._s,r.bs.Cs.offset,0,h.FLOAT,!1)}h.bindVertexArray(c)}Rs(){this.A.bindVertexArray(null)}gt(){for(const[,t]of this.$s)for(const[,e]of t)e&&this.A.deleteVertexArray(e)}}const Z=class Z{static Es(t,e,r=0){const n=e||new Float32Array(Z.FLOATS_PER_INSTANCE);let h=r;n[h++]=t.ws[0],n[h++]=t.ws[1],n[h++]=t.Ss[0],n[h++]=t.Ss[1],n[h++]=t.Nt[0],n[h++]=t.Nt[1],n[h++]=t.Nt[2],n[h++]=t.Xt[0],n[h++]=t.Xt[1],n[h++]=t.Xt[2],n[h++]=t.Xt[3],n[h++]=t.Yt[0],n[h++]=t.Yt[1],n[h++]=t.Yt[2],n[h++]=t.Yt[3],n[h++]=t.ks[0],n[h++]=t.ks[1],n[h++]=t.ks[2],n[h++]=t.Et;const a=t.zs;n[h++]=(a==null?void 0:a[0])??0,n[h++]=(a==null?void 0:a[1])??0,n[h++]=(a==null?void 0:a[2])??0;const c=t.Ds;n[h++]=(c==null?void 0:c[0])??0,n[h++]=(c==null?void 0:c[1])??0,n[h++]=(c==null?void 0:c[2])??0;const u=t.Ls,f=t.Os,d=t.Is,g=t.Bs,v=t.Hs,m=!(!f||!d);return m?(n[h++]=(g==null?void 0:g[0])??0,n[h++]=(g==null?void 0:g[1])??0,n[h++]=(v==null?void 0:v[0])??0,n[h++]=(v==null?void 0:v[1])??0,n[h++]=f[0],n[h++]=f[1],n[h++]=d[0],n[h++]=d[1]):!m&&!!u?(n[h++]=u[0],n[h++]=u[1],n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0):(n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0),n[h++]=t.Gs??0,n[h++]=t.Qs??0,n[h++]=t.Ns??0,n}static Xs(t,e){const r=t.length*Z.FLOATS_PER_INSTANCE,n=e||new Float32Array(r);for(let h=0;h<t.length;h++){const a=h*Z.FLOATS_PER_INSTANCE;Z.Es(t[h],n,a)}return n}};l(Z,"BYTES_PER_INSTANCE",144),l(Z,"FLOATS_PER_INSTANCE",36);let _=Z;const S=class S{};l(S,"STRIDE",_.BYTES_PER_INSTANCE),l(S,"ATTRIBUTES",{A2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:0,divisor:1},A3:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:8,divisor:1},A4:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:16,divisor:1},A5:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:28,divisor:1},A6:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:44,divisor:1},A7:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:60,divisor:1},A8:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:76,divisor:1},A9:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:88,divisor:1},Aa:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:100,divisor:1},Ab:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:116,divisor:1},Ac:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:132,divisor:1}});let K=S;class ne{constructor(t=1e3,e=1.5){l(this,"Ys");l(this,"js");l(this,"Ws");l(this,"Ks",0);l(this,"Zs",0);this.js=t,this.Ws=e;const r=t*_.FLOATS_PER_INSTANCE;this.Ys=new Float32Array(r)}qs(t){if(t<=this.js)return;const e=Math.ceil(t*this.Ws),r=this.js;this.js=e;const n=e*_.FLOATS_PER_INSTANCE,h=new Float32Array(n),a=r*_.FLOATS_PER_INSTANCE;h.set(this.Ys.subarray(0,Math.min(a,this.Ks))),this.Ys=h}Vs(){return{buffer:this.Ys,offset:this.Ks}}Js(t){this.Ks+=t,this.Zs++}ti(){this.Ks=0,this.Zs=0}si(t=0,e){return this.Ys.subarray(t,e??this.Ks)}get ii(){return this.Zs}get ei(){return this.js}get ri(){return this.Ks}get ni(){return this.Zs===0}}class he{constructor(t){l(this,"Ys");this.Ys=t}hi(t){this.Ys.qs(this.Ys.ii+1);const{buffer:e,offset:r}=this.Ys.Vs();e[r+0]=t.x,e[r+1]=t.y,e[r+2]=t.width,e[r+3]=t.height,e[r+4]=t.char0,e[r+5]=t.char1,e[r+6]=t.char2,e[r+7]=t.r1,e[r+8]=t.g1,e[r+9]=t.b1,e[r+10]=t.a1,e[r+11]=t.r2,e[r+12]=t.g2,e[r+13]=t.b2,e[r+14]=t.a2,e[r+15]=t.invert,e[r+16]=t.flipX,e[r+17]=t.flipY,e[r+18]=t.charRot,e[r+19]=t.translationX,e[r+20]=t.translationY,e[r+21]=t.translationZ,e[r+22]=t.rotationX,e[r+23]=t.rotationY,e[r+24]=t.rotationZ;const n=t.curveParams0,h=t.curveParams1;return e[r+25]=n[0],e[r+26]=n[1],e[r+27]=n[2],e[r+28]=n[3],e[r+29]=h[0],e[r+30]=h[1],e[r+31]=h[2],e[r+32]=h[3],e[r+33]=t.depth,e[r+34]=t.baseZ,e[r+35]=t.geometryType,this.Ys.Js(_.FLOATS_PER_INSTANCE),this.Ys.ii-1}get ii(){return this.Ys.ii}}class oe{constructor(t,e=1e3){l(this,"A");l(this,"oi",null);l(this,"ai",0);l(this,"ci",new Map);this.A=t,this.li(e)}li(t){const e=this.A;this.oi&&e.deleteBuffer(this.oi),this.oi=e.createBuffer();const r=t*_.BYTES_PER_INSTANCE;Ct(e,e.ARRAY_BUFFER,this.oi,r,e.DYNAMIC_DRAW),this.ai=t}ui(t){this.li(t)}get ei(){return this.ai}fi(t,e){if(e===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.oi);const n=e*_.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,n)}di(t){let e=this.ci.get(t);if(!e){e=new Map;const r=this.A;for(const n in K.ATTRIBUTES){const h=r.getAttribLocation(t,n);h!==-1&&e.set(n,h)}this.ci.set(t,e)}return e}pi(t){const e=this.A,r=t.G,n=this.di(r);for(const[h,a]of n){const c=K.ATTRIBUTES[h];c&&ft(e,a,c.size,c.stride,c.offset,c.divisor,c.type,c.normalized)}}gi(t){const e=this.A,r=this.di(t.G);for(const[n,h]of r)K.ATTRIBUTES[n]&&(e.disableVertexAttribArray(h),e.vertexAttribDivisor(h,0))}gt(){this.oi&&(this.A.deleteBuffer(this.oi),this.oi=null),this.ci.clear()}}class ae{constructor(t,e=1e3,r=1.5){l(this,"A");l(this,"Ys");l(this,"mi");l(this,"_i");this.A=t,this.Ys=new ne(e,r),this.mi=new he(this.Ys),this._i=new oe(t,e)}yi(t){var n,h,a,c,u,f,d,g,v,m;const e=[0,0,0,0],r=[0,0,0,0];return t.Os&&t.Is?(e[0]=((n=t.Bs)==null?void 0:n[0])??0,e[1]=((h=t.Bs)==null?void 0:h[1])??0,e[2]=((a=t.Hs)==null?void 0:a[0])??0,e[3]=((c=t.Hs)==null?void 0:c[1])??0,r[0]=t.Os[0],r[1]=t.Os[1],r[2]=t.Is[0],r[3]=t.Is[1]):t.Ls&&(e[0]=t.Ls[0],e[1]=t.Ls[1]),this.hi({x:t.ws[0],y:t.ws[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.Et,translationX:((u=t.zs)==null?void 0:u[0])??0,translationY:((f=t.zs)==null?void 0:f[1])??0,translationZ:((d=t.zs)==null?void 0:d[2])??0,rotationX:((g=t.Ds)==null?void 0:g[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:r,depth:t.Gs||0,baseZ:t.Qs||0,geometryType:t.Ns||0})}hi(t){const e=this.mi.hi(t);return this.Ys.ei>this._i.ei&&this._i.ui(this.Ys.ei),e}get Ai(){return this.Ys.ii}get ni(){return this.Ys.ni}bi(){this.Ys.ti()}pi(t){const e=this.Ys.ii;if(e===0)return;const r=this.Ys.si();this._i.fi(r,e),this._i.pi(t)}gi(t){this._i.gi(t)}Ps(t,e){const r=this.Ys.ii;r!==0&&this.A.drawArraysInstanced(t,0,e,r)}gt(){this._i.gt()}}class V{constructor(t,e,r,n){l(this,"A");l(this,"wi");l(this,"Ci");l(this,"xi");l(this,"Mi",null);this.A=t,this.wi=e,this.Ci=r,this.xi=n;const h=this.A.createBuffer();Ct(this.A,this.A.ARRAY_BUFFER,h,this.xi.Fi,this.A.STATIC_DRAW),this.Mi=h}get type(){return this.Ci}get unitGeometry(){return this.xi}get unitBuffer(){return this.Mi}get batch(){return this.wi}Pi(){this.wi.bi()}$i(){return!this.wi.ni}gt(){this.wi.gt(),this.A.deleteBuffer(this.Mi)}Ti(t,e,r){return this.wi.yi(t)}Ri(t,e,r,n,h,a){const c=h.It??0,u=h.Bt??0,f=h.Ht??0,d=h.wt??0,g=h.Ct??0,v=h.xt??0,m=[0,0,0,0],A=[0,0,0,0];a&&(a.bezStartX!==void 0&&a.bezStartY!==void 0&&a.bezEndX!==void 0&&a.bezEndY!==void 0?(m[0]=a.cp1x??0,m[1]=a.cp1y??0,m[2]=a.cp2x??0,m[3]=a.cp2y??0,A[0]=a.bezStartX??0,A[1]=a.bezStartY??0,A[2]=a.bezEndX??0,A[3]=a.bezEndY??0):a.arcStart===void 0&&a.arcStop===void 0||(m[0]=a.arcStart??0,m[1]=a.arcStop??0));const p={x:t,y:e,width:r,height:n,char0:h.Nt[0],char1:h.Nt[1],char2:h.Nt[2],r1:h.Xt[0],g1:h.Xt[1],b1:h.Xt[2],a1:h.Xt[3],r2:h.Yt[0],g2:h.Yt[1],b2:h.Yt[2],a2:h.Yt[3],invert:h.Rt?1:0,flipX:h.Gt?1:0,flipY:h.Qt?1:0,charRot:h.Et,translationX:c,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:v,curveParams0:m,curveParams1:A,depth:(a==null?void 0:a.depth)??0,baseZ:(a==null?void 0:a.baseZ)??0,geometryType:se[this.Ci]??0};return this.wi.hi(p)}}const ce={Fi:gt,Ei:6,...G},le={Fi:new Float32Array([0,-.5,0,0,1,-.5,1,0,0,.5,0,1,0,.5,0,1,1,-.5,1,0,1,.5,1,1]),Ei:6,...G},ue={Fi:function(o=32){const t=[],e=2*Math.PI/o;for(let r=0;r<o;r++){const n=r*e,h=(r+1)%o*e,a=Math.cos(n),c=Math.sin(n),u=.5*(a+1),f=.5*(c+1),d=Math.cos(h),g=Math.sin(h),v=.5*(d+1),m=.5*(g+1);t.push(0,0,.5,.5,a,c,u,f,d,g,v,m)}return new Float32Array(t)}(32),Ei:96,...G};let fe={Fi:function(o){const t=[];for(let e=0;e<o;e++){const r=e/o,n=(e+1)/o;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),Ei:96,...G};const de={Fi:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Ei:3,...G},ge={Fi:function(o=16){const t=[];for(let e=0;e<o;e++){const r=e/o,n=(e+1)/o;t.push(r,-.5,r,0,n,-.5,n,0,r,.5,r,1,r,.5,r,1,n,-.5,n,0,n,.5,n,1)}return new Float32Array(t)}(16),Ei:96,...G},ve={[R.RECTANGLE]:class extends V{constructor(o,t){super(o,t,R.RECTANGLE,ce)}yi(o,t){return this.Ri(0,0,o.width,o.height,t)}},[R.LINE]:class extends V{constructor(o,t){super(o,t,R.LINE,le)}yi(o,t){const e=o.x2-o.x1,r=o.y2-o.y1,n=Math.hypot(e,r),h=Math.atan2(r,e),a=t.Ot||1,c=o.x1+e/2-n/2,u=o.y1+r/2,f={...t,xt:(t.xt||0)+h};return this.Ri(c,u,n,a,f)}},[R.ELLIPSE]:class extends V{constructor(o,t){super(o,t,R.ELLIPSE,ue)}yi(o,t){return this.Ri(0,0,o.width,o.height,t)}},[R.ARC]:class extends V{constructor(o,t){super(o,t,R.ARC,fe)}yi(o,t){const e=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Ri(0,0,o.width,o.height,t,{arcStart:e,arcStop:r})}},[R.TRIANGLE]:class extends V{constructor(o,t){super(o,t,R.TRIANGLE,de)}yi(o,t){const e=Math.min(o.x1,o.x2,o.x3),r=Math.max(o.x1,o.x2,o.x3),n=Math.min(o.y1,o.y2,o.y3),h=r-e,a=Math.max(o.y1,o.y2,o.y3)-n;return this.Ri(e,n,h,a,t)}},[R.BEZIER_CURVE]:class extends V{constructor(o,t){super(o,t,R.BEZIER_CURVE,ge)}yi(o,t){return this.Ri(0,0,1,t.Ot||1,t,{cp1x:o.cp1x,cp1y:o.cp1y,cp2x:o.cp2x,cp2y:o.cp2y,bezStartX:o.x1,bezStartY:o.y1,bezEndX:o.x2,bezEndY:o.y2})}}};class me{constructor(t){l(this,"A");l(this,"Si");l(this,"ki");this.A=t,this.ki=new re(t),this.Si=new Map;for(const e of Object.values(R)){const r=new ae(t),n=new ve[e](t,r);this.Si.set(e,n)}}zi(t){const e=this.Di(t);for(const r of e)this.Li(r)}Di(t){const e=[];let r=null,n=null,h=null;for(const a of t)n!==a.material||h!==a.type?(r&&r.length>0&&e.push({material:n,type:h,commands:r}),r=[a],n=a.material,h=a.type):r.push(a);return r&&r.length>0&&e.push({material:n,type:h,commands:r}),e}Li(t){const{material:e,type:r,commands:n}=t,h=this.Si.get(r);e.shader.D(),e.shader.O(e.uniforms);const a=Mt(this.A),c=n.length>0&&n[0].state.kt;e.shader.O({Uv:a[2]/a[3],Us:[a[2],a[3]],Ut:1,Uu:c?1:0}),h.Pi();for(const u of n)h.yi(u.params,u.state);if(h.$i()){const u=h.unitGeometry,f=h.unitBuffer;try{this.ki.Ts(e.shader.G,r+"",u,f),h.batch.pi(e.shader),h.batch.Ps(u.As,u.Ei)}finally{h.batch.gi(e.shader),this.ki.Rs(),h.Pi()}}}gt(){for(const t of this.Si.values())t.gt();this.Si.clear(),this.ki.gt()}}function Nt(o){let t=0;for(let e=0;e<o.length;e++)t=(t<<5)-t+o.charCodeAt(e),t&=t;return t}const Ut=new WeakMap;let pe=1;function St(o){if(o==null)return 0;if(typeof o!="object"&&typeof o!="function")return Nt(o+"");let t=Ut.get(o);return t||(t=pe++,Ut.set(o,t)),t}function Q(o,t){return(o<<5)-o+t}class Ae{constructor(t){l(this,"Oi",0);l(this,"Ii");l(this,"Bi");l(this,"Hi",new Map);this.Ii=new j(t,et,`#version 300 es
|
|
10
|
-
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.Bi={id:this.Oi++,shader:this.Ii,uniforms:Object.freeze({}),hash:this.Gi(this.Ii,{}),isBuiltIn:!0}}get Qi(){return this.Bi}dt(t,e={},r=!1){const n=this.Gi(t,e),h=this.Hi.get(n);if(h)return h;const a={id:this.Oi++,shader:t,uniforms:Object.freeze({...e}),hash:n,isBuiltIn:r};return this.Hi.set(n,a),a}Ni(t,e={}){return{id:this.Oi++,shader:t,uniforms:Object.freeze({...e}),hash:0,isBuiltIn:!1}}Gi(t,e){const r=St(t.G),n=function(h,a){let c=0;const u=Object.keys(h).sort();for(const f of u)c=Q(c,Nt(f)),c=Q(c,a(h[f]));return c}(e,this.Xi.bind(this));return Q(r,n)}Xi(t){return typeof t=="number"||typeof t=="boolean"?function(e){return typeof e=="boolean"?e?1:0:Math.floor(e)}(t):Array.isArray(t)?function(e){let r=0;const n=Array.isArray(e[0])?e.flat():e;for(const h of n)r=Q(r,typeof h=="number"?h:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(e){let r=0;const n=Math.min(e.length,16);for(let h=0;h<n;h++)r=Q(r,e[h]);return r}(t):t instanceof WebGLTexture?St(t):0}gt(){this.Ii!=this.Ii&&this.Ii.dispose(),this.Ii.dispose(),this.Hi.clear()}}class Ee{constructor(){l(this,"Yi",[]);l(this,"ji",1);l(this,"Ss",0)}Wi(t,e){if(this.Ss>=this.Yi.length){const n={id:this.ji++,type:t,params:{},state:st.Lt(),material:e};this.Yi.push(n)}const r=this.Yi[this.Ss];return r.id=this.ji++,r.type=t,r.material=e,this.Ss++,r}Ki(t,e,r){const n=this.Wi(R.RECTANGLE,r),h=n.params;return h.width=t.width,h.height=t.height,e.Kt(n.state),n.id}Zi(t,e,r){const n=this.Wi(R.LINE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.thickness=t.thickness,e.Kt(n.state),n.id}qi(t,e,r){const n=this.Wi(R.ELLIPSE,r),h=n.params;return h.width=t.width,h.height=t.height,h.startAngle=t.startAngle,h.endAngle=t.endAngle,h.segments=t.segments,e.Kt(n.state),n.id}Vi(t,e,r){const n=this.Wi(R.ARC,r),h=n.params;return h.width=t.width,h.height=t.height,h.start=t.start,h.stop=t.stop,e.Kt(n.state),n.id}Ji(t,e,r){const n=this.Wi(R.TRIANGLE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.x3=t.x3,h.y3=t.y3,e.Kt(n.state),n.id}te(t,e,r){const n=this.Wi(R.BEZIER_CURVE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.cp1x=t.cp1x,h.cp1y=t.cp1y,h.cp2x=t.cp2x,h.cp2y=t.cp2y,h.x2=t.x2,h.y2=t.y2,h.thickness=t.thickness,h.segments=t.segments,e.Kt(n.state),n.id}bi(){this.Ss=0}[Symbol.iterator](){let t=0;const e=this.Ss,r=this.Yi;return{next:()=>t<e?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ye{constructor(t){l(this,"A");l(this,"se",null);l(this,"ie");l(this,"vt");l(this,"ee");l(this,"re");l(this,"ne");l(this,"he",null);l(this,"oe",{});l(this,"ae",[]);l(this,"ce",[]);l(this,"le",[]);l(this,"ue",null);l(this,"fe",[0,0,0,0]);l(this,"de",1);this.A=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.ee=new st,this.vt=new Ae(t),this.re=new Ee,this.ie=new me(t),this.ne=new ie(t);const e=[0,0,t.canvas.width,t.canvas.height];dt(t,e),this.ae.push(null),this.ce.push(e),this.le.push(1),this.ue=null,this.fe=e,this.de=1}rt(){this.ae.push(this.ue),this.ce.push([...this.fe]),this.le.push(this.de)}lt(){const t=this.ae.pop()??null,e=this.ce.pop()??[0,0,this.A.canvas.width,this.A.canvas.height],r=this.le.pop()??1;this.nt(t,e[2],e[3],r)}nt(t,e,r,n=1){const h=this.A;this.ue!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.ue=t),this.de=n;const a=[0,0,e,r];this.fe[0]===a[0]&&this.fe[1]===a[1]&&this.fe[2]===a[2]&&this.fe[3]===a[3]||(h.viewport(...a),dt(h,a),this.fe=a)}ve(t){this.se!==t&&(this.se=t,t.D())}pe(t,e){return new j(this.A,t,e)}ge(t){this.he=t,t&&(this.oe={})}I(t,e){this.oe[t]=e}me(t){Object.assign(this.oe,t)}_e(t){return new j(this.A,et,t)}ye(t,e,r){this.re.Ki({width:e??t.width,height:r??t.height},this.ee,t.ut())}Ae(t,e,r,n){this.ne.Ps(t,e,r,n)}be(t,e){if(this.he){const r=this.vt.Ni(this.he,this.oe);this.re.Ki({width:t,height:e},this.ee,r),this.he=null,this.oe={}}else this.re.Ki({width:t,height:e},this.ee,this.vt.Qi)}we(t,e,r,n){this.re.Zi({x1:t,y1:e,x2:r,y2:n},this.ee,this.vt.Qi)}Ce(t,e){this.re.qi({width:t,height:e},this.ee,this.vt.Qi)}xe(t,e,r,n,h,a){this.re.Ji({x1:t,y1:e,x2:r,y2:n,x3:h,y3:a},this.ee,this.vt.Qi)}Me(t,e,r,n,h,a,c,u){this.re.te({x1:t,y1:e,cp1x:r,cp1y:n,cp2x:h,cp2y:a,x2:c,y2:u},this.ee,this.vt.Qi)}Fe(t,e,r,n){this.re.Vi({width:t,height:e,start:r,stop:n},this.ee,this.vt.Qi)}Pe(t,e,r=1,n={}){return new z(this.A,t,e,r,n,this)}$e(t,e=t,r=t,n=255){this.ee.ps(t,e??t,r??t,n);const[h,a,c,u]=this.ee.canvasBackgroundColor;this.Te(h,a,c,u,!1)}bi(t=0,e=0,r=0,n=0){this.Te(t,e,r,n,!0)}Te(t,e,r,n,h){const a=this.A;if(this.de>1){const c=h?[1,1,0,0]:[0,0,0,0];a.clearBufferfv(a.COLOR,0,new Float32Array(c)),a.clearBufferfv(a.COLOR,1,new Float32Array([0,0,0,0])),this.de>=3&&a.clearBufferfv(a.COLOR,2,new Float32Array([t,e,r,n]));for(let u=3;u<this.de;u++)a.clearBufferfv(a.COLOR,u,new Float32Array([0,0,0,0]))}else a.clearColor(t,e,r,n),a.clear(a.COLOR_BUFFER_BIT)}Re(){const t=[0,0,this.A.canvas.width,this.A.canvas.height];this.A.viewport(...t),dt(this.A,t),this.fe=t,this.ce.length>0&&(this.ce[0]=t)}ct(){const t=this.re;this.ie.zi(t),t.bi(),this.se=null}gt(){this.vt.gt(),this.ie.gt(),this.ne.gt()}get context(){return this.A}get state(){return this.ee}get materialManager(){return this.vt}}const C={readShort:(o,t)=>(C.t.uint16[0]=o[t]<<8|o[t+1],C.t.int16[0]),readUshort:(o,t)=>o[t]<<8|o[t+1],readUshorts(o,t,e){const r=[];for(let n=0;n<e;n++)r.push(C.readUshort(o,t+2*n));return r},readUint(o,t){const e=C.t.uint8;return e[3]=o[t],e[2]=o[t+1],e[1]=o[t+2],e[0]=o[t+3],C.t.uint32[0]},readASCII(o,t,e){let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(o[t+n]);return r},t:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function rt(o){return o+3&-4}function nt(o,t,e){o[t]=e>>>8&255,o[t+1]=255&e}function X(o,t,e){o[t]=e>>>24&255,o[t+1]=e>>>16&255,o[t+2]=e>>>8&255,o[t+3]=255&e}function xe(o,t,e){for(let r=0;r<e.length;r++)o[t+r]=255&e.charCodeAt(r)}function vt(o,t,e){const r=t+e;let n=0;const h=C.t;for(let a=t;a<r;a+=4)h.uint8[3]=o[a]||0,h.uint8[2]=o[a+1]||0,h.uint8[1]=o[a+2]||0,h.uint8[0]=o[a+3]||0,n=n+(h.uint32[0]>>>0)>>>0;return n>>>0}class we{constructor(t){l(this,"b");l(this,"p",0);l(this,"bitbuf",0);l(this,"bitcnt",0);this.b=t}readBits(t){for(;this.bitcnt<t;){const r=this.b[this.p++]||0;this.bitbuf|=r<<this.bitcnt,this.bitcnt+=8}const e=this.bitbuf&(1<<t)-1;return this.bitbuf>>>=t,this.bitcnt-=t,e}alignToByte(){this.bitbuf=0,this.bitcnt=0}get offset(){return this.p}}function q(o){let t=32,e=0;for(const c of o)c&&(c<t&&(t=c),c>e&&(e=c));if(e===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(e+1);for(const c of o)c&&r[c]++;const n=new Uint32Array(e+1);let h=0;r[0]=0;for(let c=1;c<=e;c++)h=h+r[c-1]<<1,n[c]=h;const a=new Map;for(let c=0;c<o.length;c++){const u=o[c];if(!u)continue;const f=n[u]++;let d=a.get(u);d||(d=[],a.set(u,d)),d[be(f,u)]=c}return{min:t,max:e,table:a}}function mt(o,t){let e=0;for(let r=1;r<=t.max;r++){e|=o.readBits(1)<<r-1;const n=t.table.get(r);if(n&&e<n.length){const h=n[e];if(h!==void 0)return h}}throw Error("Invalid Huffman code")}function be(o,t){let e=0;for(let r=0;r<t;r++)e=e<<1|1&o,o>>>=1;return e>>>0}function Te(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],e=o[1];if((15&t)!=8)throw Error("Unsupported ZLIB compression method");if(((t<<8)+e)%31!=0)throw Error("Bad ZLIB header check");let r=2;32&e&&(r+=4);const n=[];return function(h,a){const c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],f=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],d=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];let g=0;for(;!g;){g=h.readBits(1);const v=h.readBits(2);if(v===0){h.alignToByte();const m=h.readBits(16);if((65535&(65535^m))!==h.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let A=0;A<m;A++)a.push(h.readBits(8))}else{if(v!==1&&v!==2)throw Error("Unsupported DEFLATE type");{let m,A;if(v===1){const p=Array(288).fill(0);for(let y=0;y<=143;y++)p[y]=8;for(let y=144;y<=255;y++)p[y]=9;for(let y=256;y<=279;y++)p[y]=7;for(let y=280;y<=287;y++)p[y]=8;m=q(p),A=q(Array(32).fill(5))}else{const p=h.readBits(5)+257,y=h.readBits(5)+1,E=h.readBits(4)+4,w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=Array(19).fill(0);for(let M=0;M<E;M++)x[w[M]]=h.readBits(3);const P=q(x),b=[];for(;b.length<p+y;){const M=mt(h,P);if(M<=15)b.push(M);else if(M===16){const B=h.readBits(2)+3,D=b[b.length-1]||0;for(let ct=0;ct<B;ct++)b.push(D)}else if(M===17){const B=h.readBits(3)+3;for(let D=0;D<B;D++)b.push(0)}else{if(M!==18)throw Error("Invalid code length symbol");{const B=h.readBits(7)+11;for(let D=0;D<B;D++)b.push(0)}}}const N=b.slice(0,p),L=b.slice(p,p+y);m=q(N),A=q(L)}for(;;){const p=mt(h,m);if(p<256)a.push(p);else{if(p===256)break;if(p>256&&p<286){const y=p-257;let E=c[y];const w=u[y];w&&(E+=h.readBits(w));const x=mt(h,A);if(x>=30)throw Error("Invalid distance symbol");let P=f[x];const b=d[x];b&&(P+=h.readBits(b));const N=a.length-P;if(N<0)throw Error("Invalid distance");for(let L=0;L<E;L++)a.push(a[N+L]||0)}else if(p===286||p===287)throw Error("Reserved length symbol")}}}}}}(new we(o.subarray(r)),n),new Uint8Array(n)}function Fe(o){const t=C,e=new Uint8Array(o);if(t.readASCII(e,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(e,4),n=t.readUshort(e,12),h=t.readUint(e,16),a=[];let c=44;for(let E=0;E<n;E++){const w=t.readASCII(e,c,4),x=t.readUint(e,c+4),P=t.readUint(e,c+8),b=t.readUint(e,c+12),N=t.readUint(e,c+16);a.push({tag:w,offset:x,compLength:P,origLength:b,checksum:N}),c+=20}for(const E of a){const w=new Uint8Array(e.buffer,E.offset,E.compLength);if(E.compLength===E.origLength)E.data=new Uint8Array(w);else if(E.data=Te(w),E.data.length!==E.origLength)if(E.data.length<E.origLength){const x=new Uint8Array(E.origLength);x.set(E.data),E.data=x}else E.data=E.data.subarray(0,E.origLength)}const u=n;let f=1,d=0;for(;f<<1<=u;)f<<=1,d++;const g=16*f,v=16*u-g;let m=12+16*u;const A={};for(const E of a)A[E.tag]=m,m=rt(m+E.data.length);const p=new Uint8Array(Math.max(h||0,m));X(p,0,r),nt(p,4,u),nt(p,6,g),nt(p,8,d),nt(p,10,v);let y=12;for(const E of a){xe(p,y,E.tag),y+=4;let w=E.data;if(E.tag==="head"&&w.length>=12){const x=new Uint8Array(w);X(x,8,0),X(p,y,vt(x,0,rt(x.length))),y+=4}else X(p,y,vt(w,0,rt(w.length))),y+=4;X(p,y,A[E.tag]),y+=4,X(p,y,E.data.length),y+=4}for(const E of a){const w=A[E.tag];p.set(E.data,w)}if(a.find(E=>E.tag==="head")){const E=A.head,w=function(x,P){const b=P+8,N=[x[b],x[b+1],x[b+2],x[b+3]];X(x,b,0);const L=2981146554-(vt(x,0,rt(x.length))>>>0)>>>0;return x[b]=N[0],x[b+1]=N[1],x[b+2]=N[2],x[b+3]=N[3],L>>>0}(p,E);X(p,E+8,w)}return p.buffer}const Re={parseTab(o,t,e){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,e),t=0;const n=C,h=n.readUshort,a=h(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const f=h(o,t),d=h(o,t+=2);t+=2;const g=n.readUint(o,t);t+=4;const v=`p${f}e${d}`;let m=c.indexOf(g);if(m===-1){let A;m=r.tables.length,c.push(g);const p=h(o,g);A=p===4?this.parse4(o,g):p===12?this.parse12(o,g):{format:p},r.tables.push(A)}r.ids[v]=m}return r},parse4(o,t){const e=C,r=e.readUshort,n=e.readUshorts,h=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,searchRange:r(o,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(o,t),t+=2,u.rangeShift=r(o,t),t+=2,u.endCount=n(o,t,c),t+=2*c,t+=2,u.startCount=n(o,t,c),t+=2*c;for(let f=0;f<c;f++)u.idDelta.push(e.readShort(o,t)),t+=2;return u.idRangeOffset=n(o,t,c),t+=2*c,u.glyphIdArray=n(o,t,h+a-t>>1),u},parse12(o,t){const e=C.readUint;e(o,t+=4),e(o,t+=4);const r=e(o,t+=4);t+=4;const n=new Uint32Array(3*r);for(let h=0;h<3*r;h+=3)n[h]=e(o,t+(h<<2)),n[h+1]=e(o,t+(h<<2)+4),n[h+2]=e(o,t+(h<<2)+8);return{format:12,groups:n}}},Ce={parseTab(o,t,e){const r=C;t+=18;const n=r.readUshort(o,t);t+=2,t+=16;const h=r.readShort(o,t);t+=2;const a=r.readShort(o,t);t+=2;const c=r.readShort(o,t);t+=2;const u=r.readShort(o,t);return t+=2,t+=6,{unitsPerEm:n,xMin:h,yMin:a,xMax:c,yMax:u,indexToLocFormat:r.readShort(o,t)}}},Pe={parseTab(o,t,e){const r=C;t+=4;const n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],h={};for(let a=0;a<n.length;a++){const c=n[a],u=c==="advanceWidthMax"||c==="numberOfHMetrics"?r.readUshort:r.readShort;h[c]=u(o,t+2*a)}return h}},Me={parseTab(o,t,e,r){const n=C,h=[],a=[],c=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,d=0,g=0;for(;g<u;)f=n.readUshort(o,t+(g<<2)),d=n.readShort(o,t+(g<<2)+2),h.push(f),a.push(d),g++;for(;g<c;)h.push(f),a.push(d),g++;return{aWidth:h,lsBearing:a}}},Dt={cmap:Re,head:Ce,hhea:Pe,maxp:{parseTab(o,t,e){const r=C;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:Me,loca:{parseTab(o,t,e,r){const n=C,h=[],a=r.head.indexToLocFormat,c=r.maxp.numGlyphs+1;if(a===0)for(let u=0;u<c;u++)h.push(n.readUshort(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)h.push(n.readUint(o,t+(u<<2)));return h}},glyf:{parseTab(o,t,e,r){const n=[],h=r.maxp.numGlyphs;for(let a=0;a<h;a++)n.push(null);return n},Ee(o,t){const e=C,r=o.Se,n=o.loca;if(n[t]===n[t+1])return null;const h=J.findTable(r,"glyf",o.ke);if(!h)return null;let a=h[0]+n[t];const c={};if(c.noc=e.readShort(r,a),a+=2,c.xMin=e.readShort(r,a),a+=2,c.yMin=e.readShort(r,a),a+=2,c.xMax=e.readShort(r,a),a+=2,c.yMax=e.readShort(r,a),a+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(let v=0;v<c.noc;v++)c.endPts.push(e.readUshort(r,a)),a+=2;const u=e.readUshort(r,a);if(a+=2,r.length-a<u)return null;a+=u;const f=c.endPts[c.noc-1]+1;c.flags=[];for(let v=0;v<f;v++){const m=r[a];if(a++,c.flags.push(m),8&m){const A=r[a];a++;for(let p=0;p<A;p++)c.flags.push(m),v++}}c.xs=[];for(let v=0;v<f;v++){const m=c.flags[v],A=!!(16&m);2&m?(c.xs.push(A?r[a]:-r[a]),a++):A?c.xs.push(0):(c.xs.push(e.readShort(r,a)),a+=2)}c.ys=[];for(let v=0;v<f;v++){const m=c.flags[v],A=!!(32&m);4&m?(c.ys.push(A?r[a]:-r[a]),a++):A?c.ys.push(0):(c.ys.push(e.readShort(r,a)),a+=2)}let d=0,g=0;for(let v=0;v<f;v++)d+=c.xs[v],g+=c.ys[v],c.xs[v]=d,c.ys[v]=g}else c.parts=[],c.endPts=[],c.flags=[],c.xs=[],c.ys=[];return c}}},J={parse(o){const t=new Uint8Array(o);C.readASCII(t,0,4)==="wOFF"&&(o=Fe(o));const e=new Uint8Array(o),r=Dt,n={},h={Se:e,ze:0,ke:0};for(const a in r){const c=a,u=J.findTable(e,c,0);if(u){const[f,d]=u;let g=n[f];g==null&&(g=r[c].parseTab(e,f,d,h),n[f]=g),h[c]=g}}return[h]},findTable(o,t,e){const r=C,n=r.readUshort(o,e+4);let h=e+12;for(let a=0;a<n;a++){const c=r.readASCII(o,h,4);r.readUint(o,h+4);const u=r.readUint(o,h+8),f=r.readUint(o,h+12);if(c===t)return[u,f];h+=16}return null},T:Dt,B:C};class Ne{De(t){var r;const e=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(n=>{if(n.format===4){const h=this.Le(n);e.push(...h)}else if(n.format===12){const h=this.Oe(n);e.push(...h)}}),[...new Set(e)]):[]}Le(t){const e=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return e;for(let r=0;r<t.startCount.length;r++){const n=t.startCount[r],h=t.endCount[r];if(n!==65535||h!==65535){for(let a=n;a<=h;a++)if(this.Ie(t,a,r)>0)try{const c=String.fromCodePoint(a);e.push(c)}catch{}}}return e}Oe(t){const e=[];if(!t.groups)return e;for(let r=0;r<t.groups.length;r+=3){const n=t.groups[r],h=t.groups[r+1],a=t.groups[r+2];for(let c=n;c<=h;c++)if(a+(c-n)>0)try{const u=String.fromCodePoint(c);e.push(u)}catch{}}return e}Ie(t,e,r){if(t.idRangeOffset[r]===0)return e+t.idDelta[r]&65535;{const n=t.idRangeOffset[r]/2+(e-t.startCount[r])-(t.startCount.length-r);if(n>=0&&t.glyphIdArray&&n<t.glyphIdArray.length){const h=t.glyphIdArray[n];if(h!==0)return h+t.idDelta[r]&65535}}return 0}}class Ue{constructor(t){l(this,"Be");l(this,"He");l(this,"Z");this.Z=t,this.Be=document.createElement("canvas"),this.He=this.Be.getContext("2d",{willReadFrequently:!0,alpha:!0})}Ge(t,e,r,n){const h=t.length,a=Math.ceil(Math.sqrt(h)),c=Math.ceil(h/a),u=e.width*a,f=e.height*c;this.Qe(u,f),this.Ne(t,e,a,r,n);const d=this.Z.Pe(u,f,1,{filter:"nearest"});return d.et(this.Be),{framebuffer:d,columns:a,rows:c}}Qe(t,e){this.Be.width=t,this.Be.height=e,this.Be.style.width=t+"px",this.Be.style.height=e+"px",this.He.imageSmoothingEnabled=!1,this.Be.style.imageRendering="pixelated",this.He.clearRect(0,0,t,e),this.He.textBaseline="top",this.He.textAlign="left",this.He.fillStyle="white"}Ne(t,e,r,n,h){const a=n/h.head.unitsPerEm;for(let c=0;c<t.length;c++){const u=c%r,f=Math.floor(c/r),d=t[c].glyphData;if(!d)continue;const g=d.advanceWidth*a,v=u*e.width,m=f*e.height,A=v+.5*e.width,p=m+.5*e.height,y=Math.round(A-.5*e.width),E=Math.round(p-.5*n),w=y+.5*(e.width-g),x=E+h.hhea.ascender*a;this.Xe(d,w,x,a)}}Xe(t,e,r,n){if(!t||!t.xs||t.noc===0)return;let{xs:h,ys:a,endPts:c,flags:u}=t;if(!(h&&a&&c&&u))return;this.He.beginPath();let f=0;for(let d=0;d<c.length;d++){const g=c[d];if(!(g<f)){if(g>=f){const v=e+h[f]*n,m=r-a[f]*n;this.He.moveTo(v,m);let A=f+1;for(;A<=g;)if(1&u[A]){const p=e+h[A]*n,y=r-a[A]*n;this.He.lineTo(p,y),A++}else{const p=e+h[A]*n,y=r-a[A]*n;if(A+1>g){const w=e+h[f]*n,x=r-a[f]*n;if(1&u[f])this.He.quadraticCurveTo(p,y,w,x);else{const P=(p+w)/2,b=(y+x)/2;this.He.quadraticCurveTo(p,y,P,b)}break}const E=A+1;if(1&u[E]){const w=e+h[E]*n,x=r-a[E]*n;this.He.quadraticCurveTo(p,y,w,x),A=E+1}else{const w=(p+(e+h[E]*n))/2,x=(y+(r-a[E]*n))/2;this.He.quadraticCurveTo(p,y,w,x),A=E}}this.He.closePath()}f=g+1}}this.He.fill()}}class Lt{Ye(t,e){const r=t.cmap;if(!r||!r.tables)return 0;let n=0;for(const h of r.tables)if(h.format===4?n=this.je(e,h):h.format===12&&(n=this.We(e,h)),n>0)break;return n}Ke(t,e){const r=e.codePointAt(0);return r===void 0?0:this.Ye(t,r)}Ze(t,e){const r=t.hmtx;return r&&r.aWidth&&r.aWidth.length!==0?e<r.aWidth.length?r.aWidth[e]:r.aWidth[r.aWidth.length-1]:0}qe(t,e){const r=e/t.head.unitsPerEm,n=t.hhea.ascender*r,h=t.hhea.descender*r,a=t.hhea.lineGap*r;return{ascender:n,descender:h,lineGap:a,lineHeight:n-h+a,unitsPerEm:t.head.unitsPerEm,scale:r}}je(t,e){const r=e.endCount.length;let n=-1;for(let h=0;h<r;h++)if(t<=e.endCount[h]){n=h;break}if(n===-1||t<e.startCount[n])return 0;if(e.idRangeOffset[n]===0)return t+e.idDelta[n]&65535;{const h=e.idRangeOffset[n]/2+(t-e.startCount[n])-(r-n);if(h>=0&&h<e.glyphIdArray.length){const a=e.glyphIdArray[h];return a===0?0:a+e.idDelta[n]&65535}}return 0}We(t,e){const r=e.groups.length/3;for(let n=0;n<r;n++){const h=e.groups[3*n],a=e.groups[3*n+1],c=e.groups[3*n+2];if(t>=h&&t<=a)return c+(t-h)}return 0}}class Se{constructor(){l(this,"Ve");this.Ve=new Lt}Je(t,e,r){let n=0;const h=this.Ve.qe(r,e),a=h.lineHeight;for(const c of t){const u=this.Ve.Ke(r,c);if(u===0)continue;const f=this.Ve.Ze(r,u)*h.scale;n=Math.max(n,f)}return{width:Math.ceil(n),height:Math.ceil(a)}}}class De{constructor(){l(this,"tr");this.tr=new Lt}sr(t,e){const r=[],n=new Map;return t.forEach((h,a)=>{const c=h.codePointAt(0)||0,u={character:h,unicode:c,color:this.ir(a),glyphData:this.er(e,h)};r.push(u),n.set(h,u)}),{array:r,map:n}}ir(t){return[t%256/255,Math.floor(t/256)%256/255,0]}er(t,e){const r=e.codePointAt(0)||0,n=this.tr.Ye(t,r);if(n===0)return null;let h=0;t.hmtx&&t.hmtx.aWidth&&n>0&&t.hmtx.aWidth[n]!==void 0&&(h=t.hmtx.aWidth[n]);const a=J.T.glyf.Ee(t,n);return a?{...a,advanceWidth:h}:null}}class pt{constructor(t,e=16){l(this,"rr");l(this,"nr",[]);l(this,"hr",new Map);l(this,"ar");l(this,"cr",16);l(this,"lr",0);l(this,"ur",0);l(this,"dr",{width:0,height:0});l(this,"vr");l(this,"pr");l(this,"gr");l(this,"mr");l(this,"_r");this.cr=e,this.pr=new Ne,this.gr=new Ue(t),this.mr=new Se,this._r=new De}async yr(t){let e;if(t){const r=await fetch(t);if(!r.ok)throw new F(`Failed to load font file: ${r.status} ${r.statusText}`);e=await r.arrayBuffer()}else e=await(await fetch("data:font/woff;base64,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")).arrayBuffer();await this.Ar(e),this.rr=J.parse(e)[0],await this.br()}wr(t){if(t===void 0)return this.cr;this.cr=t,this.dr=this.mr.Je(this.nr.map(r=>r.character),this.cr,this.rr);const e=this.gr.Ge(this.nr,this.dr,this.cr,this.rr);this.ar=e.framebuffer,this.lr=e.columns,this.ur=e.rows}async Cr(t){try{const e=await fetch(t);if(!e.ok)throw new F(`Failed to load font file: ${e.status} ${e.statusText}`);const r=await e.arrayBuffer();await this.Ar(r);const n=J.parse(r);if(!n||n.length===0)throw Error("Failed to parse font file");this.rr=n[0],await this.br()}catch(e){throw new F("Failed to load font: "+(e instanceof Error?e.message:"Unknown error"),e)}}async Ar(t){const e=Date.now();this.vr=new FontFace("CustomFont_"+e,t),await this.vr.load(),document.fonts.add(this.vr)}async br(){const t=this.pr.De(this.rr),{array:e,map:r}=this._r.sr(t,this.rr);this.nr=e,this.hr=r,this.dr=this.mr.Je(t,this.cr,this.rr);const n=this.gr.Ge(this.nr,this.dr,this.cr,this.rr);this.ar=n.framebuffer,this.lr=n.columns,this.ur=n.rows}Mr(t){const e=this.hr.get(t);return e?e.color:[0,0,0]}Fr(t){return Array.from(t).map(e=>{const r=this.hr.get(e);return r?r.color:[0,0,0]})}gt(){this.ar.gt(),document.fonts.delete(this.vr)}get fontFramebuffer(){return this.ar}get characterMap(){return this.hr}get characters(){return this.nr}get textureColumns(){return this.lr}get textureRows(){return this.ur}get maxGlyphDimensions(){return this.dr}get fontSize(){return this.cr}get font(){return this.rr}}class At{constructor(t,e,r){l(this,"Pr");l(this,"$r");l(this,"N");l(this,"X");l(this,"Tr");l(this,"Rr");l(this,"Er");l(this,"Sr");l(this,"kr");this.Er=t,this.Sr=e,this.kr=r,this.ti()}ti(){this.Pr=Math.floor(this.Er.width/this.Sr),this.$r=Math.floor(this.Er.height/this.kr),this.N=this.Pr*this.Sr,this.X=this.$r*this.kr,this.Tr=Math.floor((this.Er.width-this.N)/2),this.Rr=Math.floor((this.Er.height-this.X)/2)}zr(t,e){this.Sr=t,this.kr=e,this.ti()}get cellWidth(){return this.Sr}get cellHeight(){return this.kr}get cols(){return this.Pr}get rows(){return this.$r}get width(){return this.N}get height(){return this.X}get offsetX(){return this.Tr}get offsetY(){return this.Rr}}const Le=/^rgba?\(([^)]+)\)$/i;function Et(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function _e(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t)return null;let e=null;return t.startsWith("rgb")&&(e=function(r){const n=Le.exec(r.trim());if(!n)return null;const h=n[1].split(",").map(d=>d.trim());if(h.length<3)return null;const a=Et(parseFloat(h[0])),c=Et(parseFloat(h[1])),u=Et(parseFloat(h[2])),f=h[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(h[3]))):255;return[a,c,u,Math.round(f)]}(t)),e?e[3]===0?null:e:null}class _t{constructor(t={}){l(this,"Er");l(this,"Dr",null);l(this,"Lr",!1);l(this,"Or");this.Lr=t.overlay??!1,this.Lr&&t.canvas?(this.Dr=t.canvas,this.Er=this.Ir(),this.Or=!0,this.Br()):t.canvas?(this.Er=t.canvas,this.Or=!1):(this.Er=this.Hr(t.width,t.height),this.Or=!0),this.Er.style.imageRendering="pixelated"}Hr(t,e){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=e||600,document.body.appendChild(r),r}Ir(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const e=this.Dr.getBoundingClientRect();let r=Math.round(e.width),n=Math.round(e.height);if(this.Dr instanceof HTMLVideoElement){const c=this.Dr;(r===0||n===0)&&c.videoWidth>0&&c.videoHeight>0&&(r=c.videoWidth,n=c.videoHeight)}t.width=r,t.height=n,t.style.position="absolute",t.style.pointerEvents="none";const h=window.getComputedStyle(this.Dr);let a=parseInt(h.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=""+(a+1),t}Br(){var t;this.Gr(),(t=this.Dr.parentNode)==null||t.insertBefore(this.Er,this.Dr.nextSibling)}Qr(){const t=[];return this.Lr&&this.Dr instanceof HTMLElement&&(t.push(this.Dr),this.Dr.parentElement&&t.push(this.Dr.parentElement)),this.Er.parentElement&&t.push(this.Er.parentElement),t.push(this.Er),t.push(document.body),t.push(document.documentElement),t}Nr(){const t=this.Qr();for(const e of t){if(!e)continue;const r=_e(window.getComputedStyle(e).backgroundColor);if(r)return r}return[255,255,255,255]}Gr(){if(!this.Dr)return;const t=this.Dr.getBoundingClientRect();let e=this.Dr.offsetParent;if(e&&e!==document.body){const r=e.getBoundingClientRect();this.Er.style.top=t.top-r.top+"px",this.Er.style.left=t.left-r.left+"px"}else this.Er.style.top=t.top+window.scrollY+"px",this.Er.style.left=t.left+window.scrollX+"px"}Xr(t,e){if(this.Lr){const r=this.Dr.getBoundingClientRect();this.Er.width=Math.round(r.width),this.Er.height=Math.round(r.height),this.Gr()}else this.Er.width=t??this.Er.width,this.Er.height=e??this.Er.height}Yr(){const t=this.Er.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new F("`textmode.js` requires WebGL2 support.");return t}gt(){const t=this.Er.getContext("webgl")||this.Er.getContext("webgl2");if(t){const e=t.getExtension("WEBGL_lose_context");e==null||e.loseContext()}this.Or&&this.Er.parentNode&&this.Er.parentNode.removeChild(this.Er)}get canvas(){return this.Er}get targetCanvas(){return this.Dr}get width(){return this.Er.width}get height(){return this.Er.height}}function ht(o){return Y(parseInt(o,16),0,255)}class U{constructor(t,e,r,n){l(this,"jr");l(this,"Wr");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=Y(t,0,255),this.g=Y(e,0,255),this.b=Y(r,0,255),this.a=Y(n,0,255),this.jr=[this.r,this.g,this.b,this.a],this.Wr=[this.r/255,this.g/255,this.b/255,this.a/255]}static Kr(t,e,r,n){if(U.Zr(t))return t;if(Array.isArray(t)){if(t.length<3)throw Error("Component tuples must include at least RGB values.");const[h,a,c]=t,u=t.length===4?t[3]:255;return U.qr(h,a,c,u)}if(typeof t=="string"){const h=t.trim();if(h.length===0)throw Error("Color strings cannot be empty.");return U.Vr(h)}if(typeof t=="number")return typeof e=="number"&&typeof r=="number"?U.qr(t,e,r,n??255):U.Jr(t);throw Error("Unsupported color input passed to TextmodeColor.$from.")}static qr(t,e,r,n=255){return new U(t,e,r,n)}static Jr(t,e=255){return new U(t,t,t,e)}static Vr(t){return new U(...function(e){const r=e.replace(/^#|0x/gi,""),n=(h=r).length===3||h.length===4?h.split("").map(a=>a+a).join(""):h;var h;if(n.length!==6&&n.length!==8)throw Error("Invalid hex color: "+e);return[ht(n.slice(0,2)),ht(n.slice(2,4)),ht(n.slice(4,6)),n.length===8?ht(n.slice(6,8)):255]}(t))}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.jr]}get normalized(){return[...this.Wr]}withAlpha(t){return new U(this.r,this.g,this.b,t)}static Zr(t){return t instanceof U}}const yt=new Map;function Bt(o){yt.set(o.id,o)}function Xt(o){return yt.get(o)}class Zt{constructor(t,e,r,n,h,a,c,u){l(this,"A");l(this,"Z");l(this,"tn");l(this,"sn");l(this,"en");l(this,"N");l(this,"X");l(this,"q",null);l(this,"rr");l(this,"rn","brightness");l(this,"nn",null);l(this,"Rt",0);l(this,"Gt",0);l(this,"Qt",0);l(this,"Et",0);l(this,"hn","sampled");l(this,"an","fixed");l(this,"Xt",[1,1,1,1]);l(this,"Yt",[0,0,0,1]);l(this,"cn",[0,0,0,1]);l(this,"ln",[[.1,0,0]]);l(this,"un",null);l(this,"fn",new Set);l(this,"dn",[[0,0,0,0]]);l(this,"vn",0);this.A=t,this.Z=e,this.tn=r,this.rr=n,this.sn=h,this.en=a,this.N=c,this.X=u}conversionMode(t){return this.rn=t,this.nn=null,this.q=null,this}gt(){this.A.deleteTexture(this.tn);for(const t of this.fn)t();this.fn.clear()}pn(t){this.fn.add(t)}invert(t=!0){return this.Rt=t?1:0,this.q=null,this}flipX(t=!0){return this.Gt=t?1:0,this.q=null,this}flipY(t=!0){return this.Qt=t?1:0,this.q=null,this}charRotation(t){return this.Et=Ft(t),this.q=null,this}charColorMode(t){return this.hn=t,this.q=null,this}cellColorMode(t){return this.an=t,this.q=null,this}charColor(t,e,r,n){return this.gn(this.Xt,t,e,r,n),this.q=null,this}cellColor(t,e,r,n){return this.gn(this.Yt,t,e,r,n),this.q=null,this}background(t,e,r,n){return this.gn(this.cn,t,e,r,n),this.q=null,this}colorFilter(t){if(!t||t.length===0)return this.vn=0,this.dn=[[0,0,0,0]],this.q=null,this;const e=[];for(const r of t){if(e.length>=64)break;let n=U.Kr(r);e.push(n.normalized)}return this.dn=e,this.vn=e.length,this.q=null,this}characters(t){return this.un=t,this.mn(t),this.q=null,this}_n(t){this.rr=t,this.un&&this.mn(this.un),this.q=null}get texture(){return this.tn}get width(){return this.N}get height(){return this.X}get originalWidth(){return this.sn}get originalHeight(){return this.en}ut(){return this.q||this.ft(),this.q}yn(){}ft(){this.yn();const t=this.An(),e=this.bn(),r=t.createShader(e),n=t.createUniforms(e);this.q=this.Z.materialManager.Ni(r,n)}gn(t,e,r,n,h){const a=U.Kr(e,r,n,h);it(t,a.r,a.g,a.b,a.a)}mn(t){const e=this.rr.Fr(t).filter(r=>Array.isArray(r)).slice(0,255);this.ln=e.length>0?e:this.ln}createBaseConversionUniforms(){const t=this.vn>0;return{u_image:this.wn(),u_invert:!!this.Rt,u_flipX:!!this.Gt,u_flipY:!!this.Qt,u_charRotation:this.Et,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}}An(){if(this.nn&&this.nn.id===this.rn)return this.nn;const t=Xt(this.rn);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.`);return this.nn=t,t}bn(){return{renderer:this.Z,gl:this.A,font:this.rr,source:this,gridWidth:this.N,gridHeight:this.X}}}class k extends Zt{constructor(t,e,r,n,h,a,c,u){const f=Math.min(c/h,u/a);super(t,e,r,n,h,a,Math.max(1,Math.floor(h*f)),Math.max(1,Math.floor(a*f)))}static Cn(t,e,r,n,h){const a=t.context,c=a.createTexture();a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),tt(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,r),a.bindTexture(a.TEXTURE_2D,null);const u=r.naturalWidth??r.width??r.videoWidth??0,f=r.naturalHeight??r.height??r.videoHeight??0;return new k(a,t,c,e,u,f,n,h)}wn(){return this.tn}}class Ot{constructor(t=60){l(this,"xn");l(this,"Mn",null);l(this,"Fn",0);l(this,"Pn",!0);l(this,"$n",0);l(this,"Tn",0);l(this,"Rn",[]);l(this,"En",10);l(this,"Sn",0);this.xn=1e3/t}kn(t){if(!this.Pn)return;this.Fn=performance.now();const e=r=>{if(!this.Pn)return void(this.Mn=null);const n=r-this.Fn;n>=this.xn&&(t(),this.Fn=r-n%this.xn),this.Pn&&(this.Mn=requestAnimationFrame(e))};this.Mn=requestAnimationFrame(e)}zn(){this.Mn&&(cancelAnimationFrame(this.Mn),this.Mn=null)}Dn(){this.Pn&&(this.Pn=!1,this.zn())}Ln(t){this.Pn||(this.Pn=!0,this.kn(t))}On(t,e){if(t===void 0)return this.$n;this.xn=1e3/t,this.Pn&&e&&(this.zn(),this.kn(e))}In(){const t=performance.now();if(this.Tn>0){const e=t-this.Tn;this.Rn.push(e),this.Rn.length>this.En&&this.Rn.shift();const r=this.Rn.reduce((n,h)=>n+h,0)/this.Rn.length;this.$n=1e3/r}this.Tn=t}get Bn(){return this.Pn}get Hn(){return this.$n}get Gn(){return this.Sn}set Gn(t){this.Sn=t}Qn(){this.Sn++}}class It{constructor(t){l(this,"Er");l(this,"Nn");l(this,"Xn",{x:-1,y:-1});l(this,"Yn",{x:-1,y:-1});l(this,"jn",null);l(this,"Wn",0);l(this,"Kn");l(this,"Zn");l(this,"qn");l(this,"Vn");l(this,"Jn");l(this,"th");l(this,"sh",!1);l(this,"ih");l(this,"eh");l(this,"rh");l(this,"nh");l(this,"hh");this.Er=t}oh(t){const e=performance.now()+Math.max(0,t);e>this.Wn&&(this.Wn=e)}ah(){return performance.now()<this.Wn}uh(t){const e=this.Er.canvas;e.style.cursor=t==null||t===""?"":t}yr(t){this.Nn=t,this.fh()}dh(){if(this.sh)return;const t=this.Er.canvas;this.Kn=e=>{this.ph(e),this.gh(e)},this.Zn=()=>{this.Yn={...this.Xn},this.Xn.x=-1,this.Xn.y=-1,this.jn=null},this.qn=e=>{this.ph(e),this.mh(e)},this.Vn=e=>{this.ph(e),this._h(e)},this.Jn=e=>{this.ph(e),this.yh(e)},this.th=e=>{this.ph(e),this.Ah(e)},t.addEventListener("mousemove",this.Kn,{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.th,{passive:!1}),this.sh=!0}bh(){if(!this.sh)return;const t=this.Er.canvas;t.removeEventListener("mousemove",this.Kn),t.removeEventListener("mouseleave",this.Zn),t.removeEventListener("mousedown",this.qn),t.removeEventListener("mouseup",this.Vn),t.removeEventListener("click",this.Jn),t.removeEventListener("wheel",this.th),this.sh=!1}fh(){if(this.sh)try{if(this.jn){const t=new MouseEvent("mousemove",{clientX:this.jn.x,clientY:this.jn.y,bubbles:!1,cancelable:!1});this.ph(t)}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)}catch{this.Xn.x=-1,this.Xn.y=-1}}wh(t){this.ih=t}Ch(t){this.eh=t}xh(t){this.rh=t}Mh(t){this.nh=t}Fh(t){this.hh=t}Ph(){return{x:this.Xn.x,y:this.Xn.y}}gh(t){if(this.nh&&!this.ah()){const e={position:{...this.Xn},previousPosition:{...this.Yn},originalEvent:t};this.nh(e)}}mh(t){if(this.eh&&!this.ah()){const e={position:{...this.Xn},previousPosition:{...this.Yn},button:t.button,originalEvent:t};this.eh(e)}}_h(t){if(this.rh&&!this.ah()){const e={position:{...this.Xn},previousPosition:{...this.Yn},button:t.button,originalEvent:t};this.rh(e)}}yh(t){if(this.ih&&!this.ah()){const e={position:{...this.Xn},previousPosition:{...this.Yn},button:t.button,originalEvent:t};this.ih(e)}}Ah(t){if(this.hh&&!this.ah()){const e={position:{...this.Xn},previousPosition:{...this.Yn},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.hh(e)}}ph(t){const e=this.Er.canvas;this.Yn={...this.Xn},this.jn={x:t.clientX,y:t.clientY};const r=e.getBoundingClientRect(),n=t.clientX-r.left,h=t.clientY-r.top,a=e.width/r.width,c=h*(e.height/r.height),u=n*a-this.Nn.offsetX,f=c-this.Nn.offsetY,d=Math.floor(u/this.Nn.cellWidth),g=Math.floor(f/this.Nn.cellHeight);d>=0&&d<this.Nn.cols&&g>=0&&g<this.Nn.rows?(this.Xn.x=d,this.Xn.y=g):(this.Xn.x=-1,this.Xn.y=-1)}}const Be=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:It},Symbol.toStringTag,{value:"Module"}));class Yt{constructor(){l(this,"$h",new Map);l(this,"Th",null);l(this,"Rh",null);l(this,"Eh");l(this,"Sh");l(this,"sh",!1);l(this,"kh");l(this,"zh");l(this,"Dh",{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"})}dh(){this.sh||(this.Eh=t=>{this.Lh(t)},this.Sh=t=>{this.Oh(t)},window.addEventListener("keydown",this.Eh,{passive:!1}),window.addEventListener("keyup",this.Sh,{passive:!1}),this.sh=!0)}bh(){this.sh&&(window.removeEventListener("keydown",this.Eh),window.removeEventListener("keyup",this.Sh),this.sh=!1,this.$h.clear(),this.Th=null,this.Rh=null)}Ch(t){this.kh=t}xh(t){this.zh=t}Ih(t){const e=this.Bh(t),r=this.$h.get(t)||this.$h.get(e);return(r==null?void 0:r.isPressed)||!1}Hh(){return this.Th}Gh(){return this.Rh}Qh(){const t=[];for(const[e,r]of this.$h)r.isPressed&&t.push(e);return t}Nh(){return{ctrl:this.Ih("Control"),shift:this.Ih("Shift"),alt:this.Ih("Alt"),meta:this.Ih("Meta")}}Xh(){this.$h.clear(),this.Th=null,this.Rh=null}Lh(t){const e=t.key,r=Date.now();this.$h.has(e)||this.$h.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.$h.get(e);if(!n.isPressed&&(n.isPressed=!0,n.lastPressTime=r,this.Th=e,this.kh)){const h={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.kh(h)}}Oh(t){const e=t.key,r=Date.now();this.$h.has(e)||this.$h.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.$h.get(e);if(n.isPressed=!1,n.lastReleaseTime=r,this.Rh=e,this.zh){const h={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.zh(h)}}Bh(t){return this.Dh[t]||t.toLowerCase()}}const Xe=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:Yt},Symbol.toStringTag,{value:"Module"}));class zt{constructor(t,e){l(this,"Er");l(this,"Yh");l(this,"Nn");l(this,"jh",new Map);l(this,"Wh",new Map);l(this,"Kh",new Map);l(this,"Zh",null);l(this,"qh");l(this,"Vh");l(this,"Jh");l(this,"so");l(this,"io");l(this,"eo");l(this,"sh",!1);l(this,"ro");l(this,"no");l(this,"ho");l(this,"oo");l(this,"ao");l(this,"co");l(this,"lo");l(this,"uo");l(this,"fo");l(this,"do");l(this,"vo",320);l(this,"po",350);l(this,"mo",10);l(this,"_o",550);l(this,"yo",14);l(this,"Ao",48);l(this,"bo",650);l(this,"wo",.02);l(this,"Co",2);l(this,"xo",600);l(this,"Mo",0);l(this,"Fo",null);this.Er=t,this.Yh=e;const r=this.Er.canvas;this.qh=r.style.touchAction,this.Vh=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}yr(t){this.Nn=t,this.fh()}dh(){if(this.sh)return;const t=this.Er.canvas;this.Jh=e=>{this.Po(e)},this.so=e=>{this.$o(e)},this.io=e=>{this.To(e)},this.eo=e=>{this.Ro(e)},t.addEventListener("touchstart",this.Jh,{passive:!1}),t.addEventListener("touchmove",this.so,{passive:!1}),t.addEventListener("touchend",this.io,{passive:!1}),t.addEventListener("touchcancel",this.eo,{passive:!1}),this.sh=!0}bh(){if(!this.sh)return;const t=this.Er.canvas;t.removeEventListener("touchstart",this.Jh),t.removeEventListener("touchmove",this.so),t.removeEventListener("touchend",this.io),t.removeEventListener("touchcancel",this.eo),this.sh=!1,this.Zh=null,this.jh.clear(),this.Wh.clear(),this.Kh.forEach(e=>{e.longPressTimer!==null&&window.clearTimeout(e.longPressTimer)}),this.Kh.clear(),this.Fo=null,this.Mo=0,t.style.touchAction=this.qh,t.style.userSelect=this.Vh}fh(){if(!this.Nn||this.jh.size===0)return;const t=new Map;for(const e of this.jh.values()){const r=this.Eo(e.clientX,e.clientY,e.id,e);t.set(e.id,r)}this.jh=t}So(){return Array.from(this.jh.values()).map(t=>({...t}))}ko(t){this.ro=t}Mh(t){this.no=t}zo(t){this.ho=t}Do(t){this.oo=t}Lo(t){this.ao=t}Oo(t){this.co=t}Io(t){this.lo=t}Bo(t){this.uo=t}Ho(t){this.fo=t}Go(t){this.do=t}Po(t){var n;if(!this.Nn)return;t.preventDefault(),(n=this.Yh)==null||n.oh(this.xo);const e=performance.now(),r=this.Qo(t.changedTouches);for(const h of r){const a=this.jh.get(h.id);a&&this.Wh.set(h.id,this.No(a)),this.jh.set(h.id,h);const c={id:h.id,startPosition:h,lastPosition:h,startTime:e,lastTime:e,longPressTimer:null,longPressFired:!1};this.lo&&(c.longPressTimer=window.setTimeout(()=>{const u=this.jh.get(h.id);u&&(c.longPressFired=!0,this.lo({touch:this.No(u),duration:performance.now()-c.startTime,originalEvent:t}))},this._o)),this.Kh.set(h.id,c),this.ro&&this.ro(this.Xo(h,t,void 0,e))}this.jh.size===2&&this.Yo()}$o(t){var n;if(!this.Nn)return;t.preventDefault(),(n=this.Yh)==null||n.oh(this.xo);const e=performance.now(),r=this.Qo(t.changedTouches);for(const h of r){const a=this.jh.get(h.id),c=a?this.No(a):void 0;c&&this.Wh.set(h.id,c),this.jh.set(h.id,h);const u=this.Kh.get(h.id);u&&(u.lastPosition=h,u.lastTime=e,c)&&W(c.clientX,c.clientY,h.clientX,h.clientY)>this.yo&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.no&&this.no(this.Xo(h,t,c,e))}this.jh.size===2?this.jo(t):this.Zh=null}To(t){if(!this.Nn)return;t.preventDefault();const e=performance.now(),r=this.Qo(t.changedTouches);for(const n of r){const h=this.jh.get(n.id),a=h?this.No(h):void 0,c=this.Kh.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.ho&&this.ho(this.Xo(n,t,a,e)),c&&this.Wo(c,t),this.Kh.delete(n.id),this.Wh.delete(n.id),this.jh.delete(n.id)}this.jh.size<2&&(this.Zh=null)}Ro(t){if(!this.Nn)return;t.preventDefault();const e=performance.now(),r=this.Qo(t.changedTouches);for(const n of r){const h=this.jh.get(n.id),a=h?this.No(h):void 0,c=this.Kh.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.oo&&this.oo(this.Xo(n,t,a,e)),this.Kh.delete(n.id),this.Wh.delete(n.id),this.jh.delete(n.id)}this.jh.size<2&&(this.Zh=null)}Qo(t){const e=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&e.push(this.Ko(n))}return e}Ko(t){return this.Eo(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})}Eo(t,e,r,n){const h=this.Er.canvas,a=h.getBoundingClientRect(),c=t-a.left,u=e-a.top,f=h.width/a.width,d=u*(h.height/a.height),g=c*f-this.Nn.offsetX,v=d-this.Nn.offsetY,m=Math.floor(g/this.Nn.cellWidth),A=Math.floor(v/this.Nn.cellHeight),p=m>=0&&m<this.Nn.cols&&A>=0&&A<this.Nn.rows;return{id:r,x:p?m:-1,y:p?A:-1,clientX:t,clientY:e,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Xo(t,e,r,n){const h=this.Kh.get(t.id),a=Array.from(this.Wh.values()).map(f=>this.No(f)),c=Array.from(this.jh.values()).map(f=>this.No(f)),u=this.Qo(e.changedTouches);return{touch:this.No(t),previousTouch:r?this.No(r):void 0,touches:c,previousTouches:a,changedTouches:u,deltaTime:h?n-h.lastTime:0,originalEvent:e}}Yo(){if(this.jh.size!==2)return void(this.Zh=null);const t=Array.from(this.jh.values()),[e,r]=t,n=W(e.x,e.y,r.x,r.y),h=Tt(e.clientX,e.clientY,r.clientX,r.clientY);this.Zh={ids:[e.id,r.id],initialDistance:Math.max(n,1e-4),initialAngle:h,lastScale:1,lastRotation:0}}jo(t){if(this.Zh||this.Yo(),!this.Zh)return;const[e,r]=this.Zh.ids,n=this.jh.get(e),h=this.jh.get(r);if(!n||!h)return;const a=W(n.x,n.y,h.x,h.y)/this.Zh.initialDistance,c=a-this.Zh.lastScale;this.fo&&Math.abs(c)>this.wo&&(this.fo({touches:[this.No(n),this.No(h)],scale:a,deltaScale:c,center:this.Zo(n,h),originalEvent:t}),this.Zh.lastScale=a);let u=Tt(n.clientX,n.clientY,h.clientX,h.clientY)-this.Zh.initialAngle;u=(u+180)%360-180;const f=u-this.Zh.lastRotation;this.do&&Math.abs(f)>this.Co&&(this.do({touches:[this.No(n),this.No(h)],rotation:u,deltaRotation:f,center:this.Zo(n,h),originalEvent:t}),this.Zh.lastRotation=u)}Zo(t,e){const r=(t.clientX+e.clientX)/2,n=(t.clientY+e.clientY)/2,h=this.Eo(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:h.x,y:h.y}}Wo(t,e){const r=performance.now(),n=r-t.startTime,h=W(t.startPosition.clientX,t.startPosition.clientY,t.lastPosition.clientX,t.lastPosition.clientY);if(!t.longPressFired&&n<=this.vo&&h<=this.mo)this.qo(t.lastPosition,r)&&this.co?this.co({touch:this.No(t.lastPosition),taps:2,originalEvent:e}):this.ao&&this.ao({touch:this.No(t.lastPosition),taps:1,originalEvent:e});else if(!t.longPressFired&&n<=this.bo&&h>=this.Ao){const a={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},f={x:a.x/n,y:a.y/n};this.uo&&this.uo({touch:this.No(t.lastPosition),direction:u,distance:c,velocity:f,originalEvent:e})}this.Mo=r,this.Fo=this.No(t.lastPosition)}qo(t,e){return!!this.Fo&&!(e-this.Mo>this.po)&&W(t.clientX,t.clientY,this.Fo.clientX,this.Fo.clientY)<=this.mo}No(t){return{...t}}}const Ze=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:zt},Symbol.toStringTag,{value:"Module"}));class Oe{constructor(t,e){l(this,"A");l(this,"Vo");l(this,"$n",null);l(this,"Jo",0);l(this,"ta",!1);l(this,"sa",[]);l(this,"ia",-1);this.A=t,this.Vo=e}get isPreloaded(){return this.ta}get totalFrames(){return this.Jo}get frameRate(){return this.$n}get textures(){return this.sa}dispose(){this.ea(),this.sa=[],this.$n=null,this.Jo=0,this.ta=!1,this.ia=-1}async preload(t,e){var r;try{if(t<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Vo.duration;if(!isFinite(n)||n<=0)throw Error("Video duration is invalid, cannot preload frames.");const h=Math.max(1,Math.ceil(n*t));return this.ra(t,h),await this.na(t,e)?(this.ha("captureStream",e),"captureStream"):(await this.oa(t,e),this.ha("seeking",e),"seeking")}catch(n){const h=n instanceof Error?n:Error(n+"");throw(r=e==null?void 0:e.onError)==null||r.call(e,h),this.dispose(),h}}ra(t,e){this.ea(),this.$n=t,this.Jo=e,this.sa=[],this.ta=!1,this.ia=-1}ha(t,e){var r;if(this.sa.length===0)throw Error(`Video preload via ${t} completed but produced 0 frames.`);this.Jo=this.sa.length,this.ta=!0,this.ia=-1,this.Vo.pause(),this.Vo.currentTime=0,e!=null&&e.onProgress&&e.onProgress({percent:100,loadedFrames:this.Jo,totalFrames:this.Jo,strategy:t}),(r=e==null?void 0:e.onComplete)==null||r.call(e,{totalFrames:this.Jo,strategy:t})}aa(t){const e=this.A,r=e.createTexture();return e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),tt(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),r}ca(t,e){if(!(e!=null&&e.onProgress)||this.Jo===0)return;const r=Math.min(99,Math.floor(this.sa.length/this.Jo*100)),n=10*Math.floor(r/10);n>this.ia&&(this.ia=n,e.onProgress({percent:r,loadedFrames:this.sa.length,totalFrames:this.Jo,strategy:t}))}async na(t,e){const r=globalThis,n=r==null?void 0:r.MediaStreamTrackProcessor,h=this.Vo.captureStream;if(typeof n!="function"||typeof h!="function")return!1;let a,c=null;try{const u=h.call(this.Vo);if(a=u.getVideoTracks()[0],!a)return u.getTracks().forEach(g=>g.stop()),!1;if(c=new n({track:a}).readable.getReader(),this.Vo.currentTime=0,this.Vo.muted=!0,await this.Vo.play().catch(()=>{}),this.Vo.paused)return!1;const f=1e6/t;let d=0;for(;this.sa.length<this.Jo;){const g=await c.read();if(g.done)break;const v=g.value;if(v)try{const m=typeof v.timestamp=="number"?v.timestamp:d;(this.sa.length===0||m>=d)&&(this.sa.push(this.aa(v)),d=m+f,this.ca("captureStream",e))}finally{v.close()}}return c.releaseLock(),a.stop(),c=null,a=void 0,this.Vo.pause(),this.Vo.currentTime=0,this.sa.length!==0}catch{return this.ea(),this.sa=[],this.ia=-1,!1}finally{if(c)try{await c.cancel()}catch{}a&&a.stop(),this.Vo.pause(),this.Vo.currentTime=0}}async oa(t,e){const r=1/t,n=this.Jo,h=this.Vo;h.pause();for(let a=0;a<n;a++){const c=Math.min(h.duration,a*r);await this.la(c),this.sa.push(this.aa(h)),this.ca("seeking",e)}h.currentTime=0}la(t){return new Promise((e,r)=>{const n=this.Vo,h=()=>{n.removeEventListener("seeked",a),n.removeEventListener("error",c)},a=()=>{h(),e()},c=()=>{h(),r(Error("Video seek failed while preloading frames."))};n.addEventListener("seeked",a,{once:!0}),n.addEventListener("error",c,{once:!0});const u=isFinite(n.duration)?n.duration:t,f=Math.min(Math.max(t,0),u);if(Math.abs(n.currentTime-f)<1e-4)return h(),void e();n.currentTime=f})}ea(){for(const t of this.sa)this.A.deleteTexture(t)}}class ot extends Zt{constructor(e,r,n,h,a,c,u,f,d){const g=c/u;let v,m;g>1?(v=f,m=Math.round(f/g)):(m=d,v=Math.round(d*g));super(e,r,n,h,c,u,v,m);l(this,"Vo");l(this,"ua",0);l(this,"fa",null);this.Vo=a}gt(){var e;super.gt(),(e=this.fa)==null||e.dispose(),this.fa=null,this.Vo.pause(),this.Vo.src="",this.Vo.load()}da(){var e;if(!((e=this.fa)!=null&&e.isPreloaded)&&this.Vo.readyState>=this.Vo.HAVE_CURRENT_DATA){const r=this.A;r.bindTexture(r.TEXTURE_2D,this.tn),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.Vo),r.bindTexture(r.TEXTURE_2D,null)}}wn(){var r,n;const e=(r=this.fa)==null?void 0:r.textures;return e&&e.length>0&&((n=this.fa)!=null&&n.isPreloaded)?e[this.ua%e.length]:this.tn}ut(){return this.q=null,super.ut()}yn(){this.da()}frame(e){var n,h;const r=((n=this.fa)==null?void 0:n.totalFrames)??0;return(h=this.fa)!=null&&h.isPreloaded&&e!==void 0&&r>0&&(this.ua=(e%r+r)%r,this.q=null),this}static async Cn(e,r,n,h,a,c){const u=e.context,f=c==null?void 0:c.frameRate;let d;d=document.createElement("video"),d.crossOrigin="anonymous",d.loop=!0,d.muted=!0,d.playsInline=!0,await new Promise((p,y)=>{d.addEventListener("loadedmetadata",()=>p(),{once:!0}),d.addEventListener("error",E=>{var x;const w=E.target;y(Error("Failed to load video: "+(((x=w.error)==null?void 0:x.message)||"Unknown error")))},{once:!0}),d.src=n});const g=u.createTexture();u.bindTexture(u.TEXTURE_2D,g),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),tt(u,u.LINEAR,u.LINEAR,u.CLAMP_TO_EDGE,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,d),u.bindTexture(u.TEXTURE_2D,null);const v=d.videoWidth,m=d.videoHeight,A=new ot(u,e,g,r,d,v,m,h,a);return f&&f>0&&(A.fa=new Oe(u,d),await A.fa.preload(f,c),A.ua=0),A}async play(){await this.Vo.play()}pause(){this.Vo.pause()}stop(){this.Vo.pause(),this.Vo.currentTime=0}speed(e){return this.Vo.playbackRate=e,this}loop(e=!0){return this.Vo.loop=e,this}time(e){return this.Vo.currentTime=e,this}volume(e){return this.Vo.volume=Math.max(0,Math.min(1,e)),this}get texture(){return this.tn}get width(){return this.N}get height(){return this.X}get originalWidth(){return this.sn}get originalHeight(){return this.en}get videoElement(){return this.Vo}get currentTime(){return this.Vo.currentTime}get duration(){return this.Vo.duration}get isPlaying(){return!this.Vo.paused&&!this.Vo.ended}get totalFrames(){var e;return((e=this.fa)==null?void 0:e.totalFrames)??0}}const Ie=o=>class extends o{va(t,e,r,n){if(U.Zr(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,e,r,n);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,e=0,r=0){this.Z.state.Vt(t),this.Z.state.Jt(e),this.Z.state.ts(r)}rotateX(t){this.Z.state.Vt(t)}rotateY(t){this.Z.state.Jt(t)}rotateZ(t){this.Z.state.ts(t)}translate(t=0,e=0,r=0){this.Z.state.ss(t,e,r)}translateX(t){this.Z.state.ss(t,0,0)}translateY(t){this.Z.state.ss(0,t,0)}translateZ(t){this.Z.state.ss(0,0,t)}push(){this.Z.state.ht()}pop(){this.Z.state.ot()}color(t,e,r,n){return U.Kr(t,e,r,n)}rect(t=1,e=1){this.Z.be(t,e)}point(){this.Z.be(1,1)}line(t,e,r,n){this.Z.we(t,e,r,n)}lineWeight(t){this.Z.state.Zt(t)}background(t,e,r,n=255){const h=this.va(t,e,r,n);this.Z.$e(h.r,h.g,h.b,h.a)}char(t){const e=Array.from(t);if(e.length===0)throw Error("char() requires at least one character.");this.Z.state.hs(this.rr.Mr(e[0]))}charColor(t,e,r,n){const h=this.va(t,e,r,n);this.Z.state.cs(h.r,h.g,h.b,h.a)}cellColor(t,e,r,n){const h=this.va(t,e,r,n);this.Z.state.ls(h.r,h.g,h.b,h.a)}flipX(t){this.Z.state.us(t)}flipY(t){this.Z.state.fs(t)}charRotation(t){this.Z.state.vs(t)}invert(t){this.Z.state.ds(t)}clear(){this.Z.bi(0,0,0,0)}ellipse(t,e){this.Z.Ce(t/2,e/2)}triangle(t,e,r,n,h,a){this.Z.xe(t,e,r,n,h,a)}bezierCurve(t,e,r,n,h,a,c,u){this.Z.Me(t,e,r,n,h,a,c,u)}arc(t,e,r,n){this.Z.Fe(t/2,e/2,r,n)}shader(t){this.Z.ge(t)}setUniform(t,e){this.Z.I(t,e)}setUniforms(t){this.Z.me(t)}async createFilterShader(t){if(typeof t=="string"&&(t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const e=await fetch(t);if(!e.ok)throw Error(`Failed to load shader from ${t}: ${e.statusText}`);const r=await e.text();return this.Z._e(r)}return this.Z._e(t)}createFramebuffer(t){return this.Z.Pe(t.width??this.grid.cols,t.height??this.grid.rows,t.attachments??3)}image(t,e,r){this.Z.ye(t,e,r),t instanceof z&&this.Z.ct()}ortho(){this.Z.state.gs(!0)}async loadImage(t){if(typeof t!="string"){const h=k.Cn(this.Z,this.rr,t,this.Nn.cols,this.Nn.rows);return this.pa(h),h}const e=t,r=await new Promise((h,a)=>{const c=new Image;c.crossOrigin="anonymous",c.onload=()=>h(c),c.onerror=u=>a(u),c.src=e}),n=k.Cn(this.Z,this.rr,r,this.Nn.cols,this.Nn.rows);return this.pa(n),n}async loadVideo(t,e){const r=await ot.Cn(this.Z,this.rr,t,this.Nn.cols,this.Nn.rows,e);return this.pa(r),r}},Ye=o=>class extends o{async loadFont(t){return this.rr.Cr(t).then(()=>{const e=this.rr.maxGlyphDimensions;this.Nn.zr(e.width,e.height),this.ga.resize(this.Nn.cols,this.Nn.rows),this.ma.Xr(),this.Z.Re(),this.Yh.fh(),this._a.fh();for(const r of this.ya)r._n(this.rr)})}fontSize(t){if(!ut.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;this.rr.wr(t);const e=this.rr.maxGlyphDimensions;this.Nn.zr(e.width,e.height),this.ga.resize(this.Nn.cols,this.Nn.rows),this.ma.Xr(),this.Z.Re(),this.Yh.fh(),this._a.fh()}},ze=o=>class extends o{get frameCount(){return this.ba.Gn}set frameCount(t){this.ba.Gn=t}frameRate(t){return t===void 0?this.ba.Hn:this.ba.On(t,()=>this.wa())}noLoop(){this.ba.Dn()}loop(){this.ba.Ln(()=>this.wa())}redraw(t=1){if(ut.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()}isLooping(){return this.ba.Bn}},Ge=o=>class extends o{constructor(...t){super(...t)}mouseClicked(t){this.Yh.wh(t)}mousePressed(t){this.Yh.Ch(t)}mouseReleased(t){this.Yh.xh(t)}mouseMoved(t){this.Yh.Mh(t)}mouseScrolled(t){this.Yh.Fh(t)}get mouse(){return this.Yh.Ph()}cursor(t){this.Yh.uh(t)}},Ve=o=>class extends o{constructor(...t){super(...t)}touchStarted(t){this._a.ko(t)}touchMoved(t){this._a.Mh(t)}touchEnded(t){this._a.zo(t)}touchCancelled(t){this._a.Do(t)}tap(t){this._a.Lo(t)}doubleTap(t){this._a.Oo(t)}longPress(t){this._a.Io(t)}swipe(t){this._a.Bo(t)}pinch(t){this._a.Ho(t)}rotateGesture(t){this._a.Go(t)}get touches(){return this._a.So()}},ke=o=>class extends o{constructor(...t){super(...t)}keyPressed(t){this.Ca.Ch(t)}keyReleased(t){this.Ca.xh(t)}isKeyPressed(t){return this.Ca.Ih(t)}get lastKeyPressed(){return this.Ca.Hh()}get lastKeyReleased(){return this.Ca.Gh()}get pressedKeys(){return this.Ca.Qh()}get modifierState(){return this.Ca.Nh()}};class He{constructor(t){l(this,"xa");l(this,"Ma",new Map);l(this,"Fa",[]);l(this,"Pa",new Map);l(this,"$a",new Map);this.xa=t}async Ta(t){for(const e of t){if(this.Ma.has(e.name))return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);const r=this.Ra(e.name);try{await e.install(this.xa,r)}catch(n){throw this.Ea(e.name),n}this.Ma.set(e.name,e),this.Fa.push(e.name)}}async Sa(t){const e=this.Ma.get(t);if(!e)return;const r=this.Ra(t);e.uninstall&&await e.uninstall(this.xa,r),this.Ma.delete(t),this.Fa.splice(this.Fa.indexOf(t),1),this.Ea(t)}ka(){this.za(this.Pa)}Da(){this.za(this.$a)}async La(){const t=[...this.Ma.keys()];for(const e of t)await this.Sa(e)}Ra(t){return{renderer:this.xa.Z,font:this.xa.rr,grid:this.xa.Nn,canvas:this.xa.Er,drawFramebuffer:this.xa.ga,asciiFramebuffer:this.xa.Oa,registerPreDrawHook:e=>this.Ia(this.Pa,t,e),registerPostDrawHook:e=>this.Ia(this.$a,t,e)}}Ia(t,e,r){const n=t.get(e)??new Set;return n.add(r),t.set(e,n),()=>{const h=t.get(e);h&&(h.delete(r),h.size===0&&t.delete(e))}}Ea(t){this.Pa.delete(t),this.$a.delete(t)}za(t){for(const e of this.Fa){const r=t.get(e);r&&r.forEach(n=>n())}}}const $=`#version 300 es
|
|
11
|
-
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`,
|
|
12
|
-
precision highp float;uniform sampler2D u_texture;in vec2 v_uv;out vec4 fragColor;void main(){fragColor=texture(u_texture,v_uv);}`;class Vt{constructor(){l(this,"Ba",new Map);l(this,"Ha",[]);l(this,"Ga",0);l(this,"Qa",0);l(this,"Na")}get Xa(){return this.Ga}get Ya(){if(this.Ga===0)return 0;let t=0;for(const e of this.Ha){const r=this.Ba.get(e);r&&(t+=Math.min(1,Math.max(0,r.progress))*r.weight)}return Math.min(1,t/this.Ga)}ja(t){this.Na=t}Wa(t,e=1){const r=`phase-${this.Ha.length+1}-${Date.now()}`,n={id:r,label:t,weight:Math.max(.001,e),progress:0,status:"running"};return this.Ba.set(r,n),this.Ha.push(r),this.Ga+=n.weight,r}Ka(t,e){const r=this.Ba.get(t);if(!r)return;r.progress=Math.max(0,Math.min(1,e)),r.status=r.progress>=1?"complete":"running";const n=this.Ya;Math.abs(n-this.Qa)>.001&&(this.Qa=n,this.Na&&this.Na(n))}Za(t){const e=this.Ba.get(t);e&&(e.progress=1,e.status="complete",this.Ka(t,1))}qa(t){const e=this.Ba.get(t);e&&(e.status="failed")}Va(){return this.Ha.map(t=>{const e=this.Ba.get(t);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"}})}}class kt{constructor(t="active"){l(this,"Ja");l(this,"tc","");l(this,"sc","");this.Ja=t}get ec(){return this.Ja}get rc(){return this.Ja!=="disabled"}get nc(){return this.Ja==="active"||this.Ja==="transitioning"||this.Ja==="error"}get hc(){return this.tc}get oc(){return this.sc}ac(){this.Ja!=="done"&&this.Ja!=="transitioning"||(this.Ja="active")}cc(){this.Ja!=="disabled"&&(this.Ja="done")}lc(){this.Ja!=="disabled"&&(this.Ja="transitioning")}uc(){this.Ja==="transitioning"&&(this.Ja="done")}fc(t){this.Ja!=="disabled"&&(this.Ja="error",t instanceof Error?(this.tc=t.message,this.sc=t.stack||""):(this.tc=t,this.sc=""))}dc(){this.Ja="disabled"}}class Ht{constructor(t,e){l(this,"vc",0);l(this,"gc",1);l(this,"mc");l(this,"_c");this.mc=t,this._c=e}get yc(){return this.gc}get bc(){return this.gc<1}kn(){this.mc!=="none"&&this._c>0&&(this.vc=performance.now())}et(){if(this.mc==="none"||this._c===0)return this.gc=1,!1;const t=performance.now()-this.vc,e=Math.min(1,t/this._c);return e>=1?(this.gc=0,!0):(this.gc=1-e,!1)}ti(){this.gc=1,this.vc=0}}function xt(o,t){const e=o.tone??"auto";let r="dark";return e==="light"||e==="dark"?r=e:t&&(r=function(n){if(!n)return 0;const[h,a,c]=n.map(f=>f/255),u=f=>f<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4);return .2126*u(h)+.7152*u(a)+.0722*u(c)}(t)>.5?"light":"dark"),{mode:r,background:t,textColor:r==="light"?"#1A1A1A":"#F8F8F8",subtleColor:r==="light"?"#4A4A4A":"#C0C0C0"}}function jt(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function Wt(o,t){return o.length?o.map(e=>t.color(e)):[t.color("#FFFFFF")]}const je=({textmodifier:o,grid:t,progress:e,frameCount:r,message:n,palette:h,theme:a,phases:c,transitionOpacity:u,isError:f,errorMessage:d})=>{const g="|/-\\",v=Math.floor(r/6)%4,m=o.color(a.textColor),A=Math.floor(255*u),p=o.color(m.r,m.g,m.b,A);if(o.charColor(p),o.cellColor(0,0,0,0),f){const y=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",A);o.charColor(y),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const E="SETUP ERROR",w=-Math.floor(E.length/2);o.push(),o.translate(w,0,0);for(const x of E)o.char(x),o.rect(1,1),o.translateX(1);if(o.pop(),d){const x=o.color(a.subtleColor),P=o.color(x.r,x.g,x.b,A);o.charColor(P);const b=Math.floor(.8*t.cols),N=d.split(" "),L=[];let M="";for(const D of N)(M+" "+D).length<=b?M=M?M+" "+D:D:(M&&L.push(M),M=D);M&&L.push(M);const B=L.slice(0,3);L.length>3&&(B[2]=B[2].substring(0,b-3)+"..."),B.forEach((D,ct)=>{const ni=-Math.floor(D.length/2);o.push(),o.translate(ni,3+ct,0);for(const hi of D)o.char(hi),o.rect(1,1),o.translateX(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(g[v]),o.rect(1,1),o.pop(),e>0||c.some(y=>y.status!=="pending")){const y=Math.max(6,Math.floor(.6*t.cols)),E=-Math.floor(y/2),w=Math.floor(y*e),x=h.length?h:[o.color("#FFFFFF")];o.push(),o.translate(E,3,0);for(let P=0;P<y;P++){const b=P<w?"*":".",N=x[P%x.length],L=o.color(N.r,N.g,N.b,A);o.charColor(L),o.char(b),o.rect(1,1),o.translateX(1)}o.pop()}if(n){const y=o.color(a.subtleColor),E=o.color(y.r,y.g,y.b,A);o.charColor(E);const w=-Math.floor(n.length/2);o.push(),o.translate(w,5,0);for(const x of n)o.char(x),o.rect(1,1),o.translateX(1);o.pop()}},We={message:"LOADING...",tone:"auto",transition:"fade",transitionDuration:500};class Ke{constructor(t,e,r){this.wc=t,this.id=e,this.label=r}report(t){this.wc.Ka(this.id,t)}complete(){this.wc.Za(this.id)}fail(t){this.wc.qa(this.id)}async track(t){try{const e=typeof t=="function"?await t():await t;return this.complete(),e}catch(e){throw this.fail(),e}}}class Kt{constructor(t,e,r){l(this,"xa");l(this,"l");l(this,"Cc");l(this,"wc");l(this,"xc");l(this,"Mc");l(this,"Fc");l(this,"Pc");l(this,"$c");l(this,"Tc");l(this,"Z");l(this,"Rc",[]);l(this,"Ec");l(this,"Sc",performance.now());l(this,"kc",0);l(this,"zc",!1);l(this,"Dc",!1);l(this,"Bc");this.xa=t,this.l={...We,...e??{}},this.Cc=new kt("active"),this.wc=new Vt,this.xc=new Ht(this.l.transition,this.l.transitionDuration),this.Mc=new Ot(60),this.Ec=xt(this.l,r);const n=jt(this.Ec);this.Rc=Wt(n,this.xa),this.Z=this.Lc(),this.wc.ja(h=>{h>=.999&&this.cc()})}async yr(t){if(this.Dc)return;const e=this.xa.Z,r=this.xa.Er;this.Fc=new pt(e,16),await this.Fc.yr(t);const n=this.Fc.maxGlyphDimensions;this.Pc=new At(r.canvas,n.width,n.height),this.$c=e.Pe(this.Pc.cols,this.Pc.rows,3),this.Tc=e.Pe(this.Pc.width,this.Pc.height,1),this.Dc=!0}get nc(){return this.Cc.nc&&this.zc}kn(){this.zc||(this.zc=!0,this.Sc=performance.now(),this.kc=0,this.Mc.kn(()=>this.Oc()))}zn(){this.zc&&(this.zc=!1,this.Mc.zn())}Xr(){this.Dc&&(this.Pc.ti(),this.$c.resize(this.Pc.cols,this.Pc.rows),this.Tc.resize(this.Pc.width,this.Pc.height))}gt(){this.zn(),this.Dc&&(this.Fc.gt(),this.$c.gt(),this.Tc.gt(),this.Dc=!1)}get progress(){return this.wc.Ya}message(t){return typeof t=="string"&&(this.l.message=t),this.l.message}addPhase(t,e=1){this.Cc.ac();const r=this.wc.Wa(t,e);return new Ke(this.wc,r,t)}cc(){this.l.transition!=="none"&&this.l.transitionDuration>0?(this.Cc.lc(),this.xc.kn()):(this.Cc.cc(),this.zn(),this.Ic())}Ic(){this.Bc&&this.Bc()}Hc(t){this.Bc=t}error(t){this.Cc.fc(t)}Oc(){if(this.Cc.nc){if(this.kc++,this.Cc.ec==="transitioning"&&this.xc.et())return this.Cc.uc(),this.Ic(),void this.zn();this.Gc()}}Gc(){if(!this.Dc)return;const t=this.$c,e=this.Fc,r=this.Pc,n=this.Tc,h=this.xa.Z,a=this.xa.Er,c=this.xa.Qc,u=this.xa.Nc;h.state.qt(),t.begin(),this.xa.clear(),this.xa.push();try{const f={textmodifier:this.xa,grid:r,progress:this.progress,elapsedMs:performance.now()-this.Sc,frameCount:this.kc,message:this.l.message,palette:this.Rc,theme:this.Ec,phases:this.wc.Va(),transitionOpacity:this.xc.yc,isError:this.Cc.ec==="error",errorMessage:this.Cc.hc||void 0,errorDetails:this.Cc.oc||void 0};this.Z(f)}finally{this.xa.pop()}t.end(),n.begin(),h.ve(c),c.O({u_characterTexture:e.fontFramebuffer,u_charsetDimensions:[e.textureColumns,e.textureRows],Ud:t.textures[0],Ue:t.textures[1],Uf:t.textures[2],Ug:[r.cols,r.rows],Uh:[n.width,n.height],Ui:h.state.canvasBackgroundColor}),h.Ae(0,0,a.width,a.height),n.end(),h.bi(...h.state.canvasBackgroundColor),h.ve(u),u.O({u_texture:n.textures[0]}),h.Ae(r.offsetX,r.offsetY,r.width,r.height)}Xc(t){this.Ec=xt(this.l,t)}Lc(){const t=this.l.renderer||je;return e=>{t(e),this.Yc(e)}}Yc(t){const{textmodifier:e,grid:r,frameCount:n,theme:h,transitionOpacity:a}=t,c=[116,101,120,116,109,111,100,101,46,106,115].map(g=>String.fromCharCode(g)).join(""),u=(r.rows+1>>1)-2,f=2-(r.cols+1>>1),d=h.mode==="light"?[[233,30,99],[156,39,176],[255,111,0]]:[[142,249,243],[241,91,181],[255,155,113]];e.push(),e.translate(f,u,0);for(let g=0;g<c.length;g++){const v=c[g],m=Math.floor(.1*n+.5*g)%d.length,[A,p,y]=d[m],E=Math.floor(255*a),w=e.color(A,p,y,E);e.charColor(w),e.char(v),e.point(),e.translateX(1)}e.pop()}}class wt{constructor(t={}){l(this,"jc");l(this,"yc");l(this,"Wc");l(this,"Kc");l(this,"Zc");l(this,"qc");l(this,"Vc");l(this,"Jc");l(this,"tl");l(this,"sl");l(this,"il",null);l(this,"el",!1);l(this,"rl",!0);l(this,"nl",[]);this.jc=t.visible??!0,this.yc=Math.min(1,Math.max(0,t.opacity??1)),this.Wc=t.blendMode??"normal",this.Kc=Math.round(t.offsetX??0),this.Zc=Math.round(t.offsetY??0),this.qc=t.rotation??0}hl(){return this.il!==null}ol(){const t=this.nl;return this.nl=[],t}al(t){this.il&&this.il.call(t)}draw(t){this.il=t}show(){this.jc=!0}hide(){this.jc=!1}opacity(t){if(t===void 0)return this.yc;this.yc=Math.min(1,Math.max(0,t))}blendMode(t){if(t===void 0)return this.Wc;this.Wc=t}offset(t,e=0){if(t===void 0)return{x:this.Kc,y:this.Zc};this.Kc=Math.round(t),this.Zc=Math.round(e)}rotateZ(t){if(t===void 0)return this.qc;this.qc=t}filter(t,e){this.nl.push({name:t,params:e})}cl(t){this.Vc=t,this.ll(t.grid)}wa(t,e){if(!this.jc||!this.il)return void(this.el=!1);const r=this.Vc.renderer;this.nl=[],this.Jc.begin(),r.state.qt(),this.il.call(t),this.Jc.end();const n=this.nl.length>0,h=n?this.sl:this.tl;h.begin(),r.bi(0,0,0,0),r.ve(e),e.O({u_characterTexture:this.Vc.font.fontFramebuffer,u_charsetDimensions:[this.Vc.font.textureColumns,this.Vc.font.textureRows],Ud:this.Jc.textures[0],Ue:this.Jc.textures[1],Uf:this.Jc.textures[2],Ug:[this.Vc.grid.cols,this.Vc.grid.rows],Uh:[h.width,h.height],Ui:[0,0,0,0]}),r.Ae(0,0,this.Vc.grid.width,this.Vc.grid.height),h.end(),n&&this.Vc.filterManager.ul(this.sl.textures[0],this.tl,this.nl,this.tl.width,this.tl.height,this.Vc.layerPingPongBuffers),this.el=!0}Xr(t){var e;this.Vc&&(this.Vc={...this.Vc,grid:t}),this.Jc&&this.tl&&(this.Jc.resize(t.cols,t.rows),this.tl.resize(t.width,t.height),(e=this.sl)==null||e.resize(t.width,t.height))}gt(){var t,e,r;this.rl&&((t=this.Jc)==null||t.gt(),(e=this.tl)==null||e.gt(),(r=this.sl)==null||r.gt())}get texture(){var t;return(t=this.tl)==null?void 0:t.textures[0]}get width(){return this.tl?this.tl.width:0}get height(){return this.tl?this.tl.height:0}get fl(){return this.el}get drawFramebuffer(){return this.Jc}ll(t){this.Vc&&(this.Jc=this.Vc.externalDrawFramebuffer??this.Vc.createFramebuffer(t.cols,t.rows,4),this.tl=this.Vc.externalAsciiFramebuffer??this.Vc.createFramebuffer(t.width,t.height,1),this.Vc.externalAsciiFramebuffer||(this.sl=this.Vc.createFramebuffer(t.width,t.height,1)),this.rl=!this.Vc.externalDrawFramebuffer&&!this.Vc.externalAsciiFramebuffer,this.el=!1)}}const Qt={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};class qt{constructor(t){l(this,"Z");l(this,"dl");l(this,"vl",null);l(this,"pl",0);this.Z=t,this.dl=t.pe($,`#version 300 es
|
|
13
|
-
precision highp float;uniform sampler2D
|
|
7
|
+
`}static h(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="number"||typeof t=="boolean")return t+"";if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(e=>F.h(e)).join(", ")}]`:`[${t.slice(0,3).map(e=>F.h(e)).join(", ")}, ... +${t.length-3} more]`;if(typeof t=="object"){const e=Object.keys(t);return e.length===0?"{}":e.length<=3?`{ ${e.map(r=>`${r}: ${F.h(t[r])}`).join(", ")} }`:`{ ${e.slice(0,2).map(r=>`${r}: ${F.h(t[r])}`).join(", ")}, ... +${e.length-2} more }`}return t+""}}var O=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(O||{});const I=class I{constructor(){l(this,"l",{globalLevel:3})}static u(){return I.o||(I.o=new I),I.o}v(t,e){const r="%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.",n="color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";switch(this.l.globalLevel){case 0:return!1;case 1:return console.group(r,n),console.warn(F.i(t,e)),console.groupEnd(),!1;case 2:return console.group(r,n),console.error(F.i(t,e)),console.groupEnd(),!1;default:throw new F(t,e)}}m(t,e,r){return!!t||(this.v(e,r),!1)}_(t){this.l.globalLevel=t}};l(I,"o",null);let lt=I;const ut=lt.u();class H{constructor(t,e,r){l(this,"A");l(this,"C");l(this,"M",new Map);l(this,"F",new Map);l(this,"P",0);l(this,"$",new Map);l(this,"U");this.A=t,this.U=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)??16,this.C=this.R(e,r),this.S()}S(){const t=this.A.getProgramParameter(this.C,this.A.ACTIVE_UNIFORMS);for(let e=0;e<t;e++){const r=this.A.getActiveUniform(this.C,e);if(r){const n=r.name.replace(/\[0\]$/,""),h=this.A.getUniformLocation(this.C,n);h&&(this.M.set(n,h),this.F.set(n,{type:r.type,size:r.size}))}}}R(t,e){const r=this.k(this.A.VERTEX_SHADER,t),n=this.k(this.A.FRAGMENT_SHADER,e),h=this.A.createProgram();if(this.A.attachShader(h,r),this.A.attachShader(h,n),this.A.linkProgram(h),!this.A.getProgramParameter(h,this.A.LINK_STATUS)){const a=this.A.getProgramInfoLog(h);throw Error("Shader program link error: "+a)}return this.A.deleteShader(r),this.A.deleteShader(n),h}k(t,e){const r=this.A.createShader(t);if(this.A.shaderSource(r,e),this.A.compileShader(r),!this.A.getShaderParameter(r,this.A.COMPILE_STATUS)){const n=this.A.getShaderInfoLog(r);throw this.A.deleteShader(r),Error("Shader compilation error: "+n)}return r}D(){this.A.useProgram(this.C),this.L()}L(){this.P=0,this.$.clear()}O(t){for(const e in t)this.I(e,t[e])}I(t,e){var u,f;const r=this.M.get(t);if(!r)return;const n=this.F.get(t);if(!n)return;const{type:h,size:a}=n,c=this.A;if(e instanceof WebGLTexture){const d=this.H(t);return c.uniform1i(r,d),c.activeTexture(c.TEXTURE0+d),void c.bindTexture(c.TEXTURE_2D,e)}if(e instanceof z){const d=this.H(t);return c.uniform1i(r,d),c.activeTexture(c.TEXTURE0+d),void c.bindTexture(c.TEXTURE_2D,e.textures[0])}if(typeof e!="number")if(typeof e!="boolean")if(Array.isArray(e[0])){const d=e.flat(),g={[c.FLOAT_VEC2]:()=>c.uniform2fv(r,d),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,d),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,d)};(u=g[h])==null||u.call(g)}else{const d=e,g={[c.FLOAT]:()=>a>1?c.uniform1fv(r,d):c.uniform1f(r,d[0]),[c.FLOAT_VEC2]:()=>c.uniform2fv(r,d),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,d),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,d),[c.INT]:()=>a>1?c.uniform1iv(r,d):c.uniform1i(r,d[0]),[c.INT_VEC2]:()=>c.uniform2iv(r,d),[c.INT_VEC3]:()=>c.uniform3iv(r,d),[c.INT_VEC4]:()=>c.uniform4iv(r,d),[c.BOOL]:()=>c.uniform1iv(r,d),[c.FLOAT_MAT2]:()=>c.uniformMatrix2fv(r,!1,d),[c.FLOAT_MAT3]:()=>c.uniformMatrix3fv(r,!1,d),[c.FLOAT_MAT4]:()=>c.uniformMatrix4fv(r,!1,d)};(f=g[h])==null||f.call(g)}else c.uniform1i(r,e?1:0);else h===c.INT||h===c.BOOL?c.uniform1i(r,e):c.uniform1f(r,e)}H(t){const e=this.$.get(t);if(e!==void 0)return e;if(this.P>=this.U)throw Error(`[textmode.js] Shader attempted to bind more than ${this.U} texture samplers. Uniform "${t}" cannot be assigned.`);const r=this.P++;return this.$.set(t,r),r}get G(){return this.C}dispose(){this.A.deleteProgram(this.C)}}function Tt(o,t,e,r){return 180*Math.atan2(r-t,e-o)/Math.PI}function W(o,t,e,r){return Math.hypot(e-o,r-t)}function Y(o,t,e){return Math.min(Math.max(o,t),e)}function Ft(o){return(o%360+360)%360/360}function Rt(o,t,e){o.bindTexture(o.TEXTURE_2D,t),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,e),o.bindTexture(o.TEXTURE_2D,null)}function tt(o,t,e,r,n){o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n)}function ft(o,t,e,r,n,h=0,a=WebGL2RenderingContext.FLOAT,c=!1){o.enableVertexAttribArray(t),o.vertexAttribPointer(t,e,a,c,r,n),o.vertexAttribDivisor(t,h)}function Ct(o,t,e,r,n){o.bindBuffer(t,e),o.bufferData(t,r,n),o.bindBuffer(t,null)}const et=`#version 300 es
|
|
8
|
+
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 Ud;uniform float Ue;uniform float Uf;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/Ud)*2.0f;AA.y=-AA.y;float AB=y.z/Ud.y;float AC=clamp(-AB*Ue,-0.99f,0.99f);if(Uf>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);}}`,k=class k{constructor(t,e,r=e,n=1,h={},a){l(this,"N");l(this,"j");l(this,"l");l(this,"A");l(this,"X");l(this,"Y",[]);l(this,"W",null);l(this,"K");l(this,"Z");l(this,"q",null);l(this,"V",new Map);this.N=e,this.j=r,this.A=t,this.K=Y(n,1,8),this.Z=a,this.l={filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte",depth:!0,...h},k.J||(k.J=new H(t,et,`#version 300 es
|
|
9
|
+
precision highp float;in vec2 v_uv;uniform sampler2D U5;uniform sampler2D U6;uniform sampler2D U7;uniform sampler2D U8;uniform vec2 U9;uniform bool Ua;uniform bool Ub;uniform bool Uc;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*U9;vec2 D=(floor(C)+0.5f)/U9;vec4 E=texture(U5,D);vec4 F=Ua?texture(U6,D):vec4(0.);if(Ua&&F.a==0.){discard;}vec4 G=Ub?texture(U7,D):vec4(0.);vec4 H=Uc?texture(U8,D):vec4(0.);o_character=E;o_primaryColor=F;o_secondaryColor=G;A=H;}`));const c=t.getParameter(t.MAX_DRAW_BUFFERS),u=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,c,u),this.X=t.createFramebuffer(),this.tt(),this.st(),this.l.depth&&this.it()}tt(){const t=this.A,e=this.l.filter==="linear"?t.LINEAR:t.NEAREST,r=this.l.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,n=this.l.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,h=n===t.FLOAT?t.RGBA32F:t.RGBA8,a=t.RGBA;for(let c=0;c<this.K;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),tt(t,e,e,r,r),t.texImage2D(t.TEXTURE_2D,0,h,this.N,this.j,0,a,n,null),this.Y.push(u)}t.bindTexture(t.TEXTURE_2D,null)}st(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.X),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.Y[0],0);else{const e=[];for(let r=0;r<this.K;r++){const n=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,n,t.TEXTURE_2D,this.Y[r],0),e.push(n)}t.drawBuffers(e)}t.bindFramebuffer(t.FRAMEBUFFER,null)}it(){const t=this.A;this.W=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.W),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.N,this.j),t.bindFramebuffer(t.FRAMEBUFFER,this.X),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.W),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}et(t){Rt(this.A,this.Y[0],t)}resize(t,e){this.N=t,this.j=e,this.V.clear();const r=this.A,n=this.l.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,h=n===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.Y)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,h,this.N,this.j,0,a,n,null);r.bindTexture(r.TEXTURE_2D,null),this.W&&(r.bindRenderbuffer(r.RENDERBUFFER,this.W),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.N,this.j),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const e=this.V.get(t);if(e)return e;const r=this.A,n=this.N,h=this.j,a=new Uint8Array(n*h*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.X),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,n,h,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.READ_FRAMEBUFFER,c);const u=4*n,f=new Uint8Array(a.length);for(let d=0;d<h;d++){const g=(h-1-d)*u,v=d*u;f.set(a.subarray(g,g+u),v)}return this.V.set(t,f),f}begin(){const t=this.A;this.V.clear(),this.Z.rt(),this.Z.nt(this.X,this.N,this.j,this.K),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.Z.state.ht()}end(){this.Z.state.ot(),this.Z.ct(),this.Z.lt()}ut(){return this.q||this.ft(),this.q}ft(){if(!this.Z)return;const t=this.K>1,e=this.K>2,r=this.K>3,n={U5:this.Y[0],U6:t?this.Y[1]:this.Y[0],U7:e?this.Y[2]:this.Y[0],U8:r?this.Y[3]:this.Y[0],U9:[this.N,this.j],Ua:t,Ub:e,Uc:r},h=k.J;this.q=this.Z.vt.dt(h,n,!0)}gt(){const t=this.A;t.deleteFramebuffer(this.X);for(const e of this.Y)t.deleteTexture(e);this.W&&t.deleteRenderbuffer(this.W)}get width(){return this.N}get height(){return this.j}get textures(){return this.Y}get attachmentCount(){return this.K}};l(k,"J",null);let z=k;const Pt=new WeakMap;function dt(o,t){Pt.set(o,t)}function Mt(o){return Pt.get(o)}function it(o,t,e,r,n=255){o[0]=t/255,o[1]=(e??t)/255,o[2]=(r??t)/255,o[3]=n/255}class st{constructor(){l(this,"_t",1);l(this,"yt",0);l(this,"At",0);l(this,"bt",0);l(this,"wt",0);l(this,"Ct",0);l(this,"xt",0);l(this,"Mt",[0,0,0]);l(this,"Ft",[1,1,1,1]);l(this,"Pt",[0,0,0,1]);l(this,"$t",!1);l(this,"Tt",!1);l(this,"Rt",!1);l(this,"Et",0);l(this,"St",[0,0,0,1]);l(this,"kt",!1);l(this,"zt",[]);l(this,"Dt",[])}static Lt(){return{Ot:1,It:0,Bt:0,Ht:0,wt:0,Ct:0,xt:0,Et:0,Gt:!1,Qt:!1,Rt:!1,kt:!1,Nt:[0,0,0],jt:[1,1,1,1],Xt:[0,0,0,1]}}Yt(t){t.Ot=this._t,t.It=this.yt,t.Bt=this.At,t.Ht=this.bt,t.wt=this.wt,t.Ct=this.Ct,t.xt=this.xt,t.Gt=this.$t,t.Qt=this.Tt,t.Rt=this.Rt,t.Et=this.Et,t.kt=this.kt,t.Nt[0]=this.Mt[0],t.Nt[1]=this.Mt[1],t.Nt[2]=this.Mt[2],t.jt[0]=this.Ft[0],t.jt[1]=this.Ft[1],t.jt[2]=this.Ft[2],t.jt[3]=this.Ft[3],t.Xt[0]=this.Pt[0],t.Xt[1]=this.Pt[1],t.Xt[2]=this.Pt[2],t.Xt[3]=this.Pt[3]}Wt(t){this._t=t.Ot,this.yt=t.It,this.At=t.Bt,this.bt=t.Ht,this.wt=t.wt,this.Ct=t.Ct,this.xt=t.xt,this.$t=t.Gt,this.Tt=t.Qt,this.Rt=t.Rt,this.Et=t.Et,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.jt[0],this.Ft[1]=t.jt[1],this.Ft[2]=t.jt[2],this.Ft[3]=t.jt[3],this.Pt[0]=t.Xt[0],this.Pt[1]=t.Xt[1],this.Pt[2]=t.Xt[2],this.Pt[3]=t.Xt[3]}ht(){let t=this.Dt.pop();t||(t=st.Lt()),this.Yt(t),this.zt.push(t)}ot(){const t=this.zt.pop();t?(this.Wt(t),this.Dt.push(t)):console.warn("pop() called without matching push()")}Kt(t){this.Yt(t)}Zt(t){this._t=Math.abs(t)}qt(){this.yt=0,this.At=0,this.bt=0,this.wt=0,this.Ct=0,this.xt=0,this.kt=!1}Vt(t){t!==0&&(this.wt+=t*Math.PI/180)}Jt(t){t!==0&&(this.Ct+=t*Math.PI/180)}ts(t){t!==0&&(this.xt+=t*Math.PI/180)}ss(t=0,e=0,r=0){t===0&&e===0&&r===0||(this.yt+=t,this.At+=e,this.bt+=r)}es(t){this.ss(t,0,0)}rs(t){this.ss(0,t,0)}ns(t){this.ss(0,0,t)}hs(t){this.Mt[0]=t[0],this.Mt[1]=t[1],this.Mt[2]=t[2]}cs(t,e,r,n=255){it(this.Ft,t,e,r,n)}ls(t,e,r,n=255){it(this.Pt,t,e,r,n)}us(t){this.$t=t}fs(t){this.Tt=t}ds(t){this.Rt=t}vs(t){this.Et=Ft(t)}ps(t,e,r,n){it(this.St,t,e,r,n)}gs(t){this.kt=t}get canvasBackgroundColor(){return this.St}get useOrtho(){return this.kt}get rotationX(){return this.wt}get rotationY(){return this.Ct}get rotationZ(){return this.xt}}const gt=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,-.5,.5,0,1,-.5,.5,0,1,.5,-.5,1,0,.5,.5,1,1]),j={_s:16,As:WebGL2RenderingContext.TRIANGLES,bs:{ws:{size:2,offset:0},Cs:{size:2,offset:8}}};class ie{constructor(t){l(this,"A");l(this,"Ms");l(this,"Fs");this.A=t,this.Ms=t.createBuffer(),this.Fs=new Float32Array(gt.length)}Ps(t,e,r,n){const h=this.A,a=Mt(this.A),c=a[2],u=a[3],f=t/c*2-1,d=(t+r)/c*2-1,g=1-(e+n)/u*2,v=1-e/u*2,m=gt,A=this.Fs;for(let p=0;p<m.length;p+=4){const y=m[p],E=m[p+1],w=m[p+2],x=m[p+3],P=f+(y+.5)*(d-f),b=g+(E+.5)*(v-g);A[p]=P,A[p+1]=b,A[p+2]=w,A[p+3]=x}h.bindBuffer(h.ARRAY_BUFFER,this.Ms),h.bufferData(h.ARRAY_BUFFER,A,h.DYNAMIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,16,0),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,16,8),h.drawArrays(h.TRIANGLES,0,6),h.disableVertexAttribArray(1),h.disableVertexAttribArray(0),h.bindBuffer(h.ARRAY_BUFFER,null)}gt(){this.A.deleteBuffer(this.Ms)}}var R=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(R||{});const se={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class re{constructor(t){l(this,"A");l(this,"$s",new Map);this.A=t}Ts(t,e,r,n){const h=this.A;let a=this.$s.get(t);a||(a=new Map,this.$s.set(t,a));let c=a.get(e)||null;if(!c){c=h.createVertexArray(),a.set(e,c),h.bindVertexArray(c),h.bindBuffer(h.ARRAY_BUFFER,n);const u=h.getAttribLocation(t,"A0");u!==-1&&ft(h,u,r.bs.ws.size,r._s,r.bs.ws.offset,0,h.FLOAT,!1);const f=h.getAttribLocation(t,"A1");f!==-1&&ft(h,f,r.bs.Cs.size,r._s,r.bs.Cs.offset,0,h.FLOAT,!1)}h.bindVertexArray(c)}Rs(){this.A.bindVertexArray(null)}gt(){for(const[,t]of this.$s)for(const[,e]of t)e&&this.A.deleteVertexArray(e)}}const Z=class Z{static Es(t,e,r=0){const n=e||new Float32Array(Z.FLOATS_PER_INSTANCE);let h=r;n[h++]=t.ws[0],n[h++]=t.ws[1],n[h++]=t.Ss[0],n[h++]=t.Ss[1],n[h++]=t.Nt[0],n[h++]=t.Nt[1],n[h++]=t.Nt[2],n[h++]=t.jt[0],n[h++]=t.jt[1],n[h++]=t.jt[2],n[h++]=t.jt[3],n[h++]=t.Xt[0],n[h++]=t.Xt[1],n[h++]=t.Xt[2],n[h++]=t.Xt[3],n[h++]=t.ks[0],n[h++]=t.ks[1],n[h++]=t.ks[2],n[h++]=t.Et;const a=t.zs;n[h++]=(a==null?void 0:a[0])??0,n[h++]=(a==null?void 0:a[1])??0,n[h++]=(a==null?void 0:a[2])??0;const c=t.Ds;n[h++]=(c==null?void 0:c[0])??0,n[h++]=(c==null?void 0:c[1])??0,n[h++]=(c==null?void 0:c[2])??0;const u=t.Ls,f=t.Os,d=t.Is,g=t.Bs,v=t.Hs,m=!(!f||!d);return m?(n[h++]=(g==null?void 0:g[0])??0,n[h++]=(g==null?void 0:g[1])??0,n[h++]=(v==null?void 0:v[0])??0,n[h++]=(v==null?void 0:v[1])??0,n[h++]=f[0],n[h++]=f[1],n[h++]=d[0],n[h++]=d[1]):!m&&!!u?(n[h++]=u[0],n[h++]=u[1],n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0):(n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0),n[h++]=t.Gs??0,n[h++]=t.Qs??0,n[h++]=t.Ns??0,n}static js(t,e){const r=t.length*Z.FLOATS_PER_INSTANCE,n=e||new Float32Array(r);for(let h=0;h<t.length;h++){const a=h*Z.FLOATS_PER_INSTANCE;Z.Es(t[h],n,a)}return n}};l(Z,"BYTES_PER_INSTANCE",144),l(Z,"FLOATS_PER_INSTANCE",36);let _=Z;const S=class S{};l(S,"STRIDE",_.BYTES_PER_INSTANCE),l(S,"ATTRIBUTES",{A2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:0,divisor:1},A3:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:8,divisor:1},A4:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:16,divisor:1},A5:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:28,divisor:1},A6:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:44,divisor:1},A7:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:60,divisor:1},A8:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:76,divisor:1},A9:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:88,divisor:1},Aa:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:100,divisor:1},Ab:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:116,divisor:1},Ac:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:132,divisor:1}});let K=S;class ne{constructor(t=1e3,e=1.5){l(this,"Xs");l(this,"Ys");l(this,"Ws");l(this,"Ks",0);l(this,"Zs",0);this.Ys=t,this.Ws=e;const r=t*_.FLOATS_PER_INSTANCE;this.Xs=new Float32Array(r)}qs(t){if(t<=this.Ys)return;const e=Math.ceil(t*this.Ws),r=this.Ys;this.Ys=e;const n=e*_.FLOATS_PER_INSTANCE,h=new Float32Array(n),a=r*_.FLOATS_PER_INSTANCE;h.set(this.Xs.subarray(0,Math.min(a,this.Ks))),this.Xs=h}Vs(){return{buffer:this.Xs,offset:this.Ks}}Js(t){this.Ks+=t,this.Zs++}ti(){this.Ks=0,this.Zs=0}si(t=0,e){return this.Xs.subarray(t,e??this.Ks)}get ii(){return this.Zs}get ei(){return this.Ys}get ri(){return this.Ks}get ni(){return this.Zs===0}}class he{constructor(t){l(this,"Xs");this.Xs=t}hi(t){this.Xs.qs(this.Xs.ii+1);const{buffer:e,offset:r}=this.Xs.Vs();e[r+0]=t.x,e[r+1]=t.y,e[r+2]=t.width,e[r+3]=t.height,e[r+4]=t.char0,e[r+5]=t.char1,e[r+6]=t.char2,e[r+7]=t.r1,e[r+8]=t.g1,e[r+9]=t.b1,e[r+10]=t.a1,e[r+11]=t.r2,e[r+12]=t.g2,e[r+13]=t.b2,e[r+14]=t.a2,e[r+15]=t.invert,e[r+16]=t.flipX,e[r+17]=t.flipY,e[r+18]=t.charRot,e[r+19]=t.translationX,e[r+20]=t.translationY,e[r+21]=t.translationZ,e[r+22]=t.rotationX,e[r+23]=t.rotationY,e[r+24]=t.rotationZ;const n=t.curveParams0,h=t.curveParams1;return e[r+25]=n[0],e[r+26]=n[1],e[r+27]=n[2],e[r+28]=n[3],e[r+29]=h[0],e[r+30]=h[1],e[r+31]=h[2],e[r+32]=h[3],e[r+33]=t.depth,e[r+34]=t.baseZ,e[r+35]=t.geometryType,this.Xs.Js(_.FLOATS_PER_INSTANCE),this.Xs.ii-1}get ii(){return this.Xs.ii}}class oe{constructor(t,e=1e3){l(this,"A");l(this,"oi",null);l(this,"ai",0);l(this,"ci",new Map);this.A=t,this.li(e)}li(t){const e=this.A;this.oi&&e.deleteBuffer(this.oi),this.oi=e.createBuffer();const r=t*_.BYTES_PER_INSTANCE;Ct(e,e.ARRAY_BUFFER,this.oi,r,e.DYNAMIC_DRAW),this.ai=t}ui(t){this.li(t)}get ei(){return this.ai}fi(t,e){if(e===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.oi);const n=e*_.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,n)}di(t){let e=this.ci.get(t);if(!e){e=new Map;const r=this.A;for(const n in K.ATTRIBUTES){const h=r.getAttribLocation(t,n);h!==-1&&e.set(n,h)}this.ci.set(t,e)}return e}pi(t){const e=this.A,r=t.G,n=this.di(r);for(const[h,a]of n){const c=K.ATTRIBUTES[h];c&&ft(e,a,c.size,c.stride,c.offset,c.divisor,c.type,c.normalized)}}gi(t){const e=this.A,r=this.di(t.G);for(const[n,h]of r)K.ATTRIBUTES[n]&&(e.disableVertexAttribArray(h),e.vertexAttribDivisor(h,0))}gt(){this.oi&&(this.A.deleteBuffer(this.oi),this.oi=null),this.ci.clear()}}class ae{constructor(t,e=1e3,r=1.5){l(this,"A");l(this,"Xs");l(this,"mi");l(this,"_i");this.A=t,this.Xs=new ne(e,r),this.mi=new he(this.Xs),this._i=new oe(t,e)}yi(t){var n,h,a,c,u,f,d,g,v,m;const e=[0,0,0,0],r=[0,0,0,0];return t.Os&&t.Is?(e[0]=((n=t.Bs)==null?void 0:n[0])??0,e[1]=((h=t.Bs)==null?void 0:h[1])??0,e[2]=((a=t.Hs)==null?void 0:a[0])??0,e[3]=((c=t.Hs)==null?void 0:c[1])??0,r[0]=t.Os[0],r[1]=t.Os[1],r[2]=t.Is[0],r[3]=t.Is[1]):t.Ls&&(e[0]=t.Ls[0],e[1]=t.Ls[1]),this.hi({x:t.ws[0],y:t.ws[1],width:t.Ss[0],height:t.Ss[1],char0:t.Nt[0],char1:t.Nt[1],char2:t.Nt[2],r1:t.jt[0],g1:t.jt[1],b1:t.jt[2],a1:t.jt[3],r2:t.Xt[0],g2:t.Xt[1],b2:t.Xt[2],a2:t.Xt[3],invert:t.ks[0],flipX:t.ks[1],flipY:t.ks[2],charRot:t.Et,translationX:((u=t.zs)==null?void 0:u[0])??0,translationY:((f=t.zs)==null?void 0:f[1])??0,translationZ:((d=t.zs)==null?void 0:d[2])??0,rotationX:((g=t.Ds)==null?void 0:g[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:r,depth:t.Gs||0,baseZ:t.Qs||0,geometryType:t.Ns||0})}hi(t){const e=this.mi.hi(t);return this.Xs.ei>this._i.ei&&this._i.ui(this.Xs.ei),e}get Ai(){return this.Xs.ii}get ni(){return this.Xs.ni}bi(){this.Xs.ti()}pi(t){const e=this.Xs.ii;if(e===0)return;const r=this.Xs.si();this._i.fi(r,e),this._i.pi(t)}gi(t){this._i.gi(t)}Ps(t,e){const r=this.Xs.ii;r!==0&&this.A.drawArraysInstanced(t,0,e,r)}gt(){this._i.gt()}}class G{constructor(t,e,r,n){l(this,"A");l(this,"wi");l(this,"Ci");l(this,"xi");l(this,"Mi",null);this.A=t,this.wi=e,this.Ci=r,this.xi=n;const h=this.A.createBuffer();Ct(this.A,this.A.ARRAY_BUFFER,h,this.xi.Fi,this.A.STATIC_DRAW),this.Mi=h}get type(){return this.Ci}get unitGeometry(){return this.xi}get unitBuffer(){return this.Mi}get batch(){return this.wi}Pi(){this.wi.bi()}$i(){return!this.wi.ni}gt(){this.wi.gt(),this.A.deleteBuffer(this.Mi)}Ti(t,e,r){return this.wi.yi(t)}Ri(t,e,r,n,h,a){const c=h.It??0,u=h.Bt??0,f=h.Ht??0,d=h.wt??0,g=h.Ct??0,v=h.xt??0,m=[0,0,0,0],A=[0,0,0,0];a&&(a.bezStartX!==void 0&&a.bezStartY!==void 0&&a.bezEndX!==void 0&&a.bezEndY!==void 0?(m[0]=a.cp1x??0,m[1]=a.cp1y??0,m[2]=a.cp2x??0,m[3]=a.cp2y??0,A[0]=a.bezStartX??0,A[1]=a.bezStartY??0,A[2]=a.bezEndX??0,A[3]=a.bezEndY??0):a.arcStart===void 0&&a.arcStop===void 0||(m[0]=a.arcStart??0,m[1]=a.arcStop??0));const p={x:t,y:e,width:r,height:n,char0:h.Nt[0],char1:h.Nt[1],char2:h.Nt[2],r1:h.jt[0],g1:h.jt[1],b1:h.jt[2],a1:h.jt[3],r2:h.Xt[0],g2:h.Xt[1],b2:h.Xt[2],a2:h.Xt[3],invert:h.Rt?1:0,flipX:h.Gt?1:0,flipY:h.Qt?1:0,charRot:h.Et,translationX:c,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:v,curveParams0:m,curveParams1:A,depth:(a==null?void 0:a.depth)??0,baseZ:(a==null?void 0:a.baseZ)??0,geometryType:se[this.Ci]??0};return this.wi.hi(p)}}const ce={Fi:gt,Ei:6,...j},le={Fi:new Float32Array([0,-.5,0,0,1,-.5,1,0,0,.5,0,1,0,.5,0,1,1,-.5,1,0,1,.5,1,1]),Ei:6,...j},ue={Fi:function(o=32){const t=[],e=2*Math.PI/o;for(let r=0;r<o;r++){const n=r*e,h=(r+1)%o*e,a=Math.cos(n),c=Math.sin(n),u=.5*(a+1),f=.5*(c+1),d=Math.cos(h),g=Math.sin(h),v=.5*(d+1),m=.5*(g+1);t.push(0,0,.5,.5,a,c,u,f,d,g,v,m)}return new Float32Array(t)}(32),Ei:96,...j};let fe={Fi:function(o){const t=[];for(let e=0;e<o;e++){const r=e/o,n=(e+1)/o;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),Ei:96,...j};const de={Fi:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Ei:3,...j},ge={Fi:function(o=16){const t=[];for(let e=0;e<o;e++){const r=e/o,n=(e+1)/o;t.push(r,-.5,r,0,n,-.5,n,0,r,.5,r,1,r,.5,r,1,n,-.5,n,0,n,.5,n,1)}return new Float32Array(t)}(16),Ei:96,...j},ve={[R.RECTANGLE]:class extends G{constructor(o,t){super(o,t,R.RECTANGLE,ce)}yi(o,t){return this.Ri(0,0,o.width,o.height,t)}},[R.LINE]:class extends G{constructor(o,t){super(o,t,R.LINE,le)}yi(o,t){const e=o.x2-o.x1,r=o.y2-o.y1,n=Math.hypot(e,r),h=Math.atan2(r,e),a=t.Ot||1,c=o.x1+e/2-n/2,u=o.y1+r/2,f={...t,xt:(t.xt||0)+h};return this.Ri(c,u,n,a,f)}},[R.ELLIPSE]:class extends G{constructor(o,t){super(o,t,R.ELLIPSE,ue)}yi(o,t){return this.Ri(0,0,o.width,o.height,t)}},[R.ARC]:class extends G{constructor(o,t){super(o,t,R.ARC,fe)}yi(o,t){const e=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Ri(0,0,o.width,o.height,t,{arcStart:e,arcStop:r})}},[R.TRIANGLE]:class extends G{constructor(o,t){super(o,t,R.TRIANGLE,de)}yi(o,t){const e=Math.min(o.x1,o.x2,o.x3),r=Math.max(o.x1,o.x2,o.x3),n=Math.min(o.y1,o.y2,o.y3),h=r-e,a=Math.max(o.y1,o.y2,o.y3)-n;return this.Ri(e,n,h,a,t)}},[R.BEZIER_CURVE]:class extends G{constructor(o,t){super(o,t,R.BEZIER_CURVE,ge)}yi(o,t){return this.Ri(0,0,1,t.Ot||1,t,{cp1x:o.cp1x,cp1y:o.cp1y,cp2x:o.cp2x,cp2y:o.cp2y,bezStartX:o.x1,bezStartY:o.y1,bezEndX:o.x2,bezEndY:o.y2})}}};class me{constructor(t){l(this,"A");l(this,"Si");l(this,"ki");this.A=t,this.ki=new re(t),this.Si=new Map;for(const e of Object.values(R)){const r=new ae(t),n=new ve[e](t,r);this.Si.set(e,n)}}zi(t){const e=this.Di(t);for(const r of e)this.Li(r)}Di(t){const e=[];let r=null,n=null,h=null;for(const a of t)n!==a.material||h!==a.type?(r&&r.length>0&&e.push({material:n,type:h,commands:r}),r=[a],n=a.material,h=a.type):r.push(a);return r&&r.length>0&&e.push({material:n,type:h,commands:r}),e}Li(t){const{material:e,type:r,commands:n}=t,h=this.Si.get(r);e.shader.D(),e.shader.O(e.uniforms);const a=Mt(this.A),c=n.length>0&&n[0].state.kt;e.shader.O({Uv:a[2]/a[3],Ud:[a[2],a[3]],Ue:1,Uf:c?1:0}),h.Pi();for(const u of n)h.yi(u.params,u.state);if(h.$i()){const u=h.unitGeometry,f=h.unitBuffer;try{this.ki.Ts(e.shader.G,r+"",u,f),h.batch.pi(e.shader),h.batch.Ps(u.As,u.Ei)}finally{h.batch.gi(e.shader),this.ki.Rs(),h.Pi()}}}gt(){for(const t of this.Si.values())t.gt();this.Si.clear(),this.ki.gt()}}function Nt(o){let t=0;for(let e=0;e<o.length;e++)t=(t<<5)-t+o.charCodeAt(e),t&=t;return t}const Ut=new WeakMap;let pe=1;function St(o){if(o==null)return 0;if(typeof o!="object"&&typeof o!="function")return Nt(o+"");let t=Ut.get(o);return t||(t=pe++,Ut.set(o,t)),t}function Q(o,t){return(o<<5)-o+t}class Ae{constructor(t){l(this,"Oi",0);l(this,"Ii");l(this,"Bi");l(this,"Hi",new Map);this.Ii=new H(t,et,`#version 300 es
|
|
10
|
+
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.Bi={id:this.Oi++,shader:this.Ii,uniforms:Object.freeze({}),hash:this.Gi(this.Ii,{}),isBuiltIn:!0}}get Qi(){return this.Bi}dt(t,e={},r=!1){const n=this.Gi(t,e),h=this.Hi.get(n);if(h)return h;const a={id:this.Oi++,shader:t,uniforms:Object.freeze({...e}),hash:n,isBuiltIn:r};return this.Hi.set(n,a),a}Ni(t,e={}){return{id:this.Oi++,shader:t,uniforms:Object.freeze({...e}),hash:0,isBuiltIn:!1}}Gi(t,e){const r=St(t.G),n=function(h,a){let c=0;const u=Object.keys(h).sort();for(const f of u)c=Q(c,Nt(f)),c=Q(c,a(h[f]));return c}(e,this.ji.bind(this));return Q(r,n)}ji(t){return typeof t=="number"||typeof t=="boolean"?function(e){return typeof e=="boolean"?e?1:0:Math.floor(e)}(t):Array.isArray(t)?function(e){let r=0;const n=Array.isArray(e[0])?e.flat():e;for(const h of n)r=Q(r,typeof h=="number"?h:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(e){let r=0;const n=Math.min(e.length,16);for(let h=0;h<n;h++)r=Q(r,e[h]);return r}(t):t instanceof WebGLTexture?St(t):0}gt(){this.Ii!=this.Ii&&this.Ii.dispose(),this.Ii.dispose(),this.Hi.clear()}}class Ee{constructor(){l(this,"Xi",[]);l(this,"Yi",1);l(this,"Ss",0)}Wi(t,e){if(this.Ss>=this.Xi.length){const n={id:this.Yi++,type:t,params:{},state:st.Lt(),material:e};this.Xi.push(n)}const r=this.Xi[this.Ss];return r.id=this.Yi++,r.type=t,r.material=e,this.Ss++,r}Ki(t,e,r){const n=this.Wi(R.RECTANGLE,r),h=n.params;return h.width=t.width,h.height=t.height,e.Kt(n.state),n.id}Zi(t,e,r){const n=this.Wi(R.LINE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.thickness=t.thickness,e.Kt(n.state),n.id}qi(t,e,r){const n=this.Wi(R.ELLIPSE,r),h=n.params;return h.width=t.width,h.height=t.height,h.startAngle=t.startAngle,h.endAngle=t.endAngle,h.segments=t.segments,e.Kt(n.state),n.id}Vi(t,e,r){const n=this.Wi(R.ARC,r),h=n.params;return h.width=t.width,h.height=t.height,h.start=t.start,h.stop=t.stop,e.Kt(n.state),n.id}Ji(t,e,r){const n=this.Wi(R.TRIANGLE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.x3=t.x3,h.y3=t.y3,e.Kt(n.state),n.id}te(t,e,r){const n=this.Wi(R.BEZIER_CURVE,r),h=n.params;return h.x1=t.x1,h.y1=t.y1,h.cp1x=t.cp1x,h.cp1y=t.cp1y,h.cp2x=t.cp2x,h.cp2y=t.cp2y,h.x2=t.x2,h.y2=t.y2,h.thickness=t.thickness,h.segments=t.segments,e.Kt(n.state),n.id}bi(){this.Ss=0}[Symbol.iterator](){let t=0;const e=this.Ss,r=this.Xi;return{next:()=>t<e?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ye{constructor(t){l(this,"A");l(this,"se",null);l(this,"ie");l(this,"vt");l(this,"ee");l(this,"re");l(this,"ne");l(this,"he",null);l(this,"oe",{});l(this,"ae",[]);l(this,"ce",[]);l(this,"le",[]);l(this,"ue",null);l(this,"fe",[0,0,0,0]);l(this,"de",1);this.A=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.ee=new st,this.vt=new Ae(t),this.re=new Ee,this.ie=new me(t),this.ne=new ie(t);const e=[0,0,t.canvas.width,t.canvas.height];dt(t,e),this.ae.push(null),this.ce.push(e),this.le.push(1),this.ue=null,this.fe=e,this.de=1}rt(){this.ae.push(this.ue),this.ce.push([...this.fe]),this.le.push(this.de)}lt(){const t=this.ae.pop()??null,e=this.ce.pop()??[0,0,this.A.canvas.width,this.A.canvas.height],r=this.le.pop()??1;this.nt(t,e[2],e[3],r)}nt(t,e,r,n=1){const h=this.A;this.ue!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.ue=t),this.de=n;const a=[0,0,e,r];this.fe[0]===a[0]&&this.fe[1]===a[1]&&this.fe[2]===a[2]&&this.fe[3]===a[3]||(h.viewport(...a),dt(h,a),this.fe=a)}ve(t){this.se!==t&&(this.se=t,t.D())}pe(t,e){return new H(this.A,t,e)}ge(t){this.he=t,t&&(this.oe={})}I(t,e){this.oe[t]=e}me(t){Object.assign(this.oe,t)}_e(t){return new H(this.A,et,t)}ye(t,e,r){this.re.Ki({width:e??t.width,height:r??t.height},this.ee,t.ut())}Ae(t,e,r,n){this.ne.Ps(t,e,r,n)}be(t,e){if(this.he){const r=this.vt.Ni(this.he,this.oe);this.re.Ki({width:t,height:e},this.ee,r),this.he=null,this.oe={}}else this.re.Ki({width:t,height:e},this.ee,this.vt.Qi)}we(t,e,r,n){this.re.Zi({x1:t,y1:e,x2:r,y2:n},this.ee,this.vt.Qi)}Ce(t,e){this.re.qi({width:t,height:e},this.ee,this.vt.Qi)}xe(t,e,r,n,h,a){this.re.Ji({x1:t,y1:e,x2:r,y2:n,x3:h,y3:a},this.ee,this.vt.Qi)}Me(t,e,r,n,h,a,c,u){this.re.te({x1:t,y1:e,cp1x:r,cp1y:n,cp2x:h,cp2y:a,x2:c,y2:u},this.ee,this.vt.Qi)}Fe(t,e,r,n){this.re.Vi({width:t,height:e,start:r,stop:n},this.ee,this.vt.Qi)}Pe(t,e,r=1,n={}){return new z(this.A,t,e,r,n,this)}$e(t,e=t,r=t,n=255){this.ee.ps(t,e??t,r??t,n);const[h,a,c,u]=this.ee.canvasBackgroundColor;this.Te(h,a,c,u,!1)}bi(t=0,e=0,r=0,n=0){this.Te(t,e,r,n,!0)}Te(t,e,r,n,h){const a=this.A;if(this.de>1){const c=h?[1,1,0,0]:[0,0,0,0];a.clearBufferfv(a.COLOR,0,new Float32Array(c)),a.clearBufferfv(a.COLOR,1,new Float32Array([0,0,0,0])),this.de>=3&&a.clearBufferfv(a.COLOR,2,new Float32Array([t,e,r,n]));for(let u=3;u<this.de;u++)a.clearBufferfv(a.COLOR,u,new Float32Array([0,0,0,0]))}else a.clearColor(t,e,r,n),a.clear(a.COLOR_BUFFER_BIT)}Re(){const t=[0,0,this.A.canvas.width,this.A.canvas.height];this.A.viewport(...t),dt(this.A,t),this.fe=t,this.ce.length>0&&(this.ce[0]=t)}ct(){const t=this.re;this.ie.zi(t),t.bi(),this.se=null}gt(){this.vt.gt(),this.ie.gt(),this.ne.gt()}get context(){return this.A}get state(){return this.ee}get materialManager(){return this.vt}}const C={readShort:(o,t)=>(C.t.uint16[0]=o[t]<<8|o[t+1],C.t.int16[0]),readUshort:(o,t)=>o[t]<<8|o[t+1],readUshorts(o,t,e){const r=[];for(let n=0;n<e;n++)r.push(C.readUshort(o,t+2*n));return r},readUint(o,t){const e=C.t.uint8;return e[3]=o[t],e[2]=o[t+1],e[1]=o[t+2],e[0]=o[t+3],C.t.uint32[0]},readASCII(o,t,e){let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(o[t+n]);return r},t:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function rt(o){return o+3&-4}function nt(o,t,e){o[t]=e>>>8&255,o[t+1]=255&e}function X(o,t,e){o[t]=e>>>24&255,o[t+1]=e>>>16&255,o[t+2]=e>>>8&255,o[t+3]=255&e}function xe(o,t,e){for(let r=0;r<e.length;r++)o[t+r]=255&e.charCodeAt(r)}function vt(o,t,e){const r=t+e;let n=0;const h=C.t;for(let a=t;a<r;a+=4)h.uint8[3]=o[a]||0,h.uint8[2]=o[a+1]||0,h.uint8[1]=o[a+2]||0,h.uint8[0]=o[a+3]||0,n=n+(h.uint32[0]>>>0)>>>0;return n>>>0}class we{constructor(t){l(this,"b");l(this,"p",0);l(this,"bitbuf",0);l(this,"bitcnt",0);this.b=t}readBits(t){for(;this.bitcnt<t;){const r=this.b[this.p++]||0;this.bitbuf|=r<<this.bitcnt,this.bitcnt+=8}const e=this.bitbuf&(1<<t)-1;return this.bitbuf>>>=t,this.bitcnt-=t,e}alignToByte(){this.bitbuf=0,this.bitcnt=0}get offset(){return this.p}}function q(o){let t=32,e=0;for(const c of o)c&&(c<t&&(t=c),c>e&&(e=c));if(e===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(e+1);for(const c of o)c&&r[c]++;const n=new Uint32Array(e+1);let h=0;r[0]=0;for(let c=1;c<=e;c++)h=h+r[c-1]<<1,n[c]=h;const a=new Map;for(let c=0;c<o.length;c++){const u=o[c];if(!u)continue;const f=n[u]++;let d=a.get(u);d||(d=[],a.set(u,d)),d[be(f,u)]=c}return{min:t,max:e,table:a}}function mt(o,t){let e=0;for(let r=1;r<=t.max;r++){e|=o.readBits(1)<<r-1;const n=t.table.get(r);if(n&&e<n.length){const h=n[e];if(h!==void 0)return h}}throw Error("Invalid Huffman code")}function be(o,t){let e=0;for(let r=0;r<t;r++)e=e<<1|1&o,o>>>=1;return e>>>0}function Te(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],e=o[1];if((15&t)!=8)throw Error("Unsupported ZLIB compression method");if(((t<<8)+e)%31!=0)throw Error("Bad ZLIB header check");let r=2;32&e&&(r+=4);const n=[];return function(h,a){const c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],f=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],d=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];let g=0;for(;!g;){g=h.readBits(1);const v=h.readBits(2);if(v===0){h.alignToByte();const m=h.readBits(16);if((65535&(65535^m))!==h.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let A=0;A<m;A++)a.push(h.readBits(8))}else{if(v!==1&&v!==2)throw Error("Unsupported DEFLATE type");{let m,A;if(v===1){const p=Array(288).fill(0);for(let y=0;y<=143;y++)p[y]=8;for(let y=144;y<=255;y++)p[y]=9;for(let y=256;y<=279;y++)p[y]=7;for(let y=280;y<=287;y++)p[y]=8;m=q(p),A=q(Array(32).fill(5))}else{const p=h.readBits(5)+257,y=h.readBits(5)+1,E=h.readBits(4)+4,w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=Array(19).fill(0);for(let M=0;M<E;M++)x[w[M]]=h.readBits(3);const P=q(x),b=[];for(;b.length<p+y;){const M=mt(h,P);if(M<=15)b.push(M);else if(M===16){const B=h.readBits(2)+3,D=b[b.length-1]||0;for(let ct=0;ct<B;ct++)b.push(D)}else if(M===17){const B=h.readBits(3)+3;for(let D=0;D<B;D++)b.push(0)}else{if(M!==18)throw Error("Invalid code length symbol");{const B=h.readBits(7)+11;for(let D=0;D<B;D++)b.push(0)}}}const N=b.slice(0,p),L=b.slice(p,p+y);m=q(N),A=q(L)}for(;;){const p=mt(h,m);if(p<256)a.push(p);else{if(p===256)break;if(p>256&&p<286){const y=p-257;let E=c[y];const w=u[y];w&&(E+=h.readBits(w));const x=mt(h,A);if(x>=30)throw Error("Invalid distance symbol");let P=f[x];const b=d[x];b&&(P+=h.readBits(b));const N=a.length-P;if(N<0)throw Error("Invalid distance");for(let L=0;L<E;L++)a.push(a[N+L]||0)}else if(p===286||p===287)throw Error("Reserved length symbol")}}}}}}(new we(o.subarray(r)),n),new Uint8Array(n)}function Fe(o){const t=C,e=new Uint8Array(o);if(t.readASCII(e,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(e,4),n=t.readUshort(e,12),h=t.readUint(e,16),a=[];let c=44;for(let E=0;E<n;E++){const w=t.readASCII(e,c,4),x=t.readUint(e,c+4),P=t.readUint(e,c+8),b=t.readUint(e,c+12),N=t.readUint(e,c+16);a.push({tag:w,offset:x,compLength:P,origLength:b,checksum:N}),c+=20}for(const E of a){const w=new Uint8Array(e.buffer,E.offset,E.compLength);if(E.compLength===E.origLength)E.data=new Uint8Array(w);else if(E.data=Te(w),E.data.length!==E.origLength)if(E.data.length<E.origLength){const x=new Uint8Array(E.origLength);x.set(E.data),E.data=x}else E.data=E.data.subarray(0,E.origLength)}const u=n;let f=1,d=0;for(;f<<1<=u;)f<<=1,d++;const g=16*f,v=16*u-g;let m=12+16*u;const A={};for(const E of a)A[E.tag]=m,m=rt(m+E.data.length);const p=new Uint8Array(Math.max(h||0,m));X(p,0,r),nt(p,4,u),nt(p,6,g),nt(p,8,d),nt(p,10,v);let y=12;for(const E of a){xe(p,y,E.tag),y+=4;let w=E.data;if(E.tag==="head"&&w.length>=12){const x=new Uint8Array(w);X(x,8,0),X(p,y,vt(x,0,rt(x.length))),y+=4}else X(p,y,vt(w,0,rt(w.length))),y+=4;X(p,y,A[E.tag]),y+=4,X(p,y,E.data.length),y+=4}for(const E of a){const w=A[E.tag];p.set(E.data,w)}if(a.find(E=>E.tag==="head")){const E=A.head,w=function(x,P){const b=P+8,N=[x[b],x[b+1],x[b+2],x[b+3]];X(x,b,0);const L=2981146554-(vt(x,0,rt(x.length))>>>0)>>>0;return x[b]=N[0],x[b+1]=N[1],x[b+2]=N[2],x[b+3]=N[3],L>>>0}(p,E);X(p,E+8,w)}return p.buffer}const Re={parseTab(o,t,e){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,e),t=0;const n=C,h=n.readUshort,a=h(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const f=h(o,t),d=h(o,t+=2);t+=2;const g=n.readUint(o,t);t+=4;const v=`p${f}e${d}`;let m=c.indexOf(g);if(m===-1){let A;m=r.tables.length,c.push(g);const p=h(o,g);A=p===4?this.parse4(o,g):p===12?this.parse12(o,g):{format:p},r.tables.push(A)}r.ids[v]=m}return r},parse4(o,t){const e=C,r=e.readUshort,n=e.readUshorts,h=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,searchRange:r(o,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(o,t),t+=2,u.rangeShift=r(o,t),t+=2,u.endCount=n(o,t,c),t+=2*c,t+=2,u.startCount=n(o,t,c),t+=2*c;for(let f=0;f<c;f++)u.idDelta.push(e.readShort(o,t)),t+=2;return u.idRangeOffset=n(o,t,c),t+=2*c,u.glyphIdArray=n(o,t,h+a-t>>1),u},parse12(o,t){const e=C.readUint;e(o,t+=4),e(o,t+=4);const r=e(o,t+=4);t+=4;const n=new Uint32Array(3*r);for(let h=0;h<3*r;h+=3)n[h]=e(o,t+(h<<2)),n[h+1]=e(o,t+(h<<2)+4),n[h+2]=e(o,t+(h<<2)+8);return{format:12,groups:n}}},Ce={parseTab(o,t,e){const r=C;t+=18;const n=r.readUshort(o,t);t+=2,t+=16;const h=r.readShort(o,t);t+=2;const a=r.readShort(o,t);t+=2;const c=r.readShort(o,t);t+=2;const u=r.readShort(o,t);return t+=2,t+=6,{unitsPerEm:n,xMin:h,yMin:a,xMax:c,yMax:u,indexToLocFormat:r.readShort(o,t)}}},Pe={parseTab(o,t,e){const r=C;t+=4;const n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],h={};for(let a=0;a<n.length;a++){const c=n[a],u=c==="advanceWidthMax"||c==="numberOfHMetrics"?r.readUshort:r.readShort;h[c]=u(o,t+2*a)}return h}},Me={parseTab(o,t,e,r){const n=C,h=[],a=[],c=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,d=0,g=0;for(;g<u;)f=n.readUshort(o,t+(g<<2)),d=n.readShort(o,t+(g<<2)+2),h.push(f),a.push(d),g++;for(;g<c;)h.push(f),a.push(d),g++;return{aWidth:h,lsBearing:a}}},Dt={cmap:Re,head:Ce,hhea:Pe,maxp:{parseTab(o,t,e){const r=C;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:Me,loca:{parseTab(o,t,e,r){const n=C,h=[],a=r.head.indexToLocFormat,c=r.maxp.numGlyphs+1;if(a===0)for(let u=0;u<c;u++)h.push(n.readUshort(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)h.push(n.readUint(o,t+(u<<2)));return h}},glyf:{parseTab(o,t,e,r){const n=[],h=r.maxp.numGlyphs;for(let a=0;a<h;a++)n.push(null);return n},Ee(o,t){const e=C,r=o.Se,n=o.loca;if(n[t]===n[t+1])return null;const h=J.findTable(r,"glyf",o.ke);if(!h)return null;let a=h[0]+n[t];const c={};if(c.noc=e.readShort(r,a),a+=2,c.xMin=e.readShort(r,a),a+=2,c.yMin=e.readShort(r,a),a+=2,c.xMax=e.readShort(r,a),a+=2,c.yMax=e.readShort(r,a),a+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(let v=0;v<c.noc;v++)c.endPts.push(e.readUshort(r,a)),a+=2;const u=e.readUshort(r,a);if(a+=2,r.length-a<u)return null;a+=u;const f=c.endPts[c.noc-1]+1;c.flags=[];for(let v=0;v<f;v++){const m=r[a];if(a++,c.flags.push(m),8&m){const A=r[a];a++;for(let p=0;p<A;p++)c.flags.push(m),v++}}c.xs=[];for(let v=0;v<f;v++){const m=c.flags[v],A=!!(16&m);2&m?(c.xs.push(A?r[a]:-r[a]),a++):A?c.xs.push(0):(c.xs.push(e.readShort(r,a)),a+=2)}c.ys=[];for(let v=0;v<f;v++){const m=c.flags[v],A=!!(32&m);4&m?(c.ys.push(A?r[a]:-r[a]),a++):A?c.ys.push(0):(c.ys.push(e.readShort(r,a)),a+=2)}let d=0,g=0;for(let v=0;v<f;v++)d+=c.xs[v],g+=c.ys[v],c.xs[v]=d,c.ys[v]=g}else c.parts=[],c.endPts=[],c.flags=[],c.xs=[],c.ys=[];return c}}},J={parse(o){const t=new Uint8Array(o);C.readASCII(t,0,4)==="wOFF"&&(o=Fe(o));const e=new Uint8Array(o),r=Dt,n={},h={Se:e,ze:0,ke:0};for(const a in r){const c=a,u=J.findTable(e,c,0);if(u){const[f,d]=u;let g=n[f];g==null&&(g=r[c].parseTab(e,f,d,h),n[f]=g),h[c]=g}}return[h]},findTable(o,t,e){const r=C,n=r.readUshort(o,e+4);let h=e+12;for(let a=0;a<n;a++){const c=r.readASCII(o,h,4);r.readUint(o,h+4);const u=r.readUint(o,h+8),f=r.readUint(o,h+12);if(c===t)return[u,f];h+=16}return null},T:Dt,B:C};class Ne{De(t){var r;const e=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(n=>{if(n.format===4){const h=this.Le(n);e.push(...h)}else if(n.format===12){const h=this.Oe(n);e.push(...h)}}),[...new Set(e)]):[]}Le(t){const e=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return e;for(let r=0;r<t.startCount.length;r++){const n=t.startCount[r],h=t.endCount[r];if(n!==65535||h!==65535){for(let a=n;a<=h;a++)if(this.Ie(t,a,r)>0)try{const c=String.fromCodePoint(a);e.push(c)}catch{}}}return e}Oe(t){const e=[];if(!t.groups)return e;for(let r=0;r<t.groups.length;r+=3){const n=t.groups[r],h=t.groups[r+1],a=t.groups[r+2];for(let c=n;c<=h;c++)if(a+(c-n)>0)try{const u=String.fromCodePoint(c);e.push(u)}catch{}}return e}Ie(t,e,r){if(t.idRangeOffset[r]===0)return e+t.idDelta[r]&65535;{const n=t.idRangeOffset[r]/2+(e-t.startCount[r])-(t.startCount.length-r);if(n>=0&&t.glyphIdArray&&n<t.glyphIdArray.length){const h=t.glyphIdArray[n];if(h!==0)return h+t.idDelta[r]&65535}}return 0}}class Ue{constructor(t){l(this,"Be");l(this,"He");l(this,"Z");this.Z=t,this.Be=document.createElement("canvas"),this.He=this.Be.getContext("2d",{willReadFrequently:!0,alpha:!0})}Ge(t,e,r,n){const h=t.length,a=Math.ceil(Math.sqrt(h)),c=Math.ceil(h/a),u=e.width*a,f=e.height*c;this.Qe(u,f),this.Ne(t,e,a,r,n);const d=this.Z.Pe(u,f,1,{filter:"nearest"});return d.et(this.Be),{framebuffer:d,columns:a,rows:c}}Qe(t,e){this.Be.width=t,this.Be.height=e,this.Be.style.width=t+"px",this.Be.style.height=e+"px",this.He.imageSmoothingEnabled=!1,this.Be.style.imageRendering="pixelated",this.He.clearRect(0,0,t,e),this.He.textBaseline="top",this.He.textAlign="left",this.He.fillStyle="white"}Ne(t,e,r,n,h){const a=n/h.head.unitsPerEm;for(let c=0;c<t.length;c++){const u=c%r,f=Math.floor(c/r),d=t[c].glyphData;if(!d)continue;const g=d.advanceWidth*a,v=u*e.width,m=f*e.height,A=v+.5*e.width,p=m+.5*e.height,y=Math.round(A-.5*e.width),E=Math.round(p-.5*n),w=y+.5*(e.width-g),x=E+h.hhea.ascender*a;this.je(d,w,x,a)}}je(t,e,r,n){if(!t||!t.xs||t.noc===0)return;let{xs:h,ys:a,endPts:c,flags:u}=t;if(!(h&&a&&c&&u))return;this.He.beginPath();let f=0;for(let d=0;d<c.length;d++){const g=c[d];if(!(g<f)){if(g>=f){const v=e+h[f]*n,m=r-a[f]*n;this.He.moveTo(v,m);let A=f+1;for(;A<=g;)if(1&u[A]){const p=e+h[A]*n,y=r-a[A]*n;this.He.lineTo(p,y),A++}else{const p=e+h[A]*n,y=r-a[A]*n;if(A+1>g){const w=e+h[f]*n,x=r-a[f]*n;if(1&u[f])this.He.quadraticCurveTo(p,y,w,x);else{const P=(p+w)/2,b=(y+x)/2;this.He.quadraticCurveTo(p,y,P,b)}break}const E=A+1;if(1&u[E]){const w=e+h[E]*n,x=r-a[E]*n;this.He.quadraticCurveTo(p,y,w,x),A=E+1}else{const w=(p+(e+h[E]*n))/2,x=(y+(r-a[E]*n))/2;this.He.quadraticCurveTo(p,y,w,x),A=E}}this.He.closePath()}f=g+1}}this.He.fill()}}class Lt{Xe(t,e){const r=t.cmap;if(!r||!r.tables)return 0;let n=0;for(const h of r.tables)if(h.format===4?n=this.Ye(e,h):h.format===12&&(n=this.We(e,h)),n>0)break;return n}Ke(t,e){const r=e.codePointAt(0);return r===void 0?0:this.Xe(t,r)}Ze(t,e){const r=t.hmtx;return r&&r.aWidth&&r.aWidth.length!==0?e<r.aWidth.length?r.aWidth[e]:r.aWidth[r.aWidth.length-1]:0}qe(t,e){const r=e/t.head.unitsPerEm,n=t.hhea.ascender*r,h=t.hhea.descender*r,a=t.hhea.lineGap*r;return{ascender:n,descender:h,lineGap:a,lineHeight:n-h+a,unitsPerEm:t.head.unitsPerEm,scale:r}}Ye(t,e){const r=e.endCount.length;let n=-1;for(let h=0;h<r;h++)if(t<=e.endCount[h]){n=h;break}if(n===-1||t<e.startCount[n])return 0;if(e.idRangeOffset[n]===0)return t+e.idDelta[n]&65535;{const h=e.idRangeOffset[n]/2+(t-e.startCount[n])-(r-n);if(h>=0&&h<e.glyphIdArray.length){const a=e.glyphIdArray[h];return a===0?0:a+e.idDelta[n]&65535}}return 0}We(t,e){const r=e.groups.length/3;for(let n=0;n<r;n++){const h=e.groups[3*n],a=e.groups[3*n+1],c=e.groups[3*n+2];if(t>=h&&t<=a)return c+(t-h)}return 0}}class Se{constructor(){l(this,"Ve");this.Ve=new Lt}Je(t,e,r){let n=0;const h=this.Ve.qe(r,e),a=h.lineHeight;for(const c of t){const u=this.Ve.Ke(r,c);if(u===0)continue;const f=this.Ve.Ze(r,u)*h.scale;n=Math.max(n,f)}return{width:Math.ceil(n),height:Math.ceil(a)}}}class De{constructor(){l(this,"tr");this.tr=new Lt}sr(t,e){const r=[],n=new Map;return t.forEach((h,a)=>{const c=h.codePointAt(0)||0,u={character:h,unicode:c,color:this.ir(a),glyphData:this.er(e,h)};r.push(u),n.set(h,u)}),{array:r,map:n}}ir(t){return[t%256/255,Math.floor(t/256)%256/255,0]}er(t,e){const r=e.codePointAt(0)||0,n=this.tr.Xe(t,r);if(n===0)return null;let h=0;t.hmtx&&t.hmtx.aWidth&&n>0&&t.hmtx.aWidth[n]!==void 0&&(h=t.hmtx.aWidth[n]);const a=J.T.glyf.Ee(t,n);return a?{...a,advanceWidth:h}:null}}class pt{constructor(t,e=16){l(this,"rr");l(this,"nr",[]);l(this,"hr",new Map);l(this,"ar");l(this,"cr",16);l(this,"lr",0);l(this,"ur",0);l(this,"dr",{width:0,height:0});l(this,"vr");l(this,"pr");l(this,"gr");l(this,"mr");l(this,"_r");this.cr=e,this.pr=new Ne,this.gr=new Ue(t),this.mr=new Se,this._r=new De}async yr(t){let e;if(t){const r=await fetch(t);if(!r.ok)throw new F(`Failed to load font file: ${r.status} ${r.statusText}`);e=await r.arrayBuffer()}else e=await(await fetch("data:font/woff;base64,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")).arrayBuffer();await this.Ar(e),this.rr=J.parse(e)[0],await this.br()}wr(t){if(t===void 0)return this.cr;this.cr=t,this.dr=this.mr.Je(this.nr.map(r=>r.character),this.cr,this.rr);const e=this.gr.Ge(this.nr,this.dr,this.cr,this.rr);this.ar=e.framebuffer,this.lr=e.columns,this.ur=e.rows}async Cr(t){try{const e=await fetch(t);if(!e.ok)throw new F(`Failed to load font file: ${e.status} ${e.statusText}`);const r=await e.arrayBuffer();await this.Ar(r);const n=J.parse(r);if(!n||n.length===0)throw Error("Failed to parse font file");this.rr=n[0],await this.br()}catch(e){throw new F("Failed to load font: "+(e instanceof Error?e.message:"Unknown error"),e)}}async Ar(t){const e=Date.now();this.vr=new FontFace("CustomFont_"+e,t),await this.vr.load(),document.fonts.add(this.vr)}async br(){const t=this.pr.De(this.rr),{array:e,map:r}=this._r.sr(t,this.rr);this.nr=e,this.hr=r,this.dr=this.mr.Je(t,this.cr,this.rr);const n=this.gr.Ge(this.nr,this.dr,this.cr,this.rr);this.ar=n.framebuffer,this.lr=n.columns,this.ur=n.rows}Mr(t){const e=this.hr.get(t);return e?e.color:[0,0,0]}Fr(t){return Array.from(t).map(e=>{const r=this.hr.get(e);return r?r.color:[0,0,0]})}gt(){this.ar.gt(),document.fonts.delete(this.vr)}get fontFramebuffer(){return this.ar}get characterMap(){return this.hr}get characters(){return this.nr}get textureColumns(){return this.lr}get textureRows(){return this.ur}get maxGlyphDimensions(){return this.dr}get fontSize(){return this.cr}get font(){return this.rr}}class At{constructor(t,e,r){l(this,"Pr");l(this,"$r");l(this,"N");l(this,"j");l(this,"Tr");l(this,"Rr");l(this,"Er");l(this,"Sr");l(this,"kr");this.Er=t,this.Sr=e,this.kr=r,this.ti()}ti(){this.Pr=Math.floor(this.Er.width/this.Sr),this.$r=Math.floor(this.Er.height/this.kr),this.N=this.Pr*this.Sr,this.j=this.$r*this.kr,this.Tr=Math.floor((this.Er.width-this.N)/2),this.Rr=Math.floor((this.Er.height-this.j)/2)}zr(t,e){this.Sr=t,this.kr=e,this.ti()}get cellWidth(){return this.Sr}get cellHeight(){return this.kr}get cols(){return this.Pr}get rows(){return this.$r}get width(){return this.N}get height(){return this.j}get offsetX(){return this.Tr}get offsetY(){return this.Rr}}const Le=/^rgba?\(([^)]+)\)$/i;function Et(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function _e(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t)return null;let e=null;return t.startsWith("rgb")&&(e=function(r){const n=Le.exec(r.trim());if(!n)return null;const h=n[1].split(",").map(d=>d.trim());if(h.length<3)return null;const a=Et(parseFloat(h[0])),c=Et(parseFloat(h[1])),u=Et(parseFloat(h[2])),f=h[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(h[3]))):255;return[a,c,u,Math.round(f)]}(t)),e?e[3]===0?null:e:null}class _t{constructor(t={}){l(this,"Er");l(this,"Dr",null);l(this,"Lr",!1);l(this,"Or");this.Lr=t.overlay??!1,this.Lr&&t.canvas?(this.Dr=t.canvas,this.Er=this.Ir(),this.Or=!0,this.Br()):t.canvas?(this.Er=t.canvas,this.Or=!1):(this.Er=this.Hr(t.width,t.height),this.Or=!0),this.Er.style.imageRendering="pixelated"}Hr(t,e){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=e||600,document.body.appendChild(r),r}Ir(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const e=this.Dr.getBoundingClientRect();let r=Math.round(e.width),n=Math.round(e.height);if(this.Dr instanceof HTMLVideoElement){const c=this.Dr;(r===0||n===0)&&c.videoWidth>0&&c.videoHeight>0&&(r=c.videoWidth,n=c.videoHeight)}t.width=r,t.height=n,t.style.position="absolute",t.style.pointerEvents="none";const h=window.getComputedStyle(this.Dr);let a=parseInt(h.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=""+(a+1),t}Br(){var t;this.Gr(),(t=this.Dr.parentNode)==null||t.insertBefore(this.Er,this.Dr.nextSibling)}Qr(){const t=[];return this.Lr&&this.Dr instanceof HTMLElement&&(t.push(this.Dr),this.Dr.parentElement&&t.push(this.Dr.parentElement)),this.Er.parentElement&&t.push(this.Er.parentElement),t.push(this.Er),t.push(document.body),t.push(document.documentElement),t}Nr(){const t=this.Qr();for(const e of t){if(!e)continue;const r=_e(window.getComputedStyle(e).backgroundColor);if(r)return r}return[255,255,255,255]}Gr(){if(!this.Dr)return;const t=this.Dr.getBoundingClientRect();let e=this.Dr.offsetParent;if(e&&e!==document.body){const r=e.getBoundingClientRect();this.Er.style.top=t.top-r.top+"px",this.Er.style.left=t.left-r.left+"px"}else this.Er.style.top=t.top+window.scrollY+"px",this.Er.style.left=t.left+window.scrollX+"px"}jr(t,e){if(this.Lr){const r=this.Dr.getBoundingClientRect();this.Er.width=Math.round(r.width),this.Er.height=Math.round(r.height),this.Gr()}else this.Er.width=t??this.Er.width,this.Er.height=e??this.Er.height}Xr(){const t=this.Er.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new F("`textmode.js` requires WebGL2 support.");return t}gt(){const t=this.Er.getContext("webgl")||this.Er.getContext("webgl2");if(t){const e=t.getExtension("WEBGL_lose_context");e==null||e.loseContext()}this.Or&&this.Er.parentNode&&this.Er.parentNode.removeChild(this.Er)}get canvas(){return this.Er}get targetCanvas(){return this.Dr}get width(){return this.Er.width}get height(){return this.Er.height}}function ht(o){return Y(parseInt(o,16),0,255)}class U{constructor(t,e,r,n){l(this,"Yr");l(this,"Wr");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=Y(t,0,255),this.g=Y(e,0,255),this.b=Y(r,0,255),this.a=Y(n,0,255),this.Yr=[this.r,this.g,this.b,this.a],this.Wr=[this.r/255,this.g/255,this.b/255,this.a/255]}static Kr(t,e,r,n){if(U.Zr(t))return t;if(Array.isArray(t)){if(t.length<3)throw Error("Component tuples must include at least RGB values.");const[h,a,c]=t,u=t.length===4?t[3]:255;return U.qr(h,a,c,u)}if(typeof t=="string"){const h=t.trim();if(h.length===0)throw Error("Color strings cannot be empty.");return U.Vr(h)}if(typeof t=="number")return typeof e=="number"&&typeof r=="number"?U.qr(t,e,r,n??255):U.Jr(t);throw Error("Unsupported color input passed to TextmodeColor.$from.")}static qr(t,e,r,n=255){return new U(t,e,r,n)}static Jr(t,e=255){return new U(t,t,t,e)}static Vr(t){return new U(...function(e){const r=e.replace(/^#|0x/gi,""),n=(h=r).length===3||h.length===4?h.split("").map(a=>a+a).join(""):h;var h;if(n.length!==6&&n.length!==8)throw Error("Invalid hex color: "+e);return[ht(n.slice(0,2)),ht(n.slice(2,4)),ht(n.slice(4,6)),n.length===8?ht(n.slice(6,8)):255]}(t))}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.Yr]}get normalized(){return[...this.Wr]}withAlpha(t){return new U(this.r,this.g,this.b,t)}static Zr(t){return t instanceof U}}const yt=new Map;function Bt(o){yt.set(o.id,o)}function Xt(o){return yt.get(o)}class Zt{constructor(t,e,r,n,h,a,c,u){l(this,"A");l(this,"Z");l(this,"tn");l(this,"sn");l(this,"en");l(this,"N");l(this,"j");l(this,"q",null);l(this,"rr");l(this,"rn","brightness");l(this,"nn",null);l(this,"Rt",0);l(this,"Gt",0);l(this,"Qt",0);l(this,"Et",0);l(this,"hn","sampled");l(this,"an","fixed");l(this,"jt",[1,1,1,1]);l(this,"Xt",[0,0,0,1]);l(this,"cn",[0,0,0,1]);l(this,"ln",[[.1,0,0]]);l(this,"un",null);l(this,"fn",new Set);l(this,"dn",[[0,0,0,0]]);l(this,"vn",0);this.A=t,this.Z=e,this.tn=r,this.rr=n,this.sn=h,this.en=a,this.N=c,this.j=u}conversionMode(t){return this.rn=t,this.nn=null,this.q=null,this}gt(){this.A.deleteTexture(this.tn);for(const t of this.fn)t();this.fn.clear()}pn(t){this.fn.add(t)}invert(t=!0){return this.Rt=t?1:0,this.q=null,this}flipX(t=!0){return this.Gt=t?1:0,this.q=null,this}flipY(t=!0){return this.Qt=t?1:0,this.q=null,this}charRotation(t){return this.Et=Ft(t),this.q=null,this}charColorMode(t){return this.hn=t,this.q=null,this}cellColorMode(t){return this.an=t,this.q=null,this}charColor(t,e,r,n){return this.gn(this.jt,t,e,r,n),this.q=null,this}cellColor(t,e,r,n){return this.gn(this.Xt,t,e,r,n),this.q=null,this}background(t,e,r,n){return this.gn(this.cn,t,e,r,n),this.q=null,this}colorFilter(t){if(!t||t.length===0)return this.vn=0,this.dn=[[0,0,0,0]],this.q=null,this;const e=[];for(const r of t){if(e.length>=64)break;let n=U.Kr(r);e.push(n.normalized)}return this.dn=e,this.vn=e.length,this.q=null,this}characters(t){return this.un=t,this.mn(t),this.q=null,this}_n(t){this.rr=t,this.un&&this.mn(this.un),this.q=null}get texture(){return this.tn}get width(){return this.N}get height(){return this.j}get originalWidth(){return this.sn}get originalHeight(){return this.en}ut(){return this.q||this.ft(),this.q}yn(){}ft(){this.yn();const t=this.An(),e=this.bn(),r=t.createShader(e),n=t.createUniforms(e);this.q=this.Z.materialManager.Ni(r,n)}gn(t,e,r,n,h){const a=U.Kr(e,r,n,h);it(t,a.r,a.g,a.b,a.a)}mn(t){const e=this.rr.Fr(t).filter(r=>Array.isArray(r)).slice(0,255);this.ln=e.length>0?e:this.ln}createBaseConversionUniforms(){const t=this.vn>0;return{u_image:this.wn(),u_invert:!!this.Rt,u_flipX:!!this.Gt,u_flipY:!!this.Qt,u_charRotation:this.Et,u_charColorFixed:this.hn==="fixed",u_charColor:this.jt,u_cellColorFixed:this.an==="fixed",u_cellColor:this.Xt,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}}An(){if(this.nn&&this.nn.id===this.rn)return this.nn;const t=Xt(this.rn);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.`);return this.nn=t,t}bn(){return{renderer:this.Z,gl:this.A,font:this.rr,source:this,gridWidth:this.N,gridHeight:this.j}}}class V extends Zt{constructor(t,e,r,n,h,a,c,u){const f=Math.min(c/h,u/a);super(t,e,r,n,h,a,Math.max(1,Math.floor(h*f)),Math.max(1,Math.floor(a*f)))}static Cn(t,e,r,n,h){const a=t.context,c=a.createTexture();a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),tt(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,r),a.bindTexture(a.TEXTURE_2D,null);const u=r.naturalWidth??r.width??r.videoWidth??0,f=r.naturalHeight??r.height??r.videoHeight??0;return new V(a,t,c,e,u,f,n,h)}wn(){return this.tn}}class Ot{constructor(t=60){l(this,"xn");l(this,"Mn",null);l(this,"Fn",0);l(this,"Pn",!0);l(this,"$n",0);l(this,"Tn",0);l(this,"Rn",[]);l(this,"En",10);l(this,"Sn",0);this.xn=1e3/t}kn(t){if(!this.Pn)return;this.Fn=performance.now();const e=r=>{if(!this.Pn)return void(this.Mn=null);const n=r-this.Fn;n>=this.xn&&(t(),this.Fn=r-n%this.xn),this.Pn&&(this.Mn=requestAnimationFrame(e))};this.Mn=requestAnimationFrame(e)}zn(){this.Mn&&(cancelAnimationFrame(this.Mn),this.Mn=null)}Dn(){this.Pn&&(this.Pn=!1,this.zn())}Ln(t){this.Pn||(this.Pn=!0,this.kn(t))}On(t,e){if(t===void 0)return this.$n;this.xn=1e3/t,this.Pn&&e&&(this.zn(),this.kn(e))}In(){const t=performance.now();if(this.Tn>0){const e=t-this.Tn;this.Rn.push(e),this.Rn.length>this.En&&this.Rn.shift();const r=this.Rn.reduce((n,h)=>n+h,0)/this.Rn.length;this.$n=1e3/r}this.Tn=t}get Bn(){return this.Pn}get Hn(){return this.$n}get Gn(){return this.Sn}set Gn(t){this.Sn=t}Qn(){this.Sn++}}class It{constructor(t){l(this,"Er");l(this,"Nn");l(this,"jn",{x:-1,y:-1});l(this,"Xn",{x:-1,y:-1});l(this,"Yn",null);l(this,"Wn",0);l(this,"Kn");l(this,"Zn");l(this,"qn");l(this,"Vn");l(this,"Jn");l(this,"th");l(this,"sh",!1);l(this,"ih");l(this,"eh");l(this,"rh");l(this,"nh");l(this,"hh");this.Er=t}oh(t){const e=performance.now()+Math.max(0,t);e>this.Wn&&(this.Wn=e)}ah(){return performance.now()<this.Wn}uh(t){const e=this.Er.canvas;e.style.cursor=t==null||t===""?"":t}yr(t){this.Nn=t,this.fh()}dh(){if(this.sh)return;const t=this.Er.canvas;this.Kn=e=>{this.ph(e),this.gh(e)},this.Zn=()=>{this.Xn={...this.jn},this.jn.x=-1,this.jn.y=-1,this.Yn=null},this.qn=e=>{this.ph(e),this.mh(e)},this.Vn=e=>{this.ph(e),this._h(e)},this.Jn=e=>{this.ph(e),this.yh(e)},this.th=e=>{this.ph(e),this.Ah(e)},t.addEventListener("mousemove",this.Kn,{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.th,{passive:!1}),this.sh=!0}bh(){if(!this.sh)return;const t=this.Er.canvas;t.removeEventListener("mousemove",this.Kn),t.removeEventListener("mouseleave",this.Zn),t.removeEventListener("mousedown",this.qn),t.removeEventListener("mouseup",this.Vn),t.removeEventListener("click",this.Jn),t.removeEventListener("wheel",this.th),this.sh=!1}fh(){if(this.sh)try{if(this.Yn){const t=new MouseEvent("mousemove",{clientX:this.Yn.x,clientY:this.Yn.y,bubbles:!1,cancelable:!1});this.ph(t)}else this.jn.x!==-1&&this.jn.y!==-1&&(this.jn.x>=this.Nn.cols||this.jn.y>=this.Nn.rows)&&(this.jn.x=-1,this.jn.y=-1)}catch{this.jn.x=-1,this.jn.y=-1}}wh(t){this.ih=t}Ch(t){this.eh=t}xh(t){this.rh=t}Mh(t){this.nh=t}Fh(t){this.hh=t}Ph(){return{x:this.jn.x,y:this.jn.y}}gh(t){if(this.nh&&!this.ah()){const e={position:{...this.jn},previousPosition:{...this.Xn},originalEvent:t};this.nh(e)}}mh(t){if(this.eh&&!this.ah()){const e={position:{...this.jn},previousPosition:{...this.Xn},button:t.button,originalEvent:t};this.eh(e)}}_h(t){if(this.rh&&!this.ah()){const e={position:{...this.jn},previousPosition:{...this.Xn},button:t.button,originalEvent:t};this.rh(e)}}yh(t){if(this.ih&&!this.ah()){const e={position:{...this.jn},previousPosition:{...this.Xn},button:t.button,originalEvent:t};this.ih(e)}}Ah(t){if(this.hh&&!this.ah()){const e={position:{...this.jn},previousPosition:{...this.Xn},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.hh(e)}}ph(t){const e=this.Er.canvas;this.Xn={...this.jn},this.Yn={x:t.clientX,y:t.clientY};const r=e.getBoundingClientRect(),n=t.clientX-r.left,h=t.clientY-r.top,a=e.width/r.width,c=h*(e.height/r.height),u=n*a-this.Nn.offsetX,f=c-this.Nn.offsetY,d=Math.floor(u/this.Nn.cellWidth),g=Math.floor(f/this.Nn.cellHeight);d>=0&&d<this.Nn.cols&&g>=0&&g<this.Nn.rows?(this.jn.x=d,this.jn.y=g):(this.jn.x=-1,this.jn.y=-1)}}const Be=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:It},Symbol.toStringTag,{value:"Module"}));class Yt{constructor(){l(this,"$h",new Map);l(this,"Th",null);l(this,"Rh",null);l(this,"Eh");l(this,"Sh");l(this,"sh",!1);l(this,"kh");l(this,"zh");l(this,"Dh",{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"})}dh(){this.sh||(this.Eh=t=>{this.Lh(t)},this.Sh=t=>{this.Oh(t)},window.addEventListener("keydown",this.Eh,{passive:!1}),window.addEventListener("keyup",this.Sh,{passive:!1}),this.sh=!0)}bh(){this.sh&&(window.removeEventListener("keydown",this.Eh),window.removeEventListener("keyup",this.Sh),this.sh=!1,this.$h.clear(),this.Th=null,this.Rh=null)}Ch(t){this.kh=t}xh(t){this.zh=t}Ih(t){const e=this.Bh(t),r=this.$h.get(t)||this.$h.get(e);return(r==null?void 0:r.isPressed)||!1}Hh(){return this.Th}Gh(){return this.Rh}Qh(){const t=[];for(const[e,r]of this.$h)r.isPressed&&t.push(e);return t}Nh(){return{ctrl:this.Ih("Control"),shift:this.Ih("Shift"),alt:this.Ih("Alt"),meta:this.Ih("Meta")}}jh(){this.$h.clear(),this.Th=null,this.Rh=null}Lh(t){const e=t.key,r=Date.now();this.$h.has(e)||this.$h.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.$h.get(e);if(!n.isPressed&&(n.isPressed=!0,n.lastPressTime=r,this.Th=e,this.kh)){const h={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.kh(h)}}Oh(t){const e=t.key,r=Date.now();this.$h.has(e)||this.$h.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.$h.get(e);if(n.isPressed=!1,n.lastReleaseTime=r,this.Rh=e,this.zh){const h={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.zh(h)}}Bh(t){return this.Dh[t]||t.toLowerCase()}}const Xe=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:Yt},Symbol.toStringTag,{value:"Module"}));class zt{constructor(t,e){l(this,"Er");l(this,"Xh");l(this,"Nn");l(this,"Yh",new Map);l(this,"Wh",new Map);l(this,"Kh",new Map);l(this,"Zh",null);l(this,"qh");l(this,"Vh");l(this,"Jh");l(this,"so");l(this,"io");l(this,"eo");l(this,"sh",!1);l(this,"ro");l(this,"no");l(this,"ho");l(this,"oo");l(this,"ao");l(this,"co");l(this,"lo");l(this,"uo");l(this,"fo");l(this,"do");l(this,"vo",320);l(this,"po",350);l(this,"mo",10);l(this,"_o",550);l(this,"yo",14);l(this,"Ao",48);l(this,"bo",650);l(this,"wo",.02);l(this,"Co",2);l(this,"xo",600);l(this,"Mo",0);l(this,"Fo",null);this.Er=t,this.Xh=e;const r=this.Er.canvas;this.qh=r.style.touchAction,this.Vh=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}yr(t){this.Nn=t,this.fh()}dh(){if(this.sh)return;const t=this.Er.canvas;this.Jh=e=>{this.Po(e)},this.so=e=>{this.$o(e)},this.io=e=>{this.To(e)},this.eo=e=>{this.Ro(e)},t.addEventListener("touchstart",this.Jh,{passive:!1}),t.addEventListener("touchmove",this.so,{passive:!1}),t.addEventListener("touchend",this.io,{passive:!1}),t.addEventListener("touchcancel",this.eo,{passive:!1}),this.sh=!0}bh(){if(!this.sh)return;const t=this.Er.canvas;t.removeEventListener("touchstart",this.Jh),t.removeEventListener("touchmove",this.so),t.removeEventListener("touchend",this.io),t.removeEventListener("touchcancel",this.eo),this.sh=!1,this.Zh=null,this.Yh.clear(),this.Wh.clear(),this.Kh.forEach(e=>{e.longPressTimer!==null&&window.clearTimeout(e.longPressTimer)}),this.Kh.clear(),this.Fo=null,this.Mo=0,t.style.touchAction=this.qh,t.style.userSelect=this.Vh}fh(){if(!this.Nn||this.Yh.size===0)return;const t=new Map;for(const e of this.Yh.values()){const r=this.Eo(e.clientX,e.clientY,e.id,e);t.set(e.id,r)}this.Yh=t}So(){return Array.from(this.Yh.values()).map(t=>({...t}))}ko(t){this.ro=t}Mh(t){this.no=t}zo(t){this.ho=t}Do(t){this.oo=t}Lo(t){this.ao=t}Oo(t){this.co=t}Io(t){this.lo=t}Bo(t){this.uo=t}Ho(t){this.fo=t}Go(t){this.do=t}Po(t){var n;if(!this.Nn)return;t.preventDefault(),(n=this.Xh)==null||n.oh(this.xo);const e=performance.now(),r=this.Qo(t.changedTouches);for(const h of r){const a=this.Yh.get(h.id);a&&this.Wh.set(h.id,this.No(a)),this.Yh.set(h.id,h);const c={id:h.id,startPosition:h,lastPosition:h,startTime:e,lastTime:e,longPressTimer:null,longPressFired:!1};this.lo&&(c.longPressTimer=window.setTimeout(()=>{const u=this.Yh.get(h.id);u&&(c.longPressFired=!0,this.lo({touch:this.No(u),duration:performance.now()-c.startTime,originalEvent:t}))},this._o)),this.Kh.set(h.id,c),this.ro&&this.ro(this.jo(h,t,void 0,e))}this.Yh.size===2&&this.Xo()}$o(t){var n;if(!this.Nn)return;t.preventDefault(),(n=this.Xh)==null||n.oh(this.xo);const e=performance.now(),r=this.Qo(t.changedTouches);for(const h of r){const a=this.Yh.get(h.id),c=a?this.No(a):void 0;c&&this.Wh.set(h.id,c),this.Yh.set(h.id,h);const u=this.Kh.get(h.id);u&&(u.lastPosition=h,u.lastTime=e,c)&&W(c.clientX,c.clientY,h.clientX,h.clientY)>this.yo&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.no&&this.no(this.jo(h,t,c,e))}this.Yh.size===2?this.Yo(t):this.Zh=null}To(t){if(!this.Nn)return;t.preventDefault();const e=performance.now(),r=this.Qo(t.changedTouches);for(const n of r){const h=this.Yh.get(n.id),a=h?this.No(h):void 0,c=this.Kh.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.ho&&this.ho(this.jo(n,t,a,e)),c&&this.Wo(c,t),this.Kh.delete(n.id),this.Wh.delete(n.id),this.Yh.delete(n.id)}this.Yh.size<2&&(this.Zh=null)}Ro(t){if(!this.Nn)return;t.preventDefault();const e=performance.now(),r=this.Qo(t.changedTouches);for(const n of r){const h=this.Yh.get(n.id),a=h?this.No(h):void 0,c=this.Kh.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.oo&&this.oo(this.jo(n,t,a,e)),this.Kh.delete(n.id),this.Wh.delete(n.id),this.Yh.delete(n.id)}this.Yh.size<2&&(this.Zh=null)}Qo(t){const e=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&e.push(this.Ko(n))}return e}Ko(t){return this.Eo(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})}Eo(t,e,r,n){const h=this.Er.canvas,a=h.getBoundingClientRect(),c=t-a.left,u=e-a.top,f=h.width/a.width,d=u*(h.height/a.height),g=c*f-this.Nn.offsetX,v=d-this.Nn.offsetY,m=Math.floor(g/this.Nn.cellWidth),A=Math.floor(v/this.Nn.cellHeight),p=m>=0&&m<this.Nn.cols&&A>=0&&A<this.Nn.rows;return{id:r,x:p?m:-1,y:p?A:-1,clientX:t,clientY:e,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}jo(t,e,r,n){const h=this.Kh.get(t.id),a=Array.from(this.Wh.values()).map(f=>this.No(f)),c=Array.from(this.Yh.values()).map(f=>this.No(f)),u=this.Qo(e.changedTouches);return{touch:this.No(t),previousTouch:r?this.No(r):void 0,touches:c,previousTouches:a,changedTouches:u,deltaTime:h?n-h.lastTime:0,originalEvent:e}}Xo(){if(this.Yh.size!==2)return void(this.Zh=null);const t=Array.from(this.Yh.values()),[e,r]=t,n=W(e.x,e.y,r.x,r.y),h=Tt(e.clientX,e.clientY,r.clientX,r.clientY);this.Zh={ids:[e.id,r.id],initialDistance:Math.max(n,1e-4),initialAngle:h,lastScale:1,lastRotation:0}}Yo(t){if(this.Zh||this.Xo(),!this.Zh)return;const[e,r]=this.Zh.ids,n=this.Yh.get(e),h=this.Yh.get(r);if(!n||!h)return;const a=W(n.x,n.y,h.x,h.y)/this.Zh.initialDistance,c=a-this.Zh.lastScale;this.fo&&Math.abs(c)>this.wo&&(this.fo({touches:[this.No(n),this.No(h)],scale:a,deltaScale:c,center:this.Zo(n,h),originalEvent:t}),this.Zh.lastScale=a);let u=Tt(n.clientX,n.clientY,h.clientX,h.clientY)-this.Zh.initialAngle;u=(u+180)%360-180;const f=u-this.Zh.lastRotation;this.do&&Math.abs(f)>this.Co&&(this.do({touches:[this.No(n),this.No(h)],rotation:u,deltaRotation:f,center:this.Zo(n,h),originalEvent:t}),this.Zh.lastRotation=u)}Zo(t,e){const r=(t.clientX+e.clientX)/2,n=(t.clientY+e.clientY)/2,h=this.Eo(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:h.x,y:h.y}}Wo(t,e){const r=performance.now(),n=r-t.startTime,h=W(t.startPosition.clientX,t.startPosition.clientY,t.lastPosition.clientX,t.lastPosition.clientY);if(!t.longPressFired&&n<=this.vo&&h<=this.mo)this.qo(t.lastPosition,r)&&this.co?this.co({touch:this.No(t.lastPosition),taps:2,originalEvent:e}):this.ao&&this.ao({touch:this.No(t.lastPosition),taps:1,originalEvent:e});else if(!t.longPressFired&&n<=this.bo&&h>=this.Ao){const a={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},f={x:a.x/n,y:a.y/n};this.uo&&this.uo({touch:this.No(t.lastPosition),direction:u,distance:c,velocity:f,originalEvent:e})}this.Mo=r,this.Fo=this.No(t.lastPosition)}qo(t,e){return!!this.Fo&&!(e-this.Mo>this.po)&&W(t.clientX,t.clientY,this.Fo.clientX,this.Fo.clientY)<=this.mo}No(t){return{...t}}}const Ze=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:zt},Symbol.toStringTag,{value:"Module"}));class Oe{constructor(t,e){l(this,"A");l(this,"Vo");l(this,"$n",null);l(this,"Jo",0);l(this,"ta",!1);l(this,"sa",[]);l(this,"ia",-1);this.A=t,this.Vo=e}get isPreloaded(){return this.ta}get totalFrames(){return this.Jo}get frameRate(){return this.$n}get textures(){return this.sa}dispose(){this.ea(),this.sa=[],this.$n=null,this.Jo=0,this.ta=!1,this.ia=-1}async preload(t,e){var r;try{if(t<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Vo.duration;if(!isFinite(n)||n<=0)throw Error("Video duration is invalid, cannot preload frames.");const h=Math.max(1,Math.ceil(n*t));return this.ra(t,h),await this.na(t,e)?(this.ha("captureStream",e),"captureStream"):(await this.oa(t,e),this.ha("seeking",e),"seeking")}catch(n){const h=n instanceof Error?n:Error(n+"");throw(r=e==null?void 0:e.onError)==null||r.call(e,h),this.dispose(),h}}ra(t,e){this.ea(),this.$n=t,this.Jo=e,this.sa=[],this.ta=!1,this.ia=-1}ha(t,e){var r;if(this.sa.length===0)throw Error(`Video preload via ${t} completed but produced 0 frames.`);this.Jo=this.sa.length,this.ta=!0,this.ia=-1,this.Vo.pause(),this.Vo.currentTime=0,e!=null&&e.onProgress&&e.onProgress({percent:100,loadedFrames:this.Jo,totalFrames:this.Jo,strategy:t}),(r=e==null?void 0:e.onComplete)==null||r.call(e,{totalFrames:this.Jo,strategy:t})}aa(t){const e=this.A,r=e.createTexture();return e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),tt(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),r}ca(t,e){if(!(e!=null&&e.onProgress)||this.Jo===0)return;const r=Math.min(99,Math.floor(this.sa.length/this.Jo*100)),n=10*Math.floor(r/10);n>this.ia&&(this.ia=n,e.onProgress({percent:r,loadedFrames:this.sa.length,totalFrames:this.Jo,strategy:t}))}async na(t,e){const r=globalThis,n=r==null?void 0:r.MediaStreamTrackProcessor,h=this.Vo.captureStream;if(typeof n!="function"||typeof h!="function")return!1;let a,c=null;try{const u=h.call(this.Vo);if(a=u.getVideoTracks()[0],!a)return u.getTracks().forEach(g=>g.stop()),!1;if(c=new n({track:a}).readable.getReader(),this.Vo.currentTime=0,this.Vo.muted=!0,await this.Vo.play().catch(()=>{}),this.Vo.paused)return!1;const f=1e6/t;let d=0;for(;this.sa.length<this.Jo;){const g=await c.read();if(g.done)break;const v=g.value;if(v)try{const m=typeof v.timestamp=="number"?v.timestamp:d;(this.sa.length===0||m>=d)&&(this.sa.push(this.aa(v)),d=m+f,this.ca("captureStream",e))}finally{v.close()}}return c.releaseLock(),a.stop(),c=null,a=void 0,this.Vo.pause(),this.Vo.currentTime=0,this.sa.length!==0}catch{return this.ea(),this.sa=[],this.ia=-1,!1}finally{if(c)try{await c.cancel()}catch{}a&&a.stop(),this.Vo.pause(),this.Vo.currentTime=0}}async oa(t,e){const r=1/t,n=this.Jo,h=this.Vo;h.pause();for(let a=0;a<n;a++){const c=Math.min(h.duration,a*r);await this.la(c),this.sa.push(this.aa(h)),this.ca("seeking",e)}h.currentTime=0}la(t){return new Promise((e,r)=>{const n=this.Vo,h=()=>{n.removeEventListener("seeked",a),n.removeEventListener("error",c)},a=()=>{h(),e()},c=()=>{h(),r(Error("Video seek failed while preloading frames."))};n.addEventListener("seeked",a,{once:!0}),n.addEventListener("error",c,{once:!0});const u=isFinite(n.duration)?n.duration:t,f=Math.min(Math.max(t,0),u);if(Math.abs(n.currentTime-f)<1e-4)return h(),void e();n.currentTime=f})}ea(){for(const t of this.sa)this.A.deleteTexture(t)}}class ot extends Zt{constructor(e,r,n,h,a,c,u,f,d){const g=c/u;let v,m;g>1?(v=f,m=Math.round(f/g)):(m=d,v=Math.round(d*g));super(e,r,n,h,c,u,v,m);l(this,"Vo");l(this,"ua",0);l(this,"fa",null);this.Vo=a}gt(){var e;super.gt(),(e=this.fa)==null||e.dispose(),this.fa=null,this.Vo.pause(),this.Vo.src="",this.Vo.load()}da(){var e;if(!((e=this.fa)!=null&&e.isPreloaded)&&this.Vo.readyState>=this.Vo.HAVE_CURRENT_DATA){const r=this.A;r.bindTexture(r.TEXTURE_2D,this.tn),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.Vo),r.bindTexture(r.TEXTURE_2D,null)}}wn(){var r,n;const e=(r=this.fa)==null?void 0:r.textures;return e&&e.length>0&&((n=this.fa)!=null&&n.isPreloaded)?e[this.ua%e.length]:this.tn}ut(){return this.q=null,super.ut()}yn(){this.da()}frame(e){var n,h;const r=((n=this.fa)==null?void 0:n.totalFrames)??0;return(h=this.fa)!=null&&h.isPreloaded&&e!==void 0&&r>0&&(this.ua=(e%r+r)%r,this.q=null),this}static async Cn(e,r,n,h,a,c){const u=e.context,f=c==null?void 0:c.frameRate;let d;d=document.createElement("video"),d.crossOrigin="anonymous",d.loop=!0,d.muted=!0,d.playsInline=!0,await new Promise((p,y)=>{d.addEventListener("loadedmetadata",()=>p(),{once:!0}),d.addEventListener("error",E=>{var x;const w=E.target;y(Error("Failed to load video: "+(((x=w.error)==null?void 0:x.message)||"Unknown error")))},{once:!0}),d.src=n});const g=u.createTexture();u.bindTexture(u.TEXTURE_2D,g),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),tt(u,u.LINEAR,u.LINEAR,u.CLAMP_TO_EDGE,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,d),u.bindTexture(u.TEXTURE_2D,null);const v=d.videoWidth,m=d.videoHeight,A=new ot(u,e,g,r,d,v,m,h,a);return f&&f>0&&(A.fa=new Oe(u,d),await A.fa.preload(f,c),A.ua=0),A}async play(){await this.Vo.play()}pause(){this.Vo.pause()}stop(){this.Vo.pause(),this.Vo.currentTime=0}speed(e){return this.Vo.playbackRate=e,this}loop(e=!0){return this.Vo.loop=e,this}time(e){return this.Vo.currentTime=e,this}volume(e){return this.Vo.volume=Math.max(0,Math.min(1,e)),this}get texture(){return this.tn}get width(){return this.N}get height(){return this.j}get originalWidth(){return this.sn}get originalHeight(){return this.en}get videoElement(){return this.Vo}get currentTime(){return this.Vo.currentTime}get duration(){return this.Vo.duration}get isPlaying(){return!this.Vo.paused&&!this.Vo.ended}get totalFrames(){var e;return((e=this.fa)==null?void 0:e.totalFrames)??0}}const Ie=o=>class extends o{va(t,e,r,n){if(U.Zr(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,e,r,n);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,e=0,r=0){this.Z.state.Vt(t),this.Z.state.Jt(e),this.Z.state.ts(r)}rotateX(t){this.Z.state.Vt(t)}rotateY(t){this.Z.state.Jt(t)}rotateZ(t){this.Z.state.ts(t)}translate(t=0,e=0,r=0){this.Z.state.ss(t,e,r)}translateX(t){this.Z.state.ss(t,0,0)}translateY(t){this.Z.state.ss(0,t,0)}translateZ(t){this.Z.state.ss(0,0,t)}push(){this.Z.state.ht()}pop(){this.Z.state.ot()}color(t,e,r,n){return U.Kr(t,e,r,n)}rect(t=1,e=1){this.Z.be(t,e)}point(){this.Z.be(1,1)}line(t,e,r,n){this.Z.we(t,e,r,n)}lineWeight(t){this.Z.state.Zt(t)}background(t,e,r,n=255){const h=this.va(t,e,r,n);this.Z.$e(h.r,h.g,h.b,h.a)}char(t){const e=Array.from(t);if(e.length===0)throw Error("char() requires at least one character.");this.Z.state.hs(this.rr.Mr(e[0]))}charColor(t,e,r,n){const h=this.va(t,e,r,n);this.Z.state.cs(h.r,h.g,h.b,h.a)}cellColor(t,e,r,n){const h=this.va(t,e,r,n);this.Z.state.ls(h.r,h.g,h.b,h.a)}flipX(t){this.Z.state.us(t)}flipY(t){this.Z.state.fs(t)}charRotation(t){this.Z.state.vs(t)}invert(t){this.Z.state.ds(t)}clear(){this.Z.bi(0,0,0,0)}ellipse(t,e){this.Z.Ce(t/2,e/2)}triangle(t,e,r,n,h,a){this.Z.xe(t,e,r,n,h,a)}bezierCurve(t,e,r,n,h,a,c,u){this.Z.Me(t,e,r,n,h,a,c,u)}arc(t,e,r,n){this.Z.Fe(t/2,e/2,r,n)}shader(t){this.Z.ge(t)}setUniform(t,e){this.Z.I(t,e)}setUniforms(t){this.Z.me(t)}async createFilterShader(t){if(typeof t=="string"&&(t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const e=await fetch(t);if(!e.ok)throw Error(`Failed to load shader from ${t}: ${e.statusText}`);const r=await e.text();return this.Z._e(r)}return this.Z._e(t)}createFramebuffer(t){return this.Z.Pe(t.width??this.grid.cols,t.height??this.grid.rows,t.attachments??3)}image(t,e,r){this.Z.ye(t,e,r),t instanceof z&&this.Z.ct()}ortho(){this.Z.state.gs(!0)}async loadImage(t){if(typeof t!="string"){const h=V.Cn(this.Z,this.rr,t,this.Nn.cols,this.Nn.rows);return this.pa(h),h}const e=t,r=await new Promise((h,a)=>{const c=new Image;c.crossOrigin="anonymous",c.onload=()=>h(c),c.onerror=u=>a(u),c.src=e}),n=V.Cn(this.Z,this.rr,r,this.Nn.cols,this.Nn.rows);return this.pa(n),n}async loadVideo(t,e){const r=await ot.Cn(this.Z,this.rr,t,this.Nn.cols,this.Nn.rows,e);return this.pa(r),r}},Ye=o=>class extends o{async loadFont(t){return this.rr.Cr(t).then(()=>{const e=this.rr.maxGlyphDimensions;this.Nn.zr(e.width,e.height),this.ga.resize(this.Nn.cols,this.Nn.rows),this.ma.jr(),this.Z.Re(),this.Xh.fh(),this._a.fh();for(const r of this.ya)r._n(this.rr)})}fontSize(t){if(!ut.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;this.rr.wr(t);const e=this.rr.maxGlyphDimensions;this.Nn.zr(e.width,e.height),this.ga.resize(this.Nn.cols,this.Nn.rows),this.ma.jr(),this.Z.Re(),this.Xh.fh(),this._a.fh()}},ze=o=>class extends o{get frameCount(){return this.ba.Gn}set frameCount(t){this.ba.Gn=t}frameRate(t){return t===void 0?this.ba.Hn:this.ba.On(t,()=>this.wa())}noLoop(){this.ba.Dn()}loop(){this.ba.Ln(()=>this.wa())}redraw(t=1){if(ut.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()}isLooping(){return this.ba.Bn}},je=o=>class extends o{constructor(...t){super(...t)}mouseClicked(t){this.Xh.wh(t)}mousePressed(t){this.Xh.Ch(t)}mouseReleased(t){this.Xh.xh(t)}mouseMoved(t){this.Xh.Mh(t)}mouseScrolled(t){this.Xh.Fh(t)}get mouse(){return this.Xh.Ph()}cursor(t){this.Xh.uh(t)}},Ge=o=>class extends o{constructor(...t){super(...t)}touchStarted(t){this._a.ko(t)}touchMoved(t){this._a.Mh(t)}touchEnded(t){this._a.zo(t)}touchCancelled(t){this._a.Do(t)}tap(t){this._a.Lo(t)}doubleTap(t){this._a.Oo(t)}longPress(t){this._a.Io(t)}swipe(t){this._a.Bo(t)}pinch(t){this._a.Ho(t)}rotateGesture(t){this._a.Go(t)}get touches(){return this._a.So()}},Ve=o=>class extends o{constructor(...t){super(...t)}keyPressed(t){this.Ca.Ch(t)}keyReleased(t){this.Ca.xh(t)}isKeyPressed(t){return this.Ca.Ih(t)}get lastKeyPressed(){return this.Ca.Hh()}get lastKeyReleased(){return this.Ca.Gh()}get pressedKeys(){return this.Ca.Qh()}get modifierState(){return this.Ca.Nh()}};class ke{constructor(t){l(this,"xa");l(this,"Ma",new Map);l(this,"Fa",[]);l(this,"Pa",new Map);l(this,"$a",new Map);this.xa=t}async Ta(t){for(const e of t){if(this.Ma.has(e.name))return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);const r=this.Ra(e.name);try{await e.install(this.xa,r)}catch(n){throw this.Ea(e.name),n}this.Ma.set(e.name,e),this.Fa.push(e.name)}}async Sa(t){const e=this.Ma.get(t);if(!e)return;const r=this.Ra(t);e.uninstall&&await e.uninstall(this.xa,r),this.Ma.delete(t),this.Fa.splice(this.Fa.indexOf(t),1),this.Ea(t)}ka(){this.za(this.Pa)}Da(){this.za(this.$a)}async La(){const t=[...this.Ma.keys()];for(const e of t)await this.Sa(e)}Ra(t){return{renderer:this.xa.Z,font:this.xa.rr,grid:this.xa.Nn,canvas:this.xa.Er,drawFramebuffer:this.xa.ga,asciiFramebuffer:this.xa.Oa,registerPreDrawHook:e=>this.Ia(this.Pa,t,e),registerPostDrawHook:e=>this.Ia(this.$a,t,e)}}Ia(t,e,r){const n=t.get(e)??new Set;return n.add(r),t.set(e,n),()=>{const h=t.get(e);h&&(h.delete(r),h.size===0&&t.delete(e))}}Ea(t){this.Pa.delete(t),this.$a.delete(t)}za(t){for(const e of this.Fa){const r=t.get(e);r&&r.forEach(n=>n())}}}const $=`#version 300 es
|
|
11
|
+
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`,jt=`#version 300 es
|
|
12
|
+
precision highp float;uniform sampler2D u_texture;in vec2 v_uv;out vec4 fragColor;void main(){fragColor=texture(u_texture,v_uv);}`;class Gt{constructor(){l(this,"Ba",new Map);l(this,"Ha",[]);l(this,"Ga",0);l(this,"Qa",0);l(this,"Na")}get ja(){return this.Ga}get Xa(){if(this.Ga===0)return 0;let t=0;for(const e of this.Ha){const r=this.Ba.get(e);r&&(t+=Math.min(1,Math.max(0,r.progress))*r.weight)}return Math.min(1,t/this.Ga)}Ya(t){this.Na=t}Wa(t,e=1){const r=`phase-${this.Ha.length+1}-${Date.now()}`,n={id:r,label:t,weight:Math.max(.001,e),progress:0,status:"running"};return this.Ba.set(r,n),this.Ha.push(r),this.Ga+=n.weight,r}Ka(t,e){const r=this.Ba.get(t);if(!r)return;r.progress=Math.max(0,Math.min(1,e)),r.status=r.progress>=1?"complete":"running";const n=this.Xa;Math.abs(n-this.Qa)>.001&&(this.Qa=n,this.Na&&this.Na(n))}Za(t){const e=this.Ba.get(t);e&&(e.progress=1,e.status="complete",this.Ka(t,1))}qa(t){const e=this.Ba.get(t);e&&(e.status="failed")}Va(){return this.Ha.map(t=>{const e=this.Ba.get(t);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"}})}}class Vt{constructor(t="active"){l(this,"Ja");l(this,"tc","");l(this,"sc","");this.Ja=t}get ec(){return this.Ja}get rc(){return this.Ja!=="disabled"}get nc(){return this.Ja==="active"||this.Ja==="transitioning"||this.Ja==="error"}get hc(){return this.tc}get oc(){return this.sc}ac(){this.Ja!=="done"&&this.Ja!=="transitioning"||(this.Ja="active")}cc(){this.Ja!=="disabled"&&(this.Ja="done")}lc(){this.Ja!=="disabled"&&(this.Ja="transitioning")}uc(){this.Ja==="transitioning"&&(this.Ja="done")}fc(t){this.Ja!=="disabled"&&(this.Ja="error",t instanceof Error?(this.tc=t.message,this.sc=t.stack||""):(this.tc=t,this.sc=""))}dc(){this.Ja="disabled"}}class kt{constructor(t,e){l(this,"vc",0);l(this,"gc",1);l(this,"mc");l(this,"_c");this.mc=t,this._c=e}get yc(){return this.gc}get bc(){return this.gc<1}kn(){this.mc!=="none"&&this._c>0&&(this.vc=performance.now())}et(){if(this.mc==="none"||this._c===0)return this.gc=1,!1;const t=performance.now()-this.vc,e=Math.min(1,t/this._c);return e>=1?(this.gc=0,!0):(this.gc=1-e,!1)}ti(){this.gc=1,this.vc=0}}function xt(o,t){const e=o.tone??"auto";let r="dark";return e==="light"||e==="dark"?r=e:t&&(r=function(n){if(!n)return 0;const[h,a,c]=n.map(f=>f/255),u=f=>f<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4);return .2126*u(h)+.7152*u(a)+.0722*u(c)}(t)>.5?"light":"dark"),{mode:r,background:t,textColor:r==="light"?"#1A1A1A":"#F8F8F8",subtleColor:r==="light"?"#4A4A4A":"#C0C0C0"}}function Ht(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function Wt(o,t){return o.length?o.map(e=>t.color(e)):[t.color("#FFFFFF")]}const He=({textmodifier:o,grid:t,progress:e,frameCount:r,message:n,palette:h,theme:a,phases:c,transitionOpacity:u,isError:f,errorMessage:d})=>{const g="|/-\\",v=Math.floor(r/6)%4,m=o.color(a.textColor),A=Math.floor(255*u),p=o.color(m.r,m.g,m.b,A);if(o.charColor(p),o.cellColor(0,0,0,0),f){const y=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",A);o.charColor(y),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const E="SETUP ERROR",w=-Math.floor(E.length/2);o.push(),o.translate(w,0,0);for(const x of E)o.char(x),o.rect(1,1),o.translateX(1);if(o.pop(),d){const x=o.color(a.subtleColor),P=o.color(x.r,x.g,x.b,A);o.charColor(P);const b=Math.floor(.8*t.cols),N=d.split(" "),L=[];let M="";for(const D of N)(M+" "+D).length<=b?M=M?M+" "+D:D:(M&&L.push(M),M=D);M&&L.push(M);const B=L.slice(0,3);L.length>3&&(B[2]=B[2].substring(0,b-3)+"..."),B.forEach((D,ct)=>{const ni=-Math.floor(D.length/2);o.push(),o.translate(ni,3+ct,0);for(const hi of D)o.char(hi),o.rect(1,1),o.translateX(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(g[v]),o.rect(1,1),o.pop(),e>0||c.some(y=>y.status!=="pending")){const y=Math.max(6,Math.floor(.6*t.cols)),E=-Math.floor(y/2),w=Math.floor(y*e),x=h.length?h:[o.color("#FFFFFF")];o.push(),o.translate(E,3,0);for(let P=0;P<y;P++){const b=P<w?"*":".",N=x[P%x.length],L=o.color(N.r,N.g,N.b,A);o.charColor(L),o.char(b),o.rect(1,1),o.translateX(1)}o.pop()}if(n){const y=o.color(a.subtleColor),E=o.color(y.r,y.g,y.b,A);o.charColor(E);const w=-Math.floor(n.length/2);o.push(),o.translate(w,5,0);for(const x of n)o.char(x),o.rect(1,1),o.translateX(1);o.pop()}},We={message:"LOADING...",tone:"auto",transition:"fade",transitionDuration:500};class Ke{constructor(t,e,r){this.wc=t,this.id=e,this.label=r}report(t){this.wc.Ka(this.id,t)}complete(){this.wc.Za(this.id)}fail(t){this.wc.qa(this.id)}async track(t){try{const e=typeof t=="function"?await t():await t;return this.complete(),e}catch(e){throw this.fail(),e}}}class Kt{constructor(t,e,r){l(this,"xa");l(this,"l");l(this,"Cc");l(this,"wc");l(this,"xc");l(this,"Mc");l(this,"Fc");l(this,"Pc");l(this,"$c");l(this,"Tc");l(this,"Z");l(this,"Rc",[]);l(this,"Ec");l(this,"Sc",performance.now());l(this,"kc",0);l(this,"zc",!1);l(this,"Dc",!1);l(this,"Bc");this.xa=t,this.l={...We,...e??{}},this.Cc=new Vt("active"),this.wc=new Gt,this.xc=new kt(this.l.transition,this.l.transitionDuration),this.Mc=new Ot(60),this.Ec=xt(this.l,r);const n=Ht(this.Ec);this.Rc=Wt(n,this.xa),this.Z=this.Lc(),this.wc.Ya(h=>{h>=.999&&this.cc()})}async yr(t){if(this.Dc)return;const e=this.xa.Z,r=this.xa.Er;this.Fc=new pt(e,16),await this.Fc.yr(t);const n=this.Fc.maxGlyphDimensions;this.Pc=new At(r.canvas,n.width,n.height),this.$c=e.Pe(this.Pc.cols,this.Pc.rows,3),this.Tc=e.Pe(this.Pc.width,this.Pc.height,1),this.Dc=!0}get nc(){return this.Cc.nc&&this.zc}kn(){this.zc||(this.zc=!0,this.Sc=performance.now(),this.kc=0,this.Mc.kn(()=>this.Oc()))}zn(){this.zc&&(this.zc=!1,this.Mc.zn())}jr(){this.Dc&&(this.Pc.ti(),this.$c.resize(this.Pc.cols,this.Pc.rows),this.Tc.resize(this.Pc.width,this.Pc.height))}gt(){this.zn(),this.Dc&&(this.Fc.gt(),this.$c.gt(),this.Tc.gt(),this.Dc=!1)}get progress(){return this.wc.Xa}message(t){return typeof t=="string"&&(this.l.message=t),this.l.message}addPhase(t,e=1){this.Cc.ac();const r=this.wc.Wa(t,e);return new Ke(this.wc,r,t)}cc(){this.l.transition!=="none"&&this.l.transitionDuration>0?(this.Cc.lc(),this.xc.kn()):(this.Cc.cc(),this.zn(),this.Ic())}Ic(){this.Bc&&this.Bc()}Hc(t){this.Bc=t}error(t){this.Cc.fc(t)}Oc(){if(this.Cc.nc){if(this.kc++,this.Cc.ec==="transitioning"&&this.xc.et())return this.Cc.uc(),this.Ic(),void this.zn();this.Gc()}}Gc(){if(!this.Dc)return;const t=this.$c,e=this.Fc,r=this.Pc,n=this.Tc,h=this.xa.Z,a=this.xa.Er,c=this.xa.Qc,u=this.xa.Nc;h.state.qt(),t.begin(),this.xa.clear(),this.xa.push();try{const f={textmodifier:this.xa,grid:r,progress:this.progress,elapsedMs:performance.now()-this.Sc,frameCount:this.kc,message:this.l.message,palette:this.Rc,theme:this.Ec,phases:this.wc.Va(),transitionOpacity:this.xc.yc,isError:this.Cc.ec==="error",errorMessage:this.Cc.hc||void 0,errorDetails:this.Cc.oc||void 0};this.Z(f)}finally{this.xa.pop()}t.end(),n.begin(),h.ve(c),c.O({u_characterTexture:e.fontFramebuffer,u_charsetDimensions:[e.textureColumns,e.textureRows],Ug:t.textures[0],Uh:t.textures[1],Ui:t.textures[2],Uj:[r.cols,r.rows],Uk:[n.width,n.height],Ul:h.state.canvasBackgroundColor}),h.Ae(0,0,a.width,a.height),n.end(),h.bi(...h.state.canvasBackgroundColor),h.ve(u),u.O({u_texture:n.textures[0]}),h.Ae(r.offsetX,r.offsetY,r.width,r.height)}jc(t){this.Ec=xt(this.l,t)}Lc(){const t=this.l.renderer||He;return e=>{t(e),this.Xc(e)}}Xc(t){const{textmodifier:e,grid:r,frameCount:n,theme:h,transitionOpacity:a}=t,c=[116,101,120,116,109,111,100,101,46,106,115].map(g=>String.fromCharCode(g)).join(""),u=(r.rows+1>>1)-2,f=2-(r.cols+1>>1),d=h.mode==="light"?[[233,30,99],[156,39,176],[255,111,0]]:[[142,249,243],[241,91,181],[255,155,113]];e.push(),e.translate(f,u,0);for(let g=0;g<c.length;g++){const v=c[g],m=Math.floor(.1*n+.5*g)%d.length,[A,p,y]=d[m],E=Math.floor(255*a),w=e.color(A,p,y,E);e.charColor(w),e.char(v),e.point(),e.translateX(1)}e.pop()}}class wt{constructor(t={}){l(this,"Yc");l(this,"yc");l(this,"Wc");l(this,"Kc");l(this,"Zc");l(this,"qc");l(this,"Vc");l(this,"Jc");l(this,"tl");l(this,"sl");l(this,"il",null);l(this,"el",!1);l(this,"rl",!0);l(this,"nl",[]);this.Yc=t.visible??!0,this.yc=Math.min(1,Math.max(0,t.opacity??1)),this.Wc=t.blendMode??"normal",this.Kc=Math.round(t.offsetX??0),this.Zc=Math.round(t.offsetY??0),this.qc=t.rotation??0}hl(){return this.il!==null}ol(){const t=this.nl;return this.nl=[],t}al(t){this.il&&this.il.call(t)}draw(t){this.il=t}show(){this.Yc=!0}hide(){this.Yc=!1}opacity(t){if(t===void 0)return this.yc;this.yc=Math.min(1,Math.max(0,t))}blendMode(t){if(t===void 0)return this.Wc;this.Wc=t}offset(t,e=0){if(t===void 0)return{x:this.Kc,y:this.Zc};this.Kc=Math.round(t),this.Zc=Math.round(e)}rotateZ(t){if(t===void 0)return this.qc;this.qc=t}filter(t,e){this.nl.push({name:t,params:e})}cl(t){this.Vc=t,this.ll(t.grid)}wa(t,e){if(!this.Yc||!this.il)return void(this.el=!1);const r=this.Vc.renderer;this.nl=[],this.Jc.begin(),r.state.qt(),this.il.call(t),this.Jc.end();const n=this.nl.length>0,h=n?this.sl:this.tl;h.begin(),r.bi(0,0,0,0),r.ve(e),e.O({u_characterTexture:this.Vc.font.fontFramebuffer,u_charsetDimensions:[this.Vc.font.textureColumns,this.Vc.font.textureRows],Ug:this.Jc.textures[0],Uh:this.Jc.textures[1],Ui:this.Jc.textures[2],Uj:[this.Vc.grid.cols,this.Vc.grid.rows],Uk:[h.width,h.height],Ul:[0,0,0,0]}),r.Ae(0,0,this.Vc.grid.width,this.Vc.grid.height),h.end(),n&&this.Vc.filterManager.ul(this.sl.textures[0],this.tl,this.nl,this.tl.width,this.tl.height,this.Vc.layerPingPongBuffers),this.el=!0}jr(t){var e;this.Vc&&(this.Vc={...this.Vc,grid:t}),this.Jc&&this.tl&&(this.Jc.resize(t.cols,t.rows),this.tl.resize(t.width,t.height),(e=this.sl)==null||e.resize(t.width,t.height))}gt(){var t,e,r;this.rl&&((t=this.Jc)==null||t.gt(),(e=this.tl)==null||e.gt(),(r=this.sl)==null||r.gt())}get texture(){var t;return(t=this.tl)==null?void 0:t.textures[0]}get width(){return this.tl?this.tl.width:0}get height(){return this.tl?this.tl.height:0}get fl(){return this.el}get drawFramebuffer(){return this.Jc}ll(t){this.Vc&&(this.Jc=this.Vc.externalDrawFramebuffer??this.Vc.createFramebuffer(t.cols,t.rows,4),this.tl=this.Vc.externalAsciiFramebuffer??this.Vc.createFramebuffer(t.width,t.height,1),this.Vc.externalAsciiFramebuffer||(this.sl=this.Vc.createFramebuffer(t.width,t.height,1)),this.rl=!this.Vc.externalDrawFramebuffer&&!this.Vc.externalAsciiFramebuffer,this.el=!1)}}const Qt={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};class qt{constructor(t){l(this,"Z");l(this,"dl");l(this,"vl",null);l(this,"pl",0);this.Z=t,this.dl=t.pe($,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D Um;uniform sampler2D Un;uniform vec2 Uo;uniform vec2 Up;uniform vec2 Uq;uniform float Ur;uniform vec2 Us;uniform float Ut;uniform int Uu;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(Un,v_uv);vec2 h=v_uv*Uo;vec2 i=h-Uq-Us;vec2 j=Up*0.5;vec2 k=i-j;float l=cos(-Ut);float m=sin(-Ut);vec2 n=vec2(k.x*l-k.y*m,k.x*m+k.y*l);i=n+j;bool o=any(lessThan(i,vec2(0.)))||any(greaterThanEqual(i,Up));if(o){fragColor=g;return;}vec2 p=(floor(i)+0.5)/Up;vec4 q=texture(Um,p);float r=q.a*Ur;if(r<=0.){fragColor=g;return;}vec3 s=e(Uu,g.rgb,q.rgb);vec3 t=mix(g.rgb,s,r);float u=g.a+r*(1.-g.a);fragColor=vec4(t,u);}`)}yr(t,e){this.vl||(this.vl=[this.Z.Pe(t,e,1),this.Z.Pe(t,e,1)])}ml(t){const e=this.Z.context,{baseTexture:r,targetFramebuffer:n,backgroundColor:h,baseLayer:a,layers:c,canvasWidth:u,canvasHeight:f,gridWidth:d,gridHeight:g,baseOffsetX:v,baseOffsetY:m}=t,A=e.isEnabled(e.DEPTH_TEST),p=e.getParameter(e.DEPTH_WRITEMASK);A&&e.disable(e.DEPTH_TEST),p&&e.depthMask(!1);const y=this.vl[0],E=this.vl[1];y.begin(),this.Z.bi(...h),y.end(),E.begin(),this.Z.bi(0,0,0,0),E.end(),this.pl=0,a.Yc&&this._l(r,u,f,d,g,a.yc,v+a.Kc,m+a.Zc,a.qc,"normal",e);for(const w of c)w.Yc&&w.fl&&this._l(w.texture,u,f,w.width,w.height,w.yc,v+w.Kc,m+w.Zc,w.qc,w.Wc,e);this.yl(n,u,f,e),e.depthMask(p),A&&e.enable(e.DEPTH_TEST)}_l(t,e,r,n,h,a,c,u,f,d,g){const v=this.vl[this.pl],m=this.pl===0?1:0,A=this.vl[m],p=f*(Math.PI/180);A.begin(),g.disable(g.BLEND),this.Z.ve(this.dl),this.dl.O({Um:t,Un:v.textures[0],Uo:[e,r],Up:[n,h],Uq:[c,u],Ur:a,Us:[0,0],Ut:p,Uu:Qt[d]}),this.Z.Ae(0,0,v.width,v.height),A.end(),this.pl=m}yl(t,e,r,n){const h=this.vl[this.pl];t.begin(),n.disable(n.BLEND),this.Z.ve(this.dl),this.dl.O({Um:h.textures[0],Un:h.textures[0],Uo:[e,r],Up:[h.width,h.height],Uq:[0,0],Ur:1,Us:[0,0],Ut:0,Uu:Qt.normal}),this.Z.Ae(0,0,e,r),t.end()}jr(t,e){this.vl&&(this.vl[0].resize(t,e),this.vl[1].resize(t,e))}gt(){this.dl.dispose(),this.vl&&(this.vl[0].gt(),this.vl[1].gt(),this.vl=null)}}class Jt{constructor(t){l(this,"xa");l(this,"Z");l(this,"Al");l(this,"bl");l(this,"wl",[]);l(this,"Cl",[]);l(this,"xl");l(this,"Ml");l(this,"Fl");l(this,"Pl");l(this,"$l",!1);this.xa=t,this.Z=t.Z,this.Al=t.Qc,this.bl=new qt(this.Z),this.xl=new wt({visible:!0,opacity:1})}add(t={}){const e=new wt(t);return this.$l?(this.Tl(e),this.Cl.push(e)):this.wl.push(e),e}remove(t){this.Rl(this.Cl,t)||this.Rl(this.wl,t)}move(t,e){this.El(this.Cl,t,e)||this.El(this.wl,t,e)}swap(t,e){t!==e&&(this.Sl(this.Cl,t,e)||this.Sl(this.wl,t,e))}clear(){for(const t of this.Cl)t.gt();this.Cl.length=0;for(const t of this.wl)t.gt();this.wl.length=0}yr(){if(this.$l)return;const t=this.xa.Nn;this.Ml=this.Z.Pe(t.width,t.height,1),this.Fl=this.Z.Pe(t.width,t.height,1),this.Pl=[this.Z.Pe(t.width,t.height,1,{depth:!1}),this.Z.Pe(t.width,t.height,1,{depth:!1})],this.kl(),this.bl.yr(this.xa.Er.width,this.xa.Er.height);for(const e of this.wl)this.Tl(e),this.Cl.push(e);this.wl.length=0,this.$l=!0}zl(t,e){const r=this.xa.Nn,n=this.xa.font,h=this.xa.ga,a=this.xl.ol(),c=a.length>0,u=c?this.Fl:this.Ml;u.begin(),this.Z.bi(0,0,0,0),this.Z.ve(this.Al),this.Al.O({u_characterTexture:n.fontFramebuffer,u_charsetDimensions:[n.textureColumns,n.textureRows],Ug:h.textures[0],Uh:h.textures[1],Ui:h.textures[2],Uj:[r.cols,r.rows],Uk:[u.width,u.height],Ul:this.Z.state.canvasBackgroundColor}),this.Z.Ae(0,0,r.width,r.height),u.end(),c&&this.xa.Dl.ul(this.Fl.textures[0],this.Ml,a,this.Ml.width,this.Ml.height,this.Pl),this.Ll(),this.Ol(t,e)}Ll(){if(this.Cl.length!==0)for(const t of this.Cl)t.wa(this.xa,this.Al)}Ol(t,e){const r=this.xa.Nn,n=this.xa.Er;this.bl.ml({baseTexture:this.Ml.textures[0],targetFramebuffer:t,backgroundColor:e,baseLayer:this.xl,layers:this.Cl,canvasWidth:n.width,canvasHeight:n.height,gridWidth:r.width,gridHeight:r.height,baseOffsetX:r.offsetX,baseOffsetY:r.offsetY})}jr(){if(!this.$l)return;const t=this.xa.Nn;this.Ml.resize(t.width,t.height),this.Fl.resize(t.width,t.height),this.xl.jr(t),this.Pl&&(this.Pl[0].resize(t.width,t.height),this.Pl[1].resize(t.width,t.height));for(const e of this.Cl)e.jr(t);this.bl.jr(this.xa.Er.width,this.xa.Er.height)}gt(){var t,e,r,n;for(const h of this.Cl)h.gt();for(const h of this.wl)h.gt();this.Cl.length=0,this.wl.length=0,this.xl.gt(),(t=this.Ml)==null||t.gt(),(e=this.Fl)==null||e.gt(),(r=this.Pl)==null||r[0].gt(),(n=this.Pl)==null||n[1].gt(),this.bl.gt()}get all(){return this.Cl}get base(){return this.xl}Tl(t){const e={renderer:this.Z,grid:this.xa.Nn,font:this.xa.font,filterManager:this.xa.Dl,layerPingPongBuffers:this.Pl,createFramebuffer:(r,n,h=1)=>this.Z.Pe(r,n,h)};t.cl(e)}kl(){const t={renderer:this.Z,grid:this.xa.Nn,font:this.xa.font,filterManager:this.xa.Dl,layerPingPongBuffers:this.Pl,createFramebuffer:(e,r,n=1)=>this.Z.Pe(e,r,n),externalDrawFramebuffer:this.xa.ga,externalAsciiFramebuffer:this.Ml};this.xl.cl(t)}Rl(t,e){const r=t.indexOf(e);if(r===-1)return!1;const[n]=t.splice(r,1);return n.gt(),!0}El(t,e,r){const n=t.indexOf(e);if(n===-1)return!1;t.splice(n,1);const h=Math.max(0,Math.min(t.length,r));return t.splice(h,0,e),!0}Sl(t,e,r){const n=t.indexOf(e);if(n===-1)return!1;const h=t.indexOf(r);return h!==-1&&(t[n]=r,t[h]=e,!0)}}class $t{constructor(t){l(this,"Z");l(this,"Il",new Map);l(this,"Bl",new Map);this.Z=t,this.Hl()}async Gl(t,e,r={}){const n=Object.entries(r),h=n.length>0?n[0][1][0]:null;let a;if(typeof e=="string"){let u=e;if(e.startsWith("./")||e.startsWith("../")||e.endsWith(".frag")||e.endsWith(".glsl")){const f=await fetch(e);if(!f.ok)throw Error(`Failed to load shader from ${e}: ${f.statusText}`);u=await f.text()}a=this.Z.pe($,u),this.Bl.set(t,a)}else a=e,this.Bl.set(t,a);const c={id:t,createShader:()=>a,createUniforms:(u,f)=>{const d={u_resolution:[f.width,f.height]};for(const[g,[v,m]]of n){let A=m;u!=null&&(typeof u=="number"&&v===h?A=u:typeof u=="object"&&v in u&&(A=u[v]??m)),d[g]=A}return d}};this.Il.set(t,c)}Ql(t){const e=this.Bl.get(t);return e&&(e.dispose(),this.Bl.delete(t)),this.Il.delete(t)}Nl(t){return this.Il.get(t)}gt(){for(const t of this.Bl.values())t.dispose();this.Bl.clear(),this.Il.clear()}Hl(){this.Gl("invert",`#version 300 es
|
|
14
14
|
precision highp float;uniform sampler2D u_texture;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);fragColor=vec4(1.-A.rgb,A.a);}`,{}),this.Gl("grayscale",`#version 300 es
|
|
15
15
|
precision highp float;uniform sampler2D u_texture;uniform float U1;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),U1);fragColor=vec4(C,A.a);}`,{U1:["amount",1]}),this.Gl("sepia",`#version 300 es
|
|
16
16
|
precision highp float;uniform sampler2D u_texture;uniform float U1;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,U1);fragColor=vec4(C,A.a);}`,{U1:["amount",1]}),this.Gl("threshold",`#version 300 es
|
|
17
|
-
precision highp float;uniform sampler2D u_texture;uniform float U2;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(U2,B);fragColor=vec4(vec3(C),A.a);}`,{U2:["threshold",.5]})}}class te{constructor(t){l(this,"Z");l(this,"Bl",new Map);l(this,"J");l(this,"vl");l(this,"Dc",!1);l(this,"
|
|
18
|
-
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D
|
|
19
|
-
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));}`)),bt),createUniforms:({source:o})=>o.createBaseConversionUniforms()},Je=Object.freeze(Object.defineProperty({__proto__:null,LoadingPhaseTracker:
|
|
17
|
+
precision highp float;uniform sampler2D u_texture;uniform float U2;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(U2,B);fragColor=vec4(vec3(C),A.a);}`,{U2:["threshold",.5]})}}class te{constructor(t){l(this,"Z");l(this,"Bl",new Map);l(this,"J");l(this,"vl");l(this,"Dc",!1);l(this,"jl");this.Z=t,this.jl=new $t(this.Z),this.J=t.pe($,jt)}async register(t,e,r={}){await this.jl.Gl(t,e,r)}unregister(t){return this.jl.Ql(t)??!1}has(t){return this.jl.Nl(t)!==void 0}yr(t,e){this.Dc||(this.vl=[this.Z.Pe(t,e,1,{depth:!1}),this.Z.Pe(t,e,1,{depth:!1})],this.Dc=!0)}Xl(t,e,r,n,h){this.vl[0].width===n&&this.vl[0].height===h||(this.vl[0].resize(n,h),this.vl[1].resize(n,h)),this.ul(t,e,r,n,h,this.vl)}ul(t,e,r,n,h,a){if(r.length===0)return void this.Yl(t,e,n,h);const c=this.Z.context,u=c.isEnabled(c.BLEND);c.disable(c.BLEND),this.Yl(t,a[0],n,h);let f=0;for(let d=0;d<r.length;d++){const g=r[d],v=d===r.length-1,m=f===0?1:0,A=v?e:a[m];this.Wl(g,a[f],A,n,h),v||(f=m)}u&&c.enable(c.BLEND)}Wl(t,e,r,n,h){const a=this.jl.Nl(t.name);if(!a)return console.warn(`[textmode.js] Unknown filter: "${t.name}". Skipping.`),void this.Yl(e.textures[0],r,n,h);const c=this.Kl(t.name,a,n,h),u={renderer:this.Z,gl:this.Z.context,width:n,height:h};r.begin(),this.Z.ve(c),c.O({u_texture:e.textures[0]});const f=a.createUniforms(t.params,u);c.O(f),this.Z.Ae(0,0,n,h),r.end()}Kl(t,e,r,n){let h=this.Bl.get(t);if(!h&&e){const a={renderer:this.Z,gl:this.Z.context,width:r,height:n};h=e.createShader(a),this.Bl.set(t,h)}return h}Yl(t,e,r,n){e.begin(),this.Z.ve(this.J),this.J.O({u_texture:t,u_resolution:[r,n]}),this.Z.Ae(0,0,r,n),e.end()}jr(t,e){this.vl&&(this.vl[0].resize(t,e),this.vl[1].resize(t,e))}gt(){for(const t of this.Bl.values())t.dispose();this.Bl.clear(),this.J.dispose(),this.jl.gt(),this.vl&&(this.vl[0].gt(),this.vl[1].gt()),this.Dc=!1}}const Qe=Object.freeze(Object.defineProperty({__proto__:null,FilterRegistry:$t,TextmodeFilterManager:te},Symbol.toStringTag,{value:"Module"}));class ee extends function(e,...r){return r.reduce((n,h)=>h(n),e)}(class{},Ie,Ye,ze,je,Ge,Ve){constructor(e={}){super();l(this,"Z");l(this,"rr");l(this,"Er");l(this,"Nn");l(this,"ba");l(this,"Xh");l(this,"_a");l(this,"Ca");l(this,"Zl");l(this,"ga");l(this,"Qc");l(this,"Oa");l(this,"Nc");l(this,"ma");l(this,"Dl");l(this,"ql",[]);l(this,"Vl");l(this,"Jl");l(this,"tu");l(this,"su",!1);l(this,"iu",!1);l(this,"eu",!1);l(this,"ru",!1);l(this,"nu",()=>{});l(this,"il",()=>{});l(this,"hu",()=>{});l(this,"ou");l(this,"au");l(this,"Lr",!1);l(this,"cu");l(this,"ya",new Set);this.tu=new ke(this),this.Lr=e.overlay??!1,this.Er=new _t(e),this.Z=new ye(this.Er.Xr()),this.rr=new pt(this.Z,e.fontSize??16),this.ba=new Ot(e.frameRate??60),this.Zl=new Kt(this,e.loadingScreen,this.Er.Nr()),this.Zl.Hc(()=>{this.ba.Gn=0,this.ru=!0}),this.Xh=new It(this.Er),this._a=new zt(this.Er,this.Xh),this.Ca=new Yt,this.Qc=this.Z.pe($,`#version 300 es
|
|
18
|
+
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D Uh;uniform sampler2D Ui;uniform sampler2D Ug;uniform vec2 Uj;uniform vec2 Uk;uniform vec4 Ul;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/Uk;vec2 F=E*Uj;vec2 G=floor(F);vec2 H=(G+0.5)/Uj;vec4 I=texture(Uh,H);vec4 J=texture(Ui,H);vec4 K=texture(Ug,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(Ul,J,J.a);fragColor=mix(d,I,c);}`),this.ma=new Jt(this),this.Dl=new te(this.Z),this.Zl.kn(),this.lu(e)}async lu(e){await Promise.all([this.rr.yr(e.fontSource),this.Zl.yr(e.fontSource)]);const r=this.rr.maxGlyphDimensions;this.Nn=new At(this.Er.canvas,r.width,r.height),this.Xh.yr(this.Nn),this._a.yr(this.Nn),this.ga=this.Z.Pe(this.Nn.cols,this.Nn.rows,3),this.Oa=this.Z.Pe(this.Nn.width,this.Nn.height,1),this.Vl=this.Z.Pe(this.Er.width,this.Er.height,1),this.Jl=this.Z.Pe(this.Er.width,this.Er.height,1),this.Dl.yr(this.Er.width,this.Er.height),this.ma.yr(),this.Lr&&(this.cu=V.Cn(this.Z,this.rr,this.Er.targetCanvas,this.Nn.cols,this.Nn.rows),this.pa(this.cu)),this.Nc=this.Z.pe($,jt),this.uu(),this.ba.kn(()=>this.wa()),await this.tu.Ta(e.plugins??[]);try{await this.nu(),this.Zl.cc()}catch(n){console.error("Error during setup:",n),this.Zl.error(n)}}uu(){this.ou=()=>{this.Lr&&this.resizeCanvas(this.Er.targetCanvas.width,this.Er.targetCanvas.height),this.hu()},window.addEventListener("resize",this.ou),this.Xh.dh(),this._a.dh(),this.Ca.dh(),window.addEventListener("blur",()=>{this.Ca.jh()}),this.Lr&&(this.au=new ResizeObserver(()=>{this.resizeCanvas(this.Er.targetCanvas.width,this.Er.targetCanvas.height)}),this.au.observe(this.Er.targetCanvas))}wa(){if(!this.Zl.nc&&this.ru){this.iu=!0;try{this.ba.In(),this.ba.Qn(),this.Lr&&Rt(this.Z.context,this.cu.texture,this.Er.targetCanvas),this.tu.ka(),this.Z.state.qt(),this.ga.begin(),this.ma.base.hl()?this.ma.base.al(this):this.il(),this.ga.end();const e=[...this.Z.state.canvasBackgroundColor];this.ma.zl(this.Vl,e);let r=this.Vl.textures[0];this.ql.length>0&&(this.Dl.Xl(this.Vl.textures[0],this.Jl,this.ql,this.Er.width,this.Er.height),r=this.Jl.textures[0],this.ql=[]),this.Z.bi(0,0,0,0),this.Z.ve(this.Nc),this.Nc.O({u_texture:r}),this.Z.Ae(0,0,this.Er.width,this.Er.height),this.tu.Da()}finally{this.iu=!1,this.su&&!this.eu&&this.fu()}}}resizeCanvas(e,r){var n,h,a,c;this.Er.jr(e,r),this.Zl.jc(this.Er.Nr()),this.Nn.ti(),this.Zl.jr(),this.ga.resize(this.Nn.cols,this.Nn.rows),this.Oa.resize(this.Nn.width,this.Nn.height),(n=this.Vl)==null||n.resize(this.Er.width,this.Er.height),(h=this.Jl)==null||h.resize(this.Er.width,this.Er.height),(a=this.Dl)==null||a.jr(this.Er.width,this.Er.height),(c=this.ma)==null||c.jr(),this.Z.Re(),this.Xh.fh(),this._a.fh(),this.wa()}destroy(){this.eu||this.su||(this.su=!0,this.ba.Dn(),this.iu||this.fu())}fu(){var e,r,n,h,a,c;this.su=!1,this.Zl.gt(),this.tu.La(),window.removeEventListener("resize",this.ou),(e=this.au)==null||e.disconnect(),this.Xh.bh(),this._a.bh(),this.Ca.bh(),this.ga.gt(),this.Qc.dispose(),(r=this.ma)==null||r.gt(),(n=this.Dl)==null||n.gt(),(h=this.Vl)==null||h.gt(),(a=this.Jl)==null||a.gt(),this.rr.gt(),this.Z.gt(),this.Oa.gt(),this.Nc.dispose(),(c=this.cu)==null||c.gt(),this.Er.gt(),this.eu=!0}setup(e){this.nu=e}draw(e){this.il=e}windowResized(e){this.hu=e}get grid(){return this.Nn}get font(){return this.rr}get width(){return this.Er.width}get height(){return this.Er.height}get canvas(){return this.Er.canvas}get drawFramebuffer(){return this.ga}get isDisposed(){return this.eu}get overlay(){return this.cu}get loading(){return this.Zl}get layers(){return this.ma}get filters(){return this.Dl}filter(e,r){this.ql.push({name:e,params:r})}pa(e){this.ya.has(e)||this.ya.add(e)}}class at{constructor(){}static create(t={}){return new ee(t)}static setErrorLevel(t){ut._(t)}static get version(){return"0.7.1-beta.4"}}let bt=null;const qe={id:"brightness",createShader:({gl:o})=>(bt||(bt=new H(o,et,`#version 300 es
|
|
19
|
+
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));}`)),bt),createUniforms:({source:o})=>o.createBaseConversionUniforms()},Je=Object.freeze(Object.defineProperty({__proto__:null,LoadingPhaseTracker:Gt,LoadingScreenManager:Kt,LoadingScreenStateMachine:Vt,LoadingScreenTransition:kt,resolveColorInputs:Wt,resolveDefaultPalette:Ht,resolveTheme:xt},Symbol.toStringTag,{value:"Module"})),$e=Object.freeze(Object.defineProperty({__proto__:null,TextmodeFont:pt,TextmodeImage:V,TextmodeVideo:ot},Symbol.toStringTag,{value:"Module"})),ti=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Xe,mouse:Be,touch:Ze},Symbol.toStringTag,{value:"Module"})),ei=Object.freeze(Object.defineProperty({__proto__:null,LayerCompositor:qt,TextmodeLayer:wt,TextmodeLayerManager:Jt},Symbol.toStringTag,{value:"Module"}));Bt(qe);const ii=at.create,si=at.setErrorLevel,ri=at.version;T.TextmodeCanvas=_t,T.TextmodeColor=U,T.TextmodeErrorLevel=O,T.TextmodeFramebuffer=z,T.TextmodeGrid=At,T.Textmodifier=ee,T.create=ii,T.filters=Qe,T.getConversionStrategy=Xt,T.input=ti,T.layering=ei,T.loadables=$e,T.loading=Je,T.registerConversionStrategy=Bt,T.setErrorLevel=si,T.textmode=at,T.unregisterConversionStrategy=function(o){yt.delete(o)},T.version=ri,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):i((s=typeof globalThis<"u"?globalThis:s||self).textmode={});
|
|
@@ -36,6 +36,7 @@ export declare class LayerManager implements ILayerManager {
|
|
|
36
36
|
remove(layer: TextmodeLayer): void;
|
|
37
37
|
move(layer: TextmodeLayer, newIndex: number): void;
|
|
38
38
|
swap(layerA: TextmodeLayer, layerB: TextmodeLayer): void;
|
|
39
|
+
clear(): void;
|
|
39
40
|
/**
|
|
40
41
|
* Initialize all pending layers and the compositor.
|
|
41
42
|
* @ignore
|
|
@@ -33,4 +33,11 @@ export interface ILayerManager {
|
|
|
33
33
|
* @param layerB The second layer to swap.
|
|
34
34
|
*/
|
|
35
35
|
swap(layerA: TextmodeLayer, layerB: TextmodeLayer): void;
|
|
36
|
+
/**
|
|
37
|
+
* Remove all user-created layers from the manager.
|
|
38
|
+
* The base layer is not affected by this operation.
|
|
39
|
+
* This is useful for live-coding environments where code is re-evaluated
|
|
40
|
+
* and layers need to be recreated from scratch.
|
|
41
|
+
*/
|
|
42
|
+
clear(): void;
|
|
36
43
|
}
|
package/package.json
CHANGED