textmode.js 0.4.0 → 0.6.0-beta.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/dist/textmode.esm.js +2868 -2164
- package/dist/textmode.esm.min.js +2863 -2159
- package/dist/textmode.umd.js +11 -8
- package/dist/textmode.umd.min.js +11 -8
- package/dist/types/Textmode.d.ts +13 -22
- package/dist/types/index.d.ts +8 -6
- package/dist/types/rendering/index.d.ts +3 -3
- package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
- package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
- package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
- package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +25 -34
- package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
- package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
- package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
- package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
- package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
- package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
- package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
- package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
- package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
- package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
- package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
- package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
- package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
- package/dist/types/rendering/webgl/index.d.ts +15 -14
- package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
- package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
- package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
- package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
- package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
- package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
- package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
- package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
- package/dist/types/textmode/AnimationController.d.ts +11 -21
- package/dist/types/textmode/Canvas.d.ts +10 -2
- package/dist/types/textmode/Grid.d.ts +2 -0
- package/dist/types/textmode/TextmodeColor.d.ts +57 -0
- package/dist/types/textmode/Textmodifier.d.ts +40 -212
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +272 -0
- package/dist/types/textmode/interfaces/index.d.ts +1 -0
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +21 -0
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +237 -0
- package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
- package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
- package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +6 -3
- package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
- package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
- package/dist/types/textmode/loadables/index.d.ts +5 -0
- package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
- package/dist/types/textmode/loading/LoadingScreenManager.d.ts +170 -0
- package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
- package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
- package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
- package/dist/types/textmode/loading/index.d.ts +6 -0
- package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
- package/dist/types/textmode/loading/templates/index.d.ts +1 -0
- package/dist/types/textmode/loading/types.d.ts +251 -0
- package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
- package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
- package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +12 -15
- package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
- package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
- package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
- package/dist/types/textmode/mixins/index.d.ts +8 -8
- package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
- package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
- package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
- package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1085 -0
- package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
- package/dist/types/textmode/types.d.ts +49 -0
- package/dist/types/textmode/utils/cssColor.d.ts +8 -0
- package/dist/types/utils/array.d.ts +34 -0
- package/dist/types/utils/math.d.ts +69 -0
- package/package.json +1 -1
- package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
- package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
- package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
- package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
- package/dist/types/textmode/TextmodeImage.d.ts +0 -161
- package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
- /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
- /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
package/dist/textmode.umd.min.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Wi=Object.defineProperty;var qi=(M,F,S)=>F in M?Wi(M,F,{enumerable:!0,configurable:!0,writable:!0,value:S}):M[F]=S;var l=(M,F,S)=>qi(M,typeof F!="symbol"?F+"":F,S);var s,e;s=this,e=function(M){class F extends Error{constructor(t,i={}){super(F.t(t,i)),this.name="TextmodeError"}static t(t,i){return`${t}${i&&Object.keys(i).length>0?`
|
|
2
2
|
|
|
3
|
-
📋 Context
|
|
4
|
-
- ${r}: ${
|
|
3
|
+
📋 Context:${Object.entries(i).map(([r,n])=>`
|
|
4
|
+
- ${r}: ${F.i(n)}`).join("")}`:""}
|
|
5
5
|
|
|
6
6
|
${"↓".repeat(24)}
|
|
7
|
-
`}static
|
|
8
|
-
in vec2
|
|
9
|
-
precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`),this.Jt=new k(this.gt,K,`#version 300 es
|
|
10
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`),this.ts=new k(this.gt,rt,"precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"),this.ss=new k(this.gt,K,`#version 300 es
|
|
11
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`)}es(){return this.Jt}At(){return this.Qt}rs(){return this.ts}ns(){return this.ss}hs(t){return new k(this.gt,K,t)}cs(t,i){return new k(this.gt,t,i)}Pt(){this.Jt.Pt(),this.Qt.Pt(),this.ts.Pt(),this.ss.Pt()}}var R=(l=>(l.RECTANGLE="rectangle",l.LINE="line",l.ELLIPSE="ellipse",l.ARC="arc",l.TRIANGLE="triangle",l.BEZIER_CURVE="bezier_curve",l.CUSTOM="custom",l))(R||{});class pt{constructor(t){c(this,"gt");c(this,"ls",new Map);this.gt=t}us(t,i,r,n){const o=this.gt;let h=this.ls.get(t);h||(h=new Map,this.ls.set(t,h));let a=h.get(i)||null;if(!a){a=o.createVertexArray(),h.set(i,a),o.bindVertexArray(a),o.bindBuffer(o.ARRAY_BUFFER,n);const u=o.getAttribLocation(t,"a_position");u!==-1&&(o.enableVertexAttribArray(u),o.vertexAttribPointer(u,r.ds.fs.size,o.FLOAT,!1,r._s,r.ds.fs.offset),o.vertexAttribDivisor(u,0));const f=o.getAttribLocation(t,"a_texCoord");f!==-1&&(o.enableVertexAttribArray(f),o.vertexAttribPointer(f,r.ds.ps.size,o.FLOAT,!1,r._s,r.ds.ps.offset),o.vertexAttribDivisor(f,0))}o.bindVertexArray(a)}vs(){this.gt.bindVertexArray(null)}Pt(){for(const[,t]of this.ls)for(const[,i]of t)i&&this.gt.deleteVertexArray(i)}}class vt{constructor(t,i){c(this,"gs");c(this,"gt");c(this,"xt");c(this,"Cs",null);c(this,"ws",null);this.gt=t,this.gs=new pt(t),this.xt=i}bs(t,i,r){const{shader:n}=t,o=V(this.gt)||this.gt.getParameter(this.gt.VIEWPORT);n.Xt({U9:o[2]/o[3],Uy:[o[2],o[3]]});const h=f=>{if(!f||!f.$s())return;const g=f.unitGeometry,d=f.unitBuffer;try{this.gs.us(n.Zt,f.type+"",g,d),f.batch.Ms(n),f.batch.Rs(g.Fs,g.Ss)}finally{f.batch.Ts(n),this.gs.vs(),f.As()}};let a=null,u=null;for(const f of i){if(f.type===R.CUSTOM){u&&(h(u),a=null,u=null),this.zs(t,f.params,f.state,r.get(R.RECTANGLE));continue}a!==null&&f.type!==a&&(h(u),a=null,u=null);let g=u;g&&f.type===a||(g=r.get(f.type)||null,u=g,a=f.type),g&&g.ks(f.params,f.state)}h(u)}zs(t,i,r,n){const{x:o,y:h,width:a,height:u,shader:f,uniforms:g}=i,d=this.Es(Math.max(1,Math.floor(a)),Math.max(1,Math.floor(u)));d.begin(),this.Ps(n,f,g,0,0,d.width,d.height,{}),d.end();const v=this.Ls(),x={Ue:d.textures[0],Uf:d.textures[1],Ug:d.textures[2],Uh:d.textures[3],Ui:d.textures[4],Uj:[d.width,d.height]};this.Ps(n,v,x,Math.floor(o),Math.floor(h),Math.max(1,Math.floor(a)),Math.max(1,Math.floor(u)),r),t.shader.Ht()}Ps(t,i,r,n,o,h,a,u){i.Ht(),i.Xt(r);const f=this.gt.getParameter(this.gt.VIEWPORT);if(i.Xt({U9:f[2]/f[3],Uy:[f[2],f[3]]}),t.As(),t.ks({x:n,y:o,width:h,height:a},u),t.$s()){const g=t.unitGeometry,d=t.unitBuffer;try{this.gs.us(i.Zt,t.type+"",g,d),t.batch.Ms(i),t.batch.Rs(g.Fs,g.Ss)}finally{t.batch.Ts(i),this.gs.vs(),t.As()}}}Ls(){return this.xt.es()}Es(t,i){return this.Cs&&this.ws&&this.ws.w===t&&this.ws.h===i||(this.Cs&&this.Cs.Pt(),this.Cs=new $(this.gt,t,i,5),this.ws={w:t,h:i}),this.Cs}Pt(){this.gs.Pt(),this.Cs&&this.Cs.Pt()}}class yt{constructor(){c(this,"Ds",[]);c(this,"Bs",1);c(this,"Gs",0)}Is(t){if(this.Gs>=this.Ds.length){const r={id:this.Bs++,type:t,params:{},state:{W:1,H:0,K:0,X:0,Y:[0,0,0],V:[1,1,1,1],q:[0,0,0,1],N:!1,j:!1,L:!1,D:[0,0]}};this.Ds.push(r)}const i=this.Ds[this.Gs];return i.id=this.Bs++,i.type=t,this.Gs++,i}Os(t,i,r,n,o){const h=this.Is(R.RECTANGLE);return h.params.x=t,h.params.y=i,h.params.width=r,h.params.height=n,o.J(h.state),h.id}Ws(t,i,r,n,o,h,a){const u=this.Is(R.CUSTOM);return u.params.x=t,u.params.y=i,u.params.width=r,u.params.height=n,u.params.shader=o,u.params.uniforms=h,a.J(u.state),u.id}Hs(t,i,r,n,o,h){const a=this.Is(R.LINE);return a.params.x1=t,a.params.y1=i,a.params.x2=r,a.params.y2=n,a.params.thickness=o,h.J(a.state),a.id}Ks(t,i,r,n,o){const h=this.Is(R.ELLIPSE);return h.params.x=t,h.params.y=i,h.params.width=r,h.params.height=n,o.J(h.state),h.id}Xs(t,i,r,n,o,h,a){const u=this.Is(R.ARC);return u.params.x=t,u.params.y=i,u.params.width=r,u.params.height=n,u.params.start=o,u.params.stop=h,a.J(u.state),u.id}Ns(t,i,r,n,o,h,a){const u=this.Is(R.TRIANGLE);return u.params.x1=t,u.params.y1=i,u.params.x2=r,u.params.y2=n,u.params.x3=o,u.params.y3=h,a.J(u.state),u.id}js(t,i,r,n,o,h,a,u,f,g){const d=this.Is(R.BEZIER_CURVE);return d.params.x1=t,d.params.y1=i,d.params.cp1x=r,d.params.cp1y=n,d.params.cp2x=o,d.params.cp2y=h,d.params.x2=a,d.params.y2=u,d.params.thickness=f,g.J(d.state),d.id}get length(){return this.Gs}get isEmpty(){return this.Gs===0}Ys(){this.Gs=0}[Symbol.iterator](){let t=0;const i=this.Gs,r=this.Ds;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}const M=class M{static Vs(t,i,r=0){var h,a,u,f,g,d,v,x,p,m;const n=i||new Float32Array(M.FLOATS_PER_INSTANCE);let o=r;return n[o++]=t.fs[0],n[o++]=t.fs[1],n[o++]=t.Gs[0],n[o++]=t.Gs[1],n[o++]=t.Y[0],n[o++]=t.Y[1],n[o++]=t.Y[2],n[o++]=t.V[0],n[o++]=t.V[1],n[o++]=t.V[2],n[o++]=t.V[3],n[o++]=t.q[0],n[o++]=t.q[1],n[o++]=t.q[2],n[o++]=t.q[3],n[o++]=t.D[0],n[o++]=t.D[1],n[o++]=t.qs[0],n[o++]=t.qs[1],n[o++]=t.qs[2],n[o++]=t.H,n[o++]=t.K,n[o++]=t.X,n[o++]=t.Zs[0],n[o++]=t.Zs[1],n[o++]=((h=t.Js)==null?void 0:h[0])||0,n[o++]=((a=t.Js)==null?void 0:a[1])||0,n[o++]=((u=t.Qs)==null?void 0:u[0])||0,n[o++]=((f=t.Qs)==null?void 0:f[1])||0,n[o++]=((g=t.te)==null?void 0:g[0])||0,n[o++]=((d=t.te)==null?void 0:d[1])||0,n[o++]=((v=t.se)==null?void 0:v[0])||0,n[o++]=((x=t.se)==null?void 0:x[1])||0,n[o++]=((p=t.ee)==null?void 0:p[0])||0,n[o++]=((m=t.ee)==null?void 0:m[1])||0,n}static ie(t){const i=t.length*M.FLOATS_PER_INSTANCE,r=new Float32Array(i);for(let n=0;n<t.length;n++){const o=n*M.FLOATS_PER_INSTANCE;M.Vs(t[n],r,o)}return r}};c(M,"BYTES_PER_INSTANCE",140),c(M,"FLOATS_PER_INSTANCE",35);let D=M;const _=class _{};c(_,"STRIDE",D.BYTES_PER_INSTANCE),c(_,"ATTRIBUTES",{a_instancePosition:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:0,divisor:1},a_instanceSize:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:8,divisor:1},a_instanceCharacter:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:16,divisor:1},a_instancePrimaryColor:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:28,divisor:1},a_instanceSecondaryColor:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:44,divisor:1},a_instanceRotation:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:60,divisor:1},a_instanceTransform:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:68,divisor:1},a_instanceGlobalRotation:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:80,divisor:1},a_instanceRotationCenter:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:92,divisor:1},a_instanceArcAngles:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:100,divisor:1},a_instanceBezierCP1:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:108,divisor:1},a_instanceBezierCP2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:116,divisor:1},a_instanceBezierStart:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:124,divisor:1},a_instanceBezierEnd:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:_.STRIDE,offset:132,divisor:1}});let q=_;class xt{constructor(t,i=1e3,r=1.5){c(this,"gt");c(this,"re",[]);c(this,"ne");c(this,"oe");c(this,"he",null);c(this,"ae",!0);c(this,"ce",0);c(this,"le",new Map);c(this,"ue",null);this.gt=t,this.ne=i,this.oe=r,this.fe()}ks(t){const i=this.re.length;return this.re.push(t),this.ae=!0,i}get count(){return this.re.length}get isEmpty(){return this.re.length===0}clear(){this.re.length=0,this.ae=!0}de(t){if(t<=this.ne)return;const i=Math.ceil(t*this.oe);this.ne=i,this.fe()}fe(){const t=this.gt;this.he&&t.deleteBuffer(this.he),this.he=t.createBuffer();const i=this.ne*D.BYTES_PER_INSTANCE;t.bindBuffer(t.ARRAY_BUFFER,this.he),t.bufferData(t.ARRAY_BUFFER,i,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),this.ae=!0,this.ce=0}_e(){if(!this.ae||this.re.length===0)return;const t=this.gt,i=this.re.length;this.de(i),(!this.ue||this.ue.length<i*D.FLOATS_PER_INSTANCE)&&(this.ue=new Float32Array(i*D.FLOATS_PER_INSTANCE));const r=D.ie(this.re);t.bindBuffer(t.ARRAY_BUFFER,this.he),i<=this.ce?t.bufferSubData(t.ARRAY_BUFFER,0,r):t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),this.ae=!1,this.ce=i}pe(t){let i=this.le.get(t);if(!i){i=new Map;const r=this.gt;for(const n in q.ATTRIBUTES){const o=r.getAttribLocation(t,n);o!==-1&&i.set(n,o)}this.le.set(t,i)}return i}Ms(t){if(!this.he||this.re.length===0)return;const i=this.gt,r=t.Zt;this._e();const n=this.pe(r);i.bindBuffer(i.ARRAY_BUFFER,this.he);for(const[o,h]of n){const a=q.ATTRIBUTES[o];a&&(i.enableVertexAttribArray(h),i.vertexAttribPointer(h,a.size,a.type,a.normalized,a.stride,a.offset),i.vertexAttribDivisor(h,a.divisor))}}Ts(t){const i=this.gt,r=this.pe(t.Zt);for(const[,n]of r)i.disableVertexAttribArray(n),i.vertexAttribDivisor(n,0)}Rs(t,i){this.re.length!==0&&this.gt.drawArraysInstanced(t,0,i,this.re.length)}Pt(){this.he&&this.gt.deleteBuffer(this.he)}}class N{constructor(t,i,r,n){c(this,"gt");c(this,"me");c(this,"ve");c(this,"ge");c(this,"ye",null);this.gt=t,this.me=i,this.ve=r,this.ge=n;const o=this.gt.createBuffer();if(!o)throw Error("Failed to create unit geometry buffer");this.gt.bindBuffer(this.gt.ARRAY_BUFFER,o),this.gt.bufferData(this.gt.ARRAY_BUFFER,this.ge.Ce,this.gt.STATIC_DRAW),this.gt.bindBuffer(this.gt.ARRAY_BUFFER,null),this.ye=o}get type(){return this.ve}get unitGeometry(){return this.ge}get unitBuffer(){return this.ye}get batch(){return this.me}As(){this.me.clear()}$s(){return!this.me.isEmpty}Pt(){this.me.Pt(),this.gt.deleteBuffer(this.ye)}we(t,i,r,n,o){const h=this.be(t,i,r,n,o.H||0,o.K||0,o.X||0);return{fs:[t,i],Gs:[r,n],Y:o.Y||[0,0,0],V:o.V||[1,1,1,1],q:o.q||[0,0,0,1],D:o.D||[0,0],qs:[o.L?1:0,o.N?1:0,o.j?1:0],H:h.radiansX,K:h.radiansY,X:h.radiansZ,Zs:[h.centerX,h.centerY]}}$e(t,i){const r=V(this.gt)||[0,0,this.gt.canvas.width,this.gt.canvas.height];return{nx:t/r[2]*2-1,ny:1-i/r[3]*2}}xe(t,i,r){const n=this.$e(i,r);t.Zs=[n.nx,n.ny]}be(t,i,r,n,o,h,a){const u=V(this.gt)||[0,0,this.gt.canvas.width,this.gt.canvas.height],f=u[2],g=u[3];return{centerX:(t+r/2)/f*2-1,centerY:1-(i+n/2)/g*2,radiansX:-o*Math.PI/180,radiansY:-h*Math.PI/180,radiansZ:-a*Math.PI/180,aspectRatio:f/g}}}const Et={Ce:new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,1,1,1]),Ss:6,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class wt extends N{constructor(t,i){super(t,i,R.RECTANGLE,Et)}ks(t,i){const r=this.we(t.x,t.y,t.width,t.height,i);return this.me.ks(r)}}const Rt={Ce: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]),Ss:6,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class At extends N{constructor(t,i){super(t,i,R.LINE,Rt)}ks(t,i){const r=t.x2-t.x1,n=t.y2-t.y1,o=Math.hypot(r,n),h=t.thickness||i.W||1,a=t.x1+r/2,u=t.y1+n/2,f=a-o/2,g=u,d=this.we(f,g,o,h,i);return this.xe(d,a,u),this.me.ks(d)}}const Tt={Ce:function(l=32){const t=[],i=2*Math.PI/l;for(let r=0;r<l;r++){const n=r*i,o=(r+1)%l*i,h=Math.cos(n),a=Math.sin(n),u=.5*(h+1),f=.5*(a+1),g=Math.cos(o),d=Math.sin(o),v=.5*(g+1),x=.5*(d+1);t.push(0,0,.5,.5,h,a,u,f,g,d,v,x)}return new Float32Array(t)}(32),Ss:96,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class bt extends N{constructor(t,i){super(t,i,R.ELLIPSE,Tt)}ks(t,i){const r=this.we(t.x,t.y,t.width,t.height,i);return this.xe(r,t.x,t.y),this.me.ks(r)}}let Ct={Ce:function(l){const t=[];for(let i=0;i<l;i++){const r=i/l,n=(i+1)/l;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),Ss:96,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class _t extends N{constructor(t,i){super(t,i,R.ARC,Ct)}ks(t,i){const r=t.x-t.width/2,n=t.y-t.height/2,o=t.start*Math.PI/180,h=t.stop*Math.PI/180,a=this.we(r,n,t.width,t.height,i);return this.xe(a,t.x,t.y),a.Js=[o,h],this.me.ks(a)}}const Ut={Ce:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Ss:3,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class Ft extends N{constructor(t,i){super(t,i,R.TRIANGLE,Ut)}ks(t,i){const r=Math.min(t.x1,t.x2,t.x3),n=Math.max(t.x1,t.x2,t.x3),o=Math.min(t.y1,t.y2,t.y3),h=n-r,a=Math.max(t.y1,t.y2,t.y3)-o,u=this.we(r,o,h,a,i),f=r+.5*h,g=o+a*(1/3);return this.xe(u,f,g),this.me.ks(u)}}function nt(l,t,i,r,n){const o=1-l,h=o*o,a=l*l;return h*o*t+3*h*l*i+3*o*a*r+a*l*n}const Pt={Ce:function(l=16){const t=[];for(let i=0;i<l;i++){const r=i/l,n=(i+1)/l;t.push(r,-.5,r,0),t.push(n,-.5,n,0),t.push(r,.5,r,1),t.push(r,.5,r,1),t.push(n,-.5,n,0),t.push(n,.5,n,1)}return new Float32Array(t)}(16),Ss:96,Fs:WebGL2RenderingContext.TRIANGLES,_s:16,ds:{fs:{size:2,offset:0},ps:{size:2,offset:8}}};class Lt extends N{constructor(t,i){super(t,i,R.BEZIER_CURVE,Pt)}ks(t,i){const r=i.W||1,n=nt(.5,t.x1,t.cp1x,t.cp2x,t.x2),o=nt(.5,t.y1,t.cp1y,t.cp2y,t.y2),h=this.we(0,0,1,r,i);return this.xe(h,n,o),h.se=[t.x1,t.y1],h.Qs=[t.cp1x,t.cp1y],h.te=[t.cp2x,t.cp2y],h.ee=[t.x2,t.y2],this.me.ks(h)}}class It{constructor(t){c(this,"gt");c(this,"Me",null);c(this,"Re");c(this,"Fe",null);c(this,"Se",{});c(this,"Te",null);c(this,"Ae",new Map);c(this,"ze");c(this,"ke");c(this,"Ee");c(this,"I",[]);this.gt=t,this.Re=new mt(t),this.Ee=new st,this.ze=new vt(t,this),this.ke=new yt,this.Te=t.createBuffer(),H(this.gt,[0,0,this.gt.canvas.width,this.gt.canvas.height])}Pe(t){let i=this.Ae.get(t);if(i)return i;const r=new xt(this.gt);return i=(0,{[R.RECTANGLE]:()=>new wt(this.gt,r),[R.LINE]:()=>new At(this.gt,r),[R.ELLIPSE]:()=>new bt(this.gt,r),[R.ARC]:()=>new _t(this.gt,r),[R.TRIANGLE]:()=>new Ft(this.gt,r),[R.BEZIER_CURVE]:()=>new Lt(this.gt,r)}[t])(),this.Ae.set(t,i),i}Le(t){this.Me!==t&&(this.Me=t,t.Ht())}cs(t,i){return this.Re.cs(t,i)}es(){return this.Re.es()}At(){return this.Re.At()}rs(){return this.Re.rs()}ns(){return this.Re.ns()}De(t){this.Fe=t,t&&(this.Se={})}Nt(t,i){this.Se[t]=i}Be(t){Object.assign(this.Se,t)}hs(t){return this.Re.hs(t)}Ge(t,i,r,n,o){const h=this.es(),a={Ue:t.textures[0],Uf:t.textures[1],Ug:t.textures[2],Uh:t.textures[3],Ui:t.textures[4],Uj:[t.width,t.height]};this.ke.Ws(i,r,n,o,h,a,this.Ee)}Ie(t,i,r,n,o){const h=this.ns(),a=t.Oe(),u={Uk:a.texture,Ul:!!a.invert,Um:!!a.flipX,Un:!!a.flipY,Uo:a.charRotation,Up:a.charColorFixed,Uq:a.charColor,Ur:a.cellColorFixed,Us:a.cellColor,Ut:a.backgroundColor,Uu:a.charCount,Uv:a.charList};this.ke.Ws(i,r,n,o,h,u,this.Ee)}We(t,i,r,n){var m;const o=this.gt,h=o.canvas.width,a=o.canvas.height,u=t/h*2-1,f=(t+r)/h*2-1,g=1-i/a*2,d=1-(i+n)/a*2,v=new Float32Array([u,d,f,d,u,g,f,d,f,g,u,g]);o.bindBuffer(o.ARRAY_BUFFER,this.Te),o.bufferData(o.ARRAY_BUFFER,v,o.DYNAMIC_DRAW);const x=((m=this.Me)==null?void 0:m.Zt)||o.getParameter(o.CURRENT_PROGRAM),p=x?o.getAttribLocation(x,"a_position"):-1;p!==-1&&(o.enableVertexAttribArray(p),o.vertexAttribPointer(p,2,o.FLOAT,!1,8,0)),o.drawArrays(o.TRIANGLES,0,6),p!==-1&&o.disableVertexAttribArray(p)}He(t,i,r,n){this.Fe?(this.ke.Ws(t,i,r,n,this.Fe,{...this.Se},this.Ee),this.Fe=null,this.Se={}):this.ke.Os(t,i,r,n,this.Ee)}Ke(t,i,r,n){this.ke.Hs(t,i,r,n,this.Ee.lineWeight,this.Ee)}Xe(t,i,r,n){this.ke.Ks(t,i,r,n,this.Ee)}Ne(t,i,r,n,o,h){this.ke.Ns(t,i,r,n,o,h,this.Ee)}je(t,i,r,n,o,h,a,u){const f=this.Ee.lineWeight;this.ke.js(t,i,r,n,o,h,a,u,f,this.Ee)}Ye(t,i,r=1,n={}){return new $(this.gt,t,i,r,n,this,!0)}Ve(t,i,r,n,o,h){this.ke.Xs(t,i,r,n,o,h,this.Ee)}qe(t,i=t,r=t,n=255){this.Ee.ft(t,i,r,n),this.Ys(t/255,i/255,r/255,n/255)}Ys(t=0,i=0,r=0,n=0){this.gt.clearColor(t,i,r,n),this.gt.clear(this.gt.COLOR_BUFFER_BIT)}Ze(){this.gt.viewport(0,0,this.gt.canvas.width,this.gt.canvas.height),H(this.gt,[0,0,this.gt.canvas.width,this.gt.canvas.height])}get context(){return this.gt}get state(){return this.Ee}kt(t){this.I.push(this.Ee),this.Ee=t}Et(){const t=this.I.pop();t&&(this.Ee=t)}zt(t){const i=t,r=V(this.gt)??this.gt.getParameter(this.gt.VIEWPORT),n={shader:i,gl:this.gt,viewport:r};this.Le(i);const o=new Set;for(const h of this.ke)h.type===R.CUSTOM?o.add(R.RECTANGLE):o.add(h.type);for(const h of o)h!==R.CUSTOM&&this.Pe(h);this.ze.bs(n,this.ke,this.Ae),this.ke.Ys()}Pt(){this.gt.deleteBuffer(this.Te),this.ke.Ys();for(const t of this.Ae.values())t.Pt();this.Re.Pt(),this.ze.Pt()}}const b={readShort:(l,t)=>(b.t.uint16[0]=l[t]<<8|l[t+1],b.t.int16[0]),readUshort:(l,t)=>l[t]<<8|l[t+1],readUshorts(l,t,i){const r=[];for(let n=0;n<i;n++)r.push(b.readUshort(l,t+2*n));return r},readUint(l,t){const i=b.t.uint8;return i[3]=l[t],i[2]=l[t+1],i[1]=l[t+2],i[0]=l[t+3],b.t.uint32[0]},readASCII(l,t,i){let r="";for(let n=0;n<i;n++)r+=String.fromCharCode(l[t+n]);return r},writeUshort(l,t,i){l[t]=i>>>8&255,l[t+1]=255&i},writeUint(l,t,i){l[t]=i>>>24&255,l[t+1]=i>>>16&255,l[t+2]=i>>>8&255,l[t+3]=255&i},writeASCII(l,t,i){for(let r=0;r<i.length;r++)l[t+r]=255&i.charCodeAt(r)},t:(()=>{const l=new ArrayBuffer(8);return{uint8:new Uint8Array(l),int16:new Int16Array(l),uint16:new Uint16Array(l),uint32:new Uint32Array(l)}})()};function j(l){return l+3&-4}function Q(l,t,i){const r=t+i;let n=0;const o=b.t;for(let h=t;h<r;h+=4)o.uint8[3]=l[h]||0,o.uint8[2]=l[h+1]||0,o.uint8[1]=l[h+2]||0,o.uint8[0]=l[h+3]||0,n=n+(o.uint32[0]>>>0)>>>0;return n>>>0}class St{constructor(t){c(this,"b");c(this,"p",0);c(this,"bitbuf",0);c(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 X(l){let t=32,i=0;for(const a of l)a&&(a<t&&(t=a),a>i&&(i=a));if(i===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(i+1);for(const a of l)a&&r[a]++;const n=new Uint32Array(i+1);let o=0;r[0]=0;for(let a=1;a<=i;a++)o=o+r[a-1]<<1,n[a]=o;const h=new Map;for(let a=0;a<l.length;a++){const u=l[a];if(!u)continue;const f=n[u]++;let g=h.get(u);g||(g=[],h.set(u,g)),g[Mt(f,u)]=a}return{min:t,max:i,table:h}}function tt(l,t){let i=0;for(let r=1;r<=t.max;r++){i|=l.readBits(1)<<r-1;const n=t.table.get(r);if(n&&i<n.length){const o=n[i];if(o!==void 0)return o}}throw Error("Invalid Huffman code")}function Mt(l,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&l,l>>>=1;return i>>>0}function Gt(l){if(l.length<2)throw Error("ZLIB data too short");const t=l[0],i=l[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(o,h){const a=[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],g=[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 d=0;for(;!d;){d=o.readBits(1);const v=o.readBits(2);if(v===0){o.alignToByte();const x=o.readBits(16);if((65535&(65535^x))!==o.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let p=0;p<x;p++)h.push(o.readBits(8))}else{if(v!==1&&v!==2)throw Error("Unsupported DEFLATE type");{let x,p;if(v===1){const m=Array(288).fill(0);for(let E=0;E<=143;E++)m[E]=8;for(let E=144;E<=255;E++)m[E]=9;for(let E=256;E<=279;E++)m[E]=7;for(let E=280;E<=287;E++)m[E]=8;x=X(m),p=X(Array(32).fill(5))}else{const m=o.readBits(5)+257,E=o.readBits(5)+1,y=o.readBits(4)+4,A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],w=Array(19).fill(0);for(let L=0;L<y;L++)w[A[L]]=o.readBits(3);const P=X(w),U=[];for(;U.length<m+E;){const L=tt(o,P);if(L<=15)U.push(L);else if(L===16){const Y=o.readBits(2)+3,O=U[U.length-1]||0;for(let gt=0;gt<Y;gt++)U.push(O)}else if(L===17){const Y=o.readBits(3)+3;for(let O=0;O<Y;O++)U.push(0)}else{if(L!==18)throw Error("Invalid code length symbol");{const Y=o.readBits(7)+11;for(let O=0;O<Y;O++)U.push(0)}}}const F=U.slice(0,m),I=U.slice(m,m+E);x=X(F),p=X(I)}for(;;){const m=tt(o,x);if(m<256)h.push(m);else{if(m===256)break;if(m>256&&m<286){const E=m-257;let y=a[E];const A=u[E];A&&(y+=o.readBits(A));const w=tt(o,p);if(w>=30)throw Error("Invalid distance symbol");let P=f[w];const U=g[w];U&&(P+=o.readBits(U));const F=h.length-P;if(F<0)throw Error("Invalid distance");for(let I=0;I<y;I++)h.push(h[F+I]||0)}else if(m===286||m===287)throw Error("Reserved length symbol")}}}}}}(new St(l.subarray(r)),n),new Uint8Array(n)}function Dt(l){const t=b,i=new Uint8Array(l);if(t.readASCII(i,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(i,4),n=t.readUshort(i,12),o=t.readUint(i,16),h=[];let a=44;for(let y=0;y<n;y++){const A=t.readASCII(i,a,4),w=t.readUint(i,a+4),P=t.readUint(i,a+8),U=t.readUint(i,a+12),F=t.readUint(i,a+16);h.push({tag:A,offset:w,compLength:P,origLength:U,checksum:F}),a+=20}for(const y of h){const A=new Uint8Array(i.buffer,y.offset,y.compLength);if(y.compLength===y.origLength)y.data=new Uint8Array(A);else if(y.data=Gt(A),y.data.length!==y.origLength)if(y.data.length<y.origLength){const w=new Uint8Array(y.origLength);w.set(y.data),y.data=w}else y.data=y.data.subarray(0,y.origLength)}const u=n;let f=1,g=0;for(;f<<1<=u;)f<<=1,g++;const d=16*f,v=16*u-d;let x=12+16*u;const p={};for(const y of h)p[y.tag]=x,x=j(x+y.data.length);const m=new Uint8Array(Math.max(o||0,x));t.writeUint(m,0,r),t.writeUshort(m,4,u),t.writeUshort(m,6,d),t.writeUshort(m,8,g),t.writeUshort(m,10,v);let E=12;for(const y of h){t.writeASCII(m,E,y.tag),E+=4;let A=y.data;if(y.tag==="head"&&A.length>=12){const w=new Uint8Array(A);t.writeUint(w,8,0);const P=Q(w,0,j(w.length));t.writeUint(m,E,P),E+=4}else{const w=Q(A,0,j(A.length));t.writeUint(m,E,w),E+=4}t.writeUint(m,E,p[y.tag]),E+=4,t.writeUint(m,E,y.data.length),E+=4}for(const y of h){const A=p[y.tag];m.set(y.data,A)}if(h.find(y=>y.tag==="head")){const y=p.head,A=function(w,P){const U=b,F=P+8,I=[w[F],w[F+1],w[F+2],w[F+3]];U.writeUint(w,F,0);const L=2981146554-(Q(w,0,j(w.length))>>>0)>>>0;return w[F]=I[0],w[F+1]=I[1],w[F+2]=I[2],w[F+3]=I[3],L>>>0}(m,y);t.writeUint(m,y+8,A)}return m.buffer}const Bt={parseTab(l,t,i){const r={tables:[],ids:{},off:t};l=new Uint8Array(l.buffer,t,i),t=0;const n=b,o=n.readUshort,h=o(l,t+=2);t+=2;const a=[];for(let u=0;u<h;u++){const f=o(l,t),g=o(l,t+=2);t+=2;const d=n.readUint(l,t);t+=4;const v=`p${f}e${g}`;let x=a.indexOf(d);if(x===-1){let p;x=r.tables.length,a.push(d);const m=o(l,d);p=m===4?this.parse4(l,d):m===12?this.parse12(l,d):{format:m},r.tables.push(p)}r.ids[v]=x}return r},parse4(l,t){const i=b,r=i.readUshort,n=i.readUshorts,o=t,h=r(l,t+=2);t+=2;const a=r(l,t+=2)>>>1,u={format:4,searchRange:r(l,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(l,t),t+=2,u.rangeShift=r(l,t),t+=2,u.endCount=n(l,t,a),t+=2*a,t+=2,u.startCount=n(l,t,a),t+=2*a;for(let f=0;f<a;f++)u.idDelta.push(i.readShort(l,t)),t+=2;return u.idRangeOffset=n(l,t,a),t+=2*a,u.glyphIdArray=n(l,t,o+h-t>>1),u},parse12(l,t){const i=b.readUint;i(l,t+=4),i(l,t+=4);const r=i(l,t+=4);t+=4;const n=new Uint32Array(3*r);for(let o=0;o<3*r;o+=3)n[o]=i(l,t+(o<<2)),n[o+1]=i(l,t+(o<<2)+4),n[o+2]=i(l,t+(o<<2)+8);return{format:12,groups:n}}},Ot={parseTab(l,t,i){const r=b;t+=18;const n=r.readUshort(l,t);t+=2,t+=16;const o=r.readShort(l,t);t+=2;const h=r.readShort(l,t);t+=2;const a=r.readShort(l,t);t+=2;const u=r.readShort(l,t);return t+=2,t+=6,{unitsPerEm:n,xMin:o,yMin:h,xMax:a,yMax:u,indexToLocFormat:r.readShort(l,t)}}},kt={parseTab(l,t,i){const r=b;t+=4;const n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],o={};for(let h=0;h<n.length;h++){const a=n[h],u=a==="advanceWidthMax"||a==="numberOfHMetrics"?r.readUshort:r.readShort;o[a]=u(l,t+2*h)}return o}},Nt={parseTab(l,t,i,r){const n=b,o=[],h=[],a=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,g=0,d=0;for(;d<u;)f=n.readUshort(l,t+(d<<2)),g=n.readShort(l,t+(d<<2)+2),o.push(f),h.push(g),d++;for(;d<a;)o.push(f),h.push(g),d++;return{aWidth:o,lsBearing:h}}},ot={cmap:Bt,head:Ot,hhea:kt,maxp:{parseTab(l,t,i){const r=b;return r.readUint(l,t),t+=4,{numGlyphs:r.readUshort(l,t)}}},hmtx:Nt,loca:{parseTab(l,t,i,r){const n=b,o=[],h=r.head.indexToLocFormat,a=r.maxp.numGlyphs+1;if(h===0)for(let u=0;u<a;u++)o.push(n.readUshort(l,t+(u<<1))<<1);else if(h===1)for(let u=0;u<a;u++)o.push(n.readUint(l,t+(u<<2)));return o}},glyf:{parseTab(l,t,i,r){const n=[],o=r.maxp.numGlyphs;for(let h=0;h<o;h++)n.push(null);return n},Je(l,t){const i=b,r=l.Qe,n=l.loca;if(n[t]===n[t+1])return null;const o=S.findTable(r,"glyf",l.ti);if(!o)return null;let h=o[0]+n[t];const a={};if(a.noc=i.readShort(r,h),h+=2,a.xMin=i.readShort(r,h),h+=2,a.yMin=i.readShort(r,h),h+=2,a.xMax=i.readShort(r,h),h+=2,a.yMax=i.readShort(r,h),h+=2,a.xMin>=a.xMax||a.yMin>=a.yMax)return null;if(a.noc>0){a.endPts=[];for(let v=0;v<a.noc;v++)a.endPts.push(i.readUshort(r,h)),h+=2;const u=i.readUshort(r,h);if(h+=2,r.length-h<u)return null;h+=u;const f=a.endPts[a.noc-1]+1;a.flags=[];for(let v=0;v<f;v++){const x=r[h];if(h++,a.flags.push(x),8&x){const p=r[h];h++;for(let m=0;m<p;m++)a.flags.push(x),v++}}a.xs=[];for(let v=0;v<f;v++){const x=a.flags[v],p=!!(16&x);2&x?(a.xs.push(p?r[h]:-r[h]),h++):p?a.xs.push(0):(a.xs.push(i.readShort(r,h)),h+=2)}a.ys=[];for(let v=0;v<f;v++){const x=a.flags[v],p=!!(32&x);4&x?(a.ys.push(p?r[h]:-r[h]),h++):p?a.ys.push(0):(a.ys.push(i.readShort(r,h)),h+=2)}let g=0,d=0;for(let v=0;v<f;v++)g+=a.xs[v],d+=a.ys[v],a.xs[v]=g,a.ys[v]=d}else a.parts=[],a.endPts=[],a.flags=[],a.xs=[],a.ys=[];return a}}},S={parse(l){const t=new Uint8Array(l),i=b.readASCII(t,0,4);if(i==="wOFF")l=Dt(l);else if(i==="wOF2")throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");return[((r,n,o,h)=>{const a=ot,u={Qe:r,si:n,ti:o};for(const f in a){const g=f,d=S.findTable(r,g,o);if(d){const[v,x]=d;let p=h[v];p==null&&(p=a[g].parseTab(r,v,x,u),h[v]=p),u[g]=p}}return u})(new Uint8Array(l),0,0,{})]},findTable(l,t,i){const r=b,n=r.readUshort(l,i+4);let o=i+12;for(let h=0;h<n;h++){const a=r.readASCII(l,o,4);r.readUint(l,o+4);const u=r.readUint(l,o+8),f=r.readUint(l,o+12);if(a===t)return[u,f];o+=16}return null},T:ot,B:b};class zt{ei(t){var r;const i=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(n=>{if(n.format===4){const o=this.ii(n);i.push(...o)}else if(n.format===12){const o=this.ri(n);i.push(...o)}}),[...new Set(i)]):[]}ni(t){return t.filter(i=>this.oi(i))}ii(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],o=t.endCount[r];if(n!==65535||o!==65535){for(let h=n;h<=o;h++)if(this.hi(t,h,r)>0)try{const a=String.fromCodePoint(h);i.push(a)}catch{}}}return i}ri(t){const i=[];if(!t.groups)return i;for(let r=0;r<t.groups.length;r+=3){const n=t.groups[r],o=t.groups[r+1],h=t.groups[r+2];for(let a=n;a<=o;a++)if(h+(a-n)>0)try{const u=String.fromCodePoint(a);i.push(u)}catch{}}return i}hi(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 o=t.glyphIdArray[n];if(o!==0)return o+t.idDelta[r]&65535}}return 0}oi(t){const i=t.codePointAt(0)||0;return!(i>=0&&i<=31&&i!==9&&i!==10&&i!==13||i>=127&&i<=159)}}class et{constructor(){c(this,"ai",new Map);c(this,"ci",new Map)}li(t,i){const r=`${this.ui(t)}_${i}`;if(this.ai.has(r))return this.ai.get(r);const n=t.cmap;if(!n||!n.tables)return this.ai.set(r,0),0;let o=0;for(const h of n.tables)if(h.format===4?o=this.fi(i,h):h.format===12&&(o=this.di(i,h)),o>0)break;return this.ai.set(r,o),o}_i(t,i){const r=i.codePointAt(0);return r===void 0?0:this.li(t,r)}pi(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}mi(t,i){const r=i/t.head.unitsPerEm,n=t.hhea.ascender*r,o=t.hhea.descender*r,h=t.hhea.lineGap*r;return{ascender:n,descender:o,lineGap:h,lineHeight:n-o+h,unitsPerEm:t.head.unitsPerEm,scale:r}}gi(){this.ai.clear(),this.ci.clear()}ui(t){return`${t.ti}_${t.Qe.length}`}fi(t,i){const r=i.endCount.length;let n=-1;for(let o=0;o<r;o++)if(t<=i.endCount[o]){n=o;break}if(n===-1||t<i.startCount[n])return 0;if(i.idRangeOffset[n]===0)return t+i.idDelta[n]&65535;{const o=i.idRangeOffset[n]/2+(t-i.startCount[n])-(r-n);if(o>=0&&o<i.glyphIdArray.length){const h=i.glyphIdArray[o];return h===0?0:h+i.idDelta[n]&65535}}return 0}di(t,i){const r=i.groups.length/3;for(let n=0;n<r;n++){const o=i.groups[3*n],h=i.groups[3*n+1],a=i.groups[3*n+2];if(t>=o&&t<=h)return a+(t-o)}return 0}}class Wt{constructor(t){c(this,"yi");c(this,"Ci");c(this,"xt");c(this,"wi");this.xt=t,this.wi=new et,this.yi=document.createElement("canvas"),this.Ci=this.yi.getContext("2d",{willReadFrequently:!0,alpha:!0})}createTextureAtlas(t,i,r,n){const o=t.length,h=Math.ceil(Math.sqrt(o)),a=Math.ceil(o/h),u=i.width*h,f=i.height*a,g=typeof n=="object"?n:null;this.bi(u,f),this.$i(t,i,h,r,g);const d=this.xt.Ye(u,f,1,{filter:"nearest"});return d.Tt(this.yi),{framebuffer:d,columns:h,rows:a}}bi(t,i){this.yi.width=t,this.yi.height=i,this.yi.style.width=t+"px",this.yi.style.height=i+"px",this.Ci.imageSmoothingEnabled=!1,this.yi.style.imageRendering="pixelated",this.Ci.clearRect(0,0,t,i),this.Ci.textBaseline="top",this.Ci.textAlign="left",this.Ci.fillStyle="white"}$i(t,i,r,n,o){const h=n/o.head.unitsPerEm;for(let a=0;a<t.length;a++){const u=a%r,f=Math.floor(a/r),g=t[a].character,d=this.xi(o,g);if(!d)continue;const v=g.codePointAt(0)||0,x=this.wi.li(o,v),p=this.Mi(o,x)*h,m=u*i.width,E=f*i.height,y=m+.5*i.width,A=E+.5*i.height,w=Math.round(y-.5*i.width),P=Math.round(A-.5*n),U=w+.5*(i.width-p),F=P+o.hhea.ascender*h;this.Ri(d,U,F,h)}}xi(t,i){const r=i.codePointAt(0)||0,n=this.wi.li(t,r);if(n===0)return null;if(t.glyf&&t.glyf[n]!==null)return t.glyf[n];if(S&&S.T&&S.T.glyf){const o=S.T.glyf.Je(t,n);return t.glyf&&o&&(t.glyf[n]=o),o}return null}Mi(t,i){const r=t.hmtx;return r&&r.aWidth?i<r.aWidth.length?r.aWidth[i]:r.aWidth[r.aWidth.length-1]:0}Ri(t,i,r,n){if(!t||!t.xs||t.noc===0)return;const{xs:o,ys:h,endPts:a,flags:u}=t;if(!(o&&h&&a&&u))return;this.Ci.beginPath();let f=0;for(let g=0;g<a.length;g++){const d=a[g];if(!(d<f)){if(d>=f){const v=i+o[f]*n,x=r-h[f]*n;this.Ci.moveTo(v,x);let p=f+1;for(;p<=d;)if(1&u[p]){const m=i+o[p]*n,E=r-h[p]*n;this.Ci.lineTo(m,E),p++}else{const m=i+o[p]*n,E=r-h[p]*n;let y=p+1>d?f:p+1;if(1&u[y]){const A=i+o[y]*n,w=r-h[y]*n;this.Ci.quadraticCurveTo(m,E,A,w),p=y+1}else{const A=(m+(i+o[y]*n))/2,w=(E+(r-h[y]*n))/2;this.Ci.quadraticCurveTo(m,E,A,w),p=y}}this.Ci.closePath()}f=d+1}}this.Ci.fill()}}class Xt{constructor(){c(this,"Fi");this.Fi=new et}Si(t,i,r){let n=0;const o=this.Fi.mi(r,i),h=o.lineHeight;for(const a of t){const u=this.Fi._i(r,a);if(u===0)continue;const f=this.Fi.pi(r,u)*o.scale;n=Math.max(n,f)}return{width:Math.ceil(n),height:Math.ceil(h)}}gi(){this.Fi.gi()}}class Yt{constructor(){c(this,"wi");this.wi=new et}createCharacterObjects(t,i){return t.map((r,n)=>{const o=r.codePointAt(0)||0,h=this.Ti(n);let a=0;if(i.hmtx&&i.hmtx.aWidth){const u=this.wi.li(i,o);u>0&&i.hmtx.aWidth[u]!==void 0&&(a=i.hmtx.aWidth[u])}return{character:r,unicode:o,color:h,advanceWidth:a}})}Ti(t){return[t%256/255,Math.floor(t/256)%256/255,Math.floor(t/65536)%256/255]}Ai(t,i){if(!W.v(typeof t=="string","Character must be a string.",{method:"getCharacterColor",providedValue:t}))return[0,0,0];const r=i.find(n=>n.character===t);return r?r.color:[0,0,0]}zi(t,i){return W.v(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",providedValue:t})?Array.from(t).map(r=>this.Ai(r,i)||[0,0,0]):[[0,0,0]]}}class ht{constructor(t,i=16){c(this,"ki");c(this,"Ei",[]);c(this,"Pi");c(this,"Li",16);c(this,"Di",0);c(this,"Bi",0);c(this,"Gi",{width:0,height:0});c(this,"Ii");c(this,"Oi",new Map);c(this,"Wi");c(this,"Hi");c(this,"Ki");c(this,"Xi");this.Li=i,this.Wi=new zt,this.Hi=new Wt(t),this.Ki=new Xt,this.Xi=new Yt}async Ni(t){let i;if(!t)throw new T("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");{const r=await fetch(t);if(!r.ok)throw new T(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}await this.ji(i),this.ki=S.parse(i)[0],await this.Yi()}Vi(t){if(t===void 0)return this.Li;this.Li=t,this.Gi=this.Ki.Si(this.Ei.map(r=>r.character),this.Li,this.ki);const i=this.Hi.createTextureAtlas(this.Ei,this.Gi,this.Li,this.ki);this.Pi=i.framebuffer,this.Di=i.columns,this.Bi=i.rows}async qi(t){try{const i=await fetch(t);if(!i.ok)throw new T(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.ji(r);const n=S.parse(r);if(!n||n.length===0)throw Error("Failed to parse font file");this.ki=n[0],await this.Yi()}catch(i){throw new T("Failed to load font: "+(i instanceof Error?i.message:"Unknown error"),i)}}async ji(t){const i=Date.now();this.Ii=new FontFace("CustomFont_"+i,t),await this.Ii.load(),document.fonts.add(this.Ii)}async Yi(){const t=this.Wi.ei(this.ki),i=this.Wi.ni(t);this.Oi.clear(),this.Ei=this.Xi.createCharacterObjects(i,this.ki),this.Gi=this.Ki.Si(i,this.Li,this.ki);const r=this.Hi.createTextureAtlas(this.Ei,this.Gi,this.Li,this.ki);this.Pi=r.framebuffer,this.Di=r.columns,this.Bi=r.rows}Ai(t){return this.Xi.Ai(t,this.Ei)}zi(t){return this.Xi.zi(t,this.Ei)}getGlyphData(t){if(!Number.isFinite(t))return null;const i=this.Oi.get(t);if(i!==void 0)return i;const r=this.Zi(t);if(r<0)return this.Oi.set(t,null),null;const n=this.ki.glyf;if(!n)return this.Oi.set(t,null),null;let o=n[r]??null;return o==null&&(o=S.T.glyf.Je(this.ki,r)??null,n[r]=o),this.Oi.set(t,o),o}Zi(t){const i=this.ki.cmap;for(const r of i.tables)if(r.format===4){const n=r;for(let o=0;o<n.startCount.length;o++)if(t>=n.startCount[o]&&t<=n.endCount[o]){if(n.idRangeOffset[o]===0)return t+n.idDelta[o]&65535;{const h=n.idRangeOffset[o]/2+(t-n.startCount[o])-(n.startCount.length-o);if(h>=0&&h<n.glyphIdArray.length){const a=n.glyphIdArray[h];if(a!==0)return a+n.idDelta[o]&65535}}}}else if(r.format===12){const n=r;for(let o=0;o<n.groups.length;o+=3){const h=n.groups[o],a=n.groups[o+1],u=n.groups[o+2];if(t>=h&&t<=a)return u+(t-h)}}return 0}Pt(){this.Pi.Pt(),document.fonts.delete(this.Ii)}get fontFramebuffer(){return this.Pi}get characters(){return this.Ei}get textureColumns(){return this.Di}get textureRows(){return this.Bi}get maxGlyphDimensions(){return this.Gi}get fontSize(){return this.Li}get font(){return this.ki}}class at{constructor(t,i,r){c(this,"Ji");c(this,"Qi");c(this,"dt");c(this,"_t");c(this,"tr");c(this,"sr");c(this,"er");c(this,"ir");c(this,"rr");this.er=t,this.ir=i,this.rr=r,this.nr()}nr(){this.Ji=Math.floor(this.er.width/this.ir),this.Qi=Math.floor(this.er.height/this.rr),this.dt=this.Ji*this.ir,this._t=this.Qi*this.rr,this.tr=Math.floor((this.er.width-this.dt)/2),this.sr=Math.floor((this.er.height-this._t)/2)}hr(t,i){this.ir=t,this.rr=i,this.nr()}get cellWidth(){return this.ir}get cellHeight(){return this.rr}get cols(){return this.Ji}get rows(){return this.Qi}get width(){return this.dt}get height(){return this._t}get offsetX(){return this.tr}get offsetY(){return this.sr}}class ct{constructor(t={}){c(this,"er");c(this,"ar",null);c(this,"cr",!1);c(this,"lr");c(this,"ur");this.cr=t.overlay??!1,this.cr&&t.canvas?(this.ar=t.canvas,this.er=this.dr(),this.ur=!0,this._r()):t.canvas?(this.er=t.canvas,this.ur=!1):(this.er=this.pr(t.width,t.height),this.ur=!0),this.er.style.imageRendering="pixelated"}pr(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}dr(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.ar.getBoundingClientRect();let r=Math.round(i.width),n=Math.round(i.height);if(this.ar instanceof HTMLVideoElement){const a=this.ar;(r===0||n===0)&&a.videoWidth>0&&a.videoHeight>0&&(r=a.videoWidth,n=a.videoHeight)}t.width=r,t.height=n,t.style.position="absolute",t.style.pointerEvents="none";const o=window.getComputedStyle(this.ar);let h=parseInt(o.zIndex||"0",10);return isNaN(h)&&(h=0),t.style.zIndex=""+(h+1),t}_r(){var t;this.mr(),(t=this.ar.parentNode)==null||t.insertBefore(this.er,this.ar.nextSibling),window.ResizeObserver&&(this.lr=new ResizeObserver(()=>{this.vr()}),this.lr.observe(this.ar)),window.addEventListener("resize",()=>{this.vr()})}mr(){if(!this.ar)return;const t=this.ar.getBoundingClientRect();let i=this.ar.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.er.style.top=t.top-r.top+"px",this.er.style.left=t.left-r.left+"px"}else this.er.style.top=t.top+window.scrollY+"px",this.er.style.left=t.left+window.scrollX+"px"}vr(t,i){if(this.cr){const r=this.ar.getBoundingClientRect();let n=Math.round(r.width),o=Math.round(r.height);if(this.ar instanceof HTMLVideoElement){const h=this.ar;(n===0||o===0)&&h.videoWidth>0&&h.videoHeight>0&&(n=h.videoWidth,o=h.videoHeight)}this.er.width=n,this.er.height=o,this.mr()}else this.er.width=t??this.er.width,this.er.height=i??this.er.height}gr(){const t=this.er.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"});if(!t)throw new T("`textmode.js` requires WebGL2 support.");return t}Pt(){this.lr&&this.lr.disconnect();const t=this.er.getContext("webgl")||this.er.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i&&i.loseContext()}this.ur&&this.er.parentNode&&this.er.parentNode.removeChild(this.er)}get canvas(){return this.er}get targetCanvas(){return this.ar}get width(){return this.er.width}get height(){return this.er.height}}class z{constructor(t,i,r,n){c(this,"yr");c(this,"dt");c(this,"_t");c(this,"gt");c(this,"L",0);c(this,"N",0);c(this,"j",0);c(this,"D",[0,0]);c(this,"Cr","sampled");c(this,"wr","fixed");c(this,"V",[1,1,1,1]);c(this,"q",[0,0,0,1]);c(this,"br",[0,0,0,1]);c(this,"$r",[[.1,0,0]]);c(this,"Mr");this.gt=t,this.yr=i,this.dt=r,this._t=n}Pt(){this.gt.deleteTexture(this.yr)}Rr(t){return typeof t=="boolean"?t?1:0:(t==null?0:Number(t))>0?1:0}invert(t=!0){return this.L=this.Rr(t),this}flipX(t=!0){return this.N=this.Rr(t),this}flipY(t=!0){return this.j=this.Rr(t),this}charRotation(t){const i=255*t/360,r=Math.floor(i)/255,n=Math.round(i-Math.floor(i));return this.D=[r,n],this}Oe(){return{texture:this.yr,invert:this.L,flipX:this.N,flipY:this.j,charRotation:this.D,charColorFixed:this.Cr==="fixed",charColor:this.V,cellColorFixed:this.wr==="fixed",cellColor:this.q,backgroundColor:this.br,charCount:this.$r.length,charList:this.$r}}charColorMode(t){return this.Cr=t,this}cellColorMode(t){return this.wr=t,this}charColor(t,i,r,n){return this.V=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}cellColor(t,i,r,n){return this.q=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}background(t,i,r,n){return this.br=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}characters(t){const i=this.Mr(t).filter(r=>Array.isArray(r)).slice(0,64);return this.$r=i,this}static Fr(t,i,r){const n=t.context,o=n.createTexture();n.bindTexture(n.TEXTURE_2D,o),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,1),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,i),n.bindTexture(n.TEXTURE_2D,null);const h=i.naturalWidth??i.width??i.videoWidth??0,a=i.naturalHeight??i.height??i.videoHeight??0,u=new z(n,o,h,a);return u.Mr=r,u}get texture(){return this.yr}get width(){return this.dt}get height(){return this._t}}class Ht{constructor(t=60){c(this,"Sr");c(this,"Tr");c(this,"Ar",null);c(this,"zr",0);c(this,"kr",!0);c(this,"Er",0);c(this,"Pr",0);c(this,"Lr",[]);c(this,"Dr",10);c(this,"Br",0);this.Sr=t,this.Tr=1e3/t}start(t){if(!this.kr)return;this.zr=performance.now();const i=r=>{if(!this.kr)return void(this.Ar=null);const n=r-this.zr;n>=this.Tr&&(t(),this.zr=r-n%this.Tr),this.kr&&(this.Ar=requestAnimationFrame(i))};this.Ar=requestAnimationFrame(i)}stop(){this.Ar&&(cancelAnimationFrame(this.Ar),this.Ar=null)}pause(){this.kr&&(this.kr=!1,this.stop())}resume(t){this.kr||(this.kr=!0,this.start(t))}frameRate(t,i){if(t===void 0)return this.Er;this.Sr=t,this.Tr=1e3/t,this.kr&&i&&(this.stop(),this.start(i))}measureFrameRate(){const t=performance.now();if(this.Pr>0){const i=t-this.Pr;this.Lr.push(i),this.Lr.length>this.Dr&&this.Lr.shift();const r=this.Lr.reduce((n,o)=>n+o,0)/this.Lr.length;this.Er=1e3/r}this.Pr=t}get isLooping(){return this.kr}get frameRateLimit(){return this.Sr}get currentFrameRate(){return this.Er}get frameCount(){return this.Br}set frameCount(t){this.Br=t}incrementFrame(){this.Br++}resetFrameCount(){this.Br=0}}class lt{constructor(t){c(this,"er");c(this,"Gr");c(this,"Ir",{x:-1,y:-1});c(this,"Or",{x:-1,y:-1});c(this,"Wr",null);c(this,"Hr",0);c(this,"Kr");c(this,"Xr");c(this,"Nr");c(this,"jr");c(this,"Yr");c(this,"Vr");c(this,"qr",!1);c(this,"Zr");c(this,"Jr");c(this,"Qr");c(this,"tn");c(this,"sn");this.er=t}en(t){const i=performance.now()+Math.max(0,t);i>this.Hr&&(this.Hr=i)}rn(){return performance.now()<this.Hr}nn(t){const i=this.er.canvas;i.style.cursor=t==null||t===""?"":t}Ni(t){this.Gr=t,this.hn()}an(){if(this.qr)return;const t=this.er.canvas;this.Kr=i=>{this.cn(i),this.ln(i)},this.Xr=()=>{this.Or={...this.Ir},this.Ir.x=-1,this.Ir.y=-1,this.Wr=null},this.Nr=i=>{this.cn(i),this.un(i)},this.jr=i=>{this.cn(i),this.fn(i)},this.Yr=i=>{this.cn(i),this.dn(i)},this.Vr=i=>{this.cn(i),this._n(i)},t.addEventListener("mousemove",this.Kr,{passive:!0}),t.addEventListener("mouseleave",this.Xr,{passive:!0}),t.addEventListener("mousedown",this.Nr,{passive:!0}),t.addEventListener("mouseup",this.jr,{passive:!0}),t.addEventListener("click",this.Yr,{passive:!0}),t.addEventListener("wheel",this.Vr,{passive:!1}),this.qr=!0}pn(){if(!this.qr)return;const t=this.er.canvas;t.removeEventListener("mousemove",this.Kr),t.removeEventListener("mouseleave",this.Xr),t.removeEventListener("mousedown",this.Nr),t.removeEventListener("mouseup",this.jr),t.removeEventListener("click",this.Yr),t.removeEventListener("wheel",this.Vr),this.qr=!1}hn(){if(this.qr)try{if(this.Wr){const t=new MouseEvent("mousemove",{clientX:this.Wr.x,clientY:this.Wr.y,bubbles:!1,cancelable:!1});this.cn(t)}else this.Ir.x!==-1&&this.Ir.y!==-1&&(this.Ir.x>=this.Gr.cols||this.Ir.y>=this.Gr.rows)&&(this.Ir.x=-1,this.Ir.y=-1)}catch{this.Ir.x=-1,this.Ir.y=-1}}mn(t){this.Zr=t}vn(t){this.Jr=t}gn(t){this.Qr=t}yn(t){this.tn=t}Cn(t){this.sn=t}wn(){return{x:this.Ir.x,y:this.Ir.y}}ln(t){if(this.tn&&!this.rn()){const i={position:{...this.Ir},previousPosition:{...this.Or},originalEvent:t};this.tn(i)}}un(t){if(this.Jr&&!this.rn()){const i={position:{...this.Ir},previousPosition:{...this.Or},button:t.button,originalEvent:t};this.Jr(i)}}fn(t){if(this.Qr&&!this.rn()){const i={position:{...this.Ir},previousPosition:{...this.Or},button:t.button,originalEvent:t};this.Qr(i)}}dn(t){if(this.Zr&&!this.rn()){const i={position:{...this.Ir},previousPosition:{...this.Or},button:t.button,originalEvent:t};this.Zr(i)}}_n(t){if(this.sn&&!this.rn()){const i={position:{...this.Ir},previousPosition:{...this.Or},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.sn(i)}}cn(t){const i=this.er.canvas;this.Or={...this.Ir},this.Wr={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),n=t.clientX-r.left,o=t.clientY-r.top,h=i.width/r.width,a=o*(i.height/r.height),u=n*h-this.Gr.offsetX,f=a-this.Gr.offsetY,g=Math.floor(u/this.Gr.cellWidth),d=Math.floor(f/this.Gr.cellHeight);g>=0&&g<this.Gr.cols&&d>=0&&d<this.Gr.rows?(this.Ir.x=g,this.Ir.y=d):(this.Ir.x=-1,this.Ir.y=-1)}}const Vt=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:lt},Symbol.toStringTag,{value:"Module"}));class ut{constructor(){c(this,"bn",new Map);c(this,"$n",null);c(this,"xn",null);c(this,"Mn");c(this,"Rn");c(this,"qr",!1);c(this,"Fn");c(this,"Sn");c(this,"Tn",{ArrowUp:"UP_ARROW",ArrowDown:"DOWN_ARROW",ArrowLeft:"LEFT_ARROW",ArrowRight:"RIGHT_ARROW",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",Enter:"ENTER",Return:"RETURN",Tab:"TAB",Escape:"ESCAPE",Backspace:"BACKSPACE",Delete:"DELETE",Insert:"INSERT",Home:"HOME",End:"END",PageUp:"PAGE_UP",PageDown:"PAGE_DOWN",Shift:"SHIFT",Control:"CONTROL",Alt:"ALT",Meta:"META"," ":"SPACE"})}an(){this.qr||(this.Mn=t=>{this.An(t)},this.Rn=t=>{this.zn(t)},window.addEventListener("keydown",this.Mn,{passive:!1}),window.addEventListener("keyup",this.Rn,{passive:!1}),this.qr=!0)}pn(){this.qr&&(window.removeEventListener("keydown",this.Mn),window.removeEventListener("keyup",this.Rn),this.qr=!1,this.bn.clear(),this.$n=null,this.xn=null)}vn(t){this.Fn=t}gn(t){this.Sn=t}kn(t){const i=this.En(t),r=this.bn.get(t)||this.bn.get(i);return(r==null?void 0:r.isPressed)||!1}Pn(){return this.$n}Ln(){return this.xn}Dn(){const t=[];for(const[i,r]of this.bn)r.isPressed&&t.push(i);return t}Bn(){return{ctrl:this.kn("Control"),shift:this.kn("Shift"),alt:this.kn("Alt"),meta:this.kn("Meta")}}Gn(){this.bn.clear(),this.$n=null,this.xn=null}An(t){const i=t.key,r=Date.now();this.bn.has(i)||this.bn.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.bn.get(i);if(!n.isPressed&&(n.isPressed=!0,n.lastPressTime=r,this.$n=i,this.Fn)){const o={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.Fn(o)}}zn(t){const i=t.key,r=Date.now();this.bn.has(i)||this.bn.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.bn.get(i);if(n.isPressed=!1,n.lastReleaseTime=r,this.xn=i,this.Sn){const o={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.Sn(o)}}En(t){return this.Tn[t]||t.toLowerCase()}}const $t=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:ut},Symbol.toStringTag,{value:"Module"}));class ft{constructor(t,i){c(this,"er");c(this,"In");c(this,"Gr");c(this,"On",new Map);c(this,"Wn",new Map);c(this,"Hn",new Map);c(this,"Kn",null);c(this,"Xn");c(this,"Nn");c(this,"jn");c(this,"Yn");c(this,"Vn");c(this,"qn");c(this,"qr",!1);c(this,"Zn");c(this,"Jn");c(this,"Qn");c(this,"so");c(this,"eo");c(this,"io");c(this,"ro");c(this,"no");c(this,"oo");c(this,"ho");c(this,"ao",320);c(this,"co",350);c(this,"lo",10);c(this,"uo",550);c(this,"fo",14);c(this,"do",48);c(this,"_o",650);c(this,"po",.02);c(this,"mo",2);c(this,"vo",600);c(this,"yo",0);c(this,"Co",null);this.er=t,this.In=i;const r=this.er.canvas;this.Xn=r.style.touchAction,this.Nn=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}Ni(t){this.Gr=t,this.wo()}an(){if(this.qr)return;const t=this.er.canvas;this.jn=i=>{this.bo(i)},this.Yn=i=>{this.$o(i)},this.Vn=i=>{this.xo(i)},this.qn=i=>{this.Mo(i)},t.addEventListener("touchstart",this.jn,{passive:!1}),t.addEventListener("touchmove",this.Yn,{passive:!1}),t.addEventListener("touchend",this.Vn,{passive:!1}),t.addEventListener("touchcancel",this.qn,{passive:!1}),this.qr=!0}pn(){if(!this.qr)return;const t=this.er.canvas;t.removeEventListener("touchstart",this.jn),t.removeEventListener("touchmove",this.Yn),t.removeEventListener("touchend",this.Vn),t.removeEventListener("touchcancel",this.qn),this.qr=!1,this.Kn=null,this.On.clear(),this.Wn.clear(),this.Hn.forEach(i=>{i.longPressTimer!==null&&window.clearTimeout(i.longPressTimer)}),this.Hn.clear(),this.Co=null,this.yo=0,t.style.touchAction=this.Xn,t.style.userSelect=this.Nn}wo(){if(!this.Gr||this.On.size===0)return;const t=new Map;for(const i of this.On.values()){const r=this.Ro(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.On=t}Fo(){return Array.from(this.On.values()).map(t=>({...t}))}So(t){this.Zn=t}yn(t){this.Jn=t}To(t){this.Qn=t}Ao(t){this.so=t}zo(t){this.eo=t}ko(t){this.io=t}Eo(t){this.ro=t}Po(t){this.no=t}Lo(t){this.oo=t}Do(t){this.ho=t}bo(t){var n;if(!this.Gr)return;t.preventDefault(),(n=this.In)==null||n.en(this.vo);const i=performance.now(),r=this.Bo(t.changedTouches);for(const o of r){const h=this.On.get(o.id);h&&this.Wn.set(o.id,this.Go(h)),this.On.set(o.id,o);const a={id:o.id,startPosition:o,lastPosition:o,startTime:i,lastTime:i,longPressTimer:null,longPressFired:!1};this.ro&&(a.longPressTimer=window.setTimeout(()=>{const u=this.On.get(o.id);u&&(a.longPressFired=!0,this.ro({touch:this.Go(u),duration:performance.now()-a.startTime,originalEvent:t}))},this.uo)),this.Hn.set(o.id,a),this.Zn&&this.Zn(this.Io(o,t,void 0,i))}this.On.size===2&&this.Oo()}$o(t){var n;if(!this.Gr)return;t.preventDefault(),(n=this.In)==null||n.en(this.vo);const i=performance.now(),r=this.Bo(t.changedTouches);for(const o of r){const h=this.On.get(o.id),a=h?this.Go(h):void 0;a&&this.Wn.set(o.id,a),this.On.set(o.id,o);const u=this.Hn.get(o.id);u&&(u.lastPosition=o,u.lastTime=i,a)&&this.Wo(a,o,!0)>this.fo&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.Jn&&this.Jn(this.Io(o,t,a,i))}this.On.size===2?this.Ho(t):this.Kn=null}xo(t){if(!this.Gr)return;t.preventDefault();const i=performance.now(),r=this.Bo(t.changedTouches);for(const n of r){const o=this.On.get(n.id),h=o?this.Go(o):void 0,a=this.Hn.get(n.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.Qn&&this.Qn(this.Io(n,t,h,i)),a&&this.Ko(a,t),this.Hn.delete(n.id),this.Wn.delete(n.id),this.On.delete(n.id)}this.On.size<2&&(this.Kn=null)}Mo(t){if(!this.Gr)return;t.preventDefault();const i=performance.now(),r=this.Bo(t.changedTouches);for(const n of r){const o=this.On.get(n.id),h=o?this.Go(o):void 0,a=this.Hn.get(n.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.so&&this.so(this.Io(n,t,h,i)),this.Hn.delete(n.id),this.Wn.delete(n.id),this.On.delete(n.id)}this.On.size<2&&(this.Kn=null)}Bo(t){const i=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&i.push(this.Xo(n))}return i}Xo(t){return this.Ro(t.clientX,t.clientY,t.identifier,{id:t.identifier,x:-1,y:-1,clientX:t.clientX,clientY:t.clientY,pressure:t.force,radiusX:t.radiusX,radiusY:t.radiusY,rotationAngle:t.rotationAngle})}Ro(t,i,r,n){const o=this.er.canvas,h=o.getBoundingClientRect(),a=t-h.left,u=i-h.top,f=o.width/h.width,g=u*(o.height/h.height),d=a*f-this.Gr.offsetX,v=g-this.Gr.offsetY,x=Math.floor(d/this.Gr.cellWidth),p=Math.floor(v/this.Gr.cellHeight),m=x>=0&&x<this.Gr.cols&&p>=0&&p<this.Gr.rows;return{id:r,x:m?x:-1,y:m?p:-1,clientX:t,clientY:i,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Io(t,i,r,n){const o=this.Hn.get(t.id),h=Array.from(this.Wn.values()).map(f=>this.Go(f)),a=Array.from(this.On.values()).map(f=>this.Go(f)),u=this.Bo(i.changedTouches);return{touch:this.Go(t),previousTouch:r?this.Go(r):void 0,touches:a,previousTouches:h,changedTouches:u,deltaTime:o?n-o.lastTime:0,originalEvent:i}}Oo(){if(this.On.size!==2)return void(this.Kn=null);const t=Array.from(this.On.values()),[i,r]=t,n=this.Wo(i,r,!1),o=this.No(i,r);this.Kn={ids:[i.id,r.id],initialDistance:Math.max(n,1e-4),initialAngle:o,lastScale:1,lastRotation:0}}Ho(t){if(this.Kn||this.Oo(),!this.Kn)return;const[i,r]=this.Kn.ids,n=this.On.get(i),o=this.On.get(r);if(!n||!o)return;const h=this.Wo(n,o,!1)/this.Kn.initialDistance,a=h-this.Kn.lastScale;this.oo&&Math.abs(a)>this.po&&(this.oo({touches:[this.Go(n),this.Go(o)],scale:h,deltaScale:a,center:this.jo(n,o),originalEvent:t}),this.Kn.lastScale=h);let u=this.No(n,o)-this.Kn.initialAngle;u=(u+180)%360-180;const f=u-this.Kn.lastRotation;this.ho&&Math.abs(f)>this.mo&&(this.ho({touches:[this.Go(n),this.Go(o)],rotation:u,deltaRotation:f,center:this.jo(n,o),originalEvent:t}),this.Kn.lastRotation=u)}jo(t,i){const r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,o=this.Ro(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:o.x,y:o.y}}Ko(t,i){const r=performance.now(),n=r-t.startTime,o=this.Wo(t.startPosition,t.lastPosition,!0);if(!t.longPressFired&&n<=this.ao&&o<=this.lo)this.Yo(t.lastPosition,r)&&this.io?this.io({touch:this.Go(t.lastPosition),taps:2,originalEvent:i}):this.eo&&this.eo({touch:this.Go(t.lastPosition),taps:1,originalEvent:i});else if(!t.longPressFired&&n<=this._o&&o>=this.do){const h={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},a=Math.max(Math.hypot(h.x,h.y),1e-4),u={x:h.x/a,y:h.y/a},f={x:h.x/n,y:h.y/n};this.no&&this.no({touch:this.Go(t.lastPosition),direction:u,distance:a,velocity:f,originalEvent:i})}this.yo=r,this.Co=this.Go(t.lastPosition)}Yo(t,i){return!!this.Co&&!(i-this.yo>this.co)&&this.Wo(t,this.Co,!0)<=this.lo}Go(t){return{...t}}Wo(t,i,r){return r?Math.hypot(t.clientX-i.clientX,t.clientY-i.clientY):Math.hypot(t.x-i.x,t.y-i.y)}No(t,i){return 180*Math.atan2(i.clientY-t.clientY,i.clientX-t.clientX)/Math.PI}}const Kt=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:ft},Symbol.toStringTag,{value:"Module"})),qt=l=>class extends l{rotate(t=0,i=0,r=0){this.xt.state.st(t),this.xt.state.et(i),this.xt.state.it(r)}rotateX(t){this.xt.state.st(t)}rotateY(t){this.xt.state.et(t)}rotateZ(t){this.xt.state.it(t)}push(){this.xt.state.O()}pop(){this.xt.state.Z()}rect(t,i,r=1,n=1){this.xt.He(t,i,r,n)}point(t,i){this.xt.He(t,i,1,1)}line(t,i,r,n){this.xt.Ke(t,i,r,n)}lineWeight(t){this.xt.state.tt(t)}background(t,i=t,r=t,n=255){this.xt.qe(t,i,r,n)}char(t){this.xt.state.rt(this.ki.Ai(t))}charColor(t,i,r,n=255){this.xt.state.nt(t,i,r,n)}cellColor(t,i,r,n=255){this.xt.state.ot(t,i,r,n)}flipX(t){this.xt.state.ht(t)}flipY(t){this.xt.state.ct(t)}charRotation(t){this.xt.state.ut(t)}invert(t){this.xt.state.lt(t)}clear(){this.xt.qe(0,0,0,0)}ellipse(t,i,r,n){this.xt.Xe(t,i,r/2,n/2)}triangle(t,i,r,n,o,h){this.xt.Ne(t,i,r,n,o,h)}bezierCurve(t,i,r,n,o,h,a,u){this.xt.je(t,i,r,n,o,h,a,u)}arc(t,i,r,n,o,h){this.xt.Ve(t,i,r,n,o,h)}shader(t){this.xt.De(t)}setUniform(t,i){this.xt.Nt(t,i)}setUniforms(t){this.xt.Be(t)}createFilterShader(t){return this.xt.hs(t)}createFramebuffer(t){return this.xt.Ye(t.width,t.height,5,{filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte"})}image(t,i,r,n,o){if(t.textures){const h=t;this.xt.Ge(h,i,r,n??h.width,o??h.height)}else{const h=t;this.xt.Ie(h,i,r,n??Math.floor(this.Gr.cols/2),o??Math.floor(this.Gr.rows/2))}}async loadImage(t){if(typeof t!="string")return z.Fr(this.xt,t,n=>this.ki.zi(n));const i=t,r=await new Promise((n,o)=>{const h=new Image;h.crossOrigin="anonymous",h.onload=()=>n(h),h.onerror=a=>o(a),h.src=i});return z.Fr(this.xt,r,n=>this.ki.zi(n))}},jt=l=>class extends l{async loadFont(t){return this.ki.qi(t).then(()=>{const i=this.ki.maxGlyphDimensions;this.Gr.hr(i.width,i.height),this.Vo.resize(this.Gr.cols,this.Gr.rows),this.xt.Ze(),this.In.hn()})}fontSize(t){if(!W.v(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.ki.fontSize===t)return;this.ki.Vi(t);const i=this.ki.maxGlyphDimensions;this.Gr.hr(i.width,i.height),this.Vo.resize(this.Gr.cols,this.Gr.rows),this.xt.Ze(),this.In.hn()}glyphColor(t){return this.ki.Ai(t)}glyphColors(t){return this.ki.zi(t)}},Jt=l=>class extends l{get frameCount(){return this.qo.frameCount}set frameCount(t){this.qo.frameCount=t}frameRate(t){return t===void 0?this.qo.currentFrameRate:this.qo.frameRate(t,()=>this.Zo())}noLoop(){this.qo.pause()}loop(){this.qo.resume(()=>this.Zo())}redraw(t=1){if(W.v(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.Zo()}isLooping(){return this.qo.isLooping}},Zt=l=>class extends l{constructor(...t){super(...t)}mouseClicked(t){this.In.mn(t)}mousePressed(t){this.In.vn(t)}mouseReleased(t){this.In.gn(t)}mouseMoved(t){this.In.yn(t)}mouseScrolled(t){this.In.Cn(t)}get mouse(){return this.In.wn()}cursor(t){this.In.nn(t)}},Qt=l=>class extends l{constructor(...t){super(...t)}touchStarted(t){this.Jo.So(t)}touchMoved(t){this.Jo.yn(t)}touchEnded(t){this.Jo.To(t)}touchCancelled(t){this.Jo.Ao(t)}tap(t){this.Jo.zo(t)}doubleTap(t){this.Jo.ko(t)}longPress(t){this.Jo.Eo(t)}swipe(t){this.Jo.Po(t)}pinch(t){this.Jo.Lo(t)}rotateGesture(t){this.Jo.Do(t)}get touches(){return this.Jo.Fo()}},te=l=>class extends l{constructor(...t){super(...t)}keyPressed(t){this.Qo.vn(t)}keyReleased(t){this.Qo.gn(t)}isKeyPressed(t){return this.Qo.kn(t)}get lastKeyPressed(){return this.Qo.Pn()}get lastKeyReleased(){return this.Qo.Ln()}get pressedKeys(){return this.Qo.Dn()}get modifierState(){return this.Qo.Bn()}};class ee{constructor(t){c(this,"th");c(this,"sh",new Map);c(this,"eh",[]);c(this,"ih",new Map);c(this,"rh",new Map);this.th=t}async nh(t){for(const i of t){if(this.sh.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.oh(i.name);try{await i.install(this.th,r)}catch(n){throw this.hh(i.name),n}this.sh.set(i.name,i),this.eh.push(i.name)}}async ah(t){const i=this.sh.get(t);if(!i)return;const r=this.oh(t);if(i.uninstall)try{await i.uninstall(this.th,r)}catch(n){console.error(`[textmode.js] Error while uninstalling plugin "${t}":`,n)}this.sh.delete(t),this.eh.splice(this.eh.indexOf(t),1),this.hh(t)}runPreDrawHooks(){this.uh(this.ih,"preDraw")}runPostDrawHooks(){this.uh(this.rh,"postDraw")}async fh(){const t=[...this.sh.keys()];for(const i of t)await this.ah(i)}oh(t){return{...this.th.dh(),registerPreDrawHook:i=>this._h(this.ih,t,i),registerPostDrawHook:i=>this._h(this.rh,t,i)}}_h(t,i,r){const n=t.get(i)??new Set;return n.add(r),t.set(i,n),()=>{const o=t.get(i);o&&(o.delete(r),o.size===0&&t.delete(i))}}hh(t){this.ih.delete(t),this.rh.delete(t)}uh(t,i){for(const r of this.eh){const n=t.get(r);if(n)for(const o of n)try{o()}catch(h){console.error(`[textmode.js] Plugin "${r}" ${i} hook failed:`,h)}}}}class ie{constructor(){c(this,"xt");c(this,"ki");c(this,"er");c(this,"Gr");c(this,"qo");c(this,"In");c(this,"Jo");c(this,"Qo");c(this,"ph");c(this,"Vo");c(this,"mh");c(this,"gh");c(this,"yh")}Zo(){}}class dt extends function(i,...r){return r.reduce((n,o)=>o(n),i)}(ie,qt,jt,Jt,Zt,Qt,te){constructor(i={}){super();c(this,"Ch");c(this,"wh",!1);c(this,"bh",()=>{});c(this,"$h",()=>{});c(this,"xh",()=>{});c(this,"Mh");c(this,"lr");c(this,"cr",!1);c(this,"Rh");this.Ch=new ee(this),this.cr=i.overlay??!1,this.er=new ct(i),this.xt=new It(this.er.gr()),this.ki=new ht(this.xt,i.fontSize??16),this.qo=new Ht(i.frameRate??60),this.In=new lt(this.er),this.Jo=new ft(this.er,this.In),this.Qo=new ut,this.ph=this.xt.At(),this.mh=this.xt.rs(),this.Fh(i)}async Fh(i){await this.ki.Ni(i.fontSource);const r=this.ki.maxGlyphDimensions;this.Gr=new at(this.er.canvas,r.width,r.height),this.In.Ni(this.Gr),this.Jo.Ni(this.Gr),this.Vo=this.xt.Ye(this.Gr.cols,this.Gr.rows,5),this.gh=this.xt.Ye(this.Gr.width,this.Gr.height,1),this.cr&&(this.Rh=z.Fr(this.xt,this.er.targetCanvas,n=>this.ki.zi(n))),this.yh=this.xt.cs(rt,"precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"),this.Sh(),await this.Ch.nh(i.plugins??[]),this.bh(),this.qo.start(()=>this.Zo())}dh(){return{renderer:this.xt,font:this.ki,grid:this.Gr,canvas:this.er,drawFramebuffer:this.Vo,asciiFramebuffer:this.gh,flushDrawCommands:()=>{this.xt.zt(this.ph)}}}Sh(){this.Mh=()=>{this.cr&&this.resizeCanvas(this.er.targetCanvas.width,this.er.targetCanvas.height),this.xh()},window.addEventListener("resize",this.Mh),this.In.an(),this.Jo.an(),this.Qo.an(),window.addEventListener("blur",()=>{this.Qo.Gn()}),window.ResizeObserver&&this.cr&&(this.lr=new ResizeObserver(()=>{this.resizeCanvas(this.er.targetCanvas.width,this.er.targetCanvas.height)}),this.lr.observe(this.er.targetCanvas))}Zo(){if(this.qo.measureFrameRate(),this.qo.incrementFrame(),this.wh)return;if(this.cr){const r=this.xt.context;r.bindTexture(r.TEXTURE_2D,this.Rh.texture),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.er.targetCanvas),r.bindTexture(r.TEXTURE_2D,null)}this.Ch.runPreDrawHooks(),this.Vo.begin(),this.xt.Le(this.ph),this.$h(),this.xt.zt(this.ph),this.Vo.end(),this.gh.begin(),this.xt.Le(this.mh),this.mh.Xt({U0:this.ki.fontFramebuffer,U1:[this.ki.textureColumns,this.ki.textureRows],U2:this.Vo.textures[0],U3:this.Vo.textures[1],U4:this.Vo.textures[2],U5:this.Vo.textures[4],U6:this.Vo.textures[3],U7:[this.Gr.cols,this.Gr.rows],U8:[this.gh.width,this.gh.height],U9:this.gh.width/this.gh.height}),this.xt.We(0,0,this.er.width,this.er.height),this.gh.end();const i=this.xt.state.canvasBackgroundColor;this.xt.Ys(i[0],i[1],i[2],i[3]),this.xt.Le(this.yh),this.yh.Xt({Ua:this.gh.textures[0],Ub:[this.gh.width,this.gh.height],Uc:[this.Gr.offsetX,this.Gr.offsetY],Ud:[this.Gr.width,this.Gr.height]}),this.xt.We(this.Gr.offsetX,this.Gr.offsetY,this.Gr.width,this.Gr.height),this.Ch.runPostDrawHooks()}setup(i){this.bh=i}draw(i){this.$h=i}windowResized(i){this.xh=i}resizeCanvas(i,r){this.er.vr(i,r),this.Gr.nr(),this.Vo.resize(this.Gr.cols,this.Gr.rows),this.gh.resize(this.Gr.width,this.Gr.height),this.xt.Ze(),this.In.hn(),this.Jo.wo(),this.Zo()}destroy(){this.wh||(this.qo.stop(),this.Ch.fh().catch(i=>{console.error("[textmode.js] Error while disposing plugins:",i)}),window.removeEventListener("resize",this.Mh),this.In.pn(),this.Jo.pn(),this.Qo.pn(),this.ki.Pt(),this.xt.Pt(),this.gh.Pt(),this.yh.Pt(),this.Rh&&this.Rh.Pt(),this.wh=!0)}get grid(){return this.Gr}get font(){return this.ki}get width(){return this.er.width}get height(){return this.er.height}get canvas(){return this.er.canvas}get drawFramebuffer(){return this.Vo}get isDisposed(){return this.wh}get overlay(){return this.Rh}}class J{constructor(){}static create(t={}){return new dt(t)}static setErrorLevel(t){W.C(t)}static get version(){return"0.4.0"}}const se=Object.freeze(Object.defineProperty({__proto__:null,keyboard:$t,mouse:Vt,touch:Kt},Symbol.toStringTag,{value:"Module"})),re=J.create,ne=J.setErrorLevel,oe=J.version;C.TextmodeCanvas=ct,C.TextmodeErrorLevel=G,C.TextmodeFont=ht,C.TextmodeFramebuffer=$,C.TextmodeGrid=at,C.TextmodeImage=z,C.Textmodifier=dt,C.create=re,C.input=se,C.setErrorLevel=ne,C.textmode=J,C.version=oe,Object.defineProperty(C,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={});
|
|
7
|
+
`}static i(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(i=>F.i(i)).join(", ")}]`:`[${t.slice(0,3).map(i=>F.i(i)).join(", ")}, ... +${t.length-3} more]`;if(typeof t=="object"){const i=Object.keys(t);return i.length===0?"{}":i.length<=3?`{ ${i.map(r=>`${r}: ${F.i(t[r])}`).join(", ")} }`:`{ ${i.slice(0,2).map(r=>`${r}: ${F.i(t[r])}`).join(", ")}, ... +${i.length-2} more }`}return String(t)}}var S=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(S||{});const G=class G{constructor(){l(this,"h",{l:3})}static u(){return G.o||(G.o=new G),G.o}p(t,i){const r="%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.",n="color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";switch(this.h.l){case 0:return!1;case 1:return console.group(r,n),console.warn(F.t(t,i)),console.groupEnd(),!1;case 2:return console.group(r,n),console.error(F.t(t,i)),console.groupEnd(),!1;default:throw new F(t,i)}}_(t,i,r){return!!t||(this.p(i,r),!1)}v(t){this.h.l=t}};l(G,"o",null);let ft=G;const q=ft.u();class ${constructor(t,i,r){l(this,"m");l(this,"C");l(this,"$",new Map);l(this,"M",new Map);l(this,"A",0);this.m=t,this.C=this.F(i,r),this.U()}U(){const t=this.m.getProgramParameter(this.C,this.m.ACTIVE_UNIFORMS);for(let i=0;i<t;i++){const r=this.m.getActiveUniform(this.C,i);if(r){const n=r.name.replace(/\[0\]$/,""),h=this.m.getUniformLocation(this.C,n);h&&(this.$.set(n,h),this.M.set(n,{type:r.type,size:r.size}))}}}F(t,i){const r=this.T(this.m.VERTEX_SHADER,t),n=this.T(this.m.FRAGMENT_SHADER,i),h=this.m.createProgram();if(this.m.attachShader(h,r),this.m.attachShader(h,n),this.m.linkProgram(h),!this.m.getProgramParameter(h,this.m.LINK_STATUS)){const a=this.m.getProgramInfoLog(h);throw new Error(`Shader program link error: ${a}`)}return this.m.deleteShader(r),this.m.deleteShader(n),h}T(t,i){const r=this.m.createShader(t);if(this.m.shaderSource(r,i),this.m.compileShader(r),!this.m.getShaderParameter(r,this.m.COMPILE_STATUS)){const n=this.m.getShaderInfoLog(r);throw this.m.deleteShader(r),new Error(`Shader compilation error: ${n}`)}return r}S(){this.m.useProgram(this.C),this.R()}R(){this.A=0}k(t){for(const i in t)this.P(i,t[i])}P(t,i){var u,d;const r=this.$.get(t);if(!r)return;const n=this.M.get(t);if(!n)return;const{type:h,size:a}=n,c=this.m;if(i instanceof WebGLTexture){const f=this.A++;return c.uniform1i(r,f),c.activeTexture(c.TEXTURE0+f),void c.bindTexture(c.TEXTURE_2D,i)}if(i instanceof Z){const f=this.A++;return c.uniform1i(r,f),c.activeTexture(c.TEXTURE0+f),void c.bindTexture(c.TEXTURE_2D,i.L[0])}if(typeof i!="number")if(typeof i!="boolean")if(Array.isArray(i[0])){const f=i.flat(),p={[c.FLOAT_VEC2]:()=>c.uniform2fv(r,f),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,f),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,f)};(u=p[h])==null||u.call(p)}else{const f=i,p={[c.FLOAT]:()=>a>1?c.uniform1fv(r,f):c.uniform1f(r,f[0]),[c.FLOAT_VEC2]:()=>c.uniform2fv(r,f),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,f),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,f),[c.INT]:()=>a>1?c.uniform1iv(r,f):c.uniform1i(r,f[0]),[c.INT_VEC2]:()=>c.uniform2iv(r,f),[c.INT_VEC3]:()=>c.uniform3iv(r,f),[c.INT_VEC4]:()=>c.uniform4iv(r,f),[c.BOOL]:()=>c.uniform1iv(r,f),[c.FLOAT_MAT2]:()=>c.uniformMatrix2fv(r,!1,f),[c.FLOAT_MAT3]:()=>c.uniformMatrix3fv(r,!1,f),[c.FLOAT_MAT4]:()=>c.uniformMatrix4fv(r,!1,f)};(d=p[h])==null||d.call(p)}else c.uniform1i(r,i?1:0);else h===c.INT||h===c.BOOL?c.uniform1i(r,i):c.uniform1f(r,i)}get I(){return this.C}D(){this.m.deleteProgram(this.C)}}function xt(o,t,i,r){return 180*Math.atan2(r-t,i-o)/Math.PI}function V(o,t,i,r){return Math.hypot(i-o,r-t)}function Tt(o){return(o%360+360)%360/360}function Rt(o,t,i){o.bindTexture(o.TEXTURE_2D,t),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,i),o.bindTexture(o.TEXTURE_2D,null)}function et(o,t,i,r,n){o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n)}function dt(o,t,i,r,n,h=0,a=WebGL2RenderingContext.FLOAT,c=!1){o.enableVertexAttribArray(t),o.vertexAttribPointer(t,i,a,c,r,n),o.vertexAttribDivisor(t,h)}function Ft(o,t,i,r,n){o.bindBuffer(t,i),o.bufferData(t,r,n),o.bindBuffer(t,null)}const st=`#version 300 es
|
|
8
|
+
in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in vec4 A7;in vec3 A8;in vec3 A9;in vec4 Aa;in vec4 Ab;in vec3 Ac;uniform vec2 Ut;uniform float Uu;uniform float Uv;out vec2 v_uv;out vec3 v_glyphIndex;out vec4 v_glyphColor;out vec4 v_cellColor;out vec4 v_glyphFlags;out vec3 v_worldPosition;out vec3 v_normal;out float v_geometryType;const float A=6.28318530718f;const int B=2;const int C=3;const int D=4;vec2 E(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float M=L*K;float N=F*F;float O=N*F;return M*G+3.0f*L*F*H+3.0f*K*N*I+O*J;}vec2 P(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float N=F*F;return-3.0f*L*G+3.0f*(L-2.0f*K*F)*H+3.0f*(2.0f*K*F-N)*I+3.0f*N*J;}vec3 Q(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x,R.y*T-R.z*U,R.y*U+R.z*T);}vec3 V(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T+R.z*U,R.y,-R.x*U+R.z*T);}vec3 W(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T-R.y*U,R.x*U+R.y*T,R.z);}vec3 X(vec3 R,vec3 Y){vec3 Z=R;if(Y.z!=0.0f){Z=W(Z,Y.z);}if(Y.y!=0.0f){Z=V(Z,Y.y);}if(Y.x!=0.0f){Z=Q(Z,Y.x);}return Z;}void main(){v_uv=A1;v_glyphIndex=A4;v_glyphColor=A5;v_cellColor=A6;v_glyphFlags=A7;vec4 a=Aa;vec4 b=Ab;vec2 c=A3;vec2 d=A2;float e=Ac.x;float f=Ac.y;int g=int(Ac.z);vec2 h=d;vec2 i=h+c*0.5f;float j=f+e*0.5f;vec3 k=vec3(i,j);vec3 l;if(g==D){float F=clamp(A0.x,0.0f,1.0f);vec2 G=b.xy;vec2 H=a.xy;vec2 I=a.zw;vec2 J=b.zw;vec2 m=E(F,G,H,I,J);vec2 n=P(F,G,H,I,J);float o=length(n);vec2 p=o>0.0f?n/o:vec2(1.0f,0.0f);vec2 q=vec2(-p.y,p.x);vec2 r=m;vec2 s=r+q*A0.y*c.y;l=vec3(s,f);}else if(g==C){float t=mod(a.x,A);if(t<0.0f){t+=A;}float u=mod(a.y,A);if(u<0.0f){u+=A;}float v=t-u;if(v<=0.0f){v+=A;}float S=t-A0.x*v;vec2 w=vec2(cos(S),sin(S))*A0.y;vec2 s=w*c+h;l=vec3(s,f);}else if(g==B){vec2 s=A0.xy*c+h;l=vec3(s,f);}vec3 x=X(l,A9);vec3 y=x+A8;vec3 z=vec3(0.0f,0.0f,1.0f);v_worldPosition=y;v_normal=z;v_geometryType=float(g);vec2 AA=(y.xy/Ut)*2.0f;AA.y=-AA.y;float AB=y.z/Ut.y;float AC=clamp(-AB*Uu,-0.99f,0.99f);if(Uv>0.5f){gl_Position=vec4(AA,AC,1.0f);}else{float AD=0.5f;float AE=1.0f/(1.0f-AB*AD);AA*=AE;gl_Position=vec4(AA,AC,1.0f);}}`,k=class k{constructor(t,i,r=i,n=1,h={},a){l(this,"O");l(this,"B");l(this,"h");l(this,"m");l(this,"G");l(this,"W",[]);l(this,"H",null);l(this,"K");l(this,"Y");l(this,"j",null);l(this,"N",new Map);var c,u,d;this.O=i,this.B=r,this.m=t,this.K=(c=n,u=1,d=8,Math.min(Math.max(c,u),d)),this.Y=a,this.h={filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte",Z:!0,...h},k.X||(k.X=new $(t,st,`#version 300 es
|
|
9
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Ud;uniform sampler2D Ue;uniform sampler2D Uf;uniform vec2 Ug;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*Ug;vec2 C=(floor(B)+0.5f)/Ug;vec4 D=texture(Ud,C);vec4 E=texture(Ue,C);if(E.a==0.){discard;}vec4 F=texture(Uf,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const f=t.getParameter(t.MAX_DRAW_BUFFERS),p=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,f,p),this.G=t.createFramebuffer(),this.V(),this.q(),this.h.Z&&this.J()}V(){const t=this.m,i=this.h.filter==="linear"?t.LINEAR:t.NEAREST,r=this.h.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,n=this.h.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,h=n===t.FLOAT?t.RGBA32F:t.RGBA8,a=t.RGBA;for(let c=0;c<this.K;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),et(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,h,this.O,this.B,0,a,n,null),this.W.push(u)}t.bindTexture(t.TEXTURE_2D,null)}q(){const t=this.m;if(t.bindFramebuffer(t.FRAMEBUFFER,this.G),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.W[0],0);else{const i=[];for(let r=0;r<this.K;r++){const n=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,n,t.TEXTURE_2D,this.W[r],0),i.push(n)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}J(){const t=this.m;this.H=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.H),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.O,this.B),t.bindFramebuffer(t.FRAMEBUFFER,this.G),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.H),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}tt(t){Rt(this.m,this.W[0],t)}resize(t,i){this.O=t,this.B=i,this.N.clear();const r=this.m,n=this.h.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,h=n===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.W)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,h,this.O,this.B,0,a,n,null);r.bindTexture(r.TEXTURE_2D,null),this.H&&(r.bindRenderbuffer(r.RENDERBUFFER,this.H),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.O,this.B),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.N.get(t);if(i)return i;const r=this.m,n=this.O,h=this.B,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,d=new Uint8Array(a.length);for(let f=0;f<h;f++){const p=(h-1-f)*u,g=f*u;d.set(a.subarray(p,p+u),g)}return this.N.set(t,d),d}st(){const t=this.m;this.N.clear(),this.Y.et(),this.Y.it(this.G,this.O,this.B),this.h.Z&&t.clear(t.DEPTH_BUFFER_BIT),this.Y.state.rt()}end(){this.Y.state.nt(),this.Y.ot();const t=this.Y.ht();this.Y.it(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.j||this.lt(),this.j}lt(){if(!this.Y)return;const t={ut:this.W[0],ft:this.W[1],dt:this.W[2],_t:[this.O,this.B]},i=k.X;this.j=this.Y.vt.gt(i,t,!0)}D(){const t=this.m;t.deleteFramebuffer(this.G);for(const i of this.W)t.deleteTexture(i);this.H&&t.deleteRenderbuffer(this.H)}get width(){return this.O}get height(){return this.B}get L(){return this.W}get yt(){return this.K}};l(k,"X",null);let Z=k;const Lt=new WeakMap;function pt(o,t){Lt.set(o,t)}function Mt(o){return Lt.get(o)}function X(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 rt{constructor(){l(this,"wt",1);l(this,"bt",0);l(this,"Ct",0);l(this,"$t",0);l(this,"Mt",0);l(this,"xt",0);l(this,"At",0);l(this,"Ft",[0,0,0]);l(this,"Ut",[1,1,1,1]);l(this,"Tt",[0,0,0,1]);l(this,"St",!1);l(this,"Et",!1);l(this,"Rt",!1);l(this,"kt",0);l(this,"Pt",[0,0,0,1]);l(this,"Lt",!1);l(this,"It",[]);l(this,"zt",[])}static Dt(){return{Ot:1,Bt:0,Gt:0,Wt:0,Mt:0,xt:0,At:0,kt:0,Ht:!1,Kt:!1,Rt:!1,Lt:!1,Yt:[0,0,0],jt:[1,1,1,1],Nt:[0,0,0,1]}}Xt(t){t.Ot=this.wt,t.Bt=this.bt,t.Gt=this.Ct,t.Wt=this.$t,t.Mt=this.Mt,t.xt=this.xt,t.At=this.At,t.Ht=this.St,t.Kt=this.Et,t.Rt=this.Rt,t.kt=this.kt,t.Lt=this.Lt,t.Yt[0]=this.Ft[0],t.Yt[1]=this.Ft[1],t.Yt[2]=this.Ft[2],t.jt[0]=this.Ut[0],t.jt[1]=this.Ut[1],t.jt[2]=this.Ut[2],t.jt[3]=this.Ut[3],t.Nt[0]=this.Tt[0],t.Nt[1]=this.Tt[1],t.Nt[2]=this.Tt[2],t.Nt[3]=this.Tt[3]}Zt(t){this.wt=t.Ot,this.bt=t.Bt,this.Ct=t.Gt,this.$t=t.Wt,this.Mt=t.Mt,this.xt=t.xt,this.At=t.At,this.St=t.Ht,this.Et=t.Kt,this.Rt=t.Rt,this.kt=t.kt,this.Lt=t.Lt,this.Ft[0]=t.Yt[0],this.Ft[1]=t.Yt[1],this.Ft[2]=t.Yt[2],this.Ut[0]=t.jt[0],this.Ut[1]=t.jt[1],this.Ut[2]=t.jt[2],this.Ut[3]=t.jt[3],this.Tt[0]=t.Nt[0],this.Tt[1]=t.Nt[1],this.Tt[2]=t.Nt[2],this.Tt[3]=t.Nt[3]}rt(){let t=this.zt.pop();t||(t=rt.Dt()),this.Xt(t),this.It.push(t)}nt(){const t=this.It.pop();t?(this.Zt(t),this.zt.push(t)):console.warn("pop() called without matching push()")}Vt(t){this.Xt(t)}qt(t){this.wt=Math.abs(t)}Jt(){this.bt=0,this.Ct=0,this.$t=0,this.Mt=0,this.xt=0,this.At=0,this.Lt=!1}Qt(t){t!==0&&(this.Mt+=t*Math.PI/180)}ts(t){t!==0&&(this.xt+=t*Math.PI/180)}ss(t){t!==0&&(this.At+=t*Math.PI/180)}es(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.bt+=t,this.Ct+=i,this.$t+=r)}rs(t){this.es(t,0,0)}ns(t){this.es(0,t,0)}hs(t){this.es(0,0,t)}cs(t){this.Ft[0]=t[0],this.Ft[1]=t[1],this.Ft[2]=t[2]}ls(t,i,r,n=255){X(this.Ut,t,i,r,n)}us(t,i,r,n=255){X(this.Tt,t,i,r,n)}fs(t){this.St=t}ds(t){this.Et=t}ps(t){this.Rt=t}_s(t){this.kt=Tt(t)}gs(t,i,r,n){X(this.Pt,t,i,r,n)}vs(t){this.Lt=t}get ys(){return this.Pt}get ws(){return this.Lt}get bs(){return this.Mt}get Cs(){return this.xt}get $s(){return this.At}}const gt=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,-.5,.5,0,1,-.5,.5,0,1,.5,-.5,1,0,.5,.5,1,1]),j={Ms:16,xs:WebGL2RenderingContext.TRIANGLES,As:{Fs:{size:2,offset:0},Us:{size:2,offset:8}}};class zt{constructor(t){l(this,"m");l(this,"Ts");l(this,"Ss");this.m=t,this.Ts=t.createBuffer(),this.Ss=new Float32Array(gt.length)}Es(t,i,r,n){const h=this.m,a=Mt(this.m),c=a[2],u=a[3],d=t/c*2-1,f=(t+r)/c*2-1,p=1-(i+n)/u*2,g=1-i/u*2,m=gt,v=this.Ss;for(let y=0;y<m.length;y+=4){const w=m[y],b=m[y+1],E=m[y+2],A=m[y+3],x=d+(w+.5)*(f-d),T=p+(b+.5)*(g-p);v[y]=x,v[y+1]=T,v[y+2]=E,v[y+3]=A}h.bindBuffer(h.ARRAY_BUFFER,this.Ts),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)}D(){this.m.deleteBuffer(this.Ts)}}var _=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(_||{});const Kt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class kt{constructor(t){l(this,"m");l(this,"Rs",new Map);this.m=t}ks(t,i,r,n){const h=this.m;let a=this.Rs.get(t);a||(a=new Map,this.Rs.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&&dt(h,u,r.As.Fs.size,r.Ms,r.As.Fs.offset,0,h.FLOAT,!1);const d=h.getAttribLocation(t,"A1");d!==-1&&dt(h,d,r.As.Us.size,r.Ms,r.As.Us.offset,0,h.FLOAT,!1)}h.bindVertexArray(c)}Ps(){this.m.bindVertexArray(null)}D(){for(const[,t]of this.Rs)for(const[,i]of t)i&&this.m.deleteVertexArray(i)}}const I=class I{static zs(t,i,r=0){const n=i||new Float32Array(I.Is);let h=r;n[h++]=t.Fs[0],n[h++]=t.Fs[1],n[h++]=t.Ds[0],n[h++]=t.Ds[1],n[h++]=t.Yt[0],n[h++]=t.Yt[1],n[h++]=t.Yt[2],n[h++]=t.jt[0],n[h++]=t.jt[1],n[h++]=t.jt[2],n[h++]=t.jt[3],n[h++]=t.Nt[0],n[h++]=t.Nt[1],n[h++]=t.Nt[2],n[h++]=t.Nt[3],n[h++]=t.Os[0],n[h++]=t.Os[1],n[h++]=t.Os[2],n[h++]=t.kt;const a=t.Bs;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.Gs;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.Ws,d=t.Hs,f=t.Ks,p=t.Ys,g=t.js,m=!(!d||!f);return m?(n[h++]=(p==null?void 0:p[0])??0,n[h++]=(p==null?void 0:p[1])??0,n[h++]=(g==null?void 0:g[0])??0,n[h++]=(g==null?void 0:g[1])??0,n[h++]=d[0],n[h++]=d[1],n[h++]=f[0],n[h++]=f[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.Ns??0,n[h++]=t.Xs??0,n[h++]=t.Zs??0,n}static Vs(t,i){const r=t.length*I.Is,n=i||new Float32Array(r);for(let h=0;h<t.length;h++){const a=h*I.Is;I.zs(t[h],n,a)}return n}};l(I,"Ls",144),l(I,"Is",36);let O=I;const P=class P{};l(P,"qs",O.Ls),l(P,"Js",{Qs:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:0,divisor:1},ee:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:8,divisor:1},ie:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:16,divisor:1},re:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:28,divisor:1},ne:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:44,divisor:1},oe:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:60,divisor:1},he:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:76,divisor:1},ae:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:88,divisor:1},ce:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:100,divisor:1},le:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:116,divisor:1},ue:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:132,divisor:1}});let J=P;class Wt{constructor(t=1e3,i=1.5){l(this,"fe");l(this,"de");l(this,"pe");l(this,"_e",0);l(this,"ge",0);this.de=t,this.pe=i;const r=t*O.Is;this.fe=new Float32Array(r)}ve(t){if(t<=this.de)return;const i=Math.ceil(t*this.pe),r=this.de;this.de=i;const n=i*O.Is,h=new Float32Array(n),a=r*O.Is;h.set(this.fe.subarray(0,Math.min(a,this._e))),this.fe=h}me(){return{buffer:this.fe,offset:this._e}}ye(t){this._e+=t,this.ge++}reset(){this._e=0,this.ge=0}subarray(t=0,i){return this.fe.subarray(t,i??this._e)}get we(){return this.ge}get be(){return this.de}get Ce(){return this._e}get $e(){return this.ge===0}}class qt{constructor(t){l(this,"fe");this.fe=t}Me(t){this.fe.ve(this.fe.we+1);const{buffer:i,offset:r}=this.fe.me();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.xe,i[r+5]=t.Ae,i[r+6]=t.Fe,i[r+7]=t.r1,i[r+8]=t.Ue,i[r+9]=t.Te,i[r+10]=t.Se,i[r+11]=t.r2,i[r+12]=t.Ee,i[r+13]=t.Re,i[r+14]=t.ke,i[r+15]=t.Pe,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.Le,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.Ie,i[r+22]=t.bs,i[r+23]=t.Cs,i[r+24]=t.$s;const n=t.ze,h=t.De;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.Z,i[r+34]=t.Oe,i[r+35]=t.Be,this.fe.ye(O.Is),this.fe.we-1}get we(){return this.fe.we}}class $t{constructor(t,i=1e3){l(this,"m");l(this,"Ge",null);l(this,"We",0);l(this,"He",new Map);this.m=t,this.Ke(i)}Ke(t){const i=this.m;this.Ge&&i.deleteBuffer(this.Ge),this.Ge=i.createBuffer();const r=t*O.Ls;Ft(i,i.ARRAY_BUFFER,this.Ge,r,i.DYNAMIC_DRAW),this.We=t}Ye(t){this.Ke(t)}get be(){return this.We}upload(t,i){if(i===0)return;const r=this.m;r.bindBuffer(r.ARRAY_BUFFER,this.Ge);const n=i*O.Is;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,n)}je(t){let i=this.He.get(t);if(!i){i=new Map;const r=this.m;for(const n in J.Js){const h=r.getAttribLocation(t,n);h!==-1&&i.set(n,h)}this.He.set(t,i)}return i}Ne(t){const i=this.m,r=t.I,n=this.je(r);for(const[h,a]of n){const c=J.Js[h];c&&dt(i,a,c.size,c.se,c.offset,c.divisor,c.type,c.te)}}Xe(t){const i=this.m,r=this.je(t.I);for(const[n,h]of r)J.Js[n]&&(i.disableVertexAttribArray(h),i.vertexAttribDivisor(h,0))}dispose(){this.Ge&&(this.m.deleteBuffer(this.Ge),this.Ge=null),this.He.clear()}}class Vt{constructor(t,i=1e3,r=1.5){l(this,"m");l(this,"fe");l(this,"Ze");l(this,"Ve");this.m=t,this.fe=new Wt(i,r),this.Ze=new qt(this.fe),this.Ve=new $t(t,i)}qe(t){var n,h,a,c,u,d,f,p,g,m;const i=[0,0,0,0],r=[0,0,0,0];return t.Hs&&t.Ks?(i[0]=((n=t.Ys)==null?void 0:n[0])??0,i[1]=((h=t.Ys)==null?void 0:h[1])??0,i[2]=((a=t.js)==null?void 0:a[0])??0,i[3]=((c=t.js)==null?void 0:c[1])??0,r[0]=t.Hs[0],r[1]=t.Hs[1],r[2]=t.Ks[0],r[3]=t.Ks[1]):t.Ws&&(i[0]=t.Ws[0],i[1]=t.Ws[1]),this.Je({x:t.Fs[0],y:t.Fs[1],width:t.Ds[0],height:t.Ds[1],xe:t.Yt[0],Ae:t.Yt[1],Fe:t.Yt[2],r1:t.jt[0],Ue:t.jt[1],Te:t.jt[2],Se:t.jt[3],r2:t.Nt[0],Ee:t.Nt[1],Re:t.Nt[2],ke:t.Nt[3],Pe:t.Os[0],flipX:t.Os[1],flipY:t.Os[2],Le:t.kt,translationX:((u=t.Bs)==null?void 0:u[0])??0,translationY:((d=t.Bs)==null?void 0:d[1])??0,Ie:((f=t.Bs)==null?void 0:f[2])??0,bs:((p=t.Gs)==null?void 0:p[0])??0,Cs:((g=t.Gs)==null?void 0:g[1])??0,$s:((m=t.Gs)==null?void 0:m[2])??0,ze:i,De:r,Z:t.Ns||0,Oe:t.Xs||0,Be:t.Zs||0})}Je(t){const i=this.Ze.Me(t);return this.fe.be>this.Ve.be&&this.Ve.Ye(this.fe.be),i}get count(){return this.fe.we}get $e(){return this.fe.$e}clear(){this.fe.reset()}Qe(t){const i=this.fe.we;if(i===0)return;const r=this.fe.subarray();this.Ve.upload(r,i),this.Ve.Ne(t)}ti(t){this.Ve.Xe(t)}Es(t,i){const r=this.fe.we;r!==0&&this.m.drawArraysInstanced(t,0,i,r)}D(){this.Ve.dispose()}}class H{constructor(t,i,r,n){l(this,"m");l(this,"si");l(this,"ei");l(this,"ii");l(this,"ri",null);this.m=t,this.si=i,this.ei=r,this.ii=n;const h=this.m.createBuffer();Ft(this.m,this.m.ARRAY_BUFFER,h,this.ii.ni,this.m.STATIC_DRAW),this.ri=h}get type(){return this.ei}get oi(){return this.ii}get hi(){return this.ri}get ai(){return this.si}ci(){this.si.clear()}li(){return!this.si.$e}D(){this.si.D(),this.m.deleteBuffer(this.ri)}ui(t,i,r){return this.si.qe(t)}fi(t,i,r,n,h,a){const c=h.Bt??0,u=h.Gt??0,d=h.Wt??0,f=h.Mt??0,p=h.xt??0,g=h.At??0,m=[0,0,0,0],v=[0,0,0,0];a&&(a.di!==void 0&&a.pi!==void 0&&a._i!==void 0&&a.gi!==void 0?(m[0]=a.mi??0,m[1]=a.yi??0,m[2]=a.wi??0,m[3]=a.bi??0,v[0]=a.di??0,v[1]=a.pi??0,v[2]=a._i??0,v[3]=a.gi??0):a.Ci===void 0&&a.$i===void 0||(m[0]=a.Ci??0,m[1]=a.$i??0));const y={x:t,y:i,width:r,height:n,xe:h.Yt[0],Ae:h.Yt[1],Fe:h.Yt[2],r1:h.jt[0],Ue:h.jt[1],Te:h.jt[2],Se:h.jt[3],r2:h.Nt[0],Ee:h.Nt[1],Re:h.Nt[2],ke:h.Nt[3],Pe:h.Rt?1:0,flipX:h.Ht?1:0,flipY:h.Kt?1:0,Le:h.kt,translationX:c,translationY:u,Ie:d,bs:f,Cs:p,$s:g,ze:m,De:v,Z:(a==null?void 0:a.Z)??0,Oe:(a==null?void 0:a.Oe)??0,Be:Kt[this.ei]??0};return this.si.Je(y)}}const Zt={ni:gt,Mi:6,...j},Jt={ni: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]),Mi:6,...j},Qt={ni: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),d=.5*(c+1),f=Math.cos(h),p=Math.sin(h),g=.5*(f+1),m=.5*(p+1);t.push(0,0,.5,.5,a,c,u,d,f,p,g,m)}return new Float32Array(t)}(32),Mi:96,...j};let ti={ni: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),Mi:96,...j};const ii={ni:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Mi:3,...j},ei={ni: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),Mi:96,...j},si={[_.RECTANGLE]:class extends H{constructor(o,t){super(o,t,_.RECTANGLE,Zt)}qe(o,t){return this.fi(0,0,o.width,o.height,t)}},[_.LINE]:class extends H{constructor(o,t){super(o,t,_.LINE,Jt)}qe(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,n=Math.hypot(i,r),h=t.Ot||1,a=o.x1+i/2-n/2,c=o.y1+r/2;return this.fi(a,c,n,h,t)}},[_.ELLIPSE]:class extends H{constructor(o,t){super(o,t,_.ELLIPSE,Qt)}qe(o,t){return this.fi(0,0,o.width,o.height,t)}},[_.ARC]:class extends H{constructor(o,t){super(o,t,_.ARC,ti)}qe(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.fi(0,0,o.width,o.height,t,{Ci:i,$i:r})}},[_.TRIANGLE]:class extends H{constructor(o,t){super(o,t,_.TRIANGLE,ii)}qe(o,t){const i=Math.min(o.x1,o.x2,o.xi),r=Math.max(o.x1,o.x2,o.xi),n=Math.min(o.y1,o.y2,o.Ai),h=r-i,a=Math.max(o.y1,o.y2,o.Ai)-n;return this.fi(i,n,h,a,t)}},[_.BEZIER_CURVE]:class extends H{constructor(o,t){super(o,t,_.BEZIER_CURVE,ei)}qe(o,t){return this.fi(0,0,1,t.Ot||1,t,{mi:o.mi,yi:o.yi,wi:o.wi,bi:o.bi,di:o.x1,pi:o.y1,_i:o.x2,gi:o.y2})}}};class ri{constructor(t){l(this,"m");l(this,"Fi");l(this,"Ui");this.m=t,this.Ui=new kt(t),this.Fi=new Map;for(const i of Object.values(_)){const r=new Vt(t),n=new si[i](t,r);this.Fi.set(i,n)}}Ti(t){const i=this.Si(t);for(const r of i)this.Ei(r)}Si(t){const i=[];let r=null,n=null,h=null;for(const a of t)n!==a.Ri||h!==a.type?(r&&r.length>0&&i.push({Ri:n,type:h,commands:r}),r=[a],n=a.Ri,h=a.type):r.push(a);return r&&r.length>0&&i.push({Ri:n,type:h,commands:r}),i}Ei(t){const{Ri:i,type:r,commands:n}=t,h=this.Fi.get(r);i.ki.S(),i.ki.k(i.Pi);const a=Mt(this.m),c=n.length>0&&n[0].state.Lt;i.ki.k({Li:a[2]/a[3],Ii:[a[2],a[3]],zi:1,Di:c?1:0}),h.ci();for(const u of n)h.qe(u.Oi,u.state);if(h.li()){const u=h.oi,d=h.hi;try{this.Ui.ks(i.ki.I,String(r),u,d),h.ai.Qe(i.ki),h.ai.Es(u.xs,u.Mi)}finally{h.ai.ti(i.ki),this.Ui.Ps(),h.ci()}}}D(){for(const t of this.Fi.values())t.D();this.Fi.clear(),this.Ui.D()}}function _t(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Ut(o){return _t(String(o))}function Q(o,t){return(o<<5)-o+t}class hi{constructor(t){l(this,"m");l(this,"Bi",0);l(this,"Gi");l(this,"Wi");l(this,"Hi",new Map);this.m=t,this.Gi=new $(t,st,`#version 300 es
|
|
10
|
+
precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellColor;in vec4 v_glyphFlags;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;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.Wi={id:this.Bi++,ki:this.Gi,Pi:Object.freeze({}),hash:this.Ki(this.Gi,{}),Yi:!0}}get ji(){return this.Wi}gt(t,i={},r=!1){const n=this.Ki(t,i),h=this.Hi.get(n);if(h)return h;const a={id:this.Bi++,ki:t,Pi:Object.freeze({...i}),hash:n,Yi:r};return this.Hi.set(n,a),a}Ni(t,i={}){return{id:this.Bi++,ki:t,Pi:Object.freeze({...i}),hash:0,Yi:!1}}Ki(t,i){const r=Ut(t.I),n=function(h,a){let c=0;const u=Object.keys(h).sort();for(const d of u)c=Q(c,_t(d)),c=Q(c,a(h[d]));return c}(i,this.Xi.bind(this));return Q(r,n)}Xi(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?Ut(t):0}D(){this.Gi!=this.Gi&&this.Gi.D(),this.Gi.D(),this.Hi.clear()}}class ni{constructor(){l(this,"Zi",[]);l(this,"Vi",1);l(this,"Ds",0)}qi(t,i){if(this.Ds>=this.Zi.length){const n={id:this.Vi++,type:t,Oi:{},state:rt.Dt(),Ri:i};this.Zi.push(n)}const r=this.Zi[this.Ds];return r.id=this.Vi++,r.type=t,r.Ri=i,this.Ds++,r}Ji(t,i,r){const n=this.qi(_.RECTANGLE,r),h=n.Oi;return h.width=t.width,h.height=t.height,i.Vt(n.state),n.id}Qi(t,i,r){const n=this.qi(_.LINE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.tr=t.tr,i.Vt(n.state),n.id}sr(t,i,r){const n=this.qi(_.ELLIPSE,r),h=n.Oi;return h.width=t.width,h.height=t.height,h.er=t.er,h.ir=t.ir,h.rr=t.rr,i.Vt(n.state),n.id}nr(t,i,r){const n=this.qi(_.ARC,r),h=n.Oi;return h.width=t.width,h.height=t.height,h.start=t.start,h.stop=t.stop,i.Vt(n.state),n.id}hr(t,i,r){const n=this.qi(_.TRIANGLE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.xi=t.xi,h.Ai=t.Ai,i.Vt(n.state),n.id}ar(t,i,r){const n=this.qi(_.BEZIER_CURVE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.mi=t.mi,h.yi=t.yi,h.wi=t.wi,h.bi=t.bi,h.x2=t.x2,h.y2=t.y2,h.tr=t.tr,h.rr=t.rr,i.Vt(n.state),n.id}cr(){this.Ds=0}[Symbol.iterator](){let t=0;const i=this.Ds,r=this.Zi;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class oi{constructor(t){l(this,"m");l(this,"lr",null);l(this,"ur");l(this,"vt");l(this,"dr");l(this,"pr");l(this,"_r");l(this,"gr",null);l(this,"vr",{});l(this,"mr",[]);l(this,"yr",[]);l(this,"wr",null);l(this,"br",[0,0,0,0]);this.m=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.dr=new rt,this.vt=new hi(t),this.pr=new ni,this.ur=new ri(t),this._r=new zt(t);const i=[0,0,t.canvas.width,t.canvas.height];pt(t,i),this.mr.push(null),this.yr.push(i),this.wr=null,this.br=i}et(){this.mr.push(this.wr),this.yr.push([...this.br])}ht(){return{framebuffer:this.mr.pop()??null,viewport:this.yr.pop()??[0,0,this.m.canvas.width,this.m.canvas.height]}}it(t,i,r){const n=this.m;this.wr!==t&&(n.bindFramebuffer(n.FRAMEBUFFER,t),this.wr=t);const h=[0,0,i,r];this.br[0]===h[0]&&this.br[1]===h[1]&&this.br[2]===h[2]&&this.br[3]===h[3]||(n.viewport(...h),pt(n,h),this.br=h)}Cr(t){this.lr!==t&&(this.lr=t,t.S())}$r(t,i){return new $(this.m,t,i)}Mr(t){this.gr=t,t&&(this.vr={})}P(t,i){this.vr[t]=i}Ar(t){Object.assign(this.vr,t)}Fr(t){return new $(this.m,st,t)}Ur(t,i,r){this.pr.Ji({width:i??t.width,height:r??t.height},this.dr,t.ct())}Tr(t,i,r,n){this._r.Es(t,i,r,n)}Sr(t,i){if(this.gr){const r=this.vt.Ni(this.gr,this.vr);this.pr.Ji({width:t,height:i},this.dr,r),this.gr=null,this.vr={}}else this.pr.Ji({width:t,height:i},this.dr,this.vt.ji)}Er(t,i,r,n){this.pr.Qi({x1:t,y1:i,x2:r,y2:n},this.dr,this.vt.ji)}Rr(t,i){this.pr.sr({width:t,height:i},this.dr,this.vt.ji)}kr(t,i,r,n,h,a){this.pr.hr({x1:t,y1:i,x2:r,y2:n,xi:h,Ai:a},this.dr,this.vt.ji)}Pr(t,i,r,n,h,a,c,u){this.pr.ar({x1:t,y1:i,mi:r,yi:n,wi:h,bi:a,x2:c,y2:u},this.dr,this.vt.ji)}Lr(t,i,r,n){this.pr.nr({width:t,height:i,start:r,stop:n},this.dr,this.vt.ji)}Ir(t,i,r=1,n={}){return new Z(this.m,t,i,r,n,this)}zr(t,i=t,r=t,n=255){this.dr.gs(t,i??t,r??t,n);const[h,a,c,u]=this.dr.ys;this.cr(h,a,c,u)}cr(t=0,i=0,r=0,n=0){this.m.clearColor(t,i,r,n),this.m.clear(this.m.COLOR_BUFFER_BIT)}Dr(){this.m.viewport(0,0,this.m.canvas.width,this.m.canvas.height),pt(this.m,[0,0,this.m.canvas.width,this.m.canvas.height])}ot(){const t=this.pr;this.ur.Ti(t),t.cr()}D(){this.vt.D(),this.ur.D(),this._r.D()}get context(){return this.m}get state(){return this.dr}}const U={Or:(o,t)=>(U.Br.uint16[0]=o[t]<<8|o[t+1],U.Br.int16[0]),Gr:(o,t)=>o[t]<<8|o[t+1],Wr(o,t,i){const r=[];for(let n=0;n<i;n++)r.push(U.Gr(o,t+2*n));return r},Hr(o,t){const i=U.Br.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],U.Br.uint32[0]},Kr(o,t,i){let r="";for(let n=0;n<i;n++)r+=String.fromCharCode(o[t+n]);return r},Br:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function ht(o){return o+3&-4}function nt(o,t,i){o[t]=i>>>8&255,o[t+1]=255&i}function N(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 ai(o,t,i){for(let r=0;r<i.length;r++)o[t+r]=255&i.charCodeAt(r)}function mt(o,t,i){const r=t+i;let n=0;const h=U.Br;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 ci{constructor(t){l(this,"b");l(this,"Yr",0);l(this,"jr",0);l(this,"Nr",0);this.b=t}Xr(t){for(;this.Nr<t;){const r=this.b[this.Yr++]||0;this.jr|=r<<this.Nr,this.Nr+=8}const i=this.jr&(1<<t)-1;return this.jr>>>=t,this.Nr-=t,i}Zr(){this.jr=0,this.Nr=0}get offset(){return this.Yr}}function tt(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 d=n[u]++;let f=a.get(u);f||(f=[],a.set(u,f)),f[li(d,u)]=c}return{min:t,max:i,table:a}}function vt(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.Xr(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 new Error("Invalid Huffman code")}function li(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function ui(o){if(o.length<2)throw new Error("ZLIB data too short");const t=o[0],i=o[1];if((15&t)!=8)throw new Error("Unsupported ZLIB compression method");if(((t<<8)+i)%31!=0)throw new 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],d=[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],f=[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 p=0;for(;!p;){p=h.Xr(1);const g=h.Xr(2);if(g===0){h.Zr();const m=h.Xr(16);if((65535&(65535^m))!==h.Xr(16))throw new Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<m;v++)a.push(h.Xr(8))}else{if(g!==1&&g!==2)throw new Error("Unsupported DEFLATE type");{let m,v;if(g===1){const y=new Array(288).fill(0);for(let w=0;w<=143;w++)y[w]=8;for(let w=144;w<=255;w++)y[w]=9;for(let w=256;w<=279;w++)y[w]=7;for(let w=280;w<=287;w++)y[w]=8;m=tt(y),v=tt(new Array(32).fill(5))}else{const y=h.Xr(5)+257,w=h.Xr(5)+1,b=h.Xr(4)+4,E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(19).fill(0);for(let L=0;L<b;L++)A[E[L]]=h.Xr(3);const x=tt(A),T=[];for(;T.length<y+w;){const L=vt(h,x);if(L<=15)T.push(L);else if(L===16){const B=h.Xr(2)+3,D=T[T.length-1]||0;for(let ut=0;ut<B;ut++)T.push(D)}else if(L===17){const B=h.Xr(3)+3;for(let D=0;D<B;D++)T.push(0)}else{if(L!==18)throw new Error("Invalid code length symbol");{const B=h.Xr(7)+11;for(let D=0;D<B;D++)T.push(0)}}}const R=T.slice(0,y),Y=T.slice(y,y+w);m=tt(R),v=tt(Y)}for(;;){const y=vt(h,m);if(y<256)a.push(y);else{if(y===256)break;if(y>256&&y<286){const w=y-257;let b=c[w];const E=u[w];E&&(b+=h.Xr(E));const A=vt(h,v);if(A>=30)throw new Error("Invalid distance symbol");let x=d[A];const T=f[A];T&&(x+=h.Xr(T));const R=a.length-x;if(R<0)throw new Error("Invalid distance");for(let Y=0;Y<b;Y++)a.push(a[R+Y]||0)}else if(y===286||y===287)throw new Error("Reserved length symbol")}}}}}}(new ci(o.subarray(r)),n),new Uint8Array(n)}function fi(o){const t=U,i=new Uint8Array(o);if(t.Kr(i,0,4)!=="wOFF")throw new Error("Invalid WOFF signature");const r=t.Hr(i,4),n=t.Gr(i,12),h=t.Hr(i,16),a=[];let c=44;for(let E=0;E<n;E++){const A=t.Kr(i,c,4),x=t.Hr(i,c+4),T=t.Hr(i,c+8),R=t.Hr(i,c+12),Y=t.Hr(i,c+16);a.push({tag:A,offset:x,Vr:T,qr:R,Jr:Y}),c+=20}for(const E of a){const A=new Uint8Array(i.buffer,E.offset,E.Vr);if(E.Vr===E.qr)E.data=new Uint8Array(A);else if(E.data=ui(A),E.data.length!==E.qr)if(E.data.length<E.qr){const x=new Uint8Array(E.qr);x.set(E.data),E.data=x}else E.data=E.data.subarray(0,E.qr)}const u=n;let d=1,f=0;for(;d<<1<=u;)d<<=1,f++;const p=16*d,g=16*u-p;let m=12+16*u;const v={};for(const E of a)v[E.tag]=m,m=ht(m+E.data.length);const y=Math.max(h||0,m),w=new Uint8Array(y);N(w,0,r),nt(w,4,u),nt(w,6,p),nt(w,8,f),nt(w,10,g);let b=12;for(const E of a){ai(w,b,E.tag),b+=4;let A=E.data;if(E.tag==="head"&&A.length>=12){const x=new Uint8Array(A);N(x,8,0),N(w,b,mt(x,0,ht(x.length))),b+=4}else N(w,b,mt(A,0,ht(A.length))),b+=4;N(w,b,v[E.tag]),b+=4,N(w,b,E.data.length),b+=4}for(const E of a){const A=v[E.tag];w.set(E.data,A)}if(a.find(E=>E.tag==="head")){const E=v.head,A=function(x,T){const R=T+8,Y=[x[R],x[R+1],x[R+2],x[R+3]];N(x,R,0);const L=2981146554-(mt(x,0,ht(x.length))>>>0)>>>0;return x[R]=Y[0],x[R+1]=Y[1],x[R+2]=Y[2],x[R+3]=Y[3],L>>>0}(w,E);N(w,E+8,A)}return w.buffer}const di={Qr(o,t,i){const r={tn:[],sn:{},off:t};o=new Uint8Array(o.buffer,t,i),t=0;const n=U,h=n.Gr,a=h(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const d=h(o,t),f=h(o,t+=2);t+=2;const p=n.Hr(o,t);t+=4;const g=`p${d}e${f}`;let m=c.indexOf(p);if(m===-1){let v;m=r.tn.length,c.push(p);const y=h(o,p);v=y===4?this.en(o,p):y===12?this.rn(o,p):{format:y},r.tn.push(v)}r.sn[g]=m}return r},en(o,t){const i=U,r=i.Gr,n=i.Wr,h=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,nn:r(o,t+=2),hn:0,an:0,cn:[],ln:[],un:[],fn:[],dn:[]};t+=2,u.hn=r(o,t),t+=2,u.an=r(o,t),t+=2,u.cn=n(o,t,c),t+=2*c,t+=2,u.ln=n(o,t,c),t+=2*c;for(let d=0;d<c;d++)u.un.push(i.Or(o,t)),t+=2;return u.fn=n(o,t,c),t+=2*c,u.dn=n(o,t,h+a-t>>1),u},rn(o,t){const i=U.Hr;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}}},pi={Qr(o,t,i){const r=U;t+=18;const n=r.Gr(o,t);t+=2,t+=16;const h=r.Or(o,t);t+=2;const a=r.Or(o,t);t+=2;const c=r.Or(o,t);t+=2;const u=r.Or(o,t);return t+=2,t+=6,{pn:n,_n:h,gn:a,vn:c,mn:u,yn:r.Or(o,t)}}},gi={Qr(o,t,i){const r=U;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.Gr:r.Or;h[c]=u(o,t+2*a)}return h}},mi={Qr(o,t,i,r){const n=U,h=[],a=[],c=r.bn.wn,u=r.$n.Cn;let d=0,f=0,p=0;for(;p<u;)d=n.Gr(o,t+(p<<2)),f=n.Or(o,t+(p<<2)+2),h.push(d),a.push(f),p++;for(;p<c;)h.push(d),a.push(f),p++;return{Mn:h,xn:a}}},Yt={An:di,head:pi,$n:gi,bn:{Qr(o,t,i){const r=U;return r.Hr(o,t),t+=4,{wn:r.Gr(o,t)}}},Fn:mi,Un:{Qr(o,t,i,r){const n=U,h=[],a=r.head.yn,c=r.bn.wn+1;if(a===0)for(let u=0;u<c;u++)h.push(n.Gr(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)h.push(n.Hr(o,t+(u<<2)));return h}},Tn:{Qr(o,t,i,r){const n=[],h=r.bn.wn;for(let a=0;a<h;a++)n.push(null);return n},Sn(o,t){const i=U,r=o.En,n=o.Un;if(n[t]===n[t+1])return null;const h=z.Rn(r,"glyf",o.kn);if(!h)return null;let a=h[0]+n[t];const c={};if(c.Pn=i.Or(r,a),a+=2,c._n=i.Or(r,a),a+=2,c.gn=i.Or(r,a),a+=2,c.vn=i.Or(r,a),a+=2,c.mn=i.Or(r,a),a+=2,c._n>=c.vn||c.gn>=c.mn)return null;if(c.Pn>0){c.Ln=[];for(let g=0;g<c.Pn;g++)c.Ln.push(i.Gr(r,a)),a+=2;const u=i.Gr(r,a);if(a+=2,r.length-a<u)return null;a+=u;const d=c.Ln[c.Pn-1]+1;c.flags=[];for(let g=0;g<d;g++){const m=r[a];if(a++,c.flags.push(m),8&m){const v=r[a];a++;for(let y=0;y<v;y++)c.flags.push(m),g++}}c.In=[];for(let g=0;g<d;g++){const m=c.flags[g],v=!!(16&m);2&m?(c.In.push(v?r[a]:-r[a]),a++):v?c.In.push(0):(c.In.push(i.Or(r,a)),a+=2)}c.zn=[];for(let g=0;g<d;g++){const m=c.flags[g],v=!!(32&m);4&m?(c.zn.push(v?r[a]:-r[a]),a++):v?c.zn.push(0):(c.zn.push(i.Or(r,a)),a+=2)}let f=0,p=0;for(let g=0;g<d;g++)f+=c.In[g],p+=c.zn[g],c.In[g]=f,c.zn[g]=p}else c.Dn=[],c.Ln=[],c.flags=[],c.In=[],c.zn=[];return c}}},z={parse(o){const t=new Uint8Array(o);U.Kr(t,0,4)==="wOFF"&&(o=fi(o));const i=new Uint8Array(o),r=Yt,n={},h={En:i,On:0,kn:0};for(const a in r){const c=a,u=z.Rn(i,c,0);if(u){const[d,f]=u;let p=n[d];p==null&&(p=r[c].Qr(i,d,f,h),n[d]=p),h[c]=p}}return[h]},Rn(o,t,i){const r=U,n=r.Gr(o,i+4);let h=i+12;for(let a=0;a<n;a++){const c=r.Kr(o,h,4);r.Hr(o,h+4);const u=r.Hr(o,h+8),d=r.Hr(o,h+12);if(c===t)return[u,d];h+=16}return null},Bn:Yt,Gn:U};class vi{Wn(t){var r;const i=[];return(r=t.An)!=null&&r.tn?(t.An.tn.forEach(n=>{if(n.format===4){const h=this.Hn(n);i.push(...h)}else if(n.format===12){const h=this.Kn(n);i.push(...h)}}),[...new Set(i)]):[]}Hn(t){const i=[];if(!(t.ln&&t.cn&&t.fn&&t.un))return i;for(let r=0;r<t.ln.length;r++){const n=t.ln[r],h=t.cn[r];if(n!==65535||h!==65535){for(let a=n;a<=h;a++)if(this.Yn(t,a,r)>0)try{const c=String.fromCodePoint(a);i.push(c)}catch{}}}return i}Kn(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}Yn(t,i,r){if(t.fn[r]===0)return i+t.un[r]&65535;{const n=t.fn[r]/2+(i-t.ln[r])-(t.ln.length-r);if(n>=0&&t.dn&&n<t.dn.length){const h=t.dn[n];if(h!==0)return h+t.un[r]&65535}}return 0}}class wt{constructor(){l(this,"jn",new Map);l(this,"Nn",new Map)}Xn(t,i){const r=`${this.Zn(t)}_${i}`;if(this.jn.has(r))return this.jn.get(r);const n=t.An;if(!n||!n.tn)return this.jn.set(r,0),0;let h=0;for(const a of n.tn)if(a.format===4?h=this.Vn(i,a):a.format===12&&(h=this.qn(i,a)),h>0)break;return this.jn.set(r,h),h}Jn(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Xn(t,r)}Qn(t,i){const r=t.Fn;return r&&r.Mn&&r.Mn.length!==0?i<r.Mn.length?r.Mn[i]:r.Mn[r.Mn.length-1]:0}so(t,i){const r=i/t.head.pn,n=t.$n.eo*r,h=t.$n.io*r,a=t.$n.ro*r;return{eo:n,io:h,ro:a,lineHeight:n-h+a,pn:t.head.pn,scale:r}}no(){this.jn.clear(),this.Nn.clear()}Zn(t){return`${t.kn}_${t.En.length}`}Vn(t,i){const r=i.cn.length;let n=-1;for(let h=0;h<r;h++)if(t<=i.cn[h]){n=h;break}if(n===-1||t<i.ln[n])return 0;if(i.fn[n]===0)return t+i.un[n]&65535;{const h=i.fn[n]/2+(t-i.ln[n])-(r-n);if(h>=0&&h<i.dn.length){const a=i.dn[h];return a===0?0:a+i.un[n]&65535}}return 0}qn(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 wi{constructor(t){l(this,"oo");l(this,"ho");l(this,"Y");l(this,"ao");this.Y=t,this.ao=new wt,this.oo=document.createElement("canvas"),this.ho=this.oo.getContext("2d",{co:!0,alpha:!0})}lo(t,i,r,n){const h=t.length,a=Math.ceil(Math.sqrt(h)),c=Math.ceil(h/a),u=i.width*a,d=i.height*c;this.uo(u,d),this.fo(t,i,a,r,n);const f=this.Y.Ir(u,d,1,{filter:"nearest"});return f.tt(this.oo),{framebuffer:f,columns:a,rows:c}}uo(t,i){this.oo.width=t,this.oo.height=i,this.oo.style.width=t+"px",this.oo.style.height=i+"px",this.ho.imageSmoothingEnabled=!1,this.oo.style.imageRendering="pixelated",this.ho.clearRect(0,0,t,i),this.ho.textBaseline="top",this.ho.textAlign="left",this.ho.fillStyle="white"}fo(t,i,r,n,h){const a=n/h.head.pn;for(let c=0;c<t.length;c++){const u=c%r,d=Math.floor(c/r),f=t[c].do,p=this.po(h,f);if(!p)continue;const g=f.codePointAt(0)||0,m=this.ao.Xn(h,g),v=this.ao.Qn(h,m)*a,y=u*i.width,w=d*i.height,b=y+.5*i.width,E=w+.5*i.height,A=Math.round(b-.5*i.width),x=Math.round(E-.5*n),T=A+.5*(i.width-v),R=x+h.$n.eo*a;this._o(p,T,R,a)}}po(t,i){const r=i.codePointAt(0)||0,n=this.ao.Xn(t,r);return n===0?null:z.Bn.Tn.Sn(t,n)}_o(t,i,r,n){if(!t||!t.In||t.Pn===0)return;let{In:h,zn:a,Ln:c,flags:u}=t;if(!(h&&a&&c&&u))return;this.ho.beginPath();let d=0;for(let f=0;f<c.length;f++){const p=c[f];if(!(p<d)){if(p>=d){const g=i+h[d]*n,m=r-a[d]*n;this.ho.moveTo(g,m);let v=d+1;for(;v<=p;)if(1&u[v]){const y=i+h[v]*n,w=r-a[v]*n;this.ho.lineTo(y,w),v++}else{const y=i+h[v]*n,w=r-a[v]*n;if(v+1>p){const E=i+h[d]*n,A=r-a[d]*n;if(1&u[d])this.ho.quadraticCurveTo(y,w,E,A);else{const x=(y+E)/2,T=(w+A)/2;this.ho.quadraticCurveTo(y,w,x,T)}break}const b=v+1;if(1&u[b]){const E=i+h[b]*n,A=r-a[b]*n;this.ho.quadraticCurveTo(y,w,E,A),v=b+1}else{const E=(y+(i+h[b]*n))/2,A=(w+(r-a[b]*n))/2;this.ho.quadraticCurveTo(y,w,E,A),v=b}}this.ho.closePath()}d=p+1}}this.ho.fill()}}class yi{constructor(){l(this,"vo");this.vo=new wt}mo(t,i,r){let n=0;const h=this.vo.so(r,i),a=h.lineHeight;for(const c of t){const u=this.vo.Jn(r,c);if(u===0)continue;const d=this.vo.Qn(r,u)*h.scale;n=Math.max(n,d)}return{width:Math.ceil(n),height:Math.ceil(a)}}no(){this.vo.no()}}class Ei{constructor(){l(this,"ao");this.ao=new wt}yo(t,i){return t.map((r,n)=>{const h=r.codePointAt(0)||0,a=this.wo(n);let c=0;if(i.Fn&&i.Fn.Mn){const u=this.ao.Xn(i,h);u>0&&i.Fn.Mn[u]!==void 0&&(c=i.Fn.Mn[u])}return{do:r,unicode:h,color:a,bo:c}})}wo(t){return[t%256/255,Math.floor(t/256)%256/255,0]}Co(t,i){if(!q._(typeof t=="string","Character must be a string.",{method:"getCharacterColor",$o:t}))return[0,0,0];const r=i.find(n=>n.do===t);return r?r.color:[0,0,0]}Mo(t,i){return q._(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",$o:t})?Array.from(t).map(r=>this.Co(r,i)||[0,0,0]):[[0,0,0]]}}class yt{constructor(t,i=16){l(this,"xo");l(this,"Ao",[]);l(this,"Fo");l(this,"Uo",16);l(this,"To",0);l(this,"So",0);l(this,"Eo",{width:0,height:0});l(this,"Ro");l(this,"ko",new Map);l(this,"Po");l(this,"Lo");l(this,"Io");l(this,"zo");this.Uo=i,this.Po=new vi,this.Lo=new wi(t),this.Io=new yi,this.zo=new Ei}async Do(t){let i;if(!t)throw new F("Embedded font not available. This appears to be a minified build - please provide `fontSource` or use the non-minified version.");{const r=await fetch(t);if(!r.ok)throw new F(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}await this.Oo(i),this.xo=z.parse(i)[0],await this.Bo()}Go(t){if(t===void 0)return this.Uo;this.Uo=t,this.Eo=this.Io.mo(this.Ao.map(r=>r.do),this.Uo,this.xo);const i=this.Lo.lo(this.Ao,this.Eo,this.Uo,this.xo);this.Fo=i.framebuffer,this.To=i.columns,this.So=i.rows}async Wo(t){try{const i=await fetch(t);if(!i.ok)throw new F(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.Oo(r);const n=z.parse(r);if(!n||n.length===0)throw new Error("Failed to parse font file");this.xo=n[0],await this.Bo()}catch(i){throw new F(`Failed to load font: ${i instanceof Error?i.message:"Unknown error"}`,i)}}async Oo(t){const i=Date.now();this.Ro=new FontFace(`CustomFont_${i}`,t),await this.Ro.load(),document.fonts.add(this.Ro)}async Bo(){const t=this.Po.Wn(this.xo);this.ko.clear(),this.Ao=this.zo.yo(t,this.xo),this.Eo=this.Io.mo(t,this.Uo,this.xo);const i=this.Lo.lo(this.Ao,this.Eo,this.Uo,this.xo);this.Fo=i.framebuffer,this.To=i.columns,this.So=i.rows}Co(t){return this.zo.Co(t,this.Ao)}Mo(t){return this.zo.Mo(t,this.Ao)}Ho(t){if(!Number.isFinite(t))return null;const i=this.ko.get(t);if(i!==void 0)return i;const r=this.Ko(t);if(r<0)return this.ko.set(t,null),null;const n=this.xo.Tn;if(!n)return this.ko.set(t,null),null;let h=n[r]??null;return h==null&&(h=z.Bn.Tn.Sn(this.xo,r)??null,n[r]=h),this.ko.set(t,h),h}Ko(t){const i=this.xo.An;for(const r of i.tn)if(r.format===4){const n=r;for(let h=0;h<n.ln.length;h++)if(t>=n.ln[h]&&t<=n.cn[h]){if(n.fn[h]===0)return t+n.un[h]&65535;{const a=n.fn[h]/2+(t-n.ln[h])-(n.ln.length-h);if(a>=0&&a<n.dn.length){const c=n.dn[a];if(c!==0)return c+n.un[h]&65535}}}}else if(r.format===12){const n=r;for(let h=0;h<n.groups.length;h+=3){const a=n.groups[h],c=n.groups[h+1],u=n.groups[h+2];if(t>=a&&t<=c)return u+(t-a)}}return 0}D(){this.Fo.D(),document.fonts.delete(this.Ro)}get Yo(){return this.Fo}get jo(){return this.Ao}get No(){return this.To}get Xo(){return this.So}get Zo(){return this.Eo}get fontSize(){return this.Uo}get font(){return this.xo}}class Et{constructor(t,i,r){l(this,"Vo");l(this,"qo");l(this,"O");l(this,"B");l(this,"Jo");l(this,"Qo");l(this,"th");l(this,"sh");l(this,"eh");this.th=t,this.sh=i,this.eh=r,this.ih()}ih(){this.Vo=Math.floor(this.th.width/this.sh),this.qo=Math.floor(this.th.height/this.eh),this.O=this.Vo*this.sh,this.B=this.qo*this.eh,this.Jo=Math.floor((this.th.width-this.O)/2),this.Qo=Math.floor((this.th.height-this.B)/2)}rh(t,i){this.sh=t,this.eh=i,this.ih()}get nh(){return this.sh}get oh(){return this.eh}get cols(){return this.Vo}get rows(){return this.qo}get width(){return this.O}get height(){return this.B}get offsetX(){return this.Jo}get offsetY(){return this.Qo}}const Ai=/^#([0-9a-f]{3,8})$/i,bi=/^rgba?\(([^)]+)\)$/i;function At(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function xi(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t||t==="transparent")return null;let i=null;return t.startsWith("#")?i=function(r){const n=Ai.exec(r.trim());if(!n)return null;const h=n[1];return h.length===3?[parseInt(h[0]+h[0],16),parseInt(h[1]+h[1],16),parseInt(h[2]+h[2],16),255]:h.length===4?[parseInt(h[0]+h[0],16),parseInt(h[1]+h[1],16),parseInt(h[2]+h[2],16),parseInt(h[3]+h[3],16)]:h.length===6||h.length===8?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16),h.length===8?parseInt(h.slice(6,8),16):255]:null}(t):t.startsWith("rgb")&&(i=function(r){const n=bi.exec(r.trim());if(!n)return null;const h=n[1].split(",").map(f=>f.trim());if(h.length<3)return null;const a=At(parseFloat(h[0])),c=At(parseFloat(h[1])),u=At(parseFloat(h[2])),d=h[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(h[3]))):255;return[a,c,u,Math.round(d)]}(t)),i?i[3]===0?null:i:null}class Ct{constructor(t={}){l(this,"th");l(this,"hh",null);l(this,"ah",!1);l(this,"uh");this.ah=t.fh??!1,this.ah&&t.canvas?(this.hh=t.canvas,this.th=this.dh(),this.uh=!0,this.ph()):t.canvas?(this.th=t.canvas,this.uh=!1):(this.th=this._h(t.width,t.height),this.uh=!0),this.th.style.imageRendering="pixelated"}_h(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}dh(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.hh.getBoundingClientRect();let r=Math.round(i.width),n=Math.round(i.height);if(this.hh instanceof HTMLVideoElement){const c=this.hh;(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.hh);let a=parseInt(h.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=(a+1).toString(),t}ph(){var t;this.gh(),(t=this.hh.parentNode)==null||t.insertBefore(this.th,this.hh.nextSibling)}mh(){const t=[];return this.ah&&this.hh instanceof HTMLElement&&(t.push(this.hh),this.hh.parentElement&&t.push(this.hh.parentElement)),this.th.parentElement&&t.push(this.th.parentElement),t.push(this.th),t.push(document.body),t.push(document.documentElement),t}yh(){const t=this.mh();for(const i of t){if(!i)continue;const r=xi(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}gh(){if(!this.hh)return;const t=this.hh.getBoundingClientRect();let i=this.hh.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.th.style.top=t.top-r.top+"px",this.th.style.left=t.left-r.left+"px"}else this.th.style.top=t.top+window.scrollY+"px",this.th.style.left=t.left+window.scrollX+"px"}wh(t,i){if(this.ah){const r=this.hh.getBoundingClientRect();this.th.width=Math.round(r.width),this.th.height=Math.round(r.height),this.gh()}else this.th.width=t??this.th.width,this.th.height=i??this.th.height}bh(){const t=this.th.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,Ch:!0,antialias:!1,Z:!0,$h:!1,powerPreference:"high-performance"});if(!t)throw new F("`textmode.js` requires WebGL2 support.");return t}D(){const t=this.th.getContext("webgl")||this.th.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.Mh()}this.uh&&this.th.parentNode&&this.th.parentNode.removeChild(this.th)}get canvas(){return this.th}get xh(){return this.hh}get width(){return this.th.width}get height(){return this.th.height}}const Ti=/^#|0x/gi;function it(o){return Number.isNaN(o)||!Number.isFinite(o)||o<=0?0:o>=255?255:Math.round(o)}function ot(o){return it(parseInt(o,16))}class C{constructor(t,i,r,n,h){l(this,"Ah");l(this,"Fh");l(this,"Yt");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=it(t),this.g=it(i),this.b=it(r),this.a=it(n),this.Ah=[this.r,this.g,this.b,this.a],this.Fh=[this.r/255,this.g/255,this.b/255,this.a/255],this.Yt=h?[...h]:void 0}static Uh(t,i,r,n=255){return new C(t,i,r,n)}static Th(t,i=255){return new C(t,t,t,i)}static Sh(t){const[i,r,n,h]=function(a){const c=a.replace(Ti,""),u=(d=c).length===3||d.length===4?d.split("").map(f=>f+f).join(""):d;var d;if(u.length!==6&&u.length!==8)throw new Error(`Invalid hex color: ${a}`);return[ot(u.slice(0,2)),ot(u.slice(2,4)),ot(u.slice(4,6)),u.length===8?ot(u.slice(6,8)):255]}(t);return new C(i,r,n,h)}static Eh(t){const[i,r,n]=t;return new C(255*i,255*r,255*n,255,t)}get Rh(){return[this.r,this.g,this.b]}get kh(){return[...this.Ah]}get te(){return[...this.Fh]}get do(){return this.Yt?[...this.Yt]:void 0}static Ph(t){return t instanceof C}}const W=class W{constructor(t,i,r,n,h,a,c){l(this,"m");l(this,"Y");l(this,"Lh");l(this,"Ih");l(this,"zh");l(this,"O");l(this,"B");l(this,"j",null);l(this,"Rt",0);l(this,"Ht",0);l(this,"Kt",0);l(this,"kt",0);l(this,"Dh","sampled");l(this,"Oh","fixed");l(this,"jt",[1,1,1,1]);l(this,"Nt",[0,0,0,1]);l(this,"Bh",[0,0,0,1]);l(this,"Gh",[[.1,0,0]]);l(this,"Wh");this.m=t,this.Y=i,this.Lh=r,this.Ih=n,this.zh=h,this.O=a,this.B=c}dispose(){this.m.deleteTexture(this.Lh)}Pe(t=!0){return this.Rt=t?1:0,this.j=null,this}flipX(t=!0){return this.Ht=t?1:0,this.j=null,this}flipY(t=!0){return this.Kt=t?1:0,this.j=null,this}Kh(t){return this.kt=Tt(t),this.j=null,this}Yh(t){return this.Dh=t,this.j=null,this}jh(t){return this.Oh=t,this.j=null,this}Nh(t,i,r,n){return this.Xh(this.jt,t,i,r,n),this.j=null,this}Zh(t,i,r,n){return this.Xh(this.Nt,t,i,r,n),this.j=null,this}background(t,i,r,n){return this.Xh(this.Bh,t,i,r,n),this.j=null,this}jo(t){if(!this.Wh)throw new Error("Glyph color resolver not initialized");const i=this.Wh(t).filter(r=>Array.isArray(r)).slice(0,64);return this.Gh=i,this.j=null,this}get texture(){return this.Lh}get width(){return this.O}get height(){return this.B}get Vh(){return this.Ih}get qh(){return this.zh}ct(){return this.j||this.lt(),this.j}Jh(){}lt(){this.Jh();const t=this.Qh(),i=this.ta();this.j=this.Y.vt.Ni(t,i)}Xh(t,i,r,n,h){if(C.Ph(i))X(t,i.r,i.g,i.b,i.a);else{if(typeof i=="string"){const a=C.Sh(i);return void X(t,a.r,a.g,a.b,a.a)}X(t,i,r,n,h)}}Qh(){return W.Hh||(W.Hh=new $(this.m,st,`#version 300 es
|
|
11
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Uh;uniform bool Ui;uniform bool Uj;uniform bool Uk;uniform float Ul;uniform bool Um;uniform vec4 Un;uniform bool Uo;uniform vec4 Up;uniform vec4 Uq;uniform int Ur;uniform vec3 Us[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));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uh,C);float E=A(D.rgb);vec2 F=vec2(0.);if(Ur>0){float G=float(Ur);float H=clamp(E*(G-1.0f),0.0f,G-1.0f);int I=int(floor(H+0.5f));vec3 J=Us[I];F=J.xy;}else{F=vec2(E,0.0f);}vec4 K=Um?Un:D;vec4 L=Uo?Up:D;if(D.a<0.01f){K=Uq;L=Uq;}else{}o_primaryColor=vec4(K.rgb,K.a);o_secondaryColor=vec4(L.rgb,L.a);int M=int(Ui?1:0);int N=int(Uj?1:0);int O=int(Uk?1:0);float P=float(M|(N<<1)|(O<<2))/255.;o_character=vec4(F,P,clamp(Ul,0.0f,1.0f));}`)),W.Hh}ta(){return{sa:this.ea(),ia:!!this.Rt,ra:!!this.Ht,na:!!this.Kt,oa:this.kt,ha:this.Dh==="fixed",aa:this.jt,ca:this.Oh==="fixed",la:this.Nt,ua:this.Bh,fa:this.Gh.length,da:this.Gh}}};l(W,"Hh",null);let at=W;class K extends at{constructor(t,i,r,n,h,a,c){const u=Math.min(a/n,c/h);super(t,i,r,n,h,Math.max(1,Math.floor(n*u)),Math.max(1,Math.floor(h*u)))}static pa(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),et(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,i),a.bindTexture(a.TEXTURE_2D,null);const u=i.naturalWidth??i.width??i.videoWidth??0,d=i.naturalHeight??i.height??i.videoHeight??0,f=new K(a,t,c,u,d,r,n);return f.Wh=h,f}ea(){return this.Lh}}class Ri{constructor(t=60){l(this,"_a");l(this,"ga",null);l(this,"va",0);l(this,"ma",!0);l(this,"ya",0);l(this,"wa",0);l(this,"ba",[]);l(this,"Ca",10);l(this,"$a",0);this._a=1e3/t}Ma(t){if(!this.ma)return;this.va=performance.now();const i=r=>{if(!this.ma)return void(this.ga=null);const n=r-this.va;n>=this._a&&(t(),this.va=r-n%this._a),this.ma&&(this.ga=requestAnimationFrame(i))};this.ga=requestAnimationFrame(i)}xa(){this.ga&&(cancelAnimationFrame(this.ga),this.ga=null)}Aa(){this.ma&&(this.ma=!1,this.xa())}Fa(t){this.ma||(this.ma=!0,this.Ma(t))}Ua(t,i){if(t===void 0)return this.ya;this._a=1e3/t,this.ma&&i&&(this.xa(),this.Ma(i))}Ta(){const t=performance.now();if(this.wa>0){const i=t-this.wa;this.ba.push(i),this.ba.length>this.Ca&&this.ba.shift();const r=this.ba.reduce((n,h)=>n+h,0)/this.ba.length;this.ya=1e3/r}this.wa=t}get Sa(){return this.ma}get Ea(){return this.ya}get Ra(){return this.$a}set Ra(t){this.$a=t}ka(){this.$a++}}class Pt{constructor(t){l(this,"th");l(this,"Pa");l(this,"La",{x:-1,y:-1});l(this,"Ia",{x:-1,y:-1});l(this,"za",null);l(this,"Da",0);l(this,"Oa");l(this,"Ba");l(this,"Ga");l(this,"Wa");l(this,"Ha");l(this,"Ka");l(this,"Ya",!1);l(this,"ja");l(this,"Na");l(this,"Xa");l(this,"Za");l(this,"Va");this.th=t}qa(t){const i=performance.now()+Math.max(0,t);i>this.Da&&(this.Da=i)}Ja(){return performance.now()<this.Da}Qa(t){const i=this.th.canvas;i.style.cursor=t==null||t===""?"":t}Do(t){this.Pa=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.Oa=i=>{this.ec(i),this.rc(i)},this.Ba=()=>{this.Ia={...this.La},this.La.x=-1,this.La.y=-1,this.za=null},this.Ga=i=>{this.ec(i),this.nc(i)},this.Wa=i=>{this.ec(i),this.oc(i)},this.Ha=i=>{this.ec(i),this.hc(i)},this.Ka=i=>{this.ec(i),this.ac(i)},t.addEventListener("mousemove",this.Oa,{passive:!0}),t.addEventListener("mouseleave",this.Ba,{passive:!0}),t.addEventListener("mousedown",this.Ga,{passive:!0}),t.addEventListener("mouseup",this.Wa,{passive:!0}),t.addEventListener("click",this.Ha,{passive:!0}),t.addEventListener("wheel",this.Ka,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("mousemove",this.Oa),t.removeEventListener("mouseleave",this.Ba),t.removeEventListener("mousedown",this.Ga),t.removeEventListener("mouseup",this.Wa),t.removeEventListener("click",this.Ha),t.removeEventListener("wheel",this.Ka),this.Ya=!1}tc(){if(this.Ya)try{if(this.za){const t=new MouseEvent("mousemove",{clientX:this.za.x,clientY:this.za.y,bubbles:!1,cancelable:!1});this.ec(t)}else this.La.x!==-1&&this.La.y!==-1&&(this.La.x>=this.Pa.cols||this.La.y>=this.Pa.rows)&&(this.La.x=-1,this.La.y=-1)}catch{this.La.x=-1,this.La.y=-1}}lc(t){this.ja=t}uc(t){this.Na=t}fc(t){this.Xa=t}dc(t){this.Za=t}_c(t){this.Va=t}gc(){return{x:this.La.x,y:this.La.y}}rc(t){if(this.Za&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},mc:t};this.Za(i)}}nc(t){if(this.Na&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.Na(i)}}oc(t){if(this.Xa&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.Xa(i)}}hc(t){if(this.ja&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.ja(i)}}ac(t){if(this.Va&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},delta:{x:t.deltaX,y:t.deltaY},mc:t};this.Va(i)}}ec(t){const i=this.th.canvas;this.Ia={...this.La},this.za={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.Pa.offsetX,d=c-this.Pa.offsetY,f=Math.floor(u/this.Pa.nh),p=Math.floor(d/this.Pa.oh);f>=0&&f<this.Pa.cols&&p>=0&&p<this.Pa.rows?(this.La.x=f,this.La.y=p):(this.La.x=-1,this.La.y=-1)}}const Fi=Object.freeze(Object.defineProperty({__proto__:null,yc:Pt},Symbol.toStringTag,{value:"Module"}));class Dt{constructor(){l(this,"wc",new Map);l(this,"bc",null);l(this,"Cc",null);l(this,"$c");l(this,"Mc");l(this,"Ya",!1);l(this,"xc");l(this,"Ac");l(this,"Fc",{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"})}sc(){this.Ya||(this.$c=t=>{this.Uc(t)},this.Mc=t=>{this.Tc(t)},window.addEventListener("keydown",this.$c,{passive:!1}),window.addEventListener("keyup",this.Mc,{passive:!1}),this.Ya=!0)}cc(){this.Ya&&(window.removeEventListener("keydown",this.$c),window.removeEventListener("keyup",this.Mc),this.Ya=!1,this.wc.clear(),this.bc=null,this.Cc=null)}uc(t){this.xc=t}fc(t){this.Ac=t}Sc(t){const i=this.Ec(t),r=this.wc.get(t)||this.wc.get(i);return(r==null?void 0:r.Rc)||!1}kc(){return this.bc}Pc(){return this.Cc}Lc(){const t=[];for(const[i,r]of this.wc)r.Rc&&t.push(i);return t}Ic(){return{zc:this.Sc("Control"),shift:this.Sc("Shift"),alt:this.Sc("Alt"),Dc:this.Sc("Meta")}}Oc(){this.wc.clear(),this.bc=null,this.Cc=null}Uc(t){const i=t.key,r=Date.now();this.wc.has(i)||this.wc.set(i,{Rc:!1,Bc:0,Gc:0});const n=this.wc.get(i);if(!n.Rc&&(n.Rc=!0,n.Bc=r,this.bc=i,this.xc)){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,Rc:!0,mc:t};this.xc(h)}}Tc(t){const i=t.key,r=Date.now();this.wc.has(i)||this.wc.set(i,{Rc:!1,Bc:0,Gc:0});const n=this.wc.get(i);if(n.Rc=!1,n.Gc=r,this.Cc=i,this.Ac){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,Rc:!1,mc:t};this.Ac(h)}}Ec(t){return this.Fc[t]||t.toLowerCase()}}const Li=Object.freeze(Object.defineProperty({__proto__:null,Wc:Dt},Symbol.toStringTag,{value:"Module"}));class Ot{constructor(t,i){l(this,"th");l(this,"Hc");l(this,"Pa");l(this,"Kc",new Map);l(this,"Yc",new Map);l(this,"jc",new Map);l(this,"Nc",null);l(this,"Xc");l(this,"Zc");l(this,"Vc");l(this,"qc");l(this,"Jc");l(this,"Qc");l(this,"Ya",!1);l(this,"tl");l(this,"sl");l(this,"el");l(this,"il");l(this,"rl");l(this,"nl");l(this,"ol");l(this,"hl");l(this,"al");l(this,"cl");l(this,"ll",320);l(this,"ul",350);l(this,"fl",10);l(this,"dl",550);l(this,"pl",14);l(this,"_l",48);l(this,"gl",650);l(this,"vl",.02);l(this,"ml",2);l(this,"yl",600);l(this,"wl",0);l(this,"bl",null);this.th=t,this.Hc=i;const r=this.th.canvas;this.Xc=r.style.touchAction,this.Zc=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}Do(t){this.Pa=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.Vc=i=>{this.Cl(i)},this.qc=i=>{this.$l(i)},this.Jc=i=>{this.Ml(i)},this.Qc=i=>{this.xl(i)},t.addEventListener("touchstart",this.Vc,{passive:!1}),t.addEventListener("touchmove",this.qc,{passive:!1}),t.addEventListener("touchend",this.Jc,{passive:!1}),t.addEventListener("touchcancel",this.Qc,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("touchstart",this.Vc),t.removeEventListener("touchmove",this.qc),t.removeEventListener("touchend",this.Jc),t.removeEventListener("touchcancel",this.Qc),this.Ya=!1,this.Nc=null,this.Kc.clear(),this.Yc.clear(),this.jc.forEach(i=>{i.Al!==null&&window.clearTimeout(i.Al)}),this.jc.clear(),this.bl=null,this.wl=0,t.style.touchAction=this.Xc,t.style.userSelect=this.Zc}tc(){if(!this.Pa||this.Kc.size===0)return;const t=new Map;for(const i of this.Kc.values()){const r=this.Fl(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Kc=t}Ul(){return Array.from(this.Kc.values()).map(t=>({...t}))}Tl(t){this.tl=t}dc(t){this.sl=t}Sl(t){this.el=t}El(t){this.il=t}Rl(t){this.rl=t}kl(t){this.nl=t}Pl(t){this.ol=t}Ll(t){this.hl=t}Il(t){this.al=t}zl(t){this.cl=t}Cl(t){var n;if(!this.Pa)return;t.preventDefault(),(n=this.Hc)==null||n.qa(this.yl);const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const a=this.Kc.get(h.id);a&&this.Yc.set(h.id,this.Ol(a)),this.Kc.set(h.id,h);const c={id:h.id,Bl:h,Gl:h,startTime:i,Wl:i,Al:null,Hl:!1};this.ol&&(c.Al=window.setTimeout(()=>{const u=this.Kc.get(h.id);u&&(c.Hl=!0,this.ol({Kl:this.Ol(u),duration:performance.now()-c.startTime,mc:t}))},this.dl)),this.jc.set(h.id,c),this.tl&&this.tl(this.Yl(h,t,void 0,i))}this.Kc.size===2&&this.jl()}$l(t){var n;if(!this.Pa)return;t.preventDefault(),(n=this.Hc)==null||n.qa(this.yl);const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const a=this.Kc.get(h.id),c=a?this.Ol(a):void 0;c&&this.Yc.set(h.id,c),this.Kc.set(h.id,h);const u=this.jc.get(h.id);u&&(u.Gl=h,u.Wl=i,c)&&V(c.clientX,c.clientY,h.clientX,h.clientY)>this.pl&&u.Al!==null&&(window.clearTimeout(u.Al),u.Al=null),this.sl&&this.sl(this.Yl(h,t,c,i))}this.Kc.size===2?this.Nl(t):this.Nc=null}Ml(t){if(!this.Pa)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const h=this.Kc.get(n.id),a=h?this.Ol(h):void 0,c=this.jc.get(n.id);c&&c.Al!==null&&(window.clearTimeout(c.Al),c.Al=null),this.el&&this.el(this.Yl(n,t,a,i)),c&&this.Xl(c,t),this.jc.delete(n.id),this.Yc.delete(n.id),this.Kc.delete(n.id)}this.Kc.size<2&&(this.Nc=null)}xl(t){if(!this.Pa)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const h=this.Kc.get(n.id),a=h?this.Ol(h):void 0,c=this.jc.get(n.id);c&&c.Al!==null&&(window.clearTimeout(c.Al),c.Al=null),this.il&&this.il(this.Yl(n,t,a,i)),this.jc.delete(n.id),this.Yc.delete(n.id),this.Kc.delete(n.id)}this.Kc.size<2&&(this.Nc=null)}Dl(t){const i=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&i.push(this.Zl(n))}return i}Zl(t){return this.Fl(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})}Fl(t,i,r,n){const h=this.th.canvas,a=h.getBoundingClientRect(),c=t-a.left,u=i-a.top,d=h.width/a.width,f=u*(h.height/a.height),p=c*d-this.Pa.offsetX,g=f-this.Pa.offsetY,m=Math.floor(p/this.Pa.nh),v=Math.floor(g/this.Pa.oh),y=m>=0&&m<this.Pa.cols&&v>=0&&v<this.Pa.rows;return{id:r,x:y?m:-1,y:y?v:-1,clientX:t,clientY:i,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Yl(t,i,r,n){const h=this.jc.get(t.id),a=Array.from(this.Yc.values()).map(d=>this.Ol(d)),c=Array.from(this.Kc.values()).map(d=>this.Ol(d)),u=this.Dl(i.changedTouches);return{Kl:this.Ol(t),Vl:r?this.Ol(r):void 0,touches:c,ql:a,changedTouches:u,Jl:h?n-h.Wl:0,mc:i}}jl(){if(this.Kc.size!==2)return void(this.Nc=null);const t=Array.from(this.Kc.values()),[i,r]=t,n=V(i.x,i.y,r.x,r.y),h=xt(i.clientX,i.clientY,r.clientX,r.clientY);this.Nc={sn:[i.id,r.id],Ql:Math.max(n,1e-4),tu:h,su:1,eu:0}}Nl(t){if(this.Nc||this.jl(),!this.Nc)return;const[i,r]=this.Nc.sn,n=this.Kc.get(i),h=this.Kc.get(r);if(!n||!h)return;const a=V(n.x,n.y,h.x,h.y)/this.Nc.Ql,c=a-this.Nc.su;this.al&&Math.abs(c)>this.vl&&(this.al({touches:[this.Ol(n),this.Ol(h)],scale:a,iu:c,ru:this.nu(n,h),mc:t}),this.Nc.su=a);let u=xt(n.clientX,n.clientY,h.clientX,h.clientY)-this.Nc.tu;u=(u+180)%360-180;const d=u-this.Nc.eu;this.cl&&Math.abs(d)>this.ml&&(this.cl({touches:[this.Ol(n),this.Ol(h)],rotation:u,ou:d,ru:this.nu(n,h),mc:t}),this.Nc.eu=u)}nu(t,i){const r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,h=this.Fl(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:h.x,y:h.y}}Xl(t,i){const r=performance.now(),n=r-t.startTime,h=V(t.Bl.clientX,t.Bl.clientY,t.Gl.clientX,t.Gl.clientY);if(!t.Hl&&n<=this.ll&&h<=this.fl)this.hu(t.Gl,r)&&this.nl?this.nl({Kl:this.Ol(t.Gl),au:2,mc:i}):this.rl&&this.rl({Kl:this.Ol(t.Gl),au:1,mc:i});else if(!t.Hl&&n<=this.gl&&h>=this._l){const a={x:t.Gl.clientX-t.Bl.clientX,y:t.Gl.clientY-t.Bl.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},d={x:a.x/n,y:a.y/n};this.hl&&this.hl({Kl:this.Ol(t.Gl),direction:u,cu:c,lu:d,mc:i})}this.wl=r,this.bl=this.Ol(t.Gl)}hu(t,i){return!!this.bl&&!(i-this.wl>this.ul)&&V(t.clientX,t.clientY,this.bl.clientX,this.bl.clientY)<=this.fl}Ol(t){return{...t}}}const Mi=Object.freeze(Object.defineProperty({__proto__:null,uu:Ot},Symbol.toStringTag,{value:"Module"}));class ct extends at{constructor(i,r,n,h,a,c,u,d){const f=a/c;let p,g;f>1?(p=u,g=Math.round(u/f)):(g=d,p=Math.round(d*f));super(i,r,n,a,c,p,g);l(this,"fu");l(this,"du",!1);l(this,"pu",[]);l(this,"ya",null);l(this,"_u",0);l(this,"gu",0);l(this,"vu",-1);this.fu=h}dispose(){super.dispose();for(const i of this.pu)this.m.deleteTexture(i);this.pu=[],this.fu.pause(),this.fu.src="",this.fu.load()}mu(){if(!this.du&&this.fu.readyState>=this.fu.HAVE_CURRENT_DATA){const i=this.m;i.bindTexture(i.TEXTURE_2D,this.Lh),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this.fu),i.bindTexture(i.TEXTURE_2D,null)}}ea(){if(this.du&&this.pu.length>0){const i=this.gu%this.pu.length;return this.pu[i]}return this.Lh}ct(){return this.j=null,super.ct()}Jh(){this.mu()}async yu(i,r){var n;try{if(i<=0)throw new Error("Video preload requires a frameRate greater than 0.");const h=this.fu.duration;if(!isFinite(h)||h<=0)throw new Error("Video duration is invalid, cannot preload frames.");const a=Math.max(1,Math.ceil(h*i));if(this.wu(i,a),await this.bu(i,r))return void this.Cu("captureStream",r);await this.$u(i,r),this.Cu("seeking",r)}catch(h){const a=h instanceof Error?h:new Error(String(h));throw(n=r==null?void 0:r.Mu)==null||n.call(r,a),a}}wu(i,r){this.ya=i,this._u=r,this.pu=[],this.du=!1,this.gu=0,this.vu=-1}Cu(i,r){var n;if(this.pu.length===0)throw new Error(`Video preload via ${i} completed but produced 0 frames.`);this._u=this.pu.length,this.du=!0,this.gu=0,this.vu=-1,this.fu.pause(),this.fu.currentTime=0,r!=null&&r.xu&&r.xu({percent:100,Au:this._u,totalFrames:this._u,Fu:i}),(n=r==null?void 0:r.Uu)==null||n.call(r,{totalFrames:this._u,Fu:i})}Tu(i){const r=this.m,n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),et(r,r.LINEAR,r.LINEAR,r.CLAMP_TO_EDGE,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),r.bindTexture(r.TEXTURE_2D,null),n}Su(i,r){if(!(r!=null&&r.xu)||this._u===0)return;const n=Math.min(99,Math.floor(this.pu.length/this._u*100)),h=10*Math.floor(n/10);h>this.vu&&(this.vu=h,r.xu({percent:n,Au:this.pu.length,totalFrames:this._u,Fu:i}))}async bu(i,r){const n=globalThis,h=n==null?void 0:n.MediaStreamTrackProcessor,a=this.fu.captureStream;if(typeof h!="function"||typeof a!="function")return!1;let c,u=null;try{const d=a.call(this.fu);if(c=d.getVideoTracks()[0],!c)return d.getTracks().forEach(g=>g.stop()),!1;if(u=new h({track:c}).readable.getReader(),this.fu.currentTime=0,this.fu.muted=!0,await this.fu.play().catch(()=>{}),this.fu.paused)return!1;const f=1e6/i;let p=0;for(;this.pu.length<this._u;){const g=await u.read();if(g.done)break;const m=g.value;if(m)try{const v=typeof m.timestamp=="number"?m.timestamp:p;(this.pu.length===0||v>=p)&&(this.pu.push(this.Tu(m)),p=v+f,this.Su("captureStream",r))}finally{m.close()}}return u.releaseLock(),c.stop(),u=null,c=void 0,this.fu.pause(),this.fu.currentTime=0,this.pu.length!==0}catch{return this.pu=[],this.vu=-1,!1}finally{if(u)try{await u.cancel()}catch{}c&&c.stop(),this.fu.pause(),this.fu.currentTime=0}}async $u(i,r){const n=1/i,h=this._u,a=this.fu;a.pause();for(let c=0;c<h;c++){const u=Math.min(a.duration,c*n);await this.Eu(u),this.pu.push(this.Tu(a)),this.Su("seeking",r)}a.currentTime=0}Eu(i){return new Promise((r,n)=>{const h=this.fu,a=()=>{h.removeEventListener("seeked",c),h.removeEventListener("error",u)},c=()=>{a(),r()},u=()=>{a(),n(new Error("Video seek failed while preloading frames."))};h.addEventListener("seeked",c,{once:!0}),h.addEventListener("error",u,{once:!0});const d=isFinite(h.duration)?h.duration:i,f=Math.min(Math.max(i,0),d);if(Math.abs(h.currentTime-f)<1e-4)return a(),void r();h.currentTime=f})}frame(i){return this.du&&i!==void 0&&this._u>0&&(this.gu=(i%this._u+this._u)%this._u,this.j=null),this}static async pa(i,r,n,h,a,c){const u=i.context,d=c==null?void 0:c.Ru;let f;if(typeof r=="string"){if(f=document.createElement("video"),f.crossOrigin="anonymous",f.loop=!0,f.muted=!0,f.playsInline=!0,await new Promise((y,w)=>{f.addEventListener("loadedmetadata",()=>y(),{once:!0}),f.addEventListener("error",b=>{var A;const E=b.target;w(new Error(`Failed to load video: ${((A=E.error)==null?void 0:A.message)||"Unknown error"}`))},{once:!0}),f.src=r}),!d)try{await f.play()}catch(y){console.warn("Video autoplay prevented - you may need to call video.play() after user interaction:",y)}}else f=r,f.readyState<f.HAVE_METADATA&&await new Promise((y,w)=>{f.addEventListener("loadedmetadata",()=>y(),{once:!0}),f.addEventListener("error",b=>{var E;return w(new Error(`Video error: ${(E=b.target.error)==null?void 0:E.message}`))},{once:!0})});const p=u.createTexture();u.bindTexture(u.TEXTURE_2D,p),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),et(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,f),u.bindTexture(u.TEXTURE_2D,null);const g=f.videoWidth,m=f.videoHeight,v=new ct(u,i,p,f,g,m,n,h);return v.Wh=a,d&&d>0&&await v.yu(d,c),v}async play(){await this.fu.play()}pause(){this.fu.pause()}stop(){this.fu.pause(),this.fu.currentTime=0}speed(i){return this.fu.playbackRate=i,this}loop(i=!0){return this.fu.loop=i,this}time(i){return this.fu.currentTime=i,this}volume(i){return this.fu.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.Lh}get width(){return this.O}get height(){return this.B}get Vh(){return this.Ih}get qh(){return this.zh}get ku(){return this.fu}get currentTime(){return this.fu.currentTime}get duration(){return this.fu.duration}get Pu(){return!this.fu.paused&&!this.fu.ended}get Lu(){return this.du}get totalFrames(){return this._u}get Iu(){return this.ya}get zu(){return this.gu}}const _i=o=>class extends o{Du(t,i,r,n){if(C.Ph(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,n);throw new Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.Y.state.Qt(t),this.Y.state.ts(i),this.Y.state.ss(r)}Ou(t){this.Y.state.Qt(t)}Bu(t){this.Y.state.ts(t)}Gu(t){this.Y.state.ss(t)}translate(t=0,i=0,r=0){this.Y.state.es(t,i,r)}Wu(t){this.Y.state.es(t,0,0)}Hu(t){this.Y.state.es(0,t,0)}Ku(t){this.Y.state.es(0,0,t)}push(){this.Y.state.rt()}pop(){this.Y.state.nt()}color(t,i,r,n){if(C.Ph(t))return t;if(typeof t=="string"){const h=Array.from(t);if(h.length===1){const a=h[0],c=this.xo.Co(a);return C.Eh(c)}return C.Sh(t)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?C.Uh(t,i,r,n??255):typeof i=="number"&&r===void 0?C.Th(t,i):C.Th(t,n??255);throw new Error("Unsupported color input passed to color().")}rect(t=1,i=1){this.Y.Sr(t,i)}Yu(){this.Y.Sr(1,1)}line(t,i,r,n){this.Y.Er(t,i,r,n)}ju(t){this.Y.state.qt(t)}background(t,i,r,n=255){const h=this.Du(t,i,r,n);this.Y.zr(h.r,h.g,h.b,h.a)}char(t){if(C.Ph(t)){const r=t.do;return void(r&&this.Y.state.cs(r))}const i=Array.from(t);if(i.length===0)throw new Error("char() requires at least one character.");this.Y.state.cs(this.xo.Co(i[0]))}Nh(t,i,r,n){const h=this.Du(t,i,r,n);this.Y.state.ls(h.r,h.g,h.b,h.a)}Zh(t,i,r,n){const h=this.Du(t,i,r,n);this.Y.state.us(h.r,h.g,h.b,h.a)}flipX(t){this.Y.state.fs(t)}flipY(t){this.Y.state.ds(t)}Kh(t){this.Y.state._s(t)}Pe(t){this.Y.state.ps(t)}clear(){this.Y.zr(0,0,0,0)}ellipse(t,i){this.Y.Rr(t/2,i/2)}Nu(t,i,r,n,h,a){this.Y.kr(t,i,r,n,h,a)}Xu(t,i,r,n,h,a,c,u){this.Y.Pr(t,i,r,n,h,a,c,u)}arc(t,i,r,n){this.Y.Lr(t/2,i/2,r,n)}ki(t){this.Y.Mr(t)}Zu(t,i){this.Y.P(t,i)}Vu(t){this.Y.Ar(t)}qu(t){return this.Y.Fr(t)}createFramebuffer(t){return this.Y.Ir(t.width,t.height,3)}image(t,i,r){this.Y.Ur(t,i,r)}Ju(){this.Y.state.vs(!0)}async Qu(t){if(typeof t!="string")return K.pa(this.Y,t,this.Pa.cols,this.Pa.rows,n=>this.xo.Mo(n));const i=t,r=await new Promise((n,h)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a),a.onerror=c=>h(c),a.src=i});return K.pa(this.Y,r,this.Pa.cols,this.Pa.rows,n=>this.xo.Mo(n))}async tf(t,i){return ct.pa(this.Y,t,this.Pa.cols,this.Pa.rows,r=>this.xo.Mo(r),i)}},Ui=o=>class extends o{async sf(t){return this.xo.Wo(t).then(()=>{const i=this.xo.Zo;this.Pa.rh(i.width,i.height),this.ef.resize(this.Pa.cols,this.Pa.rows),this.Y.Dr(),this.Hc.tc(),this.if.tc()})}fontSize(t){if(!q._(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",$o:t})||this.xo.fontSize===t)return;this.xo.Go(t);const i=this.xo.Zo;this.Pa.rh(i.width,i.height),this.ef.resize(this.Pa.cols,this.Pa.rows),this.Y.Dr(),this.Hc.tc(),this.if.tc()}},Yi=o=>class extends o{get frameCount(){return this.rf.Ra}set frameCount(t){this.rf.Ra=t}Ru(t){return t===void 0?this.rf.Ea:this.rf.Ua(t,()=>this.nf())}hf(){this.rf.Aa()}loop(){this.rf.Fa(()=>this.nf())}af(t=1){if(q._(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",$o:t}))for(let i=0;i<t;i++)this.nf()}cf(){return this.rf.Sa}},Ci=o=>class extends o{constructor(...t){super(...t)}lf(t){this.Hc.lc(t)}uf(t){this.Hc.uc(t)}ff(t){this.Hc.fc(t)}df(t){this.Hc.dc(t)}pf(t){this.Hc._c(t)}get _f(){return this.Hc.gc()}cursor(t){this.Hc.Qa(t)}},Pi=o=>class extends o{constructor(...t){super(...t)}gf(t){this.if.Tl(t)}vf(t){this.if.dc(t)}mf(t){this.if.Sl(t)}yf(t){this.if.El(t)}wf(t){this.if.Rl(t)}bf(t){this.if.kl(t)}Cf(t){this.if.Pl(t)}$f(t){this.if.Ll(t)}Mf(t){this.if.Il(t)}xf(t){this.if.zl(t)}get touches(){return this.if.Ul()}},Di=o=>class extends o{constructor(...t){super(...t)}Af(t){this.Ff.uc(t)}Uf(t){this.Ff.fc(t)}Tf(t){return this.Ff.Sc(t)}get Sf(){return this.Ff.kc()}get Ef(){return this.Ff.Pc()}get Rf(){return this.Ff.Lc()}get kf(){return this.Ff.Ic()}};class Oi{constructor(t){l(this,"Pf");l(this,"Lf",new Map);l(this,"If",[]);l(this,"zf",new Map);l(this,"Df",new Map);this.Pf=t}async Of(t){for(const i of t){if(this.Lf.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.Bf(i.name);try{await i.install(this.Pf,r)}catch(n){throw this.Gf(i.name),n}this.Lf.set(i.name,i),this.If.push(i.name)}}async Wf(t){const i=this.Lf.get(t);if(!i)return;const r=this.Bf(t);i.Hf&&await i.Hf(this.Pf,r),this.Lf.delete(t),this.If.splice(this.If.indexOf(t),1),this.Gf(t)}Kf(){this.Yf(this.zf)}jf(){this.Yf(this.Df)}async Nf(){const t=[...this.Lf.keys()];for(const i of t)await this.Wf(i)}Bf(t){return{Xf:this.Pf.Y,font:this.Pf.xo,grid:this.Pf.Pa,canvas:this.Pf.th,Zf:this.Pf.ef,Vf:this.Pf.qf,Jf:i=>this.Qf(this.zf,t,i),td:i=>this.Qf(this.Df,t,i)}}Qf(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))}}Gf(t){this.zf.delete(t),this.Df.delete(t)}Yf(t){for(const i of this.If){const r=t.get(i);r&&r.forEach(n=>n())}}}const Bt=`#version 300 es
|
|
12
|
+
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class Nt{constructor(){l(this,"sd",new Map);l(this,"ed",[]);l(this,"rd",0);l(this,"nd",0);l(this,"od")}get hd(){return this.rd}get ad(){if(this.rd===0)return 0;let t=0;for(const i of this.ed){const r=this.sd.get(i);r&&(t+=Math.min(1,Math.max(0,r.ad))*r.weight)}return Math.min(1,t/this.rd)}ld(t){this.od=t}ud(t,i=1){const r=`phase-${this.ed.length+1}-${Date.now()}`,n={id:r,label:t,weight:Math.max(.001,i),ad:0,status:"running"};return this.sd.set(r,n),this.ed.push(r),this.rd+=n.weight,r}fd(t,i){const r=this.sd.get(t);if(!r)return;r.ad=Math.max(0,Math.min(1,i)),r.status=r.ad>=1?"complete":"running";const n=this.ad;Math.abs(n-this.nd)>.001&&(this.nd=n,this.od&&this.od(n))}dd(t){const i=this.sd.get(t);i&&(i.ad=1,i.status="complete",this.fd(t,1))}pd(t){const i=this.sd.get(t);i&&(i.status="failed")}_d(){return this.ed.map(t=>{const i=this.sd.get(t);return i?{id:i.id,label:i.label,weight:i.weight,ad:i.ad,status:i.status}:{id:t,label:t,weight:1,ad:0,status:"pending"}})}}class It{constructor(t="active"){l(this,"gd");l(this,"vd","");l(this,"md","");this.gd=t}get state(){return this.gd}get isEnabled(){return this.gd!=="disabled"}get yd(){return this.gd==="active"||this.gd==="transitioning"||this.gd==="error"}get wd(){return this.vd}get bd(){return this.md}Cd(){this.gd!=="done"&&this.gd!=="transitioning"||(this.gd="active")}finish(){this.gd!=="disabled"&&(this.gd="done")}$d(){this.gd!=="disabled"&&(this.gd="transitioning")}Md(){this.gd==="transitioning"&&(this.gd="done")}xd(t){this.gd!=="disabled"&&(this.gd="error",t instanceof Error?(this.vd=t.message,this.md=t.stack||""):(this.vd=t,this.md=""))}disable(){this.gd="disabled"}}class St{constructor(t,i){l(this,"Ad",0);l(this,"Fd",1);l(this,"Ud");l(this,"Td");this.Ud=t,this.Td=i}get opacity(){return this.Fd}get Sd(){return this.Fd<1}start(){this.Ud!=="none"&&this.Td>0&&(this.Ad=performance.now())}update(){if(this.Ud==="none"||this.Td===0)return this.Fd=1,!1;const t=performance.now()-this.Ad,i=Math.min(1,t/this.Td);return i>=1?(this.Fd=0,!0):(this.Fd=1-i,!1)}reset(){this.Fd=1,this.Ad=0}}function bt(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(d=>d/255),u=d=>d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4);return .2126*u(h)+.7152*u(a)+.0722*u(c)}(t)>.5?"light":"dark"),{mode:r,background:t,Ed:r==="light"?"#1A1A1A":"#F8F8F8",Rd:r==="light"?"#4A4A4A":"#C0C0C0"}}function Gt(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function Xt(o,t){return o.length?o.map(i=>t.color(i)):[t.color("#FFFFFF")]}const Bi=({kd:o,grid:t,ad:i,frameCount:r,message:n,palette:h,theme:a,Pd:c,Ld:u,Id:d,wd:f})=>{const p="|/-\\",g=Math.floor(r/6)%4,m=o.color(a.Ed),v=Math.floor(255*u),y=o.color(m.r,m.g,m.b,v);if(o.Nh(y),o.Zh(0,0,0,0),d){const w=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",v);o.Nh(w),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const b="SETUP ERROR",E=-Math.floor(b.length/2);o.push(),o.translate(E,0,0);for(const A of b)o.char(A),o.rect(1,1),o.Wu(1);if(o.pop(),f){const A=o.color(a.Rd),x=o.color(A.r,A.g,A.b,v);o.Nh(x);const T=Math.floor(.8*t.cols),R=f.split(" "),Y=[];let L="";for(const D of R)(L+" "+D).length<=T?L=L?L+" "+D:D:(L&&Y.push(L),L=D);L&&Y.push(L);const B=Y.slice(0,3);Y.length>3&&(B[2]=B[2].substring(0,T-3)+"..."),B.forEach((D,ut)=>{const Ki=-Math.floor(D.length/2);o.push(),o.translate(Ki,3+ut,0);for(const ki of D)o.char(ki),o.rect(1,1),o.Wu(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(p[g]),o.rect(1,1),o.pop(),i>0||c.some(w=>w.status!=="pending")){const w=Math.max(6,Math.floor(.6*t.cols)),b=-Math.floor(w/2),E=Math.floor(w*i),A=h.length?h:[o.color("#FFFFFF")];o.push(),o.translate(b,3,0);for(let x=0;x<w;x++){const T=x<E?"*":".",R=A[x%A.length],Y=o.color(R.r,R.g,R.b,v);o.Nh(Y),o.char(T),o.rect(1,1),o.Wu(1)}o.pop()}if(n){const w=o.color(a.Rd),b=o.color(w.r,w.g,w.b,v);o.Nh(b);const E=-Math.floor(n.toUpperCase().length/2);o.push(),o.translate(E,5,0);for(const A of n.toUpperCase())o.char(A),o.rect(1,1),o.Wu(1);o.pop()}},Ni={message:"loading...",tone:"auto",transition:"fade",transitionDuration:500};class Ii{constructor(t,i,r){this.zd=t,this.id=i,this.label=r}Dd(t){this.zd.fd(this.id,t)}complete(){this.zd.dd(this.id)}Od(t){this.zd.pd(this.id)}async track(t){try{const i=typeof t=="function"?await t():await t;return this.complete(),i}catch(i){throw this.Od(),i}}}class jt{constructor(t,i,r){l(this,"Pf");l(this,"h");l(this,"Bd");l(this,"zd");l(this,"Gd");l(this,"Y");l(this,"Wd",[]);l(this,"Hd");l(this,"Kd",performance.now());l(this,"Xd");this.Pf=t,this.h={...Ni,...i??{}},this.Bd=new It("active"),this.zd=new Nt,this.Gd=new St(this.h.transition,this.h.transitionDuration),this.Hd=bt(this.h,r);const n=Gt(this.Hd);this.Wd=Xt(n,this.Pf),this.Y=this.Yd(),this.zd.ld(h=>{h>=.999&&this.finish()})}get yd(){return this.Bd.yd}get ad(){return this.zd.ad}message(t){return typeof t=="string"&&(this.h.message=t),this.h.message}jd(t,i=1){this.Bd.Cd();const r=this.zd.ud(t,i);return new Ii(this.zd,r,t)}finish(){this.h.transition!=="none"&&this.h.transitionDuration>0?(this.Bd.$d(),this.Gd.start()):(this.Bd.finish(),this.Nd())}Nd(){this.Xd&&this.Xd()}Zd(t){this.Xd=t}error(t){this.Bd.xd(t)}Vd(t){if(!this.yd)return;const i=this.Pf.qd;if(i){if(this.Bd.state==="transitioning"&&this.Gd.update())return this.Bd.Md(),void this.Nd();this.Pf.clear(),this.Pf.push();try{const r={kd:this.Pf,grid:i,ad:this.ad,Jd:performance.now()-this.Kd,frameCount:t,message:this.h.message,palette:this.Wd,theme:this.Hd,Pd:this.zd._d(),Ld:this.Gd.opacity,Id:this.Bd.state==="error",wd:this.Bd.wd||void 0,bd:this.Bd.bd||void 0};this.Y(r)}finally{this.Pf.pop()}}}Qd(t){this.Hd=bt(this.h,t)}Yd(){const t=this.h.Xf||Bi;return i=>{t(i),this.tp(i)}}tp(t){const{kd:i,grid:r,frameCount:n,theme:h,Ld:a}=t,c=[116,101,120,116,109,111,100,101,46,106,115].map(p=>String.fromCharCode(p)).join(""),u=(r.rows+1>>1)-2,d=2-(r.cols+1>>1),f=h.mode==="light"?[[255,107,107],[78,205,196],[69,183,209],[255,160,122],[152,216,200]]:[[255,107,157],[199,128,250],[78,205,196],[255,217,61],[107,207,127]];i.push(),i.translate(d,u,0);for(let p=0;p<c.length;p++){const g=c[p],m=Math.floor(.1*n+.5*p)%f.length,[v,y,w]=f[m],b=Math.floor(255*a),E=i.color(v,y,w,b);i.Nh(E),i.char(g),i.rect(1,1),i.Wu(1)}i.pop()}}class Ht extends function(i,...r){return r.reduce((n,h)=>h(n),i)}(class{},_i,Ui,Yi,Ci,Pi,Di){constructor(i={}){super();l(this,"Y");l(this,"xo");l(this,"sp");l(this,"th");l(this,"Pa");l(this,"qd");l(this,"rf");l(this,"Hc");l(this,"if");l(this,"Ff");l(this,"ef");l(this,"ep");l(this,"ip");l(this,"qf");l(this,"rp");l(this,"np");l(this,"op");l(this,"hp");l(this,"ap",!1);l(this,"cp",!1);l(this,"lp",!1);l(this,"up",!1);l(this,"fp",()=>{});l(this,"dp",()=>{});l(this,"pp",()=>{});l(this,"_p");l(this,"gp");l(this,"ah",!1);l(this,"vp");this.op=new Oi(this),this.ah=i.fh??!1,this.th=new Ct(i),this.Y=new oi(this.th.bh()),this.xo=new yt(this.Y,i.fontSize??16),this.sp=new yt(this.Y,16),this.rf=new Ri(i.Ru??60),this.hp=new jt(this,i.mp,this.th.yh()),this.hp.Zd(()=>{this.rf.Ra=0,this.up=!0}),this.Hc=new Pt(this.th),this.if=new Ot(this.th,this.Hc),this.Ff=new Dt,this.ip=this.Y.$r(Bt,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U2;uniform vec2 U5;uniform vec2 U6;uniform vec4 U8;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/U6;vec2 F=E*U5;vec2 G=floor(F);vec2 H=(G+0.5)/U5;vec4 I=texture(U3,H);vec4 J=texture(U4,H);vec4 K=texture(U2,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(U1.x);int R=P/Q;int S=P-(R*Q);float T=(U1.y-1.)-float(R);vec2 U=1./U1;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(U0,a);if(M)c.rgb=mix(c.rgb,1.-c.rgb,float(M));vec4 d=mix(U8,J,J.a);fragColor=mix(d,I,c);}`),this.yp(i)}async yp(i){await Promise.all([this.xo.Do(i.wp),this.sp.Do(i.wp)]);const r=this.xo.Zo;this.Pa=new Et(this.th.canvas,r.width,r.height);const n=this.sp.Zo;this.qd=new Et(this.th.canvas,n.width,n.height),this.Hc.Do(this.Pa),this.if.Do(this.Pa),this.ef=this.Y.Ir(this.Pa.cols,this.Pa.rows,3),this.ep=this.Y.Ir(this.qd.cols,this.qd.rows,3),this.qf=this.Y.Ir(this.Pa.width,this.Pa.height,1),this.rp=this.Y.Ir(this.qd.width,this.qd.height,1),this.ah&&(this.vp=K.pa(this.Y,this.th.xh,this.Pa.cols,this.Pa.rows,h=>this.xo.Mo(h))),this.np=this.Y.$r(Bt,`#version 300 es
|
|
14
|
+
precision highp float;uniform sampler2D U9;uniform vec2 Ua;uniform vec2 Ub;uniform vec2 Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-Ub;vec2 B=A*(Ua/Uc);vec2 C=(floor(B)+0.5)/Ua;fragColor=texture(U9,C);}`),this.bp(),this.rf.Ma(()=>this.nf()),await this.op.Of(i.plugins??[]);try{await this.fp(),this.hp.finish()}catch(h){console.error("Error during setup:",h),this.hp.error(h)}}bp(){this._p=()=>{this.ah&&this.Cp(this.th.xh.width,this.th.xh.height),this.pp()},window.addEventListener("resize",this._p),this.Hc.sc(),this.if.sc(),this.Ff.sc(),window.addEventListener("blur",()=>{this.Ff.Oc()}),this.ah&&(this.gp=new ResizeObserver(()=>{this.Cp(this.th.xh.width,this.th.xh.height)}),this.gp.observe(this.th.xh))}nf(){this.cp=!0;try{this.rf.Ta(),this.rf.ka(),this.ah&&Rt(this.Y.context,this.vp.texture,this.th.xh);const i=this.hp.yd,r=this.up&&!i;r&&this.op.Kf(),this.Y.state.Jt();const n=i?this.ep:this.ef,h=i?this.sp:this.xo,a=i?this.qd:this.Pa,c=i?this.rp:this.qf;n.st(),i?this.hp.Vd(this.rf.Ra):r&&this.dp(),n.end(),c.st(),this.Y.Cr(this.ip),this.ip.k({$p:h.Yo,Mp:[h.No,h.Xo],xp:n.L[0],Ap:n.L[1],Fp:n.L[2],Up:[a.cols,a.rows],Tp:[c.width,c.height],Li:c.width/c.height,Sp:this.Y.state.ys}),this.Y.Tr(0,0,this.th.width,this.th.height),c.end(),this.Y.cr(...this.Y.state.ys),this.Y.Cr(this.np),this.np.k({Ep:c.L[0],Rp:[c.width,c.height],kp:[a.offsetX,a.offsetY],Pp:[a.width,a.height]}),this.Y.Tr(a.offsetX,a.offsetY,a.width,a.height),r&&this.op.jf()}finally{this.cp=!1,this.ap&&!this.lp&&this.Lp()}}Cp(i,r){this.th.wh(i,r),this.hp.Qd(this.th.yh()),this.Pa.ih(),this.qd.ih(),this.ef.resize(this.Pa.cols,this.Pa.rows),this.qf.resize(this.Pa.width,this.Pa.height),this.ep.resize(this.qd.cols,this.qd.rows),this.rp.resize(this.qd.width,this.qd.height),this.Y.Dr(),this.Hc.tc(),this.if.tc(),this.nf()}destroy(){this.lp||this.ap||(this.ap=!0,this.rf.Aa(),this.cp||this.Lp())}Lp(){var i,r;this.ap=!1,this.op.Nf(),window.removeEventListener("resize",this._p),(i=this.gp)==null||i.disconnect(),this.Hc.cc(),this.if.cc(),this.Ff.cc(),this.ef.D(),this.ep.D(),this.ip.D(),this.xo.D(),this.sp.D(),this.Y.D(),this.qf.D(),this.rp.D(),this.np.D(),(r=this.vp)==null||r.dispose(),this.th.D(),this.lp=!0}Ip(i){this.fp=i}draw(i){this.dp=i}zp(i){this.pp=i}get grid(){return this.Pa}get font(){return this.xo}get width(){return this.th.width}get height(){return this.th.height}get canvas(){return this.th.canvas}get Zf(){return this.ef}get Dp(){return this.lp}get fh(){return this.vp}get loading(){return this.hp}}class lt{constructor(){}static create(t={}){return new Ht(t)}static Op(t){q.v(t)}static get version(){return"0.6.0-beta.1"}}const Si=Object.freeze(Object.defineProperty({__proto__:null,Bp:Nt,Gp:jt,Wp:It,Hp:St,Kp:Xt,Yp:Gt,jp:bt},Symbol.toStringTag,{value:"Module"})),Gi=Object.freeze(Object.defineProperty({__proto__:null,Np:yt,Xp:K,Zp:ct},Symbol.toStringTag,{value:"Module"})),Xi=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Li,_f:Fi,Kl:Mi},Symbol.toStringTag,{value:"Module"})),ji=lt.create,Hi=lt.Op,zi=lt.version;M.Vp=Ct,M.qp=C,M.Jp=S,M.Qp=Z,M.t_=Et,M.s_=Ht,M.create=ji,M.input=Xi,M.e_=Gi,M.loading=Si,M.Op=Hi,M.i_=lt,M.version=zi,Object.defineProperty(M,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).i_={});
|
package/dist/types/Textmode.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TextmodeErrorLevel } from './errors';
|
|
2
|
-
import { Textmodifier
|
|
2
|
+
import { Textmodifier } from './textmode/Textmodifier';
|
|
3
|
+
import type { TextmodeOptions } from './textmode/types';
|
|
3
4
|
/**
|
|
4
5
|
* The main entry point for the `textmode.js` library.
|
|
5
6
|
*
|
|
@@ -12,27 +13,17 @@ export declare class Textmode {
|
|
|
12
13
|
* @param opts Configuration options for the Textmodifier instance
|
|
13
14
|
* @returns A new Textmodifier instance
|
|
14
15
|
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* textmodifier.background(128);
|
|
27
|
-
* textmodifier.rect(10, 10, 20, 20);
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Create with options
|
|
31
|
-
* const textmodifier2 = textmode.create({ width: 1920, height: 1080 });
|
|
32
|
-
*
|
|
33
|
-
* // Create with canvas and options
|
|
34
|
-
* const textmodifier3 = textmode.create({ canvas: canvas, fontSize: 20 });
|
|
35
|
-
* ```
|
|
16
|
+
* @example
|
|
17
|
+
* ```javascript
|
|
18
|
+
* const t = textmode.create({ width: 800, height: 600, fontSize: 16 });
|
|
19
|
+
*
|
|
20
|
+
* t.draw(() => {
|
|
21
|
+
* t.background(0);
|
|
22
|
+
* t.char("x");
|
|
23
|
+
* t.rotateZ(t.frameCount);
|
|
24
|
+
* t.rect(10, 10);
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
36
27
|
*/
|
|
37
28
|
static create(opts?: TextmodeOptions): Textmodifier;
|
|
38
29
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Textmode } from './Textmode';
|
|
2
2
|
export { Textmodifier } from './textmode/Textmodifier';
|
|
3
|
-
export { TextmodeFont } from './textmode/font';
|
|
4
3
|
export { GLFramebuffer as TextmodeFramebuffer } from './rendering';
|
|
5
|
-
export {
|
|
4
|
+
export { TextmodeColor } from './textmode/TextmodeColor';
|
|
6
5
|
export { TextmodeCanvas } from './textmode/Canvas';
|
|
7
6
|
export { TextmodeGrid } from './textmode/Grid';
|
|
8
|
-
export type { TextmodeOptions } from './textmode/
|
|
9
|
-
export type { TextmodeFramebufferOptions } from './
|
|
10
|
-
export type {
|
|
11
|
-
export type { TextmodePlugin, TextmodePluginAPI, } from './textmode/plugins/PluginManager';
|
|
7
|
+
export type { TextmodeOptions } from './textmode/types';
|
|
8
|
+
export type { TextmodeFramebufferOptions } from './rendering/webgl';
|
|
9
|
+
export type { TextmodePlugin, TextmodePluginAPI, } from './textmode/managers/PluginManager';
|
|
12
10
|
export { TextmodeErrorLevel } from './errors/ErrorHandler';
|
|
13
11
|
export { Textmode as textmode } from './Textmode';
|
|
12
|
+
/** All loading screen related modules and types. */
|
|
13
|
+
export * as loading from './textmode/loading';
|
|
14
|
+
/** All loadable assets related to textmode rendering. */
|
|
15
|
+
export * as loadables from './textmode/loadables';
|
|
14
16
|
/** All types and interfaces related to input event handling. */
|
|
15
17
|
export * as input from './textmode/managers';
|
|
16
18
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { GLShader as Shader } from './webgl/Shader';
|
|
2
|
-
export { GLRenderer } from './webgl/Renderer';
|
|
3
|
-
export { GLFramebuffer } from './webgl/Framebuffer';
|
|
1
|
+
export { GLShader as Shader } from './webgl/core/Shader';
|
|
2
|
+
export { GLRenderer } from './webgl/core/Renderer';
|
|
3
|
+
export { GLFramebuffer } from './webgl/core/Framebuffer';
|