textmode.js 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/dist/textmode.esm.js +46 -46
- package/dist/textmode.umd.js +2 -2
- package/package.json +1 -6
package/README.md
CHANGED
|
@@ -71,9 +71,6 @@ To use `textmode.js` in a UMD environment, download the latest `umd` build from
|
|
|
71
71
|
|
|
72
72
|
<!-- Standard bundle (with embedded UrsaFont) -->
|
|
73
73
|
<script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
|
|
74
|
-
|
|
75
|
-
<!-- OR Minified bundle (requires external font) -->
|
|
76
|
-
<!-- <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.min.js"></script> -->
|
|
77
74
|
</head>
|
|
78
75
|
<body>
|
|
79
76
|
<script src="sketch.js"></script>
|
|
@@ -138,9 +135,6 @@ Then, you can import it in your JavaScript or TypeScript files:
|
|
|
138
135
|
// Standard bundle (with embedded UrsaFont)
|
|
139
136
|
import { textmode } from 'textmode.js';
|
|
140
137
|
|
|
141
|
-
// OR Minified bundle (requires external font)
|
|
142
|
-
// import { textmode } from 'textmode.js/min';
|
|
143
|
-
|
|
144
138
|
const t = textmode.create({
|
|
145
139
|
width: window.innerWidth,
|
|
146
140
|
height: window.innerHeight,
|
package/dist/textmode.esm.js
CHANGED
|
@@ -280,8 +280,8 @@ class it {
|
|
|
280
280
|
a(this, "wt", 0);
|
|
281
281
|
a(this, "bt", [0, 0, 0]);
|
|
282
282
|
a(this, "Ct", [1, 1, 1, 1]);
|
|
283
|
-
a(this, "
|
|
284
|
-
a(this, "
|
|
283
|
+
a(this, "Mt", [0, 0, 0, 1]);
|
|
284
|
+
a(this, "xt", !1);
|
|
285
285
|
a(this, "Ft", !1);
|
|
286
286
|
a(this, "Tt", !1);
|
|
287
287
|
a(this, "$t", 0);
|
|
@@ -294,10 +294,10 @@ class it {
|
|
|
294
294
|
return { kt: 1, zt: 0, Lt: 0, Ot: 0, At: 0, yt: 0, wt: 0, $t: 0, Dt: !1, Ht: !1, Tt: !1, Et: !1, It: [0, 0, 0], Bt: [1, 1, 1, 1], Gt: [0, 0, 0, 1] };
|
|
295
295
|
}
|
|
296
296
|
Nt(t) {
|
|
297
|
-
t.kt = this.dt, t.zt = this.gt, t.Lt = this.vt, t.Ot = this._t, t.At = this.At, t.yt = this.yt, t.wt = this.wt, t.Dt = this.
|
|
297
|
+
t.kt = this.dt, t.zt = this.gt, t.Lt = this.vt, t.Ot = this._t, t.At = this.At, t.yt = this.yt, t.wt = this.wt, t.Dt = this.xt, t.Ht = this.Ft, t.Tt = this.Tt, t.$t = this.$t, t.Et = this.Et, t.It[0] = this.bt[0], t.It[1] = this.bt[1], t.It[2] = this.bt[2], t.Bt[0] = this.Ct[0], t.Bt[1] = this.Ct[1], t.Bt[2] = this.Ct[2], t.Bt[3] = this.Ct[3], t.Gt[0] = this.Mt[0], t.Gt[1] = this.Mt[1], t.Gt[2] = this.Mt[2], t.Gt[3] = this.Mt[3];
|
|
298
298
|
}
|
|
299
299
|
Xt(t) {
|
|
300
|
-
this.dt = t.kt, this.gt = t.zt, this.vt = t.Lt, this._t = t.Ot, this.At = t.At, this.yt = t.yt, this.wt = t.wt, this.
|
|
300
|
+
this.dt = t.kt, this.gt = t.zt, this.vt = t.Lt, this._t = t.Ot, this.At = t.At, this.yt = t.yt, this.wt = t.wt, this.xt = t.Dt, this.Ft = t.Ht, this.Tt = t.Tt, this.$t = t.$t, this.Et = t.Et, this.bt[0] = t.It[0], this.bt[1] = t.It[1], this.bt[2] = t.It[2], this.Ct[0] = t.Bt[0], this.Ct[1] = t.Bt[1], this.Ct[2] = t.Bt[2], this.Ct[3] = t.Bt[3], this.Mt[0] = t.Gt[0], this.Mt[1] = t.Gt[1], this.Mt[2] = t.Gt[2], this.Mt[3] = t.Gt[3];
|
|
301
301
|
}
|
|
302
302
|
et() {
|
|
303
303
|
let t = this.St.pop();
|
|
@@ -344,10 +344,10 @@ class it {
|
|
|
344
344
|
J(this.Ct, t, e, i, s);
|
|
345
345
|
}
|
|
346
346
|
rs(t, e, i, s = 255) {
|
|
347
|
-
J(this.
|
|
347
|
+
J(this.Mt, t, e, i, s);
|
|
348
348
|
}
|
|
349
349
|
ns(t) {
|
|
350
|
-
this.
|
|
350
|
+
this.xt = t;
|
|
351
351
|
}
|
|
352
352
|
hs(t) {
|
|
353
353
|
this.Ft = t;
|
|
@@ -646,10 +646,10 @@ class O {
|
|
|
646
646
|
ft() {
|
|
647
647
|
this.mi.ft(), this.A.deleteBuffer(this.yi);
|
|
648
648
|
}
|
|
649
|
-
|
|
649
|
+
Mi(t, e, i) {
|
|
650
650
|
return this.mi.di(t);
|
|
651
651
|
}
|
|
652
|
-
|
|
652
|
+
xi(t, e, i, s, r, h) {
|
|
653
653
|
const o = r.zt ?? 0, c = r.Lt ?? 0, l = r.Ot ?? 0, u = r.At ?? 0, f = r.yt ?? 0, g = r.wt ?? 0, A = [0, 0, 0, 0], p = [0, 0, 0, 0];
|
|
654
654
|
h && (h.bezStartX !== void 0 && h.bezStartY !== void 0 && h.bezEndX !== void 0 && h.bezEndY !== void 0 ? (A[0] = h.cp1x ?? 0, A[1] = h.cp1y ?? 0, A[2] = h.cp2x ?? 0, A[3] = h.cp2y ?? 0, p[0] = h.bezStartX ?? 0, p[1] = h.bezStartY ?? 0, p[2] = h.bezEndX ?? 0, p[3] = h.bezEndY ?? 0) : h.arcStart === void 0 && h.arcStop === void 0 || (A[0] = h.arcStart ?? 0, A[1] = h.arcStop ?? 0));
|
|
655
655
|
const d = { x: t, y: e, width: i, height: s, char0: r.It[0], char1: r.It[1], char2: r.It[2], r1: r.Bt[0], g1: r.Bt[1], b1: r.Bt[2], a1: r.Bt[3], r2: r.Gt[0], g2: r.Gt[1], b2: r.Gt[2], a2: r.Gt[3], invert: r.Tt ? 1 : 0, flipX: r.Dt ? 1 : 0, flipY: r.Ht ? 1 : 0, charRot: r.$t, translationX: o, translationY: c, translationZ: l, rotationX: u, rotationY: f, rotationZ: g, curveParams0: A, curveParams1: p, depth: (h == null ? void 0 : h.depth) ?? 0, baseZ: (h == null ? void 0 : h.baseZ) ?? 0, geometryType: Wt[this._i] ?? 0 };
|
|
@@ -684,7 +684,7 @@ const ie = { wi: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Fi:
|
|
|
684
684
|
super(n, t, T.RECTANGLE, Jt);
|
|
685
685
|
}
|
|
686
686
|
di(n, t) {
|
|
687
|
-
return this.
|
|
687
|
+
return this.xi(0, 0, n.width, n.height, t);
|
|
688
688
|
}
|
|
689
689
|
}, [T.LINE]: class extends O {
|
|
690
690
|
constructor(n, t) {
|
|
@@ -692,14 +692,14 @@ const ie = { wi: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Fi:
|
|
|
692
692
|
}
|
|
693
693
|
di(n, t) {
|
|
694
694
|
const e = n.x2 - n.x1, i = n.y2 - n.y1, s = Math.hypot(e, i), r = Math.atan2(i, e), h = t.kt || 1, o = n.x1 + e / 2 - s / 2, c = n.y1 + i / 2, l = { ...t, wt: (t.wt || 0) + r };
|
|
695
|
-
return this.
|
|
695
|
+
return this.xi(o, c, s, h, l);
|
|
696
696
|
}
|
|
697
697
|
}, [T.ELLIPSE]: class extends O {
|
|
698
698
|
constructor(n, t) {
|
|
699
699
|
super(n, t, T.ELLIPSE, te);
|
|
700
700
|
}
|
|
701
701
|
di(n, t) {
|
|
702
|
-
return this.
|
|
702
|
+
return this.xi(0, 0, n.width, n.height, t);
|
|
703
703
|
}
|
|
704
704
|
}, [T.ARC]: class extends O {
|
|
705
705
|
constructor(n, t) {
|
|
@@ -707,7 +707,7 @@ const ie = { wi: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Fi:
|
|
|
707
707
|
}
|
|
708
708
|
di(n, t) {
|
|
709
709
|
const e = n.start * Math.PI / 180, i = n.stop * Math.PI / 180;
|
|
710
|
-
return this.
|
|
710
|
+
return this.xi(0, 0, n.width, n.height, t, { arcStart: e, arcStop: i });
|
|
711
711
|
}
|
|
712
712
|
}, [T.TRIANGLE]: class extends O {
|
|
713
713
|
constructor(n, t) {
|
|
@@ -715,14 +715,14 @@ const ie = { wi: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Fi:
|
|
|
715
715
|
}
|
|
716
716
|
di(n, t) {
|
|
717
717
|
const e = Math.min(n.x1, n.x2, n.x3), i = Math.max(n.x1, n.x2, n.x3), s = Math.min(n.y1, n.y2, n.y3), r = i - e, h = Math.max(n.y1, n.y2, n.y3) - s;
|
|
718
|
-
return this.
|
|
718
|
+
return this.xi(e, s, r, h, t);
|
|
719
719
|
}
|
|
720
720
|
}, [T.BEZIER_CURVE]: class extends O {
|
|
721
721
|
constructor(n, t) {
|
|
722
722
|
super(n, t, T.BEZIER_CURVE, se);
|
|
723
723
|
}
|
|
724
724
|
di(n, t) {
|
|
725
|
-
return this.
|
|
725
|
+
return this.xi(0, 0, 1, t.kt || 1, t, { cp1x: n.cp1x, cp1y: n.cp1y, cp2x: n.cp2x, cp2y: n.cp2y, bezStartX: n.x1, bezStartY: n.y1, bezEndX: n.x2, bezEndY: n.y2 });
|
|
726
726
|
}
|
|
727
727
|
} };
|
|
728
728
|
class ne {
|
|
@@ -1289,7 +1289,7 @@ const ge = { parseTab(n, t, e) {
|
|
|
1289
1289
|
}, be(n, t) {
|
|
1290
1290
|
const e = R, i = n.Ce, s = n.loca;
|
|
1291
1291
|
if (s[t] === s[t + 1]) return null;
|
|
1292
|
-
const r = j.findTable(i, "glyf", n.
|
|
1292
|
+
const r = j.findTable(i, "glyf", n.Me);
|
|
1293
1293
|
if (!r) return null;
|
|
1294
1294
|
let h = r[0] + s[t];
|
|
1295
1295
|
const o = {};
|
|
@@ -1327,7 +1327,7 @@ const ge = { parseTab(n, t, e) {
|
|
|
1327
1327
|
} } }, j = { parse(n) {
|
|
1328
1328
|
const t = new Uint8Array(n);
|
|
1329
1329
|
R.readASCII(t, 0, 4) === "wOFF" && (n = de(n));
|
|
1330
|
-
const e = new Uint8Array(n), i = wt, s = {}, r = { Ce: e,
|
|
1330
|
+
const e = new Uint8Array(n), i = wt, s = {}, r = { Ce: e, xe: 0, Me: 0 };
|
|
1331
1331
|
for (const h in i) {
|
|
1332
1332
|
const o = h, c = j.findTable(e, o, 0);
|
|
1333
1333
|
if (c) {
|
|
@@ -2039,18 +2039,18 @@ class Mt {
|
|
|
2039
2039
|
};
|
|
2040
2040
|
this.gn = requestAnimationFrame(e);
|
|
2041
2041
|
}
|
|
2042
|
-
|
|
2042
|
+
Mn() {
|
|
2043
2043
|
this.gn && (cancelAnimationFrame(this.gn), this.gn = null);
|
|
2044
2044
|
}
|
|
2045
|
-
|
|
2046
|
-
this.mn && (this.mn = !1, this.
|
|
2045
|
+
xn() {
|
|
2046
|
+
this.mn && (this.mn = !1, this.Mn());
|
|
2047
2047
|
}
|
|
2048
2048
|
Fn(t) {
|
|
2049
2049
|
this.mn || (this.mn = !0, this.Cn(t));
|
|
2050
2050
|
}
|
|
2051
2051
|
Tn(t, e) {
|
|
2052
2052
|
if (t === void 0) return this._n;
|
|
2053
|
-
this.pn = 1e3 / t, this.mn && e && (this.
|
|
2053
|
+
this.pn = 1e3 / t, this.mn && e && (this.Mn(), this.Cn(e));
|
|
2054
2054
|
}
|
|
2055
2055
|
$n() {
|
|
2056
2056
|
const t = performance.now();
|
|
@@ -2216,9 +2216,9 @@ class Pt {
|
|
|
2216
2216
|
}
|
|
2217
2217
|
so() {
|
|
2218
2218
|
this.Xn || (this.Ao = (t) => {
|
|
2219
|
-
this.xo(t);
|
|
2220
|
-
}, this.yo = (t) => {
|
|
2221
2219
|
this.Mo(t);
|
|
2220
|
+
}, this.yo = (t) => {
|
|
2221
|
+
this.xo(t);
|
|
2222
2222
|
}, window.addEventListener("keydown", this.Ao, { passive: !1 }), window.addEventListener("keyup", this.yo, { passive: !1 }), this.Xn = !0);
|
|
2223
2223
|
}
|
|
2224
2224
|
ao() {
|
|
@@ -2251,7 +2251,7 @@ class Pt {
|
|
|
2251
2251
|
So() {
|
|
2252
2252
|
this.vo.clear(), this.mo = null, this._o = null;
|
|
2253
2253
|
}
|
|
2254
|
-
|
|
2254
|
+
Mo(t) {
|
|
2255
2255
|
const e = t.key, i = Date.now();
|
|
2256
2256
|
this.vo.has(e) || this.vo.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
2257
2257
|
const s = this.vo.get(e);
|
|
@@ -2260,7 +2260,7 @@ class Pt {
|
|
|
2260
2260
|
this.wo(r);
|
|
2261
2261
|
}
|
|
2262
2262
|
}
|
|
2263
|
-
|
|
2263
|
+
xo(t) {
|
|
2264
2264
|
const e = t.key, i = Date.now();
|
|
2265
2265
|
this.vo.has(e) || this.vo.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
2266
2266
|
const s = this.vo.get(e);
|
|
@@ -2363,10 +2363,10 @@ class Lt {
|
|
|
2363
2363
|
Ch(t) {
|
|
2364
2364
|
this.Wo = t;
|
|
2365
2365
|
}
|
|
2366
|
-
|
|
2366
|
+
Mh(t) {
|
|
2367
2367
|
this.Zo = t;
|
|
2368
2368
|
}
|
|
2369
|
-
|
|
2369
|
+
xh(t) {
|
|
2370
2370
|
this.jo = t;
|
|
2371
2371
|
}
|
|
2372
2372
|
Fh(t) {
|
|
@@ -2872,7 +2872,7 @@ const Be = (n) => class extends n {
|
|
|
2872
2872
|
return t === void 0 ? this.ha.En : this.ha.Tn(t, () => this.aa());
|
|
2873
2873
|
}
|
|
2874
2874
|
noLoop() {
|
|
2875
|
-
this.ha.
|
|
2875
|
+
this.ha.xn();
|
|
2876
2876
|
}
|
|
2877
2877
|
loop() {
|
|
2878
2878
|
this.ha.Fn(() => this.aa());
|
|
@@ -2925,10 +2925,10 @@ const Be = (n) => class extends n {
|
|
|
2925
2925
|
this.na.Ch(t);
|
|
2926
2926
|
}
|
|
2927
2927
|
tap(t) {
|
|
2928
|
-
this.na.
|
|
2928
|
+
this.na.Mh(t);
|
|
2929
2929
|
}
|
|
2930
2930
|
doubleTap(t) {
|
|
2931
|
-
this.na.
|
|
2931
|
+
this.na.xh(t);
|
|
2932
2932
|
}
|
|
2933
2933
|
longPress(t) {
|
|
2934
2934
|
this.na.Fh(t);
|
|
@@ -3009,9 +3009,9 @@ class Oe {
|
|
|
3009
3009
|
for (const e of t) await this._a(e);
|
|
3010
3010
|
}
|
|
3011
3011
|
va(t) {
|
|
3012
|
-
return { renderer: this.la.K, font: this.la.je, grid: this.la.Un, canvas: this.la.wr, drawFramebuffer: this.la.ra, asciiFramebuffer: this.la.
|
|
3012
|
+
return { renderer: this.la.K, font: this.la.je, grid: this.la.Un, canvas: this.la.wr, drawFramebuffer: this.la.ra, asciiFramebuffer: this.la.Ma, registerPreDrawHook: (e) => this.xa(this.da, t, e), registerPostDrawHook: (e) => this.xa(this.pa, t, e) };
|
|
3013
3013
|
}
|
|
3014
|
-
|
|
3014
|
+
xa(t, e, i) {
|
|
3015
3015
|
const s = t.get(e) ?? /* @__PURE__ */ new Set();
|
|
3016
3016
|
return s.add(i), t.set(e, s), () => {
|
|
3017
3017
|
const r = t.get(e);
|
|
@@ -3263,16 +3263,16 @@ class Xt {
|
|
|
3263
3263
|
return this.ac.Ya && this.wc;
|
|
3264
3264
|
}
|
|
3265
3265
|
Cn() {
|
|
3266
|
-
this.wc || (this.wc = !0, this._c = performance.now(), this.yc = 0, this.lc.Cn(() => this.
|
|
3266
|
+
this.wc || (this.wc = !0, this._c = performance.now(), this.yc = 0, this.lc.Cn(() => this.Mc()));
|
|
3267
3267
|
}
|
|
3268
|
-
|
|
3269
|
-
this.wc && (this.wc = !1, this.lc.
|
|
3268
|
+
Mn() {
|
|
3269
|
+
this.wc && (this.wc = !1, this.lc.Mn());
|
|
3270
3270
|
}
|
|
3271
3271
|
zr() {
|
|
3272
3272
|
this.bc && (this.fc.js(), this.dc.resize(this.fc.cols, this.fc.rows), this.gc.resize(this.fc.width, this.fc.height));
|
|
3273
3273
|
}
|
|
3274
3274
|
ft() {
|
|
3275
|
-
this.
|
|
3275
|
+
this.Mn(), this.bc && (this.uc.ft(), this.dc.ft(), this.gc.ft(), this.bc = !1);
|
|
3276
3276
|
}
|
|
3277
3277
|
get progress() {
|
|
3278
3278
|
return this.hc.Sa;
|
|
@@ -3286,9 +3286,9 @@ class Xt {
|
|
|
3286
3286
|
return new Ge(this.hc, i, t);
|
|
3287
3287
|
}
|
|
3288
3288
|
ja() {
|
|
3289
|
-
this.l.transition !== "none" && this.l.transitionDuration > 0 ? (this.ac.Va(), this.cc.Cn()) : (this.ac.ja(), this.
|
|
3289
|
+
this.l.transition !== "none" && this.l.transitionDuration > 0 ? (this.ac.Va(), this.cc.Cn()) : (this.ac.ja(), this.Mn(), this.xc());
|
|
3290
3290
|
}
|
|
3291
|
-
|
|
3291
|
+
xc() {
|
|
3292
3292
|
this.Fc && this.Fc();
|
|
3293
3293
|
}
|
|
3294
3294
|
Tc(t) {
|
|
@@ -3297,10 +3297,10 @@ class Xt {
|
|
|
3297
3297
|
error(t) {
|
|
3298
3298
|
this.ac.Qa(t);
|
|
3299
3299
|
}
|
|
3300
|
-
|
|
3300
|
+
Mc() {
|
|
3301
3301
|
if (this.ac.Ya) {
|
|
3302
3302
|
if (this.yc++, this.ac.Na === "transitioning" && this.cc.tt())
|
|
3303
|
-
return this.ac.qa(), this.
|
|
3303
|
+
return this.ac.qa(), this.xc(), void this.Mn();
|
|
3304
3304
|
this.$c();
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
@@ -3352,7 +3352,7 @@ class ze extends function(e, ...i) {
|
|
|
3352
3352
|
a(this, "kc");
|
|
3353
3353
|
a(this, "ra");
|
|
3354
3354
|
a(this, "Pc");
|
|
3355
|
-
a(this, "
|
|
3355
|
+
a(this, "Ma");
|
|
3356
3356
|
a(this, "Ec");
|
|
3357
3357
|
a(this, "zc");
|
|
3358
3358
|
a(this, "Lc", !1);
|
|
@@ -3378,7 +3378,7 @@ precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charse
|
|
|
3378
3378
|
async Kc(e) {
|
|
3379
3379
|
await Promise.all([this.je.cr(e.fontSource), this.kc.cr(e.fontSource)]);
|
|
3380
3380
|
const i = this.je.maxGlyphDimensions;
|
|
3381
|
-
this.Un = new Ut(this.wr.canvas, i.width, i.height), this.Uo.cr(this.Un), this.na.cr(this.Un), this.ra = this.K.Ae(this.Un.cols, this.Un.rows, 3), this.
|
|
3381
|
+
this.Un = new Ut(this.wr.canvas, i.width, i.height), this.Uo.cr(this.Un), this.na.cr(this.Un), this.ra = this.K.Ae(this.Un.cols, this.Un.rows, 3), this.Ma = this.K.Ae(this.Un.width, this.Un.height, 1), this.Tr && (this.Yc = G.dn(this.K, this.je, this.wr.targetCanvas, this.Un.cols, this.Un.rows), this.ea(this.Yc)), this.Ec = this.K.he(yt, `#version 300 es
|
|
3382
3382
|
precision highp float;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;uniform vec2 U9;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-U8;vec2 B=A*(U7/U9);vec2 C=(floor(B)+0.5)/U7;fragColor=texture(U6,C);}`), this.Wc(), this.ha.Cn(() => this.aa()), await this.zc.ga(e.plugins ?? []);
|
|
3383
3383
|
try {
|
|
3384
3384
|
await this.Ic(), this.kc.ja();
|
|
@@ -3399,21 +3399,21 @@ precision highp float;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;unifo
|
|
|
3399
3399
|
if (!this.kc.Ya && this.Hc) {
|
|
3400
3400
|
this.Oc = !0;
|
|
3401
3401
|
try {
|
|
3402
|
-
this.ha.$n(), this.ha.Sn(), this.Tr && Tt(this.K.context, this.Yc.texture, this.wr.targetCanvas), this.zc.ya(), this.K.state.Wt(), this.ra.begin(), this.Bc(), this.ra.end(), this.
|
|
3402
|
+
this.ha.$n(), this.ha.Sn(), this.Tr && Tt(this.K.context, this.Yc.texture, this.wr.targetCanvas), this.zc.ya(), this.K.state.Wt(), this.ra.begin(), this.Bc(), this.ra.end(), this.Ma.begin(), this.K.oe(this.Pc), this.Pc.L({ u_characterTexture: this.je.fontFramebuffer, u_charsetDimensions: [this.je.textureColumns, this.je.textureRows], U0: this.ra.textures[0], U1: this.ra.textures[1], U2: this.ra.textures[2], U3: [this.Un.cols, this.Un.rows], U4: [this.Ma.width, this.Ma.height], U5: this.K.state.canvasBackgroundColor }), this.K.fe(0, 0, this.wr.width, this.wr.height), this.Ma.end(), this.K.gi(...this.K.state.canvasBackgroundColor), this.K.oe(this.Ec), this.Ec.L({ U6: this.Ma.textures[0], U7: [this.Ma.width, this.Ma.height], U8: [this.Un.offsetX, this.Un.offsetY], U9: [this.Un.width, this.Un.height] }), this.K.fe(this.Un.offsetX, this.Un.offsetY, this.Un.width, this.Un.height), this.zc.ba();
|
|
3403
3403
|
} finally {
|
|
3404
3404
|
this.Oc = !1, this.Lc && !this.Dc && this.Zc();
|
|
3405
3405
|
}
|
|
3406
3406
|
}
|
|
3407
3407
|
}
|
|
3408
3408
|
resizeCanvas(e, i) {
|
|
3409
|
-
this.wr.zr(e, i), this.kc.Rc(this.wr.kr()), this.Un.js(), this.kc.zr(), this.ra.resize(this.Un.cols, this.Un.rows), this.
|
|
3409
|
+
this.wr.zr(e, i), this.kc.Rc(this.wr.kr()), this.Un.js(), this.kc.zr(), this.ra.resize(this.Un.cols, this.Un.rows), this.Ma.resize(this.Un.width, this.Un.height), this.K.we(), this.Uo.Jn(), this.na.Jn(), this.aa();
|
|
3410
3410
|
}
|
|
3411
3411
|
destroy() {
|
|
3412
|
-
this.Dc || this.Lc || (this.Lc = !0, this.ha.
|
|
3412
|
+
this.Dc || this.Lc || (this.Lc = !0, this.ha.xn(), this.Oc || this.Zc());
|
|
3413
3413
|
}
|
|
3414
3414
|
Zc() {
|
|
3415
3415
|
var e, i;
|
|
3416
|
-
this.Lc = !1, this.kc.ft(), this.zc.Ca(), window.removeEventListener("resize", this.Nc), (e = this.Xc) == null || e.disconnect(), this.Uo.ao(), this.na.ao(), this.ca.ao(), this.ra.ft(), this.Pc.dispose(), this.je.ft(), this.K.ft(), this.
|
|
3416
|
+
this.Lc = !1, this.kc.ft(), this.zc.Ca(), window.removeEventListener("resize", this.Nc), (e = this.Xc) == null || e.disconnect(), this.Uo.ao(), this.na.ao(), this.ca.ao(), this.ra.ft(), this.Pc.dispose(), this.je.ft(), this.K.ft(), this.Ma.ft(), this.Ec.dispose(), (i = this.Yc) == null || i.ft(), this.wr.ft(), this.Dc = !0;
|
|
3417
3417
|
}
|
|
3418
3418
|
setup(e) {
|
|
3419
3419
|
this.Ic = e;
|
|
@@ -3465,7 +3465,7 @@ class pt {
|
|
|
3465
3465
|
dt._(t);
|
|
3466
3466
|
}
|
|
3467
3467
|
static get version() {
|
|
3468
|
-
return "0.6.
|
|
3468
|
+
return "0.6.1";
|
|
3469
3469
|
}
|
|
3470
3470
|
}
|
|
3471
3471
|
let at = null;
|
package/dist/textmode.umd.js
CHANGED
|
@@ -9,6 +9,6 @@ in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in
|
|
|
9
9
|
precision highp float;in vec2 v_uv;uniform sampler2D Ua;uniform sampler2D Ub;uniform sampler2D Uc;uniform vec2 Ud;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Ud;vec2 C=(floor(B)+0.5f)/Ud;vec4 D=texture(Ua,C);vec4 E=texture(Ub,C);if(E.a==0.){discard;}vec4 F=texture(Uc,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const c=t.getParameter(t.MAX_DRAW_BUFFERS),u=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.Y=Math.min(this.Y,c,u),this.G=t.createFramebuffer(),this.V(),this.q(),this.l.depth&&this.J()}V(){const t=this.A,i=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.Y;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),$(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,h,this.H,this.I,0,a,n,null),this.N.push(u)}t.bindTexture(t.TEXTURE_2D,null)}q(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.G),this.Y===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.N[0],0);else{const i=[];for(let r=0;r<this.Y;r++){const n=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,n,t.TEXTURE_2D,this.N[r],0),i.push(n)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}J(){const t=this.A;this.X=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.X),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.H,this.I),t.bindFramebuffer(t.FRAMEBUFFER,this.G),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.X),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}tt(t){xt(this.A,this.N[0],t)}resize(t,i){this.H=t,this.I=i,this.Z.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.N)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,h,this.H,this.I,0,a,n,null);r.bindTexture(r.TEXTURE_2D,null),this.X&&(r.bindRenderbuffer(r.RENDERBUFFER,this.X),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.H,this.I),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.Z.get(t);if(i)return i;const r=this.A,n=this.H,h=this.I,a=new Uint8Array(n*h*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.G),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,p=d*u;f.set(a.subarray(g,g+u),p)}return this.Z.set(t,f),f}begin(){const t=this.A;this.Z.clear(),this.K.st(),this.K.et(this.G,this.H,this.I),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.K.state.it()}end(){this.K.state.rt(),this.K.nt(),this.K.ot()}ht(){return this.W||this.ct(),this.W}ct(){if(!this.K)return;const t={Ua:this.N[0],Ub:this.N[1],Uc:this.N[2],Ud:[this.H,this.I]},i=H.j;this.W=this.K.ut.lt(i,t,!0)}ft(){const t=this.A;t.deleteFramebuffer(this.G);for(const i of this.N)t.deleteTexture(i);this.X&&t.deleteRenderbuffer(this.X)}get width(){return this.H}get height(){return this.I}get textures(){return this.N}get attachmentCount(){return this.Y}};l(H,"j",null);let V=H;const Ft=new WeakMap;function ft(o,t){Ft.set(o,t)}function Ct(o){return Ft.get(o)}function et(o,t,i,r,n=255){o[0]=t/255,o[1]=(i??t)/255,o[2]=(r??t)/255,o[3]=n/255}class it{constructor(){l(this,"dt",1);l(this,"gt",0);l(this,"vt",0);l(this,"_t",0);l(this,"At",0);l(this,"yt",0);l(this,"wt",0);l(this,"bt",[0,0,0]);l(this,"Ct",[1,1,1,1]);l(this,"Mt",[0,0,0,1]);l(this,"xt",!1);l(this,"Ft",!1);l(this,"Tt",!1);l(this,"$t",0);l(this,"Pt",[0,0,0,1]);l(this,"Et",!1);l(this,"Rt",[]);l(this,"St",[])}static Ut(){return{kt:1,zt:0,Lt:0,Ot:0,At:0,yt:0,wt:0,$t:0,Dt:!1,Ht:!1,Tt:!1,Et:!1,It:[0,0,0],Bt:[1,1,1,1],Gt:[0,0,0,1]}}Nt(t){t.kt=this.dt,t.zt=this.gt,t.Lt=this.vt,t.Ot=this._t,t.At=this.At,t.yt=this.yt,t.wt=this.wt,t.Dt=this.xt,t.Ht=this.Ft,t.Tt=this.Tt,t.$t=this.$t,t.Et=this.Et,t.It[0]=this.bt[0],t.It[1]=this.bt[1],t.It[2]=this.bt[2],t.Bt[0]=this.Ct[0],t.Bt[1]=this.Ct[1],t.Bt[2]=this.Ct[2],t.Bt[3]=this.Ct[3],t.Gt[0]=this.Mt[0],t.Gt[1]=this.Mt[1],t.Gt[2]=this.Mt[2],t.Gt[3]=this.Mt[3]}Xt(t){this.dt=t.kt,this.gt=t.zt,this.vt=t.Lt,this._t=t.Ot,this.At=t.At,this.yt=t.yt,this.wt=t.wt,this.xt=t.Dt,this.Ft=t.Ht,this.Tt=t.Tt,this.$t=t.$t,this.Et=t.Et,this.bt[0]=t.It[0],this.bt[1]=t.It[1],this.bt[2]=t.It[2],this.Ct[0]=t.Bt[0],this.Ct[1]=t.Bt[1],this.Ct[2]=t.Bt[2],this.Ct[3]=t.Bt[3],this.Mt[0]=t.Gt[0],this.Mt[1]=t.Gt[1],this.Mt[2]=t.Gt[2],this.Mt[3]=t.Gt[3]}it(){let t=this.St.pop();t||(t=it.Ut()),this.Nt(t),this.Rt.push(t)}rt(){const t=this.Rt.pop();t?(this.Xt(t),this.St.push(t)):console.warn("pop() called without matching push()")}Yt(t){this.Nt(t)}Kt(t){this.dt=Math.abs(t)}Wt(){this.gt=0,this.vt=0,this._t=0,this.At=0,this.yt=0,this.wt=0,this.Et=!1}Zt(t){t!==0&&(this.At+=t*Math.PI/180)}jt(t){t!==0&&(this.yt+=t*Math.PI/180)}Vt(t){t!==0&&(this.wt+=t*Math.PI/180)}qt(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.gt+=t,this.vt+=i,this._t+=r)}Qt(t){this.qt(t,0,0)}Jt(t){this.qt(0,t,0)}ts(t){this.qt(0,0,t)}ss(t){this.bt[0]=t[0],this.bt[1]=t[1],this.bt[2]=t[2]}es(t,i,r,n=255){et(this.Ct,t,i,r,n)}rs(t,i,r,n=255){et(this.Mt,t,i,r,n)}ns(t){this.xt=t}hs(t){this.Ft=t}cs(t){this.Tt=t}ls(t){this.$t=bt(t)}us(t,i,r,n){et(this.Pt,t,i,r,n)}fs(t){this.Et=t}get canvasBackgroundColor(){return this.Pt}get useOrtho(){return this.Et}get rotationX(){return this.At}get rotationY(){return this.yt}get rotationZ(){return this.wt}}const dt=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]),K={ds:16,ps:WebGL2RenderingContext.TRIANGLES,gs:{vs:{size:2,offset:0},_s:{size:2,offset:8}}};class Vt{constructor(t){l(this,"A");l(this,"As");l(this,"ws");this.A=t,this.As=t.createBuffer(),this.ws=new Float32Array(dt.length)}bs(t,i,r,n){const h=this.A,a=Ct(this.A),c=a[2],u=a[3],f=t/c*2-1,d=(t+r)/c*2-1,g=1-(i+n)/u*2,p=1-i/u*2,m=dt,v=this.ws;for(let A=0;A<m.length;A+=4){const w=m[A],y=m[A+1],T=m[A+2],E=m[A+3],U=f+(w+.5)*(d-f),b=g+(y+.5)*(p-g);v[A]=U,v[A+1]=b,v[A+2]=T,v[A+3]=E}h.bindBuffer(h.ARRAY_BUFFER,this.As),h.bufferData(h.ARRAY_BUFFER,v,h.DYNAMIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,16,0),h.drawArrays(h.TRIANGLES,0,6),h.disableVertexAttribArray(0),h.bindBuffer(h.ARRAY_BUFFER,null)}ft(){this.A.deleteBuffer(this.As)}}var F=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(F||{});const Zt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class qt{constructor(t){l(this,"A");l(this,"Cs",new Map);this.A=t}Ms(t,i,r,n){const h=this.A;let a=this.Cs.get(t);a||(a=new Map,this.Cs.set(t,a));let c=a.get(i)||null;if(!c){c=h.createVertexArray(),a.set(i,c),h.bindVertexArray(c),h.bindBuffer(h.ARRAY_BUFFER,n);const u=h.getAttribLocation(t,"A0");u!==-1&&ut(h,u,r.gs.vs.size,r.ds,r.gs.vs.offset,0,h.FLOAT,!1);const f=h.getAttribLocation(t,"A1");f!==-1&&ut(h,f,r.gs._s.size,r.ds,r.gs._s.offset,0,h.FLOAT,!1)}h.bindVertexArray(c)}Fs(){this.A.bindVertexArray(null)}ft(){for(const[,t]of this.Cs)for(const[,i]of t)i&&this.A.deleteVertexArray(i)}}const _=class _{static Ts(t,i,r=0){const n=i||new Float32Array(_.FLOATS_PER_INSTANCE);let h=r;n[h++]=t.vs[0],n[h++]=t.vs[1],n[h++]=t.$s[0],n[h++]=t.$s[1],n[h++]=t.It[0],n[h++]=t.It[1],n[h++]=t.It[2],n[h++]=t.Bt[0],n[h++]=t.Bt[1],n[h++]=t.Bt[2],n[h++]=t.Bt[3],n[h++]=t.Gt[0],n[h++]=t.Gt[1],n[h++]=t.Gt[2],n[h++]=t.Gt[3],n[h++]=t.Ps[0],n[h++]=t.Ps[1],n[h++]=t.Ps[2],n[h++]=t.$t;const a=t.Es;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.Rs;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.Ss,f=t.Us,d=t.ks,g=t.zs,p=t.Ls,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++]=(p==null?void 0:p[0])??0,n[h++]=(p==null?void 0:p[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.Os??0,n[h++]=t.Ds??0,n[h++]=t.Hs??0,n}static Is(t,i){const r=t.length*_.FLOATS_PER_INSTANCE,n=i||new Float32Array(r);for(let h=0;h<t.length;h++){const a=h*_.FLOATS_PER_INSTANCE;_.Ts(t[h],n,a)}return n}};l(_,"BYTES_PER_INSTANCE",144),l(_,"FLOATS_PER_INSTANCE",36);let N=_;const S=class S{};l(S,"STRIDE",N.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 Z=S;class Qt{constructor(t=1e3,i=1.5){l(this,"Bs");l(this,"Gs");l(this,"Ns");l(this,"Xs",0);l(this,"Ys",0);this.Gs=t,this.Ns=i;const r=t*N.FLOATS_PER_INSTANCE;this.Bs=new Float32Array(r)}Ks(t){if(t<=this.Gs)return;const i=Math.ceil(t*this.Ns),r=this.Gs;this.Gs=i;const n=i*N.FLOATS_PER_INSTANCE,h=new Float32Array(n),a=r*N.FLOATS_PER_INSTANCE;h.set(this.Bs.subarray(0,Math.min(a,this.Xs))),this.Bs=h}Ws(){return{buffer:this.Bs,offset:this.Xs}}Zs(t){this.Xs+=t,this.Ys++}js(){this.Xs=0,this.Ys=0}Vs(t=0,i){return this.Bs.subarray(t,i??this.Xs)}get qs(){return this.Ys}get Qs(){return this.Gs}get Js(){return this.Xs}get te(){return this.Ys===0}}class Jt{constructor(t){l(this,"Bs");this.Bs=t}se(t){this.Bs.Ks(this.Bs.qs+1);const{buffer:i,offset:r}=this.Bs.Ws();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.char0,i[r+5]=t.char1,i[r+6]=t.char2,i[r+7]=t.r1,i[r+8]=t.g1,i[r+9]=t.b1,i[r+10]=t.a1,i[r+11]=t.r2,i[r+12]=t.g2,i[r+13]=t.b2,i[r+14]=t.a2,i[r+15]=t.invert,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.charRot,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.translationZ,i[r+22]=t.rotationX,i[r+23]=t.rotationY,i[r+24]=t.rotationZ;const n=t.curveParams0,h=t.curveParams1;return i[r+25]=n[0],i[r+26]=n[1],i[r+27]=n[2],i[r+28]=n[3],i[r+29]=h[0],i[r+30]=h[1],i[r+31]=h[2],i[r+32]=h[3],i[r+33]=t.depth,i[r+34]=t.baseZ,i[r+35]=t.geometryType,this.Bs.Zs(N.FLOATS_PER_INSTANCE),this.Bs.qs-1}get qs(){return this.Bs.qs}}class $t{constructor(t,i=1e3){l(this,"A");l(this,"ee",null);l(this,"ie",0);l(this,"re",new Map);this.A=t,this.ne(i)}ne(t){const i=this.A;this.ee&&i.deleteBuffer(this.ee),this.ee=i.createBuffer();const r=t*N.BYTES_PER_INSTANCE;Rt(i,i.ARRAY_BUFFER,this.ee,r,i.DYNAMIC_DRAW),this.ie=t}oe(t){this.ne(t)}get Qs(){return this.ie}he(t,i){if(i===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.ee);const n=i*N.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,n)}ae(t){let i=this.re.get(t);if(!i){i=new Map;const r=this.A;for(const n in Z.ATTRIBUTES){const h=r.getAttribLocation(t,n);h!==-1&&i.set(n,h)}this.re.set(t,i)}return i}ce(t){const i=this.A,r=t.D,n=this.ae(r);for(const[h,a]of n){const c=Z.ATTRIBUTES[h];c&&ut(i,a,c.size,c.stride,c.offset,c.divisor,c.type,c.normalized)}}le(t){const i=this.A,r=this.ae(t.D);for(const[n,h]of r)Z.ATTRIBUTES[n]&&(i.disableVertexAttribArray(h),i.vertexAttribDivisor(h,0))}ft(){this.ee&&(this.A.deleteBuffer(this.ee),this.ee=null),this.re.clear()}}class te{constructor(t,i=1e3,r=1.5){l(this,"A");l(this,"Bs");l(this,"ue");l(this,"fe");this.A=t,this.Bs=new Qt(i,r),this.ue=new Jt(this.Bs),this.fe=new $t(t,i)}de(t){var n,h,a,c,u,f,d,g,p,m;const i=[0,0,0,0],r=[0,0,0,0];return t.Us&&t.ks?(i[0]=((n=t.zs)==null?void 0:n[0])??0,i[1]=((h=t.zs)==null?void 0:h[1])??0,i[2]=((a=t.Ls)==null?void 0:a[0])??0,i[3]=((c=t.Ls)==null?void 0:c[1])??0,r[0]=t.Us[0],r[1]=t.Us[1],r[2]=t.ks[0],r[3]=t.ks[1]):t.Ss&&(i[0]=t.Ss[0],i[1]=t.Ss[1]),this.se({x:t.vs[0],y:t.vs[1],width:t.$s[0],height:t.$s[1],char0:t.It[0],char1:t.It[1],char2:t.It[2],r1:t.Bt[0],g1:t.Bt[1],b1:t.Bt[2],a1:t.Bt[3],r2:t.Gt[0],g2:t.Gt[1],b2:t.Gt[2],a2:t.Gt[3],invert:t.Ps[0],flipX:t.Ps[1],flipY:t.Ps[2],charRot:t.$t,translationX:((u=t.Es)==null?void 0:u[0])??0,translationY:((f=t.Es)==null?void 0:f[1])??0,translationZ:((d=t.Es)==null?void 0:d[2])??0,rotationX:((g=t.Rs)==null?void 0:g[0])??0,rotationY:((p=t.Rs)==null?void 0:p[1])??0,rotationZ:((m=t.Rs)==null?void 0:m[2])??0,curveParams0:i,curveParams1:r,depth:t.Os||0,baseZ:t.Ds||0,geometryType:t.Hs||0})}se(t){const i=this.ue.se(t);return this.Bs.Qs>this.fe.Qs&&this.fe.oe(this.Bs.Qs),i}get pe(){return this.Bs.qs}get te(){return this.Bs.te}ge(){this.Bs.js()}ce(t){const i=this.Bs.qs;if(i===0)return;const r=this.Bs.Vs();this.fe.he(r,i),this.fe.ce(t)}le(t){this.fe.le(t)}bs(t,i){const r=this.Bs.qs;r!==0&&this.A.drawArraysInstanced(t,0,i,r)}ft(){this.fe.ft()}}class Y{constructor(t,i,r,n){l(this,"A");l(this,"ve");l(this,"me");l(this,"_e");l(this,"Ae",null);this.A=t,this.ve=i,this.me=r,this._e=n;const h=this.A.createBuffer();Rt(this.A,this.A.ARRAY_BUFFER,h,this._e.ye,this.A.STATIC_DRAW),this.Ae=h}get type(){return this.me}get unitGeometry(){return this._e}get unitBuffer(){return this.Ae}get batch(){return this.ve}we(){this.ve.ge()}be(){return!this.ve.te}ft(){this.ve.ft(),this.A.deleteBuffer(this.Ae)}Ce(t,i,r){return this.ve.de(t)}Me(t,i,r,n,h,a){const c=h.zt??0,u=h.Lt??0,f=h.Ot??0,d=h.At??0,g=h.yt??0,p=h.wt??0,m=[0,0,0,0],v=[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,v[0]=a.bezStartX??0,v[1]=a.bezStartY??0,v[2]=a.bezEndX??0,v[3]=a.bezEndY??0):a.arcStart===void 0&&a.arcStop===void 0||(m[0]=a.arcStart??0,m[1]=a.arcStop??0));const A={x:t,y:i,width:r,height:n,char0:h.It[0],char1:h.It[1],char2:h.It[2],r1:h.Bt[0],g1:h.Bt[1],b1:h.Bt[2],a1:h.Bt[3],r2:h.Gt[0],g2:h.Gt[1],b2:h.Gt[2],a2:h.Gt[3],invert:h.Tt?1:0,flipX:h.Dt?1:0,flipY:h.Ht?1:0,charRot:h.$t,translationX:c,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:p,curveParams0:m,curveParams1:v,depth:(a==null?void 0:a.depth)??0,baseZ:(a==null?void 0:a.baseZ)??0,geometryType:Zt[this.me]??0};return this.ve.se(A)}}const ee={ye:dt,xe:6,...K},ie={ye: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]),xe:6,...K},se={ye:function(o=32){const t=[],i=2*Math.PI/o;for(let r=0;r<o;r++){const n=r*i,h=(r+1)%o*i,a=Math.cos(n),c=Math.sin(n),u=.5*(a+1),f=.5*(c+1),d=Math.cos(h),g=Math.sin(h),p=.5*(d+1),m=.5*(g+1);t.push(0,0,.5,.5,a,c,u,f,d,g,p,m)}return new Float32Array(t)}(32),xe:96,...K};let re={ye:function(o){const t=[];for(let i=0;i<o;i++){const r=i/o,n=(i+1)/o;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),xe:96,...K};const ne={ye:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),xe:3,...K},he={ye:function(o=16){const t=[];for(let i=0;i<o;i++){const r=i/o,n=(i+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),xe:96,...K},oe={[F.RECTANGLE]:class extends Y{constructor(o,t){super(o,t,F.RECTANGLE,ee)}de(o,t){return this.Me(0,0,o.width,o.height,t)}},[F.LINE]:class extends Y{constructor(o,t){super(o,t,F.LINE,ie)}de(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,n=Math.hypot(i,r),h=Math.atan2(r,i),a=t.kt||1,c=o.x1+i/2-n/2,u=o.y1+r/2,f={...t,wt:(t.wt||0)+h};return this.Me(c,u,n,a,f)}},[F.ELLIPSE]:class extends Y{constructor(o,t){super(o,t,F.ELLIPSE,se)}de(o,t){return this.Me(0,0,o.width,o.height,t)}},[F.ARC]:class extends Y{constructor(o,t){super(o,t,F.ARC,re)}de(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Me(0,0,o.width,o.height,t,{arcStart:i,arcStop:r})}},[F.TRIANGLE]:class extends Y{constructor(o,t){super(o,t,F.TRIANGLE,ne)}de(o,t){const i=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-i,a=Math.max(o.y1,o.y2,o.y3)-n;return this.Me(i,n,h,a,t)}},[F.BEZIER_CURVE]:class extends Y{constructor(o,t){super(o,t,F.BEZIER_CURVE,he)}de(o,t){return this.Me(0,0,1,t.kt||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 ae{constructor(t){l(this,"A");l(this,"Fe");l(this,"Te");this.A=t,this.Te=new qt(t),this.Fe=new Map;for(const i of Object.values(F)){const r=new te(t),n=new oe[i](t,r);this.Fe.set(i,n)}}$e(t){const i=this.Pe(t);for(const r of i)this.Ee(r)}Pe(t){const i=[];let r=null,n=null,h=null;for(const a of t)n!==a.material||h!==a.type?(r&&r.length>0&&i.push({material:n,type:h,commands:r}),r=[a],n=a.material,h=a.type):r.push(a);return r&&r.length>0&&i.push({material:n,type:h,commands:r}),i}Ee(t){const{material:i,type:r,commands:n}=t,h=this.Fe.get(r);i.shader.U(),i.shader.L(i.uniforms);const a=Ct(this.A),c=n.length>0&&n[0].state.Et;i.shader.L({Uh:a[2]/a[3],Ue:[a[2],a[3]],Uf:1,Ug:c?1:0}),h.we();for(const u of n)h.de(u.params,u.state);if(h.be()){const u=h.unitGeometry,f=h.unitBuffer;try{this.Te.Ms(i.shader.D,r+"",u,f),h.batch.ce(i.shader),h.batch.bs(u.ps,u.xe)}finally{h.batch.le(i.shader),this.Te.Fs(),h.we()}}}ft(){for(const t of this.Fe.values())t.ft();this.Fe.clear(),this.Te.ft()}}function Ut(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Mt(o){return Ut(o+"")}function q(o,t){return(o<<5)-o+t}class ce{constructor(t){l(this,"Re",0);l(this,"Se");l(this,"ke");l(this,"ze",new Map);this.Se=new j(t,tt,`#version 300 es
|
|
10
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;void main(){int A=int(v_glyphFlags.r>0.5?1:0);int B=int(v_glyphFlags.g>0.5?1:0);int C=int(v_glyphFlags.b>0.5?1:0);float D=float(A|(B<<1)|(C<<2))/255.;o_character=vec4(v_glyphIndex.xy,D,clamp(v_glyphFlags.a,0.,1.));o_primaryColor=vec4(v_glyphColor.rgb,v_glyphColor.a);o_secondaryColor=vec4(v_cellColor.rgb,v_cellColor.a);}`),this.ke={id:this.Re++,shader:this.Se,uniforms:Object.freeze({}),hash:this.Le(this.Se,{}),isBuiltIn:!0}}get Oe(){return this.ke}lt(t,i={},r=!1){const n=this.Le(t,i),h=this.ze.get(n);if(h)return h;const a={id:this.Re++,shader:t,uniforms:Object.freeze({...i}),hash:n,isBuiltIn:r};return this.ze.set(n,a),a}De(t,i={}){return{id:this.Re++,shader:t,uniforms:Object.freeze({...i}),hash:0,isBuiltIn:!1}}Le(t,i){const r=Mt(t.D),n=function(h,a){let c=0;const u=Object.keys(h).sort();for(const f of u)c=q(c,Ut(f)),c=q(c,a(h[f]));return c}(i,this.He.bind(this));return q(r,n)}He(t){return typeof t=="number"||typeof t=="boolean"?function(i){return typeof i=="boolean"?i?1:0:Math.floor(i)}(t):Array.isArray(t)?function(i){let r=0;const n=Array.isArray(i[0])?i.flat():i;for(const h of n)r=q(r,typeof h=="number"?h:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(i){let r=0;const n=Math.min(i.length,16);for(let h=0;h<n;h++)r=q(r,i[h]);return r}(t):t instanceof WebGLTexture?Mt(t):0}ft(){this.Se!=this.Se&&this.Se.dispose(),this.Se.dispose(),this.ze.clear()}}class le{constructor(){l(this,"Ie",[]);l(this,"Be",1);l(this,"$s",0)}Ge(t,i){if(this.$s>=this.Ie.length){const n={id:this.Be++,type:t,params:{},state:it.Ut(),material:i};this.Ie.push(n)}const r=this.Ie[this.$s];return r.id=this.Be++,r.type=t,r.material=i,this.$s++,r}Ne(t,i,r){const n=this.Ge(F.RECTANGLE,r),h=n.params;return h.width=t.width,h.height=t.height,i.Yt(n.state),n.id}Xe(t,i,r){const n=this.Ge(F.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,i.Yt(n.state),n.id}Ye(t,i,r){const n=this.Ge(F.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,i.Yt(n.state),n.id}Ke(t,i,r){const n=this.Ge(F.ARC,r),h=n.params;return h.width=t.width,h.height=t.height,h.start=t.start,h.stop=t.stop,i.Yt(n.state),n.id}We(t,i,r){const n=this.Ge(F.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,i.Yt(n.state),n.id}Ze(t,i,r){const n=this.Ge(F.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,i.Yt(n.state),n.id}ge(){this.$s=0}[Symbol.iterator](){let t=0;const i=this.$s,r=this.Ie;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ue{constructor(t){l(this,"A");l(this,"je",null);l(this,"Ve");l(this,"ut");l(this,"qe");l(this,"Qe");l(this,"Je");l(this,"ti",null);l(this,"si",{});l(this,"ei",[]);l(this,"ii",[]);l(this,"ri",null);l(this,"ni",[0,0,0,0]);this.A=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.qe=new it,this.ut=new ce(t),this.Qe=new le,this.Ve=new ae(t),this.Je=new Vt(t);const i=[0,0,t.canvas.width,t.canvas.height];ft(t,i),this.ei.push(null),this.ii.push(i),this.ri=null,this.ni=i}st(){this.ei.push(this.ri),this.ii.push([...this.ni])}ot(){const t=this.ei.pop()??null,i=this.ii.pop()??[0,0,this.A.canvas.width,this.A.canvas.height];this.et(t,i[2],i[3])}et(t,i,r){const n=this.A;this.ri!==t&&(n.bindFramebuffer(n.FRAMEBUFFER,t),this.ri=t);const h=[0,0,i,r];this.ni[0]===h[0]&&this.ni[1]===h[1]&&this.ni[2]===h[2]&&this.ni[3]===h[3]||(n.viewport(...h),ft(n,h),this.ni=h)}oi(t){this.je!==t&&(this.je=t,t.U())}hi(t,i){return new j(this.A,t,i)}ai(t){this.ti=t,t&&(this.si={})}O(t,i){this.si[t]=i}ci(t){Object.assign(this.si,t)}li(t){return new j(this.A,tt,t)}ui(t,i,r){this.Qe.Ne({width:i??t.width,height:r??t.height},this.qe,t.ht())}fi(t,i,r,n){this.Je.bs(t,i,r,n)}di(t,i){if(this.ti){const r=this.ut.De(this.ti,this.si);this.Qe.Ne({width:t,height:i},this.qe,r),this.ti=null,this.si={}}else this.Qe.Ne({width:t,height:i},this.qe,this.ut.Oe)}pi(t,i,r,n){this.Qe.Xe({x1:t,y1:i,x2:r,y2:n},this.qe,this.ut.Oe)}gi(t,i){this.Qe.Ye({width:t,height:i},this.qe,this.ut.Oe)}mi(t,i,r,n,h,a){this.Qe.We({x1:t,y1:i,x2:r,y2:n,x3:h,y3:a},this.qe,this.ut.Oe)}_i(t,i,r,n,h,a,c,u){this.Qe.Ze({x1:t,y1:i,cp1x:r,cp1y:n,cp2x:h,cp2y:a,x2:c,y2:u},this.qe,this.ut.Oe)}Ai(t,i,r,n){this.Qe.Ke({width:t,height:i,start:r,stop:n},this.qe,this.ut.Oe)}yi(t,i,r=1,n={}){return new V(this.A,t,i,r,n,this)}wi(t,i=t,r=t,n=255){this.qe.us(t,i??t,r??t,n);const[h,a,c,u]=this.qe.canvasBackgroundColor;this.ge(h,a,c,u)}ge(t=0,i=0,r=0,n=0){this.A.clearColor(t,i,r,n),this.A.clear(this.A.COLOR_BUFFER_BIT)}bi(){const t=[0,0,this.A.canvas.width,this.A.canvas.height];this.A.viewport(...t),ft(this.A,t),this.ni=t,this.ii.length>0&&(this.ii[0]=t)}nt(){const t=this.Qe;this.Ve.$e(t),t.ge()}ft(){this.ut.ft(),this.Ve.ft(),this.Je.ft()}get context(){return this.A}get state(){return this.qe}get materialManager(){return this.ut}}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,i){const r=[];for(let n=0;n<i;n++)r.push(C.readUshort(o,t+2*n));return r},readUint(o,t){const i=C.t.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],C.t.uint32[0]},readASCII(o,t,i){let r="";for(let n=0;n<i;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 st(o){return o+3&-4}function rt(o,t,i){o[t]=i>>>8&255,o[t+1]=255&i}function O(o,t,i){o[t]=i>>>24&255,o[t+1]=i>>>16&255,o[t+2]=i>>>8&255,o[t+3]=255&i}function fe(o,t,i){for(let r=0;r<i.length;r++)o[t+r]=255&i.charCodeAt(r)}function gt(o,t,i){const r=t+i;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 de{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 i=this.bitbuf&(1<<t)-1;return this.bitbuf>>>=t,this.bitcnt-=t,i}alignToByte(){this.bitbuf=0,this.bitcnt=0}get offset(){return this.p}}function Q(o){let t=32,i=0;for(const c of o)c&&(c<t&&(t=c),c>i&&(i=c));if(i===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(i+1);for(const c of o)c&&r[c]++;const n=new Uint32Array(i+1);let h=0;r[0]=0;for(let c=1;c<=i;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[ge(f,u)]=c}return{min:t,max:i,table:a}}function At(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.readBits(1)<<r-1;const n=t.table.get(r);if(n&&i<n.length){const h=n[i];if(h!==void 0)return h}}throw Error("Invalid Huffman code")}function ge(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function Ae(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],i=o[1];if((15&t)!=8)throw Error("Unsupported ZLIB compression method");if(((t<<8)+i)%31!=0)throw Error("Bad ZLIB header check");let r=2;32&i&&(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 p=h.readBits(2);if(p===0){h.alignToByte();const m=h.readBits(16);if((65535&(65535^m))!==h.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<m;v++)a.push(h.readBits(8))}else{if(p!==1&&p!==2)throw Error("Unsupported DEFLATE type");{let m,v;if(p===1){const A=Array(288).fill(0);for(let w=0;w<=143;w++)A[w]=8;for(let w=144;w<=255;w++)A[w]=9;for(let w=256;w<=279;w++)A[w]=7;for(let w=280;w<=287;w++)A[w]=8;m=Q(A),v=Q(Array(32).fill(5))}else{const A=h.readBits(5)+257,w=h.readBits(5)+1,y=h.readBits(4)+4,T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E=Array(19).fill(0);for(let M=0;M<y;M++)E[T[M]]=h.readBits(3);const U=Q(E),b=[];for(;b.length<A+w;){const M=At(h,U);if(M<=15)b.push(M);else if(M===16){const D=h.readBits(2)+3,P=b[b.length-1]||0;for(let at=0;at<D;at++)b.push(P)}else if(M===17){const D=h.readBits(3)+3;for(let P=0;P<D;P++)b.push(0)}else{if(M!==18)throw Error("Invalid code length symbol");{const D=h.readBits(7)+11;for(let P=0;P<D;P++)b.push(0)}}}const I=b.slice(0,A),L=b.slice(A,A+w);m=Q(I),v=Q(L)}for(;;){const A=At(h,m);if(A<256)a.push(A);else{if(A===256)break;if(A>256&&A<286){const w=A-257;let y=c[w];const T=u[w];T&&(y+=h.readBits(T));const E=At(h,v);if(E>=30)throw Error("Invalid distance symbol");let U=f[E];const b=d[E];b&&(U+=h.readBits(b));const I=a.length-U;if(I<0)throw Error("Invalid distance");for(let L=0;L<y;L++)a.push(a[I+L]||0)}else if(A===286||A===287)throw Error("Reserved length symbol")}}}}}}(new de(o.subarray(r)),n),new Uint8Array(n)}function pe(o){const t=C,i=new Uint8Array(o);if(t.readASCII(i,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(i,4),n=t.readUshort(i,12),h=t.readUint(i,16),a=[];let c=44;for(let y=0;y<n;y++){const T=t.readASCII(i,c,4),E=t.readUint(i,c+4),U=t.readUint(i,c+8),b=t.readUint(i,c+12),I=t.readUint(i,c+16);a.push({tag:T,offset:E,compLength:U,origLength:b,checksum:I}),c+=20}for(const y of a){const T=new Uint8Array(i.buffer,y.offset,y.compLength);if(y.compLength===y.origLength)y.data=new Uint8Array(T);else if(y.data=Ae(T),y.data.length!==y.origLength)if(y.data.length<y.origLength){const E=new Uint8Array(y.origLength);E.set(y.data),y.data=E}else y.data=y.data.subarray(0,y.origLength)}const u=n;let f=1,d=0;for(;f<<1<=u;)f<<=1,d++;const g=16*f,p=16*u-g;let m=12+16*u;const v={};for(const y of a)v[y.tag]=m,m=st(m+y.data.length);const A=new Uint8Array(Math.max(h||0,m));O(A,0,r),rt(A,4,u),rt(A,6,g),rt(A,8,d),rt(A,10,p);let w=12;for(const y of a){fe(A,w,y.tag),w+=4;let T=y.data;if(y.tag==="head"&&T.length>=12){const E=new Uint8Array(T);O(E,8,0),O(A,w,gt(E,0,st(E.length))),w+=4}else O(A,w,gt(T,0,st(T.length))),w+=4;O(A,w,v[y.tag]),w+=4,O(A,w,y.data.length),w+=4}for(const y of a){const T=v[y.tag];A.set(y.data,T)}if(a.find(y=>y.tag==="head")){const y=v.head,T=function(E,U){const b=U+8,I=[E[b],E[b+1],E[b+2],E[b+3]];O(E,b,0);const L=2981146554-(gt(E,0,st(E.length))>>>0)>>>0;return E[b]=I[0],E[b+1]=I[1],E[b+2]=I[2],E[b+3]=I[3],L>>>0}(A,y);O(A,y+8,T)}return A.buffer}const me={parseTab(o,t,i){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,i),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 p=`p${f}e${d}`;let m=c.indexOf(g);if(m===-1){let v;m=r.tables.length,c.push(g);const A=h(o,g);v=A===4?this.parse4(o,g):A===12?this.parse12(o,g):{format:A},r.tables.push(v)}r.ids[p]=m}return r},parse4(o,t){const i=C,r=i.readUshort,n=i.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(i.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 i=C.readUint;i(o,t+=4),i(o,t+=4);const r=i(o,t+=4);t+=4;const n=new Uint32Array(3*r);for(let h=0;h<3*r;h+=3)n[h]=i(o,t+(h<<2)),n[h+1]=i(o,t+(h<<2)+4),n[h+2]=i(o,t+(h<<2)+8);return{format:12,groups:n}}},ve={parseTab(o,t,i){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)}}},ye={parseTab(o,t,i){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}},we={parseTab(o,t,i,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}}},It={cmap:me,head:ve,hhea:ye,maxp:{parseTab(o,t,i){const r=C;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:we,loca:{parseTab(o,t,i,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,i,r){const n=[],h=r.maxp.numGlyphs;for(let a=0;a<h;a++)n.push(null);return n},Ci(o,t){const i=C,r=o.Mi,n=o.loca;if(n[t]===n[t+1])return null;const h=J.findTable(r,"glyf",o.xi);if(!h)return null;let a=h[0]+n[t];const c={};if(c.noc=i.readShort(r,a),a+=2,c.xMin=i.readShort(r,a),a+=2,c.yMin=i.readShort(r,a),a+=2,c.xMax=i.readShort(r,a),a+=2,c.yMax=i.readShort(r,a),a+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(let p=0;p<c.noc;p++)c.endPts.push(i.readUshort(r,a)),a+=2;const u=i.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 p=0;p<f;p++){const m=r[a];if(a++,c.flags.push(m),8&m){const v=r[a];a++;for(let A=0;A<v;A++)c.flags.push(m),p++}}c.xs=[];for(let p=0;p<f;p++){const m=c.flags[p],v=!!(16&m);2&m?(c.xs.push(v?r[a]:-r[a]),a++):v?c.xs.push(0):(c.xs.push(i.readShort(r,a)),a+=2)}c.ys=[];for(let p=0;p<f;p++){const m=c.flags[p],v=!!(32&m);4&m?(c.ys.push(v?r[a]:-r[a]),a++):v?c.ys.push(0):(c.ys.push(i.readShort(r,a)),a+=2)}let d=0,g=0;for(let p=0;p<f;p++)d+=c.xs[p],g+=c.ys[p],c.xs[p]=d,c.ys[p]=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=pe(o));const i=new Uint8Array(o),r=It,n={},h={Mi:i,Fi:0,xi:0};for(const a in r){const c=a,u=J.findTable(i,c,0);if(u){const[f,d]=u;let g=n[f];g==null&&(g=r[c].parseTab(i,f,d,h),n[f]=g),h[c]=g}}return[h]},findTable(o,t,i){const r=C,n=r.readUshort(o,i+4);let h=i+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:It,B:C};class Ee{Ti(t){var r;const i=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(n=>{if(n.format===4){const h=this.$i(n);i.push(...h)}else if(n.format===12){const h=this.Pi(n);i.push(...h)}}),[...new Set(i)]):[]}$i(t){const i=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return i;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.Ei(t,a,r)>0)try{const c=String.fromCodePoint(a);i.push(c)}catch{}}}return i}Pi(t){const i=[];if(!t.groups)return i;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);i.push(u)}catch{}}return i}Ei(t,i,r){if(t.idRangeOffset[r]===0)return i+t.idDelta[r]&65535;{const n=t.idRangeOffset[r]/2+(i-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 Te{constructor(t){l(this,"Ri");l(this,"Si");l(this,"K");this.K=t,this.Ri=document.createElement("canvas"),this.Si=this.Ri.getContext("2d",{willReadFrequently:!0,alpha:!0})}Ui(t,i,r,n){const h=t.length,a=Math.ceil(Math.sqrt(h)),c=Math.ceil(h/a),u=i.width*a,f=i.height*c;this.ki(u,f),this.zi(t,i,a,r,n);const d=this.K.yi(u,f,1,{filter:"nearest"});return d.tt(this.Ri),{framebuffer:d,columns:a,rows:c}}ki(t,i){this.Ri.width=t,this.Ri.height=i,this.Ri.style.width=t+"px",this.Ri.style.height=i+"px",this.Si.imageSmoothingEnabled=!1,this.Ri.style.imageRendering="pixelated",this.Si.clearRect(0,0,t,i),this.Si.textBaseline="top",this.Si.textAlign="left",this.Si.fillStyle="white"}zi(t,i,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,p=u*i.width,m=f*i.height,v=p+.5*i.width,A=m+.5*i.height,w=Math.round(v-.5*i.width),y=Math.round(A-.5*n),T=w+.5*(i.width-g),E=y+h.hhea.ascender*a;this.Li(d,T,E,a)}}Li(t,i,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.Si.beginPath();let f=0;for(let d=0;d<c.length;d++){const g=c[d];if(!(g<f)){if(g>=f){const p=i+h[f]*n,m=r-a[f]*n;this.Si.moveTo(p,m);let v=f+1;for(;v<=g;)if(1&u[v]){const A=i+h[v]*n,w=r-a[v]*n;this.Si.lineTo(A,w),v++}else{const A=i+h[v]*n,w=r-a[v]*n;if(v+1>g){const T=i+h[f]*n,E=r-a[f]*n;if(1&u[f])this.Si.quadraticCurveTo(A,w,T,E);else{const U=(A+T)/2,b=(w+E)/2;this.Si.quadraticCurveTo(A,w,U,b)}break}const y=v+1;if(1&u[y]){const T=i+h[y]*n,E=r-a[y]*n;this.Si.quadraticCurveTo(A,w,T,E),v=y+1}else{const T=(A+(i+h[y]*n))/2,E=(w+(r-a[y]*n))/2;this.Si.quadraticCurveTo(A,w,T,E),v=y}}this.Si.closePath()}f=g+1}}this.Si.fill()}}class Bt{Oi(t,i){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.Di(i,h):h.format===12&&(n=this.Hi(i,h)),n>0)break;return n}Ii(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Oi(t,r)}Bi(t,i){const r=t.hmtx;return r&&r.aWidth&&r.aWidth.length!==0?i<r.aWidth.length?r.aWidth[i]:r.aWidth[r.aWidth.length-1]:0}Gi(t,i){const r=i/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}}Di(t,i){const r=i.endCount.length;let n=-1;for(let h=0;h<r;h++)if(t<=i.endCount[h]){n=h;break}if(n===-1||t<i.startCount[n])return 0;if(i.idRangeOffset[n]===0)return t+i.idDelta[n]&65535;{const h=i.idRangeOffset[n]/2+(t-i.startCount[n])-(r-n);if(h>=0&&h<i.glyphIdArray.length){const a=i.glyphIdArray[h];return a===0?0:a+i.idDelta[n]&65535}}return 0}Hi(t,i){const r=i.groups.length/3;for(let n=0;n<r;n++){const h=i.groups[3*n],a=i.groups[3*n+1],c=i.groups[3*n+2];if(t>=h&&t<=a)return c+(t-h)}return 0}}class be{constructor(){l(this,"Ni");this.Ni=new Bt}Xi(t,i,r){let n=0;const h=this.Ni.Gi(r,i),a=h.lineHeight;for(const c of t){const u=this.Ni.Ii(r,c);if(u===0)continue;const f=this.Ni.Bi(r,u)*h.scale;n=Math.max(n,f)}return{width:Math.ceil(n),height:Math.ceil(a)}}}class xe{constructor(){l(this,"Yi");this.Yi=new Bt}Ki(t,i){const r=[],n=new Map;return t.forEach((h,a)=>{const c=h.codePointAt(0)||0,u={character:h,unicode:c,color:this.Wi(a),glyphData:this.Zi(i,h)};r.push(u),n.set(h,u)}),{array:r,map:n}}Wi(t){return[t%256/255,Math.floor(t/256)%256/255,0]}Zi(t,i){const r=i.codePointAt(0)||0,n=this.Yi.Oi(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.Ci(t,n);return a?{...a,advanceWidth:h}:null}}class pt{constructor(t,i=16){l(this,"ji");l(this,"Vi",[]);l(this,"qi",new Map);l(this,"Qi");l(this,"Ji",16);l(this,"tr",0);l(this,"sr",0);l(this,"er",{width:0,height:0});l(this,"ir");l(this,"rr");l(this,"nr");l(this,"hr");l(this,"ar");this.Ji=i,this.rr=new Ee,this.nr=new Te(t),this.hr=new be,this.ar=new xe}async cr(t){let i;if(t){const r=await fetch(t);if(!r.ok)throw new R(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}else i=await(await fetch("data:font/woff;base64,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")).arrayBuffer();await this.lr(i),this.ji=J.parse(i)[0],await this.ur()}dr(t){if(t===void 0)return this.Ji;this.Ji=t,this.er=this.hr.Xi(this.Vi.map(r=>r.character),this.Ji,this.ji);const i=this.nr.Ui(this.Vi,this.er,this.Ji,this.ji);this.Qi=i.framebuffer,this.tr=i.columns,this.sr=i.rows}async pr(t){try{const i=await fetch(t);if(!i.ok)throw new R(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.lr(r);const n=J.parse(r);if(!n||n.length===0)throw Error("Failed to parse font file");this.ji=n[0],await this.ur()}catch(i){throw new R("Failed to load font: "+(i instanceof Error?i.message:"Unknown error"),i)}}async lr(t){const i=Date.now();this.ir=new FontFace("CustomFont_"+i,t),await this.ir.load(),document.fonts.add(this.ir)}async ur(){const t=this.rr.Ti(this.ji),{array:i,map:r}=this.ar.Ki(t,this.ji);this.Vi=i,this.qi=r,this.er=this.hr.Xi(t,this.Ji,this.ji);const n=this.nr.Ui(this.Vi,this.er,this.Ji,this.ji);this.Qi=n.framebuffer,this.tr=n.columns,this.sr=n.rows}gr(t){const i=this.qi.get(t);return i?i.color:[0,0,0]}vr(t){return Array.from(t).map(i=>{const r=this.qi.get(i);return r?r.color:[0,0,0]})}ft(){this.Qi.ft(),document.fonts.delete(this.ir)}get fontFramebuffer(){return this.Qi}get characterMap(){return this.qi}get characters(){return this.Vi}get textureColumns(){return this.tr}get textureRows(){return this.sr}get maxGlyphDimensions(){return this.er}get fontSize(){return this.Ji}get font(){return this.ji}}class mt{constructor(t,i,r){l(this,"mr");l(this,"_r");l(this,"H");l(this,"I");l(this,"Ar");l(this,"yr");l(this,"wr");l(this,"br");l(this,"Cr");this.wr=t,this.br=i,this.Cr=r,this.js()}js(){this.mr=Math.floor(this.wr.width/this.br),this._r=Math.floor(this.wr.height/this.Cr),this.H=this.mr*this.br,this.I=this._r*this.Cr,this.Ar=Math.floor((this.wr.width-this.H)/2),this.yr=Math.floor((this.wr.height-this.I)/2)}Mr(t,i){this.br=t,this.Cr=i,this.js()}get cellWidth(){return this.br}get cellHeight(){return this.Cr}get cols(){return this.mr}get rows(){return this._r}get width(){return this.H}get height(){return this.I}get offsetX(){return this.Ar}get offsetY(){return this.yr}}const Re=/^rgba?\(([^)]+)\)$/i;function vt(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function Fe(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t)return null;let i=null;return t.startsWith("rgb")&&(i=function(r){const n=Re.exec(r.trim());if(!n)return null;const h=n[1].split(",").map(d=>d.trim());if(h.length<3)return null;const a=vt(parseFloat(h[0])),c=vt(parseFloat(h[1])),u=vt(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)),i?i[3]===0?null:i:null}class St{constructor(t={}){l(this,"wr");l(this,"Fr",null);l(this,"Tr",!1);l(this,"$r");this.Tr=t.overlay??!1,this.Tr&&t.canvas?(this.Fr=t.canvas,this.wr=this.Pr(),this.$r=!0,this.Er()):t.canvas?(this.wr=t.canvas,this.$r=!1):(this.wr=this.Rr(t.width,t.height),this.$r=!0),this.wr.style.imageRendering="pixelated"}Rr(t,i){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=i||600,document.body.appendChild(r),r}Pr(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.Fr.getBoundingClientRect();let r=Math.round(i.width),n=Math.round(i.height);if(this.Fr instanceof HTMLVideoElement){const c=this.Fr;(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.Fr);let a=parseInt(h.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=""+(a+1),t}Er(){var t;this.Sr(),(t=this.Fr.parentNode)==null||t.insertBefore(this.wr,this.Fr.nextSibling)}Ur(){const t=[];return this.Tr&&this.Fr instanceof HTMLElement&&(t.push(this.Fr),this.Fr.parentElement&&t.push(this.Fr.parentElement)),this.wr.parentElement&&t.push(this.wr.parentElement),t.push(this.wr),t.push(document.body),t.push(document.documentElement),t}kr(){const t=this.Ur();for(const i of t){if(!i)continue;const r=Fe(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}Sr(){if(!this.Fr)return;const t=this.Fr.getBoundingClientRect();let i=this.Fr.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.wr.style.top=t.top-r.top+"px",this.wr.style.left=t.left-r.left+"px"}else this.wr.style.top=t.top+window.scrollY+"px",this.wr.style.left=t.left+window.scrollX+"px"}zr(t,i){if(this.Tr){const r=this.Fr.getBoundingClientRect();this.wr.width=Math.round(r.width),this.wr.height=Math.round(r.height),this.Sr()}else this.wr.width=t??this.wr.width,this.wr.height=i??this.wr.height}Lr(){const t=this.wr.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new R("`textmode.js` requires WebGL2 support.");return t}ft(){const t=this.wr.getContext("webgl")||this.wr.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.loseContext()}this.$r&&this.wr.parentNode&&this.wr.parentNode.removeChild(this.wr)}get canvas(){return this.wr}get targetCanvas(){return this.Fr}get width(){return this.wr.width}get height(){return this.wr.height}}function nt(o){return z(parseInt(o,16),0,255)}class B{constructor(t,i,r,n){l(this,"Or");l(this,"Dr");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=z(t,0,255),this.g=z(i,0,255),this.b=z(r,0,255),this.a=z(n,0,255),this.Or=[this.r,this.g,this.b,this.a],this.Dr=[this.r/255,this.g/255,this.b/255,this.a/255]}static Hr(t,i,r,n){if(B.Ir(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 B.Br(h,a,c,u)}if(typeof t=="string"){const h=t.trim();if(h.length===0)throw Error("Color strings cannot be empty.");return B.Gr(h)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?B.Br(t,i,r,n??255):B.Nr(t);throw Error("Unsupported color input passed to TextmodeColor.$from.")}static Br(t,i,r,n=255){return new B(t,i,r,n)}static Nr(t,i=255){return new B(t,t,t,i)}static Gr(t){return new B(...function(i){const r=i.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: "+i);return[nt(n.slice(0,2)),nt(n.slice(2,4)),nt(n.slice(4,6)),n.length===8?nt(n.slice(6,8)):255]}(t))}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.Or]}get normalized(){return[...this.Dr]}withAlpha(t){return new B(this.r,this.g,this.b,t)}static Ir(t){return t instanceof B}}const yt=new Map;function Pt(o){yt.set(o.id,o)}function Lt(o){return yt.get(o)}class Nt{constructor(t,i,r,n,h,a,c,u){l(this,"A");l(this,"K");l(this,"Xr");l(this,"Yr");l(this,"Kr");l(this,"H");l(this,"I");l(this,"W",null);l(this,"ji");l(this,"Wr","brightness");l(this,"Zr",null);l(this,"Tt",0);l(this,"Dt",0);l(this,"Ht",0);l(this,"$t",0);l(this,"jr","sampled");l(this,"Vr","fixed");l(this,"Bt",[1,1,1,1]);l(this,"Gt",[0,0,0,1]);l(this,"qr",[0,0,0,1]);l(this,"Qr",[[.1,0,0]]);l(this,"Jr",null);l(this,"tn",new Set);l(this,"sn",[[0,0,0,0]]);l(this,"en",0);this.A=t,this.K=i,this.Xr=r,this.ji=n,this.Yr=h,this.Kr=a,this.H=c,this.I=u}conversionMode(t){return this.Wr=t,this.Zr=null,this.W=null,this}ft(){this.A.deleteTexture(this.Xr);for(const t of this.tn)t();this.tn.clear()}rn(t){this.tn.add(t)}invert(t=!0){return this.Tt=t?1:0,this.W=null,this}flipX(t=!0){return this.Dt=t?1:0,this.W=null,this}flipY(t=!0){return this.Ht=t?1:0,this.W=null,this}charRotation(t){return this.$t=bt(t),this.W=null,this}charColorMode(t){return this.jr=t,this.W=null,this}cellColorMode(t){return this.Vr=t,this.W=null,this}charColor(t,i,r,n){return this.nn(this.Bt,t,i,r,n),this.W=null,this}cellColor(t,i,r,n){return this.nn(this.Gt,t,i,r,n),this.W=null,this}background(t,i,r,n){return this.nn(this.qr,t,i,r,n),this.W=null,this}colorFilter(t){if(!t||t.length===0)return this.en=0,this.sn=[[0,0,0,0]],this.W=null,this;const i=[];for(const r of t){if(i.length>=64)break;let n=B.Hr(r);i.push(n.normalized)}return this.sn=i,this.en=i.length,this.W=null,this}characters(t){return this.Jr=t,this.hn(t),this.W=null,this}an(t){this.ji=t,this.Jr&&this.hn(this.Jr),this.W=null}get texture(){return this.Xr}get width(){return this.H}get height(){return this.I}get originalWidth(){return this.Yr}get originalHeight(){return this.Kr}ht(){return this.W||this.ct(),this.W}cn(){}ct(){this.cn();const t=this.ln(),i=this.un(),r=t.createShader(i),n=t.createUniforms(i);this.W=this.K.materialManager.De(r,n)}nn(t,i,r,n,h){const a=B.Hr(i,r,n,h);et(t,a.r,a.g,a.b,a.a)}hn(t){const i=this.ji.vr(t).filter(r=>Array.isArray(r)).slice(0,255);this.Qr=i.length>0?i:this.Qr}createBaseConversionUniforms(){const t=this.en>0;return{u_image:this.fn(),u_invert:!!this.Tt,u_flipX:!!this.Dt,u_flipY:!!this.Ht,u_charRotation:this.$t,u_charColorFixed:this.jr==="fixed",u_charColor:this.Bt,u_cellColorFixed:this.Vr==="fixed",u_cellColor:this.Gt,u_backgroundColor:this.qr,u_charCount:this.Qr.length,u_charList:this.Qr,u_colorFilterEnabled:t,u_colorFilterSize:t?this.en:0,u_colorFilterPalette:this.sn}}ln(){if(this.Zr&&this.Zr.id===this.Wr)return this.Zr;const t=Lt(this.Wr);if(!t)throw Error(`[textmode.js] Conversion mode "${this.Wr}" is not registered. If this mode is provided by an add-on, make sure its plugin is installed before loading sources.`);return this.Zr=t,t}un(){return{renderer:this.K,gl:this.A,font:this.ji,source:this,gridWidth:this.H,gridHeight:this.I}}}class k extends Nt{constructor(t,i,r,n,h,a,c,u){const f=Math.min(c/h,u/a);super(t,i,r,n,h,a,Math.max(1,Math.floor(h*f)),Math.max(1,Math.floor(a*f)))}static dn(t,i,r,n,h){const a=t.context,c=a.createTexture();a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),$(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,i,u,f,n,h)}fn(){return this.Xr}}class Dt{constructor(t=60){l(this,"pn");l(this,"gn",null);l(this,"vn",0);l(this,"mn",!0);l(this,"_n",0);l(this,"An",0);l(this,"yn",[]);l(this,"wn",10);l(this,"bn",0);this.pn=1e3/t}Cn(t){if(!this.mn)return;this.vn=performance.now();const i=r=>{if(!this.mn)return void(this.gn=null);const n=r-this.vn;n>=this.pn&&(t(),this.vn=r-n%this.pn),this.mn&&(this.gn=requestAnimationFrame(i))};this.gn=requestAnimationFrame(i)}Mn(){this.gn&&(cancelAnimationFrame(this.gn),this.gn=null)}xn(){this.mn&&(this.mn=!1,this.Mn())}Fn(t){this.mn||(this.mn=!0,this.Cn(t))}Tn(t,i){if(t===void 0)return this._n;this.pn=1e3/t,this.mn&&i&&(this.Mn(),this.Cn(i))}$n(){const t=performance.now();if(this.An>0){const i=t-this.An;this.yn.push(i),this.yn.length>this.wn&&this.yn.shift();const r=this.yn.reduce((n,h)=>n+h,0)/this.yn.length;this._n=1e3/r}this.An=t}get Pn(){return this.mn}get En(){return this._n}get Rn(){return this.bn}set Rn(t){this.bn=t}Sn(){this.bn++}}class Ot{constructor(t){l(this,"wr");l(this,"Un");l(this,"kn",{x:-1,y:-1});l(this,"zn",{x:-1,y:-1});l(this,"Ln",null);l(this,"On",0);l(this,"Dn");l(this,"Hn");l(this,"In");l(this,"Bn");l(this,"Gn");l(this,"Nn");l(this,"Xn",!1);l(this,"Yn");l(this,"Kn");l(this,"Wn");l(this,"Zn");l(this,"jn");this.wr=t}Vn(t){const i=performance.now()+Math.max(0,t);i>this.On&&(this.On=i)}qn(){return performance.now()<this.On}Qn(t){const i=this.wr.canvas;i.style.cursor=t==null||t===""?"":t}cr(t){this.Un=t,this.Jn()}so(){if(this.Xn)return;const t=this.wr.canvas;this.Dn=i=>{this.eo(i),this.io(i)},this.Hn=()=>{this.zn={...this.kn},this.kn.x=-1,this.kn.y=-1,this.Ln=null},this.In=i=>{this.eo(i),this.ro(i)},this.Bn=i=>{this.eo(i),this.no(i)},this.Gn=i=>{this.eo(i),this.oo(i)},this.Nn=i=>{this.eo(i),this.ho(i)},t.addEventListener("mousemove",this.Dn,{passive:!0}),t.addEventListener("mouseleave",this.Hn,{passive:!0}),t.addEventListener("mousedown",this.In,{passive:!0}),t.addEventListener("mouseup",this.Bn,{passive:!0}),t.addEventListener("click",this.Gn,{passive:!0}),t.addEventListener("wheel",this.Nn,{passive:!1}),this.Xn=!0}ao(){if(!this.Xn)return;const t=this.wr.canvas;t.removeEventListener("mousemove",this.Dn),t.removeEventListener("mouseleave",this.Hn),t.removeEventListener("mousedown",this.In),t.removeEventListener("mouseup",this.Bn),t.removeEventListener("click",this.Gn),t.removeEventListener("wheel",this.Nn),this.Xn=!1}Jn(){if(this.Xn)try{if(this.Ln){const t=new MouseEvent("mousemove",{clientX:this.Ln.x,clientY:this.Ln.y,bubbles:!1,cancelable:!1});this.eo(t)}else this.kn.x!==-1&&this.kn.y!==-1&&(this.kn.x>=this.Un.cols||this.kn.y>=this.Un.rows)&&(this.kn.x=-1,this.kn.y=-1)}catch{this.kn.x=-1,this.kn.y=-1}}co(t){this.Yn=t}lo(t){this.Kn=t}uo(t){this.Wn=t}fo(t){this.Zn=t}do(t){this.jn=t}po(){return{x:this.kn.x,y:this.kn.y}}io(t){if(this.Zn&&!this.qn()){const i={position:{...this.kn},previousPosition:{...this.zn},originalEvent:t};this.Zn(i)}}ro(t){if(this.Kn&&!this.qn()){const i={position:{...this.kn},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Kn(i)}}no(t){if(this.Wn&&!this.qn()){const i={position:{...this.kn},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Wn(i)}}oo(t){if(this.Yn&&!this.qn()){const i={position:{...this.kn},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Yn(i)}}ho(t){if(this.jn&&!this.qn()){const i={position:{...this.kn},previousPosition:{...this.zn},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.jn(i)}}eo(t){const i=this.wr.canvas;this.zn={...this.kn},this.Ln={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),n=t.clientX-r.left,h=t.clientY-r.top,a=i.width/r.width,c=h*(i.height/r.height),u=n*a-this.Un.offsetX,f=c-this.Un.offsetY,d=Math.floor(u/this.Un.cellWidth),g=Math.floor(f/this.Un.cellHeight);d>=0&&d<this.Un.cols&&g>=0&&g<this.Un.rows?(this.kn.x=d,this.kn.y=g):(this.kn.x=-1,this.kn.y=-1)}}const Ce=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:Ot},Symbol.toStringTag,{value:"Module"}));class _t{constructor(){l(this,"vo",new Map);l(this,"mo",null);l(this,"_o",null);l(this,"Ao");l(this,"yo");l(this,"Xn",!1);l(this,"wo");l(this,"bo");l(this,"Co",{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"})}so(){this.Xn||(this.Ao=t=>{this.Mo(t)},this.yo=t=>{this.xo(t)},window.addEventListener("keydown",this.Ao,{passive:!1}),window.addEventListener("keyup",this.yo,{passive:!1}),this.Xn=!0)}ao(){this.Xn&&(window.removeEventListener("keydown",this.Ao),window.removeEventListener("keyup",this.yo),this.Xn=!1,this.vo.clear(),this.mo=null,this._o=null)}lo(t){this.wo=t}uo(t){this.bo=t}Fo(t){const i=this.To(t),r=this.vo.get(t)||this.vo.get(i);return(r==null?void 0:r.isPressed)||!1}$o(){return this.mo}Po(){return this._o}Eo(){const t=[];for(const[i,r]of this.vo)r.isPressed&&t.push(i);return t}Ro(){return{ctrl:this.Fo("Control"),shift:this.Fo("Shift"),alt:this.Fo("Alt"),meta:this.Fo("Meta")}}So(){this.vo.clear(),this.mo=null,this._o=null}Mo(t){const i=t.key,r=Date.now();this.vo.has(i)||this.vo.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.vo.get(i);if(!n.isPressed&&(n.isPressed=!0,n.lastPressTime=r,this.mo=i,this.wo)){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.wo(h)}}xo(t){const i=t.key,r=Date.now();this.vo.has(i)||this.vo.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.vo.get(i);if(n.isPressed=!1,n.lastReleaseTime=r,this._o=i,this.bo){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.bo(h)}}To(t){return this.Co[t]||t.toLowerCase()}}const Ue=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:_t},Symbol.toStringTag,{value:"Module"}));class Xt{constructor(t,i){l(this,"wr");l(this,"Uo");l(this,"Un");l(this,"ko",new Map);l(this,"zo",new Map);l(this,"Lo",new Map);l(this,"Oo",null);l(this,"Do");l(this,"Ho");l(this,"Io");l(this,"Bo");l(this,"Go");l(this,"No");l(this,"Xn",!1);l(this,"Xo");l(this,"Yo");l(this,"Ko");l(this,"Wo");l(this,"Zo");l(this,"jo");l(this,"Vo");l(this,"qo");l(this,"Qo");l(this,"Jo");l(this,"th",320);l(this,"sh",350);l(this,"eh",10);l(this,"ih",550);l(this,"rh",14);l(this,"nh",48);l(this,"oh",650);l(this,"hh",.02);l(this,"ah",2);l(this,"uh",600);l(this,"fh",0);l(this,"dh",null);this.wr=t,this.Uo=i;const r=this.wr.canvas;this.Do=r.style.touchAction,this.Ho=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}cr(t){this.Un=t,this.Jn()}so(){if(this.Xn)return;const t=this.wr.canvas;this.Io=i=>{this.ph(i)},this.Bo=i=>{this.gh(i)},this.Go=i=>{this.mh(i)},this.No=i=>{this._h(i)},t.addEventListener("touchstart",this.Io,{passive:!1}),t.addEventListener("touchmove",this.Bo,{passive:!1}),t.addEventListener("touchend",this.Go,{passive:!1}),t.addEventListener("touchcancel",this.No,{passive:!1}),this.Xn=!0}ao(){if(!this.Xn)return;const t=this.wr.canvas;t.removeEventListener("touchstart",this.Io),t.removeEventListener("touchmove",this.Bo),t.removeEventListener("touchend",this.Go),t.removeEventListener("touchcancel",this.No),this.Xn=!1,this.Oo=null,this.ko.clear(),this.zo.clear(),this.Lo.forEach(i=>{i.longPressTimer!==null&&window.clearTimeout(i.longPressTimer)}),this.Lo.clear(),this.dh=null,this.fh=0,t.style.touchAction=this.Do,t.style.userSelect=this.Ho}Jn(){if(!this.Un||this.ko.size===0)return;const t=new Map;for(const i of this.ko.values()){const r=this.Ah(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.ko=t}yh(){return Array.from(this.ko.values()).map(t=>({...t}))}wh(t){this.Xo=t}fo(t){this.Yo=t}bh(t){this.Ko=t}Ch(t){this.Wo=t}Mh(t){this.Zo=t}xh(t){this.jo=t}Fh(t){this.Vo=t}Th(t){this.qo=t}$h(t){this.Qo=t}Ph(t){this.Jo=t}ph(t){var n;if(!this.Un)return;t.preventDefault(),(n=this.Uo)==null||n.Vn(this.uh);const i=performance.now(),r=this.Eh(t.changedTouches);for(const h of r){const a=this.ko.get(h.id);a&&this.zo.set(h.id,this.Rh(a)),this.ko.set(h.id,h);const c={id:h.id,startPosition:h,lastPosition:h,startTime:i,lastTime:i,longPressTimer:null,longPressFired:!1};this.Vo&&(c.longPressTimer=window.setTimeout(()=>{const u=this.ko.get(h.id);u&&(c.longPressFired=!0,this.Vo({touch:this.Rh(u),duration:performance.now()-c.startTime,originalEvent:t}))},this.ih)),this.Lo.set(h.id,c),this.Xo&&this.Xo(this.Sh(h,t,void 0,i))}this.ko.size===2&&this.kh()}gh(t){var n;if(!this.Un)return;t.preventDefault(),(n=this.Uo)==null||n.Vn(this.uh);const i=performance.now(),r=this.Eh(t.changedTouches);for(const h of r){const a=this.ko.get(h.id),c=a?this.Rh(a):void 0;c&&this.zo.set(h.id,c),this.ko.set(h.id,h);const u=this.Lo.get(h.id);u&&(u.lastPosition=h,u.lastTime=i,c)&&W(c.clientX,c.clientY,h.clientX,h.clientY)>this.rh&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.Yo&&this.Yo(this.Sh(h,t,c,i))}this.ko.size===2?this.zh(t):this.Oo=null}mh(t){if(!this.Un)return;t.preventDefault();const i=performance.now(),r=this.Eh(t.changedTouches);for(const n of r){const h=this.ko.get(n.id),a=h?this.Rh(h):void 0,c=this.Lo.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.Ko&&this.Ko(this.Sh(n,t,a,i)),c&&this.Lh(c,t),this.Lo.delete(n.id),this.zo.delete(n.id),this.ko.delete(n.id)}this.ko.size<2&&(this.Oo=null)}_h(t){if(!this.Un)return;t.preventDefault();const i=performance.now(),r=this.Eh(t.changedTouches);for(const n of r){const h=this.ko.get(n.id),a=h?this.Rh(h):void 0,c=this.Lo.get(n.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.Wo&&this.Wo(this.Sh(n,t,a,i)),this.Lo.delete(n.id),this.zo.delete(n.id),this.ko.delete(n.id)}this.ko.size<2&&(this.Oo=null)}Eh(t){const i=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&i.push(this.Oh(n))}return i}Oh(t){return this.Ah(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})}Ah(t,i,r,n){const h=this.wr.canvas,a=h.getBoundingClientRect(),c=t-a.left,u=i-a.top,f=h.width/a.width,d=u*(h.height/a.height),g=c*f-this.Un.offsetX,p=d-this.Un.offsetY,m=Math.floor(g/this.Un.cellWidth),v=Math.floor(p/this.Un.cellHeight),A=m>=0&&m<this.Un.cols&&v>=0&&v<this.Un.rows;return{id:r,x:A?m:-1,y:A?v:-1,clientX:t,clientY:i,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Sh(t,i,r,n){const h=this.Lo.get(t.id),a=Array.from(this.zo.values()).map(f=>this.Rh(f)),c=Array.from(this.ko.values()).map(f=>this.Rh(f)),u=this.Eh(i.changedTouches);return{touch:this.Rh(t),previousTouch:r?this.Rh(r):void 0,touches:c,previousTouches:a,changedTouches:u,deltaTime:h?n-h.lastTime:0,originalEvent:i}}kh(){if(this.ko.size!==2)return void(this.Oo=null);const t=Array.from(this.ko.values()),[i,r]=t,n=W(i.x,i.y,r.x,r.y),h=Tt(i.clientX,i.clientY,r.clientX,r.clientY);this.Oo={ids:[i.id,r.id],initialDistance:Math.max(n,1e-4),initialAngle:h,lastScale:1,lastRotation:0}}zh(t){if(this.Oo||this.kh(),!this.Oo)return;const[i,r]=this.Oo.ids,n=this.ko.get(i),h=this.ko.get(r);if(!n||!h)return;const a=W(n.x,n.y,h.x,h.y)/this.Oo.initialDistance,c=a-this.Oo.lastScale;this.Qo&&Math.abs(c)>this.hh&&(this.Qo({touches:[this.Rh(n),this.Rh(h)],scale:a,deltaScale:c,center:this.Dh(n,h),originalEvent:t}),this.Oo.lastScale=a);let u=Tt(n.clientX,n.clientY,h.clientX,h.clientY)-this.Oo.initialAngle;u=(u+180)%360-180;const f=u-this.Oo.lastRotation;this.Jo&&Math.abs(f)>this.ah&&(this.Jo({touches:[this.Rh(n),this.Rh(h)],rotation:u,deltaRotation:f,center:this.Dh(n,h),originalEvent:t}),this.Oo.lastRotation=u)}Dh(t,i){const r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,h=this.Ah(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:h.x,y:h.y}}Lh(t,i){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.th&&h<=this.eh)this.Hh(t.lastPosition,r)&&this.jo?this.jo({touch:this.Rh(t.lastPosition),taps:2,originalEvent:i}):this.Zo&&this.Zo({touch:this.Rh(t.lastPosition),taps:1,originalEvent:i});else if(!t.longPressFired&&n<=this.oh&&h>=this.nh){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.qo&&this.qo({touch:this.Rh(t.lastPosition),direction:u,distance:c,velocity:f,originalEvent:i})}this.fh=r,this.dh=this.Rh(t.lastPosition)}Hh(t,i){return!!this.dh&&!(i-this.fh>this.sh)&&W(t.clientX,t.clientY,this.dh.clientX,this.dh.clientY)<=this.eh}Rh(t){return{...t}}}const Me=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:Xt},Symbol.toStringTag,{value:"Module"}));class Ie{constructor(t,i){l(this,"A");l(this,"Ih");l(this,"_n",null);l(this,"Bh",0);l(this,"Gh",!1);l(this,"Nh",[]);l(this,"Xh",-1);this.A=t,this.Ih=i}get isPreloaded(){return this.Gh}get totalFrames(){return this.Bh}get frameRate(){return this._n}get textures(){return this.Nh}dispose(){this.Yh(),this.Nh=[],this._n=null,this.Bh=0,this.Gh=!1,this.Xh=-1}async preload(t,i){var r;try{if(t<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Ih.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.Kh(t,h),await this.Wh(t,i)?(this.Zh("captureStream",i),"captureStream"):(await this.jh(t,i),this.Zh("seeking",i),"seeking")}catch(n){const h=n instanceof Error?n:Error(n+"");throw(r=i==null?void 0:i.onError)==null||r.call(i,h),this.dispose(),h}}Kh(t,i){this.Yh(),this._n=t,this.Bh=i,this.Nh=[],this.Gh=!1,this.Xh=-1}Zh(t,i){var r;if(this.Nh.length===0)throw Error(`Video preload via ${t} completed but produced 0 frames.`);this.Bh=this.Nh.length,this.Gh=!0,this.Xh=-1,this.Ih.pause(),this.Ih.currentTime=0,i!=null&&i.onProgress&&i.onProgress({percent:100,loadedFrames:this.Bh,totalFrames:this.Bh,strategy:t}),(r=i==null?void 0:i.onComplete)==null||r.call(i,{totalFrames:this.Bh,strategy:t})}Vh(t){const i=this.A,r=i.createTexture();return i.bindTexture(i.TEXTURE_2D,r),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,1),$(i,i.LINEAR,i.LINEAR,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),i.bindTexture(i.TEXTURE_2D,null),r}qh(t,i){if(!(i!=null&&i.onProgress)||this.Bh===0)return;const r=Math.min(99,Math.floor(this.Nh.length/this.Bh*100)),n=10*Math.floor(r/10);n>this.Xh&&(this.Xh=n,i.onProgress({percent:r,loadedFrames:this.Nh.length,totalFrames:this.Bh,strategy:t}))}async Wh(t,i){const r=globalThis,n=r==null?void 0:r.MediaStreamTrackProcessor,h=this.Ih.captureStream;if(typeof n!="function"||typeof h!="function")return!1;let a,c=null;try{const u=h.call(this.Ih);if(a=u.getVideoTracks()[0],!a)return u.getTracks().forEach(g=>g.stop()),!1;if(c=new n({track:a}).readable.getReader(),this.Ih.currentTime=0,this.Ih.muted=!0,await this.Ih.play().catch(()=>{}),this.Ih.paused)return!1;const f=1e6/t;let d=0;for(;this.Nh.length<this.Bh;){const g=await c.read();if(g.done)break;const p=g.value;if(p)try{const m=typeof p.timestamp=="number"?p.timestamp:d;(this.Nh.length===0||m>=d)&&(this.Nh.push(this.Vh(p)),d=m+f,this.qh("captureStream",i))}finally{p.close()}}return c.releaseLock(),a.stop(),c=null,a=void 0,this.Ih.pause(),this.Ih.currentTime=0,this.Nh.length!==0}catch{return this.Yh(),this.Nh=[],this.Xh=-1,!1}finally{if(c)try{await c.cancel()}catch{}a&&a.stop(),this.Ih.pause(),this.Ih.currentTime=0}}async jh(t,i){const r=1/t,n=this.Bh,h=this.Ih;h.pause();for(let a=0;a<n;a++){const c=Math.min(h.duration,a*r);await this.Qh(c),this.Nh.push(this.Vh(h)),this.qh("seeking",i)}h.currentTime=0}Qh(t){return new Promise((i,r)=>{const n=this.Ih,h=()=>{n.removeEventListener("seeked",a),n.removeEventListener("error",c)},a=()=>{h(),i()},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 i();n.currentTime=f})}Yh(){for(const t of this.Nh)this.A.deleteTexture(t)}}class ht extends Nt{constructor(i,r,n,h,a,c,u,f,d){const g=c/u;let p,m;g>1?(p=f,m=Math.round(f/g)):(m=d,p=Math.round(d*g));super(i,r,n,h,c,u,p,m);l(this,"Ih");l(this,"Jh",0);l(this,"ta",null);this.Ih=a}ft(){var i;super.ft(),(i=this.ta)==null||i.dispose(),this.ta=null,this.Ih.pause(),this.Ih.src="",this.Ih.load()}sa(){var i;if(!((i=this.ta)!=null&&i.isPreloaded)&&this.Ih.readyState>=this.Ih.HAVE_CURRENT_DATA){const r=this.A;r.bindTexture(r.TEXTURE_2D,this.Xr),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.Ih),r.bindTexture(r.TEXTURE_2D,null)}}fn(){var r,n;const i=(r=this.ta)==null?void 0:r.textures;return i&&i.length>0&&((n=this.ta)!=null&&n.isPreloaded)?i[this.Jh%i.length]:this.Xr}ht(){return this.W=null,super.ht()}cn(){this.sa()}frame(i){var n,h;const r=((n=this.ta)==null?void 0:n.totalFrames)??0;return(h=this.ta)!=null&&h.isPreloaded&&i!==void 0&&r>0&&(this.Jh=(i%r+r)%r,this.W=null),this}static async dn(i,r,n,h,a,c){const u=i.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((A,w)=>{d.addEventListener("loadedmetadata",()=>A(),{once:!0}),d.addEventListener("error",y=>{var E;const T=y.target;w(Error("Failed to load video: "+(((E=T.error)==null?void 0:E.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),$(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 p=d.videoWidth,m=d.videoHeight,v=new ht(u,i,g,r,d,p,m,h,a);return f&&f>0&&(v.ta=new Ie(u,d),await v.ta.preload(f,c),v.Jh=0),v}async play(){await this.Ih.play()}pause(){this.Ih.pause()}stop(){this.Ih.pause(),this.Ih.currentTime=0}speed(i){return this.Ih.playbackRate=i,this}loop(i=!0){return this.Ih.loop=i,this}time(i){return this.Ih.currentTime=i,this}volume(i){return this.Ih.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.Xr}get width(){return this.H}get height(){return this.I}get originalWidth(){return this.Yr}get originalHeight(){return this.Kr}get videoElement(){return this.Ih}get currentTime(){return this.Ih.currentTime}get duration(){return this.Ih.duration}get isPlaying(){return!this.Ih.paused&&!this.Ih.ended}get totalFrames(){var i;return((i=this.ta)==null?void 0:i.totalFrames)??0}}const Be=o=>class extends o{ea(t,i,r,n){if(B.Ir(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,n);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.K.state.Zt(t),this.K.state.jt(i),this.K.state.Vt(r)}rotateX(t){this.K.state.Zt(t)}rotateY(t){this.K.state.jt(t)}rotateZ(t){this.K.state.Vt(t)}translate(t=0,i=0,r=0){this.K.state.qt(t,i,r)}translateX(t){this.K.state.qt(t,0,0)}translateY(t){this.K.state.qt(0,t,0)}translateZ(t){this.K.state.qt(0,0,t)}push(){this.K.state.it()}pop(){this.K.state.rt()}color(t,i,r,n){return B.Hr(t,i,r,n)}rect(t=1,i=1){this.K.di(t,i)}point(){this.K.di(1,1)}line(t,i,r,n){this.K.pi(t,i,r,n)}lineWeight(t){this.K.state.Kt(t)}background(t,i,r,n=255){const h=this.ea(t,i,r,n);this.K.wi(h.r,h.g,h.b,h.a)}char(t){const i=Array.from(t);if(i.length===0)throw Error("char() requires at least one character.");this.K.state.ss(this.ji.gr(i[0]))}charColor(t,i,r,n){const h=this.ea(t,i,r,n);this.K.state.es(h.r,h.g,h.b,h.a)}cellColor(t,i,r,n){const h=this.ea(t,i,r,n);this.K.state.rs(h.r,h.g,h.b,h.a)}flipX(t){this.K.state.ns(t)}flipY(t){this.K.state.hs(t)}charRotation(t){this.K.state.ls(t)}invert(t){this.K.state.cs(t)}clear(){this.K.wi(0,0,0,0)}ellipse(t,i){this.K.gi(t/2,i/2)}triangle(t,i,r,n,h,a){this.K.mi(t,i,r,n,h,a)}bezierCurve(t,i,r,n,h,a,c,u){this.K._i(t,i,r,n,h,a,c,u)}arc(t,i,r,n){this.K.Ai(t/2,i/2,r,n)}shader(t){this.K.ai(t)}setUniform(t,i){this.K.O(t,i)}setUniforms(t){this.K.ci(t)}async createFilterShader(t){if(typeof t=="string"&&(t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const i=await fetch(t);if(!i.ok)throw Error(`Failed to load shader from ${t}: ${i.statusText}`);const r=await i.text();return this.K.li(r)}return this.K.li(t)}createFramebuffer(t){return this.K.yi(t.width??this.grid.cols,t.height??this.grid.rows,3)}image(t,i,r){this.K.ui(t,i,r)}ortho(){this.K.state.fs(!0)}async loadImage(t){if(typeof t!="string"){const h=k.dn(this.K,this.ji,t,this.Un.cols,this.Un.rows);return this.ia(h),h}const i=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=i}),n=k.dn(this.K,this.ji,r,this.Un.cols,this.Un.rows);return this.ia(n),n}async loadVideo(t,i){const r=await ht.dn(this.K,this.ji,t,this.Un.cols,this.Un.rows,i);return this.ia(r),r}},Se=o=>class extends o{async loadFont(t){return this.ji.pr(t).then(()=>{const i=this.ji.maxGlyphDimensions;this.Un.Mr(i.width,i.height),this.ra.resize(this.Un.cols,this.Un.rows),this.K.bi(),this.Uo.Jn(),this.na.Jn();for(const r of this.oa)r.an(this.ji)})}fontSize(t){if(!lt.m(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.ji.fontSize===t)return;this.ji.dr(t);const i=this.ji.maxGlyphDimensions;this.Un.Mr(i.width,i.height),this.ra.resize(this.Un.cols,this.Un.rows),this.K.bi(),this.Uo.Jn(),this.na.Jn()}},Pe=o=>class extends o{get frameCount(){return this.ha.Rn}set frameCount(t){this.ha.Rn=t}frameRate(t){return t===void 0?this.ha.En:this.ha.Tn(t,()=>this.aa())}noLoop(){this.ha.xn()}loop(){this.ha.Fn(()=>this.aa())}redraw(t=1){if(lt.m(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",providedValue:t}))for(let i=0;i<t;i++)this.aa()}isLooping(){return this.ha.Pn}},Le=o=>class extends o{constructor(...t){super(...t)}mouseClicked(t){this.Uo.co(t)}mousePressed(t){this.Uo.lo(t)}mouseReleased(t){this.Uo.uo(t)}mouseMoved(t){this.Uo.fo(t)}mouseScrolled(t){this.Uo.do(t)}get mouse(){return this.Uo.po()}cursor(t){this.Uo.Qn(t)}},Ne=o=>class extends o{constructor(...t){super(...t)}touchStarted(t){this.na.wh(t)}touchMoved(t){this.na.fo(t)}touchEnded(t){this.na.bh(t)}touchCancelled(t){this.na.Ch(t)}tap(t){this.na.Mh(t)}doubleTap(t){this.na.xh(t)}longPress(t){this.na.Fh(t)}swipe(t){this.na.Th(t)}pinch(t){this.na.$h(t)}rotateGesture(t){this.na.Ph(t)}get touches(){return this.na.yh()}},De=o=>class extends o{constructor(...t){super(...t)}keyPressed(t){this.ca.lo(t)}keyReleased(t){this.ca.uo(t)}isKeyPressed(t){return this.ca.Fo(t)}get lastKeyPressed(){return this.ca.$o()}get lastKeyReleased(){return this.ca.Po()}get pressedKeys(){return this.ca.Eo()}get modifierState(){return this.ca.Ro()}};class Oe{constructor(t){l(this,"la");l(this,"ua",new Map);l(this,"fa",[]);l(this,"da",new Map);l(this,"pa",new Map);this.la=t}async ga(t){for(const i of t){if(this.ua.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.va(i.name);try{await i.install(this.la,r)}catch(n){throw this.ma(i.name),n}this.ua.set(i.name,i),this.fa.push(i.name)}}async _a(t){const i=this.ua.get(t);if(!i)return;const r=this.va(t);i.uninstall&&await i.uninstall(this.la,r),this.ua.delete(t),this.fa.splice(this.fa.indexOf(t),1),this.ma(t)}ya(){this.wa(this.da)}ba(){this.wa(this.pa)}async Ca(){const t=[...this.ua.keys()];for(const i of t)await this._a(i)}va(t){return{renderer:this.la.K,font:this.la.ji,grid:this.la.Un,canvas:this.la.wr,drawFramebuffer:this.la.ra,asciiFramebuffer:this.la.Ma,registerPreDrawHook:i=>this.xa(this.da,t,i),registerPostDrawHook:i=>this.xa(this.pa,t,i)}}xa(t,i,r){const n=t.get(i)??new Set;return n.add(r),t.set(i,n),()=>{const h=t.get(i);h&&(h.delete(r),h.size===0&&t.delete(i))}}ma(t){this.da.delete(t),this.pa.delete(t)}wa(t){for(const i of this.fa){const r=t.get(i);r&&r.forEach(n=>n())}}}const Gt=`#version 300 es
|
|
11
11
|
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class zt{constructor(){l(this,"Fa",new Map);l(this,"Ta",[]);l(this,"$a",0);l(this,"Pa",0);l(this,"Ea")}get Ra(){return this.$a}get Sa(){if(this.$a===0)return 0;let t=0;for(const i of this.Ta){const r=this.Fa.get(i);r&&(t+=Math.min(1,Math.max(0,r.progress))*r.weight)}return Math.min(1,t/this.$a)}ka(t){this.Ea=t}za(t,i=1){const r=`phase-${this.Ta.length+1}-${Date.now()}`,n={id:r,label:t,weight:Math.max(.001,i),progress:0,status:"running"};return this.Fa.set(r,n),this.Ta.push(r),this.$a+=n.weight,r}La(t,i){const r=this.Fa.get(t);if(!r)return;r.progress=Math.max(0,Math.min(1,i)),r.status=r.progress>=1?"complete":"running";const n=this.Sa;Math.abs(n-this.Pa)>.001&&(this.Pa=n,this.Ea&&this.Ea(n))}Oa(t){const i=this.Fa.get(t);i&&(i.progress=1,i.status="complete",this.La(t,1))}Da(t){const i=this.Fa.get(t);i&&(i.status="failed")}Ha(){return this.Ta.map(t=>{const i=this.Fa.get(t);return i?{id:i.id,label:i.label,weight:i.weight,progress:i.progress,status:i.status}:{id:t,label:t,weight:1,progress:0,status:"pending"}})}}class Kt{constructor(t="active"){l(this,"Ia");l(this,"Ba","");l(this,"Ga","");this.Ia=t}get Na(){return this.Ia}get Xa(){return this.Ia!=="disabled"}get Ya(){return this.Ia==="active"||this.Ia==="transitioning"||this.Ia==="error"}get Ka(){return this.Ba}get Wa(){return this.Ga}Za(){this.Ia!=="done"&&this.Ia!=="transitioning"||(this.Ia="active")}ja(){this.Ia!=="disabled"&&(this.Ia="done")}Va(){this.Ia!=="disabled"&&(this.Ia="transitioning")}qa(){this.Ia==="transitioning"&&(this.Ia="done")}Qa(t){this.Ia!=="disabled"&&(this.Ia="error",t instanceof Error?(this.Ba=t.message,this.Ga=t.stack||""):(this.Ba=t,this.Ga=""))}Ja(){this.Ia="disabled"}}class Yt{constructor(t,i){l(this,"tc",0);l(this,"sc",1);l(this,"ec");l(this,"rc");this.ec=t,this.rc=i}get nc(){return this.sc}get oc(){return this.sc<1}Cn(){this.ec!=="none"&&this.rc>0&&(this.tc=performance.now())}tt(){if(this.ec==="none"||this.rc===0)return this.sc=1,!1;const t=performance.now()-this.tc,i=Math.min(1,t/this.rc);return i>=1?(this.sc=0,!0):(this.sc=1-i,!1)}js(){this.sc=1,this.tc=0}}function wt(o,t){const i=o.tone??"auto";let r="dark";return i==="light"||i==="dark"?r=i: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 kt(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function Ht(o,t){return o.length?o.map(i=>t.color(i)):[t.color("#FFFFFF")]}const _e=({textmodifier:o,grid:t,progress:i,frameCount:r,message:n,palette:h,theme:a,phases:c,transitionOpacity:u,isError:f,errorMessage:d})=>{const g="|/-\\",p=Math.floor(r/6)%4,m=o.color(a.textColor),v=Math.floor(255*u),A=o.color(m.r,m.g,m.b,v);if(o.charColor(A),o.cellColor(0,0,0,0),f){const w=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",v);o.charColor(w),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const y="SETUP ERROR",T=-Math.floor(y.length/2);o.push(),o.translate(T,0,0);for(const E of y)o.char(E),o.rect(1,1),o.translateX(1);if(o.pop(),d){const E=o.color(a.subtleColor),U=o.color(E.r,E.g,E.b,v);o.charColor(U);const b=Math.floor(.8*t.cols),I=d.split(" "),L=[];let M="";for(const P of I)(M+" "+P).length<=b?M=M?M+" "+P:P:(M&&L.push(M),M=P);M&&L.push(M);const D=L.slice(0,3);L.length>3&&(D[2]=D[2].substring(0,b-3)+"..."),D.forEach((P,at)=>{const Ve=-Math.floor(P.length/2);o.push(),o.translate(Ve,3+at,0);for(const Ze of P)o.char(Ze),o.rect(1,1),o.translateX(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(g[p]),o.rect(1,1),o.pop(),i>0||c.some(w=>w.status!=="pending")){const w=Math.max(6,Math.floor(.6*t.cols)),y=-Math.floor(w/2),T=Math.floor(w*i),E=h.length?h:[o.color("#FFFFFF")];o.push(),o.translate(y,3,0);for(let U=0;U<w;U++){const b=U<T?"*":".",I=E[U%E.length],L=o.color(I.r,I.g,I.b,v);o.charColor(L),o.char(b),o.rect(1,1),o.translateX(1)}o.pop()}if(n){const w=o.color(a.subtleColor),y=o.color(w.r,w.g,w.b,v);o.charColor(y);const T=-Math.floor(n.length/2);o.push(),o.translate(T,5,0);for(const E of n)o.char(E),o.rect(1,1),o.translateX(1);o.pop()}},Xe={message:"LOADING...",tone:"auto",transition:"fade",transitionDuration:500};class Ge{constructor(t,i,r){this.hc=t,this.id=i,this.label=r}report(t){this.hc.La(this.id,t)}complete(){this.hc.Oa(this.id)}fail(t){this.hc.Da(this.id)}async track(t){try{const i=typeof t=="function"?await t():await t;return this.complete(),i}catch(i){throw this.fail(),i}}}class jt{constructor(t,i,r){l(this,"la");l(this,"l");l(this,"ac");l(this,"hc");l(this,"cc");l(this,"lc");l(this,"uc");l(this,"fc");l(this,"dc");l(this,"gc");l(this,"K");l(this,"vc",[]);l(this,"mc");l(this,"_c",performance.now());l(this,"yc",0);l(this,"wc",!1);l(this,"bc",!1);l(this,"Fc");this.la=t,this.l={...Xe,...i??{}},this.ac=new Kt("active"),this.hc=new zt,this.cc=new Yt(this.l.transition,this.l.transitionDuration),this.lc=new Dt(60),this.mc=wt(this.l,r);const n=kt(this.mc);this.vc=Ht(n,this.la),this.K=this.Cc(),this.hc.ka(h=>{h>=.999&&this.ja()})}async cr(t){if(this.bc)return;const i=this.la.K,r=this.la.wr;this.uc=new pt(i,16),await this.uc.cr(t);const n=this.uc.maxGlyphDimensions;this.fc=new mt(r.canvas,n.width,n.height),this.dc=i.yi(this.fc.cols,this.fc.rows,3),this.gc=i.yi(this.fc.width,this.fc.height,1),this.bc=!0}get Ya(){return this.ac.Ya&&this.wc}Cn(){this.wc||(this.wc=!0,this._c=performance.now(),this.yc=0,this.lc.Cn(()=>this.Mc()))}Mn(){this.wc&&(this.wc=!1,this.lc.Mn())}zr(){this.bc&&(this.fc.js(),this.dc.resize(this.fc.cols,this.fc.rows),this.gc.resize(this.fc.width,this.fc.height))}ft(){this.Mn(),this.bc&&(this.uc.ft(),this.dc.ft(),this.gc.ft(),this.bc=!1)}get progress(){return this.hc.Sa}message(t){return typeof t=="string"&&(this.l.message=t),this.l.message}addPhase(t,i=1){this.ac.Za();const r=this.hc.za(t,i);return new Ge(this.hc,r,t)}ja(){this.l.transition!=="none"&&this.l.transitionDuration>0?(this.ac.Va(),this.cc.Cn()):(this.ac.ja(),this.Mn(),this.xc())}xc(){this.Fc&&this.Fc()}Tc(t){this.Fc=t}error(t){this.ac.Qa(t)}Mc(){if(this.ac.Ya){if(this.yc++,this.ac.Na==="transitioning"&&this.cc.tt())return this.ac.qa(),this.xc(),void this.Mn();this.$c()}}$c(){if(!this.bc)return;const t=this.dc,i=this.uc,r=this.fc,n=this.gc,h=this.la.K,a=this.la.wr,c=this.la.Pc,u=this.la.Ec;h.state.Wt(),t.begin(),this.la.clear(),this.la.push();try{const f={textmodifier:this.la,grid:r,progress:this.progress,elapsedMs:performance.now()-this._c,frameCount:this.yc,message:this.l.message,palette:this.vc,theme:this.mc,phases:this.hc.Ha(),transitionOpacity:this.cc.nc,isError:this.ac.Na==="error",errorMessage:this.ac.Ka||void 0,errorDetails:this.ac.Wa||void 0};this.K(f)}finally{this.la.pop()}t.end(),n.begin(),h.oi(c),c.L({u_characterTexture:i.fontFramebuffer,u_charsetDimensions:[i.textureColumns,i.textureRows],U0:t.textures[0],U1:t.textures[1],U2:t.textures[2],U3:[r.cols,r.rows],U4:[n.width,n.height],U5:h.state.canvasBackgroundColor}),h.fi(0,0,a.width,a.height),n.end(),h.ge(...h.state.canvasBackgroundColor),h.oi(u),u.L({U6:n.textures[0],U7:[n.width,n.height],U8:[r.offsetX,r.offsetY],U9:[r.width,r.height]}),h.fi(r.offsetX,r.offsetY,r.width,r.height)}Rc(t){this.mc=wt(this.l,t)}Cc(){const t=this.l.renderer||_e;return i=>{t(i),this.Sc(i)}}Sc(t){const{textmodifier:i,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]];i.push(),i.translate(f,u,0);for(let g=0;g<c.length;g++){const p=c[g],m=Math.floor(.1*n+.5*g)%d.length,[v,A,w]=d[m],y=Math.floor(255*a),T=i.color(v,A,w,y);i.charColor(T),i.char(p),i.point(),i.translateX(1)}i.pop()}}class Wt extends function(i,...r){return r.reduce((n,h)=>h(n),i)}(class{},Be,Se,Pe,Le,Ne,De){constructor(i={}){super();l(this,"K");l(this,"ji");l(this,"wr");l(this,"Un");l(this,"ha");l(this,"Uo");l(this,"na");l(this,"ca");l(this,"kc");l(this,"ra");l(this,"Pc");l(this,"Ma");l(this,"Ec");l(this,"zc");l(this,"Lc",!1);l(this,"Oc",!1);l(this,"Dc",!1);l(this,"Hc",!1);l(this,"Ic",()=>{});l(this,"Bc",()=>{});l(this,"Gc",()=>{});l(this,"Nc");l(this,"Xc");l(this,"Tr",!1);l(this,"Yc");l(this,"oa",new Set);this.zc=new Oe(this),this.Tr=i.overlay??!1,this.wr=new St(i),this.K=new ue(this.wr.Lr()),this.ji=new pt(this.K,i.fontSize??16),this.ha=new Dt(i.frameRate??60),this.kc=new jt(this,i.loadingScreen,this.wr.kr()),this.kc.Tc(()=>{this.ha.Rn=0,this.Hc=!0}),this.Uo=new Ot(this.wr),this.na=new Xt(this.wr,this.Uo),this.ca=new _t,this.Pc=this.K.hi(Gt,`#version 300 es
|
|
12
|
-
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D U1;uniform sampler2D U2;uniform sampler2D U0;uniform vec2 U3;uniform vec2 U4;uniform vec4 U5;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/U4;vec2 F=E*U3;vec2 G=floor(F);vec2 H=(G+0.5)/U3;vec4 I=texture(U1,H);vec4 J=texture(U2,H);vec4 K=texture(U0,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(U5,J,J.a);fragColor=mix(d,I,c);}`),this.kc.Cn(),this.Kc(i)}async Kc(i){await Promise.all([this.ji.cr(i.fontSource),this.kc.cr(i.fontSource)]);const r=this.ji.maxGlyphDimensions;this.Un=new mt(this.wr.canvas,r.width,r.height),this.Uo.cr(this.Un),this.na.cr(this.Un),this.ra=this.K.yi(this.Un.cols,this.Un.rows,3),this.Ma=this.K.yi(this.Un.width,this.Un.height,1),this.Tr&&(this.Yc=k.dn(this.K,this.ji,this.wr.targetCanvas,this.Un.cols,this.Un.rows),this.ia(this.Yc)),
|
|
13
|
-
precision highp float;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;uniform vec2 U9;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-U8;vec2 B=A*(U7/U9);vec2 C=(floor(B)+0.5)/U7;fragColor=texture(U6,C);}`),this.Wc(),this.ha.Cn(()=>this.aa()),await this.zc.ga(i.plugins??[]);try{await this.Ic(),this.kc.ja()}catch(n){console.error("Error during setup:",n),this.kc.error(n)}}Wc(){this.Nc=()=>{this.Tr&&this.resizeCanvas(this.wr.targetCanvas.width,this.wr.targetCanvas.height),this.Gc()},window.addEventListener("resize",this.Nc),this.Uo.so(),this.na.so(),this.ca.so(),window.addEventListener("blur",()=>{this.ca.So()}),this.Tr&&(this.Xc=new ResizeObserver(()=>{this.resizeCanvas(this.wr.targetCanvas.width,this.wr.targetCanvas.height)}),this.Xc.observe(this.wr.targetCanvas))}aa(){if(!this.kc.Ya&&this.Hc){this.Oc=!0;try{this.ha.$n(),this.ha.Sn(),this.Tr&&xt(this.K.context,this.Yc.texture,this.wr.targetCanvas),this.zc.ya(),this.K.state.Wt(),this.ra.begin(),this.Bc(),this.ra.end(),this.Ma.begin(),this.K.oi(this.Pc),this.Pc.L({u_characterTexture:this.ji.fontFramebuffer,u_charsetDimensions:[this.ji.textureColumns,this.ji.textureRows],U0:this.ra.textures[0],U1:this.ra.textures[1],U2:this.ra.textures[2],U3:[this.Un.cols,this.Un.rows],U4:[this.Ma.width,this.Ma.height],U5:this.K.state.canvasBackgroundColor}),this.K.fi(0,0,this.wr.width,this.wr.height),this.Ma.end(),this.K.ge(...this.K.state.canvasBackgroundColor),this.K.oi(this.Ec),this.Ec.L({U6:this.Ma.textures[0],U7:[this.Ma.width,this.Ma.height],U8:[this.Un.offsetX,this.Un.offsetY],U9:[this.Un.width,this.Un.height]}),this.K.fi(this.Un.offsetX,this.Un.offsetY,this.Un.width,this.Un.height),this.zc.ba()}finally{this.Oc=!1,this.Lc&&!this.Dc&&this.Zc()}}}resizeCanvas(i,r){this.wr.zr(i,r),this.kc.Rc(this.wr.kr()),this.Un.js(),this.kc.zr(),this.ra.resize(this.Un.cols,this.Un.rows),this.Ma.resize(this.Un.width,this.Un.height),this.K.bi(),this.Uo.Jn(),this.na.Jn(),this.aa()}destroy(){this.Dc||this.Lc||(this.Lc=!0,this.ha.xn(),this.Oc||this.Zc())}Zc(){var i,r;this.Lc=!1,this.kc.ft(),this.zc.Ca(),window.removeEventListener("resize",this.Nc),(i=this.Xc)==null||i.disconnect(),this.Uo.ao(),this.na.ao(),this.ca.ao(),this.ra.ft(),this.Pc.dispose(),this.ji.ft(),this.K.ft(),this.Ma.ft(),this.Ec.dispose(),(r=this.Yc)==null||r.ft(),this.wr.ft(),this.Dc=!0}setup(i){this.Ic=i}draw(i){this.Bc=i}windowResized(i){this.Gc=i}get grid(){return this.Un}get font(){return this.ji}get width(){return this.wr.width}get height(){return this.wr.height}get canvas(){return this.wr.canvas}get drawFramebuffer(){return this.ra}get isDisposed(){return this.Dc}get overlay(){return this.Yc}get loading(){return this.kc}ia(i){this.oa.has(i)||this.oa.add(i)}}class ot{constructor(){}static create(t={}){return new Wt(t)}static setErrorLevel(t){lt._(t)}static get version(){return"0.6.
|
|
12
|
+
precision highp float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D U1;uniform sampler2D U2;uniform sampler2D U0;uniform vec2 U3;uniform vec2 U4;uniform vec4 U5;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/U4;vec2 F=E*U3;vec2 G=floor(F);vec2 H=(G+0.5)/U3;vec4 I=texture(U1,H);vec4 J=texture(U2,H);vec4 K=texture(U0,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(U5,J,J.a);fragColor=mix(d,I,c);}`),this.kc.Cn(),this.Kc(i)}async Kc(i){await Promise.all([this.ji.cr(i.fontSource),this.kc.cr(i.fontSource)]);const r=this.ji.maxGlyphDimensions;this.Un=new mt(this.wr.canvas,r.width,r.height),this.Uo.cr(this.Un),this.na.cr(this.Un),this.ra=this.K.yi(this.Un.cols,this.Un.rows,3),this.Ma=this.K.yi(this.Un.width,this.Un.height,1),this.Tr&&(this.Yc=k.dn(this.K,this.ji,this.wr.targetCanvas,this.Un.cols,this.Un.rows),this.ia(this.Yc)),this.Ec=this.K.hi(Gt,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;uniform vec2 U9;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-U8;vec2 B=A*(U7/U9);vec2 C=(floor(B)+0.5)/U7;fragColor=texture(U6,C);}`),this.Wc(),this.ha.Cn(()=>this.aa()),await this.zc.ga(i.plugins??[]);try{await this.Ic(),this.kc.ja()}catch(n){console.error("Error during setup:",n),this.kc.error(n)}}Wc(){this.Nc=()=>{this.Tr&&this.resizeCanvas(this.wr.targetCanvas.width,this.wr.targetCanvas.height),this.Gc()},window.addEventListener("resize",this.Nc),this.Uo.so(),this.na.so(),this.ca.so(),window.addEventListener("blur",()=>{this.ca.So()}),this.Tr&&(this.Xc=new ResizeObserver(()=>{this.resizeCanvas(this.wr.targetCanvas.width,this.wr.targetCanvas.height)}),this.Xc.observe(this.wr.targetCanvas))}aa(){if(!this.kc.Ya&&this.Hc){this.Oc=!0;try{this.ha.$n(),this.ha.Sn(),this.Tr&&xt(this.K.context,this.Yc.texture,this.wr.targetCanvas),this.zc.ya(),this.K.state.Wt(),this.ra.begin(),this.Bc(),this.ra.end(),this.Ma.begin(),this.K.oi(this.Pc),this.Pc.L({u_characterTexture:this.ji.fontFramebuffer,u_charsetDimensions:[this.ji.textureColumns,this.ji.textureRows],U0:this.ra.textures[0],U1:this.ra.textures[1],U2:this.ra.textures[2],U3:[this.Un.cols,this.Un.rows],U4:[this.Ma.width,this.Ma.height],U5:this.K.state.canvasBackgroundColor}),this.K.fi(0,0,this.wr.width,this.wr.height),this.Ma.end(),this.K.ge(...this.K.state.canvasBackgroundColor),this.K.oi(this.Ec),this.Ec.L({U6:this.Ma.textures[0],U7:[this.Ma.width,this.Ma.height],U8:[this.Un.offsetX,this.Un.offsetY],U9:[this.Un.width,this.Un.height]}),this.K.fi(this.Un.offsetX,this.Un.offsetY,this.Un.width,this.Un.height),this.zc.ba()}finally{this.Oc=!1,this.Lc&&!this.Dc&&this.Zc()}}}resizeCanvas(i,r){this.wr.zr(i,r),this.kc.Rc(this.wr.kr()),this.Un.js(),this.kc.zr(),this.ra.resize(this.Un.cols,this.Un.rows),this.Ma.resize(this.Un.width,this.Un.height),this.K.bi(),this.Uo.Jn(),this.na.Jn(),this.aa()}destroy(){this.Dc||this.Lc||(this.Lc=!0,this.ha.xn(),this.Oc||this.Zc())}Zc(){var i,r;this.Lc=!1,this.kc.ft(),this.zc.Ca(),window.removeEventListener("resize",this.Nc),(i=this.Xc)==null||i.disconnect(),this.Uo.ao(),this.na.ao(),this.ca.ao(),this.ra.ft(),this.Pc.dispose(),this.ji.ft(),this.K.ft(),this.Ma.ft(),this.Ec.dispose(),(r=this.Yc)==null||r.ft(),this.wr.ft(),this.Dc=!0}setup(i){this.Ic=i}draw(i){this.Bc=i}windowResized(i){this.Gc=i}get grid(){return this.Un}get font(){return this.ji}get width(){return this.wr.width}get height(){return this.wr.height}get canvas(){return this.wr.canvas}get drawFramebuffer(){return this.ra}get isDisposed(){return this.Dc}get overlay(){return this.Yc}get loading(){return this.kc}ia(i){this.oa.has(i)||this.oa.add(i)}}class ot{constructor(){}static create(t={}){return new Wt(t)}static setErrorLevel(t){lt._(t)}static get version(){return"0.6.1"}}let Et=null;const ze={id:"brightness",createShader:({gl:o})=>(Et||(Et=new j(o,tt,`#version 300 es
|
|
14
14
|
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;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}float C(vec3 D,vec3 E){vec3 F=D-E;return dot(F,F);}vec4 G(vec4 H){if(!u_colorFilterEnabled||u_colorFilterSize<=0){return H;}int I=min(u_colorFilterSize,64);vec3 J=u_colorFilterPalette[0].rgb;float K=C(H.rgb,J);for(int L=1;L<64;++L){if(L>=I){break;}vec3 M=u_colorFilterPalette[L].rgb;float N=C(H.rgb,M);if(N<K){K=N;J=M;}}return vec4(J,H.a);}void main(){vec2 O=vec2(v_uv.x,1.0f-v_uv.y);vec4 H=texture(u_image,O);H=G(H);float E=A(H.rgb);vec2 P=vec2(0.);if(u_charCount>0){float Q=float(u_charCount);float R=clamp(E*(Q-1.0f),0.0f,Q-1.0f);int S=int(floor(R+0.5f));vec3 T=u_charList[S];P=T.xy;}else{P=vec2(E,0.0f);}vec4 U=u_charColorFixed?u_charColor:H;vec4 V=u_cellColorFixed?u_cellColor:H;if(H.a<0.01f){U=u_backgroundColor;V=u_backgroundColor;}else{}o_primaryColor=vec4(U.rgb,U.a);o_secondaryColor=vec4(V.rgb,V.a);int W=int(u_invert?1:0);int X=int(u_flipX?1:0);int Y=int(u_flipY?1:0);float Z=float(W|(X<<1)|(Y<<2))/255.;o_character=vec4(P,Z,clamp(u_charRotation,0.0f,1.0f));}`)),Et),createUniforms:({source:o})=>o.createBaseConversionUniforms()},Ke=Object.freeze(Object.defineProperty({__proto__:null,LoadingPhaseTracker:zt,LoadingScreenManager:jt,LoadingScreenStateMachine:Kt,LoadingScreenTransition:Yt,resolveColorInputs:Ht,resolveDefaultPalette:kt,resolveTheme:wt},Symbol.toStringTag,{value:"Module"})),Ye=Object.freeze(Object.defineProperty({__proto__:null,TextmodeFont:pt,TextmodeImage:k,TextmodeVideo:ht},Symbol.toStringTag,{value:"Module"})),ke=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Ue,mouse:Ce,touch:Me},Symbol.toStringTag,{value:"Module"}));Pt(ze);const He=ot.create,je=ot.setErrorLevel,We=ot.version;x.TextmodeCanvas=St,x.TextmodeColor=B,x.TextmodeErrorLevel=X,x.TextmodeFramebuffer=V,x.TextmodeGrid=mt,x.Textmodifier=Wt,x.create=He,x.getConversionStrategy=Lt,x.input=ke,x.loadables=Ye,x.loading=Ke,x.registerConversionStrategy=Pt,x.setErrorLevel=je,x.textmode=ot,x.unregisterConversionStrategy=function(o){yt.delete(o)},x.version=We,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):e((s=typeof globalThis<"u"?globalThis:s||self).textmode={});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.js",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "textmode.js is a lightweight creative coding library for creating real-time ASCII art on the web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -11,11 +11,6 @@
|
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
12
|
"import": "./dist/textmode.esm.js",
|
|
13
13
|
"require": "./dist/textmode.umd.js"
|
|
14
|
-
},
|
|
15
|
-
"./min": {
|
|
16
|
-
"types": "./dist/types/index.d.ts",
|
|
17
|
-
"import": "./dist/textmode.esm.min.js",
|
|
18
|
-
"require": "./dist/textmode.umd.min.js"
|
|
19
14
|
}
|
|
20
15
|
},
|
|
21
16
|
"scripts": {
|