msdfgen-ts 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -4
- package/dist/atlas-worker.js +1380 -1117
- package/dist/msdfgen-ts.iife.js +3 -2
- package/dist/msdfgen-ts.js +2020 -1402
- package/dist/types/atlas-gen.d.ts +51 -25
- package/dist/types/font/tables/glyf.d.ts +3 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/msdf/shape-msdf.d.ts +51 -0
- package/dist/types/shape/normalize.d.ts +12 -1
- package/dist/types/shape/union.d.ts +58 -0
- package/dist/types/svg/svg.d.ts +78 -0
- package/package.json +38 -18
package/dist/msdfgen-ts.iife.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
var MsdfgenTs=(function(At){"use strict";function so(e,n,t,s){return e*t+n*s}function J(e,n,t,s){return e*s-n*t}function oo(e,n,t){return(1-t)*e+t*n}function rt(e){return+(e>0)-+(e<0)}function Et(e){return 2*+(e>0)-1}function Zn(e,n,t,s){if(n===0||Math.abs(t)>1e12*Math.abs(n))return t===0?s===0?-1:0:(e[0]=-s/t,1);const i=t*t-4*n*s;if(i>0){const o=Math.sqrt(i);return e[0]=(-t+o)/(2*n),e[1]=(-t-o)/(2*n),2}else if(i===0)return e[0]=-t/(2*n),1;return 0}function io(e,n,t,s){const i=n*n,o=1/9*(i-3*t),l=1/54*(n*(2*i-9*t)+27*s),c=l*l,r=o*o*o,h=n*(1/3);if(c<r){let p=l/Math.sqrt(r);p<-1&&(p=-1),p>1&&(p=1),p=Math.acos(p);const a=-2*Math.sqrt(o);return e[0]=a*Math.cos(.3333333333333333*p)-h,e[1]=a*Math.cos(.3333333333333333*(p+2*Math.PI))-h,e[2]=a*Math.cos(.3333333333333333*(p-2*Math.PI))-h,3}else{const p=(l<0?1:-1)*Math.pow(Math.abs(l)+Math.sqrt(c-r),.3333333333333333),a=p===0?0:o/p;return e[0]=p+a-h,p===a||Math.abs(p-a)<1e-12*Math.abs(p+a)?(e[1]=-.5*(p+a)-h,2):1}}function eo(e,n,t,s,i){if(n!==0){const o=t/n;if(Math.abs(o)<1e6)return io(e,o,s/n,i/n)}return Zn(e,t,s,i)}const co=24;function St(e,n,t,s){return((s+e)*s+n)*s+t}function ro(e,n,t,s,i,o,l){const c=o<0;let r=s-o*(i-s)/(l-o);r>s&&r<i||(r=.5*(s+i));for(let h=0;h<co;h++){const p=St(e,n,t,r);if(p===0)return r;p<0===c?s=r:i=r;const a=(3*r+2*e)*r+n;let f=r-p/a;f>s&&f<i||(f=.5*(s+i));const y=f-r;if(r=f,(y<0?-y:y)<=1e-15*(r<0?-r:r))break}return r}function Ut(e,n,t,s,i,o,l,c,r){return o===0?c[r++]=s:o<0!=l<0&&(c[r++]=ro(e,n,t,s,i,o,l)),r}function ao(e,n,t,s,i,o){let l=0;if(e===0){if(n===0)return 0;const f=-t/n;return f>=s&&f<=i&&(o[l++]=f),l}const c=n*n-4*e*t;if(c<0)return 0;const r=Math.sqrt(c),h=-.5*(n+(n<0?-r:r));let p,a;if(h===0)p=0,a=0;else if(p=h/e,a=t/h,p>a){const f=p;p=a,a=f}return p>=s&&p<=i&&(o[l++]=p),a!==p&&a>=s&&a<=i&&(o[l++]=a),l}function ho(e,n,t,s,i,o,l){if(e===0)return ao(n,t,s,i,o,l);const c=1/e;n*=c,t*=c,s*=c;const r=St(n,t,s,i),h=St(n,t,s,o),p=n*n-3*t;let a=0;if(p<=0)a=Ut(n,t,s,i,o,r,h,l,0);else{const f=Math.sqrt(p)/3,y=-n/3,_=y-f,u=y+f;let x=i,M=r;if(_>i&&_<o){const w=St(n,t,s,_);a=Ut(n,t,s,x,_,M,w,l,a),x=_,M=w}if(u>i&&u<o){const w=St(n,t,s,u);a=Ut(n,t,s,x,u,M,w,l,a),x=u,M=w}a=Ut(n,t,s,x,o,M,h,l,a)}return h===0&&(l[a++]=o),a}const ot=0,tt=1,It=2,jn=4,lo=4,U=[0,0,0];class nt{constructor(n,t,s,i,o,l,c,r,h){this.type=n,this.p0x=t,this.p0y=s,this.p1x=i,this.p1y=o,this.p2x=l,this.p2y=c,this.p3x=r,this.p3y=h,this.color=7}endX(){switch(this.type){case ot:return this.p1x;case tt:return this.p2x;default:return this.p3x}}endY(){switch(this.type){case ot:return this.p1y;case tt:return this.p2y;default:return this.p3y}}point(n,t){const s=n;switch(this.type){case ot:{t[0]=this.p0x+s*(this.p1x-this.p0x),t[1]=this.p0y+s*(this.p1y-this.p0y);return}case tt:{const i=this.p0x+s*(this.p1x-this.p0x),o=this.p0y+s*(this.p1y-this.p0y),l=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y);t[0]=i+s*(l-i),t[1]=o+s*(c-o);return}default:{const i=this.p0x+s*(this.p1x-this.p0x),o=this.p0y+s*(this.p1y-this.p0y),l=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y),r=this.p2x+s*(this.p3x-this.p2x),h=this.p2y+s*(this.p3y-this.p2y),p=i+s*(l-i),a=o+s*(c-o),f=l+s*(r-l),y=c+s*(h-c);t[0]=p+s*(f-p),t[1]=a+s*(y-a);return}}}direction(n,t){const s=n;switch(this.type){case ot:{t[0]=this.p1x-this.p0x,t[1]=this.p1y-this.p0y;return}case tt:{const i=this.p1x-this.p0x+s*(this.p2x-this.p1x-(this.p1x-this.p0x)),o=this.p1y-this.p0y+s*(this.p2y-this.p1y-(this.p1y-this.p0y));i!==0||o!==0?(t[0]=i,t[1]=o):(t[0]=this.p2x-this.p0x,t[1]=this.p2y-this.p0y);return}default:{const i=this.p1x-this.p0x,o=this.p1y-this.p0y,l=this.p2x-this.p1x,c=this.p2y-this.p1y,r=this.p3x-this.p2x,h=this.p3y-this.p2y,p=i+s*(l-i)+s*(l+s*(r-l)-(i+s*(l-i))),a=o+s*(c-o)+s*(c+s*(h-c)-(o+s*(c-o)));p!==0||a!==0?(t[0]=p,t[1]=a):s===0?(t[0]=this.p2x-this.p0x,t[1]=this.p2y-this.p0y):s===1?(t[0]=this.p3x-this.p1x,t[1]=this.p3y-this.p1y):(t[0]=p,t[1]=a);return}}}splitInThirds(){const n=[0,0],t=[0,0];switch(this.type){case ot:{this.point(.3333333333333333,n),this.point(.6666666666666666,t);const s=new nt(ot,this.p0x,this.p0y,n[0],n[1],0,0,0,0),i=new nt(ot,n[0],n[1],t[0],t[1],0,0,0,0),o=new nt(ot,t[0],t[1],this.p1x,this.p1y,0,0,0,0);return s.color=i.color=o.color=this.color,[s,i,o]}case tt:{this.point(.3333333333333333,n),this.point(.6666666666666666,t);const s=this.p0x+1/3*(this.p1x-this.p0x),i=this.p0y+1/3*(this.p1y-this.p0y),o=this.p0x+5/9*(this.p1x-this.p0x),l=this.p0y+5/9*(this.p1y-this.p0y),c=this.p1x+4/9*(this.p2x-this.p1x),r=this.p1y+4/9*(this.p2y-this.p1y),h=o+.5*(c-o),p=l+.5*(r-l),a=this.p1x+2/3*(this.p2x-this.p1x),f=this.p1y+2/3*(this.p2y-this.p1y),y=new nt(tt,this.p0x,this.p0y,s,i,n[0],n[1],0,0),_=new nt(tt,n[0],n[1],h,p,t[0],t[1],0,0),u=new nt(tt,t[0],t[1],a,f,this.p2x,this.p2y,0,0);return y.color=_.color=u.color=this.color,[y,_,u]}default:{this.point(.3333333333333333,n),this.point(.6666666666666666,t);const s=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0x:this.p0x+1/3*(this.p1x-this.p0x),i=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0y:this.p0y+1/3*(this.p1y-this.p0y),o=this.p0x+1/3*(this.p1x-this.p0x),l=this.p0y+1/3*(this.p1y-this.p0y),c=this.p1x+1/3*(this.p2x-this.p1x),r=this.p1y+1/3*(this.p2y-this.p1y),h=this.p2x+1/3*(this.p3x-this.p2x),p=this.p2y+1/3*(this.p3y-this.p2y),a=o+1/3*(c-o),f=l+1/3*(r-l),y=c+1/3*(h-c),_=r+1/3*(p-r),u=a+2/3*(y-a),x=f+2/3*(_-f),M=this.p0x+2/3*(this.p1x-this.p0x),w=this.p0y+2/3*(this.p1y-this.p0y),v=this.p1x+2/3*(this.p2x-this.p1x),C=this.p1y+2/3*(this.p2y-this.p1y),A=this.p2x+2/3*(this.p3x-this.p2x),D=this.p2y+2/3*(this.p3y-this.p2y),I=M+2/3*(v-M),L=w+2/3*(C-w),m=v+2/3*(A-v),b=C+2/3*(D-C),N=I+1/3*(m-I),R=L+1/3*(b-L),q=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3x:this.p2x+2/3*(this.p3x-this.p2x),P=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3y:this.p2y+2/3*(this.p3y-this.p2y),X=new nt(It,this.p0x,this.p0y,s,i,a,f,n[0],n[1]),$=new nt(It,n[0],n[1],u,x,N,R,t[0],t[1]),V=new nt(It,t[0],t[1],m,b,q,P,this.p3x,this.p3y);return X.color=$.color=V.color=this.color,[X,$,V]}}}signedDistance(n,t,s){switch(this.type){case ot:{const i=this.p0x,o=this.p0y,l=this.p1x,c=this.p1y,r=n-i,h=t-o,p=l-i,a=c-o,f=p*p+a*a,y=(r*p+h*a)/f,_=y>.5,u=(_?l:i)-n,x=(_?c:o)-t,M=Math.sqrt(u*u+x*x);if(y>0&&y<1){const C=Math.sqrt(p*p+a*a),A=p/C,I=a/C*r-A*h;if(Math.abs(I)<M){s.distance=I,s.dot=0,s.param=y;return}}const w=r*a-h*p;s.distance=Et(w)*M;const v=Math.sqrt(p*p+a*a);s.dot=M===0||v===0?0:Math.abs((p*u+a*x)/(v*M)),s.param=y;return}case tt:{const i=this.p0x,o=this.p0y,l=this.p1x,c=this.p1y,r=this.p2x,h=this.p2y,p=i-n,a=o-t,f=l-i,y=c-o,_=r-l-f,u=h-c-y,x=_*_+u*u,M=3*(f*_+y*u),w=2*(f*f+y*y)+(p*_+a*u),v=p*f+a*y,C=ho(x,M,w,v,0,1,U);let A=f,D=y;const I=p*p+a*a;let L=Et(A*a-D*p),m=I,b=-(p*A+a*D)/(A*A+D*D);{const R=r-n,q=h-t,P=R*R+q*q;P<m&&(A=r-l,D=h-c,L=Et(A*q-D*R),m=P,b=((n-l)*A+(t-c)*D)/(A*A+D*D))}for(let R=0;R<C;++R){const q=U[R];if(q>0&&q<1){const P=p+2*q*f+q*q*_,X=a+2*q*y+q*q*u,$=P*P+X*X;if($<=m){const V=f+q*_,et=y+q*u;L=Et(V*X-et*P),m=$,b=q}}}const N=L*Math.sqrt(m);if(b>=0&&b<=1){s.distance=N,s.dot=0,s.param=b;return}if(s.distance=N,s.param=b,b<.5){const R=Math.sqrt(f*f+y*y),q=Math.sqrt(I);s.dot=q===0||R===0?0:Math.abs((f*p+y*a)/(R*q))}else{const R=r-l,q=h-c,P=r-n,X=h-t,$=Math.sqrt(R*R+q*q),V=Math.sqrt(P*P+X*X);s.dot=$===0||V===0?0:Math.abs((R*P+q*X)/($*V))}return}default:{const i=this.p0x,o=this.p0y,l=this.p1x,c=this.p1y,r=this.p2x,h=this.p2y,p=this.p3x,a=this.p3y,f=i-n,y=o-t,_=l-i,u=c-o,x=r-l-_,M=h-c-u,w=p-r-(r-l)-x,v=a-h-(h-c)-M;let C=_,A=u;C===0&&A===0&&(C=r-i,A=h-o);const D=Math.sqrt(f*f+y*y);let I=Et(C*y-A*f)*D,L=-(f*C+y*A)/(C*C+A*A);{const m=p-n,b=a-t,N=Math.sqrt(m*m+b*b);if(N<Math.abs(I)){let R=p-r,q=a-h;R===0&&q===0&&(R=p-l,q=a-c),C=R,A=q,I=Et(C*b-A*m)*N,L=((C-m)*C+(A-b)*A)/(C*C+A*A)}}for(let m=0;m<=jn;++m){let b=1/jn*m,N=f+3*b*_+3*b*b*x+b*b*b*w,R=y+3*b*u+3*b*b*M+b*b*b*v,q=3*_+6*b*x+3*b*b*w,P=3*u+6*b*M+3*b*b*v,X=6*x+6*b*w,$=6*M+6*b*v,V=b-(N*q+R*P)/(q*q+P*P+(N*X+R*$));if(V>0&&V<1){let et=lo;do{if(b=V,N=f+3*b*_+3*b*b*x+b*b*b*w,R=y+3*b*u+3*b*b*M+b*b*b*v,q=3*_+6*b*x+3*b*b*w,P=3*u+6*b*M+3*b*b*v,!--et)break;X=6*x+6*b*w,$=6*M+6*b*v,V=b-(N*q+R*P)/(q*q+P*P+(N*X+R*$))}while(V>0&&V<1);const H=Math.sqrt(N*N+R*R);H<Math.abs(I)&&(I=Et(q*R-P*N)*H,L=b)}}if(L>=0&&L<=1){s.distance=I,s.dot=0,s.param=L;return}if(s.distance=I,s.param=L,L<.5){let m=_,b=u;m===0&&b===0&&(m=r-i,b=h-o);const N=Math.sqrt(m*m+b*b);s.dot=D===0||N===0?0:Math.abs((m*f+b*y)/(N*D))}else{let m=p-r,b=a-h;m===0&&b===0&&(m=p-l,b=a-c);const N=p-n,R=a-t,q=Math.sqrt(m*m+b*b),P=Math.sqrt(N*N+R*R);s.dot=q===0||P===0?0:Math.abs((m*N+b*R)/(q*P))}return}}}scanlineIntersections(n,t,s){switch(this.type){case ot:{const i=this.p0y,o=this.p1y;if(n>=i&&n<o||n>=o&&n<i){const l=(n-i)/(o-i);return t[0]=oo(this.p0x,this.p1x,l),s[0]=rt(o-i),1}return 0}case tt:{const i=this.p0x,o=this.p0y,l=this.p1x,c=this.p1y,r=this.p2x,h=this.p2y;let p=0,a=n>o?1:-1;t[p]=i,o===n&&(o<c||o===c&&o<h?s[p++]=1:a=1);{const f=l-i,y=c-o,_=r-l-f,u=h-c-y,x=Zn(U,u,2*y,o-n);if(x>=2&&U[0]>U[1]){const M=U[0];U[0]=U[1],U[1]=M}for(let M=0;M<x&&p<2;++M){const w=U[M];w>=0&&w<=1&&(t[p]=i+2*w*f+w*w*_,a*(y+w*u)>=0&&(s[p++]=a,a=-a))}}return h===n&&(a>0&&p>0&&(--p,a=-1),(h<c||h===c&&h<o)&&p<2&&(t[p]=r,a<0&&(s[p++]=-1,a=1))),a!==(n>=h?1:-1)&&(p>0?--p:(Math.abs(h-n)<Math.abs(o-n)&&(t[p]=r),s[p++]=a)),p}default:{const i=this.p0x,o=this.p0y,l=this.p1x,c=this.p1y,r=this.p2x,h=this.p2y,p=this.p3x,a=this.p3y;let f=0,y=n>o?1:-1;t[f]=i,o===n&&(o<c||o===c&&(o<h||o===h&&o<a)?s[f++]=1:y=1);{const _=p-3*r+3*l-i,u=a-3*h+3*c-o,x=3*r-6*l+3*i,M=3*h-6*c+3*o,w=3*l-3*i,v=3*c-3*o,C=eo(U,u,M,v,o-n);if(C>=2){if(U[0]>U[1]){const A=U[0];U[0]=U[1],U[1]=A}if(C>=3&&U[1]>U[2]){const A=U[1];if(U[1]=U[2],U[2]=A,U[0]>U[1]){const D=U[0];U[0]=U[1],U[1]=D}}}for(let A=0;A<C&&f<3;++A){const D=U[A];D>=0&&D<=1&&(t[f]=((_*D+x)*D+w)*D+i,y*((3*u*D+2*M)*D+v)>=0&&(s[f++]=y,y=-y))}}return a===n&&(y>0&&f>0&&(--f,y=-1),(a<h||a===h&&(a<c||a===c&&a<o))&&f<3&&(t[f]=p,y<0&&(s[f++]=-1,y=1))),y!==(n>=a?1:-1)&&(f>0?--f:(Math.abs(a-n)<Math.abs(o-n)&&(t[f]=p),s[f++]=y)),f}}}convertToCubic(){const n=this.p0x+.6666666666666666*(this.p1x-this.p0x),t=this.p0y+2/3*(this.p1y-this.p0y),s=this.p1x+1/3*(this.p2x-this.p1x),i=this.p1y+1/3*(this.p2y-this.p1y),o=new nt(It,this.p0x,this.p0y,n,t,s,i,this.p2x,this.p2y);return o.color=this.color,o}}class ut{constructor(n,t=0){this._view=new DataView(n),this._pos=t}get pos(){return this._pos}seek(n){this._pos=n}skip(n){this._pos+=n}u8(){return this._view.getUint8(this._pos++)}u16(){const n=this._view.getUint16(this._pos,!1);return this._pos+=2,n}i16(){const n=this._view.getInt16(this._pos,!1);return this._pos+=2,n}u32(){const n=this._view.getUint32(this._pos,!1);return this._pos+=4,n}i32(){const n=this._view.getInt32(this._pos,!1);return this._pos+=4,n}f2dot14(){return this.i16()/16384}offset16(){return this.u16()}offset32(){return this.u32()}peekU16(n){return this._view.getUint16(n,!1)}peekU32(n){return this._view.getUint32(n,!1)}peekI16(n){return this._view.getInt16(n,!1)}}function po(e,n){const t=new ut(e,n);t.skip(2);const s=t.u16();let i=null;for(let l=0;l<s;l++){const c=t.u16(),r=t.u16(),h=t.u32(),p=n+h,a=t.peekU16(p);let f=-1;c===3&&r===10&&a===12?f=5:c===0&&r===6&&a===12?f=4:c===0&&r===4&&a===12?f=3:c===3&&r===1&&a===4?f=2:c===0&&r<=3&&a===4&&(f=1),f>((i==null?void 0:i.priority)??-1)&&(i={priority:f,subtableAbsOffset:p})}if(!i)return()=>0;const o=t.peekU16(i.subtableAbsOffset);return o===12?fo(e,i.subtableAbsOffset):o===4?yo(e,i.subtableAbsOffset):()=>0}function fo(e,n){const t=new ut(e,n);t.skip(2),t.skip(2),t.skip(4),t.skip(4);const s=t.u32(),i=new Uint32Array(s),o=new Uint32Array(s),l=new Uint32Array(s);for(let c=0;c<s;c++)i[c]=t.u32(),o[c]=t.u32(),l[c]=t.u32();return c=>{let r=0,h=s-1;for(;r<=h;){const p=r+h>>>1,a=i[p]??0,f=o[p]??0;if(c<a)h=p-1;else if(c>f)r=p+1;else return(l[p]??0)+(c-a)}return 0}}function yo(e,n){const t=new ut(e,n);t.skip(2),t.skip(2),t.skip(2);const i=t.u16()>>>1;t.skip(6);const o=new Uint16Array(i);for(let a=0;a<i;a++)o[a]=t.u16();t.skip(2);const l=new Uint16Array(i);for(let a=0;a<i;a++)l[a]=t.u16();const c=new Int16Array(i);for(let a=0;a<i;a++)c[a]=t.i16();const r=new Int32Array(i),h=new Uint16Array(i);for(let a=0;a<i;a++)r[a]=t.pos,h[a]=t.u16();const p=new DataView(e);return a=>{if(a>65535)return 0;let f=0,y=i-1;for(;f<=y;){const _=f+y>>>1,u=o[_]??0;if(a>u)f=_+1;else if(a<(l[_]??0))y=_-1;else{if((o[_]??0)===65535)return 0;const M=h[_]??0,w=c[_]??0,v=l[_]??0;if(M===0)return a+w&65535;const C=(r[_]??0)+M+(a-v)*2,A=p.getUint16(C,!1);return A===0?0:A+w&65535}}return 0}}function uo(e,n){const t=new ut(e,n);t.skip(4),t.skip(4),t.skip(4),t.skip(4),t.skip(2);const s=t.u16();t.skip(16),t.skip(8),t.skip(2),t.skip(2),t.skip(2);const i=t.i16();return{unitsPerEm:s,indexToLocFormat:i}}function _o(e,n){const t=new ut(e,n);t.skip(4);const s=t.i16(),i=t.i16(),o=t.i16();t.skip(2),t.skip(2),t.skip(2),t.skip(2),t.skip(2),t.skip(2),t.skip(2),t.skip(8),t.skip(2);const l=t.u16();return{ascender:s,descender:i,lineGap:o,numberOfHMetrics:l}}function xo(e,n,t,s){const i=new ut(e,n),o=new Array(t);let l=0;for(let c=0;c<s;c++){const r=i.u16(),h=i.i16();o[c]={advanceWidth:r,lsb:h},l=r}for(let c=s;c<t;c++){const r=i.i16();o[c]={advanceWidth:l,lsb:r}}return o}function Mo(e,n,t,s){const i=new ut(e,n),o=t+1,l=new Array(o);if(s===0)for(let c=0;c<o;c++)l[c]=i.u16()*2;else for(let c=0;c<o;c++)l[c]=i.u32();return l}function go(e,n){const t=new ut(e,n);return t.skip(4),{numGlyphs:t.u16()}}const bo=1,Ao=2,wo=4,Do=8,Jn=16,ts=32,Eo=1,ns=2,qo=8,vo=32,Co=64,Io=128;function Ro(e,n,t,s,i){const o=ss(e,n,t,s,i),l=[];for(const c of o){const r=Fo(c);r.length>0&&l.push(r)}return{contours:l,inverseYAxis:!1}}function ss(e,n,t,s,i){if(s===0)return[];const o=n+t,l=new ut(e,o),c=l.i16();return l.skip(8),c>=0?To(l,c):ko(e,l,n,i)}function To(e,n){if(n===0)return[];const t=new Array(n);for(let a=0;a<n;a++)t[a]=e.u16();const s=(t[n-1]??0)+1,i=e.u16();e.skip(i);const o=new Uint8Array(s);for(let a=0;a<s;){const f=e.u8();if(o[a++]=f,f&Do){let y=e.u8();for(;y-- >0;)o[a++]=f}}const l=new Float64Array(s);let c=0;for(let a=0;a<s;a++){const f=o[a]??0;if(f&Ao){const y=e.u8();c+=f&Jn?y:-y}else f&Jn||(c+=e.i16());l[a]=c}const r=new Float64Array(s);c=0;for(let a=0;a<s;a++){const f=o[a]??0;if(f&wo){const y=e.u8();c+=f&ts?y:-y}else f&ts||(c+=e.i16());r[a]=c}const h=[];let p=0;for(let a=0;a<n;a++){const f=t[a]??0,y=mo(o,l,r,p,f);y.length>0&&h.push(y),p=f+1}return h}function mo(e,n,t,s,i){const o=i-s+1;if(o<=0)return[];const l=[];for(let c=0;c<o;c++){const r=e[s+c]??0,h=n[s+c]??0,p=t[s+c]??0;l.push({x:h,y:p,onCurve:(r&bo)!==0})}return l}function Fo(e){const n=e.length;if(n<=0)return[];const t=[];for(let c=0;c<n;c++){const r=e[c],h=e[(c+1)%n];t.push(r),!r.onCurve&&!h.onCurve&&t.push({x:Math.trunc((r.x+h.x)/2),y:Math.trunc((r.y+h.y)/2),onCurve:!0})}const s=t.length;let i=0;if(!t[0].onCurve){for(let c=1;c<s;c++)if(t[c].onCurve){i=c;break}}const o=[];let l=0;for(;l<s;){const c=t[(i+l)%s],r=t[(i+l+1)%s];if(r.onCurve)o.push(new nt(ot,c.x,c.y,r.x,r.y,0,0,0,0)),l+=1;else{const h=t[(i+l+2)%s];o.push(new nt(tt,c.x,c.y,r.x,r.y,h.x,h.y,0,0)),l+=2}}return o}function ko(e,n,t,s){const i=[];let o=0;do{o=n.u16();const l=n.u16();let c,r;o&Eo?(c=n.i16(),r=n.i16()):(c=n.u8(),r=n.u8(),o&ns&&(c>127&&(c-=256),r>127&&(r-=256)));let h=0,p=0;o&ns&&(h=c,p=r);let a=1,f=0,y=0,_=1;o&qo?a=_=n.f2dot14():o&Co?(a=n.f2dot14(),_=n.f2dot14()):o&Io&&(a=n.f2dot14(),f=n.f2dot14(),y=n.f2dot14(),_=n.f2dot14());const u=s(l),x=So(u,a,f,y,_,h,p);for(const M of x)i.push(M)}while(o&vo);return i}function os(e){return e>=0?Math.floor(e+.5):Math.ceil(e-.5)}function So(e,n,t,s,i,o,l){if(n===1&&t===0&&s===0&&i===1&&o===0&&l===0)return e;const r=n===1&&t===0&&s===0&&i===1;return e.map(h=>h.map(p=>r?{x:p.x+o,y:p.y+l,onCurve:p.onCurve}:{x:os(n*p.x+t*p.y+o),y:os(s*p.x+i*p.y+l),onCurve:p.onCurve}))}function Lo(e,n){const t=new ut(e,n);if(t.u16()!==0)return is;const i=t.u16(),o=new Map;for(let l=0;l<i;l++){const c=t.pos;t.skip(2);const r=t.u16(),h=t.u16(),p=h>>8&255,a=!(h&2),f=!!(h&4);if(p!==0||!a||f){t.seek(c+r);continue}const y=t.u16();t.skip(6);for(let _=0;_<y;_++){const u=t.u16(),x=t.u16(),M=t.i16(),w=(u&65535)<<16|x&65535;o.set(w,M)}t.seek(c+r)}return o.size===0?is:(l,c)=>{const r=(l&65535)<<16|c&65535;return o.get(r)??0}}const is=()=>0;function Go(e){const n=new ut(e);if(n.u32()===1953784678){if(n.skip(4),n.u32()===0)throw new Error("TTC contains no fonts");const i=n.u32();n.seek(i)}else n.seek(0);return Oo(e,n)}function Oo(e,n){n.skip(4);const t=n.u16();n.skip(6);const s=new Map;for(let i=0;i<t;i++){const o=String.fromCharCode(n.u8(),n.u8(),n.u8(),n.u8());n.skip(4);const l=n.u32(),c=n.u32();s.set(o,{offset:l,length:c})}return s}class Po{constructor(n){this._buffer=n,this._tables=Go(n);const t=this._tables.get("head"),s=this._tables.get("maxp"),i=this._tables.get("hhea"),o=this._tables.get("hmtx"),l=this._tables.get("loca"),c=this._tables.get("cmap");if(!t)throw new Error("Font missing required `head` table");if(!s)throw new Error("Font missing required `maxp` table");if(!i)throw new Error("Font missing required `hhea` table");if(!o)throw new Error("Font missing required `hmtx` table");if(!l)throw new Error("Font missing required `loca` table");if(!c)throw new Error("Font missing required `cmap` table");this._head=uo(n,t.offset);const r=go(n,s.offset);this._hhea=_o(n,i.offset),this._hmtx=xo(n,o.offset,r.numGlyphs,this._hhea.numberOfHMetrics),this._loca=Mo(n,l.offset,r.numGlyphs,this._head.indexToLocFormat),this._cmap=po(n,c.offset);const h=this._tables.get("kern");this._kern=h?Lo(n,h.offset):()=>0,this.metrics={unitsPerEm:this._head.unitsPerEm,ascender:this._hhea.ascender,descender:this._hhea.descender,lineGap:this._hhea.lineGap}}glyphId(n){return this._cmap(n)}get numGlyphs(){return this._loca.length-1}advance(n){return(this._hmtx[n]??this._hmtx[this._hmtx.length-1]??{advanceWidth:0}).advanceWidth}lsb(n){return(this._hmtx[n]??this._hmtx[this._hmtx.length-1]??{lsb:0}).lsb}kerning(n,t){return this._kern(n,t)}shape(n){const t=this._tables.get("glyf");if(!t)return{contours:[],inverseYAxis:!1};const s=this._loca,i=s[n]??0,l=(s[n+1]??i)-i;return Ro(this._buffer,t.offset,i,l,c=>this._glyphRaw(c))}_glyphRaw(n){const t=this._tables.get("glyf");if(!t)return[];const s=this._loca,i=s[n]??0,l=(s[n+1]??i)-i;return ss(this._buffer,t.offset,i,l,c=>this._glyphRaw(c))}}function No(e,n){const t=1/n;for(const s of e.contours)for(let i=0;i<s.length;i++){const o=s[i];if(o.p0x*=t,o.p0y*=t,o.p1x*=t,o.p1y*=t,o.p2x*=t,o.p2y*=t,o.p3x*=t,o.p3y*=t,o.type===tt){const l=o.p1x-o.p0x,c=o.p1y-o.p0y,r=o.p2x-o.p1x,h=o.p2y-o.p1y;J(l,c,r,h)===0&&(s[i]=new nt(ot,o.p0x,o.p0y,o.p2x,o.p2y,0,0,0,0))}}}const es=1e-6,Uo=1.1111111111111112,Yo=new Float64Array(16);function cs(e,n,t){switch(n[t]=e.p0x,n[t+1]=e.p0y,n[t+2]=e.p1x,n[t+3]=e.p1y,e.type){case ot:return 1;case tt:return n[t+4]=e.p2x,n[t+5]=e.p2y,2;default:return n[t+4]=e.p2x,n[t+5]=e.p2y,n[t+6]=e.p3x,n[t+7]=e.p3y,3}}function rs(e,n,t){if(t===3){const s=e[n],i=e[n+1],o=e[n+2],l=e[n+3],c=e[n+4],r=e[n+5],h=e[n+6],p=e[n+7];(o===s&&l===i||o===h&&l===p)&&(c===s&&r===i||c===h&&r===p)&&(e[n+2]=h,e[n+3]=p,t=1)}if(t===2){const s=e[n],i=e[n+1],o=e[n+2],l=e[n+3],c=e[n+4],r=e[n+5];(o===s&&l===i||o===c&&l===r)&&(e[n+2]=c,e[n+3]=r,t=1)}return t===1&&e[n]===e[n+2]&&e[n+1]===e[n+3]&&(t=0),t}function Xo(e,n){const t=Yo;let s=cs(e,t,0),i=cs(n,t,8);if(!(s>=1&&s<=3&&i>=1&&i<=3)||t[s*2]!==t[8]||t[s*2+1]!==t[9])return 0;s=rs(t,0,s),i=rs(t,8,i);const o=t[s*2],l=t[s*2+1];let c=0,r=0,h=0,p=0,a=0,f=0,y=0,_=0,u=0,x=0,M=0,w=0;if(s>=1&&(c=t[(s-1)*2]-o,r=t[(s-1)*2+1]-l),s>=2){const H=t[(s-2)*2]-t[(s-1)*2],B=t[(s-2)*2+1]-t[(s-1)*2+1];h=H-c,p=B-r}if(s>=3){const H=t[(s-3)*2]-t[(s-2)*2],B=t[(s-3)*2+1]-t[(s-2)*2+1],ft=t[(s-2)*2]-t[(s-1)*2],ct=t[(s-2)*2+1]-t[(s-1)*2+1];a=H-ft-h,f=B-ct-p,h*=3,p*=3}if(i>=1&&(y=t[10]-o,_=t[11]-l),i>=2){const H=t[12]-t[10],B=t[13]-t[11];u=H-y,x=B-_}if(i>=3){const H=t[14]-t[12],B=t[15]-t[13],ft=t[12]-t[10],ct=t[13]-t[11];M=H-ft-u,w=B-ct-x,u*=3,x*=3}c*=s,r*=s,y*=i,_*=i;const v=c!==0||r!==0;if(v&&(y!==0||_!==0)){const H=Math.sqrt(c*c+r*r),B=Math.sqrt(y*y+_*_),ft=H*J(c,r,u,x)+B*J(h,p,y,_);if(ft)return rt(ft);const ct=H*H*J(c,r,M,w)+H*B*J(h,p,u,x)+B*B*J(a,f,y,_);if(ct)return rt(ct);const Nt=H*J(h,p,M,w)+B*J(a,f,u,x);return rt(Nt||J(a,f,M,w))}let A=1,D=h,I=p,L=a,m=f,b=y,N=_,R=u,q=x,P=M,X=w;if(v&&(D=u,I=x,L=M,m=w,b=c,N=r,R=h,q=p,P=a,X=f,A=-1),b!==0||N!==0){const H=J(L,m,b,N);if(H)return A*rt(H);const B=J(D,I,R,q);if(B)return A*rt(B);const ft=J(L,m,R,q);if(ft)return A*rt(ft);const ct=J(D,I,P,X);return ct?A*rt(ct):A*rt(J(L,m,P,X))}const $=Math.sqrt(D*D+I*I),V=Math.sqrt(R*R+q*q),et=Math.sqrt($)*J(D,I,P,X)+Math.sqrt(V)*J(L,m,R,q);return rt(et||J(L,m,P,X))}function as(e,n,t,s,i){let o=e[n];if(o.type===tt){const l=o.convertToCubic();e[n]=l,o=l}if(o.type===It)if(t===0){const l=Math.sqrt((o.p1x-o.p0x)**2+(o.p1y-o.p0y)**2);o.p1x+=l*s,o.p1y+=l*i}else{const l=Math.sqrt((o.p2x-o.p3x)**2+(o.p2y-o.p3y)**2);o.p2x+=l*s,o.p2y+=l*i}}const Lt=[0,0],Gt=[0,0];function Wo(e){for(let n=0;n<e.contours.length;n++){const t=e.contours[n];let s=0;for(let i=0;i<t.length;i++){const o=t[i];(o.p0x!==o.endX()||o.p0y!==o.endY())&&(t[s++]=o)}t.length=s}for(const n of e.contours)if(n.length===1){const[t,s,i]=n[0].splitInThirds();n.length=0,n.push(t,s,i)}else if(n.length>0){const t=n.length;for(let s=0;s<t;s++){const i=(s+t-1)%t,o=n[i],l=n[s];o.direction(1,Lt),l.direction(0,Gt);const c=Math.sqrt(Lt[0]**2+Lt[1]**2),r=Math.sqrt(Gt[0]**2+Gt[1]**2);if(c===0||r===0)continue;const h=Lt[0]/c,p=Lt[1]/c,a=Gt[0]/r,f=Gt[1]/r;if(so(h,p,a,f)<es-1){const y=es-1,_=Uo*Math.sqrt(1-y*y)/y;let u=a-h,x=f-p;const M=Math.sqrt(u*u+x*x);if(M===0)continue;u=_*u/M,x=_*x/M,Xo(o,l)<0&&(u=-u,x=-x),as(n,i,1,-x,u),as(n,s,0,x,-u)}}}}const Yt=1,Xt=2,Ho=3,Wt=4,Vo=5,Bo=6,en=7,it=[0,0],qt=[0,0];function zo(e,n){return Math.trunc(3+2.875*e/(n-1)-1.4375+.5)-3}function Qo(e,n,t,s,i){return e*t+n*s<=0||Math.abs(e*s-n*t)>i}function $o(e){const n=Number(e.v&1n);return e.v>>=1n,n}function Ko(e){const n=Number(e.v%3n);return e.v/=3n,n}function hs(e){return[Bo,Vo,Ho][Ko(e)]}function Ot(e,n){const t=e.v<<1+$o(n);e.v=(t|t>>3)&en}function Zo(e,n,t){const s=e.v&t;s===Yt||s===Xt||s===Wt?e.v=s^en:Ot(e,n)}function jo(e,n,t=0n){const s=Math.sin(n),i={v:hs({v:t})},o={v:t};o.v=t,i.v=hs(o);const l=[];for(const c of e.contours){if(c.length===0)continue;l.length=0,c[c.length-1].direction(1,it);const h=Math.sqrt(it[0]*it[0]+it[1]*it[1]);let p=h>0?it[0]/h:0,a=h>0?it[1]/h:0;for(let f=0;f<c.length;f++){const y=c[f];y.direction(0,qt);const _=Math.sqrt(qt[0]*qt[0]+qt[1]*qt[1]),u=_>0?qt[0]/_:0,x=_>0?qt[1]/_:0;Qo(p,a,u,x,s)&&l.push(f),y.direction(1,it);const M=Math.sqrt(it[0]*it[0]+it[1]*it[1]);p=M>0?it[0]/M:0,a=M>0?it[1]/M:0}if(l.length===0){Ot(i,o);for(const f of c)f.color=i.v}else if(l.length===1){const f=[0,en,0];Ot(i,o),f[0]=i.v,Ot(i,o),f[2]=i.v;const y=l[0],_=c.length;if(_>=3)for(let u=0;u<_;u++){const x=zo(u,_);c[(y+u)%_].color=f[1+x]}else if(_>=1){const u=[null,null,null,null,null,null,null],x=c[0].splitInThirds();if(u[0+3*y]=x[0],u[1+3*y]=x[1],u[2+3*y]=x[2],_>=2){const M=c[1].splitInThirds();u[3-3*y]=M[0],u[4-3*y]=M[1],u[5-3*y]=M[2],u[0].color=u[1].color=f[0],u[2].color=u[3].color=f[1],u[4].color=u[5].color=f[2]}else u[0].color=f[0],u[1].color=f[1],u[2].color=f[2];c.length=0;for(const M of u)M!==null&&c.push(M)}}else{const f=l.length;let y=0;const _=l[0],u=c.length;Ot(i,o);const x=i.v;for(let M=0;M<u;M++){const w=(_+M)%u;y+1<f&&l[y+1]===w&&(++y,Zo(i,o,y===f-1?x:0)),c[w].color=i.v}}}}const Y=Number.MAX_VALUE,T=[0,0],ht=[0,0];let ls=0,z=new Float64Array(0),K=new Float64Array(0),k=new Float64Array(0),S=new Float64Array(0),Z=new Int32Array(0),j=new Float64Array(0),Rt=new Float64Array(0),Tt=new Float64Array(0),mt=new Float64Array(0),vt=new Int32Array(0);const Q=[0,0];let ps=0,cn=new Float64Array(0),rn=new Float64Array(0),an=new Float64Array(0),hn=new Float64Array(0),ln=new Float64Array(0),pn=new Float64Array(0),fn=new Float64Array(0),yn=new Float64Array(0),un=new Float64Array(0),_n=new Float64Array(0),xn=new Float64Array(0),Mn=new Float64Array(0),fs=0,Pt=new Int32Array(0);function Jo(e){const n=e.length;if(n===0)return 0;let t=0;if(n===1){e[0].point(0,Q);const s=Q[0],i=Q[1];e[0].point(.3333333333333333,Q);const o=Q[0],l=Q[1];e[0].point(.6666666666666666,Q);const c=Q[0],r=Q[1];t+=s*l-i*o,t+=o*r-l*c,t+=c*i-r*s}else if(n===2){e[0].point(0,Q);const s=Q[0],i=Q[1];e[0].point(.5,Q);const o=Q[0],l=Q[1];e[1].point(0,Q);const c=Q[0],r=Q[1];e[1].point(.5,Q);const h=Q[0],p=Q[1];t+=s*l-i*o,t+=o*r-l*c,t+=c*p-r*h,t+=h*i-p*s}else{const s=e[n-1];let i=s.p0x,o=s.p0y;for(let l=0;l<n;l++){const c=e[l].p0x,r=e[l].p0y;t+=i*r-o*c,i=c,o=r}}return t>0?-1:t<0?1:0}function ti(e,n,t,s,i,o,l){const c=l[e][n];let r=t;if(o<0){c.direction(0,T);const h=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(h>0){const p=T[0]/h,a=T[1]/h;c.point(0,ht);const f=s-ht[0],y=i-ht[1];if(f*p+y*a<0){const u=f*a-y*p;Math.abs(u)<=Math.abs(r)&&(r=u)}}}if(o>1){c.direction(1,T);const h=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(h>0){const p=T[0]/h,a=T[1]/h;c.point(1,ht);const f=s-ht[0],y=i-ht[1];if(f*p+y*a>0){const u=f*a-y*p;Math.abs(u)<=Math.abs(r)&&(r=u)}}}return r}function lt(e,n,t,s,i,o,l,c,r){let h=e<0?n:t;if(i>=0){const p=ti(s,i,e,l,c,o,r);Math.abs(p)<Math.abs(h)&&(h=p)}return h}function _t(e,n,t){return Math.max(Math.min(e,n),Math.min(Math.max(e,n),t))}function ni(e,n,t,s,i,o,l,c){if(c.length!==n*t*3)throw new Error(`generateMSDF: out.length ${c.length} !== ${n*t*3}`);const r=e.contours,h=r.length;if(h===0){c.fill(0);return}const p=s/l;vt.length<h&&(vt=new Int32Array(h));for(let y=0;y<h;y++)vt[y]=Jo(r[y]);fs<h+1&&(Pt=new Int32Array(h+1),fs=h+1);let a=0;for(let y=0;y<h;y++)Pt[y]=a,a+=r[y].length;Pt[h]=a,ps<a&&(cn=new Float64Array(a),rn=new Float64Array(a),an=new Float64Array(a),hn=new Float64Array(a),ln=new Float64Array(a),pn=new Float64Array(a),fn=new Float64Array(a),yn=new Float64Array(a),un=new Float64Array(a),_n=new Float64Array(a),xn=new Float64Array(a),Mn=new Float64Array(a),ps=a);for(let y=0;y<h;y++){const _=r[y],u=_.length,x=Pt[y];for(let M=0;M<u;M++){const w=_[M],v=_[(M+u-1)%u],C=_[(M+1)%u],A=x+M;w.point(0,ht),cn[A]=ht[0],rn[A]=ht[1],w.point(1,ht),an[A]=ht[0],hn[A]=ht[1],w.direction(0,T);let D=Math.sqrt(T[0]*T[0]+T[1]*T[1]);const I=D>0?T[0]/D:0,L=D>0?T[1]/D:0;ln[A]=I,pn[A]=L,w.direction(1,T),D=Math.sqrt(T[0]*T[0]+T[1]*T[1]);const m=D>0?T[0]/D:0,b=D>0?T[1]/D:0;fn[A]=m,yn[A]=b,v.direction(1,T),D=Math.sqrt(T[0]*T[0]+T[1]*T[1]);const N=D>0?T[0]/D:0,R=D>0?T[1]/D:0;C.direction(0,T),D=Math.sqrt(T[0]*T[0]+T[1]*T[1]);const q=D>0?T[0]/D:0,P=D>0?T[1]/D:0,X=N+I,$=R+L,V=Math.sqrt(X*X+$*$);un[A]=V>0?X/V:0,_n[A]=V>0?$/V:0;const et=m+q,H=b+P,B=Math.sqrt(et*et+H*H);xn[A]=B>0?-(et/B):0,Mn[A]=B>0?-(H/B):0}}if(ls<h){const y=h*3;z=new Float64Array(y),K=new Float64Array(y),k=new Float64Array(y),S=new Float64Array(y),Z=new Int32Array(y),j=new Float64Array(y),Rt=new Float64Array(h),Tt=new Float64Array(h),mt=new Float64Array(h),ls=h}const f={distance:0,dot:0,param:0};for(let y=0;y<t;y++)for(let _=0;_<n;_++){const u=(_+.5)/s-i,x=(y+.5)/s-o;for(let E=0;E<h;E++){const d=r[E],at=d.length,g=E*3,G=Pt[E];z[g]=z[g+1]=z[g+2]=-Y,K[g]=K[g+1]=K[g+2]=0,k[g]=k[g+1]=k[g+2]=-Y,S[g]=S[g+1]=S[g+2]=Y,Z[g]=Z[g+1]=Z[g+2]=-1,j[g]=j[g+1]=j[g+2]=0;for(let O=0;O<at;O++){const W=d[O],Xn=W.color,Wn=(Xn&Yt)!==0,Hn=(Xn&Xt)!==0,Vn=(Xn&Wt)!==0;W.signedDistance(u,x,f);const on=f.distance,kt=f.dot,Bn=f.param,Dt=Math.abs(on);if(Wn){const bt=Math.abs(z[g]);(Dt<bt||Dt===bt&&kt<K[g])&&(z[g]=on,K[g]=kt,Z[g]=O,j[g]=Bn)}if(Hn){const bt=Math.abs(z[g+1]);(Dt<bt||Dt===bt&&kt<K[g+1])&&(z[g+1]=on,K[g+1]=kt,Z[g+1]=O,j[g+1]=Bn)}if(Vn){const bt=Math.abs(z[g+2]);(Dt<bt||Dt===bt&&kt<K[g+2])&&(z[g+2]=on,K[g+2]=kt,Z[g+2]=O,j[g+2]=Bn)}const yt=G+O,zn=u-cn[yt],Qn=x-rn[yt],$n=u-an[yt],Kn=x-hn[yt],js=ln[yt],Js=pn[yt],to=fn[yt],no=yn[yt],Ei=zn*un[yt]+Qn*_n[yt],qi=$n*xn[yt]+Kn*Mn[yt];if(Ei>0&&-(zn*js+Qn*Js)>0){const F=zn*Js-Qn*js;Math.abs(F)<Dt&&(Wn&&(F<=0&&F>k[g]?k[g]=F:F>0&&F<S[g]&&(S[g]=F)),Hn&&(F<=0&&F>k[g+1]?k[g+1]=F:F>0&&F<S[g+1]&&(S[g+1]=F)),Vn&&(F<=0&&F>k[g+2]?k[g+2]=F:F>0&&F<S[g+2]&&(S[g+2]=F)))}if(qi>0&&$n*to+Kn*no>0){const F=$n*no-Kn*to;Math.abs(F)<Dt&&(Wn&&(F<=0&&F>k[g]?k[g]=F:F>0&&F<S[g]&&(S[g]=F)),Hn&&(F<=0&&F>k[g+1]?k[g+1]=F:F>0&&F<S[g+1]&&(S[g+1]=F)),Vn&&(F<=0&&F>k[g+2]?k[g+2]=F:F>0&&F<S[g+2]&&(S[g+2]=F)))}}Rt[E]=lt(z[g],k[g],S[g],E,Z[g],j[g],u,x,r),Tt[E]=lt(z[g+1],k[g+1],S[g+1],E,Z[g+1],j[g+1],u,x,r),mt[E]=lt(z[g+2],k[g+2],S[g+2],E,Z[g+2],j[g+2],u,x,r)}let M=-Y,w=0,v=-Y,C=Y,A=-1,D=-1,I=0,L=-Y,m=0,b=-Y,N=Y,R=-1,q=-1,P=0,X=-Y,$=0,V=-Y,et=Y,H=-1,B=-1,ft=0,ct=-Y,Nt=0,qn=-Y,vn=Y,Ds=-1,Es=-1,qs=0,Kt=-Y,vs=0,Cn=-Y,In=Y,Cs=-1,Is=-1,Rs=0,Zt=-Y,Ts=0,Rn=-Y,Tn=Y,ms=-1,Fs=-1,ks=0,jt=-Y,Ss=0,mn=-Y,Fn=Y,Ls=-1,Gs=-1,Os=0,Jt=-Y,Ps=0,kn=-Y,Sn=Y,Ns=-1,Us=-1,Ys=0,tn=-Y,Xs=0,Ln=-Y,Gn=Y,Ws=-1,Hs=-1,Vs=0;for(let E=0;E<h;E++){const d=E*3,at=vt[E],g=_t(Rt[E],Tt[E],mt[E]);{const G=z[d],O=K[d],W=Math.abs(G);(W<Math.abs(M)||W===Math.abs(M)&&O<w)&&(M=G,w=O,A=E,D=Z[d],I=j[d]),k[d]>v&&(v=k[d]),S[d]<C&&(C=S[d])}{const G=z[d+1],O=K[d+1],W=Math.abs(G);(W<Math.abs(L)||W===Math.abs(L)&&O<m)&&(L=G,m=O,R=E,q=Z[d+1],P=j[d+1]),k[d+1]>b&&(b=k[d+1]),S[d+1]<N&&(N=S[d+1])}{const G=z[d+2],O=K[d+2],W=Math.abs(G);(W<Math.abs(X)||W===Math.abs(X)&&O<$)&&(X=G,$=O,H=E,B=Z[d+2],ft=j[d+2]),k[d+2]>V&&(V=k[d+2]),S[d+2]<et&&(et=S[d+2])}if(at>0&&g>=0){{const G=z[d],O=K[d],W=Math.abs(G);(W<Math.abs(ct)||W===Math.abs(ct)&&O<Nt)&&(ct=G,Nt=O,Ds=E,Es=Z[d],qs=j[d]),k[d]>qn&&(qn=k[d]),S[d]<vn&&(vn=S[d])}{const G=z[d+1],O=K[d+1],W=Math.abs(G);(W<Math.abs(Kt)||W===Math.abs(Kt)&&O<vs)&&(Kt=G,vs=O,Cs=E,Is=Z[d+1],Rs=j[d+1]),k[d+1]>Cn&&(Cn=k[d+1]),S[d+1]<In&&(In=S[d+1])}{const G=z[d+2],O=K[d+2],W=Math.abs(G);(W<Math.abs(Zt)||W===Math.abs(Zt)&&O<Ts)&&(Zt=G,Ts=O,ms=E,Fs=Z[d+2],ks=j[d+2]),k[d+2]>Rn&&(Rn=k[d+2]),S[d+2]<Tn&&(Tn=S[d+2])}}if(at<0&&g<=0){{const G=z[d],O=K[d],W=Math.abs(G);(W<Math.abs(jt)||W===Math.abs(jt)&&O<Ss)&&(jt=G,Ss=O,Ls=E,Gs=Z[d],Os=j[d]),k[d]>mn&&(mn=k[d]),S[d]<Fn&&(Fn=S[d])}{const G=z[d+1],O=K[d+1],W=Math.abs(G);(W<Math.abs(Jt)||W===Math.abs(Jt)&&O<Ps)&&(Jt=G,Ps=O,Ns=E,Us=Z[d+1],Ys=j[d+1]),k[d+1]>kn&&(kn=k[d+1]),S[d+1]<Sn&&(Sn=S[d+1])}{const G=z[d+2],O=K[d+2],W=Math.abs(G);(W<Math.abs(tn)||W===Math.abs(tn)&&O<Xs)&&(tn=G,Xs=O,Ws=E,Hs=Z[d+2],Vs=j[d+2]),k[d+2]>Ln&&(Ln=k[d+2]),S[d+2]<Gn&&(Gn=S[d+2])}}}const On=lt(M,v,C,A,D,I,u,x,r),Pn=lt(L,b,N,R,q,P,u,x,r),Nn=lt(X,V,et,H,B,ft,u,x,r),Di=_t(On,Pn,Nn),Bs=lt(ct,qn,vn,Ds,Es,qs,u,x,r),zs=lt(Kt,Cn,In,Cs,Is,Rs,u,x,r),Qs=lt(Zt,Rn,Tn,ms,Fs,ks,u,x,r),nn=_t(Bs,zs,Qs),$s=lt(jt,mn,Fn,Ls,Gs,Os,u,x,r),Ks=lt(Jt,kn,Sn,Ns,Us,Ys,u,x,r),Zs=lt(tn,Ln,Gn,Ws,Hs,Vs,u,x,r),sn=_t($s,Ks,Zs);let xt,Mt,gt,Un=0;if(nn>=0&&Math.abs(nn)<=Math.abs(sn)){xt=Bs,Mt=zs,gt=Qs,Un=1;for(let E=0;E<h;E++)if(vt[E]>0){const d=Rt[E],at=Tt[E],g=mt[E],G=_t(d,at,g);Math.abs(G)<Math.abs(sn)&&G>_t(xt,Mt,gt)&&(xt=d,Mt=at,gt=g)}}else if(sn<=0&&Math.abs(sn)<Math.abs(nn)){xt=$s,Mt=Ks,gt=Zs,Un=-1;for(let E=0;E<h;E++)if(vt[E]<0){const d=Rt[E],at=Tt[E],g=mt[E],G=_t(d,at,g);Math.abs(G)<Math.abs(nn)&&G<_t(xt,Mt,gt)&&(xt=d,Mt=at,gt=g)}}else{const E=(y*n+_)*3;c[E+0]=On*p+.5,c[E+1]=Pn*p+.5,c[E+2]=Nn*p+.5;continue}for(let E=0;E<h;E++)if(vt[E]!==Un){const d=Rt[E],at=Tt[E],g=mt[E],G=_t(d,at,g),O=_t(xt,Mt,gt);G*O>=0&&Math.abs(G)<Math.abs(O)&&(xt=d,Mt=at,gt=g)}_t(xt,Mt,gt)===Di&&(xt=On,Mt=Pn,gt=Nn);const Yn=(y*n+_)*3;c[Yn+0]=xt*p+.5,c[Yn+1]=Mt*p+.5,c[Yn+2]=gt*p+.5}}const ys=0,si=1,oi=2,ii=3;function ei(e,n){switch(n){case ys:return e!==0;case si:return(e&1)!==0;case oi:return e>0;case ii:return e<0}return!1}class ci{constructor(){this._intersections=[],this._lastIndex=0}setIntersections(n){if(this._intersections=n,this._lastIndex=0,n.length>0){n.sort((s,i)=>rt(s.x-i.x));let t=0;for(let s=0;s<n.length;s++)t+=n[s].direction,n[s].direction=t}}_moveTo(n){const t=this._intersections.length;if(t===0)return-1;let s=this._lastIndex;if(n<this._intersections[s].x)do{if(s===0)return this._lastIndex=0,-1;--s}while(n<this._intersections[s].x);else for(;s<t-1&&n>=this._intersections[s+1].x;)++s;return this._lastIndex=s,s}sumIntersections(n){const t=this._moveTo(n);return t>=0?this._intersections[t].direction:0}filled(n,t){return ei(this.sumIntersections(n),t)}}const us=[0,0,0],_s=[0,0,0];function ri(e,n,t){const s=[];for(const i of e.contours)for(const o of i){const l=o.scanlineIntersections(n,us,_s);for(let c=0;c<l;c++)s.push({x:us[c],direction:_s[c]})}t.setIntersections(s)}const Ft=2,xs=1,gn=1.001,ai=1.1111111111111112,Ht=.01;function hi(e,n,t,s,i,o,l){if(t===0||s===0)return;const c=new ci,r=new Int8Array(t*s);for(let h=0;h<s;h++){const p=(h+.5)/i-l;ri(n,p,c);for(let a=0;a<t;a++){const f=(a+.5)/i-o,y=c.filled(f,ys),_=(h*t+a)*3,u=e[_],x=e[_+1],M=e[_+2],w=st(u,x,M),v=h*t+a;w===.5?r[v]=0:w>.5!==y?(e[_]=1-u,e[_+1]=1-x,e[_+2]=1-M,r[v]=-1):r[v]=1}}for(let h=0;h<s;h++)for(let p=0;p<t;p++){const a=h*t+p;if(r[a]!==0)continue;let f=0;if(p>0&&(f+=r[a-1]),p<t-1&&(f+=r[a+1]),h>0&&(f+=r[a-t]),h<s-1&&(f+=r[a+t]),f<0){const y=(h*t+p)*3;e[y]=1-e[y],e[y+1]=1-e[y+1],e[y+2]=1-e[y+2]}}}const dn=[0,0];function li(e,n,t,s,i,o,l,c){const r=new Uint8Array(t*s);pi(r,n,t,s,i,o,l),fi(r,e,t,s,i,c),xi(r,e,t,s,c,ai),Mi(r,e,t,s)}function pi(e,n,t,s,i,o,l){for(const c of n.contours){if(c.length===0)continue;let r=c[c.length-1];for(const h of c){const p=r.color&h.color;if(!(p&p-1)){h.point(0,dn);const a=i*(dn[0]+o),f=i*(dn[1]+l),y=Math.floor(a-.5)|0,_=Math.floor(f-.5)|0,u=y+1,x=_+1;y<t&&_<s&&u>=0&&x>=0&&(y>=0&&_>=0&&(e[_*t+y]|=Ft),u<t&&_>=0&&(e[_*t+u]|=Ft),y>=0&&x<s&&(e[x*t+y]|=Ft),u<t&&x<s&&(e[x*t+u]|=Ft))}r=h}}}function Vt(e,n,t){let s=0;for(let i=0;i<3;i++){const o=e[n+i],l=e[t+i],c=o-l;if(c===0)continue;const r=(o-.5)/c;if(r>0&&r<1){const h=1-r,p=h*e[n]+r*e[t],a=h*e[n+1]+r*e[t+1],f=h*e[n+2]+r*e[t+2],y=i===0?p:i===1?a:f;st(p,a,f)===y&&(s|=i===0?Yt:i===1?Xt:Wt)}}return s}function wt(e,n,t,s,i,o){(o&Yt&&t[s]!==i||o&Xt&&t[s+1]!==i||o&Wt&&t[s+2]!==i)&&(e[n]|=Ft)}function fi(e,n,t,s,i,o){const l=gn/o,c=gn/o,r=gn*Math.SQRT2/o;for(let h=0;h<s;h++)for(let p=0;p<t-1;p++){const a=(h*t+p)*3,f=a+3,y=st(n[a],n[a+1],n[a+2]),_=st(n[f],n[f+1],n[f+2]);if(Math.abs(y-.5)+Math.abs(_-.5)<l){const u=Vt(n,a,f);wt(e,h*t+p,n,a,y,u),wt(e,h*t+p+1,n,f,_,u)}}for(let h=0;h<s-1;h++)for(let p=0;p<t;p++){const a=(h*t+p)*3,f=((h+1)*t+p)*3,y=st(n[a],n[a+1],n[a+2]),_=st(n[f],n[f+1],n[f+2]);if(Math.abs(y-.5)+Math.abs(_-.5)<c){const u=Vt(n,a,f);wt(e,h*t+p,n,a,y,u),wt(e,(h+1)*t+p,n,f,_,u)}}for(let h=0;h<s-1;h++)for(let p=0;p<t-1;p++){const a=(h*t+p)*3,f=(h*t+p+1)*3,y=((h+1)*t+p)*3,_=((h+1)*t+p+1)*3,u=st(n[a],n[a+1],n[a+2]),x=st(n[f],n[f+1],n[f+2]),M=st(n[y],n[y+1],n[y+2]),w=st(n[_],n[_+1],n[_+2]);if(Math.abs(u-.5)+Math.abs(w-.5)<r){const v=Vt(n,a,_);wt(e,h*t+p,n,a,u,v),wt(e,(h+1)*t+p+1,n,_,w,v)}if(Math.abs(x-.5)+Math.abs(M-.5)<r){const v=Vt(n,f,y);wt(e,h*t+p+1,n,f,x,v),wt(e,(h+1)*t+p,n,y,M,v)}}}function yi(e,n,t){const s=n<e?n:e,i=e<n?n:e,o=t<i?t:i;return s<o?o:s}function ui(e,n,t,s){return st(e[n]+s*(e[t]-e[n]),e[n+1]+s*(e[t+1]-e[n+1]),e[n+2]+s*(e[t+2]-e[n+2]))}function bn(e,n,t,s){return yi(Math.fround(s*(s*t[0]+n[0])+e[0]),Math.fround(s*(s*t[1]+n[1])+e[1]),Math.fround(s*(s*t[2]+n[2])+e[2]))}const Ct=[0,0,0],dt=[0,0,0],An=[0,0,0],pt=[0,0,0],Ms=1,gs=2;function wn(e,n,t,s,i,o,l,c){if(s>.5&&i>.5&&o<=.5||s<.5&&i<.5&&o>=.5||!c&&_i(s,i,o)!==o){const r=(t-e)*l,h=(n-t)*l;return o>=s-r&&o<=s+r&&o>=i-h&&o<=i+h?Ms:Ms|gs}return 0}function ds(e){return(e&gs)!==0}function _i(e,n,t){return Math.max(Math.min(e,n),Math.min(Math.max(e,n),t))}function Bt(e,n,t,s,i,o){const l=st(e[t],e[t+1],e[t+2]);if(Math.abs(s-.5)<Math.abs(l-.5))return!1;for(let c=0;c<3;c++){const r=e[n+c]-e[n+(c+1)%3],h=e[t+c]-e[t+(c+1)%3],p=r-h;if(p===0)continue;const a=r/p;if(a>Ht&&a<1-Ht){const f=ui(e,n,t,a),y=wn(0,1,a,s,l,f,i,o);if(ds(y))return!0}}return!1}function bs(e,n,t,s,i,o,l,c,r){if(!(r>0&&r<1))return 0;const h=r>l?0:r,p=r>l?r:1;pt[0]=e[n],pt[1]=e[n+1],pt[2]=e[n+2];const a=r>l?t:bn(pt,Ct,dt,r);pt[0]=e[n],pt[1]=e[n+1],pt[2]=e[n+2];const f=r>l?bn(pt,Ct,dt,r):s;return wn(h,p,l,a,f,c,i,o)}function zt(e,n,t,s,i,o,l,c,r){if(!(l>Ht&&l<1-Ht))return!1;pt[0]=e[n],pt[1]=e[n+1],pt[2]=e[n+2];const h=bn(pt,Ct,dt,l);let p=wn(0,1,l,t,s,h,i,o);return p|=bs(e,n,t,s,i,o,l,h,c),p|=bs(e,n,t,s,i,o,l,h,r),ds(p)}function Dn(e,n,t,s,i,o,l,c,r,h,p,a,f){const y=Math.fround(e[n+h]-e[n+p]),_=Math.fround(Math.fround(e[t+h]-e[t+p])+Math.fround(e[s+h]-e[s+p])),u=Math.fround(e[i+h]-e[i+p]),x=Math.fround(Math.fround(u-_)+y),M=Math.fround(Math.fround(_-y)-y),w=y;if(x===0||Math.abs(M)>1e12*Math.abs(x)){if(M!==0){const C=-w/M;if(zt(e,n,o,l,c,r,C,a,f))return!0}return!1}const v=M*M-4*x*w;if(v>0){const C=Math.sqrt(v),A=(-M+C)/(2*x);if(zt(e,n,o,l,c,r,A,a,f))return!0;const D=(-M-C)/(2*x);if(zt(e,n,o,l,c,r,D,a,f))return!0}else if(v===0){const C=-M/(2*x);if(zt(e,n,o,l,c,r,C,a,f))return!0}return!1}function Qt(e,n,t,s,i,o,l,c){const r=st(e[i],e[i+1],e[i+2]);if(Math.abs(o-.5)<Math.abs(r-.5))return!1;for(let f=0;f<3;f++)An[f]=Math.fround(Math.fround(e[n+f]-e[t+f])-e[s+f]),Ct[f]=Math.fround(-e[n+f]-An[f]),dt[f]=Math.fround(e[i+f]+An[f]);const h=dt[0]!==0?-.5*Ct[0]/dt[0]:-1,p=dt[1]!==0?-.5*Ct[1]/dt[1]:-1,a=dt[2]!==0?-.5*Ct[2]/dt[2]:-1;return!!(Dn(e,n,t,s,i,o,r,l,c,0,1,h,p)||Dn(e,n,t,s,i,o,r,l,c,1,2,p,a)||Dn(e,n,t,s,i,o,r,l,c,2,0,a,h))}function xi(e,n,t,s,i,o){const l=o/i,c=o/i,r=o*Math.SQRT2/i;for(let h=0;h<s;h++)for(let p=0;p<t;p++){const a=h*t+p,f=a*3,y=st(n[f],n[f+1],n[f+2]),_=(e[a]&Ft)!==0,u=p>0,x=p<t-1,M=h>0,w=h<s-1,v=u?(a-1)*3:-1,C=x?(a+1)*3:-1,A=M?(a-t)*3:-1,D=w?(a+t)*3:-1;let I=!1;if(u&&Bt(n,f,v,y,l,_)&&(I=!0),!I&&M&&Bt(n,f,A,y,c,_)&&(I=!0),!I&&x&&Bt(n,f,C,y,l,_)&&(I=!0),!I&&w&&Bt(n,f,D,y,c,_)&&(I=!0),!I&&u&&M){const L=(a-t-1)*3;Qt(n,f,v,A,L,y,r,_)&&(I=!0)}if(!I&&x&&M){const L=(a-t+1)*3;Qt(n,f,C,A,L,y,r,_)&&(I=!0)}if(!I&&u&&w){const L=(a+t-1)*3;Qt(n,f,v,D,L,y,r,_)&&(I=!0)}if(!I&&x&&w){const L=(a+t+1)*3;Qt(n,f,C,D,L,y,r,_)&&(I=!0)}I&&(e[a]|=xs)}}function Mi(e,n,t,s){const i=t*s;for(let o=0;o<i;o++)if(e[o]&xs){const l=o*3,c=st(n[l],n[l+1],n[l+2]);n[l]=c,n[l+1]=c,n[l+2]=c}}function st(e,n,t){return Math.max(Math.min(e,n),Math.min(Math.max(e,n),t))}function gi(e){let n=0,t=0;for(const c of e)n+=c.w*c.h,t=Math.max(t,c.w);e.sort((c,r)=>r.h-c.h);const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),t),h:1/0}];let o=0,l=0;for(const c of e)for(let r=i.length-1;r>=0;r--){const h=i[r];if(!(c.w>h.w||c.h>h.h)){if(c.x=h.x,c.y=h.y,l=Math.max(l,c.y+c.h),o=Math.max(o,c.x+c.w),c.w===h.w&&c.h===h.h){const p=i.pop();p&&r<i.length&&(i[r]=p)}else c.h===h.h?(h.x+=c.w,h.w-=c.w):c.w===h.w?(h.y+=c.h,h.h-=c.h):(i.push({x:h.x+c.w,y:h.y,w:h.w-c.w,h:c.h}),h.y+=c.h,h.h-=c.h);break}}return{w:o,h:l,fill:n/(o*l)||0}}const di=3,bi=0n,As=4,ws=16;function $t(e){const n=e<0?0:e>1?1:e;return~Math.trunc(255.5-255*n)&255}class Ai{constructor(n,t={}){this._width=0,this._height=0,this._pixels=new Uint8Array(0),this._cache=new Map,this._cacheByGid=new Map,this._font=n,this._pxPerEm=t.pixelsPerEm??40,this._pxrange=t.pxrange??4,this.pxrangeEm=this._pxrange/this._pxPerEm}get width(){return this._width}get height(){return this._height}get texture(){return this._pixels}glyphs(n){const t=[];let s=0;for(const i of n){const o=this._cache.get(i);if(o){t.push(o.glyph);continue}const l=this._generateForGlyphId(this._font.glyphId(i));this._cache.set(i,l),t.push(l.glyph),s++}return s>0&&this._repack(),t}glyph(n){return this.glyphs([n])[0]}glyphsByIndex(n){const t=[];let s=0;for(const i of n){const o=this._cacheByGid.get(i);if(o){t.push(o.glyph);continue}const l=this._generateForGlyphId(i);this._cacheByGid.set(i,l),t.push(l.glyph),s++}return s>0&&this._repack(),t}glyphByIndex(n){return this.glyphsByIndex([n])[0]}_generateForGlyphId(n){const t=this._font,s=t.metrics.unitsPerEm,i=t.advance(n)/s,o=t.shape(n);if(No(o,s),o.contours.length===0)return{glyph:{x:0,y:0,w:0,h:0,advance:i,planeLeft:0,planeBottom:0,planeRight:0,planeTop:0},msdf:null};const l=wi(o),c=this._pxPerEm,r=this._pxrange,h=Math.max(1,Math.ceil((l.maxX-l.minX)*c))+2*r,p=Math.max(1,Math.ceil((l.maxY-l.minY)*c))+2*r,a=r/c-l.minX,f=r/c-l.minY;Wo(o),jo(o,di,bi);const y=new Float32Array(h*p*3);return ni(o,h,p,c,a,f,r,y),hi(y,o,h,p,c,a,f),li(y,o,h,p,c,a,f,r),{glyph:{x:0,y:0,w:h,h:p,advance:i,planeLeft:-a,planeBottom:-f,planeRight:h/c-a,planeTop:p/c-f},msdf:y}}layout(n){const t=[];for(const r of n)t.push(r.codePointAt(0));this.glyphs(t);const s=[],i=this._font,o=i.metrics.unitsPerEm;let l=0,c=-1;for(const r of t){const h=i.glyphId(r);c>=0&&(l+=i.kerning(c,h)/o);const p=this._cache.get(r).glyph;s.push({glyph:p,penX:l,penY:0}),l+=p.advance,c=h}return{glyphs:s,widthEm:l}}layoutMultiline(n){const t=this._font,s=t.metrics.unitsPerEm,i=(t.metrics.ascender-t.metrics.descender+t.metrics.lineGap)/s,o=n.split(`
|
|
2
|
-
`),
|
|
1
|
+
var MsdfgenTs=(function(yt){"use strict";function Ko(s,t,n,o){return s*n+t*o}function K(s,t,n,o){return s*o-t*n}function vs(s,t,n){return(1-n)*s+n*t}function ht(s){return+(s>0)-+(s<0)}function Rt(s){return 2*+(s>0)-1}function Cs(s,t,n,o){if(t===0||Math.abs(n)>1e12*Math.abs(t))return n===0?o===0?-1:0:(s[0]=-o/n,1);const e=n*n-4*t*o;if(e>0){const i=Math.sqrt(e);return s[0]=(-n+i)/(2*t),s[1]=(-n-i)/(2*t),2}else if(e===0)return s[0]=-n/(2*t),1;return 0}function Zo(s,t,n,o){const e=t*t,i=1/9*(e-3*n),r=1/54*(t*(2*e-9*n)+27*o),c=r*r,a=i*i*i,l=t*(1/3);if(c<a){let h=r/Math.sqrt(a);h<-1&&(h=-1),h>1&&(h=1),h=Math.acos(h);const p=-2*Math.sqrt(i);return s[0]=p*Math.cos(.3333333333333333*h)-l,s[1]=p*Math.cos(.3333333333333333*(h+2*Math.PI))-l,s[2]=p*Math.cos(.3333333333333333*(h-2*Math.PI))-l,3}else{const h=(r<0?1:-1)*Math.pow(Math.abs(r)+Math.sqrt(c-a),.3333333333333333),p=h===0?0:i/h;return s[0]=h+p-l,h===p||Math.abs(h-p)<1e-12*Math.abs(h+p)?(s[1]=-.5*(h+p)-l,2):1}}function Jo(s,t,n,o,e){if(t!==0){const i=n/t;if(Math.abs(i)<1e6)return Zo(s,i,o/t,e/t)}return Cs(s,n,o,e)}const te=24;function Vt(s,t,n,o){return((o+s)*o+t)*o+n}function ne(s,t,n,o,e,i,r){const c=i<0;let a=o-i*(e-o)/(r-i);a>o&&a<e||(a=.5*(o+e));for(let l=0;l<te;l++){const h=Vt(s,t,n,a);if(h===0)return a;h<0===c?o=a:e=a;const p=(3*a+2*s)*a+t;let f=a-h/p;f>o&&f<e||(f=.5*(o+e));const u=f-a;if(a=f,(u<0?-u:u)<=1e-15*(a<0?-a:a))break}return a}function en(s,t,n,o,e,i,r,c,a){return i===0?c[a++]=o:i<0!=r<0&&(c[a++]=ne(s,t,n,o,e,i,r)),a}function se(s,t,n,o,e,i){let r=0;if(s===0){if(t===0)return 0;const f=-n/t;return f>=o&&f<=e&&(i[r++]=f),r}const c=t*t-4*s*n;if(c<0)return 0;const a=Math.sqrt(c),l=-.5*(t+(t<0?-a:a));let h,p;if(l===0)h=0,p=0;else if(h=l/s,p=n/l,h>p){const f=h;h=p,p=f}return h>=o&&h<=e&&(i[r++]=h),p!==h&&p>=o&&p<=e&&(i[r++]=p),r}function oe(s,t,n,o,e,i,r){if(s===0)return se(t,n,o,e,i,r);const c=1/s;t*=c,n*=c,o*=c;const a=Vt(t,n,o,e),l=Vt(t,n,o,i),h=t*t-3*n;let p=0;if(h<=0)p=en(t,n,o,e,i,a,l,r,0);else{const f=Math.sqrt(h)/3,u=-t/3,y=u-f,x=u+f;let g=e,M=a;if(y>e&&y<i){const b=Vt(t,n,o,y);p=en(t,n,o,g,y,M,b,r,p),g=y,M=b}if(x>e&&x<i){const b=Vt(t,n,o,x);p=en(t,n,o,g,x,M,b,r,p),g=x,M=b}p=en(t,n,o,g,i,M,l,r,p)}return l===0&&(r[p++]=i),p}const Z=0,ot=1,kt=2,Ss=4,ee=4,W=[0,0,0];class J{constructor(t,n,o,e,i,r,c,a,l){this.type=t,this.p0x=n,this.p0y=o,this.p1x=e,this.p1y=i,this.p2x=r,this.p2y=c,this.p3x=a,this.p3y=l,this.color=7}endX(){switch(this.type){case Z:return this.p1x;case ot:return this.p2x;default:return this.p3x}}endY(){switch(this.type){case Z:return this.p1y;case ot:return this.p2y;default:return this.p3y}}point(t,n){const o=t;switch(this.type){case Z:{n[0]=this.p0x+o*(this.p1x-this.p0x),n[1]=this.p0y+o*(this.p1y-this.p0y);return}case ot:{const e=this.p0x+o*(this.p1x-this.p0x),i=this.p0y+o*(this.p1y-this.p0y),r=this.p1x+o*(this.p2x-this.p1x),c=this.p1y+o*(this.p2y-this.p1y);n[0]=e+o*(r-e),n[1]=i+o*(c-i);return}default:{const e=this.p0x+o*(this.p1x-this.p0x),i=this.p0y+o*(this.p1y-this.p0y),r=this.p1x+o*(this.p2x-this.p1x),c=this.p1y+o*(this.p2y-this.p1y),a=this.p2x+o*(this.p3x-this.p2x),l=this.p2y+o*(this.p3y-this.p2y),h=e+o*(r-e),p=i+o*(c-i),f=r+o*(a-r),u=c+o*(l-c);n[0]=h+o*(f-h),n[1]=p+o*(u-p);return}}}direction(t,n){const o=t;switch(this.type){case Z:{n[0]=this.p1x-this.p0x,n[1]=this.p1y-this.p0y;return}case ot:{const e=this.p1x-this.p0x+o*(this.p2x-this.p1x-(this.p1x-this.p0x)),i=this.p1y-this.p0y+o*(this.p2y-this.p1y-(this.p1y-this.p0y));e!==0||i!==0?(n[0]=e,n[1]=i):(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y);return}default:{const e=this.p1x-this.p0x,i=this.p1y-this.p0y,r=this.p2x-this.p1x,c=this.p2y-this.p1y,a=this.p3x-this.p2x,l=this.p3y-this.p2y,h=e+o*(r-e)+o*(r+o*(a-r)-(e+o*(r-e))),p=i+o*(c-i)+o*(c+o*(l-c)-(i+o*(c-i)));h!==0||p!==0?(n[0]=h,n[1]=p):o===0?(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y):o===1?(n[0]=this.p3x-this.p1x,n[1]=this.p3y-this.p1y):(n[0]=h,n[1]=p);return}}}splitInThirds(){const t=[0,0],n=[0,0];switch(this.type){case Z:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const o=new J(Z,this.p0x,this.p0y,t[0],t[1],0,0,0,0),e=new J(Z,t[0],t[1],n[0],n[1],0,0,0,0),i=new J(Z,n[0],n[1],this.p1x,this.p1y,0,0,0,0);return o.color=e.color=i.color=this.color,[o,e,i]}case ot:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const o=this.p0x+1/3*(this.p1x-this.p0x),e=this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+5/9*(this.p1x-this.p0x),r=this.p0y+5/9*(this.p1y-this.p0y),c=this.p1x+4/9*(this.p2x-this.p1x),a=this.p1y+4/9*(this.p2y-this.p1y),l=i+.5*(c-i),h=r+.5*(a-r),p=this.p1x+2/3*(this.p2x-this.p1x),f=this.p1y+2/3*(this.p2y-this.p1y),u=new J(ot,this.p0x,this.p0y,o,e,t[0],t[1],0,0),y=new J(ot,t[0],t[1],l,h,n[0],n[1],0,0),x=new J(ot,n[0],n[1],p,f,this.p2x,this.p2y,0,0);return u.color=y.color=x.color=this.color,[u,y,x]}default:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const o=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0x:this.p0x+1/3*(this.p1x-this.p0x),e=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0y:this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+1/3*(this.p1x-this.p0x),r=this.p0y+1/3*(this.p1y-this.p0y),c=this.p1x+1/3*(this.p2x-this.p1x),a=this.p1y+1/3*(this.p2y-this.p1y),l=this.p2x+1/3*(this.p3x-this.p2x),h=this.p2y+1/3*(this.p3y-this.p2y),p=i+1/3*(c-i),f=r+1/3*(a-r),u=c+1/3*(l-c),y=a+1/3*(h-a),x=p+2/3*(u-p),g=f+2/3*(y-f),M=this.p0x+2/3*(this.p1x-this.p0x),b=this.p0y+2/3*(this.p1y-this.p0y),A=this.p1x+2/3*(this.p2x-this.p1x),T=this.p1y+2/3*(this.p2y-this.p1y),I=this.p2x+2/3*(this.p3x-this.p2x),S=this.p2y+2/3*(this.p3y-this.p2y),q=M+2/3*(A-M),m=b+2/3*(T-b),d=A+2/3*(I-A),_=T+2/3*(S-T),w=q+1/3*(d-q),E=m+1/3*(_-m),k=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3x:this.p2x+2/3*(this.p3x-this.p2x),v=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3y:this.p2y+2/3*(this.p3y-this.p2y),F=new J(kt,this.p0x,this.p0y,o,e,p,f,t[0],t[1]),O=new J(kt,t[0],t[1],x,g,w,E,n[0],n[1]),L=new J(kt,n[0],n[1],d,_,k,v,this.p3x,this.p3y);return F.color=O.color=L.color=this.color,[F,O,L]}}}signedDistance(t,n,o){switch(this.type){case Z:{const e=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=t-e,l=n-i,h=r-e,p=c-i,f=h*h+p*p,u=(a*h+l*p)/f,y=u>.5,x=(y?r:e)-t,g=(y?c:i)-n,M=Math.sqrt(x*x+g*g);if(u>0&&u<1){const T=Math.sqrt(h*h+p*p),I=h/T,q=p/T*a-I*l;if(Math.abs(q)<M){o.distance=q,o.dot=0,o.param=u;return}}const b=a*p-l*h;o.distance=Rt(b)*M;const A=Math.sqrt(h*h+p*p);o.dot=M===0||A===0?0:Math.abs((h*x+p*g)/(A*M)),o.param=u;return}case ot:{const e=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=e-t,p=i-n,f=r-e,u=c-i,y=a-r-f,x=l-c-u,g=y*y+x*x,M=3*(f*y+u*x),b=2*(f*f+u*u)+(h*y+p*x),A=h*f+p*u,T=oe(g,M,b,A,0,1,W);let I=f,S=u;const q=h*h+p*p;let m=Rt(I*p-S*h),d=q,_=-(h*I+p*S)/(I*I+S*S);{const E=a-t,k=l-n,v=E*E+k*k;v<d&&(I=a-r,S=l-c,m=Rt(I*k-S*E),d=v,_=((t-r)*I+(n-c)*S)/(I*I+S*S))}for(let E=0;E<T;++E){const k=W[E];if(k>0&&k<1){const v=h+2*k*f+k*k*y,F=p+2*k*u+k*k*x,O=v*v+F*F;if(O<=d){const L=f+k*y,B=u+k*x;m=Rt(L*F-B*v),d=O,_=k}}}const w=m*Math.sqrt(d);if(_>=0&&_<=1){o.distance=w,o.dot=0,o.param=_;return}if(o.distance=w,o.param=_,_<.5){const E=Math.sqrt(f*f+u*u),k=Math.sqrt(q);o.dot=k===0||E===0?0:Math.abs((f*h+u*p)/(E*k))}else{const E=a-r,k=l-c,v=a-t,F=l-n,O=Math.sqrt(E*E+k*k),L=Math.sqrt(v*v+F*F);o.dot=O===0||L===0?0:Math.abs((E*v+k*F)/(O*L))}return}default:{const e=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,p=this.p3y,f=e-t,u=i-n,y=r-e,x=c-i,g=a-r-y,M=l-c-x,b=h-a-(a-r)-g,A=p-l-(l-c)-M;let T=y,I=x;T===0&&I===0&&(T=a-e,I=l-i);const S=Math.sqrt(f*f+u*u);let q=Rt(T*u-I*f)*S,m=-(f*T+u*I)/(T*T+I*I);{const d=h-t,_=p-n,w=Math.sqrt(d*d+_*_);if(w<Math.abs(q)){let E=h-a,k=p-l;E===0&&k===0&&(E=h-r,k=p-c),T=E,I=k,q=Rt(T*_-I*d)*w,m=((T-d)*T+(I-_)*I)/(T*T+I*I)}}for(let d=0;d<=Ss;++d){let _=1/Ss*d,w=f+3*_*y+3*_*_*g+_*_*_*b,E=u+3*_*x+3*_*_*M+_*_*_*A,k=3*y+6*_*g+3*_*_*b,v=3*x+6*_*M+3*_*_*A,F=6*g+6*_*b,O=6*M+6*_*A,L=_-(w*k+E*v)/(k*k+v*v+(w*F+E*O));if(L>0&&L<1){let B=ee;do{if(_=L,w=f+3*_*y+3*_*_*g+_*_*_*b,E=u+3*_*x+3*_*_*M+_*_*_*A,k=3*y+6*_*g+3*_*_*b,v=3*x+6*_*M+3*_*_*A,!--B)break;F=6*g+6*_*b,O=6*M+6*_*A,L=_-(w*k+E*v)/(k*k+v*v+(w*F+E*O))}while(L>0&&L<1);const X=Math.sqrt(w*w+E*E);X<Math.abs(q)&&(q=Rt(k*E-v*w)*X,m=_)}}if(m>=0&&m<=1){o.distance=q,o.dot=0,o.param=m;return}if(o.distance=q,o.param=m,m<.5){let d=y,_=x;d===0&&_===0&&(d=a-e,_=l-i);const w=Math.sqrt(d*d+_*_);o.dot=S===0||w===0?0:Math.abs((d*f+_*u)/(w*S))}else{let d=h-a,_=p-l;d===0&&_===0&&(d=h-r,_=p-c);const w=h-t,E=p-n,k=Math.sqrt(d*d+_*_),v=Math.sqrt(w*w+E*E);o.dot=k===0||v===0?0:Math.abs((d*w+_*E)/(k*v))}return}}}scanlineIntersections(t,n,o){switch(this.type){case Z:{const e=this.p0y,i=this.p1y;if(t>=e&&t<i||t>=i&&t<e){const r=(t-e)/(i-e);return n[0]=vs(this.p0x,this.p1x,r),o[0]=ht(i-e),1}return 0}case ot:{const e=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y;let h=0,p=t>i?1:-1;n[h]=e,i===t&&(i<c||i===c&&i<l?o[h++]=1:p=1);{const f=r-e,u=c-i,y=a-r-f,x=l-c-u,g=Cs(W,x,2*u,i-t);if(g>=2&&W[0]>W[1]){const M=W[0];W[0]=W[1],W[1]=M}for(let M=0;M<g&&h<2;++M){const b=W[M];b>=0&&b<=1&&(n[h]=e+2*b*f+b*b*y,p*(u+b*x)>=0&&(o[h++]=p,p=-p))}}return l===t&&(p>0&&h>0&&(--h,p=-1),(l<c||l===c&&l<i)&&h<2&&(n[h]=a,p<0&&(o[h++]=-1,p=1))),p!==(t>=l?1:-1)&&(h>0?--h:(Math.abs(l-t)<Math.abs(i-t)&&(n[h]=a),o[h++]=p)),h}default:{const e=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,p=this.p3y;let f=0,u=t>i?1:-1;n[f]=e,i===t&&(i<c||i===c&&(i<l||i===l&&i<p)?o[f++]=1:u=1);{const y=h-3*a+3*r-e,x=p-3*l+3*c-i,g=3*a-6*r+3*e,M=3*l-6*c+3*i,b=3*r-3*e,A=3*c-3*i,T=Jo(W,x,M,A,i-t);if(T>=2){if(W[0]>W[1]){const I=W[0];W[0]=W[1],W[1]=I}if(T>=3&&W[1]>W[2]){const I=W[1];if(W[1]=W[2],W[2]=I,W[0]>W[1]){const S=W[0];W[0]=W[1],W[1]=S}}}for(let I=0;I<T&&f<3;++I){const S=W[I];S>=0&&S<=1&&(n[f]=((y*S+g)*S+b)*S+e,u*((3*x*S+2*M)*S+A)>=0&&(o[f++]=u,u=-u))}}return p===t&&(u>0&&f>0&&(--f,u=-1),(p<l||p===l&&(p<c||p===c&&p<i))&&f<3&&(n[f]=h,u<0&&(o[f++]=-1,u=1))),u!==(t>=p?1:-1)&&(f>0?--f:(Math.abs(p-t)<Math.abs(i-t)&&(n[f]=h),o[f++]=u)),f}}}convertToCubic(){const t=this.p0x+.6666666666666666*(this.p1x-this.p0x),n=this.p0y+2/3*(this.p1y-this.p0y),o=this.p1x+1/3*(this.p2x-this.p1x),e=this.p1y+1/3*(this.p2y-this.p1y),i=new J(kt,this.p0x,this.p0y,t,n,o,e,this.p2x,this.p2y);return i.color=this.color,i}}class mt{constructor(t,n=0){this._view=new DataView(t),this._pos=n}get pos(){return this._pos}seek(t){this._pos=t}skip(t){this._pos+=t}u8(){return this._view.getUint8(this._pos++)}u16(){const t=this._view.getUint16(this._pos,!1);return this._pos+=2,t}i16(){const t=this._view.getInt16(this._pos,!1);return this._pos+=2,t}u32(){const t=this._view.getUint32(this._pos,!1);return this._pos+=4,t}i32(){const t=this._view.getInt32(this._pos,!1);return this._pos+=4,t}f2dot14(){return this.i16()/16384}offset16(){return this.u16()}offset32(){return this.u32()}peekU16(t){return this._view.getUint16(t,!1)}peekU32(t){return this._view.getUint32(t,!1)}peekI16(t){return this._view.getInt16(t,!1)}}function ie(s,t){const n=new mt(s,t);n.skip(2);const o=n.u16();let e=null;for(let r=0;r<o;r++){const c=n.u16(),a=n.u16(),l=n.u32(),h=t+l,p=n.peekU16(h);let f=-1;c===3&&a===10&&p===12?f=5:c===0&&a===6&&p===12?f=4:c===0&&a===4&&p===12?f=3:c===3&&a===1&&p===4?f=2:c===0&&a<=3&&p===4&&(f=1),f>((e==null?void 0:e.priority)??-1)&&(e={priority:f,subtableAbsOffset:h})}if(!e)return()=>0;const i=n.peekU16(e.subtableAbsOffset);return i===12?ce(s,e.subtableAbsOffset):i===4?re(s,e.subtableAbsOffset):()=>0}function ce(s,t){const n=new mt(s,t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);const o=n.u32(),e=new Uint32Array(o),i=new Uint32Array(o),r=new Uint32Array(o);for(let c=0;c<o;c++)e[c]=n.u32(),i[c]=n.u32(),r[c]=n.u32();return c=>{let a=0,l=o-1;for(;a<=l;){const h=a+l>>>1,p=e[h]??0,f=i[h]??0;if(c<p)l=h-1;else if(c>f)a=h+1;else return(r[h]??0)+(c-p)}return 0}}function re(s,t){const n=new mt(s,t);n.skip(2),n.skip(2),n.skip(2);const e=n.u16()>>>1;n.skip(6);const i=new Uint16Array(e);for(let p=0;p<e;p++)i[p]=n.u16();n.skip(2);const r=new Uint16Array(e);for(let p=0;p<e;p++)r[p]=n.u16();const c=new Int16Array(e);for(let p=0;p<e;p++)c[p]=n.i16();const a=new Int32Array(e),l=new Uint16Array(e);for(let p=0;p<e;p++)a[p]=n.pos,l[p]=n.u16();const h=new DataView(s);return p=>{if(p>65535)return 0;let f=0,u=e-1;for(;f<=u;){const y=f+u>>>1,x=i[y]??0;if(p>x)f=y+1;else if(p<(r[y]??0))u=y-1;else{if((i[y]??0)===65535)return 0;const M=l[y]??0,b=c[y]??0,A=r[y]??0;if(M===0)return p+b&65535;const T=(a[y]??0)+M+(p-A)*2,I=h.getUint16(T,!1);return I===0?0:I+b&65535}}return 0}}function ae(s,t){const n=new mt(s,t);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);const o=n.u16();n.skip(16),n.skip(8),n.skip(2),n.skip(2),n.skip(2);const e=n.i16();return{unitsPerEm:o,indexToLocFormat:e}}function le(s,t){const n=new mt(s,t);n.skip(4);const o=n.i16(),e=n.i16(),i=n.i16();n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(8),n.skip(2);const r=n.u16();return{ascender:o,descender:e,lineGap:i,numberOfHMetrics:r}}function he(s,t,n,o){const e=new mt(s,t),i=[];let r=0;for(let c=0;c<o;c++){const a=e.u16(),l=e.i16();i[c]={advanceWidth:a,lsb:l},r=a}for(let c=o;c<n;c++){const a=e.i16();i[c]={advanceWidth:r,lsb:a}}return i}function pe(s,t,n,o){const e=new mt(s,t),i=n+1,r=[];if(o===0)for(let c=0;c<i;c++)r[c]=e.u16()*2;else for(let c=0;c<i;c++)r[c]=e.u32();return r}function fe(s,t){const n=new mt(s,t);return n.skip(4),{numGlyphs:n.u16()}}const ue=1,ye=2,xe=4,_e=8,Ts=16,Fs=32,ge=1,Rs=2,de=8,Me=32,me=64,be=128;function we(s,t,n,o,e){const i=Ls(s,t,n,o,e),r=[];for(const c of i){const a=ke(c);a.length>0&&r.push(a)}return{contours:r,inverseYAxis:!1}}function Ls(s,t,n,o,e){if(o===0)return[];const i=t+n,r=new mt(s,i),c=r.i16();return r.skip(8),c>=0?Ae(r,c):Ee(s,r,t,e)}function Ae(s,t){if(t===0)return[];const n=[];for(let p=0;p<t;p++)n[p]=s.u16();const o=(n[t-1]??0)+1,e=s.u16();s.skip(e);const i=new Uint8Array(o);for(let p=0;p<o;){const f=s.u8();if(i[p++]=f,f&_e){let u=s.u8();for(;u-- >0;)i[p++]=f}}const r=new Float64Array(o);let c=0;for(let p=0;p<o;p++){const f=i[p]??0;if(f&ye){const u=s.u8();c+=f&Ts?u:-u}else f&Ts||(c+=s.i16());r[p]=c}const a=new Float64Array(o);c=0;for(let p=0;p<o;p++){const f=i[p]??0;if(f&xe){const u=s.u8();c+=f&Fs?u:-u}else f&Fs||(c+=s.i16());a[p]=c}const l=[];let h=0;for(let p=0;p<t;p++){const f=n[p]??0,u=Ie(i,r,a,h,f);u.length>0&&l.push(u),h=f+1}return l}function Ie(s,t,n,o,e){const i=e-o+1;if(i<=0)return[];const r=[];for(let c=0;c<i;c++){const a=s[o+c]??0,l=t[o+c]??0,h=n[o+c]??0;r.push({x:l,y:h,onCurve:(a&ue)!==0})}return r}function ke(s){const t=s.length;if(t<=0)return[];const n=[];for(let c=0;c<t;c++){const a=s[c],l=s[(c+1)%t];n.push(a),!a.onCurve&&!l.onCurve&&n.push({x:Math.trunc((a.x+l.x)/2),y:Math.trunc((a.y+l.y)/2),onCurve:!0})}const o=n.length;let e=0;if(!n[0].onCurve){for(let c=1;c<o;c++)if(n[c].onCurve){e=c;break}}const i=[];let r=0;for(;r<o;){const c=n[(e+r)%o],a=n[(e+r+1)%o];if(a.onCurve)i.push(new J(Z,c.x,c.y,a.x,a.y,0,0,0,0)),r+=1;else{const l=n[(e+r+2)%o];i.push(new J(ot,c.x,c.y,a.x,a.y,l.x,l.y,0,0)),r+=2}}return i}function Ee(s,t,n,o){const e=[];let i=0;do{i=t.u16();const r=t.u16();let c,a;i&ge?(c=t.i16(),a=t.i16()):(c=t.u8(),a=t.u8(),i&Rs&&(c>127&&(c-=256),a>127&&(a-=256)));let l=0,h=0;i&Rs&&(l=c,h=a);let p=1,f=0,u=0,y=1;i&de?p=y=t.f2dot14():i&me?(p=t.f2dot14(),y=t.f2dot14()):i&be&&(p=t.f2dot14(),f=t.f2dot14(),u=t.f2dot14(),y=t.f2dot14());const x=o(r),g=De(x,p,f,u,y,l,h);for(const M of g)e.push(M)}while(i&Me);return e}function Ps(s){return s>=0?Math.floor(s+.5):Math.ceil(s-.5)}function De(s,t,n,o,e,i,r){if(t===1&&n===0&&o===0&&e===1&&i===0&&r===0)return s;const a=t===1&&n===0&&o===0&&e===1;return s.map(l=>l.map(h=>a?{x:h.x+i,y:h.y+r,onCurve:h.onCurve}:{x:Ps(t*h.x+n*h.y+i),y:Ps(o*h.x+e*h.y+r),onCurve:h.onCurve}))}function qe(s,t){const n=new mt(s,t);if(n.u16()!==0)return $s;const e=n.u16(),i=new Map;for(let r=0;r<e;r++){const c=n.pos;n.skip(2);const a=n.u16(),l=n.u16(),h=l>>8&255,p=!(l&2),f=!!(l&4);if(h!==0||!p||f){n.seek(c+a);continue}const u=n.u16();n.skip(6);for(let y=0;y<u;y++){const x=n.u16(),g=n.u16(),M=n.i16(),b=(x&65535)<<16|g&65535;i.set(b,M)}n.seek(c+a)}return i.size===0?$s:(r,c)=>{const a=(r&65535)<<16|c&65535;return i.get(a)??0}}const $s=()=>0;function ve(s){const t=new mt(s);if(t.u32()===1953784678){if(t.skip(4),t.u32()===0)throw new Error("TTC contains no fonts");const e=t.u32();t.seek(e)}else t.seek(0);return Ce(s,t)}function Ce(s,t){t.skip(4);const n=t.u16();t.skip(6);const o=new Map;for(let e=0;e<n;e++){const i=String.fromCharCode(t.u8(),t.u8(),t.u8(),t.u8());t.skip(4);const r=t.u32(),c=t.u32();o.set(i,{offset:r,length:c})}return o}class Se{constructor(t){this._buffer=t,this._tables=ve(t);const n=this._tables.get("head"),o=this._tables.get("maxp"),e=this._tables.get("hhea"),i=this._tables.get("hmtx"),r=this._tables.get("loca"),c=this._tables.get("cmap");if(!n)throw new Error("Font missing required `head` table");if(!o)throw new Error("Font missing required `maxp` table");if(!e)throw new Error("Font missing required `hhea` table");if(!i)throw new Error("Font missing required `hmtx` table");if(!r)throw new Error("Font missing required `loca` table");if(!c)throw new Error("Font missing required `cmap` table");this._head=ae(t,n.offset);const a=fe(t,o.offset);this._hhea=le(t,e.offset),this._hmtx=he(t,i.offset,a.numGlyphs,this._hhea.numberOfHMetrics),this._loca=pe(t,r.offset,a.numGlyphs,this._head.indexToLocFormat),this._cmap=ie(t,c.offset);const l=this._tables.get("kern");this._kern=l?qe(t,l.offset):()=>0,this.metrics={unitsPerEm:this._head.unitsPerEm,ascender:this._hhea.ascender,descender:this._hhea.descender,lineGap:this._hhea.lineGap}}glyphId(t){return this._cmap(t)}get numGlyphs(){return this._loca.length-1}advance(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{advanceWidth:0}).advanceWidth}lsb(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{lsb:0}).lsb}kerning(t,n){return this._kern(t,n)}shape(t){const n=this._tables.get("glyf");if(!n)return{contours:[],inverseYAxis:!1};const o=this._loca,e=o[t]??0,r=(o[t+1]??e)-e;return we(this._buffer,n.offset,e,r,c=>this._glyphRaw(c))}_glyphRaw(t){const n=this._tables.get("glyf");if(!n)return[];const o=this._loca,e=o[t]??0,r=(o[t+1]??e)-e;return Ls(this._buffer,n.offset,e,r,c=>this._glyphRaw(c))}}function cn(s,t){const n=1/t;for(const o of s.contours)for(let e=0;e<o.length;e++){const i=o[e];if(i.p0x*=n,i.p0y*=n,i.p1x*=n,i.p1y*=n,i.p2x*=n,i.p2y*=n,i.p3x*=n,i.p3y*=n,i.type===ot){const r=i.p1x-i.p0x,c=i.p1y-i.p0y,a=i.p2x-i.p1x,l=i.p2y-i.p1y;K(r,c,a,l)===0&&(o[e]=new J(Z,i.p0x,i.p0y,i.p2x,i.p2y,0,0,0,0))}else if(i.type===kt){const r=i.p2x-i.p1x,c=i.p2y-i.p1y,a=1.5*i.p1x-.5*i.p0x,l=1.5*i.p1y-.5*i.p0y;K(i.p1x-i.p0x,i.p1y-i.p0y,r,c)===0&&K(r,c,i.p3x-i.p2x,i.p3y-i.p2y)===0?o[e]=new J(Z,i.p0x,i.p0y,i.p3x,i.p3y,0,0,0,0):a===1.5*i.p2x-.5*i.p3x&&l===1.5*i.p2y-.5*i.p3y&&(o[e]=new J(ot,i.p0x,i.p0y,a,l,i.p3x,i.p3y,0,0))}}}const Os=1e-6,Te=1.1111111111111112,Fe=new Float64Array(16);function Ns(s,t,n){switch(t[n]=s.p0x,t[n+1]=s.p0y,t[n+2]=s.p1x,t[n+3]=s.p1y,s.type){case Z:return 1;case ot:return t[n+4]=s.p2x,t[n+5]=s.p2y,2;default:return t[n+4]=s.p2x,t[n+5]=s.p2y,t[n+6]=s.p3x,t[n+7]=s.p3y,3}}function Us(s,t,n){if(n===3){const o=s[t],e=s[t+1],i=s[t+2],r=s[t+3],c=s[t+4],a=s[t+5],l=s[t+6],h=s[t+7];(i===o&&r===e||i===l&&r===h)&&(c===o&&a===e||c===l&&a===h)&&(s[t+2]=l,s[t+3]=h,n=1)}if(n===2){const o=s[t],e=s[t+1],i=s[t+2],r=s[t+3],c=s[t+4],a=s[t+5];(i===o&&r===e||i===c&&r===a)&&(s[t+2]=c,s[t+3]=a,n=1)}return n===1&&s[t]===s[t+2]&&s[t+1]===s[t+3]&&(n=0),n}function Re(s,t){const n=Fe;let o=Ns(s,n,0),e=Ns(t,n,8);if(!(o>=1&&o<=3&&e>=1&&e<=3)||n[o*2]!==n[8]||n[o*2+1]!==n[9])return 0;o=Us(n,0,o),e=Us(n,8,e);const i=n[o*2],r=n[o*2+1];let c=0,a=0,l=0,h=0,p=0,f=0,u=0,y=0,x=0,g=0,M=0,b=0;if(o>=1&&(c=n[(o-1)*2]-i,a=n[(o-1)*2+1]-r),o>=2){const X=n[(o-2)*2]-n[(o-1)*2],V=n[(o-2)*2+1]-n[(o-1)*2+1];l=X-c,h=V-a}if(o>=3){const X=n[(o-3)*2]-n[(o-2)*2],V=n[(o-3)*2+1]-n[(o-2)*2+1],st=n[(o-2)*2]-n[(o-1)*2],z=n[(o-2)*2+1]-n[(o-1)*2+1];p=X-st-l,f=V-z-h,l*=3,h*=3}if(e>=1&&(u=n[10]-i,y=n[11]-r),e>=2){const X=n[12]-n[10],V=n[13]-n[11];x=X-u,g=V-y}if(e>=3){const X=n[14]-n[12],V=n[15]-n[13],st=n[12]-n[10],z=n[13]-n[11];M=X-st-x,b=V-z-g,x*=3,g*=3}c*=o,a*=o,u*=e,y*=e;const A=c!==0||a!==0;if(A&&(u!==0||y!==0)){const X=Math.sqrt(c*c+a*a),V=Math.sqrt(u*u+y*y),st=X*K(c,a,x,g)+V*K(l,h,u,y);if(st)return ht(st);const z=X*X*K(c,a,M,b)+X*V*K(l,h,x,g)+V*V*K(p,f,u,y);if(z)return ht(z);const vt=X*K(l,h,M,b)+V*K(p,f,x,g);return ht(vt||K(p,f,M,b))}let I=1,S=l,q=h,m=p,d=f,_=u,w=y,E=x,k=g,v=M,F=b;if(A&&(S=x,q=g,m=M,d=b,_=c,w=a,E=l,k=h,v=p,F=f,I=-1),_!==0||w!==0){const X=K(m,d,_,w);if(X)return I*ht(X);const V=K(S,q,E,k);if(V)return I*ht(V);const st=K(m,d,E,k);if(st)return I*ht(st);const z=K(S,q,v,F);return z?I*ht(z):I*ht(K(m,d,v,F))}const O=Math.sqrt(S*S+q*q),L=Math.sqrt(E*E+k*k),B=Math.sqrt(O)*K(S,q,v,F)+Math.sqrt(L)*K(m,d,E,k);return ht(B||K(m,d,v,F))}function Gs(s,t,n,o,e){let i=s[t];if(i.type===ot){const r=i.convertToCubic();s[t]=r,i=r}if(i.type===kt)if(n===0){const r=Math.sqrt((i.p1x-i.p0x)**2+(i.p1y-i.p0y)**2);i.p1x+=r*o,i.p1y+=r*e}else{const r=Math.sqrt((i.p2x-i.p3x)**2+(i.p2y-i.p3y)**2);i.p2x+=r*o,i.p2y+=r*e}}const jt=[0,0],zt=[0,0];function Le(s){for(let t=0;t<s.contours.length;t++){const n=s.contours[t];let o=0;for(let e=0;e<n.length;e++){const i=n[e];(i.p0x!==i.endX()||i.p0y!==i.endY())&&(n[o++]=i)}n.length=o}for(const t of s.contours)if(t.length===1){const[n,o,e]=t[0].splitInThirds();t.length=0,t.push(n,o,e)}else if(t.length>0){const n=t.length;for(let o=0;o<n;o++){const e=(o+n-1)%n,i=t[e],r=t[o];i.direction(1,jt),r.direction(0,zt);const c=Math.sqrt(jt[0]**2+jt[1]**2),a=Math.sqrt(zt[0]**2+zt[1]**2);if(c===0||a===0)continue;const l=jt[0]/c,h=jt[1]/c,p=zt[0]/a,f=zt[1]/a;if(Ko(l,h,p,f)<Os-1){const u=Os-1,y=Te*Math.sqrt(1-u*u)/u;let x=p-l,g=f-h;const M=Math.sqrt(x*x+g*g);if(M===0)continue;x=y*x/M,g=y*g/M,Re(i,r)<0&&(x=-x,g=-g),Gs(t,e,1,-g,x),Gs(t,o,0,g,-x)}}}}const Ys=[0,0,0],Xs=[0,0,0],Bs=[0,0];function Ws(s){const t=.5*(Math.sqrt(5)-1),n=s.map(()=>0),o=[];for(let e=0;e<s.length;e++){const i=s[e];if(n[e]||i.length===0)continue;const r=i[0].p0y;let c=r;for(let l=0;l<i.length&&r===c;l++)c=i[l].endY();for(let l=0;l<i.length&&r===c;l++)i[l].point(t,Bs),c=Bs[1];const a=vs(r,c,t);for(let l=0;l<s.length;l++)for(const h of s[l]){const p=h.scanlineIntersections(a,Ys,Xs);for(let f=0;f<p;f++)o.push({x:Ys[f],dy:Xs[f],c:l})}o.sort((l,h)=>ht(l.x-h.x));for(let l=1;l<o.length;l++)o[l].x===o[l-1].x&&(o[l].dy=o[l-1].dy=0);for(let l=0;l<o.length;l++){const h=o[l];h.dy&&(n[h.c]+=2*(l&1^(h.dy>0?1:0))-1)}o.length=0}for(let e=0;e<s.length;e++){if(n[e]>=0)continue;const i=s[e].reverse();for(let r=0;r<i.length;r++){const c=i[r];i[r]=c.type===Z?new J(Z,c.p1x,c.p1y,c.p0x,c.p0y,0,0,0,0):c.type===ot?new J(ot,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y,0,0):new J(kt,c.p3x,c.p3y,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y)}}}const Hs=1e-5,Fn=1e-6,Pe=2e4,$e=1e5;function Oe(s){return[s.p0x,s.p0y,s.p1x,s.p1y,s.p2x,s.p2y,s.p3x,s.p3y].slice(0,2*s.type+4)}function Vs(s){const t=s.length/2-2;return new J(t,s[0],s[1],s[2],s[3],s[4]??0,s[5]??0,s[6]??0,s[7]??0)}const rt=new Float64Array(8),at=new Float64Array(8),Lt=new Float64Array(8);function Rn(s,t,n,o){const e=s.length,i=e/2-1;for(let r=0;r<=i;r++){for(let c=0;c<e;c++)Lt[c]=s[c];for(let c=0,a=e;c<i;c++,a-=2){const l=c<i-r?t:n;for(let h=0;h<a-2;h++)Lt[h]=Lt[h]+l*(Lt[h+2]-Lt[h])}o[2*r]=Lt[0],o[2*r+1]=Lt[1]}}function Ne(s,t,n){return Rn(s,t,n,rt),Array.from(rt.subarray(0,s.length))}let Ln=0,Pn=0,qt=-1,Qt=-1,Kt=0,Zt=0,rn=0,an=0;function Ue(s,t){qt=-1,Qt=-1;let n=0;for(let h=0;h<2;h++){const p=h?s.length-2:0;for(let f=0;f<2;f++){const u=f?t.length-2:0;s[p]===t[u]&&s[p+1]===t[u+1]&&(n++,qt=h,Qt=f)}}if(n!==1){qt=-1;return}const o=qt?s.length-2:0;Kt=s[o],Zt=s[o+1];let e=0,i=0;for(let h=2;h<s.length&&e===0&&i===0;h+=2){const p=qt?s.length-2-h:h;e=s[p]-Kt,i=s[p+1]-Zt}let r=0,c=0;for(let h=2;h<t.length&&r===0&&c===0;h+=2){const p=Qt?t.length-2-h:h;r=t[p]-Kt,c=t[p+1]-Zt}const a=Math.hypot(e,i),l=Math.hypot(r,c);rn=e/a-r/l,an=i/a-c/l,Math.hypot(rn,an)>1e-9||(qt=-1)}function Ge(s,t){const n=qt?s-2:0;for(let e=0;e<s;e+=2)if(e!==n&&(rt[e]-Kt)*rn+(rt[e+1]-Zt)*an<=0)return!1;const o=Qt?t-2:0;for(let e=0;e<t;e+=2)if(e!==o&&(at[e]-Kt)*rn+(at[e+1]-Zt)*an>=0)return!1;return!0}function Jt(s,t,n,o,e,i,r){if(--Ln<0||--Pn<0)return;const c=s.length,a=o.length;Rn(s,t,n,rt),Rn(o,e,i,at);let l=1/0,h=1/0,p=-1/0,f=-1/0;for(let A=0;A<c;A+=2)l=Math.min(l,rt[A]),h=Math.min(h,rt[A+1]),p=Math.max(p,rt[A]),f=Math.max(f,rt[A+1]);let u=1/0,y=1/0,x=-1/0,g=-1/0;for(let A=0;A<a;A+=2)u=Math.min(u,at[A]),y=Math.min(y,at[A+1]),x=Math.max(x,at[A]),g=Math.max(g,at[A+1]);if(l>x||u>p||h>g||y>f||qt>=0&&(qt?n===1:t===0)&&(Qt?i===1:e===0)&&Ge(c,a))return;const M=Math.max(p-l,f-h),b=Math.max(x-u,g-y);if(c===4&&a===4||M<Hs&&b<Hs){const A=rt[c-2]-rt[0],T=rt[c-1]-rt[1],I=at[a-2]-at[0],S=at[a-1]-at[1],q=K(A,T,I,S),m=K(at[0]-rt[0],at[1]-rt[1],I,S)/q,d=K(at[0]-rt[0],at[1]-rt[1],A,T)/q;m>=0&&m<=1&&d>=0&&d<=1&&r.push(t+m*(n-t),e+d*(i-e))}else M>b?(Jt(s,t,(t+n)/2,o,e,i,r),Jt(s,(t+n)/2,n,o,e,i,r)):(Jt(s,t,n,o,e,(e+i)/2,r),Jt(s,t,n,o,(e+i)/2,i,r))}function ln(s,t,n){const o=s[2]-s[0],e=s[3]-s[1];return((t-s[0])*o+(n-s[1])*e)/(o*o+e*e)}function Ye(s,t,n){if(s.length!==4||t.length!==4)return!1;const o=s[2]-s[0],e=s[3]-s[1],i=1e-9*Math.hypot(o,e);return Math.abs(K(o,e,t[0]-s[0],t[1]-s[1]))>i||Math.abs(K(o,e,t[2]-s[0],t[3]-s[1]))>i?!1:(n.push(ln(s,t[0],t[1]),0,ln(s,t[2],t[3]),1),n.push(0,ln(t,s[0],s[1]),1,ln(t,s[2],s[3])),!0)}function Xe(s){const t=[];for(let n=s.length-2;n>=0;n-=2)t.push(s[n],s[n+1]);return t}function Be(s,t){if(s.length!==t.length)return!1;for(let n=0;n<s.length;n++)if(!(Math.abs(s[n]-t[n])<Fn))return!1;return!0}const tn=[0,0],Pt=[0,0],hn=[0,0,0],pn=[0,0,0];let Gt=new Int32Array(8);const We=0,js=1,He=2;function zs(s,t,n,o){let e=0;for(let i=0;i<s.length;i++){if(o<t[4*i+1]-1e-9||o>t[4*i+3]+1e-9)continue;const r=s[i].scanlineIntersections(o,hn,pn);for(let c=0;c<r;c++)hn[c]<=n&&(e+=pn[c])}return e!==0}function Qs(s,t,n,o,e,i,r){Gt.fill(0,0,n);for(let a=0;a<s.length;a++){if(r<e[4*a+1]-1e-9||r>e[4*a+3]+1e-9)continue;const l=s[a].scanlineIntersections(r,hn,pn);for(let h=0;h<l;h++)hn[h]<=i&&(Gt[t[a]]+=pn[h])}let c=!1;for(let a=1;a<n&&!c;a++)c=Gt[a]!==0;return Gt[0]!==0&&(o===js?c:!c)}function Ve(s){const t=$n([s.contours]);t&&(s.contours=t)}function Ks(s,t){const n=$n([s.contours,...t.length>0?t:[[]]],js);n&&(s.contours=n)}function je(s,t){if(t.length===0)return;const n=$n([s.contours,...t],He);n&&(s.contours=n)}function $n(s,t=We){const n=s.flat(),o=n.flat(),e=o.map(Oe),i=e.length,r=s.length,c=r>1;Gt.length<r&&(Gt=new Int32Array(r));const a=new Float64Array(4*i),l=new Int32Array(i),h=new Int32Array(i);let p=0;for(let m=0;m<r;m++)for(const d of s[m]){for(let _=0;_<d.length;_++)l[p+_]=p+(_+1)%d.length,h[p+_]=m;p+=d.length}for(let m=0;m<i;m++){const d=e[m];let _=1/0,w=1/0,E=-1/0,k=-1/0;for(let v=0;v<d.length;v+=2)_=Math.min(_,d[v]),w=Math.min(w,d[v+1]),E=Math.max(E,d[v]),k=Math.max(k,d[v+1]);a[4*m]=_,a[4*m+1]=w,a[4*m+2]=E,a[4*m+3]=k}const f=Array.from({length:i},(m,d)=>d).sort((m,d)=>a[4*m]-a[4*d]),u=e.map(()=>[]),y=new Uint8Array(i);Pn=$e;for(let m=0;m<i;m++){const d=f[m];for(let _=m+1;_<i;_++){const w=f[_];if(a[4*w]>a[4*d+2])break;if(a[4*d+1]>a[4*w+3]||a[4*w+1]>a[4*d+3])continue;const E=Math.min(d,w),k=Math.max(d,w);l[E]!==k&&l[k]!==E&&(y[E]=y[k]=1);const v=[];if(Ln=Pe,Ye(e[E],e[k],v)||(Ue(e[E],e[k]),Jt(e[E],0,1,e[k],0,1,v)),Ln<0||Pn<0)return null;for(let F=0;F<v.length;F+=2)u[E].push(v[F]),u[k].push(v[F+1])}}const x=u.map(m=>{const d=[0];for(const _ of m.sort((w,E)=>w-E))_-d[d.length-1]>1e-7&&_<1-1e-7&&d.push(_);return d.push(1),d});let g=!1;const M=[],b=[];let A=0;for(const m of n){const d=A+m.length;let _=!0;for(let v=A;v<d;v++)(y[v]||x[v].length>2)&&(_=!1);let w=!1,E=!1,k=!1;for(let v=A;v<d;v++){const F=x[v];for(let O=1;O<F.length;O++){const L=Ne(e[v],F[O-1],F[O]),B=Vs(L);B.point(.5,tn),B.direction(.5,Pt);const X=Math.hypot(Pt[0],Pt[1]),V=Math.hypot(L[L.length-2]-L[0],L[L.length-1]-L[1]);if(!(X===0||V===0)){if(!_||!w){const st=Math.min(1e-6,V*V/64)/X,z=tn[0]+Pt[1]*st,vt=tn[1]-Pt[0]*st,ft=tn[0]-Pt[1]*st,Tt=tn[1]+Pt[0]*st;E=c?Qs(o,h,r,t,a,z,vt):zs(o,a,z,vt),k=c?Qs(o,h,r,t,a,ft,Tt):zs(o,a,ft,Tt),w=!0}E===k?h[v]===0&&(g=!0):(M.push(L),b.push(E),h[v]!==0&&(g=!0))}}}A=d}const T=2*b.filter(Boolean).length>=b.length,I=[];for(let m=0;m<M.length;m++){let d=M[m];b[m]!==T&&(d=Xe(d),g=!0);let _=!1;for(let w=0;w<I.length&&!_;w++)_=Be(I[w],d);_?g=!0:I.push(d)}if(!g)return null;const S=new Uint8Array(I.length),q=[];for(let m=0;m<I.length;m++){if(S[m])continue;S[m]=1;const d=[I[m]];for(;;){const _=d[d.length-1],w=_[_.length-2],E=_[_.length-1];if(d.length>1&&Math.hypot(w-d[0][0],E-d[0][1])<Fn){d[0][0]=w,d[0][1]=E;break}let k=-1,v=Fn;for(let F=0;F<I.length;F++){if(S[F])continue;const O=Math.hypot(I[F][0]-w,I[F][1]-E);O<v&&(k=F,v=O)}if(k<0)return null;S[k]=1,I[k][0]=w,I[k][1]=E,d.push(I[k])}q.push(d.map(Vs))}return q}const fn=1,un=2,ze=3,yn=4,Qe=5,Ke=6,On=7,pt=[0,0],$t=[0,0];function Ze(s,t){return Math.trunc(3+2.875*s/(t-1)-1.4375+.5)-3}function Je(s,t,n,o,e){return s*n+t*o<=0||Math.abs(s*o-t*n)>e}function ti(s){const t=Number(s.v&1n);return s.v>>=1n,t}function ni(s){const t=Number(s.v%3n);return s.v/=3n,t}function Zs(s){return[Ke,Qe,ze][ni(s)]}function nn(s,t){const n=s.v<<1+ti(t);s.v=(n|n>>3)&On}function si(s,t,n){const o=s.v&n;o===fn||o===un||o===yn?s.v=o^On:nn(s,t)}function oi(s,t,n=0n){const o=Math.sin(t),e={v:Zs({v:n})},i={v:n};i.v=n,e.v=Zs(i);const r=[];for(const c of s.contours){if(c.length===0)continue;r.length=0,c[c.length-1].direction(1,pt);const l=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]);let h=l>0?pt[0]/l:0,p=l>0?pt[1]/l:0;for(let f=0;f<c.length;f++){const u=c[f];u.direction(0,$t);const y=Math.sqrt($t[0]*$t[0]+$t[1]*$t[1]),x=y>0?$t[0]/y:0,g=y>0?$t[1]/y:0;Je(h,p,x,g,o)&&r.push(f),u.direction(1,pt);const M=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]);h=M>0?pt[0]/M:0,p=M>0?pt[1]/M:0}if(r.length===0){nn(e,i);for(const f of c)f.color=e.v}else if(r.length===1){const f=[0,On,0];nn(e,i),f[0]=e.v,nn(e,i),f[2]=e.v;const u=r[0],y=c.length;if(y>=3)for(let x=0;x<y;x++){const g=Ze(x,y);c[(u+x)%y].color=f[1+g]}else if(y>=1){const x=[null,null,null,null,null,null,null],g=c[0].splitInThirds();if(x[0+3*u]=g[0],x[1+3*u]=g[1],x[2+3*u]=g[2],y>=2){const M=c[1].splitInThirds();x[3-3*u]=M[0],x[4-3*u]=M[1],x[5-3*u]=M[2],x[0].color=x[1].color=f[0],x[2].color=x[3].color=f[1],x[4].color=x[5].color=f[2]}else x[0].color=f[0],x[1].color=f[1],x[2].color=f[2];c.length=0;for(const M of x)M!==null&&c.push(M)}}else{const f=r.length;let u=0;const y=r[0],x=c.length;nn(e,i);const g=e.v;for(let M=0;M<x;M++){const b=(y+M)%x;u+1<f&&r[u+1]===b&&(++u,si(e,i,u===f-1?g:0)),c[b].color=e.v}}}}const H=Number.MAX_VALUE,P=[0,0],xt=[0,0];let Js=0,tt=new Float64Array(0),et=new Float64Array(0),N=new Float64Array(0),U=new Float64Array(0),it=new Int32Array(0),ct=new Float64Array(0),Yt=new Float64Array(0),Xt=new Float64Array(0),Bt=new Float64Array(0),Ot=new Int32Array(0);const nt=[0,0];let to=0,Nn=new Float64Array(0),Un=new Float64Array(0),Gn=new Float64Array(0),Yn=new Float64Array(0),Xn=new Float64Array(0),Bn=new Float64Array(0),Wn=new Float64Array(0),Hn=new Float64Array(0),Vn=new Float64Array(0),jn=new Float64Array(0),zn=new Float64Array(0),Qn=new Float64Array(0),no=0,sn=new Int32Array(0);function ei(s){const t=s.length;if(t===0)return 0;let n=0;if(t===1){s[0].point(0,nt);const o=nt[0],e=nt[1];s[0].point(.3333333333333333,nt);const i=nt[0],r=nt[1];s[0].point(.6666666666666666,nt);const c=nt[0],a=nt[1];n+=o*r-e*i,n+=i*a-r*c,n+=c*e-a*o}else if(t===2){s[0].point(0,nt);const o=nt[0],e=nt[1];s[0].point(.5,nt);const i=nt[0],r=nt[1];s[1].point(0,nt);const c=nt[0],a=nt[1];s[1].point(.5,nt);const l=nt[0],h=nt[1];n+=o*r-e*i,n+=i*a-r*c,n+=c*h-a*l,n+=l*e-h*o}else{const o=s[t-1];let e=o.p0x,i=o.p0y;for(let r=0;r<t;r++){const c=s[r].p0x,a=s[r].p0y;n+=e*a-i*c,e=c,i=a}}return n>0?-1:n<0?1:0}function ii(s,t,n,o,e,i,r){const c=r[s][t];let a=n;if(i<0){c.direction(0,P);const l=Math.sqrt(P[0]*P[0]+P[1]*P[1]);if(l>0){const h=P[0]/l,p=P[1]/l;c.point(0,xt);const f=o-xt[0],u=e-xt[1];if(f*h+u*p<0){const x=f*p-u*h;Math.abs(x)<=Math.abs(a)&&(a=x)}}}if(i>1){c.direction(1,P);const l=Math.sqrt(P[0]*P[0]+P[1]*P[1]);if(l>0){const h=P[0]/l,p=P[1]/l;c.point(1,xt);const f=o-xt[0],u=e-xt[1];if(f*h+u*p>0){const x=f*p-u*h;Math.abs(x)<=Math.abs(a)&&(a=x)}}}return a}function _t(s,t,n,o,e,i,r,c,a){let l=s<0?t:n;if(e>=0){const h=ii(o,e,s,r,c,i,a);Math.abs(h)<Math.abs(l)&&(l=h)}return l}function bt(s,t,n){return Math.max(Math.min(s,t),Math.min(Math.max(s,t),n))}function ci(s,t,n,o,e,i,r,c){if(c.length!==t*n*3)throw new Error(`generateMSDF: out.length ${c.length} !== ${t*n*3}`);const a=s.contours,l=a.length;if(l===0){c.fill(0);return}const h=o/r;Ot.length<l&&(Ot=new Int32Array(l));for(let u=0;u<l;u++)Ot[u]=ei(a[u]);no<l+1&&(sn=new Int32Array(l+1),no=l+1);let p=0;for(let u=0;u<l;u++)sn[u]=p,p+=a[u].length;sn[l]=p,to<p&&(Nn=new Float64Array(p),Un=new Float64Array(p),Gn=new Float64Array(p),Yn=new Float64Array(p),Xn=new Float64Array(p),Bn=new Float64Array(p),Wn=new Float64Array(p),Hn=new Float64Array(p),Vn=new Float64Array(p),jn=new Float64Array(p),zn=new Float64Array(p),Qn=new Float64Array(p),to=p);for(let u=0;u<l;u++){const y=a[u],x=y.length,g=sn[u];for(let M=0;M<x;M++){const b=y[M],A=y[(M+x-1)%x],T=y[(M+1)%x],I=g+M;b.point(0,xt),Nn[I]=xt[0],Un[I]=xt[1],b.point(1,xt),Gn[I]=xt[0],Yn[I]=xt[1],b.direction(0,P);let S=Math.sqrt(P[0]*P[0]+P[1]*P[1]);const q=S>0?P[0]/S:0,m=S>0?P[1]/S:0;Xn[I]=q,Bn[I]=m,b.direction(1,P),S=Math.sqrt(P[0]*P[0]+P[1]*P[1]);const d=S>0?P[0]/S:0,_=S>0?P[1]/S:0;Wn[I]=d,Hn[I]=_,A.direction(1,P),S=Math.sqrt(P[0]*P[0]+P[1]*P[1]);const w=S>0?P[0]/S:0,E=S>0?P[1]/S:0;T.direction(0,P),S=Math.sqrt(P[0]*P[0]+P[1]*P[1]);const k=S>0?P[0]/S:0,v=S>0?P[1]/S:0,F=w+q,O=E+m,L=Math.sqrt(F*F+O*O);Vn[I]=L>0?F/L:0,jn[I]=L>0?O/L:0;const B=d+k,X=_+v,V=Math.sqrt(B*B+X*X);zn[I]=V>0?-(B/V):0,Qn[I]=V>0?-(X/V):0}}if(Js<l){const u=l*3;tt=new Float64Array(u),et=new Float64Array(u),N=new Float64Array(u),U=new Float64Array(u),it=new Int32Array(u),ct=new Float64Array(u),Yt=new Float64Array(l),Xt=new Float64Array(l),Bt=new Float64Array(l),Js=l}const f={distance:0,dot:0,param:0};for(let u=0;u<n;u++)for(let y=0;y<t;y++){const x=(y+.5)/o-e,g=(u+.5)/o-i;for(let R=0;R<l;R++){const C=a[R],ut=C.length,D=R*3,G=sn[R];tt[D]=tt[D+1]=tt[D+2]=-H,et[D]=et[D+1]=et[D+2]=0,N[D]=N[D+1]=N[D+2]=-H,U[D]=U[D+1]=U[D+2]=H,it[D]=it[D+1]=it[D+2]=-1,ct[D]=ct[D+1]=ct[D+2]=0;for(let Y=0;Y<ut;Y++){const j=C[Y],ms=j.color,bs=(ms&fn)!==0,ws=(ms&un)!==0,As=(ms&yn)!==0;j.signedDistance(x,g,f);const Tn=f.distance,Ht=f.dot,Is=f.param,Ft=Math.abs(Tn);if(bs){const Dt=Math.abs(tt[D]);(Ft<Dt||Ft===Dt&&Ht<et[D])&&(tt[D]=Tn,et[D]=Ht,it[D]=Y,ct[D]=Is)}if(ws){const Dt=Math.abs(tt[D+1]);(Ft<Dt||Ft===Dt&&Ht<et[D+1])&&(tt[D+1]=Tn,et[D+1]=Ht,it[D+1]=Y,ct[D+1]=Is)}if(As){const Dt=Math.abs(tt[D+2]);(Ft<Dt||Ft===Dt&&Ht<et[D+2])&&(tt[D+2]=Tn,et[D+2]=Ht,it[D+2]=Y,ct[D+2]=Is)}const Mt=G+Y,ks=x-Nn[Mt],Es=g-Un[Mt],Ds=x-Gn[Mt],qs=g-Yn[Mt],Vo=Xn[Mt],jo=Bn[Mt],zo=Wn[Mt],Qo=Hn[Mt],Fi=ks*Vn[Mt]+Es*jn[Mt],Ri=Ds*zn[Mt]+qs*Qn[Mt];if(Fi>0&&-(ks*Vo+Es*jo)>0){const $=ks*jo-Es*Vo;Math.abs($)<Ft&&(bs&&($<=0&&$>N[D]?N[D]=$:$>0&&$<U[D]&&(U[D]=$)),ws&&($<=0&&$>N[D+1]?N[D+1]=$:$>0&&$<U[D+1]&&(U[D+1]=$)),As&&($<=0&&$>N[D+2]?N[D+2]=$:$>0&&$<U[D+2]&&(U[D+2]=$)))}if(Ri>0&&Ds*zo+qs*Qo>0){const $=Ds*Qo-qs*zo;Math.abs($)<Ft&&(bs&&($<=0&&$>N[D]?N[D]=$:$>0&&$<U[D]&&(U[D]=$)),ws&&($<=0&&$>N[D+1]?N[D+1]=$:$>0&&$<U[D+1]&&(U[D+1]=$)),As&&($<=0&&$>N[D+2]?N[D+2]=$:$>0&&$<U[D+2]&&(U[D+2]=$)))}}Yt[R]=_t(tt[D],N[D],U[D],R,it[D],ct[D],x,g,a),Xt[R]=_t(tt[D+1],N[D+1],U[D+1],R,it[D+1],ct[D+1],x,g,a),Bt[R]=_t(tt[D+2],N[D+2],U[D+2],R,it[D+2],ct[D+2],x,g,a)}let M=-H,b=0,A=-H,T=H,I=-1,S=-1,q=0,m=-H,d=0,_=-H,w=H,E=-1,k=-1,v=0,F=-H,O=0,L=-H,B=H,X=-1,V=-1,st=0,z=-H,vt=0,ft=-H,Tt=H,Ct=-1,Mo=-1,mo=0,kn=-H,bo=0,is=-H,cs=H,wo=-1,Ao=-1,Io=0,En=-H,ko=0,rs=-H,as=H,Eo=-1,Do=-1,qo=0,Dn=-H,vo=0,ls=-H,hs=H,Co=-1,So=-1,To=0,qn=-H,Fo=0,ps=-H,fs=H,Ro=-1,Lo=-1,Po=0,vn=-H,$o=0,us=-H,ys=H,Oo=-1,No=-1,Uo=0;for(let R=0;R<l;R++){const C=R*3,ut=Ot[R],D=bt(Yt[R],Xt[R],Bt[R]);{const G=tt[C],Y=et[C],j=Math.abs(G);(j<Math.abs(M)||j===Math.abs(M)&&Y<b)&&(M=G,b=Y,I=R,S=it[C],q=ct[C]),N[C]>A&&(A=N[C]),U[C]<T&&(T=U[C])}{const G=tt[C+1],Y=et[C+1],j=Math.abs(G);(j<Math.abs(m)||j===Math.abs(m)&&Y<d)&&(m=G,d=Y,E=R,k=it[C+1],v=ct[C+1]),N[C+1]>_&&(_=N[C+1]),U[C+1]<w&&(w=U[C+1])}{const G=tt[C+2],Y=et[C+2],j=Math.abs(G);(j<Math.abs(F)||j===Math.abs(F)&&Y<O)&&(F=G,O=Y,X=R,V=it[C+2],st=ct[C+2]),N[C+2]>L&&(L=N[C+2]),U[C+2]<B&&(B=U[C+2])}if(ut>0&&D>=0){{const G=tt[C],Y=et[C],j=Math.abs(G);(j<Math.abs(z)||j===Math.abs(z)&&Y<vt)&&(z=G,vt=Y,Ct=R,Mo=it[C],mo=ct[C]),N[C]>ft&&(ft=N[C]),U[C]<Tt&&(Tt=U[C])}{const G=tt[C+1],Y=et[C+1],j=Math.abs(G);(j<Math.abs(kn)||j===Math.abs(kn)&&Y<bo)&&(kn=G,bo=Y,wo=R,Ao=it[C+1],Io=ct[C+1]),N[C+1]>is&&(is=N[C+1]),U[C+1]<cs&&(cs=U[C+1])}{const G=tt[C+2],Y=et[C+2],j=Math.abs(G);(j<Math.abs(En)||j===Math.abs(En)&&Y<ko)&&(En=G,ko=Y,Eo=R,Do=it[C+2],qo=ct[C+2]),N[C+2]>rs&&(rs=N[C+2]),U[C+2]<as&&(as=U[C+2])}}if(ut<0&&D<=0){{const G=tt[C],Y=et[C],j=Math.abs(G);(j<Math.abs(Dn)||j===Math.abs(Dn)&&Y<vo)&&(Dn=G,vo=Y,Co=R,So=it[C],To=ct[C]),N[C]>ls&&(ls=N[C]),U[C]<hs&&(hs=U[C])}{const G=tt[C+1],Y=et[C+1],j=Math.abs(G);(j<Math.abs(qn)||j===Math.abs(qn)&&Y<Fo)&&(qn=G,Fo=Y,Ro=R,Lo=it[C+1],Po=ct[C+1]),N[C+1]>ps&&(ps=N[C+1]),U[C+1]<fs&&(fs=U[C+1])}{const G=tt[C+2],Y=et[C+2],j=Math.abs(G);(j<Math.abs(vn)||j===Math.abs(vn)&&Y<$o)&&(vn=G,$o=Y,Oo=R,No=it[C+2],Uo=ct[C+2]),N[C+2]>us&&(us=N[C+2]),U[C+2]<ys&&(ys=U[C+2])}}}const xs=_t(M,A,T,I,S,q,x,g,a),_s=_t(m,_,w,E,k,v,x,g,a),gs=_t(F,L,B,X,V,st,x,g,a),Ti=bt(xs,_s,gs),Go=_t(z,ft,Tt,Ct,Mo,mo,x,g,a),Yo=_t(kn,is,cs,wo,Ao,Io,x,g,a),Xo=_t(En,rs,as,Eo,Do,qo,x,g,a),Cn=bt(Go,Yo,Xo),Bo=_t(Dn,ls,hs,Co,So,To,x,g,a),Wo=_t(qn,ps,fs,Ro,Lo,Po,x,g,a),Ho=_t(vn,us,ys,Oo,No,Uo,x,g,a),Sn=bt(Bo,Wo,Ho);let wt,At,It,ds=0;if(Cn>=0&&Math.abs(Cn)<=Math.abs(Sn)){wt=Go,At=Yo,It=Xo,ds=1;for(let R=0;R<l;R++)if(Ot[R]>0){const C=Yt[R],ut=Xt[R],D=Bt[R],G=bt(C,ut,D);Math.abs(G)<Math.abs(Sn)&&G>bt(wt,At,It)&&(wt=C,At=ut,It=D)}}else if(Sn<=0&&Math.abs(Sn)<Math.abs(Cn)){wt=Bo,At=Wo,It=Ho,ds=-1;for(let R=0;R<l;R++)if(Ot[R]<0){const C=Yt[R],ut=Xt[R],D=Bt[R],G=bt(C,ut,D);Math.abs(G)<Math.abs(Cn)&&G<bt(wt,At,It)&&(wt=C,At=ut,It=D)}}else{const R=(u*t+y)*3;c[R+0]=xs*h+.5,c[R+1]=_s*h+.5,c[R+2]=gs*h+.5;continue}for(let R=0;R<l;R++)if(Ot[R]!==ds){const C=Yt[R],ut=Xt[R],D=Bt[R],G=bt(C,ut,D),Y=bt(wt,At,It);G*Y>=0&&Math.abs(G)<Math.abs(Y)&&(wt=C,At=ut,It=D)}bt(wt,At,It)===Ti&&(wt=xs,At=_s,It=gs);const Ms=(u*t+y)*3;c[Ms+0]=wt*h+.5,c[Ms+1]=At*h+.5,c[Ms+2]=It*h+.5}}const so=0,ri=1,ai=2,li=3;function hi(s,t){switch(t){case so:return s!==0;case ri:return(s&1)!==0;case ai:return s>0;case li:return s<0}return!1}class pi{constructor(){this._intersections=[],this._lastIndex=0}setIntersections(t){if(this._intersections=t,this._lastIndex=0,t.length>0){t.sort((o,e)=>ht(o.x-e.x));let n=0;for(let o=0;o<t.length;o++)n+=t[o].direction,t[o].direction=n}}_moveTo(t){const n=this._intersections.length;if(n===0)return-1;let o=this._lastIndex;if(t<this._intersections[o].x)do{if(o===0)return this._lastIndex=0,-1;--o}while(t<this._intersections[o].x);else for(;o<n-1&&t>=this._intersections[o+1].x;)++o;return this._lastIndex=o,o}sumIntersections(t){const n=this._moveTo(t);return n>=0?this._intersections[n].direction:0}filled(t,n){return hi(this.sumIntersections(t),n)}}const oo=[0,0,0],eo=[0,0,0];function fi(s,t,n){const o=[];for(const e of s.contours)for(const i of e){const r=i.scanlineIntersections(t,oo,eo);for(let c=0;c<r;c++)o.push({x:oo[c],direction:eo[c]})}n.setIntersections(o)}const Wt=2,io=1,Kn=1.001,ui=1.1111111111111112,xn=.01;function yi(s,t,n,o,e,i,r){if(n===0||o===0)return;const c=new pi,a=new Int8Array(n*o);for(let l=0;l<o;l++){const h=(l+.5)/e-r;fi(t,h,c);for(let p=0;p<n;p++){const f=(p+.5)/e-i,u=c.filled(f,so),y=(l*n+p)*3,x=s[y],g=s[y+1],M=s[y+2],b=lt(x,g,M),A=l*n+p;b===.5?a[A]=0:b>.5!==u?(s[y]=1-x,s[y+1]=1-g,s[y+2]=1-M,a[A]=-1):a[A]=1}}for(let l=0;l<o;l++)for(let h=0;h<n;h++){const p=l*n+h;if(a[p]!==0)continue;let f=0;if(h>0&&(f+=a[p-1]),h<n-1&&(f+=a[p+1]),l>0&&(f+=a[p-n]),l<o-1&&(f+=a[p+n]),f<0){const u=(l*n+h)*3;s[u]=1-s[u],s[u+1]=1-s[u+1],s[u+2]=1-s[u+2]}}}const Zn=[0,0];function xi(s,t,n,o,e,i,r,c){const a=new Uint8Array(n*o);_i(a,t,n,o,e,i,r),gi(a,s,n,o,e,c),bi(a,s,n,o,c,ui),wi(a,s,n,o)}function _i(s,t,n,o,e,i,r){for(const c of t.contours){if(c.length===0)continue;let a=c[c.length-1];for(const l of c){const h=a.color&l.color;if(!(h&h-1)){l.point(0,Zn);const p=e*(Zn[0]+i),f=e*(Zn[1]+r),u=Math.floor(p-.5)|0,y=Math.floor(f-.5)|0,x=u+1,g=y+1;u<n&&y<o&&x>=0&&g>=0&&(u>=0&&y>=0&&(s[y*n+u]|=Wt),x<n&&y>=0&&(s[y*n+x]|=Wt),u>=0&&g<o&&(s[g*n+u]|=Wt),x<n&&g<o&&(s[g*n+x]|=Wt))}a=l}}}function _n(s,t,n){let o=0;for(let e=0;e<3;e++){const i=s[t+e],r=s[n+e],c=i-r;if(c===0)continue;const a=(i-.5)/c;if(a>0&&a<1){const l=1-a,h=l*s[t]+a*s[n],p=l*s[t+1]+a*s[n+1],f=l*s[t+2]+a*s[n+2],u=e===0?h:e===1?p:f;lt(h,p,f)===u&&(o|=e===0?fn:e===1?un:yn)}}return o}function St(s,t,n,o,e,i){(i&fn&&n[o]!==e||i&un&&n[o+1]!==e||i&yn&&n[o+2]!==e)&&(s[t]|=Wt)}function gi(s,t,n,o,e,i){const r=Kn/i,c=Kn/i,a=Kn*Math.SQRT2/i;for(let l=0;l<o;l++)for(let h=0;h<n-1;h++){const p=(l*n+h)*3,f=p+3,u=lt(t[p],t[p+1],t[p+2]),y=lt(t[f],t[f+1],t[f+2]);if(Math.abs(u-.5)+Math.abs(y-.5)<r){const x=_n(t,p,f);St(s,l*n+h,t,p,u,x),St(s,l*n+h+1,t,f,y,x)}}for(let l=0;l<o-1;l++)for(let h=0;h<n;h++){const p=(l*n+h)*3,f=((l+1)*n+h)*3,u=lt(t[p],t[p+1],t[p+2]),y=lt(t[f],t[f+1],t[f+2]);if(Math.abs(u-.5)+Math.abs(y-.5)<c){const x=_n(t,p,f);St(s,l*n+h,t,p,u,x),St(s,(l+1)*n+h,t,f,y,x)}}for(let l=0;l<o-1;l++)for(let h=0;h<n-1;h++){const p=(l*n+h)*3,f=(l*n+h+1)*3,u=((l+1)*n+h)*3,y=((l+1)*n+h+1)*3,x=lt(t[p],t[p+1],t[p+2]),g=lt(t[f],t[f+1],t[f+2]),M=lt(t[u],t[u+1],t[u+2]),b=lt(t[y],t[y+1],t[y+2]);if(Math.abs(x-.5)+Math.abs(b-.5)<a){const A=_n(t,p,y);St(s,l*n+h,t,p,x,A),St(s,(l+1)*n+h+1,t,y,b,A)}if(Math.abs(g-.5)+Math.abs(M-.5)<a){const A=_n(t,f,u);St(s,l*n+h+1,t,f,g,A),St(s,(l+1)*n+h,t,u,M,A)}}}function di(s,t,n){const o=t<s?t:s,e=s<t?t:s,i=n<e?n:e;return o<i?i:o}function Mi(s,t,n,o){return lt(s[t]+o*(s[n]-s[t]),s[t+1]+o*(s[n+1]-s[t+1]),s[t+2]+o*(s[n+2]-s[t+2]))}function Jn(s,t,n,o){return di(Math.fround(o*(o*n[0]+t[0])+s[0]),Math.fround(o*(o*n[1]+t[1])+s[1]),Math.fround(o*(o*n[2]+t[2])+s[2]))}const Nt=[0,0,0],Et=[0,0,0],ts=[0,0,0],gt=[0,0,0],co=1,ro=2;function ns(s,t,n,o,e,i,r,c){if(o>.5&&e>.5&&i<=.5||o<.5&&e<.5&&i>=.5||!c&&mi(o,e,i)!==i){const a=(n-s)*r,l=(t-n)*r;return i>=o-a&&i<=o+a&&i>=e-l&&i<=e+l?co:co|ro}return 0}function ao(s){return(s&ro)!==0}function mi(s,t,n){return Math.max(Math.min(s,t),Math.min(Math.max(s,t),n))}function gn(s,t,n,o,e,i){const r=lt(s[n],s[n+1],s[n+2]);if(Math.abs(o-.5)<Math.abs(r-.5))return!1;for(let c=0;c<3;c++){const a=s[t+c]-s[t+(c+1)%3],l=s[n+c]-s[n+(c+1)%3],h=a-l;if(h===0)continue;const p=a/h;if(p>xn&&p<1-xn){const f=Mi(s,t,n,p),u=ns(0,1,p,o,r,f,e,i);if(ao(u))return!0}}return!1}function lo(s,t,n,o,e,i,r,c,a){if(!(a>0&&a<1))return 0;const l=a>r?0:a,h=a>r?a:1;gt[0]=s[t],gt[1]=s[t+1],gt[2]=s[t+2];const p=a>r?n:Jn(gt,Nt,Et,a);gt[0]=s[t],gt[1]=s[t+1],gt[2]=s[t+2];const f=a>r?Jn(gt,Nt,Et,a):o;return ns(l,h,r,p,f,c,e,i)}function dn(s,t,n,o,e,i,r,c,a){if(!(r>xn&&r<1-xn))return!1;gt[0]=s[t],gt[1]=s[t+1],gt[2]=s[t+2];const l=Jn(gt,Nt,Et,r);let h=ns(0,1,r,n,o,l,e,i);return h|=lo(s,t,n,o,e,i,r,l,c),h|=lo(s,t,n,o,e,i,r,l,a),ao(h)}function ss(s,t,n,o,e,i,r,c,a,l,h,p,f){const u=Math.fround(s[t+l]-s[t+h]),y=Math.fround(Math.fround(s[n+l]-s[n+h])+Math.fround(s[o+l]-s[o+h])),x=Math.fround(s[e+l]-s[e+h]),g=Math.fround(Math.fround(x-y)+u),M=Math.fround(Math.fround(y-u)-u),b=u;if(g===0||Math.abs(M)>1e12*Math.abs(g)){if(M!==0){const T=-b/M;if(dn(s,t,i,r,c,a,T,p,f))return!0}return!1}const A=M*M-4*g*b;if(A>0){const T=Math.sqrt(A),I=(-M+T)/(2*g);if(dn(s,t,i,r,c,a,I,p,f))return!0;const S=(-M-T)/(2*g);if(dn(s,t,i,r,c,a,S,p,f))return!0}else if(A===0){const T=-M/(2*g);if(dn(s,t,i,r,c,a,T,p,f))return!0}return!1}function Mn(s,t,n,o,e,i,r,c){const a=lt(s[e],s[e+1],s[e+2]);if(Math.abs(i-.5)<Math.abs(a-.5))return!1;for(let f=0;f<3;f++)ts[f]=Math.fround(Math.fround(s[t+f]-s[n+f])-s[o+f]),Nt[f]=Math.fround(-s[t+f]-ts[f]),Et[f]=Math.fround(s[e+f]+ts[f]);const l=Et[0]!==0?-.5*Nt[0]/Et[0]:-1,h=Et[1]!==0?-.5*Nt[1]/Et[1]:-1,p=Et[2]!==0?-.5*Nt[2]/Et[2]:-1;return!!(ss(s,t,n,o,e,i,a,r,c,0,1,l,h)||ss(s,t,n,o,e,i,a,r,c,1,2,h,p)||ss(s,t,n,o,e,i,a,r,c,2,0,p,l))}function bi(s,t,n,o,e,i){const r=i/e,c=i/e,a=i*Math.SQRT2/e;for(let l=0;l<o;l++)for(let h=0;h<n;h++){const p=l*n+h,f=p*3,u=lt(t[f],t[f+1],t[f+2]),y=(s[p]&Wt)!==0,x=h>0,g=h<n-1,M=l>0,b=l<o-1,A=x?(p-1)*3:-1,T=g?(p+1)*3:-1,I=M?(p-n)*3:-1,S=b?(p+n)*3:-1;let q=!1;if(x&&gn(t,f,A,u,r,y)&&(q=!0),!q&&M&&gn(t,f,I,u,c,y)&&(q=!0),!q&&g&&gn(t,f,T,u,r,y)&&(q=!0),!q&&b&&gn(t,f,S,u,c,y)&&(q=!0),!q&&x&&M){const m=(p-n-1)*3;Mn(t,f,A,I,m,u,a,y)&&(q=!0)}if(!q&&g&&M){const m=(p-n+1)*3;Mn(t,f,T,I,m,u,a,y)&&(q=!0)}if(!q&&x&&b){const m=(p+n-1)*3;Mn(t,f,A,S,m,u,a,y)&&(q=!0)}if(!q&&g&&b){const m=(p+n+1)*3;Mn(t,f,T,S,m,u,a,y)&&(q=!0)}q&&(s[p]|=io)}}function wi(s,t,n,o){const e=n*o;for(let i=0;i<e;i++)if(s[i]&io){const r=i*3,c=lt(t[r],t[r+1],t[r+2]);t[r]=c,t[r+1]=c,t[r+2]=c}}function lt(s,t,n){return Math.max(Math.min(s,t),Math.min(Math.max(s,t),n))}const Ai=3,Ii=0n,ho=16;function po(s,t,n,o=!0){if(o&&Ve(s),s.contours.length===0)return null;const e=mn(s),i=t,r=n,c=Math.max(1,Math.ceil((e.maxX-e.minX)*i))+2*r,a=Math.max(1,Math.ceil((e.maxY-e.minY)*i))+2*r,l=r/i-e.minX,h=r/i-e.minY;Le(s),oi(s,Ai,Ii);const p=new Float32Array(c*a*3);return ci(s,c,a,i,l,h,r,p),yi(p,s,c,a,i,l,h),xi(p,s,c,a,i,l,h,r),{msdf:p,w:c,h:a,planeLeft:-l,planeBottom:-h,planeRight:c/i-l,planeTop:a/i-h}}const os=[0,0];function mn(s){let t=1/0,n=1/0,o=-1/0,e=-1/0;for(const i of s.contours)for(const r of i)for(let c=0;c<=ho;c++){r.point(c/ho,os);const a=os[0],l=os[1];a<t&&(t=a),l<n&&(n=l),a>o&&(o=a),l>e&&(e=l)}return{minX:t,minY:n,maxX:o,maxY:e}}function Q(s,t){var n;return(n=new RegExp(`\\s${t}\\s*=\\s*(["'])([\\s\\S]*?)\\1`).exec(s))==null?void 0:n[2]}function bn(s,t,n){const o=new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"g"),e=c=>{var a,l;return(l=(a=[...c.matchAll(o)].pop())==null?void 0:a[1])==null?void 0:l.trim()},i=Q(s,"class");let r="";if(i&&n){const c=new Set(i.split(/\s+/));r=n.filter(([a])=>c.has(a)).map(([,a])=>a).join(";")}return e(Q(s,"style")??"")??e(r)??Q(s,t)}function wn(s,t){return s===void 0?t:parseFloat(s)/(s.trim().endsWith("%")?100:1)}function Ut(s,t){return s===void 0?0:parseFloat(s)*(s.trim().endsWith("%")?t/100:1)}function ki(s){const{layers:t,width:n}=fo(s);return{shape:{contours:t.flatMap(e=>e.shape.contours),inverseYAxis:!1},width:n}}function fo(s){var I,S;s=s.replace(/<!--[\s\S]*?-->/g,"");const t=((I=/<svg\b[^>]*>/.exec(s))==null?void 0:I[0])??"",n=(Q(t,"viewBox")??`0 0 ${Q(t,"width")} ${Q(t,"height")}`).trim().split(/[\s,]+/).map(parseFloat),[o=0,e=0,i=NaN,r=NaN]=n;if(!(r>0))throw new Error("parseSvg: needs a viewBox or width/height");const c=[i,r],a=[r,0,0,-r,o,e+r],l=[1,0,0,-1,-o,e+r],h=i/r,p=[];i>0&&An(`M${o} ${e}h${i}v${r}h${-i}z`,l,p),cn({contours:p},r);const f=new Map,u=/<(linear|radial)Gradient\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1Gradient>)/g;for(const[,q="",m="",d=""]of s.matchAll(u))f.set(Q(m,"id")??"",[q,m,d]);const y=new Map;for(const[,q="",m=""]of s.matchAll(/<clipPath\b([^>]*?)(?:\/>|>([\s\S]*?)<\/clipPath>)/g))y.set(Q(q,"id")??"",[q,m]);const x=new Map;for(const[,q="",m=""]of s.matchAll(uo)){const d=Q(m,"id");d!==void 0&&x.set(d,[q,m])}const g=[];for(const[,q=""]of s.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const[,m="",d=""]of q.matchAll(/([^{}]+)\{([^}]*)\}/g))for(const _ of m.split(",")){const w=(S=/^\s*\.([\w-]+)\s*$/.exec(_))==null?void 0:S[1];w&&g.push([w,d])}const M=[],b=[],A=[{m:[1,0,0,1,0,0],fill:"black",rule:"nonzero",fillOpacity:1,opacity:1,clips:[],group:-1}];let T=0;for(const[,q,m="",d="",_]of s.matchAll(/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g)){if(T>0||/^(defs|clipPath|mask|symbol|pattern|marker|style)$/.test(m)){q?T--:_||T++;continue}if(q){A.pop();continue}const w=A[A.length-1],E=ft=>bn(d,ft,g),k=wn(E("opacity"),1),v=xo(m,d,c),F={m:dt(w.m,on(Q(d,"transform")??"")),fill:E("fill")??w.fill,rule:E("fill-rule")??w.rule,fillOpacity:wn(E("fill-opacity"),w.fillOpacity),opacity:w.opacity*k,clips:w.clips,group:w.group};v===void 0&&k<1&&!_&&(F.group=b.push({members:[],parent:w.group,translucent:!1})-1);const O=y.get(yo(E("clip-path")));if(O&&Q(O[0],"clipPathUnits")!=="objectBoundingBox"&&(F.clips=[...w.clips,Ei(O,x,g,dt(l,F.m),c)]),_||A.push(F),v===void 0||F.fill==="none")continue;const L=[];An(v,dt(l,F.m),L),F.rule==="evenodd"&&Ws(L);const B={contours:L,inverseYAxis:!1};cn(B,r);const X=f.get(yo(F.fill)),V=dt(_o(F.m),a),st=X?Di(X,f,g,V,v,c):null;for(const ft of F.clips)Ks(B,ft);const z=mn(B);if(!(z.maxX<=0||z.minX>=h||z.maxY<=0||z.minY>=1||((z.minX<0||z.minY<0||z.maxX>h||z.maxY>1)&&p.length>0&&Ks(B,[p]),B.contours.length===0))){if(F.group>=0){const ft=b[F.group];ft.members.push(M.length);const Tt=st?st.stops.some(Ct=>Ct.opacity<1):!1;(k<1||F.fillOpacity<1||Tt)&&(ft.translucent=!0);for(let Ct=ft.parent;Ct>=0;Ct=b[Ct].parent)b[Ct].translucent=!0}M.push({shape:B,color:F.fill,opacity:F.opacity*F.fillOpacity,gradient:st})}}for(const q of b){if(q.translucent||q.members.length<2)continue;const m=q.members.map(d=>mn(M[d].shape));for(let d=0;d<q.members.length-1;d++){const _=m[d],w=[];for(let E=d+1;E<q.members.length;E++){const k=m[E];k.minX<_.maxX&&_.minX<k.maxX&&k.minY<_.maxY&&_.minY<k.maxY&&w.push(M[q.members[E]].shape.contours)}je(M[q.members[d]].shape,w)}}return{layers:M.filter(q=>q.shape.contours.length>0),width:i/r}}const uo=/<([\w:-]+)\b([^>]*?)\/?>/g;function yo(s){var t;return((t=/url\(\s*['"]?#([^)'"\s]+)/.exec(s??""))==null?void 0:t[1])??""}function Ei([s="",t=""],n,o,e,i){var h;const[r=0,c=1]=i,a=[],l=dt(e,on(Q(s,"transform")??""));for(const[,p="",f=""]of t.matchAll(uo)){let u=[p,f],y=dt(l,on(Q(f,"transform")??""));if(p==="use"){const b=n.get(((h=Q(f,"(?:xlink:)?href"))==null?void 0:h.slice(1))??"");if(!b)continue;y=dt(y,[1,0,0,1,Ut(Q(f,"x"),r),Ut(Q(f,"y"),c)]),y=dt(y,on(Q(b[1],"transform")??"")),u=b}const x=xo(u[0],u[1],i);if(x===void 0)continue;const g=[];An(x,y,g),[u[1],f,s].map(b=>bn(b,"clip-rule",o)).find(Boolean)==="evenodd"&&Ws(g),cn({contours:g},c),a.push(g)}return a}function xo(s,t,[n=0,o=0]){const e=(f,u)=>Ut(Q(t,f),u),[i,r,c,a]=[e("x",n),e("y",o),e("width",n),e("height",o)],[l,h,p]=[e("cx",n),e("cy",o),Math.hypot(n,o)/Math.SQRT2];switch(s){case"path":return Q(t,"d")??"";case"polygon":case"polyline":return`M${Q(t,"points")??"0 0"}`;case"circle":case"ellipse":{const[f,u]=s==="circle"?[e("r",p),e("r",p)]:[e("rx",n),e("ry",o)],y=`A${f} ${u} 0 1 0`;return`M${l-f} ${h}${y} ${l+f} ${h}${y} ${l-f} ${h}Z`}case"rect":{const[f,u]=[Q(t,"rx"),Q(t,"ry")],y=Math.min(f===void 0?Ut(u,o):Ut(f,n),c/2),x=Math.min(u===void 0?Ut(f,n):Ut(u,o),a/2),g=`A${y} ${x} 0 0 1`;return`M${i+y} ${r}H${i+c-y}${g} ${i+c} ${r+x}V${r+a-x}${g} ${i+c-y} ${r+a}H${i+y}${g} ${i} ${r+a-x}V${r+x}${g} ${i+y} ${r}Z`}default:return}}function Di(s,t,n,o,e,[i=0,r=0]){var d;const c=[];for(let _=s;_&&!c.includes(_);)c.push(_),_=t.get(((d=Q(_[1]??"","(?:xlink:)?href"))==null?void 0:d.slice(1))??"");const a=_=>c.map(w=>Q(w[1]??"",_)).find(w=>w!==void 0),l=a("gradientUnits")==="userSpaceOnUse",h=(_,w,E)=>{const k=a(_)??w;return parseFloat(k)*(k.trim().endsWith("%")?(l?E:1)/100:1)};let p=on(a("gradientTransform")??"");if(!l){const _=[];An(e,[1,0,0,1,0,0],_);const w=mn({contours:_});p=dt([w.maxX-w.minX,0,0,w.maxY-w.minY,w.minX,w.minY],p)}const f=s[0]==="radial",[u,y]=[h("x1","0%",i),h("y1","0%",r)],[x,g]=[h("x2","100%",i)-u,h("y2","0%",r)-y],M=Math.hypot(i,r)/Math.SQRT2,[b,A,T]=[h("cx","50%",i),h("cy","50%",r),h("r","50%",M)],I=x*x+g*g||1,S=f?[1/T,0,0,1/T,-b/T,-A/T]:[x/I,0,g/I,0,-(u*x+y*g)/I,0],m=[...(c.map(_=>_[2]??"").find(_=>/<stop\b/.test(_))??"").matchAll(/<stop\b[^>]*>/g)].map(([_])=>({offset:wn(Q(_,"offset"),0),color:bn(_,"stop-color",n)??"black",opacity:wn(bn(_,"stop-opacity",n),1)}));return{radial:f,matrix:dt(S,dt(_o(p),o)),stops:m}}function dt(s,t){const[n=0,o=0,e=0,i=0,r=0,c=0]=s,[a=0,l=0,h=0,p=0,f=0,u=0]=t;return[n*a+e*l,o*a+i*l,n*h+e*p,o*h+i*p,n*f+e*u+r,o*f+i*u+c]}function qi([s=0,t=0,n=0,o=0,e=0,i=0],r,c){return[s*r+n*c+e,t*r+o*c+i]}function _o([s=0,t=0,n=0,o=0,e=0,i=0]){const r=s*o-t*n;return[o/r,-t/r,-n/r,s/r,(n*i-o*e)/r,(t*e-s*i)/r]}function on(s){let t=[1,0,0,1,0,0];for(const[,n,o=""]of s.matchAll(/(\w+)\s*\(([^)]*)\)/g)){const[e=0,i,r,c=0,a=0,l=0]=o.trim().split(/[\s,]+/).map(parseFloat),h=e*Math.PI/180,[p,f]=[Math.cos(h),Math.sin(h)],[u,y]=[i??0,r??0];t=dt(t,n==="matrix"?[e,i??0,r??0,c,a,l]:n==="translate"?[1,0,0,1,e,i??0]:n==="scale"?[e,0,0,i??e,0,0]:n==="rotate"?[p,f,-f,p,u-p*u+f*y,y-f*u-p*y]:n==="skewX"?[1,0,Math.tan(h),1,0,0]:[1,Math.tan(h),0,1,0,0])}return t}const es=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y;function An(s,t,n){let o=0,e=0,i=0,r=0,c=0,a=0,l=0,h="",p="",f=[];const u=()=>{for(;o<s.length&&` \r
|
|
2
|
+
,`.includes(s[o]);)o++},y=()=>{u(),es.lastIndex=o;const b=es.exec(s);if(!b)throw new Error(`parseSvg: expected a number at ${o} in path "${s}"`);return o=es.lastIndex,parseFloat(b[0])},x=()=>(u(),s[o++]==="1"?1:0),g=(b,...A)=>{const T=[e,i,...A],I=[];for(let v=0;v<T.length;v+=2)I.push(...qi(t,T[v],T[v+1]));const[S=0,q=0,m=0,d=0,_=0,w=0,E=0,k=0]=I;f.push(new J(b,S,q,m,d,_,w,E,k)),e=A[A.length-2],i=A[A.length-1]},M=()=>{f.length>0&&((e!==r||i!==c)&&g(Z,r,c),n.push(f),f=[]),e=r,i=c};for(u();o<s.length;u()){if(/[a-zA-Z]/.test(s[o]))h=s[o++];else if(!h)throw new Error(`parseSvg: expected a command at ${o} in path "${s}"`);const b=h.toUpperCase(),A=h===b?0:e,T=h===b?0:i,I=b==="S"&&"CS".includes(p)||b==="T"&&"QT".includes(p),S=I?2*e-a:e,q=I?2*i-l:i;switch(b){case"M":{const m=A+y(),d=T+y();M(),e=r=m,i=c=d,h=h==="M"?"L":"l";break}case"L":g(Z,A+y(),T+y());break;case"H":g(Z,A+y(),i);break;case"V":g(Z,e,T+y());break;case"C":case"S":{const m=b==="C"?A+y():S,d=b==="C"?T+y():q;a=A+y(),l=T+y(),g(kt,m,d,a,l,A+y(),T+y());break}case"Q":case"T":a=b==="Q"?A+y():S,l=b==="Q"?T+y():q,g(ot,a,l,A+y(),T+y());break;case"A":{const m=y(),d=y(),_=y(),w=x(),E=x();vi(g,e,i,m,d,_,w,E,A+y(),T+y());break}case"Z":M(),h="";break;default:throw new Error(`parseSvg: unknown path command "${h}"`)}p=b}M()}function vi(s,t,n,o,e,i,r,c,a,l){if(t===a&&n===l)return;if(o=Math.abs(o),e=Math.abs(e),o===0||e===0)return s(Z,a,l);const h=Math.cos(i*Math.PI/180),p=Math.sin(i*Math.PI/180),f=(t-a)/2,u=(n-l)/2,y=h*f+p*u,x=-p*f+h*u,g=y*y/(o*o)+x*x/(e*e);g>1&&(o*=Math.sqrt(g),e*=Math.sqrt(g));const M=o*o*x*x+e*e*y*y,b=(r===c?-1:1)*Math.sqrt(Math.max(0,(o*o*e*e-M)/M)),A=b*o*x/e,T=-b*e*y/o,I=h*A-p*T+(t+a)/2,S=p*A+h*T+(n+l)/2,q=Math.atan2((x-T)/e,(y-A)/o);let m=Math.atan2((-x-T)/e,(-y-A)/o)-q;c&&m<0?m+=2*Math.PI:!c&&m>0&&(m-=2*Math.PI);const d=Math.max(1,Math.ceil(Math.abs(m)/(Math.PI/2)-1e-9)),_=m/d,w=4/3*Math.tan(_/4),E=(v,F)=>I+o*v*h-e*F*p,k=(v,F)=>S+o*v*p+e*F*h;for(let v=0;v<d;v++){const F=Math.cos(q+v*_),O=Math.sin(q+v*_),L=Math.cos(q+(v+1)*_),B=Math.sin(q+(v+1)*_),X=v===d-1;s(kt,E(F-w*O,O+w*F),k(F-w*O,O+w*F),E(L+w*B,B-w*L),k(L+w*B,B-w*L),X?a:E(L,B),X?l:k(L,B))}}function Ci(s){let t=0,n=0;for(const c of s)t+=c.w*c.h,n=Math.max(n,c.w);s.sort((c,a)=>a.h-c.h);const e=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,r=0;for(const c of s)for(let a=e.length-1;a>=0;a--){const l=e[a];if(!(c.w>l.w||c.h>l.h)){if(c.x=l.x,c.y=l.y,r=Math.max(r,c.y+c.h),i=Math.max(i,c.x+c.w),c.w===l.w&&c.h===l.h){const h=e.pop();h&&a<e.length&&(e[a]=h)}else c.h===l.h?(l.x+=c.w,l.w-=c.w):c.w===l.w?(l.y+=c.h,l.h-=c.h):(e.push({x:l.x+c.w,y:l.y,w:l.w-c.w,h:c.h}),l.y+=c.h,l.h-=c.h);break}}return{w:i,h:r,fill:t/(i*r)||0}}const go=4;function In(s){const t=s<0?0:s>1?1:s;return~Math.trunc(255.5-255*t)&255}class Si{constructor(t,n={}){this._width=0,this._height=0,this._pixels=new Uint8Array(0),this._cache=new Map,this._cacheByKey=new Map,this._font=t,this._pxPerEm=n.pixelsPerEm??40,this._pxrange=n.pxrange??4,this._floats=n.float?new Float32Array(0):null,this.pxrangeEm=this._pxrange/this._pxPerEm}get width(){return this._width}get height(){return this._height}get texture(){return this._pixels}get floatTexture(){return this._floats}glyphs(t){const n=this._requireFont();return this.glyphsByIndex(Array.from(t,o=>n.glyphId(o)))}glyph(t){return this.glyphs([t])[0]}glyphsByIndex(t){const n=[];let o=0;for(const e of t){const i=this._cache.get(e);if(i){n.push(i.glyph);continue}const r=this._generateForGlyphId(e);this._cache.set(e,r),n.push(r.glyph),o++}return o>0&&this._repack(),n}glyphByIndex(t){return this.glyphsByIndex([t])[0]}shapes(t){const n=[];let o=0;for(const[e,i]of t){let r=this._cacheByKey.get(e);r||(r=this._generate(i,0),this._cacheByKey.set(e,r),o++),n.push(r.glyph)}return o>0&&this._repack(),n}_requireFont(){if(!this._font)throw new Error("Atlas: no font — this atlas only supports shapes()");return this._font}_generateForGlyphId(t){const n=this._requireFont(),o=n.metrics.unitsPerEm,e=n.shape(t);return cn(e,o),this._generate(e,n.advance(t)/o)}_generate(t,n){const o=po(t,this._pxPerEm,this._pxrange);return{glyph:{x:0,y:0,w:o?o.w:0,h:o?o.h:0,advance:n,planeLeft:o?o.planeLeft:0,planeBottom:o?o.planeBottom:0,planeRight:o?o.planeRight:0,planeTop:o?o.planeTop:0},msdf:o?o.msdf:null}}layout(t){const n=[];for(const a of t)n.push(a.codePointAt(0));this.glyphs(n);const o=[],e=this._requireFont(),i=e.metrics.unitsPerEm;let r=0,c=-1;for(const a of n){const l=e.glyphId(a);c>=0&&(r+=e.kerning(c,l)/i);const h=this._cache.get(l).glyph;o.push({glyph:h,penX:r,penY:0}),r+=h.advance,c=l}return{glyphs:o,widthEm:r}}layoutMultiline(t){const n=this._requireFont(),o=n.metrics.unitsPerEm,e=(n.metrics.ascender-n.metrics.descender+n.metrics.lineGap)/o,i=t.split(`
|
|
3
|
+
`),r=[];let c=0;for(let a=0;a<i.length;a++){const{glyphs:l,widthEm:h}=this.layout(i[a]),p=-a*e;for(const f of l)r.push({glyph:f.glyph,penX:f.penX,penY:p});h>c&&(c=h)}return{glyphs:r,widthEm:c,heightEm:i.length*e}}_repack(){const t=[];for(const e of[this._cache,this._cacheByKey])for(const{glyph:i,msdf:r}of e.values())r&&t.push({w:i.w+1,h:i.h+1,x:0,y:0,glyph:i,msdf:r});const{w:n,h:o}=Ci(t);this._width=n,this._height=o,this._pixels=new Uint8Array(n*o*go),this._floats&&(this._floats=new Float32Array(n*o*3));for(const e of t)e.glyph.x=e.x,e.glyph.y=e.y,this._blit(e.msdf,e.x,e.y,e.glyph.w,e.glyph.h)}_blit(t,n,o,e,i){var a;const r=this._width,c=this._pixels;for(let l=0;l<i;l++){const h=o+(i-1-l);(a=this._floats)==null||a.set(t.subarray(l*e*3,(l+1)*e*3),(h*r+n)*3);for(let p=0;p<e;p++){const f=(l*e+p)*3,u=(h*r+(n+p))*go;c[u]=In(t[f]),c[u+1]=In(t[f+1]),c[u+2]=In(t[f+2]),c[u+3]=255}}}}return yt.Atlas=Si,yt.CUBIC=kt,yt.EdgeSegment=J,yt.Font=Se,yt.LINEAR=Z,yt.QUADRATIC=ot,yt.generateShapeMSDF=po,yt.parseSvg=ki,yt.parseSvgLayers=fo,yt.pixelFloatToByte=In,Object.defineProperty(yt,Symbol.toStringTag,{value:"Module"}),yt})({});
|