msdfgen-ts 0.2.0 → 0.3.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 +3 -3
- package/dist/atlas-worker.js +2572 -1415
- package/dist/msdfgen-ts.iife.js +3 -3
- package/dist/msdfgen-ts.js +2652 -1495
- package/dist/types/atlas-gen.d.ts +7 -3
- package/dist/types/font/font.d.ts +38 -3
- package/dist/types/font/glyph-run.d.ts +50 -0
- package/dist/types/font/script.d.ts +47 -0
- package/dist/types/font/shaper.d.ts +41 -0
- package/dist/types/font/tables/gdef.d.ts +25 -0
- package/dist/types/font/tables/gpos.d.ts +85 -0
- package/dist/types/font/tables/kern.d.ts +31 -14
- package/dist/types/font/tables/otl.d.ts +27 -0
- package/package.json +4 -2
package/dist/msdfgen-ts.iife.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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
|
|
3
|
-
`),r=[];let c=0;for(let a=0;a<i.length;a++){const{glyphs:l,widthEm:h}=this.layout(i[a]),
|
|
1
|
+
var MsdfgenTs=(function(gt){"use strict";function bi(e,t,n,s){return e*n+t*s}function Q(e,t,n,s){return e*s-t*n}function Ue(e,t,n){return(1-n)*e+n*t}function ut(e){return+(e>0)-+(e<0)}function jt(e){return 2*+(e>0)-1}function Te(e,t,n,s){if(t===0||Math.abs(n)>1e12*Math.abs(t))return n===0?s===0?-1:0:(e[0]=-s/n,1);const o=n*n-4*t*s;if(o>0){const i=Math.sqrt(o);return e[0]=(-n+i)/(2*t),e[1]=(-n-i)/(2*t),2}else if(o===0)return e[0]=-n/(2*t),1;return 0}function wi(e,t,n,s){const o=t*t,i=1/9*(o-3*n),r=1/54*(t*(2*o-9*n)+27*s),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 f=-2*Math.sqrt(i);return e[0]=f*Math.cos(.3333333333333333*h)-l,e[1]=f*Math.cos(.3333333333333333*(h+2*Math.PI))-l,e[2]=f*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),f=h===0?0:i/h;return e[0]=h+f-l,h===f||Math.abs(h-f)<1e-12*Math.abs(h+f)?(e[1]=-.5*(h+f)-l,2):1}}function Ai(e,t,n,s,o){if(t!==0){const i=n/t;if(Math.abs(i)<1e6)return wi(e,i,s/t,o/t)}return Te(e,n,s,o)}const ki=24;function fn(e,t,n,s){return((s+e)*s+t)*s+n}function Ui(e,t,n,s,o,i,r){const c=i<0;let a=s-i*(o-s)/(r-i);a>s&&a<o||(a=.5*(s+o));for(let l=0;l<ki;l++){const h=fn(e,t,n,a);if(h===0)return a;h<0===c?s=a:o=a;const f=(3*a+2*e)*a+t;let u=a-h/f;u>s&&u<o||(u=.5*(s+o));const p=u-a;if(a=u,(p<0?-p:p)<=1e-15*(a<0?-a:a))break}return a}function En(e,t,n,s,o,i,r,c,a){return i===0?c[a++]=s:i<0!=r<0&&(c[a++]=Ui(e,t,n,s,o,i,r)),a}function Ti(e,t,n,s,o,i){let r=0;if(e===0){if(t===0)return 0;const u=-n/t;return u>=s&&u<=o&&(i[r++]=u),r}const c=t*t-4*e*n;if(c<0)return 0;const a=Math.sqrt(c),l=-.5*(t+(t<0?-a:a));let h,f;if(l===0)h=0,f=0;else if(h=l/e,f=n/l,h>f){const u=h;h=f,f=u}return h>=s&&h<=o&&(i[r++]=h),f!==h&&f>=s&&f<=o&&(i[r++]=f),r}function Si(e,t,n,s,o,i,r){if(e===0)return Ti(t,n,s,o,i,r);const c=1/e;t*=c,n*=c,s*=c;const a=fn(t,n,s,o),l=fn(t,n,s,i),h=t*t-3*n;let f=0;if(h<=0)f=En(t,n,s,o,i,a,l,r,0);else{const u=Math.sqrt(h)/3,p=-t/3,_=p-u,y=p+u;let g=o,x=a;if(_>o&&_<i){const b=fn(t,n,s,_);f=En(t,n,s,g,_,x,b,r,f),g=_,x=b}if(y>o&&y<i){const b=fn(t,n,s,y);f=En(t,n,s,g,y,x,b,r,f),g=y,x=b}f=En(t,n,s,g,i,x,l,r,f)}return l===0&&(r[f++]=i),f}const J=0,ot=1,Et=2,Se=4,vi=4,K=[0,0,0];class tt{constructor(t,n,s,o,i,r,c,a,l){this.type=t,this.p0x=n,this.p0y=s,this.p1x=o,this.p1y=i,this.p2x=r,this.p2y=c,this.p3x=a,this.p3y=l,this.color=7}endX(){switch(this.type){case J:return this.p1x;case ot:return this.p2x;default:return this.p3x}}endY(){switch(this.type){case J:return this.p1y;case ot:return this.p2y;default:return this.p3y}}point(t,n){const s=t;switch(this.type){case J:{n[0]=this.p0x+s*(this.p1x-this.p0x),n[1]=this.p0y+s*(this.p1y-this.p0y);return}case ot:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y);n[0]=o+s*(r-o),n[1]=i+s*(c-i);return}default:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y),a=this.p2x+s*(this.p3x-this.p2x),l=this.p2y+s*(this.p3y-this.p2y),h=o+s*(r-o),f=i+s*(c-i),u=r+s*(a-r),p=c+s*(l-c);n[0]=h+s*(u-h),n[1]=f+s*(p-f);return}}}direction(t,n){const s=t;switch(this.type){case J:{n[0]=this.p1x-this.p0x,n[1]=this.p1y-this.p0y;return}case ot:{const o=this.p1x-this.p0x+s*(this.p2x-this.p1x-(this.p1x-this.p0x)),i=this.p1y-this.p0y+s*(this.p2y-this.p1y-(this.p1y-this.p0y));o!==0||i!==0?(n[0]=o,n[1]=i):(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y);return}default:{const o=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=o+s*(r-o)+s*(r+s*(a-r)-(o+s*(r-o))),f=i+s*(c-i)+s*(c+s*(l-c)-(i+s*(c-i)));h!==0||f!==0?(n[0]=h,n[1]=f):s===0?(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y):s===1?(n[0]=this.p3x-this.p1x,n[1]=this.p3y-this.p1y):(n[0]=h,n[1]=f);return}}}splitInThirds(){const t=[0,0],n=[0,0];switch(this.type){case J:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=new tt(J,this.p0x,this.p0y,t[0],t[1],0,0,0,0),o=new tt(J,t[0],t[1],n[0],n[1],0,0,0,0),i=new tt(J,n[0],n[1],this.p1x,this.p1y,0,0,0,0);return s.color=o.color=i.color=this.color,[s,o,i]}case ot:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x+1/3*(this.p1x-this.p0x),o=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),f=this.p1x+2/3*(this.p2x-this.p1x),u=this.p1y+2/3*(this.p2y-this.p1y),p=new tt(ot,this.p0x,this.p0y,s,o,t[0],t[1],0,0),_=new tt(ot,t[0],t[1],l,h,n[0],n[1],0,0),y=new tt(ot,n[0],n[1],f,u,this.p2x,this.p2y,0,0);return p.color=_.color=y.color=this.color,[p,_,y]}default:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0x:this.p0x+1/3*(this.p1x-this.p0x),o=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),f=i+1/3*(c-i),u=r+1/3*(a-r),p=c+1/3*(l-c),_=a+1/3*(h-a),y=f+2/3*(p-f),g=u+2/3*(_-u),x=this.p0x+2/3*(this.p1x-this.p0x),b=this.p0y+2/3*(this.p1y-this.p0y),M=this.p1x+2/3*(this.p2x-this.p1x),A=this.p1y+2/3*(this.p2y-this.p1y),k=this.p2x+2/3*(this.p3x-this.p2x),T=this.p2y+2/3*(this.p3y-this.p2y),S=x+2/3*(M-x),w=b+2/3*(A-b),m=M+2/3*(k-M),d=A+2/3*(T-A),U=S+1/3*(m-S),C=w+1/3*(d-w),v=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3x:this.p2x+2/3*(this.p3x-this.p2x),I=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3y:this.p2y+2/3*(this.p3y-this.p2y),R=new tt(Et,this.p0x,this.p0y,s,o,f,u,t[0],t[1]),G=new tt(Et,t[0],t[1],y,g,U,C,n[0],n[1]),F=new tt(Et,n[0],n[1],m,d,v,I,this.p3x,this.p3y);return R.color=G.color=F.color=this.color,[R,G,F]}}}signedDistance(t,n,s){switch(this.type){case J:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=t-o,l=n-i,h=r-o,f=c-i,u=h*h+f*f,p=(a*h+l*f)/u,_=p>.5,y=(_?r:o)-t,g=(_?c:i)-n,x=Math.sqrt(y*y+g*g);if(p>0&&p<1){const A=Math.sqrt(h*h+f*f),k=h/A,S=f/A*a-k*l;if(Math.abs(S)<x){s.distance=S,s.dot=0,s.param=p;return}}const b=a*f-l*h;s.distance=jt(b)*x;const M=Math.sqrt(h*h+f*f);s.dot=x===0||M===0?0:Math.abs((h*y+f*g)/(M*x)),s.param=p;return}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=o-t,f=i-n,u=r-o,p=c-i,_=a-r-u,y=l-c-p,g=_*_+y*y,x=3*(u*_+p*y),b=2*(u*u+p*p)+(h*_+f*y),M=h*u+f*p,A=Si(g,x,b,M,0,1,K);let k=u,T=p;const S=h*h+f*f;let w=jt(k*f-T*h),m=S,d=-(h*k+f*T)/(k*k+T*T);{const C=a-t,v=l-n,I=C*C+v*v;I<m&&(k=a-r,T=l-c,w=jt(k*v-T*C),m=I,d=((t-r)*k+(n-c)*T)/(k*k+T*T))}for(let C=0;C<A;++C){const v=K[C];if(v>0&&v<1){const I=h+2*v*u+v*v*_,R=f+2*v*p+v*v*y,G=I*I+R*R;if(G<=m){const F=u+v*_,X=p+v*y;w=jt(F*R-X*I),m=G,d=v}}}const U=w*Math.sqrt(m);if(d>=0&&d<=1){s.distance=U,s.dot=0,s.param=d;return}if(s.distance=U,s.param=d,d<.5){const C=Math.sqrt(u*u+p*p),v=Math.sqrt(S);s.dot=v===0||C===0?0:Math.abs((u*h+p*f)/(C*v))}else{const C=a-r,v=l-c,I=a-t,R=l-n,G=Math.sqrt(C*C+v*v),F=Math.sqrt(I*I+R*R);s.dot=G===0||F===0?0:Math.abs((C*I+v*R)/(G*F))}return}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y,u=o-t,p=i-n,_=r-o,y=c-i,g=a-r-_,x=l-c-y,b=h-a-(a-r)-g,M=f-l-(l-c)-x;let A=_,k=y;A===0&&k===0&&(A=a-o,k=l-i);const T=Math.sqrt(u*u+p*p);let S=jt(A*p-k*u)*T,w=-(u*A+p*k)/(A*A+k*k);{const m=h-t,d=f-n,U=Math.sqrt(m*m+d*d);if(U<Math.abs(S)){let C=h-a,v=f-l;C===0&&v===0&&(C=h-r,v=f-c),A=C,k=v,S=jt(A*d-k*m)*U,w=((A-m)*A+(k-d)*k)/(A*A+k*k)}}for(let m=0;m<=Se;++m){let d=1/Se*m,U=u+3*d*_+3*d*d*g+d*d*d*b,C=p+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G));if(F>0&&F<1){let X=vi;do{if(d=F,U=u+3*d*_+3*d*d*g+d*d*d*b,C=p+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,!--X)break;R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G))}while(F>0&&F<1);const H=Math.sqrt(U*U+C*C);H<Math.abs(S)&&(S=jt(v*C-I*U)*H,w=d)}}if(w>=0&&w<=1){s.distance=S,s.dot=0,s.param=w;return}if(s.distance=S,s.param=w,w<.5){let m=_,d=y;m===0&&d===0&&(m=a-o,d=l-i);const U=Math.sqrt(m*m+d*d);s.dot=T===0||U===0?0:Math.abs((m*u+d*p)/(U*T))}else{let m=h-a,d=f-l;m===0&&d===0&&(m=h-r,d=f-c);const U=h-t,C=f-n,v=Math.sqrt(m*m+d*d),I=Math.sqrt(U*U+C*C);s.dot=v===0||I===0?0:Math.abs((m*U+d*C)/(v*I))}return}}}scanlineIntersections(t,n,s){switch(this.type){case J:{const o=this.p0y,i=this.p1y;if(t>=o&&t<i||t>=i&&t<o){const r=(t-o)/(i-o);return n[0]=Ue(this.p0x,this.p1x,r),s[0]=ut(i-o),1}return 0}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y;let h=0,f=t>i?1:-1;n[h]=o,i===t&&(i<c||i===c&&i<l?s[h++]=1:f=1);{const u=r-o,p=c-i,_=a-r-u,y=l-c-p,g=Te(K,y,2*p,i-t);if(g>=2&&K[0]>K[1]){const x=K[0];K[0]=K[1],K[1]=x}for(let x=0;x<g&&h<2;++x){const b=K[x];b>=0&&b<=1&&(n[h]=o+2*b*u+b*b*_,f*(p+b*y)>=0&&(s[h++]=f,f=-f))}}return l===t&&(f>0&&h>0&&(--h,f=-1),(l<c||l===c&&l<i)&&h<2&&(n[h]=a,f<0&&(s[h++]=-1,f=1))),f!==(t>=l?1:-1)&&(h>0?--h:(Math.abs(l-t)<Math.abs(i-t)&&(n[h]=a),s[h++]=f)),h}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y;let u=0,p=t>i?1:-1;n[u]=o,i===t&&(i<c||i===c&&(i<l||i===l&&i<f)?s[u++]=1:p=1);{const _=h-3*a+3*r-o,y=f-3*l+3*c-i,g=3*a-6*r+3*o,x=3*l-6*c+3*i,b=3*r-3*o,M=3*c-3*i,A=Ai(K,y,x,M,i-t);if(A>=2){if(K[0]>K[1]){const k=K[0];K[0]=K[1],K[1]=k}if(A>=3&&K[1]>K[2]){const k=K[1];if(K[1]=K[2],K[2]=k,K[0]>K[1]){const T=K[0];K[0]=K[1],K[1]=T}}}for(let k=0;k<A&&u<3;++k){const T=K[k];T>=0&&T<=1&&(n[u]=((_*T+g)*T+b)*T+o,p*((3*y*T+2*x)*T+M)>=0&&(s[u++]=p,p=-p))}}return f===t&&(p>0&&u>0&&(--u,p=-1),(f<l||f===l&&(f<c||f===c&&f<i))&&u<3&&(n[u]=h,p<0&&(s[u++]=-1,p=1))),p!==(t>=f?1:-1)&&(u>0?--u:(Math.abs(f-t)<Math.abs(i-t)&&(n[u]=h),s[u++]=p)),u}}}convertToCubic(){const t=this.p0x+.6666666666666666*(this.p1x-this.p0x),n=this.p0y+2/3*(this.p1y-this.p0y),s=this.p1x+1/3*(this.p2x-this.p1x),o=this.p1y+1/3*(this.p2y-this.p1y),i=new tt(Et,this.p0x,this.p0y,t,n,s,o,this.p2x,this.p2y);return i.color=this.color,i}}class It{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 Ci(e,t){const n=new It(e,t);n.skip(2);const s=n.u16();let o=null;for(let r=0;r<s;r++){const c=n.u16(),a=n.u16(),l=n.u32(),h=t+l,f=n.peekU16(h);let u=-1;c===3&&a===10&&f===12?u=5:c===0&&a===6&&f===12?u=4:c===0&&a===4&&f===12?u=3:c===3&&a===1&&f===4?u=2:c===0&&a<=3&&f===4&&(u=1),u>((o==null?void 0:o.priority)??-1)&&(o={priority:u,subtableAbsOffset:h})}if(!o)return()=>0;const i=n.peekU16(o.subtableAbsOffset);return i===12?Ei(e,o.subtableAbsOffset):i===4?Ii(e,o.subtableAbsOffset):()=>0}function Ei(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);const s=n.u32(),o=new Uint32Array(s),i=new Uint32Array(s),r=new Uint32Array(s);for(let c=0;c<s;c++)o[c]=n.u32(),i[c]=n.u32(),r[c]=n.u32();return c=>{let a=0,l=s-1;for(;a<=l;){const h=a+l>>>1,f=o[h]??0,u=i[h]??0;if(c<f)l=h-1;else if(c>u)a=h+1;else return(r[h]??0)+(c-f)}return 0}}function Ii(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(2);const o=n.u16()>>>1;n.skip(6);const i=new Uint16Array(o);for(let f=0;f<o;f++)i[f]=n.u16();n.skip(2);const r=new Uint16Array(o);for(let f=0;f<o;f++)r[f]=n.u16();const c=new Int16Array(o);for(let f=0;f<o;f++)c[f]=n.i16();const a=new Int32Array(o),l=new Uint16Array(o);for(let f=0;f<o;f++)a[f]=n.pos,l[f]=n.u16();const h=new DataView(e);return f=>{if(f>65535)return 0;let u=0,p=o-1;for(;u<=p;){const _=u+p>>>1,y=i[_]??0;if(f>y)u=_+1;else if(f<(r[_]??0))p=_-1;else{if((i[_]??0)===65535)return 0;const x=l[_]??0,b=c[_]??0,M=r[_]??0;if(x===0)return f+b&65535;const A=(a[_]??0)+x+(f-M)*2,k=h.getUint16(A,!1);return k===0?0:k+b&65535}}return 0}}function Di(e,t){const n=new It(e,t);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);const s=n.u16();n.skip(16),n.skip(8),n.skip(2),n.skip(2),n.skip(2);const o=n.i16();return{unitsPerEm:s,indexToLocFormat:o}}function Ri(e,t){const n=new It(e,t);n.skip(4);const s=n.i16(),o=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:s,descender:o,lineGap:i,numberOfHMetrics:r}}function Li(e,t,n,s){const o=new It(e,t),i=[];let r=0;for(let c=0;c<s;c++){const a=o.u16(),l=o.i16();i[c]={advanceWidth:a,lsb:l},r=a}for(let c=s;c<n;c++){const a=o.i16();i[c]={advanceWidth:r,lsb:a}}return i}function Pi(e,t,n,s){const o=new It(e,t),i=n+1,r=[];if(s===0)for(let c=0;c<i;c++)r[c]=o.u16()*2;else for(let c=0;c<i;c++)r[c]=o.u32();return r}function Fi(e,t){const n=new It(e,t);return n.skip(4),{numGlyphs:n.u16()}}const qi=1,Oi=2,Gi=4,Ni=8,ve=16,Ce=32,$i=1,Ee=2,Bi=8,Yi=32,Hi=64,Xi=128;function Ki(e,t,n,s,o){const i=Ie(e,t,n,s,o),r=[];for(const c of i){const a=Wi(c);a.length>0&&r.push(a)}return{contours:r,inverseYAxis:!1}}function Ie(e,t,n,s,o){if(s===0)return[];const i=t+n,r=new It(e,i),c=r.i16();return r.skip(8),c>=0?ji(r,c):zi(e,r,t,o)}function ji(e,t){if(t===0)return[];const n=[];for(let f=0;f<t;f++)n[f]=e.u16();const s=(n[t-1]??0)+1,o=e.u16();e.skip(o);const i=new Uint8Array(s);for(let f=0;f<s;){const u=e.u8();if(i[f++]=u,u&Ni){let p=e.u8();for(;p-- >0;)i[f++]=u}}const r=new Float64Array(s);let c=0;for(let f=0;f<s;f++){const u=i[f]??0;if(u&Oi){const p=e.u8();c+=u&ve?p:-p}else u&ve||(c+=e.i16());r[f]=c}const a=new Float64Array(s);c=0;for(let f=0;f<s;f++){const u=i[f]??0;if(u&Gi){const p=e.u8();c+=u&Ce?p:-p}else u&Ce||(c+=e.i16());a[f]=c}const l=[];let h=0;for(let f=0;f<t;f++){const u=n[f]??0,p=Vi(i,r,a,h,u);p.length>0&&l.push(p),h=u+1}return l}function Vi(e,t,n,s,o){const i=o-s+1;if(i<=0)return[];const r=[];for(let c=0;c<i;c++){const a=e[s+c]??0,l=t[s+c]??0,h=n[s+c]??0;r.push({x:l,y:h,onCurve:(a&qi)!==0})}return r}function Wi(e){const t=e.length;if(t<=0)return[];const n=[];for(let c=0;c<t;c++){const a=e[c],l=e[(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 s=n.length;let o=0;if(!n[0].onCurve){for(let c=1;c<s;c++)if(n[c].onCurve){o=c;break}}const i=[];let r=0;for(;r<s;){const c=n[(o+r)%s],a=n[(o+r+1)%s];if(a.onCurve)i.push(new tt(J,c.x,c.y,a.x,a.y,0,0,0,0)),r+=1;else{const l=n[(o+r+2)%s];i.push(new tt(ot,c.x,c.y,a.x,a.y,l.x,l.y,0,0)),r+=2}}return i}function zi(e,t,n,s){const o=[];let i=0;do{i=t.u16();const r=t.u16();let c,a;i&$i?(c=t.i16(),a=t.i16()):(c=t.u8(),a=t.u8(),i&Ee&&(c>127&&(c-=256),a>127&&(a-=256)));let l=0,h=0;i&Ee&&(l=c,h=a);let f=1,u=0,p=0,_=1;i&Bi?f=_=t.f2dot14():i&Hi?(f=t.f2dot14(),_=t.f2dot14()):i&Xi&&(f=t.f2dot14(),u=t.f2dot14(),p=t.f2dot14(),_=t.f2dot14());const y=s(r),g=Zi(y,f,u,p,_,l,h);for(const x of g)o.push(x)}while(i&Yi);return o}function De(e){return e>=0?Math.floor(e+.5):Math.ceil(e-.5)}function Zi(e,t,n,s,o,i,r){if(t===1&&n===0&&s===0&&o===1&&i===0&&r===0)return e;const a=t===1&&n===0&&s===0&&o===1;return e.map(l=>l.map(h=>a?{x:h.x+i,y:h.y+r,onCurve:h.onCurve}:{x:De(t*h.x+n*h.y+i),y:De(s*h.x+o*h.y+r),onCurve:h.onCurve}))}const nn=1,In=2,Qi=4,Dt=8,un=16,L={_cp:new Int32Array(64),_gid:new Uint16Array(64),_gp:new Uint16Array(64),_xa:new Float64Array(64),_xo:new Float64Array(64),_yo:new Float64Array(64),_runEnd:new Int32Array(64),_runScript:new Int32Array(64)};function pn(e,t,n,s){if(e&n&14)return!1;if(e&Dt){if(n&16)return s!==null&&t<s.length&&s[t]!==65535;if(n&65280)return(n&65280)===(e&65280)}return!0}function gs(e,t,n,s){const o=L._gp,i=L._gid;for(let r=e+1;r<t;r++){const c=o[r];if(!(c&nn)&&pn(c,i[r],n,s))return r}return-1}function Re(e){if(L._gid.length>=e)return;let t=L._gid.length;for(;t<e;)t*=2;L._cp=new Int32Array(t),L._gid=new Uint16Array(t),L._gp=new Uint16Array(t),L._xa=new Float64Array(t),L._xo=new Float64Array(t),L._yo=new Float64Array(t),L._runEnd=new Int32Array(t),L._runScript=new Int32Array(t)}let _n=new Uint8Array(64);class Ji{constructor(t,n){this._pairs=[],this._counts=[],this._cross=[];const s=new DataView(t);this._dv=s;const o=s.getUint16(n)===1,i=o?s.getUint32(n+4):s.getUint16(n+2);let r=n+(o?8:4),c=!1,a=!1;for(let l=0;l<i&&r+8<=s.byteLength;l++){let h,f,u,p,_=!1,y;if(o){h=s.getUint32(r);const g=s.getUint8(r+4);f=s.getUint8(r+5),u=!(g&128),p=!!(g&64),_=!!(g&32),y=r+8}else{h=s.getUint16(r+2),f=s.getUint8(r+4);const g=s.getUint8(r+5);u=!!(g&1),p=!!(g&4),y=r+6}if(f===1&&(c=!0),p&&(a=!0),f===0&&u&&!_&&(this._pairs.push(y+8),this._counts.push(s.getUint16(y)),this._cross.push(p)),h<6)break;r+=h}this._hasData=i>0,this._hasMachine=c,this._hasCross=a}_get(t,n,s){const o=this._dv,i=this._pairs[t],r=(n<<16|s)>>>0;let c=0,a=this._counts[t]-1;for(;c<=a;){const l=c+a>>1,h=o.getUint32(i+6*l);if(h<r)c=l+1;else if(h>r)a=l-1;else return o.getInt16(i+6*l+4)}return 0}_apply(t,n){const s=L._gid,o=L._xa,i=L._xo,r=L._yo;let c=!1,a=!1;for(let l=0;l<this._pairs.length;l++){const h=this._cross[l];h&&!c&&(c=!0,_n.length<n&&(_n=new Uint8Array(n*2)),_n.fill(0,t,n));for(let f=t;f<n;){const u=gs(f,n,Dt,null);if(u<0){f++;continue}const p=this._get(l,s[f],s[u]);if(p)if(h)p===-32768?(_n[u]=1,r[u]=0):(r[u]=p,a=!0);else{const _=p/2;o[f]=o[f]+_,o[u]=o[u]+p-_,i[u]=i[u]+p-_}f=u}}if(a)for(let l=t+1;l<n;l++)_n[l]||(r[l]=r[l]+r[l-1])}}const $t=65535,Le=new Uint16Array(0);function tr(e,t){const n=e.getUint16(t+4);if(!n)return new Uint32Array(0);const s=t+n,o=new Uint32Array(e.getUint16(s));for(let i=0;i<o.length;i++)o[i]=e.getUint32(s+2+6*i);return o}function Pe(e,t){const n=e.getUint16(t),s=e.getUint16(t+2);let o=-1;if(n===1){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+4+2*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--)i[e.getUint16(t+4+2*r)]=r;return i}if(n===2){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c),l=e.getUint16(c+2),h=e.getUint16(c+4);for(let f=a;f<=l;f++)i[f]=h+f-a}return i}return Le}function xs(e,t){const n=e.getUint16(t);if(n===1){const s=e.getUint16(t+2),o=e.getUint16(t+4),i=new Uint16Array(s+o);for(let r=0;r<o;r++)i[s+r]=e.getUint16(t+6+2*r);return i}if(n===2){const s=e.getUint16(t+2);let o=-1;for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c+2),l=e.getUint16(c+4);for(let h=e.getUint16(c);h<=a;h++)i[h]=l}return i}return Le}class nr{constructor(t,n,s){this._setCache=[];const o=new DataView(t);this._dv=o;const i=o.getUint16(n+2),r=o.getUint16(n+4),c=o.getUint16(n+10),a=i>=2?o.getUint16(n+12):0;if(this._sets=a?n+a:0,!r){this._props=null;return}const l=xs(o,n+r),h=c?xs(o,n+c):new Uint16Array(0),f=new Uint16Array(s);for(let u=0;u<s&&u<l.length;u++)switch(l[u]){case 1:f[u]=In;break;case 2:f[u]=Qi;break;case 3:f[u]=Dt|(h[u]??0)<<8;break}this._props=f}_markSet(t){let n=this._setCache[t];if(!n){const s=this._dv,o=this._sets;n=o&&t<s.getUint16(o+2)?Pe(s,o+s.getUint32(o+4+4*t)):new Uint16Array(0),this._setCache[t]=n}return n}}const Fe="ZyyyZinhArabArmnBengBopoCherCoptCyrlDsrtDevaEthiGeorGothGrekGujrGuruHaniHangHebrHiraKndaKanaKhmrLaooLatnMlymMongMymrOgamItalOryaRunrSinhSyrcTamlTeluThaaThaiTibtCansYiiiTglgHanoBuhdTagbBraiCprtLimbLinbOsmaShawTaleUgarHrktBugiGlagKharSyloTaluTfngXpeoBaliBatkBlisBrahChamCirtCyrsEgydEgyhEgypGeokHansHantHmngHungIndsJavaKaliLatfLatgLepcLinaMandMayaMeroNkooOrkhPermPhagPhnxPlrdRoroSaraSyreSyrjSyrnTengVaiiVispXsuxZxxxZzzzCariJpanLanaLyciLydiOlckRjngSaurSgnwSundMoonMteiArmiAvstCakmKoreKthiManiPhliPhlpPhlvPrtiSamrTavtZmthZsymBamuLisuNkgbSarbBassDuplElbaGranKpelLomaMendMercNarbNbatPalmSindWaraAfakJurcMrooNshuShrdSoraTakrTangWoleHluwKhojTirhAghbMahjAhomHatrModiMultPaucSiddAdlmBhksMarcNewaOsgeHanbJamoZsyeGonmSoyoZanbDogrGongMakaMedfRohgSogdSogoElymHmnpNandWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmAranGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTols",Dn=Fe.length/4,lt=0,Rt=1,Rn=25,sr=8,er=14;function yn(e){return Fe.substring(e*4,e*4+4)}const or=[],ir=[];function Ln(e,t){const n=t?ir:or;let s=n[e];if(s===void 0){try{s=new RegExp(`^\\p{${t?"scx":"sc"}=${yn(e)}}$`,"u")}catch{s=null}n[e]=s}return s}let ds=null;const Pn=[Rn,lt,Rt,sr,er],gn=[[lt],[Rn]],qe=new Map;let Fn=null;const Oe=new Map;function Ms(e){if(e<128)return gn[e>=65&&e<=90||e>=97&&e<=122?1:0];let t;if(e<65536){Fn||(Fn=new Uint16Array(65536));const n=Fn[e];if(n)return gn[n-1];t=Ge(e),Fn[e]=t+1}else t=Oe.get(e),t===void 0&&(t=Ge(e),Oe.set(e,t));return gn[t]}function Ge(e){const t=String.fromCodePoint(e);let n=103;for(let r=0;r<Pn.length+Dn;r++){const c=r<Pn.length?Pn[r]:r-Pn.length,a=Ln(c,!1);if(a&&a.test(t)){n=c;break}}let s=[n];if(!ds){let r="";for(let c=0;c<Dn;c++)Ln(c,!1)&&Ln(c,!0)&&(r+=`${r?"|":""}(?!\\p{sc=${yn(c)}})\\p{scx=${yn(c)}}`);ds=new RegExp(`^(?:${r})$`,"u")}if(ds.test(t)){const r=[];for(let c=0;c<Dn;c++){const a=Ln(c,!0);a&&a.test(t)&&r.push(c)}r.length&&(s=rr(n,r))}const o=s.join(",");let i=qe.get(o);return i===void 0&&(i=gn.length,gn.push(s),qe.set(o,i)),i}function rr(e,t){if(e===t[0])return t;if(e!==Rt&&e!==lt){const n=t.indexOf(e,1);if(n<0){t.push(e);const s=t[0];t[0]=e,t[t.length-1]=s}else t[n]=t[0],t[0]=e;return t}if(e===lt){if(t.length===1)return[lt,t[0]];for(let n=1;n<t.length;n++)if(t[0]===Rn||t[n]<t[0]){const s=t[0];t[0]=t[n],t[n]=s}return t}t.push(t[0]),t[0]=e;for(let n=2;n<t.length;n++)if(t[1]===Rn||t[n]<t[1]){const s=t[1];t[1]=t[n],t[n]=s}return t}const xn=[40,41,91,93,123,125,3898,3899,3900,3901,5787,5788,8261,8262,8317,8318,8333,8334,8968,8969,8970,8971,9001,9002,10088,10089,10090,10091,10092,10093,10094,10095,10096,10097,10098,10099,10100,10101,10181,10182,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10640,10639,10638,10641,10642,10643,10644,10645,10646,10647,10648,10712,10713,10714,10715,10748,10749,11810,11811,11812,11813,11814,11815,11816,11817,11861,11862,11863,11864,11865,11866,11867,11868,12296,12297,12298,12299,12300,12301,12302,12303,12304,12305,12308,12309,12310,12311,12312,12313,12314,12315,65113,65114,65115,65116,65117,65118,65288,65289,65339,65341,65371,65373,65375,65376,65378,65379];let dn=null;function cr(e){if(e<40||e>125&&e<3898)return 0;if(!dn){dn=new Map;for(let t=0;t<xn.length;t+=2)dn.set(xn[t],xn[t+1]),dn.set(xn[t+1],-xn[t])}return dn.get(e)??0}const Ne=32,kt=[],sn=[];let Ft=0,qn=lt;const Bt=[];let en=[],Vt=[];const $e=[];function Be(e){let t=$e[e];return t||($e[e]=t=[e]),t}function ms(){const e=Bt[0];return e===lt?qn:e}function Ye(e,t){let n=Ft;if(n<=0)return;n>kt.length&&(n=kt.length);let s=kt.length-1;for(t?(s--,n--,Ft=1):Ft=0;n>0;s--,n--)sn[s]=e}function ar(){const e=en,t=Bt;if(e.length===0||t.length===0)return!1;if(e.length===1&&t.length===1){const c=e[0];return c<=Rt?!0:t[0]<=Rt?(t[0]=c,!0):t[0]===c}let n=0,s=t[n++];if(e[0]<=Rt)return e.length===2&&s<=Rt&&qn===lt&&(qn=e[1]),!0;if(s<=Rt)return He(Bt,e),!0;let o=e.indexOf(s)>=0;if(n===t.length)return o;let i=0;o||(s=e[i++],o=t.indexOf(s,n)>=0);let r=0;if(o&&(t[r++]=s),i!==e.length)for(;n<t.length;n++)e.indexOf(t[n],i)>=0&&(t[r++]=t[n]);return r>0?(t.length=r,!0):!1}function He(e,t){e.length=t.length;for(let n=0;n<t.length;n++)e[n]=t[n]}function lr(e,t,n,s){if(t===0)return 0;let o=lt,i=0;for(;i<t;i++){const l=Ms(e[i]);if(l.length!==1)break;const h=l[0];if(!(h<=Rt||h===o)){if(o!==lt)break;o=h}}if(i===t)return n[0]=t,s[0]=o,1;kt.length=0,sn.length=0,Ft=0,qn=lt,Bt.length=1,Bt[0]=lt,Vt=Ms(e[0]);let r=1,c=e[0],a=0;for(;Bt.length;){let l=!1;for(;r<=t;){const h=r-1,f=c;en=Vt,r===t?r++:(c=e[r++],Vt=Ms(c),Vt[0]===Rt&&Vt.length>1&&(en[0]===lt&&(en=Vt.slice(1)),Vt=Be(Rt)));const u=cr(f);if(u>0)kt.length===Ne&&(kt.shift(),sn.shift(),Ft===Ne&&Ft--),Ye(ms(),!1),kt.push(f),sn.push(lt),Ft++;else if(u<0){for(let p=kt.length-1;p>=0;p--)if(kt[p]===-u){const _=sn[p];_!==lt&&(en=Be(_));const y=kt.length-1-p;kt.length-=y,sn.length-=y,Ft=Math.max(0,Ft-y);break}}if(!ar()){const p=ms();Ye(p,u>0),n[a]=h,s[a++]=p,He(Bt,en),l=!0;break}}l||(n[a]=t,s[a++]=ms(),Bt.length=0)}return a}const Xe=[];function xt(e){return(e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3))>>>0}const hr="Bengbng2Devadev2Gujrgjr2Gurugur2Kndaknd2Mlymmlm2Oryaory2Tamltml2Telutel2Mymrmym2",fr="HirakanaLaoolao Yiiiyi Nkoonko Vaiivai Zmthmath";function Ke(e,t){for(let n=0;n<e.length;n+=8)if(e.substring(n,n+4)===t)return e.substring(n+4,n+8);return""}function je(e){let t=Xe[e];if(!t){t=[];const n=yn(e),s=Ke(hr,n);s&&(s!=="mym2"&&t.push(xt(s.substring(0,3)+"3")),t.push(xt(s))),t.push(xt(Ke(fr,n)||n.toLowerCase())),Xe[e]=t}return t}const Ve=64,On=64,ur=["abvm","blwm","mark","mkmk","curs","dist","kern"].map(xt),pr=xt("kern"),We=[xt("DFLT"),xt("dflt"),xt("latn")],bs=0,ws=1,Gn=2,Ut=new Uint16Array(0),_r=new Int16Array(0),yr=new Uint32Array(0);class Mn{constructor(t,n,s,o){this._type=t,this._fmt=n,this._off=s,this._cov=o,this._cd1=Ut,this._cd2=Ut,this._cd3=Ut,this._vf1=0,this._vf2=0,this._len1=0,this._len2=0,this._n1=0,this._n2=0,this._simple=!1,this._kx=_r,this._ps=yr,this._sg=Ut}}class gr{constructor(t,n,s){this._props=t,this._set=n,this._subs=s;let o=0;for(const r of s)o=Math.max(o,r._cov.length);const i=new Uint8Array(o);for(const r of s){const c=r._cov;for(let a=0;a<c.length;a++)c[a]!==$t&&(i[a]=1)}this._any=i,this._pairs=s.length>0&&s.every(r=>r._simple)}}class xr{constructor(t,n){this._lookups=t,this._kern=n}}let dt=new DataView(new ArrayBuffer(0)),ze=0,Nn=0,Ze=0,qt=0,Yt=null;const As=new Int32Array(Ve*On);function $n(e,t,n){let s=e;t&1&&(L._xo[n]=L._xo[n]+dt.getInt16(s),s+=2),t&2&&(L._yo[n]=L._yo[n]+dt.getInt16(s),s+=2),t&4&&(L._xa[n]=L._xa[n]+dt.getInt16(s))}function dr(e,t,n){const s=L._gid,o=L._gp,i=L._xa,r=e._any,c=e._subs,a=e._props,l=e._set;for(let h=t;h<n;h++){const f=s[h];if(f>=r.length||!r[f])continue;const u=o[h];if(u&a&14||u&Dt&&!pn(u,f,a,l))continue;let p=h+1;if(p>=n)break;const _=o[p];if((_&(nn|Dt)||_&a&14)&&(p=gs(h,n,a,l),p<0))continue;const y=s[p];for(let g=0;g<c.length;g++){const x=c[g],b=x._cov,M=f<b.length?b[f]:$t;if(M===$t)continue;let A=-1;if(x._fmt===1){if(M>=x._ps.length-1)continue;const k=x._sg;let T=x._ps[M],S=x._ps[M+1]-1;for(;T<=S;){const w=T+S>>1,m=k[w];if(m<y)T=w+1;else if(m>y)S=w-1;else{A=w;break}}}else{const k=f<x._cd1.length?x._cd1[f]:0,T=y<x._cd2.length?x._cd2[y]:0;k<x._n1&&T<x._n2&&(A=k*x._n2+T)}if(!(A<0)){i[h]=i[h]+x._kx[A],h=p-1;break}}}}function Qe(e){let t=0;for(let n=e&255;n;n&=n-1)t++;return t*2}class Mr{constructor(t,n,s){this._lookupCache=[],this._planCache=[],this._covCache=new Map,this._cdCache=new Map;const o=new DataView(t);this._view=o,this._scripts=n+o.getUint16(n+4),this._features=n+o.getUint16(n+6),this._lookupList=n+o.getUint16(n+8),this._gdef=s}_cov(t,n){if(!n)return Ut;let s=this._covCache.get(t+n);return s||(s=Pe(this._view,t+n),this._covCache.set(t+n,s)),s}_cd(t,n){if(!n)return Ut;let s=this._cdCache.get(t+n);return s||(s=xs(this._view,t+n),this._cdCache.set(t+n,s)),s}_script(t){const n=this._view,s=this._scripts;for(let o=0,i=n.getUint16(s);o<i;o++)if(n.getUint32(s+2+6*o)===t)return s+n.getUint16(s+6+6*o);return 0}_plan(t,n){let s=this._planCache[t];if(s)return s;const o=this._view;let i=0;for(let l=0;l<n.length&&!i;l++)i=this._script(n[l]);for(let l=0;l<We.length&&!i;l++)i=this._script(We[l]);const r=[];let c=!1;const a=i?o.getUint16(i):0;if(a){const l=i+a,h=o.getUint16(l+2),f=this._features,u=o.getUint16(f),p=o.getUint16(l+4);for(let _=-1;_<p;_++){const y=_<0?h:o.getUint16(l+6+2*_);if(y>=u)continue;const g=o.getUint32(f+2+6*y);if(_>=0&&ur.indexOf(g)<0)continue;g===pr&&(c=!0);const x=f+o.getUint16(f+6+6*y);for(let b=0,M=o.getUint16(x+2);b<M;b++){const A=o.getUint16(x+4+2*b);r.indexOf(A)<0&&r.push(A)}}}return r.sort((l,h)=>l-h),s=new xr(r,c),this._planCache[t]=s,s}_lookup(t){const n=this._lookupCache[t];if(n)return n;const s=this._view,o=this._lookupList;if(t>=s.getUint16(o))return null;const i=o+s.getUint16(o+2+2*t),r=s.getUint16(i),c=s.getUint16(i+2),a=s.getUint16(i+4);let l=null;c&16&&(l=this._gdef?this._gdef._markSet(s.getUint16(i+6+2*a)):Ut);const h=[];for(let u=0;u<a;u++){let p=i+s.getUint16(i+6+2*u),_=r;_===9&&(_=s.getUint16(p+2),p+=s.getUint32(p+4));const y=this._sub(_,p);y&&h.push(y)}const f=new gr(c,l,h);return this._lookupCache[t]=f,f}_sub(t,n){const s=this._view,o=s.getUint16(n);if(t===1||t===2){if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return i._vf1=s.getUint16(n+4),i._len1=Qe(i._vf1),t===2&&(i._vf2=s.getUint16(n+6),i._len2=Qe(i._vf2),o===2&&(i._cd1=this._cd(n,s.getUint16(n+8)),i._cd2=this._cd(n,s.getUint16(n+10)),i._n1=s.getUint16(n+12),i._n2=s.getUint16(n+14)),(i._vf1&15)===4&&i._vf2===0&&this._decodePairs(i)),i}if(t===7){if(o===3)return new Mn(t,o,n,this._cov(n,s.getUint16(n+6)));if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4))),i}if(t===8){if(o===3){const r=s.getUint16(n+2);return new Mn(t,o,n,this._cov(n,s.getUint16(n+6+2*r)))}if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4)),i._cd2=this._cd(n,s.getUint16(n+6)),i._cd3=this._cd(n,s.getUint16(n+8))),i}return null}_decodePairs(t){const n=this._view,s=t._off,o=t._len1;if(t._simple=!0,t._fmt===2){const h=t._n1*t._n2,f=new Int16Array(h);for(let u=0;u<h;u++)f[u]=n.getInt16(s+16+u*o);t._kx=f;return}const i=n.getUint16(s+8),r=new Uint32Array(i+1);let c=0;for(let h=0;h<i;h++)r[h]=c,c+=n.getUint16(s+n.getUint16(s+10+2*h));r[i]=c;const a=new Uint16Array(c),l=new Int16Array(c);for(let h=0;h<i;h++){const f=s+n.getUint16(s+10+2*h);for(let u=0,p=r[h+1]-r[h];u<p;u++){const _=f+2+u*(2+o);a[r[h]+u]=n.getUint16(_),l[r[h]+u]=n.getInt16(_+2)}}t._ps=r,t._sg=a,t._kx=l}_position(t,n,s){dt=this._view,ze=n,Nn=s,Ze=Math.max((s-n)*64,16384);const o=t._lookups;for(let i=0;i<o.length;i++){const r=this._lookup(o[i]);if(!r||!r._subs.length)continue;if(qt=r._props,Yt=r._set,r._pairs){dr(r,n,s);continue}const c=L._gp,a=L._gid,l=r._any;for(let h=n;h<s;){const f=a[h];if(f<l.length&&l[f]&&pn(c[h],f,qt,Yt)){const u=this._applyAt(r,h,0);if(u>=0){h=u;continue}}h++}}}_applyAt(t,n,s){const o=t._subs;for(let i=0;i<o.length;i++){const r=this._applySub(o[i],n,s);if(r>=0)return r}return-1}_applySub(t,n,s){const o=L._gid[n],i=t._cov,r=o<i.length?i[o]:$t;if(r===$t)return-1;const c=dt,a=t._off;switch(t._type){case 1:{if(t._fmt===1)$n(a+6,t._vf1,n);else{if(r>=c.getUint16(a+6))return-1;$n(a+8+r*t._len1,t._vf1,n)}return n+1}case 2:{let l=n+1;if(l>=Nn)return-1;const h=L._gp[l];if((h&(nn|Dt)||h&qt&14)&&(l=gs(n,Nn,qt,Yt),l<0))return-1;const f=L._gid[l];if(t._simple){const p=t._kx;if(t._fmt===1){if(r>=t._ps.length-1)return-1;const g=t._sg;let x=t._ps[r],b=t._ps[r+1]-1;for(;x<=b;){const M=x+b>>1,A=g[M];if(A<f)x=M+1;else if(A>f)b=M-1;else return L._xa[n]=L._xa[n]+p[M],l}return-1}const _=o<t._cd1.length?t._cd1[o]:0,y=f<t._cd2.length?t._cd2[f]:0;return _>=t._n1||y>=t._n2?-1:(L._xa[n]=L._xa[n]+p[_*t._n2+y],l)}let u;if(t._fmt===1){if(r>=c.getUint16(a+8))return-1;const p=a+c.getUint16(a+10+2*r),_=2+t._len1+t._len2;let y=0,g=c.getUint16(p)-1;for(u=-1;y<=g;){const x=y+g>>1,b=p+2+x*_,M=c.getUint16(b);if(M<f)y=x+1;else if(M>f)g=x-1;else{u=b+2;break}}if(u<0)return-1}else{const p=o<t._cd1.length?t._cd1[o]:0,_=f<t._cd2.length?t._cd2[f]:0;if(p>=t._n1||_>=t._n2)return-1;u=a+16+(p*t._n2+_)*(t._len1+t._len2)}return t._vf1&&$n(u,t._vf1,n),t._vf2&&$n(u+t._len1,t._vf2,l),t._len2?l+1:l}case 7:return this._context(t,n,o,r,s);case 8:return this._chain(t,n,o,r,s)}return-1}_context(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){const p=r.getUint16(c+2),_=this._input(n,p,Gn,Ut,c+8,c,i);return _<0?-1:(this._apply(c+6+2*p,r.getUint16(c+4),p,i),_)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd1.length?t._cd1[s]:0,l=c+6,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const u=c+f;for(let p=0,_=r.getUint16(u);p<_;p++){const y=u+r.getUint16(u+2+2*p),g=r.getUint16(y),x=this._input(n,g,h,t._cd1,y+4,0,i);if(!(x<0))return this._apply(y+4+2*Math.max(g-1,0),r.getUint16(y+2),g,i),x}return-1}_chain(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){let p=c+2;const _=r.getUint16(p),y=p+2;p+=2+2*_;const g=r.getUint16(p),x=p+2;p+=2+2*g;const b=r.getUint16(p),M=p+2;p+=2+2*b;const A=this._input(n,g,Gn,Ut,x+2,c,i);return A<0||!this._lookahead(A,b,Gn,Ut,M,c)||!this._backtrack(n,_,Gn,Ut,y,c)?-1:(this._apply(p+2,r.getUint16(p),g,i),A)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd2.length?t._cd2[s]:0,l=c+10,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const u=c+f;for(let p=0,_=r.getUint16(u);p<_;p++){let y=u+r.getUint16(u+2+2*p);const g=r.getUint16(y),x=y+2;y+=2+2*g;const b=r.getUint16(y),M=y+2;y+=2+2*Math.max(b-1,0);const A=r.getUint16(y),k=y+2;y+=2+2*A;const T=this._input(n,b,h,t._cd2,M,0,i);if(!(T<0)&&this._lookahead(T,A,h,t._cd3,k,0)&&this._backtrack(n,g,h,t._cd1,x,0))return this._apply(y+2,r.getUint16(y),b,i),T}return-1}_matches(t,n,s,o,i){if(t===bs)return i===o;if(t===ws)return(i<n.length?n[i]:0)===o;const r=this._cov(s,o);return i<r.length&&r[i]!==$t}_next(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t+1;a<Nn;a++){const l=r[a],h=c[a];if(pn(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_prev(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t-1;a>=ze;a--){const l=r[a],h=c[a];if(pn(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_input(t,n,s,o,i,r,c){if(n>On)return-1;const a=c*On;As[a]=t;let l=t;for(let h=1;h<n;h++){if(l=this._next(l,s,o,r,dt.getUint16(i+2*(h-1))),l<0)return-1;As[a+h]=l}return l+1}_lookahead(t,n,s,o,i,r){let c=t-1;for(let a=0;a<n;a++)if(c=this._next(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_backtrack(t,n,s,o,i,r){let c=t;for(let a=0;a<n;a++)if(c=this._prev(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_apply(t,n,s,o){const i=o*On;for(let r=0;r<n;r++){const c=dt.getUint16(t+4*r);if(c>=s||o+1>=Ve||Ze--<=0)continue;const a=this._lookup(dt.getUint16(t+4*r+2));if(!a)continue;const l=qt,h=Yt;qt=a._props,Yt=a._set,this._applyAt(a,As[i+c],o+1),qt=l,Yt=h}}}function mr(e){if(e<173)return!1;if(e<65536){switch(e>>8){case 0:return e===173;case 3:return e===847;case 6:return e===1564;case 23:return e>=6068&&e<=6069;case 24:return e>=6155&&e<=6159;case 32:return e>=8203&&e<=8207||e>=8234&&e<=8238||e>=8288&&e<=8303;case 254:return e>=65024&&e<=65039||e===65279;case 255:return e>=65520&&e<=65528}return!1}return e>=119155&&e<=119162||e>=917504&&e<=921599}function br(e,t,n){const s=e.metrics.unitsPerEm;switch(t){case 160:return e.advance(n);case 8193:case 8195:case 12288:return s;case 8192:case 8194:return s/2;case 8196:return s/3;case 8197:return s/4;case 8198:return s/6;case 8201:return s/5;case 8202:return s/16;case 8287:return s*4/18;case 8239:return e.advance(n)/2;case 8199:{for(let o=48;o<=57;o++){const i=e.glyphId(o);if(i)return e.advance(i)}return e.advance(n)}case 8200:{const o=e.glyphId(46)||e.glyphId(44);return e.advance(o||n)}}return-1}let ks=null;const Je=new Map;function wr(e){if(e<768)return!1;let t=Je.get(e);return t===void 0&&(ks||(ks=new RegExp("^\\p{Mn}$","u")),t=ks.test(String.fromCodePoint(e)),Je.set(e,t)),t}function Ar(e,t){const n=t.length;Re(n);const s=L._cp,o=L._gid,i=L._gp,r=L._xa,c=L._xo,a=L._yo,l=e._glyphProps(),h=e._advances(),f=h.length?h[h.length-1]:0,u=e.glyphId(32);let p=!1,_=0,y=0;for(let M=0;M<n;M++){let A=t.charCodeAt(M);if(A>=55296&&A<56320&&M+1<n){const m=t.charCodeAt(M+1);m>=56320&&m<57344&&(A=(A-55296<<10)+(m-56320)+65536,M++)}let k=e.glyphId(A),T=-1;!k&&A>=160&&u&&((A===8192||A===8193)&&(k=e.glyphId(A+2)),k||(T=br(e,A,u),T>=0&&(k=u)));const S=A>=173&&mr(A);let w;l?w=k<l.length?l[k]:0:w=!S&&wr(A)?Dt:In,S&&(w|=A===8204?un:un|nn,p=!0),_|=w,s[y]=A,o[y]=k,i[y]=w,r[y]=T>=0?T:k<h.length?h[k]:f,c[y]=0,a[y]=0,y++}const g=lr(s,y,L._runEnd,L._runScript),x=(_&Dt)!==0;let b=0;for(let M=0;M<g;M++){const A=L._runEnd[M];ro(e,b,A,L._runScript[M],x),b=A}if(p)for(let M=0;M<y;M++)i[M]&un&&(r[M]=c[M]=a[M]=0);return y}const Us=0,to=1,Ts=2,kr=3,Ss=4,Bn=Ts|Ss,Ur=Us|Ss,Tr=Ts,no=Us,vs=to,Sr="BengDevaGujrGuruKndaMlymOryaTamlTelu",vr="TibtMongSinhBuhdHanoTglgTagbLimbTaleBugiKharSyloTfngBaliNkooPhagChamKaliLepcRjngSaurSundEgypJavaKthiMteiLanaTavtBatkBrahMandCakmPlrdShrdTakrDuplGranKhojSindMahjManiModiHmngPhlpSiddTirhAhomMultAdlmBhksMarcNewaGonmSoyoZanbDogrGongRohgMakaMedfSogoSogdElymNandHmnpWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTolsJurcPcunSeal",so=xt("DFLT"),eo=xt("latn"),Cr=xt("mymr"),oo=[so,xt("dflt"),eo];function Er(e,t){if(!e)return 0;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>=0)return t[n];for(let n=0;n<3;n++)if(e.indexOf(oo[n])>=0)return oo[n];return 0}function Ir(e,t){const n=t===so||t===eo;return e==="Thai"||e==="Laoo"?Tr:e==="Hang"?Ur:e==="Khmr"?no:e==="Mymr"?n||t===Cr?Bn:vs:Sr.indexOf(e)>=0?n?Bn:(t&255)===51?vs:no:vr.indexOf(e)>=0?n?Bn:vs:Bn}function Dr(e,t){const n=e._shaperCache();let s=n[t];return s<0&&(s=Ir(yn(t),Er(e._gsubScriptTags(),je(t))),n[t]=s),s}function io(e,t,n){const s=L._gp,o=L._xa,i=L._xo;for(let r=e;r<t;r++)s[r]&Dt&&(n&&(i[r]=i[r]-o[r]),o[r]=0)}function ro(e,t,n,s,o){const i=Dr(e,s),r=e._gposTable(),c=e._kernTable(),a=r?r._plan(s,je(s)):null,l=c!==null&&c._hasData&&!(a&&a._kern)&&(i&Ss)!==0,h=!o||l&&c._hasMachine?Us:i&kr,f=!r&&(!l||!c._hasCross);h===to&&io(t,n,f),a&&r._position(a,t,n),l&&c._apply(t,n),h===Ts&&io(t,n,f)}function Rr(e,t,n){Re(2);const s=e._glyphProps(),o=e.advance(t),i=e.advance(n);return L._gid[0]=t,L._gid[1]=n,L._gp[0]=s?t<s.length?s[t]:0:In,L._gp[1]=s?n<s.length?s[n]:0:In,L._xa[0]=o,L._xa[1]=i,L._xo[0]=L._xo[1]=L._yo[0]=L._yo[1]=0,ro(e,0,2,lt,((L._gp[0]|L._gp[1])&Dt)!==0),L._xa[0]+L._xa[1]-o-i}function Lr(e){const t=new It(e);if(t.u32()===1953784678){if(t.skip(4),t.u32()===0)throw new Error("TTC contains no fonts");const o=t.u32();t.seek(o)}else t.seek(0);return Pr(e,t)}function Pr(e,t){t.skip(4);const n=t.u16();t.skip(6);const s=new Map;for(let o=0;o<n;o++){const i=String.fromCharCode(t.u8(),t.u8(),t.u8(),t.u8());t.skip(4);const r=t.u32(),c=t.u32();s.set(i,{offset:r,length:c})}return s}const co=2048,Fr=65536;class qr{constructor(t){this._buffer=t,this._tables=Lr(t);const n=this._tables.get("head"),s=this._tables.get("maxp"),o=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(!s)throw new Error("Font missing required `maxp` table");if(!o)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=Di(t,n.offset);const a=Fi(t,s.offset);this._hhea=Ri(t,o.offset),this._hmtx=Li(t,i.offset,a.numGlyphs,this._hhea.numberOfHMetrics),this._loca=Pi(t,r.offset,a.numGlyphs,this._head.indexToLocFormat),this._cmap=Ci(t,c.offset),this._cmapCache=null,this._layoutLoaded=!1,this._gdef=null,this._gpos=null,this._kern=null,this._gsubScripts=null,this._shapers=null,this._advanceTable=null,this._pairCache=new Map,this.metrics={unitsPerEm:this._head.unitsPerEm,ascender:this._hhea.ascender,descender:this._hhea.descender,lineGap:this._hhea.lineGap}}glyphId(t){if(t>=co||t<0)return this._cmap(t);let n=this._cmapCache;n||(n=this._cmapCache=new Uint16Array(co));let s=n[t];return s||(n[t]=s=this._cmap(t)+1),s-1}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){const s=t<32768&&n<32768?t<<15|n:-1-(t*65536+n),o=this._pairCache.get(s);return o!==void 0?o:this._kerningMiss(s,t,n)}_kerningMiss(t,n,s){const o=Rr(this,n,s);return this._pairCache.size>=Fr&&this._pairCache.clear(),this._pairCache.set(t,o),o}_loadLayout(){if(this._layoutLoaded)return;this._layoutLoaded=!0;const t=this._buffer,n=this._tables.get("GDEF"),s=this._tables.get("GPOS"),o=this._tables.get("kern"),i=this._tables.get("GSUB");n&&(this._gdef=new nr(t,n.offset,this.numGlyphs)),s&&(this._gpos=new Mr(t,s.offset,this._gdef)),o&&(this._kern=new Ji(t,o.offset)),i&&(this._gsubScripts=tr(new DataView(t),i.offset))}_gsubScriptTags(){return this._loadLayout(),this._gsubScripts}_shaperCache(){let t=this._shapers;return t||(t=this._shapers=new Int8Array(Dn).fill(-1)),t}_advances(){let t=this._advanceTable;if(!t){const n=this._hmtx.length;t=new Uint16Array(n);for(let s=0;s<n;s++)t[s]=this._hmtx[s].advanceWidth;this._advanceTable=t}return t}_glyphProps(){return this._loadLayout(),this._gdef?this._gdef._props:null}_gposTable(){return this._loadLayout(),this._gpos}_kernTable(){return this._loadLayout(),this._kern}shape(t){const n=this._tables.get("glyf");if(!n)return{contours:[],inverseYAxis:!1};const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return Ki(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}_glyphRaw(t){const n=this._tables.get("glyf");if(!n)return[];const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return Ie(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}}function Yn(e,t){const n=1/t;for(const s of e.contours)for(let o=0;o<s.length;o++){const i=s[o];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;Q(r,c,a,l)===0&&(s[o]=new tt(J,i.p0x,i.p0y,i.p2x,i.p2y,0,0,0,0))}else if(i.type===Et){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;Q(i.p1x-i.p0x,i.p1y-i.p0y,r,c)===0&&Q(r,c,i.p3x-i.p2x,i.p3y-i.p2y)===0?s[o]=new tt(J,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&&(s[o]=new tt(ot,i.p0x,i.p0y,a,l,i.p3x,i.p3y,0,0))}}}const ao=1e-6,Or=1.1111111111111112,Gr=new Float64Array(16);function lo(e,t,n){switch(t[n]=e.p0x,t[n+1]=e.p0y,t[n+2]=e.p1x,t[n+3]=e.p1y,e.type){case J:return 1;case ot:return t[n+4]=e.p2x,t[n+5]=e.p2y,2;default:return t[n+4]=e.p2x,t[n+5]=e.p2y,t[n+6]=e.p3x,t[n+7]=e.p3y,3}}function ho(e,t,n){if(n===3){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5],l=e[t+6],h=e[t+7];(i===s&&r===o||i===l&&r===h)&&(c===s&&a===o||c===l&&a===h)&&(e[t+2]=l,e[t+3]=h,n=1)}if(n===2){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5];(i===s&&r===o||i===c&&r===a)&&(e[t+2]=c,e[t+3]=a,n=1)}return n===1&&e[t]===e[t+2]&&e[t+1]===e[t+3]&&(n=0),n}function Nr(e,t){const n=Gr;let s=lo(e,n,0),o=lo(t,n,8);if(!(s>=1&&s<=3&&o>=1&&o<=3)||n[s*2]!==n[8]||n[s*2+1]!==n[9])return 0;s=ho(n,0,s),o=ho(n,8,o);const i=n[s*2],r=n[s*2+1];let c=0,a=0,l=0,h=0,f=0,u=0,p=0,_=0,y=0,g=0,x=0,b=0;if(s>=1&&(c=n[(s-1)*2]-i,a=n[(s-1)*2+1]-r),s>=2){const H=n[(s-2)*2]-n[(s-1)*2],V=n[(s-2)*2+1]-n[(s-1)*2+1];l=H-c,h=V-a}if(s>=3){const H=n[(s-3)*2]-n[(s-2)*2],V=n[(s-3)*2+1]-n[(s-2)*2+1],et=n[(s-2)*2]-n[(s-1)*2],z=n[(s-2)*2+1]-n[(s-1)*2+1];f=H-et-l,u=V-z-h,l*=3,h*=3}if(o>=1&&(p=n[10]-i,_=n[11]-r),o>=2){const H=n[12]-n[10],V=n[13]-n[11];y=H-p,g=V-_}if(o>=3){const H=n[14]-n[12],V=n[15]-n[13],et=n[12]-n[10],z=n[13]-n[11];x=H-et-y,b=V-z-g,y*=3,g*=3}c*=s,a*=s,p*=o,_*=o;const M=c!==0||a!==0;if(M&&(p!==0||_!==0)){const H=Math.sqrt(c*c+a*a),V=Math.sqrt(p*p+_*_),et=H*Q(c,a,y,g)+V*Q(l,h,p,_);if(et)return ut(et);const z=H*H*Q(c,a,x,b)+H*V*Q(l,h,y,g)+V*V*Q(f,u,p,_);if(z)return ut(z);const Gt=H*Q(l,h,x,b)+V*Q(f,u,y,g);return ut(Gt||Q(f,u,x,b))}let k=1,T=l,S=h,w=f,m=u,d=p,U=_,C=y,v=g,I=x,R=b;if(M&&(T=y,S=g,w=x,m=b,d=c,U=a,C=l,v=h,I=f,R=u,k=-1),d!==0||U!==0){const H=Q(w,m,d,U);if(H)return k*ut(H);const V=Q(T,S,C,v);if(V)return k*ut(V);const et=Q(w,m,C,v);if(et)return k*ut(et);const z=Q(T,S,I,R);return z?k*ut(z):k*ut(Q(w,m,I,R))}const G=Math.sqrt(T*T+S*S),F=Math.sqrt(C*C+v*v),X=Math.sqrt(G)*Q(T,S,I,R)+Math.sqrt(F)*Q(w,m,C,v);return ut(X||Q(w,m,I,R))}function fo(e,t,n,s,o){let i=e[t];if(i.type===ot){const r=i.convertToCubic();e[t]=r,i=r}if(i.type===Et)if(n===0){const r=Math.sqrt((i.p1x-i.p0x)**2+(i.p1y-i.p0y)**2);i.p1x+=r*s,i.p1y+=r*o}else{const r=Math.sqrt((i.p2x-i.p3x)**2+(i.p2y-i.p3y)**2);i.p2x+=r*s,i.p2y+=r*o}}const mn=[0,0],bn=[0,0];function $r(e){for(let t=0;t<e.contours.length;t++){const n=e.contours[t];let s=0;for(let o=0;o<n.length;o++){const i=n[o];(i.p0x!==i.endX()||i.p0y!==i.endY())&&(n[s++]=i)}n.length=s}for(const t of e.contours)if(t.length===1){const[n,s,o]=t[0].splitInThirds();t.length=0,t.push(n,s,o)}else if(t.length>0){const n=t.length;for(let s=0;s<n;s++){const o=(s+n-1)%n,i=t[o],r=t[s];i.direction(1,mn),r.direction(0,bn);const c=Math.sqrt(mn[0]**2+mn[1]**2),a=Math.sqrt(bn[0]**2+bn[1]**2);if(c===0||a===0)continue;const l=mn[0]/c,h=mn[1]/c,f=bn[0]/a,u=bn[1]/a;if(bi(l,h,f,u)<ao-1){const p=ao-1,_=Or*Math.sqrt(1-p*p)/p;let y=f-l,g=u-h;const x=Math.sqrt(y*y+g*g);if(x===0)continue;y=_*y/x,g=_*g/x,Nr(i,r)<0&&(y=-y,g=-g),fo(t,o,1,-g,y),fo(t,s,0,g,-y)}}}}const uo=[0,0,0],po=[0,0,0],_o=[0,0];function yo(e){const t=.5*(Math.sqrt(5)-1),n=e.map(()=>0),s=[];for(let o=0;o<e.length;o++){const i=e[o];if(n[o]||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,_o),c=_o[1];const a=Ue(r,c,t);for(let l=0;l<e.length;l++)for(const h of e[l]){const f=h.scanlineIntersections(a,uo,po);for(let u=0;u<f;u++)s.push({x:uo[u],dy:po[u],c:l})}s.sort((l,h)=>ut(l.x-h.x));for(let l=1;l<s.length;l++)s[l].x===s[l-1].x&&(s[l].dy=s[l-1].dy=0);for(let l=0;l<s.length;l++){const h=s[l];h.dy&&(n[h.c]+=2*(l&1^(h.dy>0?1:0))-1)}s.length=0}for(let o=0;o<e.length;o++){if(n[o]>=0)continue;const i=e[o].reverse();for(let r=0;r<i.length;r++){const c=i[r];i[r]=c.type===J?new tt(J,c.p1x,c.p1y,c.p0x,c.p0y,0,0,0,0):c.type===ot?new tt(ot,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y,0,0):new tt(Et,c.p3x,c.p3y,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y)}}}const go=1e-5,Cs=1e-6,Br=2e4,Yr=1e5;function Hr(e){return[e.p0x,e.p0y,e.p1x,e.p1y,e.p2x,e.p2y,e.p3x,e.p3y].slice(0,2*e.type+4)}function xo(e){const t=e.length/2-2;return new tt(t,e[0],e[1],e[2],e[3],e[4]??0,e[5]??0,e[6]??0,e[7]??0)}const at=new Float64Array(8),ht=new Float64Array(8),Wt=new Float64Array(8);function Es(e,t,n,s){const o=e.length,i=o/2-1;for(let r=0;r<=i;r++){for(let c=0;c<o;c++)Wt[c]=e[c];for(let c=0,a=o;c<i;c++,a-=2){const l=c<i-r?t:n;for(let h=0;h<a-2;h++)Wt[h]=Wt[h]+l*(Wt[h+2]-Wt[h])}s[2*r]=Wt[0],s[2*r+1]=Wt[1]}}function Xr(e,t,n){return Es(e,t,n,at),Array.from(at.subarray(0,e.length))}let Is=0,Ds=0,Ot=-1,wn=-1,An=0,kn=0,Hn=0,Xn=0;function Kr(e,t){Ot=-1,wn=-1;let n=0;for(let h=0;h<2;h++){const f=h?e.length-2:0;for(let u=0;u<2;u++){const p=u?t.length-2:0;e[f]===t[p]&&e[f+1]===t[p+1]&&(n++,Ot=h,wn=u)}}if(n!==1){Ot=-1;return}const s=Ot?e.length-2:0;An=e[s],kn=e[s+1];let o=0,i=0;for(let h=2;h<e.length&&o===0&&i===0;h+=2){const f=Ot?e.length-2-h:h;o=e[f]-An,i=e[f+1]-kn}let r=0,c=0;for(let h=2;h<t.length&&r===0&&c===0;h+=2){const f=wn?t.length-2-h:h;r=t[f]-An,c=t[f+1]-kn}const a=Math.hypot(o,i),l=Math.hypot(r,c);Hn=o/a-r/l,Xn=i/a-c/l,Math.hypot(Hn,Xn)>1e-9||(Ot=-1)}function jr(e,t){const n=Ot?e-2:0;for(let o=0;o<e;o+=2)if(o!==n&&(at[o]-An)*Hn+(at[o+1]-kn)*Xn<=0)return!1;const s=wn?t-2:0;for(let o=0;o<t;o+=2)if(o!==s&&(ht[o]-An)*Hn+(ht[o+1]-kn)*Xn>=0)return!1;return!0}function Un(e,t,n,s,o,i,r){if(--Is<0||--Ds<0)return;const c=e.length,a=s.length;Es(e,t,n,at),Es(s,o,i,ht);let l=1/0,h=1/0,f=-1/0,u=-1/0;for(let M=0;M<c;M+=2)l=Math.min(l,at[M]),h=Math.min(h,at[M+1]),f=Math.max(f,at[M]),u=Math.max(u,at[M+1]);let p=1/0,_=1/0,y=-1/0,g=-1/0;for(let M=0;M<a;M+=2)p=Math.min(p,ht[M]),_=Math.min(_,ht[M+1]),y=Math.max(y,ht[M]),g=Math.max(g,ht[M+1]);if(l>y||p>f||h>g||_>u||Ot>=0&&(Ot?n===1:t===0)&&(wn?i===1:o===0)&&jr(c,a))return;const x=Math.max(f-l,u-h),b=Math.max(y-p,g-_);if(c===4&&a===4||x<go&&b<go){const M=at[c-2]-at[0],A=at[c-1]-at[1],k=ht[a-2]-ht[0],T=ht[a-1]-ht[1],S=Q(M,A,k,T),w=Q(ht[0]-at[0],ht[1]-at[1],k,T)/S,m=Q(ht[0]-at[0],ht[1]-at[1],M,A)/S;w>=0&&w<=1&&m>=0&&m<=1&&r.push(t+w*(n-t),o+m*(i-o))}else x>b?(Un(e,t,(t+n)/2,s,o,i,r),Un(e,(t+n)/2,n,s,o,i,r)):(Un(e,t,n,s,o,(o+i)/2,r),Un(e,t,n,s,(o+i)/2,i,r))}function Kn(e,t,n){const s=e[2]-e[0],o=e[3]-e[1];return((t-e[0])*s+(n-e[1])*o)/(s*s+o*o)}function Vr(e,t,n){if(e.length!==4||t.length!==4)return!1;const s=e[2]-e[0],o=e[3]-e[1],i=1e-9*Math.hypot(s,o);return Math.abs(Q(s,o,t[0]-e[0],t[1]-e[1]))>i||Math.abs(Q(s,o,t[2]-e[0],t[3]-e[1]))>i?!1:(n.push(Kn(e,t[0],t[1]),0,Kn(e,t[2],t[3]),1),n.push(0,Kn(t,e[0],e[1]),1,Kn(t,e[2],e[3])),!0)}function Wr(e){const t=[];for(let n=e.length-2;n>=0;n-=2)t.push(e[n],e[n+1]);return t}function zr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!(Math.abs(e[n]-t[n])<Cs))return!1;return!0}const Tn=[0,0],zt=[0,0],jn=[0,0,0],Vn=[0,0,0];let on=new Int32Array(8);const Zr=0,Mo=1,Qr=2;function mo(e,t,n,s){let o=0;for(let i=0;i<e.length;i++){if(s<t[4*i+1]-1e-9||s>t[4*i+3]+1e-9)continue;const r=e[i].scanlineIntersections(s,jn,Vn);for(let c=0;c<r;c++)jn[c]<=n&&(o+=Vn[c])}return o!==0}function bo(e,t,n,s,o,i,r){on.fill(0,0,n);for(let a=0;a<e.length;a++){if(r<o[4*a+1]-1e-9||r>o[4*a+3]+1e-9)continue;const l=e[a].scanlineIntersections(r,jn,Vn);for(let h=0;h<l;h++)jn[h]<=i&&(on[t[a]]+=Vn[h])}let c=!1;for(let a=1;a<n&&!c;a++)c=on[a]!==0;return on[0]!==0&&(s===Mo?c:!c)}function Jr(e){const t=Rs([e.contours]);t&&(e.contours=t)}function wo(e,t){const n=Rs([e.contours,...t.length>0?t:[[]]],Mo);n&&(e.contours=n)}function tc(e,t){if(t.length===0)return;const n=Rs([e.contours,...t],Qr);n&&(e.contours=n)}function Rs(e,t=Zr){const n=e.flat(),s=n.flat(),o=s.map(Hr),i=o.length,r=e.length,c=r>1;on.length<r&&(on=new Int32Array(r));const a=new Float64Array(4*i),l=new Int32Array(i),h=new Int32Array(i);let f=0;for(let w=0;w<r;w++)for(const m of e[w]){for(let d=0;d<m.length;d++)l[f+d]=f+(d+1)%m.length,h[f+d]=w;f+=m.length}for(let w=0;w<i;w++){const m=o[w];let d=1/0,U=1/0,C=-1/0,v=-1/0;for(let I=0;I<m.length;I+=2)d=Math.min(d,m[I]),U=Math.min(U,m[I+1]),C=Math.max(C,m[I]),v=Math.max(v,m[I+1]);a[4*w]=d,a[4*w+1]=U,a[4*w+2]=C,a[4*w+3]=v}const u=Array.from({length:i},(w,m)=>m).sort((w,m)=>a[4*w]-a[4*m]),p=o.map(()=>[]),_=new Uint8Array(i);Ds=Yr;for(let w=0;w<i;w++){const m=u[w];for(let d=w+1;d<i;d++){const U=u[d];if(a[4*U]>a[4*m+2])break;if(a[4*m+1]>a[4*U+3]||a[4*U+1]>a[4*m+3])continue;const C=Math.min(m,U),v=Math.max(m,U);l[C]!==v&&l[v]!==C&&(_[C]=_[v]=1);const I=[];if(Is=Br,Vr(o[C],o[v],I)||(Kr(o[C],o[v]),Un(o[C],0,1,o[v],0,1,I)),Is<0||Ds<0)return null;for(let R=0;R<I.length;R+=2)p[C].push(I[R]),p[v].push(I[R+1])}}const y=p.map(w=>{const m=[0];for(const d of w.sort((U,C)=>U-C))d-m[m.length-1]>1e-7&&d<1-1e-7&&m.push(d);return m.push(1),m});let g=!1;const x=[],b=[];let M=0;for(const w of n){const m=M+w.length;let d=!0;for(let I=M;I<m;I++)(_[I]||y[I].length>2)&&(d=!1);let U=!1,C=!1,v=!1;for(let I=M;I<m;I++){const R=y[I];for(let G=1;G<R.length;G++){const F=Xr(o[I],R[G-1],R[G]),X=xo(F);X.point(.5,Tn),X.direction(.5,zt);const H=Math.hypot(zt[0],zt[1]),V=Math.hypot(F[F.length-2]-F[0],F[F.length-1]-F[1]);if(!(H===0||V===0)){if(!d||!U){const et=Math.min(1e-6,V*V/64)/H,z=Tn[0]+zt[1]*et,Gt=Tn[1]-zt[0]*et,_t=Tn[0]-zt[1]*et,Xt=Tn[1]+zt[0]*et;C=c?bo(s,h,r,t,a,z,Gt):mo(s,a,z,Gt),v=c?bo(s,h,r,t,a,_t,Xt):mo(s,a,_t,Xt),U=!0}C===v?h[I]===0&&(g=!0):(x.push(F),b.push(C),h[I]!==0&&(g=!0))}}}M=m}const A=2*b.filter(Boolean).length>=b.length,k=[];for(let w=0;w<x.length;w++){let m=x[w];b[w]!==A&&(m=Wr(m),g=!0);let d=!1;for(let U=0;U<k.length&&!d;U++)d=zr(k[U],m);d?g=!0:k.push(m)}if(!g)return null;const T=new Uint8Array(k.length),S=[];for(let w=0;w<k.length;w++){if(T[w])continue;T[w]=1;const m=[k[w]];for(;;){const d=m[m.length-1],U=d[d.length-2],C=d[d.length-1];if(m.length>1&&Math.hypot(U-m[0][0],C-m[0][1])<Cs){m[0][0]=U,m[0][1]=C;break}let v=-1,I=Cs;for(let R=0;R<k.length;R++){if(T[R])continue;const G=Math.hypot(k[R][0]-U,k[R][1]-C);G<I&&(v=R,I=G)}if(v<0)return null;T[v]=1,k[v][0]=U,k[v][1]=C,m.push(k[v])}S.push(m.map(xo))}return S}const Wn=1,zn=2,nc=3,Zn=4,sc=5,ec=6,Ls=7,pt=[0,0],Zt=[0,0];function oc(e,t){return Math.trunc(3+2.875*e/(t-1)-1.4375+.5)-3}function ic(e,t,n,s,o){return e*n+t*s<=0||Math.abs(e*s-t*n)>o}function rc(e){const t=Number(e.v&1n);return e.v>>=1n,t}function cc(e){const t=Number(e.v%3n);return e.v/=3n,t}function Ao(e){return[ec,sc,nc][cc(e)]}function Sn(e,t){const n=e.v<<1+rc(t);e.v=(n|n>>3)&Ls}function ac(e,t,n){const s=e.v&n;s===Wn||s===zn||s===Zn?e.v=s^Ls:Sn(e,t)}function lc(e,t,n=0n){const s=Math.sin(t),o={v:Ao({v:n})},i={v:n};i.v=n,o.v=Ao(i);const r=[];for(const c of e.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,f=l>0?pt[1]/l:0;for(let u=0;u<c.length;u++){const p=c[u];p.direction(0,Zt);const _=Math.sqrt(Zt[0]*Zt[0]+Zt[1]*Zt[1]),y=_>0?Zt[0]/_:0,g=_>0?Zt[1]/_:0;ic(h,f,y,g,s)&&r.push(u),p.direction(1,pt);const x=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]);h=x>0?pt[0]/x:0,f=x>0?pt[1]/x:0}if(r.length===0){Sn(o,i);for(const u of c)u.color=o.v}else if(r.length===1){const u=[0,Ls,0];Sn(o,i),u[0]=o.v,Sn(o,i),u[2]=o.v;const p=r[0],_=c.length;if(_>=3)for(let y=0;y<_;y++){const g=oc(y,_);c[(p+y)%_].color=u[1+g]}else if(_>=1){const y=[null,null,null,null,null,null,null],g=c[0].splitInThirds();if(y[0+3*p]=g[0],y[1+3*p]=g[1],y[2+3*p]=g[2],_>=2){const x=c[1].splitInThirds();y[3-3*p]=x[0],y[4-3*p]=x[1],y[5-3*p]=x[2],y[0].color=y[1].color=u[0],y[2].color=y[3].color=u[1],y[4].color=y[5].color=u[2]}else y[0].color=u[0],y[1].color=u[1],y[2].color=u[2];c.length=0;for(const x of y)x!==null&&c.push(x)}}else{const u=r.length;let p=0;const _=r[0],y=c.length;Sn(o,i);const g=o.v;for(let x=0;x<y;x++){const b=(_+x)%y;p+1<u&&r[p+1]===b&&(++p,ac(o,i,p===u-1?g:0)),c[b].color=o.v}}}}const j=Number.MAX_VALUE,q=[0,0],Mt=[0,0];let ko=0,nt=new Float64Array(0),it=new Float64Array(0),N=new Float64Array(0),$=new Float64Array(0),rt=new Int32Array(0),ct=new Float64Array(0),rn=new Float64Array(0),cn=new Float64Array(0),an=new Float64Array(0),Qt=new Int32Array(0);const st=[0,0];let Uo=0,Ps=new Float64Array(0),Fs=new Float64Array(0),qs=new Float64Array(0),Os=new Float64Array(0),Gs=new Float64Array(0),Ns=new Float64Array(0),$s=new Float64Array(0),Bs=new Float64Array(0),Ys=new Float64Array(0),Hs=new Float64Array(0),Xs=new Float64Array(0),Ks=new Float64Array(0),To=0,vn=new Int32Array(0);function hc(e){const t=e.length;if(t===0)return 0;let n=0;if(t===1){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.3333333333333333,st);const i=st[0],r=st[1];e[0].point(.6666666666666666,st);const c=st[0],a=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*o-a*s}else if(t===2){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.5,st);const i=st[0],r=st[1];e[1].point(0,st);const c=st[0],a=st[1];e[1].point(.5,st);const l=st[0],h=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*h-a*l,n+=l*o-h*s}else{const s=e[t-1];let o=s.p0x,i=s.p0y;for(let r=0;r<t;r++){const c=e[r].p0x,a=e[r].p0y;n+=o*a-i*c,o=c,i=a}}return n>0?-1:n<0?1:0}function fc(e,t,n,s,o,i,r){const c=r[e][t];let a=n;if(i<0){c.direction(0,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(0,Mt);const u=s-Mt[0],p=o-Mt[1];if(u*h+p*f<0){const y=u*f-p*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}if(i>1){c.direction(1,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(1,Mt);const u=s-Mt[0],p=o-Mt[1];if(u*h+p*f>0){const y=u*f-p*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}return a}function mt(e,t,n,s,o,i,r,c,a){let l=e<0?t:n;if(o>=0){const h=fc(s,o,e,r,c,i,a);Math.abs(h)<Math.abs(l)&&(l=h)}return l}function Tt(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function uc(e,t,n,s,o,i,r,c){if(c.length!==t*n*3)throw new Error(`generateMSDF: out.length ${c.length} !== ${t*n*3}`);const a=e.contours,l=a.length;if(l===0){c.fill(0);return}const h=s/r;Qt.length<l&&(Qt=new Int32Array(l));for(let p=0;p<l;p++)Qt[p]=hc(a[p]);To<l+1&&(vn=new Int32Array(l+1),To=l+1);let f=0;for(let p=0;p<l;p++)vn[p]=f,f+=a[p].length;vn[l]=f,Uo<f&&(Ps=new Float64Array(f),Fs=new Float64Array(f),qs=new Float64Array(f),Os=new Float64Array(f),Gs=new Float64Array(f),Ns=new Float64Array(f),$s=new Float64Array(f),Bs=new Float64Array(f),Ys=new Float64Array(f),Hs=new Float64Array(f),Xs=new Float64Array(f),Ks=new Float64Array(f),Uo=f);for(let p=0;p<l;p++){const _=a[p],y=_.length,g=vn[p];for(let x=0;x<y;x++){const b=_[x],M=_[(x+y-1)%y],A=_[(x+1)%y],k=g+x;b.point(0,Mt),Ps[k]=Mt[0],Fs[k]=Mt[1],b.point(1,Mt),qs[k]=Mt[0],Os[k]=Mt[1],b.direction(0,q);let T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const S=T>0?q[0]/T:0,w=T>0?q[1]/T:0;Gs[k]=S,Ns[k]=w,b.direction(1,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const m=T>0?q[0]/T:0,d=T>0?q[1]/T:0;$s[k]=m,Bs[k]=d,M.direction(1,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const U=T>0?q[0]/T:0,C=T>0?q[1]/T:0;A.direction(0,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const v=T>0?q[0]/T:0,I=T>0?q[1]/T:0,R=U+S,G=C+w,F=Math.sqrt(R*R+G*G);Ys[k]=F>0?R/F:0,Hs[k]=F>0?G/F:0;const X=m+v,H=d+I,V=Math.sqrt(X*X+H*H);Xs[k]=V>0?-(X/V):0,Ks[k]=V>0?-(H/V):0}}if(ko<l){const p=l*3;nt=new Float64Array(p),it=new Float64Array(p),N=new Float64Array(p),$=new Float64Array(p),rt=new Int32Array(p),ct=new Float64Array(p),rn=new Float64Array(l),cn=new Float64Array(l),an=new Float64Array(l),ko=l}const u={distance:0,dot:0,param:0};for(let p=0;p<n;p++)for(let _=0;_<t;_++){const y=(_+.5)/s-o,g=(p+.5)/s-i;for(let P=0;P<l;P++){const D=a[P],yt=D.length,E=P*3,B=vn[P];nt[E]=nt[E+1]=nt[E+2]=-j,it[E]=it[E+1]=it[E+2]=0,N[E]=N[E+1]=N[E+2]=-j,$[E]=$[E+1]=$[E+2]=j,rt[E]=rt[E+1]=rt[E+2]=-1,ct[E]=ct[E+1]=ct[E+2]=0;for(let Y=0;Y<yt;Y++){const W=D[Y],ge=W.color,xe=(ge&Wn)!==0,de=(ge&zn)!==0,Me=(ge&Zn)!==0;W.signedDistance(y,g,u);const ys=u.distance,hn=u.dot,me=u.param,Kt=Math.abs(ys);if(xe){const Pt=Math.abs(nt[E]);(Kt<Pt||Kt===Pt&&hn<it[E])&&(nt[E]=ys,it[E]=hn,rt[E]=Y,ct[E]=me)}if(de){const Pt=Math.abs(nt[E+1]);(Kt<Pt||Kt===Pt&&hn<it[E+1])&&(nt[E+1]=ys,it[E+1]=hn,rt[E+1]=Y,ct[E+1]=me)}if(Me){const Pt=Math.abs(nt[E+2]);(Kt<Pt||Kt===Pt&&hn<it[E+2])&&(nt[E+2]=ys,it[E+2]=hn,rt[E+2]=Y,ct[E+2]=me)}const At=B+Y,be=y-Ps[At],we=g-Fs[At],Ae=y-qs[At],ke=g-Os[At],xi=Gs[At],di=Ns[At],Mi=$s[At],mi=Bs[At],Nc=be*Ys[At]+we*Hs[At],$c=Ae*Xs[At]+ke*Ks[At];if(Nc>0&&-(be*xi+we*di)>0){const O=be*di-we*xi;Math.abs(O)<Kt&&(xe&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),de&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),Me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}if($c>0&&Ae*Mi+ke*mi>0){const O=Ae*mi-ke*Mi;Math.abs(O)<Kt&&(xe&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),de&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),Me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}}rn[P]=mt(nt[E],N[E],$[E],P,rt[E],ct[E],y,g,a),cn[P]=mt(nt[E+1],N[E+1],$[E+1],P,rt[E+1],ct[E+1],y,g,a),an[P]=mt(nt[E+2],N[E+2],$[E+2],P,rt[E+2],ct[E+2],y,g,a)}let x=-j,b=0,M=-j,A=j,k=-1,T=-1,S=0,w=-j,m=0,d=-j,U=j,C=-1,v=-1,I=0,R=-j,G=0,F=-j,X=j,H=-1,V=-1,et=0,z=-j,Gt=0,_t=-j,Xt=j,Nt=-1,Yo=-1,Ho=0,as=-j,Xo=0,ne=-j,se=j,Ko=-1,jo=-1,Vo=0,ls=-j,Wo=0,ee=-j,oe=j,zo=-1,Zo=-1,Qo=0,hs=-j,Jo=0,ie=-j,re=j,ti=-1,ni=-1,si=0,fs=-j,ei=0,ce=-j,ae=j,oi=-1,ii=-1,ri=0,us=-j,ci=0,le=-j,he=j,ai=-1,li=-1,hi=0;for(let P=0;P<l;P++){const D=P*3,yt=Qt[P],E=Tt(rn[P],cn[P],an[P]);{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(x)||W===Math.abs(x)&&Y<b)&&(x=B,b=Y,k=P,T=rt[D],S=ct[D]),N[D]>M&&(M=N[D]),$[D]<A&&(A=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(w)||W===Math.abs(w)&&Y<m)&&(w=B,m=Y,C=P,v=rt[D+1],I=ct[D+1]),N[D+1]>d&&(d=N[D+1]),$[D+1]<U&&(U=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(R)||W===Math.abs(R)&&Y<G)&&(R=B,G=Y,H=P,V=rt[D+2],et=ct[D+2]),N[D+2]>F&&(F=N[D+2]),$[D+2]<X&&(X=$[D+2])}if(yt>0&&E>=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(z)||W===Math.abs(z)&&Y<Gt)&&(z=B,Gt=Y,Nt=P,Yo=rt[D],Ho=ct[D]),N[D]>_t&&(_t=N[D]),$[D]<Xt&&(Xt=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(as)||W===Math.abs(as)&&Y<Xo)&&(as=B,Xo=Y,Ko=P,jo=rt[D+1],Vo=ct[D+1]),N[D+1]>ne&&(ne=N[D+1]),$[D+1]<se&&(se=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(ls)||W===Math.abs(ls)&&Y<Wo)&&(ls=B,Wo=Y,zo=P,Zo=rt[D+2],Qo=ct[D+2]),N[D+2]>ee&&(ee=N[D+2]),$[D+2]<oe&&(oe=$[D+2])}}if(yt<0&&E<=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(hs)||W===Math.abs(hs)&&Y<Jo)&&(hs=B,Jo=Y,ti=P,ni=rt[D],si=ct[D]),N[D]>ie&&(ie=N[D]),$[D]<re&&(re=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(fs)||W===Math.abs(fs)&&Y<ei)&&(fs=B,ei=Y,oi=P,ii=rt[D+1],ri=ct[D+1]),N[D+1]>ce&&(ce=N[D+1]),$[D+1]<ae&&(ae=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(us)||W===Math.abs(us)&&Y<ci)&&(us=B,ci=Y,ai=P,li=rt[D+2],hi=ct[D+2]),N[D+2]>le&&(le=N[D+2]),$[D+2]<he&&(he=$[D+2])}}}const fe=mt(x,M,A,k,T,S,y,g,a),ue=mt(w,d,U,C,v,I,y,g,a),pe=mt(R,F,X,H,V,et,y,g,a),Gc=Tt(fe,ue,pe),fi=mt(z,_t,Xt,Nt,Yo,Ho,y,g,a),ui=mt(as,ne,se,Ko,jo,Vo,y,g,a),pi=mt(ls,ee,oe,zo,Zo,Qo,y,g,a),ps=Tt(fi,ui,pi),_i=mt(hs,ie,re,ti,ni,si,y,g,a),yi=mt(fs,ce,ae,oi,ii,ri,y,g,a),gi=mt(us,le,he,ai,li,hi,y,g,a),_s=Tt(_i,yi,gi);let St,vt,Ct,_e=0;if(ps>=0&&Math.abs(ps)<=Math.abs(_s)){St=fi,vt=ui,Ct=pi,_e=1;for(let P=0;P<l;P++)if(Qt[P]>0){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E);Math.abs(B)<Math.abs(_s)&&B>Tt(St,vt,Ct)&&(St=D,vt=yt,Ct=E)}}else if(_s<=0&&Math.abs(_s)<Math.abs(ps)){St=_i,vt=yi,Ct=gi,_e=-1;for(let P=0;P<l;P++)if(Qt[P]<0){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E);Math.abs(B)<Math.abs(ps)&&B<Tt(St,vt,Ct)&&(St=D,vt=yt,Ct=E)}}else{const P=(p*t+_)*3;c[P+0]=fe*h+.5,c[P+1]=ue*h+.5,c[P+2]=pe*h+.5;continue}for(let P=0;P<l;P++)if(Qt[P]!==_e){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E),Y=Tt(St,vt,Ct);B*Y>=0&&Math.abs(B)<Math.abs(Y)&&(St=D,vt=yt,Ct=E)}Tt(St,vt,Ct)===Gc&&(St=fe,vt=ue,Ct=pe);const ye=(p*t+_)*3;c[ye+0]=St*h+.5,c[ye+1]=vt*h+.5,c[ye+2]=Ct*h+.5}}const So=0,pc=1,_c=2,yc=3;function gc(e,t){switch(t){case So:return e!==0;case pc:return(e&1)!==0;case _c:return e>0;case yc:return e<0}return!1}class xc{constructor(){this._intersections=[],this._lastIndex=0}setIntersections(t){if(this._intersections=t,this._lastIndex=0,t.length>0){t.sort((s,o)=>ut(s.x-o.x));let n=0;for(let s=0;s<t.length;s++)n+=t[s].direction,t[s].direction=n}}_moveTo(t){const n=this._intersections.length;if(n===0)return-1;let s=this._lastIndex;if(t<this._intersections[s].x)do{if(s===0)return this._lastIndex=0,-1;--s}while(t<this._intersections[s].x);else for(;s<n-1&&t>=this._intersections[s+1].x;)++s;return this._lastIndex=s,s}sumIntersections(t){const n=this._moveTo(t);return n>=0?this._intersections[n].direction:0}filled(t,n){return gc(this.sumIntersections(t),n)}}const vo=[0,0,0],Co=[0,0,0];function dc(e,t,n){const s=[];for(const o of e.contours)for(const i of o){const r=i.scanlineIntersections(t,vo,Co);for(let c=0;c<r;c++)s.push({x:vo[c],direction:Co[c]})}n.setIntersections(s)}const ln=2,Eo=1,js=1.001,Mc=1.1111111111111112,Qn=.01;function mc(e,t,n,s,o,i,r){if(n===0||s===0)return;const c=new xc,a=new Int8Array(n*s);for(let l=0;l<s;l++){const h=(l+.5)/o-r;dc(t,h,c);for(let f=0;f<n;f++){const u=(f+.5)/o-i,p=c.filled(u,So),_=(l*n+f)*3,y=e[_],g=e[_+1],x=e[_+2],b=ft(y,g,x),M=l*n+f;b===.5?a[M]=0:b>.5!==p?(e[_]=1-y,e[_+1]=1-g,e[_+2]=1-x,a[M]=-1):a[M]=1}}for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h;if(a[f]!==0)continue;let u=0;if(h>0&&(u+=a[f-1]),h<n-1&&(u+=a[f+1]),l>0&&(u+=a[f-n]),l<s-1&&(u+=a[f+n]),u<0){const p=(l*n+h)*3;e[p]=1-e[p],e[p+1]=1-e[p+1],e[p+2]=1-e[p+2]}}}const Vs=[0,0];function bc(e,t,n,s,o,i,r,c){const a=new Uint8Array(n*s);wc(a,t,n,s,o,i,r),Ac(a,e,n,s,o,c),Sc(a,e,n,s,c,Mc),vc(a,e,n,s)}function wc(e,t,n,s,o,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,Vs);const f=o*(Vs[0]+i),u=o*(Vs[1]+r),p=Math.floor(f-.5)|0,_=Math.floor(u-.5)|0,y=p+1,g=_+1;p<n&&_<s&&y>=0&&g>=0&&(p>=0&&_>=0&&(e[_*n+p]|=ln),y<n&&_>=0&&(e[_*n+y]|=ln),p>=0&&g<s&&(e[g*n+p]|=ln),y<n&&g<s&&(e[g*n+y]|=ln))}a=l}}}function Jn(e,t,n){let s=0;for(let o=0;o<3;o++){const i=e[t+o],r=e[n+o],c=i-r;if(c===0)continue;const a=(i-.5)/c;if(a>0&&a<1){const l=1-a,h=l*e[t]+a*e[n],f=l*e[t+1]+a*e[n+1],u=l*e[t+2]+a*e[n+2],p=o===0?h:o===1?f:u;ft(h,f,u)===p&&(s|=o===0?Wn:o===1?zn:Zn)}}return s}function Ht(e,t,n,s,o,i){(i&Wn&&n[s]!==o||i&zn&&n[s+1]!==o||i&Zn&&n[s+2]!==o)&&(e[t]|=ln)}function Ac(e,t,n,s,o,i){const r=js/i,c=js/i,a=js*Math.SQRT2/i;for(let l=0;l<s;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,u=f+3,p=ft(t[f],t[f+1],t[f+2]),_=ft(t[u],t[u+1],t[u+2]);if(Math.abs(p-.5)+Math.abs(_-.5)<r){const y=Jn(t,f,u);Ht(e,l*n+h,t,f,p,y),Ht(e,l*n+h+1,t,u,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n;h++){const f=(l*n+h)*3,u=((l+1)*n+h)*3,p=ft(t[f],t[f+1],t[f+2]),_=ft(t[u],t[u+1],t[u+2]);if(Math.abs(p-.5)+Math.abs(_-.5)<c){const y=Jn(t,f,u);Ht(e,l*n+h,t,f,p,y),Ht(e,(l+1)*n+h,t,u,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,u=(l*n+h+1)*3,p=((l+1)*n+h)*3,_=((l+1)*n+h+1)*3,y=ft(t[f],t[f+1],t[f+2]),g=ft(t[u],t[u+1],t[u+2]),x=ft(t[p],t[p+1],t[p+2]),b=ft(t[_],t[_+1],t[_+2]);if(Math.abs(y-.5)+Math.abs(b-.5)<a){const M=Jn(t,f,_);Ht(e,l*n+h,t,f,y,M),Ht(e,(l+1)*n+h+1,t,_,b,M)}if(Math.abs(g-.5)+Math.abs(x-.5)<a){const M=Jn(t,u,p);Ht(e,l*n+h+1,t,u,g,M),Ht(e,(l+1)*n+h,t,p,x,M)}}}function kc(e,t,n){const s=t<e?t:e,o=e<t?t:e,i=n<o?n:o;return s<i?i:s}function Uc(e,t,n,s){return ft(e[t]+s*(e[n]-e[t]),e[t+1]+s*(e[n+1]-e[t+1]),e[t+2]+s*(e[n+2]-e[t+2]))}function Ws(e,t,n,s){return kc(Math.fround(s*(s*n[0]+t[0])+e[0]),Math.fround(s*(s*n[1]+t[1])+e[1]),Math.fround(s*(s*n[2]+t[2])+e[2]))}const Jt=[0,0,0],Lt=[0,0,0],zs=[0,0,0],bt=[0,0,0],Io=1,Do=2;function Zs(e,t,n,s,o,i,r,c){if(s>.5&&o>.5&&i<=.5||s<.5&&o<.5&&i>=.5||!c&&Tc(s,o,i)!==i){const a=(n-e)*r,l=(t-n)*r;return i>=s-a&&i<=s+a&&i>=o-l&&i<=o+l?Io:Io|Do}return 0}function Ro(e){return(e&Do)!==0}function Tc(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function ts(e,t,n,s,o,i){const r=ft(e[n],e[n+1],e[n+2]);if(Math.abs(s-.5)<Math.abs(r-.5))return!1;for(let c=0;c<3;c++){const a=e[t+c]-e[t+(c+1)%3],l=e[n+c]-e[n+(c+1)%3],h=a-l;if(h===0)continue;const f=a/h;if(f>Qn&&f<1-Qn){const u=Uc(e,t,n,f),p=Zs(0,1,f,s,r,u,o,i);if(Ro(p))return!0}}return!1}function Lo(e,t,n,s,o,i,r,c,a){if(!(a>0&&a<1))return 0;const l=a>r?0:a,h=a>r?a:1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const f=a>r?n:Ws(bt,Jt,Lt,a);bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const u=a>r?Ws(bt,Jt,Lt,a):s;return Zs(l,h,r,f,u,c,o,i)}function ns(e,t,n,s,o,i,r,c,a){if(!(r>Qn&&r<1-Qn))return!1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const l=Ws(bt,Jt,Lt,r);let h=Zs(0,1,r,n,s,l,o,i);return h|=Lo(e,t,n,s,o,i,r,l,c),h|=Lo(e,t,n,s,o,i,r,l,a),Ro(h)}function Qs(e,t,n,s,o,i,r,c,a,l,h,f,u){const p=Math.fround(e[t+l]-e[t+h]),_=Math.fround(Math.fround(e[n+l]-e[n+h])+Math.fround(e[s+l]-e[s+h])),y=Math.fround(e[o+l]-e[o+h]),g=Math.fround(Math.fround(y-_)+p),x=Math.fround(Math.fround(_-p)-p),b=p;if(g===0||Math.abs(x)>1e12*Math.abs(g)){if(x!==0){const A=-b/x;if(ns(e,t,i,r,c,a,A,f,u))return!0}return!1}const M=x*x-4*g*b;if(M>0){const A=Math.sqrt(M),k=(-x+A)/(2*g);if(ns(e,t,i,r,c,a,k,f,u))return!0;const T=(-x-A)/(2*g);if(ns(e,t,i,r,c,a,T,f,u))return!0}else if(M===0){const A=-x/(2*g);if(ns(e,t,i,r,c,a,A,f,u))return!0}return!1}function ss(e,t,n,s,o,i,r,c){const a=ft(e[o],e[o+1],e[o+2]);if(Math.abs(i-.5)<Math.abs(a-.5))return!1;for(let u=0;u<3;u++)zs[u]=Math.fround(Math.fround(e[t+u]-e[n+u])-e[s+u]),Jt[u]=Math.fround(-e[t+u]-zs[u]),Lt[u]=Math.fround(e[o+u]+zs[u]);const l=Lt[0]!==0?-.5*Jt[0]/Lt[0]:-1,h=Lt[1]!==0?-.5*Jt[1]/Lt[1]:-1,f=Lt[2]!==0?-.5*Jt[2]/Lt[2]:-1;return!!(Qs(e,t,n,s,o,i,a,r,c,0,1,l,h)||Qs(e,t,n,s,o,i,a,r,c,1,2,h,f)||Qs(e,t,n,s,o,i,a,r,c,2,0,f,l))}function Sc(e,t,n,s,o,i){const r=i/o,c=i/o,a=i*Math.SQRT2/o;for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h,u=f*3,p=ft(t[u],t[u+1],t[u+2]),_=(e[f]&ln)!==0,y=h>0,g=h<n-1,x=l>0,b=l<s-1,M=y?(f-1)*3:-1,A=g?(f+1)*3:-1,k=x?(f-n)*3:-1,T=b?(f+n)*3:-1;let S=!1;if(y&&ts(t,u,M,p,r,_)&&(S=!0),!S&&x&&ts(t,u,k,p,c,_)&&(S=!0),!S&&g&&ts(t,u,A,p,r,_)&&(S=!0),!S&&b&&ts(t,u,T,p,c,_)&&(S=!0),!S&&y&&x){const w=(f-n-1)*3;ss(t,u,M,k,w,p,a,_)&&(S=!0)}if(!S&&g&&x){const w=(f-n+1)*3;ss(t,u,A,k,w,p,a,_)&&(S=!0)}if(!S&&y&&b){const w=(f+n-1)*3;ss(t,u,M,T,w,p,a,_)&&(S=!0)}if(!S&&g&&b){const w=(f+n+1)*3;ss(t,u,A,T,w,p,a,_)&&(S=!0)}S&&(e[f]|=Eo)}}function vc(e,t,n,s){const o=n*s;for(let i=0;i<o;i++)if(e[i]&Eo){const r=i*3,c=ft(t[r],t[r+1],t[r+2]);t[r]=c,t[r+1]=c,t[r+2]=c}}function ft(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}const Cc=3,Ec=0n,Po=16;function Fo(e,t,n,s=!0){if(s&&Jr(e),e.contours.length===0)return null;const o=es(e),i=t,r=n,c=Math.max(1,Math.ceil((o.maxX-o.minX)*i))+2*r,a=Math.max(1,Math.ceil((o.maxY-o.minY)*i))+2*r,l=r/i-o.minX,h=r/i-o.minY;$r(e),lc(e,Cc,Ec);const f=new Float32Array(c*a*3);return uc(e,c,a,i,l,h,r,f),mc(f,e,c,a,i,l,h),bc(f,e,c,a,i,l,h,r),{msdf:f,w:c,h:a,planeLeft:-l,planeBottom:-h,planeRight:c/i-l,planeTop:a/i-h}}const Js=[0,0];function es(e){let t=1/0,n=1/0,s=-1/0,o=-1/0;for(const i of e.contours)for(const r of i)for(let c=0;c<=Po;c++){r.point(c/Po,Js);const a=Js[0],l=Js[1];a<t&&(t=a),l<n&&(n=l),a>s&&(s=a),l>o&&(o=l)}return{minX:t,minY:n,maxX:s,maxY:o}}function Z(e,t){var n;return(n=new RegExp(`\\s${t}\\s*=\\s*(["'])([\\s\\S]*?)\\1`).exec(e))==null?void 0:n[2]}function os(e,t,n){const s=new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"g"),o=c=>{var a,l;return(l=(a=[...c.matchAll(s)].pop())==null?void 0:a[1])==null?void 0:l.trim()},i=Z(e,"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 o(Z(e,"style")??"")??o(r)??Z(e,t)}function is(e,t){return e===void 0?t:parseFloat(e)/(e.trim().endsWith("%")?100:1)}function tn(e,t){return e===void 0?0:parseFloat(e)*(e.trim().endsWith("%")?t/100:1)}function Ic(e){const{layers:t,width:n}=qo(e);return{shape:{contours:t.flatMap(o=>o.shape.contours),inverseYAxis:!1},width:n}}function qo(e){var k,T;e=e.replace(/<!--[\s\S]*?-->/g,"");const t=((k=/<svg\b[^>]*>/.exec(e))==null?void 0:k[0])??"",n=(Z(t,"viewBox")??`0 0 ${Z(t,"width")} ${Z(t,"height")}`).trim().split(/[\s,]+/).map(parseFloat),[s=0,o=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,s,o+r],l=[1,0,0,-1,-s,o+r],h=i/r,f=[];i>0&&rs(`M${s} ${o}h${i}v${r}h${-i}z`,l,f),Yn({contours:f},r);const u=new Map,p=/<(linear|radial)Gradient\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1Gradient>)/g;for(const[,S="",w="",m=""]of e.matchAll(p))u.set(Z(w,"id")??"",[S,w,m]);const _=new Map;for(const[,S="",w=""]of e.matchAll(/<clipPath\b([^>]*?)(?:\/>|>([\s\S]*?)<\/clipPath>)/g))_.set(Z(S,"id")??"",[S,w]);const y=new Map;for(const[,S="",w=""]of e.matchAll(Oo)){const m=Z(w,"id");m!==void 0&&y.set(m,[S,w])}const g=[];for(const[,S=""]of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const[,w="",m=""]of S.matchAll(/([^{}]+)\{([^}]*)\}/g))for(const d of w.split(",")){const U=(T=/^\s*\.([\w-]+)\s*$/.exec(d))==null?void 0:T[1];U&&g.push([U,m])}const x=[],b=[],M=[{m:[1,0,0,1,0,0],fill:"black",rule:"nonzero",fillOpacity:1,opacity:1,clips:[],group:-1}];let A=0;for(const[,S,w="",m="",d]of e.matchAll(/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g)){if(A>0||/^(defs|clipPath|mask|symbol|pattern|marker|style)$/.test(w)){S?A--:d||A++;continue}if(S){M.pop();continue}const U=M[M.length-1],C=_t=>os(m,_t,g),v=is(C("opacity"),1),I=No(w,m,c),R={m:wt(U.m,Cn(Z(m,"transform")??"")),fill:C("fill")??U.fill,rule:C("fill-rule")??U.rule,fillOpacity:is(C("fill-opacity"),U.fillOpacity),opacity:U.opacity*v,clips:U.clips,group:U.group};I===void 0&&v<1&&!d&&(R.group=b.push({members:[],parent:U.group,translucent:!1})-1);const G=_.get(Go(C("clip-path")));if(G&&Z(G[0],"clipPathUnits")!=="objectBoundingBox"&&(R.clips=[...U.clips,Dc(G,y,g,wt(l,R.m),c)]),d||M.push(R),I===void 0||R.fill==="none")continue;const F=[];rs(I,wt(l,R.m),F),R.rule==="evenodd"&&yo(F);const X={contours:F,inverseYAxis:!1};Yn(X,r);const H=u.get(Go(R.fill)),V=wt($o(R.m),a),et=H?Rc(H,u,g,V,I,c):null;for(const _t of R.clips)wo(X,_t);const z=es(X);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)&&f.length>0&&wo(X,[f]),X.contours.length===0))){if(R.group>=0){const _t=b[R.group];_t.members.push(x.length);const Xt=et?et.stops.some(Nt=>Nt.opacity<1):!1;(v<1||R.fillOpacity<1||Xt)&&(_t.translucent=!0);for(let Nt=_t.parent;Nt>=0;Nt=b[Nt].parent)b[Nt].translucent=!0}x.push({shape:X,color:R.fill,opacity:R.opacity*R.fillOpacity,gradient:et})}}for(const S of b){if(S.translucent||S.members.length<2)continue;const w=S.members.map(m=>es(x[m].shape));for(let m=0;m<S.members.length-1;m++){const d=w[m],U=[];for(let C=m+1;C<S.members.length;C++){const v=w[C];v.minX<d.maxX&&d.minX<v.maxX&&v.minY<d.maxY&&d.minY<v.maxY&&U.push(x[S.members[C]].shape.contours)}tc(x[S.members[m]].shape,U)}}return{layers:x.filter(S=>S.shape.contours.length>0),width:i/r}}const Oo=/<([\w:-]+)\b([^>]*?)\/?>/g;function Go(e){var t;return((t=/url\(\s*['"]?#([^)'"\s]+)/.exec(e??""))==null?void 0:t[1])??""}function Dc([e="",t=""],n,s,o,i){var h;const[r=0,c=1]=i,a=[],l=wt(o,Cn(Z(e,"transform")??""));for(const[,f="",u=""]of t.matchAll(Oo)){let p=[f,u],_=wt(l,Cn(Z(u,"transform")??""));if(f==="use"){const b=n.get(((h=Z(u,"(?:xlink:)?href"))==null?void 0:h.slice(1))??"");if(!b)continue;_=wt(_,[1,0,0,1,tn(Z(u,"x"),r),tn(Z(u,"y"),c)]),_=wt(_,Cn(Z(b[1],"transform")??"")),p=b}const y=No(p[0],p[1],i);if(y===void 0)continue;const g=[];rs(y,_,g),[p[1],u,e].map(b=>os(b,"clip-rule",s)).find(Boolean)==="evenodd"&&yo(g),Yn({contours:g},c),a.push(g)}return a}function No(e,t,[n=0,s=0]){const o=(u,p)=>tn(Z(t,u),p),[i,r,c,a]=[o("x",n),o("y",s),o("width",n),o("height",s)],[l,h,f]=[o("cx",n),o("cy",s),Math.hypot(n,s)/Math.SQRT2];switch(e){case"path":return Z(t,"d")??"";case"polygon":case"polyline":return`M${Z(t,"points")??"0 0"}`;case"circle":case"ellipse":{const[u,p]=e==="circle"?[o("r",f),o("r",f)]:[o("rx",n),o("ry",s)],_=`A${u} ${p} 0 1 0`;return`M${l-u} ${h}${_} ${l+u} ${h}${_} ${l-u} ${h}Z`}case"rect":{const[u,p]=[Z(t,"rx"),Z(t,"ry")],_=Math.min(u===void 0?tn(p,s):tn(u,n),c/2),y=Math.min(p===void 0?tn(u,n):tn(p,s),a/2),g=`A${_} ${y} 0 0 1`;return`M${i+_} ${r}H${i+c-_}${g} ${i+c} ${r+y}V${r+a-y}${g} ${i+c-_} ${r+a}H${i+_}${g} ${i} ${r+a-y}V${r+y}${g} ${i+_} ${r}Z`}default:return}}function Rc(e,t,n,s,o,[i=0,r=0]){var m;const c=[];for(let d=e;d&&!c.includes(d);)c.push(d),d=t.get(((m=Z(d[1]??"","(?:xlink:)?href"))==null?void 0:m.slice(1))??"");const a=d=>c.map(U=>Z(U[1]??"",d)).find(U=>U!==void 0),l=a("gradientUnits")==="userSpaceOnUse",h=(d,U,C)=>{const v=a(d)??U;return parseFloat(v)*(v.trim().endsWith("%")?(l?C:1)/100:1)};let f=Cn(a("gradientTransform")??"");if(!l){const d=[];rs(o,[1,0,0,1,0,0],d);const U=es({contours:d});f=wt([U.maxX-U.minX,0,0,U.maxY-U.minY,U.minX,U.minY],f)}const u=e[0]==="radial",[p,_]=[h("x1","0%",i),h("y1","0%",r)],[y,g]=[h("x2","100%",i)-p,h("y2","0%",r)-_],x=Math.hypot(i,r)/Math.SQRT2,[b,M,A]=[h("cx","50%",i),h("cy","50%",r),h("r","50%",x)],k=y*y+g*g||1,T=u?[1/A,0,0,1/A,-b/A,-M/A]:[y/k,0,g/k,0,-(p*y+_*g)/k,0],w=[...(c.map(d=>d[2]??"").find(d=>/<stop\b/.test(d))??"").matchAll(/<stop\b[^>]*>/g)].map(([d])=>({offset:is(Z(d,"offset"),0),color:os(d,"stop-color",n)??"black",opacity:is(os(d,"stop-opacity",n),1)}));return{radial:u,matrix:wt(T,wt($o(f),s)),stops:w}}function wt(e,t){const[n=0,s=0,o=0,i=0,r=0,c=0]=e,[a=0,l=0,h=0,f=0,u=0,p=0]=t;return[n*a+o*l,s*a+i*l,n*h+o*f,s*h+i*f,n*u+o*p+r,s*u+i*p+c]}function Lc([e=0,t=0,n=0,s=0,o=0,i=0],r,c){return[e*r+n*c+o,t*r+s*c+i]}function $o([e=0,t=0,n=0,s=0,o=0,i=0]){const r=e*s-t*n;return[s/r,-t/r,-n/r,e/r,(n*i-s*o)/r,(t*o-e*i)/r]}function Cn(e){let t=[1,0,0,1,0,0];for(const[,n,s=""]of e.matchAll(/(\w+)\s*\(([^)]*)\)/g)){const[o=0,i,r,c=0,a=0,l=0]=s.trim().split(/[\s,]+/).map(parseFloat),h=o*Math.PI/180,[f,u]=[Math.cos(h),Math.sin(h)],[p,_]=[i??0,r??0];t=wt(t,n==="matrix"?[o,i??0,r??0,c,a,l]:n==="translate"?[1,0,0,1,o,i??0]:n==="scale"?[o,0,0,i??o,0,0]:n==="rotate"?[f,u,-u,f,p-f*p+u*_,_-u*p-f*_]:n==="skewX"?[1,0,Math.tan(h),1,0,0]:[1,Math.tan(h),0,1,0,0])}return t}const te=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y;function rs(e,t,n){let s=0,o=0,i=0,r=0,c=0,a=0,l=0,h="",f="",u=[];const p=()=>{for(;s<e.length&&` \r
|
|
2
|
+
,`.includes(e[s]);)s++},_=()=>{p(),te.lastIndex=s;const b=te.exec(e);if(!b)throw new Error(`parseSvg: expected a number at ${s} in path "${e}"`);return s=te.lastIndex,parseFloat(b[0])},y=()=>(p(),e[s++]==="1"?1:0),g=(b,...M)=>{const A=[o,i,...M],k=[];for(let I=0;I<A.length;I+=2)k.push(...Lc(t,A[I],A[I+1]));const[T=0,S=0,w=0,m=0,d=0,U=0,C=0,v=0]=k;u.push(new tt(b,T,S,w,m,d,U,C,v)),o=M[M.length-2],i=M[M.length-1]},x=()=>{u.length>0&&((o!==r||i!==c)&&g(J,r,c),n.push(u),u=[]),o=r,i=c};for(p();s<e.length;p()){if(/[a-zA-Z]/.test(e[s]))h=e[s++];else if(!h)throw new Error(`parseSvg: expected a command at ${s} in path "${e}"`);const b=h.toUpperCase(),M=h===b?0:o,A=h===b?0:i,k=b==="S"&&"CS".includes(f)||b==="T"&&"QT".includes(f),T=k?2*o-a:o,S=k?2*i-l:i;switch(b){case"M":{const w=M+_(),m=A+_();x(),o=r=w,i=c=m,h=h==="M"?"L":"l";break}case"L":g(J,M+_(),A+_());break;case"H":g(J,M+_(),i);break;case"V":g(J,o,A+_());break;case"C":case"S":{const w=b==="C"?M+_():T,m=b==="C"?A+_():S;a=M+_(),l=A+_(),g(Et,w,m,a,l,M+_(),A+_());break}case"Q":case"T":a=b==="Q"?M+_():T,l=b==="Q"?A+_():S,g(ot,a,l,M+_(),A+_());break;case"A":{const w=_(),m=_(),d=_(),U=y(),C=y();Pc(g,o,i,w,m,d,U,C,M+_(),A+_());break}case"Z":x(),h="";break;default:throw new Error(`parseSvg: unknown path command "${h}"`)}f=b}x()}function Pc(e,t,n,s,o,i,r,c,a,l){if(t===a&&n===l)return;if(s=Math.abs(s),o=Math.abs(o),s===0||o===0)return e(J,a,l);const h=Math.cos(i*Math.PI/180),f=Math.sin(i*Math.PI/180),u=(t-a)/2,p=(n-l)/2,_=h*u+f*p,y=-f*u+h*p,g=_*_/(s*s)+y*y/(o*o);g>1&&(s*=Math.sqrt(g),o*=Math.sqrt(g));const x=s*s*y*y+o*o*_*_,b=(r===c?-1:1)*Math.sqrt(Math.max(0,(s*s*o*o-x)/x)),M=b*s*y/o,A=-b*o*_/s,k=h*M-f*A+(t+a)/2,T=f*M+h*A+(n+l)/2,S=Math.atan2((y-A)/o,(_-M)/s);let w=Math.atan2((-y-A)/o,(-_-M)/s)-S;c&&w<0?w+=2*Math.PI:!c&&w>0&&(w-=2*Math.PI);const m=Math.max(1,Math.ceil(Math.abs(w)/(Math.PI/2)-1e-9)),d=w/m,U=4/3*Math.tan(d/4),C=(I,R)=>k+s*I*h-o*R*f,v=(I,R)=>T+s*I*f+o*R*h;for(let I=0;I<m;I++){const R=Math.cos(S+I*d),G=Math.sin(S+I*d),F=Math.cos(S+(I+1)*d),X=Math.sin(S+(I+1)*d),H=I===m-1;e(Et,C(R-U*G,G+U*R),v(R-U*G,G+U*R),C(F+U*X,X-U*F),v(F+U*X,X-U*F),H?a:C(F,X),H?l:v(F,X))}}function Fc(e){let t=0,n=0;for(const c of e)t+=c.w*c.h,n=Math.max(n,c.w);e.sort((c,a)=>a.h-c.h);const o=[{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 e)for(let a=o.length-1;a>=0;a--){const l=o[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=o.pop();h&&a<o.length&&(o[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):(o.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 Bo=4,qc={x:0,y:0,w:0,h:0,advance:0,planeLeft:0,planeBottom:0,planeRight:0,planeTop:0};function cs(e){const t=e<0?0:e>1?1:e;return~Math.trunc(255.5-255*t)&255}class Oc{constructor(t,n={}){this._width=0,this._height=0,this._pixels=new Uint8Array(0),this._cache=new Map,this._byGid=[],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,s=>n.glyphId(s)))}glyph(t){return this.glyphs([t])[0]}glyphsByIndex(t){const n=[];let s=0;for(const o of t){const i=this._cache.get(o);if(i){n.push(i.glyph);continue}const r=this._generateForGlyphId(o);this._cache.set(o,r),this._byGid[o]=r.glyph,n.push(r.glyph),s++}return s>0&&this._repack(),n}glyphByIndex(t){return this.glyphsByIndex([t])[0]}shapes(t){const n=[];let s=0;for(const[o,i]of t){let r=this._cacheByKey.get(o);r||(r=this._generate(i,0),this._cacheByKey.set(o,r),s++),n.push(r.glyph)}return s>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(),s=n.metrics.unitsPerEm,o=n.shape(t);return Yn(o,s),this._generate(o,n.advance(t)/s)}_generate(t,n){const s=Fo(t,this._pxPerEm,this._pxrange);return{glyph:{x:0,y:0,w:s?s.w:0,h:s?s.h:0,advance:n,planeLeft:s?s.planeLeft:0,planeBottom:s?s.planeBottom:0,planeRight:s?s.planeRight:0,planeTop:s?s.planeTop:0},msdf:s?s.msdf:null}}layout(t){const n=this._requireFont(),s=Ar(n,t),o=L._gid,i=L._gp;let r=0;const c=this._byGid;for(let _=0;_<s;_++){const y=o[_];if(i[_]&un||c[y])continue;const g=this._generateForGlyphId(y);this._cache.set(y,g),c[y]=g.glyph,r++}r>0&&this._repack();const a=L._xa,l=L._xo,h=L._yo,f=n.metrics.unitsPerEm,u=[];let p=0;for(let _=0;_<s;_++){const y=i[_]&un?qc:c[o[_]];u.push({glyph:y,penX:(p+l[_])/f,penY:h[_]/f}),p+=a[_]}return{glyphs:u,widthEm:p/f}}layoutMultiline(t){const n=this._requireFont(),s=n.metrics.unitsPerEm,o=(n.metrics.ascender-n.metrics.descender+n.metrics.lineGap)/s,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]),f=-a*o;for(const u of l)r.push({glyph:u.glyph,penX:u.penX,penY:f+u.penY});h>c&&(c=h)}return{glyphs:r,widthEm:c,heightEm:i.length*o}}_repack(){const t=[];for(const o of[this._cache,this._cacheByKey])for(const{glyph:i,msdf:r}of o.values())r&&t.push({w:i.w+1,h:i.h+1,x:0,y:0,glyph:i,msdf:r});const{w:n,h:s}=Fc(t);this._width=n,this._height=s,this._pixels=new Uint8Array(n*s*Bo),this._floats&&(this._floats=new Float32Array(n*s*3));for(const o of t)o.glyph.x=o.x,o.glyph.y=o.y,this._blit(o.msdf,o.x,o.y,o.glyph.w,o.glyph.h)}_blit(t,n,s,o,i){var a;const r=this._width,c=this._pixels;for(let l=0;l<i;l++){const h=s+(i-1-l);(a=this._floats)==null||a.set(t.subarray(l*o*3,(l+1)*o*3),(h*r+n)*3);for(let f=0;f<o;f++){const u=(l*o+f)*3,p=(h*r+(n+f))*Bo;c[p]=cs(t[u]),c[p+1]=cs(t[u+1]),c[p+2]=cs(t[u+2]),c[p+3]=255}}}}return gt.Atlas=Oc,gt.CUBIC=Et,gt.EdgeSegment=tt,gt.Font=qr,gt.LINEAR=J,gt.QUADRATIC=ot,gt.generateShapeMSDF=Fo,gt.parseSvg=Ic,gt.parseSvgLayers=qo,gt.pixelFloatToByte=cs,Object.defineProperty(gt,Symbol.toStringTag,{value:"Module"}),gt})({});
|