modern-text 0.5.11 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -841,6 +841,7 @@ function highlight() {
841
841
  name: "highlight",
842
842
  paths,
843
843
  update: async (text) => {
844
+ clipRects.length = 0;
844
845
  paths.length = 0;
845
846
  let groups = [];
846
847
  let group;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(L,ot){typeof exports=="object"&&typeof module<"u"?ot(exports):typeof define=="function"&&define.amd?define(["exports"],ot):(L=typeof globalThis<"u"?globalThis:L||self,ot(L.modernText={}))})(this,function(L){"use strict";var ga=Object.defineProperty;var ya=(L,ot,$t)=>ot in L?ga(L,ot,{enumerable:!0,configurable:!0,writable:!0,value:$t}):L[ot]=$t;var B=(L,ot,$t)=>ya(L,typeof ot!="symbol"?ot+"":ot,$t);function ot(n,t,e){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:r,y0:s,x1:o,y1:i,stops:a}=un(t,e.left,e.top,e.width,e.height),l=n.createLinearGradient(r,s,o,i);return a.forEach(h=>l.addColorStop(h.offset,h.color)),l}return t}function $t(n,t,e){n!=null&&n.color&&(n.color=ot(e,n.color,t)),n!=null&&n.backgroundColor&&(n.backgroundColor=ot(e,n.backgroundColor,t)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=ot(e,n.textStrokeColor,t))}function un(n,t,e,r,s){var d;const o=((d=n.match(/linear-gradient\((.+)\)$/))==null?void 0:d[1])??"",i=o.split(",")[0],a=i.includes("deg")?i:"0deg",l=o.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),u=(Number(a.replace("deg",""))||0)*Math.PI/180,c=r*Math.sin(u),f=s*Math.cos(u);return{x0:t+r/2-c,y0:e+s/2+f,x1:t+r/2+c,y1:e+s/2-f,stops:Array.from(l).map(g=>{let m=g[2];return m.startsWith("(")?m=m.split(",").length>3?`rgba${m}`:`rgb${m}`:m=`#${m}`,{offset:Number(g[3].replace("%",""))/100,color:m}})}}function te(n){const{ctx:t,path:e,fontSize:r,clipRect:s}=n;t.save(),t.beginPath();const o=e.style,i={...o,fill:n.color??o.fill,stroke:n.textStrokeColor??o.stroke,strokeWidth:n.textStrokeWidth?n.textStrokeWidth*r:o.strokeWidth,shadowOffsetX:(n.shadowOffsetX??0)*r,shadowOffsetY:(n.shadowOffsetY??0)*r,shadowBlur:(n.shadowBlur??0)*r,shadowColor:n.shadowColor};s&&(t.rect(s.left,s.top,s.width,s.height),t.clip(),t.beginPath()),e.drawTo(t,i),t.restore()}function Lr(n,t,e){const{left:r,top:s,width:o,height:i}=e,a=n.canvas;a.dataset.viewBox=`${r} ${s} ${o} ${i}`,a.dataset.pixelRatio=String(t);const l=o,h=i;a.width=Math.max(1,Math.ceil(l*t)),a.height=Math.max(1,Math.ceil(h*t)),a.style.width=`${l}px`,a.style.height=`${h}px`,n.clearRect(0,0,a.width,a.height),n.scale(t,t),n.translate(-r,-s)}function Fr(n,t){const{paragraphs:e,computedStyle:r,glyphBox:s}=t;$t(r,s,n),e.forEach(o=>{$t(o.computedStyle,o.lineBox,n),o.fragments.forEach(i=>{$t(i.computedStyle,i.inlineBox,n)})})}var at=Uint8Array,Ct=Uint16Array,Qe=Int32Array,Ae=new at([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ie=new at([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Je=new at([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zr=function(n,t){for(var e=new Ct(31),r=0;r<31;++r)e[r]=t+=1<<n[r-1];for(var s=new Qe(e[30]),r=1;r<30;++r)for(var o=e[r];o<e[r+1];++o)s[o]=o-e[r]<<5|r;return{b:e,r:s}},Nr=zr(Ae,2),qr=Nr.b,tr=Nr.r;qr[28]=258,tr[258]=28;for(var Gr=zr(Ie,0),fn=Gr.b,Rr=Gr.r,er=new Ct(32768),X=0;X<32768;++X){var Gt=(X&43690)>>1|(X&21845)<<1;Gt=(Gt&52428)>>2|(Gt&13107)<<2,Gt=(Gt&61680)>>4|(Gt&3855)<<4,er[X]=((Gt&65280)>>8|(Gt&255)<<8)>>1}for(var Bt=function(n,t,e){for(var r=n.length,s=0,o=new Ct(t);s<r;++s)n[s]&&++o[n[s]-1];var i=new Ct(t);for(s=1;s<t;++s)i[s]=i[s-1]+o[s-1]<<1;var a;if(e){a=new Ct(1<<t);var l=15-t;for(s=0;s<r;++s)if(n[s])for(var h=s<<4|n[s],u=t-n[s],c=i[n[s]-1]++<<u,f=c|(1<<u)-1;c<=f;++c)a[er[c]>>l]=h}else for(a=new Ct(r),s=0;s<r;++s)n[s]&&(a[s]=er[i[n[s]-1]++]>>15-n[s]);return a},Rt=new at(288),X=0;X<144;++X)Rt[X]=8;for(var X=144;X<256;++X)Rt[X]=9;for(var X=256;X<280;++X)Rt[X]=7;for(var X=280;X<288;++X)Rt[X]=8;for(var ce=new at(32),X=0;X<32;++X)ce[X]=5;var pn=Bt(Rt,9,0),dn=Bt(Rt,9,1),gn=Bt(ce,5,0),yn=Bt(ce,5,1),rr=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},Tt=function(n,t,e){var r=t/8|0;return(n[r]|n[r+1]<<8)>>(t&7)&e},sr=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},nr=function(n){return(n+7)/8|0},Wr=function(n,t,e){return(e==null||e>n.length)&&(e=n.length),new at(n.subarray(t,e))},mn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ot=function(n,t,e){var r=new Error(t||mn[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,Ot),!e)throw r;return r},wn=function(n,t,e,r){var s=n.length,o=0;if(!s||t.f&&!t.l)return e||new at(0);var i=!e,a=i||t.i!=2,l=t.i;i&&(e=new at(s*3));var h=function(kt){var Lt=e.length;if(kt>Lt){var qt=new at(Math.max(Lt*2,kt));qt.set(e),e=qt}},u=t.f||0,c=t.p||0,f=t.b||0,d=t.l,g=t.d,m=t.m,p=t.n,C=s*8;do{if(!d){u=Tt(n,c,1);var S=Tt(n,c+1,3);if(c+=3,S)if(S==1)d=dn,g=yn,m=9,p=5;else if(S==2){var x=Tt(n,c,31)+257,T=Tt(n,c+10,15)+4,_=x+Tt(n,c+5,31)+1;c+=14;for(var O=new at(_),E=new at(19),N=0;N<T;++N)E[Je[N]]=Tt(n,c+N*3,7);c+=T*3;for(var M=rr(E),gt=(1<<M)-1,U=Bt(E,M,1),N=0;N<_;){var z=U[Tt(n,c,gt)];c+=z&15;var v=z>>4;if(v<16)O[N++]=v;else{var D=0,k=0;for(v==16?(k=3+Tt(n,c,3),c+=2,D=O[N-1]):v==17?(k=3+Tt(n,c,7),c+=3):v==18&&(k=11+Tt(n,c,127),c+=7);k--;)O[N++]=D}}var V=O.subarray(0,x),A=O.subarray(x);m=rr(V),p=rr(A),d=Bt(V,m,1),g=Bt(A,p,1)}else Ot(1);else{var v=nr(c)+4,P=n[v-4]|n[v-3]<<8,w=v+P;if(w>s){l&&Ot(0);break}a&&h(f+P),e.set(n.subarray(v,w),f),t.b=f+=P,t.p=c=w*8,t.f=u;continue}if(c>C){l&&Ot(0);break}}a&&h(f+131072);for(var bt=(1<<m)-1,W=(1<<p)-1,Y=c;;Y=c){var D=d[sr(n,c)&bt],G=D>>4;if(c+=D&15,c>C){l&&Ot(0);break}if(D||Ot(2),G<256)e[f++]=G;else if(G==256){Y=c,d=null;break}else{var j=G-254;if(G>264){var N=G-257,F=Ae[N];j=Tt(n,c,(1<<F)-1)+qr[N],c+=F}var Q=g[sr(n,c)&W],Z=Q>>4;Q||Ot(3),c+=Q&15;var A=fn[Z];if(Z>3){var F=Ie[Z];A+=sr(n,c)&(1<<F)-1,c+=F}if(c>C){l&&Ot(0);break}a&&h(f+131072);var rt=f+j;if(f<A){var Qt=o-A,Jt=Math.min(A,rt);for(Qt+f<0&&Ot(3);f<Jt;++f)e[f]=r[Qt+f]}for(;f<rt;++f)e[f]=e[f-A]}}t.l=d,t.p=Y,t.b=f,t.f=u,d&&(u=1,t.m=m,t.d=g,t.n=p)}while(!u);return f!=e.length&&i?Wr(e,0,f):e.subarray(0,f)},zt=function(n,t,e){e<<=t&7;var r=t/8|0;n[r]|=e,n[r+1]|=e>>8},ue=function(n,t,e){e<<=t&7;var r=t/8|0;n[r]|=e,n[r+1]|=e>>8,n[r+2]|=e>>16},ir=function(n,t){for(var e=[],r=0;r<n.length;++r)n[r]&&e.push({s:r,f:n[r]});var s=e.length,o=e.slice();if(!s)return{t:Hr,l:0};if(s==1){var i=new at(e[0].s+1);return i[e[0].s]=1,{t:i,l:1}}e.sort(function(w,x){return w.f-x.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,u=1,c=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=e[e[h].f<e[c].f?h++:c++],l=e[h!=u&&e[h].f<e[c].f?h++:c++],e[u++]={s:-1,f:a.f+l.f,l:a,r:l};for(var f=o[0].s,r=1;r<s;++r)o[r].s>f&&(f=o[r].s);var d=new Ct(f+1),g=or(e[u-1],d,0);if(g>t){var r=0,m=0,p=g-t,C=1<<p;for(o.sort(function(x,T){return d[T.s]-d[x.s]||x.f-T.f});r<s;++r){var S=o[r].s;if(d[S]>t)m+=C-(1<<g-d[S]),d[S]=t;else break}for(m>>=p;m>0;){var v=o[r].s;d[v]<t?m-=1<<t-d[v]++-1:++r}for(;r>=0&&m;--r){var P=o[r].s;d[P]==t&&(--d[P],++m)}g=t}return{t:new at(d),l:g}},or=function(n,t,e){return n.s==-1?Math.max(or(n.l,t,e+1),or(n.r,t,e+1)):t[n.s]=e},Vr=function(n){for(var t=n.length;t&&!n[--t];);for(var e=new Ct(++t),r=0,s=n[0],o=1,i=function(l){e[r++]=l},a=1;a<=t;++a)if(n[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=n[a]}return{c:e.subarray(0,r),n:t}},fe=function(n,t){for(var e=0,r=0;r<t.length;++r)e+=n[r]*t[r];return e},Xr=function(n,t,e){var r=e.length,s=nr(t+2);n[s]=r&255,n[s+1]=r>>8,n[s+2]=n[s]^255,n[s+3]=n[s+1]^255;for(var o=0;o<r;++o)n[s+o+4]=e[o];return(s+4+r)*8},jr=function(n,t,e,r,s,o,i,a,l,h,u){zt(t,u++,e),++s[256];for(var c=ir(s,15),f=c.t,d=c.l,g=ir(o,15),m=g.t,p=g.l,C=Vr(f),S=C.c,v=C.n,P=Vr(m),w=P.c,x=P.n,T=new Ct(19),_=0;_<S.length;++_)++T[S[_]&31];for(var _=0;_<w.length;++_)++T[w[_]&31];for(var O=ir(T,7),E=O.t,N=O.l,M=19;M>4&&!E[Je[M-1]];--M);var gt=h+5<<3,U=fe(s,Rt)+fe(o,ce)+i,z=fe(s,f)+fe(o,m)+i+14+3*M+fe(T,E)+2*T[16]+3*T[17]+7*T[18];if(l>=0&&gt<=U&&gt<=z)return Xr(t,u,n.subarray(l,l+h));var D,k,V,A;if(zt(t,u,1+(z<U)),u+=2,z<U){D=Bt(f,d,0),k=f,V=Bt(m,p,0),A=m;var bt=Bt(E,N,0);zt(t,u,v-257),zt(t,u+5,x-1),zt(t,u+10,M-4),u+=14;for(var _=0;_<M;++_)zt(t,u+3*_,E[Je[_]]);u+=3*M;for(var W=[S,w],Y=0;Y<2;++Y)for(var G=W[Y],_=0;_<G.length;++_){var j=G[_]&31;zt(t,u,bt[j]),u+=E[j],j>15&&(zt(t,u,G[_]>>5&127),u+=G[_]>>12)}}else D=pn,k=Rt,V=gn,A=ce;for(var _=0;_<a;++_){var F=r[_];if(F>255){var j=F>>18&31;ue(t,u,D[j+257]),u+=k[j+257],j>7&&(zt(t,u,F>>23&31),u+=Ae[j]);var Q=F&31;ue(t,u,V[Q]),u+=A[Q],Q>3&&(ue(t,u,F>>5&8191),u+=Ie[Q])}else ue(t,u,D[F]),u+=k[F]}return ue(t,u,D[256]),u+k[256]},xn=new Qe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hr=new at(0),vn=function(n,t,e,r,s,o){var i=o.z||n.length,a=new at(r+i+5*(1+Math.ceil(i/7e3))+s),l=a.subarray(r,a.length-s),h=o.l,u=(o.r||0)&7;if(t){u&&(l[0]=o.r>>3);for(var c=xn[t-1],f=c>>13,d=c&8191,g=(1<<e)-1,m=o.p||new Ct(32768),p=o.h||new Ct(g+1),C=Math.ceil(e/3),S=2*C,v=function(he){return(n[he]^n[he+1]<<C^n[he+2]<<S)&g},P=new Qe(25e3),w=new Ct(288),x=new Ct(32),T=0,_=0,O=o.i||0,E=0,N=o.w||0,M=0;O+2<i;++O){var gt=v(O),U=O&32767,z=p[gt];if(m[U]=z,p[gt]=U,N<=O){var D=i-O;if((T>7e3||E>24576)&&(D>423||!h)){u=jr(n,l,0,P,w,x,_,E,M,O-M,u),E=T=_=0,M=O;for(var k=0;k<286;++k)w[k]=0;for(var k=0;k<30;++k)x[k]=0}var V=2,A=0,bt=d,W=U-z&32767;if(D>2&&gt==v(O-W))for(var Y=Math.min(f,D)-1,G=Math.min(32767,O),j=Math.min(258,D);W<=G&&--bt&&U!=z;){if(n[O+V]==n[O+V-W]){for(var F=0;F<j&&n[O+F]==n[O+F-W];++F);if(F>V){if(V=F,A=W,F>Y)break;for(var Q=Math.min(W,F-2),Z=0,k=0;k<Q;++k){var rt=O-W+k&32767,Qt=m[rt],Jt=rt-Qt&32767;Jt>Z&&(Z=Jt,z=rt)}}}U=z,z=m[U],W+=U-z&32767}if(A){P[E++]=268435456|tr[V]<<18|Rr[A];var kt=tr[V]&31,Lt=Rr[A]&31;_+=Ae[kt]+Ie[Lt],++w[257+kt],++x[Lt],N=O+V,++T}else P[E++]=n[O],++w[n[O]]}}for(O=Math.max(O,N);O<i;++O)P[E++]=n[O],++w[n[O]];u=jr(n,l,h,P,w,x,_,E,M,O-M,u),h||(o.r=u&7|l[u/8|0]<<3,u-=7,o.h=p,o.p=m,o.i=O,o.w=N)}else{for(var O=o.w||0;O<i+h;O+=65535){var qt=O+65535;qt>=i&&(l[u/8|0]=h,qt=i),u=Xr(l,u+1,n.subarray(O,qt))}o.i=i}return Wr(a,0,r+nr(u)+s)},Yr=function(){var n=1,t=0;return{p:function(e){for(var r=n,s=t,o=e.length|0,i=0;i!=o;){for(var a=Math.min(i+2655,o);i<a;++i)s+=r+=e[i];r=(r&65535)+15*(r>>16),s=(s&65535)+15*(s>>16)}n=r,t=s},d:function(){return n%=65521,t%=65521,(n&255)<<24|(n&65280)<<8|(t&255)<<8|t>>8}}},bn=function(n,t,e,r,s){if(!s&&(s={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),i=new at(o.length+n.length);i.set(o),i.set(n,o.length),n=i,s.w=o.length}return vn(n,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+t.mem,e,r,s)},Zr=function(n,t,e){for(;e;++t)n[t]=e,e>>>=8},Sn=function(n,t){var e=t.level,r=e==0?0:e<6?1:e==9?3:2;if(n[0]=120,n[1]=r<<6|(t.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,t.dictionary){var s=Yr();s.p(t.dictionary),Zr(n,2,s.d())}},Pn=function(n,t){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&Ot(6,"invalid zlib data"),(n[1]>>5&1)==+!t&&Ot(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Cn(n,t){t||(t={});var e=Yr();e.p(n);var r=bn(n,t,t.dictionary?6:2,4);return Sn(r,t),Zr(r,r.length-4,e.d()),r}function _n(n,t){return wn(n.subarray(Pn(n,t),-4),{i:2},t,t)}var Mn=typeof TextDecoder<"u"&&new TextDecoder,Tn=0;try{Mn.decode(Hr,{stream:!0}),Tn=1}catch{}const On="modern-font";function pe(n,t){if(!n)throw new Error(`[${On}] ${t}`)}function An(n){return ArrayBuffer.isView(n)?n.byteOffset>0||n.byteLength<n.buffer.byteLength?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n.buffer:n}function ee(n){return ArrayBuffer.isView(n)?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}var Kr=Object.defineProperty,In=(n,t,e)=>t in n?Kr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,lt=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&Kr(t,e,s),s},$n=(n,t,e)=>(In(n,t+"",e),e);const $e={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function ht(){return function(n,t){Object.defineProperty(n.constructor.prototype,t,{get(){if(typeof t=="string"){if(t.startsWith("read"))return(...e)=>this.read(t.substring(4).toLowerCase(),...e);if(t.startsWith("write"))return(...e)=>this.write(t.substring(5).toLowerCase(),...e)}},configurable:!0,enumerable:!0})}}class nt extends DataView{constructor(t,e,r,s){super(An(t),e,r),this.littleEndian=s,$n(this,"cursor",0)}readColumn(t){if(t.size){const e=Array.from({length:t.size},(r,s)=>this.read(t.type,t.offset+s));switch(t.type){case"char":return e.join("");default:return e}}else return this.read(t.type,t.offset)}writeColumn(t,e){t.size?Array.from({length:t.size},(r,s)=>{this.write(t.type,e[s],t.offset+s)}):this.write(t.type,e,t.offset)}read(t,e=this.cursor,r=this.littleEndian){switch(t){case"char":return this.readChar(e);case"fixed":return this.readFixed(e,r);case"longDateTime":return this.readLongDateTime(e,r)}const s=`get${t.replace(/^\S/,i=>i.toUpperCase())}`,o=this[s](e,r);return this.cursor+=$e[t],o}readUint24(t=this.cursor){const[e,r,s]=this.readBytes(t,3);return(e<<16)+(r<<8)+s}readBytes(t,e){e==null&&(e=t,t=this.cursor);const r=[];for(let s=0;s<e;++s)r.push(this.getUint8(t+s));return this.cursor=t+e,r}readString(t,e){const r=this.readBytes(t,e);let s="";for(let o=0,i=r.length;o<i;o++)s+=String.fromCharCode(r[o]);return s}readFixed(t,e){const r=this.readInt32(t,e)/65536;return Math.ceil(r*1e5)/1e5}readLongDateTime(t=this.cursor,e){const r=this.readUint32(t+4,e),s=new Date;return s.setTime(r*1e3+-20775456e5),s}readChar(t){return this.readString(t,1)}write(t,e,r=this.cursor,s=this.littleEndian){switch(t){case"char":return this.writeChar(e,r);case"fixed":return this.writeFixed(e,r);case"longDateTime":return this.writeLongDateTime(e,r)}const o=`set${t.replace(/^\S/,a=>a.toUpperCase())}`,i=this[o](r,e,s);return this.cursor+=$e[t.toLowerCase()],i}writeString(t="",e=this.cursor){const r=t.replace(/[^\x00-\xFF]/g,"11").length;this.seek(e);for(let s=0,o=t.length,i;s<o;++s)i=t.charCodeAt(s)||0,i>127?this.writeUint16(i):this.writeUint8(i);return this.cursor+=r,this}writeChar(t,e){return this.writeString(t,e)}writeFixed(t,e){return this.writeInt32(Math.round(t*65536),e),this}writeLongDateTime(t,e=this.cursor){typeof t>"u"?t=-20775456e5:typeof t.getTime=="function"?t=t.getTime():/^\d+$/.test(t)?t=+t:t=Date.parse(t);const s=Math.round((t- -20775456e5)/1e3);return this.writeUint32(0,e),this.writeUint32(s,e+4),this}writeBytes(t,e=this.cursor){let r;if(Array.isArray(t)){r=t.length;for(let s=0;s<r;++s)this.setUint8(e+s,t[s])}else{const s=ee(t);r=s.byteLength;for(let o=0;o<r;++o)this.setUint8(e+o,s.getUint8(o))}return this.cursor=e+r,this}seek(t){return this.cursor=t,this}}lt([ht()],nt.prototype,"readInt8"),lt([ht()],nt.prototype,"readInt16"),lt([ht()],nt.prototype,"readInt32"),lt([ht()],nt.prototype,"readUint8"),lt([ht()],nt.prototype,"readUint16"),lt([ht()],nt.prototype,"readUint32"),lt([ht()],nt.prototype,"readFloat32"),lt([ht()],nt.prototype,"readFloat64"),lt([ht()],nt.prototype,"writeInt8"),lt([ht()],nt.prototype,"writeInt16"),lt([ht()],nt.prototype,"writeInt32"),lt([ht()],nt.prototype,"writeUint8"),lt([ht()],nt.prototype,"writeUint16"),lt([ht()],nt.prototype,"writeUint32"),lt([ht()],nt.prototype,"writeFloat32"),lt([ht()],nt.prototype,"writeFloat64");var Bn=Object.defineProperty,Dn=(n,t,e)=>t in n?Bn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,En=(n,t,e)=>(Dn(n,t+"",e),e);const Qr=new WeakMap;function y(n){const t=typeof n=="object"?n:{type:n},{size:e=1,type:r}=t;return(s,o)=>{if(typeof o!="string")return;let i=Qr.get(s);i||(i={columns:[],byteLength:0},Qr.set(s,i));const a={...t,name:o,byteLength:e*$e[r],offset:t.offset??i.columns.reduce((l,h)=>l+h.byteLength,0)};i.columns.push(a),i.byteLength=i.columns.reduce((l,h)=>l+$e[h.type]*(h.size??1),0),Object.defineProperty(s.constructor.prototype,o,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class Mt{constructor(t,e,r,s){En(this,"view"),this.view=new nt(t,e,r,s)}}function Un(n){let t="";for(let e=0,r=n.length,s;e<r;e++)s=n.charCodeAt(e),s!==0&&(t+=String.fromCharCode(s));return t}function Be(n){n=Un(n);const t=[];for(let e=0,r=n.length,s;e<r;e++)s=n.charCodeAt(e),t.push(s>>8),t.push(s&255);return t}function kn(n){let t="";for(let e=0,r=n.length;e<r;e++)n[e]<127?t+=String.fromCharCode(n[e]):t+=`%${(256+n[e]).toString(16).slice(1)}`;return unescape(t)}function Ln(n){let t="";for(let e=0,r=n.length;e<r;e+=2)t+=String.fromCharCode((n[e]<<8)+n[e+1]);return t}class ar extends Mt{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(t){return new FontFace(t,this.view.buffer)}}var Jr=Object.defineProperty,Fn=(n,t,e)=>t in n?Jr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,yt=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&Jr(t,e,s),s},ts=(n,t,e)=>(Fn(n,typeof t!="symbol"?t+"":t,e),e);const mt=class on extends ar{constructor(){super(...arguments),ts(this,"format","EmbeddedOpenType"),ts(this,"mimeType","application/vnd.ms-fontobject")}static from(t){const e=t.sfnt,s=e.name.names,o=Be(s.fontFamily||""),i=o.length,a=Be(s.fontStyle||""),l=a.length,h=Be(s.version||""),u=h.length,c=Be(s.fullName||""),f=c.length,d=86+i+4+l+4+u+4+f+2+t.view.byteLength,g=new on(new ArrayBuffer(d),0,d,!0);g.EOTSize=g.view.byteLength,g.FontDataSize=t.view.byteLength,g.Version=131073,g.Flags=0,g.Charset=1,g.MagicNumber=20556,g.Padding1=0,g.CheckSumAdjustment=e.head.checkSumAdjustment;const m=e.os2;return m&&(g.FontPANOSE=m.fontPANOSE,g.Italic=m.fsSelection,g.Weight=m.usWeightClass,g.fsType=m.fsType,g.UnicodeRange=m.ulUnicodeRange,g.CodePageRange=m.ulCodePageRange),g.view.writeUint16(i),g.view.writeBytes(o),g.view.writeUint16(0),g.view.writeUint16(l),g.view.writeBytes(a),g.view.writeUint16(0),g.view.writeUint16(u),g.view.writeBytes(h),g.view.writeUint16(0),g.view.writeUint16(f),g.view.writeBytes(c),g.view.writeUint16(0),g.view.writeUint16(0),g.view.writeBytes(t.view),g}};yt([y("uint32")],mt.prototype,"EOTSize"),yt([y("uint32")],mt.prototype,"FontDataSize"),yt([y("uint32")],mt.prototype,"Version"),yt([y("uint32")],mt.prototype,"Flags"),yt([y({type:"uint8",size:10})],mt.prototype,"FontPANOSE"),yt([y("uint8")],mt.prototype,"Charset"),yt([y("uint8")],mt.prototype,"Italic"),yt([y("uint32")],mt.prototype,"Weight"),yt([y("uint16")],mt.prototype,"fsType"),yt([y("uint16")],mt.prototype,"MagicNumber"),yt([y({type:"uint8",size:16})],mt.prototype,"UnicodeRange"),yt([y({type:"uint8",size:8})],mt.prototype,"CodePageRange"),yt([y("uint32")],mt.prototype,"CheckSumAdjustment"),yt([y({type:"uint8",size:16})],mt.prototype,"Reserved"),yt([y("uint16")],mt.prototype,"Padding1");var zn=Object.defineProperty,De=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&zn(t,e,s),s};class de extends Mt{constructor(t,e){super(t,e,16)}}De([y({type:"char",size:4})],de.prototype,"tag"),De([y("uint32")],de.prototype,"checkSum"),De([y("uint32")],de.prototype,"offset"),De([y("uint32")],de.prototype,"length");const lr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Nn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];var qn=Object.defineProperty,Gn=(n,t,e)=>t in n?qn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ge=(n,t,e)=>(Gn(n,typeof t!="symbol"?t+"":t,e),e);class es{constructor(t){ge(this,"index"),ge(this,"name"),ge(this,"isComposite",!1),ge(this,"components",[]),ge(this,"pathCommands",[]);const e={...t};if(this.index=e.index??0,e.name===".notdef"?e.unicode=void 0:e.name===".null"&&(e.unicode=0),e.unicode===0&&e.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=e.name??null,e.unicode&&(this.unicode=e.unicode),e.unicodes?this.unicodes=e.unicodes:e.unicode&&(this.unicodes=[e.unicode])}getPathCommands(t=0,e=0,r=72,s={},o){const i=1/((o==null?void 0:o.unitsPerEm)??1e3)*r,{xScale:a=i,yScale:l=i}=s,h=this.pathCommands,u=[];for(let c=0,f=h.length;c<f;c+=1){const d=h[c];d.type==="M"?u.push({type:"M",x:t+d.x*a,y:e+-d.y*l}):d.type==="L"?u.push({type:"L",x:t+d.x*a,y:e+-d.y*l}):d.type==="Q"?u.push({type:"Q",x1:t+d.x1*a,y1:e+-d.y1*l,x:t+d.x*a,y:e+-d.y*l}):d.type==="C"?u.push({type:"C",x1:t+d.x1*a,y1:e+-d.y1*l,x2:t+d.x2*a,y2:e+-d.y2*l,x:t+d.x*a,y:e+-d.y*l}):d.type==="Z"&&u.push({type:"Z"})}return u}}class Rn extends es{parse(t,e,r){const s=this,{nominalWidthX:o,defaultWidthX:i,gsubrsBias:a,subrsBias:l}=t,h=t.topDict.paintType,u=this.index;let c,f,d,g;const m=[],p=[];let C=0,S=!1,v=!1,P=i,w=0,x=0;function T(U,z){m.push({type:"L",x:U,y:z})}function _(U,z,D,k,V,A){m.push({type:"C",x1:U,y1:z,x2:D,y2:k,x:V,y:A})}function O(U,z){v&&h!==2&&E(),v=!0,m.push({type:"M",x:U,y:z})}function E(){m.push({type:"Z"})}function N(U){m.push(...U)}function M(){p.length%2!==0&&!S&&(P=p.shift()+o),C+=p.length>>1,p.length=0,S=!0}function gt(U){let z,D,k,V,A,bt,W,Y,G,j,F,Q,Z=0;for(;Z<U.length;){let rt=U[Z++];switch(rt){case 1:M();break;case 3:M();break;case 4:p.length>1&&!S&&(P=p.shift()+o,S=!0),x+=p.pop(),O(w,x);break;case 5:for(;p.length>0;)w+=p.shift(),x+=p.shift(),T(w,x);break;case 6:for(;p.length>0&&(w+=p.shift(),T(w,x),p.length!==0);)x+=p.shift(),T(w,x);break;case 7:for(;p.length>0&&(x+=p.shift(),T(w,x),p.length!==0);)w+=p.shift(),T(w,x);break;case 8:for(;p.length>0;)c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g+p.shift(),_(c,f,d,g,w,x);break;case 10:A=p.pop()+l,bt=t.subrs[A],bt&&gt(bt);break;case 11:return;case 12:switch(rt=U[Z],Z+=1,rt){case 35:c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),W=d+p.shift(),Y=g+p.shift(),G=W+p.shift(),j=Y+p.shift(),F=G+p.shift(),Q=j+p.shift(),w=F+p.shift(),x=Q+p.shift(),p.shift(),_(c,f,d,g,W,Y),_(G,j,F,Q,w,x);break;case 34:c=w+p.shift(),f=x,d=c+p.shift(),g=f+p.shift(),W=d+p.shift(),Y=g,G=W+p.shift(),j=g,F=G+p.shift(),Q=x,w=F+p.shift(),_(c,f,d,g,W,Y),_(G,j,F,Q,w,x);break;case 36:c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),W=d+p.shift(),Y=g,G=W+p.shift(),j=g,F=G+p.shift(),Q=j+p.shift(),w=F+p.shift(),_(c,f,d,g,W,Y),_(G,j,F,Q,w,x);break;case 37:c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),W=d+p.shift(),Y=g+p.shift(),G=W+p.shift(),j=Y+p.shift(),F=G+p.shift(),Q=j+p.shift(),Math.abs(F-w)>Math.abs(Q-x)?w=F+p.shift():x=Q+p.shift(),_(c,f,d,g,W,Y),_(G,j,F,Q,w,x);break;default:console.warn(`Glyph ${u}: unknown operator ${1200+rt}`),p.length=0}break;case 14:if(p.length>=4){const Qt=lr[p.pop()],Jt=lr[p.pop()],kt=p.pop(),Lt=p.pop();if(Qt&&Jt){s.isComposite=!0,s.components=[];const qt=t.charset.indexOf(Qt),he=t.charset.indexOf(Jt);s.components.push({glyphIndex:he,dx:0,dy:0}),s.components.push({glyphIndex:qt,dx:Lt,dy:kt}),N(r.get(he).pathCommands);const Er=JSON.parse(JSON.stringify(r.get(qt).pathCommands));for(let Ur=0;Ur<Er.length;Ur+=1){const Ft=Er[Ur];Ft.type!=="Z"&&(Ft.x+=Lt,Ft.y+=kt),(Ft.type==="Q"||Ft.type==="C")&&(Ft.x1+=Lt,Ft.y1+=kt),Ft.type==="C"&&(Ft.x2+=Lt,Ft.y2+=kt)}N(Er)}}else p.length>0&&!S&&(P=p.shift()+o,S=!0);v&&h!==2&&(E(),v=!1);break;case 18:M();break;case 19:case 20:M(),Z+=C+7>>3;break;case 21:p.length>2&&!S&&(P=p.shift()+o,S=!0),x+=p.pop(),w+=p.pop(),O(w,x);break;case 22:p.length>1&&!S&&(P=p.shift()+o,S=!0),w+=p.pop(),O(w,x);break;case 23:M();break;case 24:for(;p.length>2;)c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g+p.shift(),_(c,f,d,g,w,x);w+=p.shift(),x+=p.shift(),T(w,x);break;case 25:for(;p.length>6;)w+=p.shift(),x+=p.shift(),T(w,x);c=w+p.shift(),f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g+p.shift(),_(c,f,d,g,w,x);break;case 26:for(p.length%2&&(w+=p.shift());p.length>0;)c=w,f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d,x=g+p.shift(),_(c,f,d,g,w,x);break;case 27:for(p.length%2&&(x+=p.shift());p.length>0;)c=w+p.shift(),f=x,d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g,_(c,f,d,g,w,x);break;case 28:z=U[Z],D=U[Z+1],p.push((z<<24|D<<16)>>16),Z+=2;break;case 29:A=p.pop()+a,bt=t.gsubrs[A],bt&&gt(bt);break;case 30:for(;p.length>0&&(c=w,f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g+(p.length===1?p.shift():0),_(c,f,d,g,w,x),p.length!==0);)c=w+p.shift(),f=x,d=c+p.shift(),g=f+p.shift(),x=g+p.shift(),w=d+(p.length===1?p.shift():0),_(c,f,d,g,w,x);break;case 31:for(;p.length>0&&(c=w+p.shift(),f=x,d=c+p.shift(),g=f+p.shift(),x=g+p.shift(),w=d+(p.length===1?p.shift():0),_(c,f,d,g,w,x),p.length!==0);)c=w,f=x+p.shift(),d=c+p.shift(),g=f+p.shift(),w=d+p.shift(),x=g+(p.length===1?p.shift():0),_(c,f,d,g,w,x);break;default:rt<32?console.warn(`Glyph ${u}: unknown operator ${rt}`):rt<247?p.push(rt-139):rt<251?(z=U[Z],Z+=1,p.push((rt-247)*256+z+108)):rt<255?(z=U[Z],Z+=1,p.push(-(rt-251)*256-z-108)):(z=U[Z],D=U[Z+1],k=U[Z+2],V=U[Z+3],Z+=4,p.push((z<<24|D<<16|k<<8|V)/65536))}}}gt(e),this.pathCommands=m,S&&(this.advanceWidth=P)}}var Wn=Object.defineProperty,Vn=(n,t,e)=>t in n?Wn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Xn=(n,t,e)=>(Vn(n,t+"",e),e);class rs{constructor(t){this._sfnt=t,Xn(this,"_items",[])}get(t){const e=this._items[t];let r;if(e)r=e;else{r=this._get(t);const s=this._sfnt.hmtx.metrics[t];s&&(r.advanceWidth=r.advanceWidth||s.advanceWidth,r.leftSideBearing=r.leftSideBearing||s.leftSideBearing);const o=this._sfnt.cmap.glyphIndexToUnicodesMap.get(t);o&&(r.unicode??(r.unicode=o[0]),r.unicodes??(r.unicodes=o)),this._items[t]=r}return r}}class jn extends rs{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(t){const e=this._sfnt.cff,r=new Rn({index:t});return r.parse(e,e.charStringsIndex.get(t),this),r.name=e.charset[t],r}}var ss=Object.defineProperty,Hn=(n,t,e)=>t in n?ss(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ns=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ss(t,e,s),s},Ee=(n,t,e)=>(Hn(n,typeof t!="symbol"?t+"":t,e),e);class Ue extends Mt{constructor(t,e,r,s){super(t,e,r,s),Ee(this,"_offsets"),Ee(this,"_objects"),this._init()}get offsets(){return this._offsets??(this._offsets=this.readOffsets())}get objects(){return this._objects??(this._objects=this.readObjects())}_init(){const t=this.view,e=this.count,r=this.offsetSize;this.objectOffset=(e+1)*r+2,this.endOffset=t.byteOffset+this.objectOffset+this.offsets[e]}readOffsets(){const t=this.view,e=this.count,r=this.offsetSize;t.seek(3);const s=[];for(let o=0,i=e+1;o<i;o++){const a=this.view;let l=0;for(let h=0;h<r;h++)l<<=8,l+=a.readUint8();s.push(l)}return s}readObjects(){const t=[];for(let e=0,r=this.count;e<r;e++)t.push(this.get(e));return t}get(t){const e=this.offsets,r=this.objectOffset,s=r+e[t],i=r+e[t+1]-s;return this._isString?this.view.readString(s,i):this.view.readBytes(s,i)}}ns([y("uint16")],Ue.prototype,"count"),ns([y("uint8")],Ue.prototype,"offsetSize");class ke extends Ue{constructor(){super(...arguments),Ee(this,"_isString",!1)}}class is extends Ue{constructor(){super(...arguments),Ee(this,"_isString",!0)}}const Yn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Zn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Kn=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Qn=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function Le(n,t){return t<=390?Yn[t]:n[t-391]}var Jn=Object.defineProperty,ti=(n,t,e)=>t in n?Jn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,os=(n,t,e)=>(ti(n,typeof t!="symbol"?t+"":t,e),e);function H(n,t="number",e){return(r,s)=>{if(typeof s!="string")return;const o={type:t,operator:n,default:e??t==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,s,{get(){return this._getProp(o)},set(i){this._setProp(o,i)},configurable:!0,enumerable:!0})}}class as extends Mt{constructor(){super(...arguments),os(this,"_dict"),os(this,"_stringIndex")}get dict(){return this._dict??(this._dict=this._readDict())}setStringIndex(t){return this._stringIndex=t,this}_readFloatOperand(){const t=this.view;let e="";const r=15,s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const o=t.readUint8(),i=o>>4,a=o&15;if(i===r||(e+=s[i],a===r))break;e+=s[a]}return Number.parseFloat(e)}_readOperand(t){const e=this.view;let r,s,o,i;if(t===28)return r=e.readUint8(),s=e.readUint8(),r<<8|s;if(t===29)return r=e.readUint8(),s=e.readUint8(),o=e.readUint8(),i=e.readUint8(),r<<24|s<<16|o<<8|i;if(t===30)return this._readFloatOperand();if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return r=e.readUint8(),(t-247)*256+r+108;if(t>=251&&t<=254)return r=e.readUint8(),-(t-251)*256-r-108;throw new Error(`invalid b0 ${t}, at: ${e.cursor}`)}_readDict(){const t=this.view;t.seek(0);let e=[];const r=t.cursor+t.byteLength,s={};for(;t.cursor<r;){let o=t.readUint8();o<=21?(o===12&&(o=1200+t.readUint8()),s[o]=e,e=[]):e.push(this._readOperand(o))}return s}_getProp(t){var r;const e=this.dict[t.operator]??t.default;switch(t.type){case"number":return e[0];case"string":return Le(((r=this._stringIndex)==null?void 0:r.objects)??[],e[0]);case"number[]":return e}return e}_setProp(t,e){}}var ei=Object.defineProperty,hr=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ei(t,e,s),s};class Fe extends as{}hr([H(19)],Fe.prototype,"subrs"),hr([H(20)],Fe.prototype,"defaultWidthX"),hr([H(21)],Fe.prototype,"nominalWidthX");var ri=Object.defineProperty,J=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ri(t,e,s),s};class K extends as{}J([H(0,"string")],K.prototype,"version"),J([H(1,"string")],K.prototype,"notice"),J([H(1200,"string")],K.prototype,"copyright"),J([H(2,"string")],K.prototype,"fullName"),J([H(3,"string")],K.prototype,"familyName"),J([H(4,"string")],K.prototype,"weight"),J([H(1201)],K.prototype,"isFixedPitch"),J([H(1202)],K.prototype,"italicAngle"),J([H(1203,"number",-100)],K.prototype,"underlinePosition"),J([H(1204,"number",50)],K.prototype,"underlineThickness"),J([H(1205)],K.prototype,"paintType"),J([H(1206,"number",2)],K.prototype,"charstringType"),J([H(1207,"number[]",[.001,0,0,.001,0,0])],K.prototype,"fontMatrix"),J([H(13)],K.prototype,"uniqueId"),J([H(5,"number[]",[0,0,0,0])],K.prototype,"fontBBox"),J([H(1208)],K.prototype,"strokeWidth"),J([H(14)],K.prototype,"xuid"),J([H(15)],K.prototype,"charset"),J([H(16)],K.prototype,"encoding"),J([H(17)],K.prototype,"charStrings"),J([H(18,"number[]",[0,0])],K.prototype,"private");var si=Object.defineProperty,ni=(n,t,e)=>t in n?si(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,cr=(n,t,e)=>(ni(n,typeof t!="symbol"?t+"":t,e),e);function ct(n,t=n){return e=>{ze.tableDefinitions.set(n,{tag:n,prop:t,class:e}),Object.defineProperty(ze.prototype,t,{get(){return this.get(n)},set(r){return this.set(n,r)},configurable:!0,enumerable:!0})}}const ls=class Oe{constructor(t){cr(this,"tables",new Map),cr(this,"tableViews",new Map),(t instanceof Map?t:new Map(Object.entries(t))).forEach((r,s)=>{this.tableViews.set(s,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(t){let e=this.cmap.unicodeToGlyphIndexMap.get(t.codePointAt(0));if(e===void 0&&!this.hasGlyf){const{encoding:r,charset:s}=this.cff;e=s.indexOf(r[t.codePointAt(0)])}return e??0}charToGlyph(t){return this.glyphs.get(this.charToGlyphIndex(t))}textToGlyphIndexes(t){const e=[];for(const r of t)e.push(this.charToGlyphIndex(r));return e}textToGlyphs(t){const e=this.glyphs,r=this.textToGlyphIndexes(t),s=r.length,o=Array.from({length:s}),i=e.get(0);for(let a=0;a<s;a+=1)o[a]=e.get(r[a])||i;return o}getPathCommands(t,e,r,s,o){const i=[];return this.forEachGlyph(t,e,r,s,o,(a,l,h,u,c)=>{i.push(...a.getPathCommands(l,h,u,c,this))}),i}getAdvanceWidth(t,e,r){return this.forEachGlyph(t,0,0,e,r,()=>{})}forEachGlyph(t,e=0,r=0,s=72,o={},i){const a=1/this.unitsPerEm*s,l=this.textToGlyphs(t);for(let h=0;h<l.length;h+=1){const u=l[h];i.call(this,u,e,r,s,o),u.advanceWidth&&(e+=u.advanceWidth*a),o.letterSpacing?e+=o.letterSpacing*s:o.tracking&&(e+=o.tracking/1e3*s)}return e}clone(){return new Oe(this.tableViews)}delete(t){const e=Oe.tableDefinitions.get(t);return e?(this.tableViews.delete(t),this.tables.delete(e.prop),this):this}set(t,e){const r=Oe.tableDefinitions.get(t);return r&&this.tables.set(r.prop,e),this.tableViews.set(t,e.view),this}get(t){const e=Oe.tableDefinitions.get(t);if(!e)return;let r=this.tables.get(e.prop);if(!r){const s=e.class;if(s){const o=this.tableViews.get(t);if(!o)return;r=new s(o.buffer,o.byteOffset,o.byteLength).setSfnt(this),this.tables.set(e.prop,r)}}return r}};cr(ls,"tableDefinitions",new Map);let ze=ls;class ut extends Mt{setSfnt(t){return this._sfnt=t,this}getSfnt(){return this._sfnt}}var hs=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,oi=(n,t,e)=>t in n?hs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ye=(n,t,e,r)=>{for(var s=r>1?void 0:r?ii(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&hs(t,e,s),s},ur=(n,t,e)=>(oi(n,typeof t!="symbol"?t+"":t,e),e);let re=class extends ut{constructor(n,t,e,r){super(n,t,e,r),ur(this,"_glyphs"),ur(this,"privateDict"),ur(this,"subrsIndex"),this._init()}get glyphs(){return this._glyphs??(this._glyphs=new jn(this._sfnt))}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}get defaultWidthX(){var n;return((n=this.privateDict)==null?void 0:n.defaultWidthX)??0}get nominalWidthX(){var n;return((n=this.privateDict)==null?void 0:n.nominalWidthX)??0}get subrs(){var n;return((n=this.subrsIndex)==null?void 0:n.objects)??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}_init(){const n=this.view,{buffer:t,byteOffset:e}=n,r=e+4;this.nameIndex=new is(t,r),this.topDictIndex=new ke(t,this.nameIndex.endOffset),this.stringIndex=new is(t,this.topDictIndex.endOffset),this.globalSubrIndex=new ke(t,this.stringIndex.endOffset),this.topDict=new K(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const s=this.topDict.private[0],o=this.topDict.private[1];s&&(this.privateDict=new Fe(t,e+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new ke(t,e+o+this.privateDict.subrs))),this.charStringsIndex=new ke(t,e+this.topDict.charStrings);const i=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=Zn:this.topDict.charset===1?this.charset=Kn:this.topDict.charset===2?this.charset=Qn:this.charset=this._readCharset(e+this.topDict.charset,i,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=lr:this.topDict.encoding===1?this.encoding=Nn:this.encoding=this._readEncoding(e+this.topDict.encoding)}_readCharset(n,t,e){const r=this.view;r.seek(n);let s,o,i;t-=1;const a=[".notdef"],l=r.readUint8();if(l===0)for(s=0;s<t;s+=1)o=r.readUint16(),a.push(Le(e,o));else if(l===1)for(;a.length<=t;)for(o=r.readUint16(),i=r.readUint8(),s=0;s<=i;s+=1)a.push(Le(e,o)),o+=1;else if(l===2)for(;a.length<=t;)for(o=r.readUint16(),i=r.readUint16(),s=0;s<=i;s+=1)a.push(Le(e,o)),o+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(n){const t=this.view;t.seek(n);let e,r;const s={},o=t.readUint8();if(o===0){const i=t.readUint8();for(e=0;e<i;e+=1)r=t.readUint8(),s[r]=e}else if(o===1){const i=t.readUint8();for(r=1,e=0;e<i;e+=1){const a=t.readUint8(),l=t.readUint8();for(let h=a;h<=a+l;h+=1)s[h]=r,r+=1}}else console.warn(`unknown encoding format:${o}`);return s}_calcSubroutineBias(n){let t;return n.length<1240?t=107:n.length<33900?t=1131:t=32768,t}};ye([y("uint8")],re.prototype,"majorVersion",2),ye([y("uint8")],re.prototype,"minorVersion",2),ye([y("uint8")],re.prototype,"headerSize",2),ye([y("uint8")],re.prototype,"offsetSize",2),re=ye([ct("CFF ","cff")],re);var ai=Object.defineProperty,Ne=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ai(t,e,s),s};const me=class an extends Mt{constructor(t=new ArrayBuffer(262),e){super(t,e,262)}static from(t){const e=new an;return e.format=0,e.length=e.view.byteLength,e.language=0,t.forEach((r,s)=>{s<256&&r<256&&e.view.writeUint8(r,6+s)}),e}getUnicodeToGlyphIndexMap(){const t=new Map;return this.glyphIndexArray.forEach((e,r)=>{t.set(r,e)}),t}};Ne([y("uint16")],me.prototype,"format"),Ne([y("uint16")],me.prototype,"length"),Ne([y("uint16")],me.prototype,"language"),Ne([y({type:"uint8",size:256})],me.prototype,"glyphIndexArray");let cs=me;var li=Object.defineProperty,fr=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&li(t,e,s),s};class qe extends Mt{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((t,e)=>Math.max(t,e),0)}get subHeaders(){const t=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:t},(e,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(t-r)*8-2)/2}))}get glyphIndexArray(){const t=this.maxSubHeaderKey,e=6+256*2+t*8;this.view.seek(e);const r=(this.view.byteLength-e)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(t){const e=new Map,r=this.subHeaderKeys,s=this.maxSubHeaderKey,o=this.subHeaders,i=this.glyphIndexArray,a=r.findIndex(h=>h===s);let l=0;for(let h=0;h<256;h++)if(r[h]===0)h>=a||h<o[0].firstCode||h>=o[0].firstCode+o[0].entryCount||o[0].idRangeOffset+(h-o[0].firstCode)>=i.length?l=0:(l=i[o[0].idRangeOffset+(h-o[0].firstCode)],l!==0&&(l=l+o[0].idDelta)),l!==0&&l<t&&e.set(h,l);else{const u=r[h];for(let c=0,f=o[u].entryCount;c<f;c++)if(o[u].idRangeOffset+c>=i.length?l=0:(l=i[o[u].idRangeOffset+c],l!==0&&(l=l+o[u].idDelta)),l!==0&&l<t){const d=(h<<8|c+o[u].firstCode)%65535;e.set(d,l)}}return e}}fr([y("uint16")],qe.prototype,"format"),fr([y("uint16")],qe.prototype,"length"),fr([y("uint16")],qe.prototype,"language");function us(n){return n>32767?n-65536:n<-32767?n+65536:n}function fs(n,t){let e;const r=[];let s={};return n.forEach((o,i)=>{t&&i>t||((!e||i!==e.unicode+1||o!==e.glyphIndex+1)&&(e?(s.end=e.unicode,r.push(s),s={start:i,startId:o,delta:us(o-i)}):(s.start=Number(i),s.startId=o,s.delta=us(o-i))),e={unicode:i,glyphIndex:o})}),e&&(s.end=e.unicode,r.push(s)),r}var hi=Object.defineProperty,Ht=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&hi(t,e,s),s};const Wt=class ln extends Mt{get endCode(){const t=this.segCountX2;return this.view.seek(14),Array.from({length:t/2},()=>this.view.readUint16())}set endCode(t){this.view.seek(14),t.forEach(e=>this.view.writeUint16(e))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(t){this.view.writeUint16(t,14+this.segCountX2)}get startCode(){const t=this.segCountX2;return this.view.seek(14+t+2),Array.from({length:t/2},()=>this.view.readUint16())}set startCode(t){this.view.seek(14+this.segCountX2+2),t.forEach(e=>this.view.writeUint16(e))}get idDelta(){const t=this.segCountX2;return this.view.seek(14+t+2+t),Array.from({length:t/2},()=>this.view.readUint16())}set idDelta(t){const e=this.segCountX2;this.view.seek(14+e+2+e),t.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const t=this.segCountX2;return 14+t+2+t*2}get idRangeOffset(){const t=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:t/2},()=>this.view.readUint16())}set idRangeOffset(t){this.view.seek(this.idRangeOffsetCursor),t.forEach(e=>this.view.writeUint16(e))}get glyphIndexArrayCursor(){const t=this.segCountX2;return 14+t+2+t*3}get glyphIndexArray(){const t=this.glyphIndexArrayCursor;this.view.seek(t);const e=(this.view.byteLength-t)/2;return Array.from({length:e},()=>this.view.readUint16())}static from(t){const e=fs(t,65535),r=e.length+1,s=Math.floor(Math.log(r)/Math.LN2),o=2*2**s,i=new ln(new ArrayBuffer(24+e.length*8));return i.format=4,i.length=i.view.byteLength,i.language=0,i.segCountX2=r*2,i.searchRange=o,i.entrySelector=s,i.rangeShift=2*r-o,i.endCode=[...e.map(a=>a.end),65535],i.reservedPad=0,i.startCode=[...e.map(a=>a.start),65535],i.idDelta=[...e.map(a=>a.delta),1],i.idRangeOffset=Array.from({length:r},()=>0),i}getUnicodeToGlyphIndexMap(){const t=new Map,e=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,s=this.startCode,o=this.endCode,i=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<e;++h)for(let u=s[h],c=o[h];u<=c;++u)if(i[h]===0)t.set(u,(u+a[h])%65536);else{const f=h+i[h]/2+(u-s[h])-r,d=l[f];d!==0?t.set(u,(d+a[h])%65536):t.set(u,0)}return t.delete(65535),t}};Ht([y("uint16")],Wt.prototype,"format"),Ht([y("uint16")],Wt.prototype,"length"),Ht([y("uint16")],Wt.prototype,"language"),Ht([y("uint16")],Wt.prototype,"segCountX2"),Ht([y("uint16")],Wt.prototype,"searchRange"),Ht([y("uint16")],Wt.prototype,"entrySelector"),Ht([y("uint16")],Wt.prototype,"rangeShift");let ps=Wt;var ci=Object.defineProperty,we=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ci(t,e,s),s};class se extends Mt{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const t=this.glyphIndexArray,e=new Map;return t.forEach((r,s)=>{e.set(s,r)}),e}}we([y("uint16")],se.prototype,"format"),we([y("uint16")],se.prototype,"length"),we([y("uint16")],se.prototype,"language"),we([y("uint16")],se.prototype,"firstCode"),we([y("uint16")],se.prototype,"entryCount");var ui=Object.defineProperty,xe=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&ui(t,e,s),s};const ne=class hn extends Mt{get groups(){const t=this.nGroups;return this.view.seek(16),Array.from({length:t},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(t){const e=fs(t),r=new hn(new ArrayBuffer(16+e.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=e.length,e.forEach(s=>{r.view.writeUint32(s.start),r.view.writeUint32(s.end),r.view.writeUint32(s.startId)}),r}getUnicodeToGlyphIndexMap(){const t=new Map,e=this.groups;for(let r=0,s=e.length;r<s;r++){const o=e[r];let i=o.startGlyphCode,a=o.startCharCode;const l=o.endCharCode;for(;a<=l;)t.set(a++,i++)}return t}};xe([y("uint16")],ne.prototype,"format"),xe([y("uint16")],ne.prototype,"reserved"),xe([y("uint32")],ne.prototype,"length"),xe([y("uint32")],ne.prototype,"language"),xe([y("uint32")],ne.prototype,"nGroups");let ds=ne;var fi=Object.defineProperty,pr=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&fi(t,e,s),s};class Ge extends Mt{getVarSelectorRecords(){const t=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:t},()=>{const e={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(e.defaultUVSOffset){this.view.seek(e.defaultUVSOffset);const r=this.view.readUint32();e.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(e.nonDefaultUVSOffset){this.view.seek(e.nonDefaultUVSOffset);const r=this.view.readUint32();e.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return e})}getUnicodeToGlyphIndexMap(){const t=new Map,e=this.getVarSelectorRecords();for(let r=0,s=e.length;r<s;r++){const{uVSMappings:o}=e[r];o.forEach(i=>{t.set(i.unicodeValue,i.glyphID)})}return t}}pr([y("uint16")],Ge.prototype,"format"),pr([y("uint32")],Ge.prototype,"length"),pr([y("uint32")],Ge.prototype,"numVarSelectorRecords");var gs=Object.defineProperty,pi=Object.getOwnPropertyDescriptor,di=(n,t,e)=>t in n?gs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dr=(n,t,e,r)=>{for(var s=r>1?void 0:r?pi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&gs(t,e,s),s},ys=(n,t,e)=>(di(n,typeof t!="symbol"?t+"":t,e),e);let ve=class extends ut{constructor(){super(...arguments),ys(this,"_unicodeToGlyphIndexMap"),ys(this,"_glyphIndexToUnicodesMap")}static from(n){const t=Array.from(n.keys()).some(u=>u>65535),e=ps.from(n),r=cs.from(n),s=t?ds.from(n):void 0,o=4+(s?32:24),i=o+e.view.byteLength,a=i+r.view.byteLength,l=[{platformID:0,platformSpecificID:3,offset:o},{platformID:1,platformSpecificID:0,offset:i},{platformID:3,platformSpecificID:1,offset:o},s&&{platformID:3,platformSpecificID:10,offset:a}].filter(Boolean),h=new ve(new ArrayBuffer(4+8*l.length+e.view.byteLength+r.view.byteLength+((s==null?void 0:s.view.byteLength)??0)));return h.numberSubtables=l.length,h.view.seek(4),l.forEach(u=>{h.view.writeUint16(u.platformID),h.view.writeUint16(u.platformSpecificID),h.view.writeUint32(u.offset)}),h.view.writeBytes(e.view,o),h.view.writeBytes(r.view,i),s&&h.view.writeBytes(s.view,a),h}get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??(this._unicodeToGlyphIndexMap=this.readunicodeToGlyphIndexMap())}get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const n=new Map,t=this.unicodeToGlyphIndexMap,e=Array.from(t.keys());for(let r=0,s=e.length;r<s;r++){const o=e[r],i=t.get(o);n.has(i)?n.get(i).push(o):n.set(i,[o])}this._glyphIndexToUnicodesMap=n}return this._glyphIndexToUnicodesMap}readSubtables(){const n=this.numberSubtables;return this.view.seek(4),Array.from({length:n},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(t=>{this.view.seek(t.offset);const e=this.view.readUint16();let r;switch(e){case 0:r=new cs(this.view.buffer,t.offset);break;case 2:r=new qe(this.view.buffer,t.offset,this.view.readUint16());break;case 4:r=new ps(this.view.buffer,t.offset,this.view.readUint16());break;case 6:r=new se(this.view.buffer,t.offset,this.view.readUint16());break;case 12:r=new ds(this.view.buffer,t.offset,this.view.readUint32(t.offset+4));break;case 14:default:r=new Ge(this.view.buffer,t.offset,this.view.readUint32());break}return{...t,format:e,view:r}})}readunicodeToGlyphIndexMap(){var i,a,l,h,u;const n=this.readSubtables(),t=(i=n.find(c=>c.format===0))==null?void 0:i.view,e=(a=n.find(c=>c.platformID===3&&c.platformSpecificID===3&&c.format===2))==null?void 0:a.view,r=(l=n.find(c=>c.platformID===3&&c.platformSpecificID===1&&c.format===4))==null?void 0:l.view,s=(h=n.find(c=>c.platformID===3&&c.platformSpecificID===10&&c.format===12))==null?void 0:h.view,o=(u=n.find(c=>c.platformID===0&&c.platformSpecificID===5&&c.format===14))==null?void 0:u.view;return new Map([...(t==null?void 0:t.getUnicodeToGlyphIndexMap())??[],...(e==null?void 0:e.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(r==null?void 0:r.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};dr([y("uint16")],ve.prototype,"version",2),dr([y("uint16")],ve.prototype,"numberSubtables",2),ve=dr([ct("cmap")],ve);class gi extends es{_parseContours(t){const e=[];let r=[];for(let s=0;s<t.length;s+=1){const o=t[s];r.push(o),o.lastPointOfContour&&(e.push(r),r=[])}return pe(r.length===0,"There are still points left in the current contour."),e}_transformPoints(t,e){const r=[];for(let s=0;s<t.length;s+=1){const o=t[s],i={x:e.xScale*o.x+e.scale10*o.y+e.dx,y:e.scale01*o.x+e.yScale*o.y+e.dy,onCurve:o.onCurve,lastPointOfContour:o.lastPointOfContour};r.push(i)}return r}_parseGlyphCoordinate(t,e,r,s,o){let i;return(e&s)>0?(i=t.view.readUint8(),e&o||(i=-i),i=r+i):(e&o)>0?i=r:i=r+t.view.readInt16(),i}parse(t,e,r){t.view.seek(e);const s=this.numberOfContours=t.view.readInt16();if(this.xMin=t.view.readInt16(),this.yMin=t.view.readInt16(),this.xMax=t.view.readInt16(),this.yMax=t.view.readInt16(),s>0){const a=this.endPointIndices=[];for(let m=0;m<s;m++)a.push(t.view.readUint16());const l=this.instructionLength=t.view.readUint16();pe(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let m=0;m<l;++m)h.push(t.view.readUint8());const u=t.view.byteOffset,c=a[a.length-1]+1;pe(c<2e4,`Bad numberOfCoordinates:${u}`);const f=[];let d,g=0;for(;g<c;)if(d=t.view.readUint8(),f.push(d),g++,d&8&&g<c){const m=t.view.readUint8();for(let p=0;p<m;p++)f.push(d),g++}if(pe(f.length===c,`Bad flags length: ${f.length}, numberOfCoordinates: ${c}`),a.length>0){const m=[];let p;if(c>0){for(let v=0;v<c;v+=1)d=f[v],p={},p.onCurve=!!(d&1),p.lastPointOfContour=a.includes(v),m.push(p);let C=0;for(let v=0;v<c;v+=1)d=f[v],p=m[v],p.x=this._parseGlyphCoordinate(t,d,C,2,16),C=p.x;let S=0;for(let v=0;v<c;v+=1)d=f[v],p=m[v],p.y=this._parseGlyphCoordinate(t,d,S,4,32),S=p.y}this.points=m}else this.points=[]}else if(s===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=t.view.readUint16();const h={glyphIndex:t.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(h.dx=t.view.readInt16(),h.dy=t.view.readInt16()):h.matchedPoints=[t.view.readUint16(),t.view.readUint16()]:(a&2)>0?(h.dx=t.view.readInt8(),h.dy=t.view.readInt8()):h.matchedPoints=[t.view.readUint8(),t.view.readUint8()],(a&8)>0?h.xScale=h.yScale=t.view.readInt16()/16384:(a&64)>0?(h.xScale=t.view.readInt16()/16384,h.yScale=t.view.readInt16()/16384):(a&128)>0&&(h.xScale=t.view.readInt16()/16384,h.scale01=t.view.readInt16()/16384,h.scale10=t.view.readInt16()/16384,h.yScale=t.view.readInt16()/16384),this.components.push(h),l=!!(a&32)}if(a&256){this.instructionLength=t.view.readUint16(),this.instructions=[];for(let h=0;h<this.instructionLength;h+=1)this.instructions.push(t.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],h=r.get(l.glyphIndex);if(h.getPathCommands(),h.points){let u;if(l.matchedPoints===void 0)u=this._transformPoints(h.points,l);else{pe(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const c=this.points[l.matchedPoints[0]];let f=h.points[l.matchedPoints[1]];const d={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};f=this._transformPoints([f],d)[0],d.dx=c.x-f.x,d.dy=c.y-f.y,u=this._transformPoints(h.points,d)}this.points=this.points.concat(u)}}const o=[],i=this._parseContours(this.points);for(let a=0,l=i.length;a<l;++a){const h=i[a];let u=h[h.length-1],c=h[0];u.onCurve?o.push({type:"M",x:u.x,y:u.y}):c.onCurve?o.push({type:"M",x:c.x,y:c.y}):o.push({type:"M",x:(u.x+c.x)*.5,y:(u.y+c.y)*.5});for(let f=0,d=h.length;f<d;++f)if(u=c,c=h[(f+1)%d],u.onCurve)o.push({type:"L",x:u.x,y:u.y});else{let g=c;c.onCurve||(g={x:(u.x+c.x)*.5,y:(u.y+c.y)*.5}),o.push({type:"Q",x1:u.x,y1:u.y,x:g.x,y:g.y})}o.push({type:"Z"})}this.pathCommands=o}}class yi extends rs{get length(){return this._sfnt.loca.locations.length}_get(t){const e=this._sfnt.loca.locations,r=e[t],s=new gi({index:t});return r!==e[t+1]&&s.parse(this._sfnt.glyf,r,this),s}}var ms=Object.defineProperty,mi=Object.getOwnPropertyDescriptor,wi=(n,t,e)=>t in n?ms(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,xi=(n,t,e,r)=>{for(var s=r>1?void 0:r?mi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&ms(t,e,s),s},vi=(n,t,e)=>(wi(n,t+"",e),e);let gr=class extends ut{constructor(){super(...arguments),vi(this,"_glyphs")}static from(n){const t=n.reduce((r,s)=>r+s.byteLength,0),e=new gr(new ArrayBuffer(t));return n.forEach(r=>{e.view.writeBytes(r)}),e}get glyphs(){return this._glyphs??(this._glyphs=new yi(this._sfnt))}};gr=xi([ct("glyf")],gr);var bi=Object.defineProperty,Si=Object.getOwnPropertyDescriptor,Pi=(n,t,e,r)=>{for(var s=r>1?void 0:r?Si(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&bi(t,e,s),s};let ws=class extends ut{};ws=Pi([ct("GPOS","gpos")],ws);var Ci=Object.defineProperty,_i=Object.getOwnPropertyDescriptor,Yt=(n,t,e,r)=>{for(var s=r>1?void 0:r?_i(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Ci(t,e,s),s};let Vt=class extends ut{};Yt([y("uint16")],Vt.prototype,"majorVersion",2),Yt([y("uint16")],Vt.prototype,"minorVersion",2),Yt([y("uint16")],Vt.prototype,"scriptListOffset",2),Yt([y("uint16")],Vt.prototype,"featureListOffset",2),Yt([y("uint16")],Vt.prototype,"lookupListOffset",2),Yt([y("uint16")],Vt.prototype,"featureVariationsOffset",2),Vt=Yt([ct("GSUB","gsub")],Vt);var Mi=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,st=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ti(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Mi(t,e,s),s};let et=class extends ut{constructor(n=new ArrayBuffer(54),t){super(n,t,Math.min(54,n.byteLength-(t??0)))}};st([y("fixed")],et.prototype,"version",2),st([y("fixed")],et.prototype,"fontRevision",2),st([y("uint32")],et.prototype,"checkSumAdjustment",2),st([y("uint32")],et.prototype,"magickNumber",2),st([y("uint16")],et.prototype,"flags",2),st([y("uint16")],et.prototype,"unitsPerEm",2),st([y({type:"longDateTime"})],et.prototype,"created",2),st([y({type:"longDateTime"})],et.prototype,"modified",2),st([y("int16")],et.prototype,"xMin",2),st([y("int16")],et.prototype,"yMin",2),st([y("int16")],et.prototype,"xMax",2),st([y("int16")],et.prototype,"yMax",2),st([y("uint16")],et.prototype,"macStyle",2),st([y("uint16")],et.prototype,"lowestRecPPEM",2),st([y("int16")],et.prototype,"fontDirectionHint",2),st([y("int16")],et.prototype,"indexToLocFormat",2),st([y("int16")],et.prototype,"glyphDataFormat",2),et=st([ct("head")],et);var Oi=Object.defineProperty,Ai=Object.getOwnPropertyDescriptor,wt=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ai(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Oi(t,e,s),s};let ft=class extends ut{constructor(n=new ArrayBuffer(36),t){super(n,t,Math.min(36,n.byteLength-(t??0)))}};wt([y("fixed")],ft.prototype,"version",2),wt([y("int16")],ft.prototype,"ascent",2),wt([y("int16")],ft.prototype,"descent",2),wt([y("int16")],ft.prototype,"lineGap",2),wt([y("uint16")],ft.prototype,"advanceWidthMax",2),wt([y("int16")],ft.prototype,"minLeftSideBearing",2),wt([y("int16")],ft.prototype,"minRightSideBearing",2),wt([y("int16")],ft.prototype,"xMaxExtent",2),wt([y("int16")],ft.prototype,"caretSlopeRise",2),wt([y("int16")],ft.prototype,"caretSlopeRun",2),wt([y("int16")],ft.prototype,"caretOffset",2),wt([y({type:"int16",size:4})],ft.prototype,"reserved",2),wt([y("int16")],ft.prototype,"metricDataFormat",2),wt([y("uint16")],ft.prototype,"numOfLongHorMetrics",2),ft=wt([ct("hhea")],ft);var xs=Object.defineProperty,Ii=Object.getOwnPropertyDescriptor,$i=(n,t,e)=>t in n?xs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bi=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ii(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&xs(t,e,s),s},Di=(n,t,e)=>($i(n,t+"",e),e);let yr=class extends ut{constructor(){super(...arguments),Di(this,"_metrics")}static from(n){const t=n.length*4,e=new yr(new ArrayBuffer(t));return n.forEach(r=>{e.view.writeUint16(r.advanceWidth),e.view.writeUint16(r.leftSideBearing)}),e}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){const n=this._sfnt.maxp.numGlyphs,t=this._sfnt.hhea.numOfLongHorMetrics;let e=0;const r=this.view;return r.seek(0),Array.from({length:n}).map((s,o)=>(o<t&&(e=r.readUint16()),{advanceWidth:e,leftSideBearing:r.readUint16()}))}};yr=Bi([ct("hmtx")],yr);var Ei=Object.defineProperty,Ui=Object.getOwnPropertyDescriptor,ki=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ui(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Ei(t,e,s),s};let vs=class extends ut{};vs=ki([ct("kern","kern")],vs);var bs=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,Fi=(n,t,e)=>t in n?bs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,zi=(n,t,e,r)=>{for(var s=r>1?void 0:r?Li(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&bs(t,e,s),s},Ni=(n,t,e)=>(Fi(n,t+"",e),e);let mr=class extends ut{constructor(){super(...arguments),Ni(this,"_locations")}static from(n,t=1){const e=n.length*(t?4:2),r=new mr(new ArrayBuffer(e));return n.forEach(s=>{t?r.view.writeUint32(s):r.view.writeUint16(s/2)}),r}get locations(){return this._locations??(this._locations=this.readLocations())}readLocations(){const n=this._sfnt.maxp.numGlyphs,t=this._sfnt.head.indexToLocFormat,e=this.view;return e.seek(0),Array.from({length:n}).map(()=>t?e.readUint32():e.readUint16()*2)}};mr=zi([ct("loca")],mr);var qi=Object.defineProperty,Gi=Object.getOwnPropertyDescriptor,pt=(n,t,e,r)=>{for(var s=r>1?void 0:r?Gi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&qi(t,e,s),s};let it=class extends ut{constructor(n=new ArrayBuffer(32),t){super(n,t,Math.min(32,n.byteLength-(t??0)))}};pt([y("fixed")],it.prototype,"version",2),pt([y("uint16")],it.prototype,"numGlyphs",2),pt([y("uint16")],it.prototype,"maxPoints",2),pt([y("uint16")],it.prototype,"maxContours",2),pt([y("uint16")],it.prototype,"maxComponentPoints",2),pt([y("uint16")],it.prototype,"maxComponentContours",2),pt([y("uint16")],it.prototype,"maxZones",2),pt([y("uint16")],it.prototype,"maxTwilightPoints",2),pt([y("uint16")],it.prototype,"maxStorage",2),pt([y("uint16")],it.prototype,"maxFunctionDefs",2),pt([y("uint16")],it.prototype,"maxInstructionDefs",2),pt([y("uint16")],it.prototype,"maxStackElements",2),pt([y("uint16")],it.prototype,"maxSizeOfInstructions",2),pt([y("uint16")],it.prototype,"maxComponentElements",2),pt([y("uint16")],it.prototype,"maxComponentDepth",2),it=pt([ct("maxp")],it);var Ss=Object.defineProperty,Ri=Object.getOwnPropertyDescriptor,Wi=(n,t,e)=>t in n?Ss(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Re=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ri(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Ss(t,e,s),s},Vi=(n,t,e)=>(Wi(n,t+"",e),e);const Ps={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},wr={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Xi={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},Cs={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let be=class extends ut{constructor(){super(...arguments),Vi(this,"_names")}get names(){return this._names??(this._names=this.readNames())}readNames(){const n=this.count;this.view.seek(6);const t=[];for(let a=0;a<n;++a)t.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const e=this.stringOffset;for(let a=0;a<n;++a){const l=t[a];l.name=this.view.readBytes(e+l.offset,l.length)}let r=wr.Macintosh,s=Xi.Default,o=0;t.some(a=>a.platform===wr.Microsoft&&a.encoding===Cs.UCS2&&a.language===1033)&&(r=wr.Microsoft,s=Cs.UCS2,o=1033);const i={};for(let a=0;a<n;++a){const l=t[a];l.platform===r&&l.encoding===s&&l.language===o&&Ps[l.nameId]&&(i[Ps[l.nameId]]=o===0?kn(l.name):Ln(l.name))}return i}};Re([y("uint16")],be.prototype,"format",2),Re([y("uint16")],be.prototype,"count",2),Re([y("uint16")],be.prototype,"stringOffset",2),be=Re([ct("name")],be);var ji=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,$=(n,t,e,r)=>{for(var s=r>1?void 0:r?Hi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&ji(t,e,s),s};let I=class extends ut{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};$([y("uint16")],I.prototype,"version",2),$([y("int16")],I.prototype,"xAvgCharWidth",2),$([y("uint16")],I.prototype,"usWeightClass",2),$([y("uint16")],I.prototype,"usWidthClass",2),$([y("uint16")],I.prototype,"fsType",2),$([y("uint16")],I.prototype,"ySubscriptXSize",2),$([y("uint16")],I.prototype,"ySubscriptYSize",2),$([y("uint16")],I.prototype,"ySubscriptXOffset",2),$([y("uint16")],I.prototype,"ySubscriptYOffset",2),$([y("uint16")],I.prototype,"ySuperscriptXSize",2),$([y("uint16")],I.prototype,"ySuperscriptYSize",2),$([y("uint16")],I.prototype,"ySuperscriptXOffset",2),$([y("uint16")],I.prototype,"ySuperscriptYOffset",2),$([y("uint16")],I.prototype,"yStrikeoutSize",2),$([y("uint16")],I.prototype,"yStrikeoutPosition",2),$([y("uint16")],I.prototype,"sFamilyClass",2),$([y({type:"uint8"})],I.prototype,"bFamilyType",2),$([y({type:"uint8"})],I.prototype,"bSerifStyle",2),$([y({type:"uint8"})],I.prototype,"bWeight",2),$([y({type:"uint8"})],I.prototype,"bProportion",2),$([y({type:"uint8"})],I.prototype,"bContrast",2),$([y({type:"uint8"})],I.prototype,"bStrokeVariation",2),$([y({type:"uint8"})],I.prototype,"bArmStyle",2),$([y({type:"uint8"})],I.prototype,"bLetterform",2),$([y({type:"uint8"})],I.prototype,"bMidline",2),$([y({type:"uint8"})],I.prototype,"bXHeight",2),$([y({type:"uint8",size:16})],I.prototype,"ulUnicodeRange",2),$([y({type:"char",size:4})],I.prototype,"achVendID",2),$([y("uint16")],I.prototype,"fsSelection",2),$([y("uint16")],I.prototype,"usFirstCharIndex",2),$([y("uint16")],I.prototype,"usLastCharIndex",2),$([y("int16")],I.prototype,"sTypoAscender",2),$([y("int16")],I.prototype,"sTypoDescender",2),$([y("int16")],I.prototype,"sTypoLineGap",2),$([y("uint16")],I.prototype,"usWinAscent",2),$([y("uint16")],I.prototype,"usWinDescent",2),$([y({offset:72,type:"uint8",size:8})],I.prototype,"ulCodePageRange",2),$([y({offset:72,type:"int16"})],I.prototype,"sxHeight",2),$([y("int16")],I.prototype,"sCapHeight",2),$([y("uint16")],I.prototype,"usDefaultChar",2),$([y("uint16")],I.prototype,"usBreakChar",2),$([y("uint16")],I.prototype,"usMaxContext",2),I=$([ct("OS/2","os2")],I);var Yi=Object.defineProperty,Zi=Object.getOwnPropertyDescriptor,Dt=(n,t,e,r)=>{for(var s=r>1?void 0:r?Zi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Yi(t,e,s),s};let At=class extends ut{constructor(n=new ArrayBuffer(32),t,e){super(n,t,e)}};Dt([y("fixed")],At.prototype,"format",2),Dt([y("fixed")],At.prototype,"italicAngle",2),Dt([y("int16")],At.prototype,"underlinePosition",2),Dt([y("int16")],At.prototype,"underlineThickness",2),Dt([y("uint32")],At.prototype,"isFixedPitch",2),Dt([y("uint32")],At.prototype,"minMemType42",2),Dt([y("uint32")],At.prototype,"maxMemType42",2),Dt([y("uint32")],At.prototype,"minMemType1",2),Dt([y("uint32")],At.prototype,"maxMemType1",2),At=Dt([ct("post")],At);var Ki=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,xt=(n,t,e,r)=>{for(var s=r>1?void 0:r?Qi(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&Ki(t,e,s),s};let dt=class extends ut{constructor(n=new ArrayBuffer(36),t){super(n,t,Math.min(36,n.byteLength-(t??0)))}};xt([y("fixed")],dt.prototype,"version",2),xt([y("int16")],dt.prototype,"vertTypoAscender",2),xt([y("int16")],dt.prototype,"vertTypoDescender",2),xt([y("int16")],dt.prototype,"vertTypoLineGap",2),xt([y("int16")],dt.prototype,"advanceHeightMax",2),xt([y("int16")],dt.prototype,"minTopSideBearing",2),xt([y("int16")],dt.prototype,"minBottomSideBearing",2),xt([y("int16")],dt.prototype,"yMaxExtent",2),xt([y("int16")],dt.prototype,"caretSlopeRise",2),xt([y("int16")],dt.prototype,"caretSlopeRun",2),xt([y("int16")],dt.prototype,"caretOffset",2),xt([y({type:"int16",size:4})],dt.prototype,"reserved",2),xt([y("int16")],dt.prototype,"metricDataFormat",2),xt([y("int16")],dt.prototype,"numOfLongVerMetrics",2),dt=xt([ct("vhea")],dt);var _s=Object.defineProperty,Ji=Object.getOwnPropertyDescriptor,to=(n,t,e)=>t in n?_s(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,eo=(n,t,e,r)=>{for(var s=r>1?void 0:r?Ji(t,e):t,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=(r?i(t,e,s):i(s))||s);return r&&s&&_s(t,e,s),s},ro=(n,t,e)=>(to(n,t+"",e),e);let xr=class extends ut{constructor(){super(...arguments),ro(this,"_metrics")}static from(n){const t=n.length*4,e=new xr(new ArrayBuffer(t));return n.forEach(r=>{e.view.writeUint16(r.advanceHeight),e.view.writeInt16(r.topSideBearing)}),e}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){var s;const n=this._sfnt.maxp.numGlyphs,t=((s=this._sfnt.vhea)==null?void 0:s.numOfLongVerMetrics)??0,e=this.view;e.seek(0);let r=0;return Array.from({length:n}).map((o,i)=>(i<t&&(r=e.readUint16()),{advanceHeight:r,topSideBearing:e.readUint8()}))}};xr=eo([ct("vmtx")],xr);var Ms=Object.defineProperty,so=(n,t,e)=>t in n?Ms(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Se=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&Ms(t,e,s),s},We=(n,t,e)=>(so(n,typeof t!="symbol"?t+"":t,e),e);class It extends ar{constructor(){super(...arguments),We(this,"format","TrueType"),We(this,"mimeType","font/ttf"),We(this,"_sfnt")}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(ee(t).getUint32(0))}static checksum(t){const e=ee(t);let r=e.byteLength;for(;r%4;)r++;let s=0;for(let o=0,i=r/4;o<i;o+=4)o*4<r-4&&(s+=e.getUint32(o*4,!1));return s&4294967295}static from(t){const e=c=>c+3&-4,r=t.tableViews.size,s=t.tableViews.values().reduce((c,f)=>c+e(f.byteLength),0),o=new this(new ArrayBuffer(12+r*16+s));o.scalerType=65536,o.numTables=r;const i=Math.log(2);o.searchRange=Math.floor(Math.log(r)/i)*16,o.entrySelector=Math.floor(o.searchRange/i),o.rangeShift=r*16-o.searchRange;let a=12+r*16,l=0;const h=o.getDirectories();t.tableViews.forEach((c,f)=>{const d=h[l++];d.tag=f,d.checkSum=this.checksum(c),d.offset=a,d.length=c.byteLength,o.view.writeBytes(c,a),a+=e(d.length)});const u=o.createSfnt().head;return u.checkSumAdjustment=0,u.checkSumAdjustment=2981146554-this.checksum(o.view),o}getDirectories(){let t=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const e=new de(this.view.buffer,t);return t+=e.view.byteLength,e})}createSfnt(){return new ze(this.getDirectories().reduce((t,e)=>(t[e.tag]=new DataView(this.view.buffer,this.view.byteOffset+e.offset,e.length),t),{}))}}We(It,"signature",new Set([65536,1953658213,1954115633])),Se([y("uint32")],It.prototype,"scalerType"),Se([y("uint16")],It.prototype,"numTables"),Se([y("uint16")],It.prototype,"searchRange"),Se([y("uint16")],It.prototype,"entrySelector"),Se([y("uint16")],It.prototype,"rangeShift");var no=Object.defineProperty,io=(n,t,e)=>t in n?no(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,vr=(n,t,e)=>(io(n,typeof t!="symbol"?t+"":t,e),e);class Ve extends It{constructor(){super(...arguments),vr(this,"format","OpenType"),vr(this,"mimeType","font/otf")}static from(t){return super.from(t)}}vr(Ve,"signature",new Set([1330926671]));var oo=Object.defineProperty,Pe=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&oo(t,e,s),s};class ie extends Mt{constructor(t,e){super(t,e,20)}}Pe([y({type:"char",size:4})],ie.prototype,"tag"),Pe([y("uint32")],ie.prototype,"offset"),Pe([y("uint32")],ie.prototype,"compLength"),Pe([y("uint32")],ie.prototype,"origLength"),Pe([y("uint32")],ie.prototype,"origChecksum");var Ts=Object.defineProperty,ao=(n,t,e)=>t in n?Ts(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_t=(n,t,e,r)=>{for(var s=void 0,o=n.length-1,i;o>=0;o--)(i=n[o])&&(s=i(t,e,s)||s);return s&&Ts(t,e,s),s},Xe=(n,t,e)=>(ao(n,typeof t!="symbol"?t+"":t,e),e);const vt=class kr extends ar{constructor(){super(...arguments),Xe(this,"format","WOFF"),Xe(this,"mimeType","font/woff"),Xe(this,"_sfnt")}get subfontFormat(){return It.is(this.flavor)?"TrueType":Ve.is(this.flavor)?"OpenType":"Open"}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(ee(t).getUint32(0))}static checkSum(t){const e=ee(t),r=e.byteLength,s=Math.floor(r/4);let o=0,i=0;for(;i<s;)o+=e.getUint32(4*i++,!1);let a=r-s*4;if(a){let l=s*4;for(;a>0;)o+=e.getUint8(l)<<a*8,l++,a--}return o%4294967296}static from(t,e=new ArrayBuffer(0)){const r=c=>c+3&-4,s=[];t.tableViews.forEach((c,f)=>{const d=ee(Cn(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)));s.push({tag:f,view:d.byteLength<c.byteLength?d:c,rawView:c})});const o=s.length,i=s.reduce((c,f)=>c+r(f.view.byteLength),0),a=new kr(new ArrayBuffer(44+20*o+i+e.byteLength));a.signature=2001684038,a.flavor=65536,a.length=a.view.byteLength,a.numTables=o,a.totalSfntSize=12+16*o+s.reduce((c,f)=>c+r(f.rawView.byteLength),0);let l=44+o*20,h=0;const u=a.getDirectories();return s.forEach(c=>{const f=u[h++];f.tag=c.tag,f.offset=l,f.compLength=c.view.byteLength,f.origChecksum=kr.checkSum(c.rawView),f.origLength=c.rawView.byteLength,a.view.writeBytes(c.view,l),l+=r(f.compLength)}),a.view.writeBytes(e),a}getDirectories(){let t=44;return Array.from({length:this.numTables},()=>{const e=new ie(this.view.buffer,t);return t+=e.view.byteLength,e})}createSfnt(){return new ze(this.getDirectories().reduce((t,e)=>{const r=e.tag,s=this.view.byteOffset+e.offset,o=e.compLength,i=e.origLength,a=s+o;return t[r]=o>=i?new DataView(this.view.buffer,s,o):new DataView(_n(new Uint8Array(this.view.buffer.slice(s,a))).buffer),t},{}))}};Xe(vt,"signature",new Set([2001684038])),_t([y("uint32")],vt.prototype,"signature"),_t([y("uint32")],vt.prototype,"flavor"),_t([y("uint32")],vt.prototype,"length"),_t([y("uint16")],vt.prototype,"numTables"),_t([y("uint16")],vt.prototype,"reserved"),_t([y("uint32")],vt.prototype,"totalSfntSize"),_t([y("uint16")],vt.prototype,"majorVersion"),_t([y("uint16")],vt.prototype,"minorVersion"),_t([y("uint32")],vt.prototype,"metaOffset"),_t([y("uint32")],vt.prototype,"metaLength"),_t([y("uint32")],vt.prototype,"metaOrigLength"),_t([y("uint32")],vt.prototype,"privOffset"),_t([y("uint32")],vt.prototype,"privLength");let br=vt;function lo(n,t=!0){if(It.is(n))return new It(n);if(Ve.is(n))return new Ve(n);if(br.is(n))return new br(n);if(t)throw new Error("Failed to parseFont")}var ho=Object.defineProperty,co=(n,t,e)=>t in n?ho(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ce=(n,t,e)=>(co(n,typeof t!="symbol"?t+"":t,e),e);const Os=class cn{constructor(){Ce(this,"fallbackFont"),Ce(this,"loading",new Map),Ce(this,"loaded",new Map),Ce(this,"familyToUrl",new Map)}_createRequest(t,e){const r=new AbortController;return{url:t,when:fetch(t,{...cn.defaultRequestInit,...e,signal:r.signal}).then(s=>s.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(t,e){return document.fonts.add(new FontFace(t,e)),this}injectStyleTag(t,e){const r=document.createElement("style");return r.appendChild(document.createTextNode(`@font-face {
2
2
  font-family: "${t}";
3
3
  src: url(${e});
4
- }`)),document.head.appendChild(r),this}get(t){let e;return t&&(e=this.loaded.get(this.familyToUrl.get(t)??t)),e??this.fallbackFont}set(t,e){return this.familyToUrl.set(t,e.src),this.loaded.set(e.src,e),this}delete(t){const e=this.familyToUrl.get(t)??t;return this.familyToUrl.delete(e),this.loaded.delete(e),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(t,e={}){const{cancelOther:r,injectFontFace:s=!0,injectStyleTag:o=!0,...i}=e,{src:a}=t;if(this.loaded.has(a))return r&&(this.loading.forEach(f=>f.cancel()),this.loading.clear()),u(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,i),this.loading.set(a,l)),r&&this.loading.forEach((f,d)=>{f!==l&&(f.cancel(),this.loading.delete(d))}),l.when.then(f=>{if(this.loaded.has(a))return u(this.loaded.get(a));{const d=c(f);return e.noAdd||this.loaded.set(t.src,d),d.familySet.forEach(g=>{this.familyToUrl.set(g,a),typeof document<"u"&&(s&&this.injectFontFace(g,f),o&&this.injectStyleTag(g,a))}),d}}).catch(f=>{if(f instanceof DOMException&&f.message==="The user aborted a request.")return c();throw f}).finally(()=>{this.loading.delete(a)});function h(){return t.family?Array.isArray(t.family)?t.family:[t.family]:[]}function u(f){return h().forEach(d=>{f.familySet.add(d)}),f}function c(f=new ArrayBuffer(0)){let d;function g(){return d||(d=f.byteLength?lo(f,!1):void 0),d}function m(){const p=g();if(p instanceof It||p instanceof br)return p.sfnt}return{...t,buffer:f,familySet:new Set(h()),getFont:g,getSfnt:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(t=>t.when))}};Ce(Os,"defaultRequestInit",{cache:"force-cache"});let uo=Os;const fo=new uo,po={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Sr(n,t){const{fill:e="#000",stroke:r="none",strokeWidth:s=r==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:u=0,shadowOffsetY:c=0,shadowBlur:f=0,shadowColor:d="rgba(0, 0, 0, 0)"}=t;n.fillStyle=e,n.strokeStyle=r,n.lineWidth=s,n.lineCap=o,n.lineJoin=po[i],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=u,n.shadowOffsetY=c,n.shadowBlur=f,n.shadowColor=d}class b{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new b(1/0,1/0)}static get MIN(){return new b(-1/0,-1/0)}get array(){return[this.x,this.y]}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const r=-t/180*Math.PI,s=this.x-e.x,o=-(this.y-e.y),i=Math.sin(r),a=Math.cos(r);return this.set(e.x+(s*a-o*i),e.y-(s*i+o*a)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,r={x:0,y:0}){const s=t<0?r.x-this.x+r.x:this.x,o=e<0?r.y-this.y+r.y:this.y;return this.x=s*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,r={x:0,y:0}){const s=this.x-r.x,o=this.y-r.y;return this.x=r.x+(s+Math.tan(t)*o),this.y=r.y+(o+Math.tan(e)*s),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,r=this.y,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6],this.y=s[1]*e+s[4]*r+s[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new b(this.x,this.y)}}class q{constructor(t=0,e=0,r=0,s=0){this.left=t,this.top=e,this.width=r,this.height=s}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new b((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new q;if(t.length===1)return t[0].clone();const e=t[0],r=t.slice(1).reduce((s,o)=>(s.left=Math.min(s.left,o.left),s.top=Math.min(s.top,o.top),s.right=Math.max(s.right,o.right),s.bottom=Math.max(s.bottom,o.bottom),s),{left:(e==null?void 0:e.left)??0,top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0});return new q(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new q(this.left,this.top,this.width,this.height)}}var go=Object.defineProperty,yo=(n,t,e)=>t in n?go(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mo=(n,t,e)=>(yo(n,t+"",e),e);class St{constructor(t=1,e=0,r=0,s=0,o=1,i=0,a=0,l=0,h=1){mo(this,"elements",[]),this.set(t,e,r,s,o,i,a,l,h)}set(t,e,r,s,o,i,a,l,h){const u=this.elements;return u[0]=t,u[1]=s,u[2]=a,u[3]=e,u[4]=o,u[5]=l,u[6]=r,u[7]=i,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,s=e.elements,o=this.elements,i=r[0],a=r[3],l=r[6],h=r[1],u=r[4],c=r[7],f=r[2],d=r[5],g=r[8],m=s[0],p=s[3],C=s[6],S=s[1],v=s[4],P=s[7],w=s[2],x=s[5],T=s[8];return o[0]=i*m+a*S+l*w,o[3]=i*p+a*v+l*x,o[6]=i*C+a*P+l*T,o[1]=h*m+u*S+c*w,o[4]=h*p+u*v+c*x,o[7]=h*C+u*P+c*T,o[2]=f*m+d*S+g*w,o[5]=f*p+d*v+g*x,o[8]=f*C+d*P+g*T,this}invert(){const t=this.elements,e=t[0],r=t[1],s=t[2],o=t[3],i=t[4],a=t[5],l=t[6],h=t[7],u=t[8],c=u*i-a*h,f=a*l-u*o,d=h*o-i*l,g=e*c+r*f+s*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/g;return t[0]=c*m,t[1]=(s*h-u*r)*m,t[2]=(a*r-s*i)*m,t[3]=f*m,t[4]=(u*e-s*l)*m,t[5]=(s*o-a*e)*m,t[6]=d*m,t[7]=(r*l-h*e)*m,t[8]=(i*e-r*o)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(Pr.makeScale(t,e)),this}rotate(t){return this.premultiply(Pr.makeRotation(-t)),this}translate(t,e){return this.premultiply(Pr.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Pr=new St;function As(n,t,e,r){const s=n*e+t*r,o=Math.sqrt(n*n+t*t)*Math.sqrt(e*e+r*r);let i=Math.acos(Math.max(-1,Math.min(1,s/o)));return n*r-t*e<0&&(i=-i),i}function wo(n,t,e,r,s,o,i,a){if(t===0||e===0){n.lineTo(a.x,a.y);return}r=r*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const l=(i.x-a.x)/2,h=(i.y-a.y)/2,u=Math.cos(r)*l+Math.sin(r)*h,c=-Math.sin(r)*l+Math.cos(r)*h;let f=t*t,d=e*e;const g=u*u,m=c*c,p=g/f+m/d;if(p>1){const E=Math.sqrt(p);t=E*t,e=E*e,f=t*t,d=e*e}const C=f*m+d*g,S=(f*d-C)/C;let v=Math.sqrt(Math.max(0,S));s===o&&(v=-v);const P=v*t*c/e,w=-v*e*u/t,x=Math.cos(r)*P-Math.sin(r)*w+(i.x+a.x)/2,T=Math.sin(r)*P+Math.cos(r)*w+(i.y+a.y)/2,_=As(1,0,(u-P)/t,(c-w)/e),O=As((u-P)/t,(c-w)/e,(-u-P)/t,(-c-w)/e)%(Math.PI*2);n.ellipse(x,T,t,e,r,_,_+O,o===1)}function oe(n,t){return n-(t-n)}function Is(n,t){const e=new b,r=new b;for(let s=0,o=n.length;s<o;s++){const i=n[s];if(i.type==="m"||i.type==="M")i.type==="m"?e.add(i):e.copy(i),t.moveTo(e.x,e.y),r.copy(e);else if(i.type==="h"||i.type==="H")i.type==="h"?e.x+=i.x:e.x=i.x,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="v"||i.type==="V")i.type==="v"?e.y+=i.y:e.y=i.y,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="l"||i.type==="L")i.type==="l"?e.add(i):e.copy(i),t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="c"||i.type==="C")i.type==="c"?(t.bezierCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(t.bezierCurveTo(oe(e.x,r.x),oe(e.y,r.y),e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(oe(e.x,r.x),oe(e.y,r.y),i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(t.quadraticCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x,e.y+i.y),r.x=e.x+i.x1,r.y=e.y+i.y1,e.add(i)):(t.quadraticCurveTo(i.x1,i.y1,i.x,i.y),r.x=i.x1,r.y=i.y1,e.copy(i));else if(i.type==="t"||i.type==="T"){const a=oe(e.x,r.x),l=oe(e.y,r.y);r.x=a,r.y=l,i.type==="t"?(t.quadraticCurveTo(a,l,e.x+i.x,e.y+i.y),e.add(i)):(t.quadraticCurveTo(a,l,i.x,i.y),e.copy(i))}else if(i.type==="a"||i.type==="A"){const a=e.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;e.add(i)}else{if(e.equals(i))continue;e.copy(i)}r.copy(e),wo(t,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,a,e)}else i.type==="z"||i.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",i)}}const tt={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Et(n,t,e=0){let a=0,l=!0,h="",u="";const c=[];function f(p,C,S){const v=new SyntaxError(`Unexpected character "${p}" at index ${C}.`);throw v.partial=S,v}function d(){h!==""&&(u===""?c.push(Number(h)):c.push(Number(h)*10**Number(u))),h="",u=""}let g;const m=n.length;for(let p=0;p<m;p++){if(g=n[p],Array.isArray(t)&&t.includes(c.length%e)&&tt.FLAGS.test(g)){a=1,h=g,d();continue}if(a===0){if(tt.WHITESPACE.test(g))continue;if(tt.DIGIT.test(g)||tt.SIGN.test(g)){a=1,h=g;continue}if(tt.POINT.test(g)){a=2,h=g;continue}tt.COMMA.test(g)&&(l&&f(g,p,c),l=!0)}if(a===1){if(tt.DIGIT.test(g)){h+=g;continue}if(tt.POINT.test(g)){h+=g,a=2;continue}if(tt.EXP.test(g)){a=3;continue}tt.SIGN.test(g)&&h.length===1&&tt.SIGN.test(h[0])&&f(g,p,c)}if(a===2){if(tt.DIGIT.test(g)){h+=g;continue}if(tt.EXP.test(g)){a=3;continue}tt.POINT.test(g)&&h[h.length-1]==="."&&f(g,p,c)}if(a===3){if(tt.DIGIT.test(g)){u+=g;continue}if(tt.SIGN.test(g)){if(u===""){u+=g;continue}u.length===1&&tt.SIGN.test(u)&&f(g,p,c)}}tt.WHITESPACE.test(g)?(d(),a=0,l=!1):tt.COMMA.test(g)?(d(),a=0,l=!0):tt.SIGN.test(g)?(d(),a=1,h=g):tt.POINT.test(g)?(d(),a=2,h=g):f(g,p,c)}return d(),c}function xo(n){const t={x:0,y:0},e={x:0,y:0};let r="";for(let s=0,o=n.length;s<o;s++){const i=n[s];switch(i.type){case"m":case"M":if(i.x===e.x&&i.y===e.y)continue;r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y,t.x=i.x,t.y=i.y;break;case"h":case"H":r+=`${i.type} ${i.x}`,e.x=i.x;break;case"v":case"V":r+=`${i.type} ${i.y}`,e.y=i.y;break;case"l":case"L":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"c":case"C":r+=`${i.type} ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"s":case"S":r+=`${i.type} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"q":case"Q":r+=`${i.type} ${i.x1} ${i.y1} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"t":case"T":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"a":case"A":r+=`${i.type} ${i.rx} ${i.ry} ${i.angle} ${i.largeArcFlag} ${i.sweepFlag} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"z":case"Z":r+=i.type,e.x=t.x,e.y=t.y;break}}return r}const vo=/[a-df-z][^a-df-z]*/gi;function $s(n){const t=[],e=n.match(vo);if(!e)return t;for(let r=0,s=e.length;r<s;r++){const o=e[r],i=o.charAt(0),a=o.slice(1).trim();let l;switch(i){case"m":case"M":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)h===0?t.push({type:i,x:l[h],y:l[h+1]}):t.push({type:i==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=Et(a);for(let h=0,u=l.length;h<u;h++)t.push({type:i,x:l[h]});break;case"v":case"V":l=Et(a);for(let h=0,u=l.length;h<u;h++)t.push({type:i,y:l[h]});break;case"l":case"L":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)t.push({type:i,x:l[h],y:l[h+1]});break;case"c":case"C":l=Et(a);for(let h=0,u=l.length;h<u;h+=6)t.push({type:i,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=Et(a);for(let h=0,u=l.length;h<u;h+=4)t.push({type:i,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=Et(a);for(let h=0,u=l.length;h<u;h+=4)t.push({type:i,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)t.push({type:i,x:l[h],y:l[h+1]});break;case"a":case"A":l=Et(a,[3,4],7);for(let h=0,u=l.length;h<u;h+=7)t.push({type:i,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":t.push({type:i});break;default:console.warn(o)}}return t}var bo=Object.defineProperty,So=(n,t,e)=>t in n?bo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Cr=(n,t,e)=>(So(n,typeof t!="symbol"?t+"":t,e),e);class Zt{constructor(){Cr(this,"arcLengthDivisions",200),Cr(this,"_cacheArcLengths"),Cr(this,"_needsUpdate",!1)}isClockwise(){const t=this.getPoint(1),e=this.getPoint(.5),r=this.getPoint(1);return(e.x-t.x)*(r.y-e.y)-(e.y-t.y)*(r.x-e.x)<0}getPointAt(t,e=new b){return this.getPoint(this.getUToTMapping(t),e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}forEachControlPoints(t){return this.getControlPoints().forEach(t),this}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===t+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const e=[];let r,s=this.getPoint(0),o=0;e.push(0);for(let i=1;i<=t;i++)r=this.getPoint(i/t),o+=r.distanceTo(s),e.push(o),s=r;return this._cacheArcLengths=e,e}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(t,e){const r=this.getLengths();let s=0;const o=r.length;let i;e?i=e:i=t*r[o-1];let a=0,l=o-1,h;for(;a<=l;)if(s=Math.floor(a+(l-a)/2),h=r[s]-i,h<0)a=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===i)return s/(o-1);const u=r[s],f=r[s+1]-u,d=(i-u)/f;return(s+d)/(o-1)}getTangent(t,e=new b){const s=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(s)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new b){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let r=0,s=1,o=(r+s)/2;for(;s-r>e;){o=(r+s)/2;const i=this.getPoint(o);if(i.distanceTo(t)<e)return o;i.x<t.x?r=o:s=o}return o}matrix(t){return this.forEachControlPoints(e=>e.applyMatrix3(t)),this}getMinMax(t=b.MAX,e=b.MIN){return this.getPoints().forEach(r=>{t.min(r),e.max(r)}),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new q(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.getPoints().map((t,e)=>e===0?{type:"M",x:t.x,y:t.y}:{type:"L",x:t.x,y:t.y})}toData(){return xo(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}function Bs(n,t,e,r,s){const o=(r-t)*.5,i=(s-e)*.5,a=n*n,l=n*a;return(2*e-2*r+o+i)*l+(-3*e+3*r-2*o-i)*a+o*n+e}function Po(n,t){const e=1-n;return e*e*t}function Co(n,t){return 2*(1-n)*n*t}function _o(n,t){return n*n*t}function Ds(n,t,e,r){return Po(n,t)+Co(n,e)+_o(n,r)}function Mo(n,t){const e=1-n;return e*e*e*t}function To(n,t){const e=1-n;return 3*e*e*n*t}function Oo(n,t){return 3*(1-n)*n*n*t}function Ao(n,t){return n*n*n*t}function Es(n,t,e,r,s){return Mo(n,t)+To(n,e)+Oo(n,r)+Ao(n,s)}class Io extends Zt{constructor(t=new b,e=new b,r=new b,s=new b){super(),this.start=t,this.startControl=e,this.endControl=r,this.end=s}getPoint(t,e=new b){const{start:r,startControl:s,endControl:o,end:i}=this;return e.set(Es(t,r.x,s.x,o.x,i.x),Es(t,r.y,s.y,o.y,i.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(t,e,r){const s=e*e-4*t*r;if(s<0)return[];const o=Math.sqrt(s),i=(-e+o)/(2*t),a=(-e-o)/(2*t);return[i,a].filter(l=>l>=0&&l<=1)}getMinMax(t=b.MAX,e=b.MIN){const r=this.start,s=this.startControl,o=this.endControl,i=this.end,a=this._solveQuadratic(3*(s.x-r.x),6*(o.x-s.x),3*(i.x-o.x)),l=this._solveQuadratic(3*(s.y-r.y),6*(o.y-s.y),3*(i.y-o.y)),h=[0,1,...a,...l];return((c,f)=>{for(const d of c)for(let g=0;g<=f;g++){const m=g/f-.5,p=Math.min(1,Math.max(0,d+m)),C=this.getPoint(p);t.x=Math.min(t.x,C.x),t.y=Math.min(t.y,C.y),e.x=Math.max(e.x,C.x),e.y=Math.max(e.y,C.y)}})(h,10),{min:t,max:e}}toCommands(){const{start:t,startControl:e,endControl:r,end:s}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:r.x,y2:r.y,x:s.x,y:s.y}]}drawTo(t){const{start:e,startControl:r,endControl:s,end:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(r.x,r.y,s.x,s.y,o.x,o.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.startControl.copy(t.startControl),this.endControl.copy(t.endControl),this.end.copy(t.end),this}}const $o=new St,Us=new St,ks=new St,je=new b;class Bo extends Zt{constructor(t=new b,e=1,r=1,s=0,o=0,i=Math.PI*2,a=!1){super(),this.center=t,this.radiusX=e,this.radiusY=r,this.rotation=s,this.startAngle=o,this.endAngle=i,this.clockwise=a}isClockwise(){return this.clockwise}getPoint(t,e=new b){const r=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.clockwise&&!o&&(s===r?s=-r:s=s-r);const i=this.startAngle+t*s;let a=this.center.x+this.radiusX*Math.cos(i),l=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const h=Math.cos(this.rotation),u=Math.sin(this.rotation),c=a-this.center.x,f=l-this.center.y;a=c*h-f*u+this.center.x,l=c*u+f*h+this.center.y}return e.set(a,l)}toCommands(){const{center:t,radiusX:e,radiusY:r,startAngle:s,endAngle:o,clockwise:i,rotation:a}=this,{x:l,y:h}=t,u=l+e*Math.cos(s)*Math.cos(a)-r*Math.sin(s)*Math.sin(a),c=h+e*Math.cos(s)*Math.sin(a)+r*Math.sin(s)*Math.cos(a),f=Math.abs(s-o),d=f>Math.PI?1:0,g=i?1:0,m=a*180/Math.PI;if(f>=2*Math.PI){const p=s+Math.PI,C=l+e*Math.cos(p)*Math.cos(a)-r*Math.sin(p)*Math.sin(a),S=h+e*Math.cos(p)*Math.sin(a)+r*Math.sin(p)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:g,x:C,y:S},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:g,x:u,y:c}]}else{const p=l+e*Math.cos(o)*Math.cos(a)-r*Math.sin(o)*Math.sin(a),C=h+e*Math.cos(o)*Math.sin(a)+r*Math.sin(o)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:d,sweepFlag:g,x:p,y:C}]}}drawTo(t){const{center:e,radiusX:r,radiusY:s,rotation:o,startAngle:i,endAngle:a,clockwise:l}=this;return t.ellipse(e.x,e.y,r,s,o,i,a,!l),this}matrix(t){return je.set(this.center.x,this.center.y),je.applyMatrix3(t),this.center.x=je.x,this.center.y=je.y,Uo(t)?Do(this,t):Eo(this,t),this}getControlPoints(){return[this.center]}getMinMax(t=b.MAX,e=b.MIN){const{center:r,radiusX:s,radiusY:o,rotation:i}=this,{x:a,y:l}=r,h=Math.cos(i),u=Math.sin(i),c=Math.sqrt(s*s*h*h+o*o*u*u),f=Math.sqrt(s*s*u*u+o*o*h*h);return t.x=Math.min(t.x,a-c),t.y=Math.min(t.y,l-f),e.x=Math.max(e.x,a+c),e.y=Math.max(e.y,l+f),{min:t,max:e}}copy(t){return super.copy(t),this.center.x=t.center.x,this.center.y=t.center.y,this.radiusX=t.radiusX,this.radiusY=t.radiusY,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}}function Do(n,t){const e=n.radiusX,r=n.radiusY,s=Math.cos(n.rotation),o=Math.sin(n.rotation),i=new b(e*s,e*o),a=new b(-r*o,r*s),l=i.applyMatrix3(t),h=a.applyMatrix3(t),u=$o.set(l.x,h.x,0,l.y,h.y,0,0,0,1),c=Us.copy(u).invert(),g=ks.copy(c).transpose().multiply(c).elements,m=ko(g[0],g[1],g[4]),p=Math.sqrt(m.rt1),C=Math.sqrt(m.rt2);if(n.radiusX=1/p,n.radiusY=1/C,n.rotation=Math.atan2(m.sn,m.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=Us.set(p,0,0,0,C,0,0,0,1),P=ks.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),w=v.multiply(P).multiply(u),x=T=>{const{x:_,y:O}=new b(Math.cos(T),Math.sin(T)).applyMatrix3(w);return Math.atan2(O,_)};n.startAngle=x(n.startAngle),n.endAngle=x(n.endAngle),Ls(t)&&(n.clockwise=!n.clockwise)}}function Eo(n,t){const e=Fs(t),r=zs(t);n.radiusX*=e,n.radiusY*=r;const s=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);n.rotation+=s,Ls(t)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function Ls(n){const t=n.elements;return t[0]*t[4]-t[1]*t[3]<0}function Uo(n){const t=n.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const r=Fs(n),s=zs(n);return Math.abs(e/(r*s))>Number.EPSILON}function Fs(n){const t=n.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function zs(n){const t=n.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function ko(n,t,e){let r,s,o,i,a;const l=n+e,h=n-e,u=Math.sqrt(h*h+4*t*t);return l>0?(r=.5*(l+u),a=1/r,s=n*a*e-t*a*t):l<0?s=.5*(l-u):(r=.5*u,s=-.5*u),h>0?o=h+u:o=h-u,Math.abs(o)>2*Math.abs(t)?(a=-2*t/o,i=1/Math.sqrt(1+a*a),o=a*i):Math.abs(t)===0?(o=1,i=0):(a=-.5*o/t,o=1/Math.sqrt(1+a*a),i=a*o),h>0&&(a=o,o=-i,i=a),{rt1:r,rt2:s,cs:o,sn:i}}class _r extends Zt{constructor(t=new b,e=new b){super(),this.start=t,this.end=e}getPoint(t,e=new b){return t===1?e.copy(this.end):e.copy(this.end).sub(this.start).scale(t).add(this.start),e}getPointAt(t,e=new b){return this.getPoint(t,e)}getTangent(t,e=new b){return e.subVectors(this.end,this.start).normalize()}getTangentAt(t,e=new b){return this.getTangent(t,e)}getControlPoints(){return[this.start,this.end]}getMinMax(t=b.MAX,e=b.MIN){const{start:r,end:s}=this;return t.x=Math.min(t.x,r.x,s.x),t.y=Math.min(t.y,r.y,s.y),e.x=Math.max(e.x,r.x,s.x),e.y=Math.max(e.y,r.y,s.y),{min:t,max:e}}toCommands(){const{start:t,end:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}drawTo(t){const{start:e,end:r}=this;return t.lineTo(e.x,e.y),t.lineTo(r.x,r.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.end.copy(t.end),this}}class Lo extends Zt{constructor(t=new b,e=new b,r=new b){super(),this.start=t,this.control=e,this.end=r}getPoint(t,e=new b){const{start:r,control:s,end:o}=this;return e.set(Ds(t,r.x,s.x,o.x),Ds(t,r.y,s.y,o.y)),e}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(t=b.MAX,e=b.MIN){const{start:r,control:s,end:o}=this,i=.5*(r.x+s.x),a=.5*(r.y+s.y),l=.5*(r.x+o.x),h=.5*(r.y+o.y);return t.x=Math.min(t.x,r.x,o.x,i,l),t.y=Math.min(t.y,r.y,o.y,a,h),e.x=Math.max(e.x,r.x,o.x,i,l),e.y=Math.max(e.y,r.y,o.y,a,h),{min:t,max:e}}toCommands(){const{start:t,control:e,end:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:r.x,y:r.y}]}drawTo(t){const{start:e,control:r,end:s}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(r.x,r.y,s.x,s.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.control.copy(t.control),this.end.copy(t.end),this}}var Fo=Object.defineProperty,zo=(n,t,e)=>t in n?Fo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ns=(n,t,e)=>(zo(n,typeof t!="symbol"?t+"":t,e),e);class No extends Zt{constructor(t,e,r=1,s=0,o=1){super(),this.center=t,this.rx=e,this.aspectRatio=r,this.start=s,this.end=o,Ns(this,"curves",[]),Ns(this,"curveT",0),this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:e}=this.center,r=this.rx,s=this.rx/this.aspectRatio,o=[new b(t-r,e-s),new b(t+r,e-s),new b(t+r,e+s),new b(t-r,e+s)];for(let i=0;i<4;i++)this.curves.push(new _r(o[i].clone(),o[(i+1)%4].clone()));return this}getCurve(t){let e=(t*(this.end-this.start)+this.start)%1;e<0&&(e+=1),e*=(1+this.aspectRatio)*2;let r;return e<this.aspectRatio?(r=0,this.curveT=e/this.aspectRatio):e<this.aspectRatio+1?(r=1,this.curveT=(e-this.aspectRatio)/1):e<2*this.aspectRatio+1?(r=2,this.curveT=(e-this.aspectRatio-1)/this.aspectRatio):(r=3,this.curveT=(e-2*this.aspectRatio-1)/1),this.curves[r]}getPoint(t,e){return this.getCurve(t).getPoint(this.curveT,e)}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){return this.getCurve(t).getTangent(this.curveT,e)}getNormal(t,e){return this.getCurve(t).getNormal(this.curveT,e)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=b.MAX,e=b.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(e=>e.drawTo(t)),this}}class qo extends Zt{constructor(t=[]){super(),this.points=t}getPoint(t,e=new b){const{points:r}=this,s=(r.length-1)*t,o=Math.floor(s),i=s-o,a=r[o===0?o:o-1],l=r[o],h=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return e.set(Bs(i,a.x,l.x,h.x,u.x),Bs(i,a.y,l.y,h.y,u.y)),e}getControlPoints(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++)this.points.push(t.points[e].clone());return this}}var Go=Object.defineProperty,Ro=(n,t,e)=>t in n?Go(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_e=(n,t,e)=>(Ro(n,typeof t!="symbol"?t+"":t,e),e);class Me extends Zt{constructor(t){super(),_e(this,"curves",[]),_e(this,"startPoint"),_e(this,"currentPoint",new b),_e(this,"autoClose",!1),_e(this,"_cacheLengths",[]),t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++){const{x:s,y:o}=t[e];this.lineTo(s,o)}return this}addCommands(t){return Is(t,this),this}addData(t){return this.addCommands($s(t)),this}getPoint(t,e=new b){const r=t*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=r){const i=s[o]-r,a=this.curves[o],l=a.getLength();return a.getPointAt(l===0?0:1-i/l,e)}o++}return e}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let e=0;for(let r=0,s=this.curves.length;r<s;r++)e+=this.curves[r].getLength(),t.push(e);return this._cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[],r=this.curves;let s;for(let o=0,i=r.length;o<i;o++){const l=r[o].getPoints(t);for(let h=0;h<l.length;h++){const u=l[h];s!=null&&s.equals(u)||(e.push(u),s=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;t.equals(e)||(this.curves.push(new _r(e.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint.set(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){return this.currentPoint.equals({x:t,y:e})||this.curves.push(new _r(this.currentPoint.clone(),new b(t,e))),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,r,s,o,i){return this.currentPoint.equals({x:o,y:i})||this.curves.push(new Io(this.currentPoint.clone(),new b(t,e),new b(r,s),new b(o,i))),this._setCurrentPoint({x:o,y:i}),this}quadraticCurveTo(t,e,r,s){return this.currentPoint.equals({x:r,y:s})||this.curves.push(new Lo(this.currentPoint.clone(),new b(t,e),new b(r,s))),this._setCurrentPoint({x:r,y:s}),this}arc(t,e,r,s,o,i){return this.ellipse(t,e,r,r,0,s,o,i),this}relativeArc(t,e,r,s,o,i){const a=this.currentPoint;return this.arc(t+a.x,e+a.y,r,s,o,i),this}arcTo(t,e,r,s,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,r,s,o,i,a,l=!0){const h=new Bo(new b(t,e),r,s,o,i,a,!l);if(this.curves.length>0){const u=h.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}return this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeEllipse(t,e,r,s,o,i,a,l){const h=this.currentPoint;return this.ellipse(t+h.x,e+h.y,r,s,o,i,a,l),this}rect(t,e,r,s){return this.curves.push(new No(new b(t+r/2,e+s/2),r/2,r/s)),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){return this.curves.push(new qo([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=b.MAX,e=b.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new q(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var r;const e=(r=this.curves[0])==null?void 0:r.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++)this.curves.push(t.curves[e].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Wo(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Vo(n,t,e,r){const s=t.clone().sub(n),o=r.clone().sub(e),i=e.clone().sub(n),a=s.cross(o);if(a===0)return new b((n.x+e.x)/2,(n.y+e.y)/2);const l=i.cross(o)/a;return Math.abs(l)>1?new b((n.x+e.x)/2,(n.y+e.y)/2):new b(n.x+l*s.x,n.y+l*s.y)}var Xo=Object.defineProperty,jo=(n,t,e)=>t in n?Xo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mr=(n,t,e)=>(jo(n,typeof t!="symbol"?t+"":t,e),e);class Pt{constructor(t,e={}){Mr(this,"currentPath",new Me),Mr(this,"paths",[this.currentPath]),Mr(this,"style"),t&&(t instanceof Pt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t)),this.style=e}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){return t instanceof Pt?this.paths.push(...t.paths.map(e=>e.clone())):this.paths.push(t),this}closePath(){const t=this.startPoint;return t&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new Me().moveTo(t.x,t.y),this.paths.push(this.currentPath))),this}moveTo(t,e){const{currentPoint:r,curves:s}=this.currentPath;return r.equals({x:t,y:e})||(s.length?(this.currentPath=new Me().moveTo(t,e),this.paths.push(this.currentPath)):this.currentPath.moveTo(t,e)),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}bezierCurveTo(t,e,r,s,o,i){return this.currentPath.bezierCurveTo(t,e,r,s,o,i),this}quadraticCurveTo(t,e,r,s){return this.currentPath.quadraticCurveTo(t,e,r,s),this}arc(t,e,r,s,o,i){return this.currentPath.arc(t,e,r,s,o,i),this}arcTo(t,e,r,s,o){return this.currentPath.arcTo(t,e,r,s,o),this}ellipse(t,e,r,s,o,i,a,l){return this.currentPath.ellipse(t,e,r,s,o,i,a,l),this}rect(t,e,r,s){return this.currentPath.rect(t,e,r,s),this}addCommands(t){return Is(t,this),this}addData(t){return this.addCommands($s(t)),this}splineThru(t){return this.currentPath.splineThru(t),this}getControlPoints(){return this.paths.flatMap(t=>t.getControlPoints())}getCurves(){return this.paths.flatMap(t=>t.curves)}scale(t,e=t,r={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.scale(t,e,r)}),this}skew(t,e=0,r={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.skew(t,e,r)}),this}rotate(t,e={x:0,y:0}){return this.getControlPoints().forEach(r=>{r.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getCurves(),r=[],s=[],o=[];e.forEach((a,l)=>{const h=a.getControlPoints(),u=a.isClockwise();o[l]=h,s[l]=u;const c=h[0],f=h[h.length-1]??c;r.push({start:u?f:c,end:u?c:f,index:l})});const i=[];return r.forEach((a,l)=>{i[l]=[],r.forEach((h,u)=>{u!==l&&h.start.equals(a.end)&&i[l].push(h.index)})}),e.forEach((a,l)=>{const h=s[l];o[l].forEach(c=>{const f=a.getTForPoint(c),d=a.getNormal(f).scale(h?t:-t);c.add(d)})}),i.forEach((a,l)=>{const h=o[l];a.forEach(u=>{const c=o[u],f=Vo(h[h.length-1],h[h.length-2]??h[h.length-1],c[0],c[1]??c[0]);f&&(h[h.length-1].copy(f),c[0].copy(f))})}),this}matrix(t){return this.getCurves().forEach(e=>e.matrix(t)),this}getMinMax(t=b.MAX,e=b.MIN,r=!0){const s=this.strokeWidth;return this.getCurves().forEach(o=>{if(o.getMinMax(t,e),r&&s>1){const i=s/2,a=o.isClockwise(),l=[];for(let h=0;h<=1;h+=1/o.arcLengthDivisions){const u=o.getPoint(h),c=o.getNormal(h),f=c.clone().scale(a?i:-i),d=c.clone().scale(a?-i:i);l.push(u.clone().add(f),u.clone().add(d),u.clone().add({x:i,y:0}),u.clone().add({x:-i,y:0}),u.clone().add({x:0,y:i}),u.clone().add({x:0,y:-i}),u.clone().add({x:i,y:i}),u.clone().add({x:-i,y:-i}))}t.min(...l),e.max(...l)}}),{min:t,max:e}}getBoundingBox(t=!0){const{min:e,max:r}=this.getMinMax(void 0,void 0,t);return new q(e.x,e.y,r.x-e.x,r.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:s="none"}=e;return t.beginPath(),t.save(),Sr(t,e),this.paths.forEach(o=>{o.drawTo(t)}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:s="none"}=e;return t.beginPath(),t.save(),Sr(t,e),this.getControlPoints().forEach(o=>{t.moveTo(o.x,o.y),t.arc(o.x,o.y,4,0,Math.PI*2)}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.paths.flatMap(t=>t.toCommands())}toData(){return this.paths.map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const s in t)t[s]!==void 0&&(e[Wo(s)]=t[s]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const s in e)e[s]!==void 0&&(r+=`${s}:${e[s]};`);return`<path d="${this.toData()}" style="${r}"></path>`}toSvgString(){const{x:t,y:e,width:r,height:s}=this.getBoundingBox(),o=this.toSvgPathString();return`<svg viewBox="${t} ${e} ${r} ${s}" width="${r}px" height="${s}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...r}=t,{left:s,top:o,width:i,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=i*e,l.height=a*e,l.style.width=`${i}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(e,e),h.translate(-s,-o),this.drawTo(h,r)),l}copy(t){return this.currentPath=t.currentPath.clone(),this.paths=t.paths.map(e=>e.clone()),this.style={...t.style},this}clone(){return new this.constructor().copy(this)}}const Tr="px",qs=90,Gs=["mm","cm","in","pt","pc","px"],Or={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function R(n){let t="px";if(typeof n=="string"||n instanceof String)for(let r=0,s=Gs.length;r<s;r++){const o=Gs[r];if(n.endsWith(o)){t=o,n=n.substring(0,n.length-o.length);break}}let e;return t==="px"&&Tr!=="px"?e=Or.in[Tr]/qs:(e=Or[t][Tr],e<0&&(e=Or[t].in*qs)),e*Number.parseFloat(n)}const Ho=new St,He=new St,Rs=new St,Ws=new St;function Yo(n,t,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const r=Zo(n);return e.length>0&&r.premultiply(e[e.length-1]),t.copy(r),e.push(r),r}function Zo(n){const t=new St,e=Ho;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&t.translate(R(n.getAttribute("x")),R(n.getAttribute("y"))),n.hasAttribute("transform")){const r=n.getAttribute("transform").split(")");for(let s=r.length-1;s>=0;s--){const o=r[s].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const l=o.slice(0,i),h=Et(o.slice(i+1));switch(e.identity(),l){case"translate":if(h.length>=1){const u=h[0];let c=0;h.length>=2&&(c=h[1]),e.translate(u,c)}break;case"rotate":if(h.length>=1){let u=0,c=0,f=0;u=h[0]*Math.PI/180,h.length>=3&&(c=h[1],f=h[2]),He.makeTranslation(-c,-f),Rs.makeRotation(u),Ws.multiplyMatrices(Rs,He),He.makeTranslation(c,f),e.multiplyMatrices(He,Ws)}break;case"scale":h.length>=1&&e.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&e.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&e.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&e.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}t.premultiply(e)}}return t}function Ko(n){return new Pt().addPath(new Me().arc(R(n.getAttribute("cx")||0),R(n.getAttribute("cy")||0),R(n.getAttribute("r")||0),0,Math.PI*2))}function Qo(n,t){if(!(!n.sheet||!n.sheet.cssRules||!n.sheet.cssRules.length))for(let e=0;e<n.sheet.cssRules.length;e++){const r=n.sheet.cssRules[e];if(r.type!==1)continue;const s=r.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),o={};for(let i=r.style.length,a=0;a<i;a++){const l=r.style.item(a);o[l]=r.style.getPropertyValue(l)}for(let i=0;i<s.length;i++)t[s[i]]=Object.assign(t[s[i]]||{},{...o})}}function Jo(n){return new Pt().addPath(new Me().ellipse(R(n.getAttribute("cx")||0),R(n.getAttribute("cy")||0),R(n.getAttribute("rx")||0),R(n.getAttribute("ry")||0),0,0,Math.PI*2))}function ta(n){return new Pt().moveTo(R(n.getAttribute("x1")||0),R(n.getAttribute("y1")||0)).lineTo(R(n.getAttribute("x2")||0),R(n.getAttribute("y2")||0))}function ea(n){const t=new Pt,e=n.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const ra=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function sa(n){var r;const t=new Pt;let e=0;return(r=n.getAttribute("points"))==null||r.replace(ra,(s,o,i)=>{const a=R(o),l=R(i);return e===0?t.moveTo(a,l):t.lineTo(a,l),e++,s}),t.currentPath.autoClose=!0,t}const na=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ia(n){var r;const t=new Pt;let e=0;return(r=n.getAttribute("points"))==null||r.replace(na,(s,o,i)=>{const a=R(o),l=R(i);return e===0?t.moveTo(a,l):t.lineTo(a,l),e++,s}),t.currentPath.autoClose=!1,t}function oa(n){const t=R(n.getAttribute("x")||0),e=R(n.getAttribute("y")||0),r=R(n.getAttribute("rx")||n.getAttribute("ry")||0),s=R(n.getAttribute("ry")||n.getAttribute("rx")||0),o=R(n.getAttribute("width")),i=R(n.getAttribute("height")),a=1-.551915024494,l=new Pt;return l.moveTo(t+r,e),l.lineTo(t+o-r,e),(r!==0||s!==0)&&l.bezierCurveTo(t+o-r*a,e,t+o,e+s*a,t+o,e+s),l.lineTo(t+o,e+i-s),(r!==0||s!==0)&&l.bezierCurveTo(t+o,e+i-s*a,t+o-r*a,e+i,t+o-r,e+i),l.lineTo(t+r,e+i),(r!==0||s!==0)&&l.bezierCurveTo(t+r*a,e+i,t,e+i-s*a,t,e+i-s),l.lineTo(t,e+s),(r!==0||s!==0)&&l.bezierCurveTo(t,e+s*a,t+r*a,e,t+r,e),l}function Ut(n,t,e){t=Object.assign({},t);let r={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(u=>u.trim());for(let u=0;u<h.length;u++)r=Object.assign(r,e[`.${h[u]}`])}n.hasAttribute("id")&&(r=Object.assign(r,e[`#${n.getAttribute("id")}`]));for(let h=n.style.length,u=0;u<h;u++){const c=n.style.item(u),f=n.style.getPropertyValue(c);t[c]=f,r[c]=f}function s(h,u,c=o){n.hasAttribute(h)&&(t[u]=c(n.getAttribute(h))),r[h]&&(t[u]=c(r[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function i(h){return Math.max(0,Math.min(1,R(h)))}function a(h){return Math.max(0,R(h))}function l(h){return h.split(" ").filter(u=>u!=="").map(u=>R(u))}return s("fill","fill"),s("fill-opacity","fillOpacity",i),s("fill-rule","fillRule"),s("opacity","opacity",i),s("stroke","stroke"),s("stroke-opacity","strokeOpacity",i),s("stroke-width","strokeWidth",a),s("stroke-linecap","strokeLinecap"),s("stroke-linejoin","strokeLinejoin"),s("stroke-miterlimit","strokeMiterlimit",a),s("stroke-dasharray","strokeDasharray",l),s("stroke-dashoffset","strokeDashoffset",R),s("visibility","visibility"),t}function Ar(n,t,e=[],r={}){var c;if(n.nodeType!==1)return e;let s=!1,o=null,i={...t};switch(n.nodeName){case"svg":i=Ut(n,i,r);break;case"style":Qo(n,r);break;case"g":i=Ut(n,i,r);break;case"path":i=Ut(n,i,r),n.hasAttribute("d")&&(o=ea(n));break;case"rect":i=Ut(n,i,r),o=oa(n);break;case"polygon":i=Ut(n,i,r),o=sa(n);break;case"polyline":i=Ut(n,i,r),o=ia(n);break;case"circle":i=Ut(n,i,r),o=Ko(n);break;case"ellipse":i=Ut(n,i,r),o=Jo(n);break;case"line":i=Ut(n,i,r),o=ta(n);break;case"defs":s=!0;break;case"use":{i=Ut(n,i,r);const d=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),g=(c=n.viewportElement)==null?void 0:c.getElementById(d);g?Ar(g,i,e,r):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(n);break}if(i.display==="none")return e;Object.assign(t,i);const a=new St,l=[],h=Yo(n,a,l);o&&(o.matrix(a),e.push(o),o.style=t);const u=n.childNodes;for(let f=0,d=u.length;f<d;f++){const g=u[f];s&&g.nodeName!=="style"&&g.nodeName!=="defs"||Ar(g,t,e,r)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),e}const Vs="data:image/svg+xml;",Xs=`${Vs}base64,`,js=`${Vs}charset=utf8,`;function Hs(n){if(typeof n=="string"){let t;return n.startsWith(Xs)?(n=n.substring(Xs.length,n.length),t=atob(n)):n.startsWith(js)?(n=n.substring(js.length,n.length),t=decodeURIComponent(n)):t=n,new DOMParser().parseFromString(t,"image/svg+xml").documentElement}else return n}function Ys(n){return Ar(Hs(n),{})}function Te(n,t=!0){if(!n.length)return;const e=b.MAX,r=b.MIN;return n.forEach(s=>s.getMinMax(e,r,t)),new q(e.x,e.y,r.x-e.x,r.y-e.y)}const aa=new Set(["©","®","÷"]),la=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),ha={1:"italic",32:"bold"},ca={1:"italic",2:"bold"},Zs={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Ks{constructor(t,e,r){B(this,"path",new Pt);B(this,"lineBox",new q);B(this,"inlineBox",new q);B(this,"glyphBox");B(this,"advanceWidth",0);B(this,"advanceHeight",0);B(this,"underlinePosition",0);B(this,"underlineThickness",0);B(this,"strikeoutPosition",0);B(this,"strikeoutSize",0);B(this,"ascender",0);B(this,"descender",0);B(this,"typoAscender",0);B(this,"typoDescender",0);B(this,"typoLineGap",0);B(this,"winAscent",0);B(this,"winDescent",0);B(this,"xHeight",0);B(this,"capHeight",0);B(this,"baseline",0);B(this,"centerDiviation",0);B(this,"fontStyle");this.content=t,this.index=e,this.parent=r}get center(){var t;return(t=this.glyphBox)==null?void 0:t.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(t){const e=this.computedStyle.fontFamily,r=t??fo,s=e?r.get(e):r.fallbackFont;return s==null?void 0:s.getSfnt()}updateGlyph(t=this._getFontSfnt()){if(!t)return this;const{hhea:e,os2:r,post:s,head:o}=t,i=o.unitsPerEm,a=e.ascent,l=e.descent,{content:h,computedStyle:u,isVertical:c}=this,{fontSize:f}=u,d=i/f,g=t.getAdvanceWidth(h,f),m=(a+Math.abs(l))/d,p=a/d;return this.advanceWidth=g,this.advanceHeight=m,this.inlineBox.width=c?m:g,this.inlineBox.height=c?g:m,this.underlinePosition=(a-s.underlinePosition)/d,this.underlineThickness=s.underlineThickness/d,this.strikeoutPosition=(a-r.yStrikeoutPosition)/d,this.strikeoutSize=r.yStrikeoutSize/d,this.ascender=a/d,this.descender=l/d,this.typoAscender=r.sTypoAscender/d,this.typoDescender=r.sTypoDescender/d,this.typoLineGap=r.sTypoLineGap/d,this.winAscent=r.usWinAscent/d,this.winDescent=r.usWinDescent/d,this.xHeight=r.sxHeight/d,this.capHeight=r.sCapHeight/d,this.baseline=p,this.centerDiviation=m/2-p,this.fontStyle=ha[r.fsSelection]??ca[o.macStyle],this}update(t){const e=this._getFontSfnt(t);if(!e)return this;this.updateGlyph(e);const{isVertical:r,content:s,computedStyle:o,baseline:i,inlineBox:a,ascender:l,descender:h,typoAscender:u,fontStyle:c,advanceWidth:f,advanceHeight:d}=this,{left:g,top:m}=a,p=o.fontStyle==="italic"&&c!=="italic";let C=g,S=m+i,v;const P=new Pt;if(r&&(C+=(d-f)/2,Math.abs(f-d)>.1&&(S-=(l-u)/(l+Math.abs(h))*d),v=void 0),r&&!aa.has(s)&&(s.codePointAt(0)<=256||la.has(s))){P.addCommands(e.getPathCommands(s,C,m+i-(d-f)/2,o.fontSize));const x={y:m-(d-f)/2+d/2,x:C+f/2};p&&this._italic(P,r?{x:x.x,y:m-(d-f)/2+i}:void 0),P.rotate(90,x)}else v!==void 0?(P.addCommands(e.glyphs.get(v).getPathCommands(C,S,o.fontSize)),p&&this._italic(P,r?{x:C+f/2,y:m+u/(l+Math.abs(h))*d}:void 0)):(P.addCommands(e.getPathCommands(s,C,S,o.fontSize)),p&&this._italic(P,r?{x:C+d/2,y:S}:void 0));const w=o.fontWeight??400;return w in Zs&&(w===700||w==="bold")&&c!=="bold"&&P.bold(Zs[w]*o.fontSize*.05),P.style={fill:o.color,stroke:o.textStrokeWidth?o.textStrokeColor:"none",strokeWidth:o.textStrokeWidth?o.textStrokeWidth*o.fontSize*.03:0},this.path=P,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(t,e){t.skew(-.24,0,e||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(t,e,r){var s;if((s=this.path.paths[0])!=null&&s.curves.length)return this.path.getMinMax(t,e,r)}getGlyphBoundingBox(t){const e=this.getGlyphMinMax(void 0,void 0,t);if(!e)return;const{min:r,max:s}=e;return new q(r.x,r.y,s.x-r.x,s.y-r.y)}drawTo(t,e={}){const r=this.computedStyle,s={ctx:t,path:this.path,fontSize:r.fontSize,color:r.color,...e};if(this.glyphBox)te(s);else{t.save(),t.beginPath();const o=this.path.style,i={...o,fill:s.color??o.fill,stroke:s.textStrokeColor??o.stroke,strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize:o.strokeWidth,shadowOffsetX:(s.shadowOffsetX??0)*s.fontSize,shadowOffsetY:(s.shadowOffsetY??0)*s.fontSize,shadowBlur:(s.shadowBlur??0)*s.fontSize,shadowColor:s.shadowColor};Sr(t,i),t.font=`${s.fontSize}px ${s.fontFamily}`,this.isVertical?(t.textBaseline="middle",t.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(t.textBaseline="alphabetic",t.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),t.restore()}}}function Ye(n,t){return typeof n=="number"?n:n.endsWith("%")?(n=n.substring(0,n.length-1),Math.ceil(Number(n)/100*t.total)):n.endsWith("rem")?(n=n.substring(0,n.length-3),Number(n)*t.fontSize):n.endsWith("em")?(n=n.substring(0,n.length-2),Number(n)*t.fontSize):Number(n)}function Ir(n){const t=Nt(n)?{}:n;return Object.keys(t).reduce((e,r)=>{let s=t[r];const o=$r(r),i=$r(s);return o&&(r=o),i&&(s=i),e[r]=s,e},{})}function Nt(n){return!n||n==="none"}function Qs(n,t){const e=Object.keys(n),r=Object.keys(t);return Array.from(new Set([...e,...r])).every(o=>Kt(n[o],t[o]))}function Kt(n,t){const e=typeof n;return e===typeof t?e==="object"?Qs(n,t):n===t:!1}function $r(n){const t=n.startsWith("#")?n.slice(1):n;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(t))return null;const r=t.length===3?t.split("").map(a=>a+a).join(""):t,s=Number.parseInt(r.slice(0,2),16),o=Number.parseInt(r.slice(2,4),16),i=Number.parseInt(r.slice(4,6),16);return`rgb(${s}, ${o}, ${i})`}function Ze(n){if(!n)return n;const t={};for(const e in n)n[e]!==""&&n[e]!==void 0&&(t[e]=n[e]);return t}class Js{constructor(t,e={},r){B(this,"inlineBox",new q);this.content=t,this.style=e,this.parent=r,this.updateComputedStyle().initCharacters()}get computedContent(){const t=this.computedStyle;return t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Ze(this.style)},this}initCharacters(){const t=[];let e=0;for(const r of this.computedContent)t.push(new Ks(r,e++,this));return this.characters=t,this}}class ae{constructor(t,e){B(this,"lineBox",new q);B(this,"fragments",[]);this.style=t,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Ze(this.parentStyle),...Ze(this.style)},this}addFragment(t,e){const r=new Js(t,e,this);return this.fragments.push(r),r}}function ua(n){return n}class tn{constructor(t){this._text=t}_styleToDomStyle(t){const e={...t};for(const r in t)["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur"].includes(r)?e[r]=`${t[r]}px`:e[r]=t[r];return e}createDom(){const{paragraphs:t,computedStyle:e}=this._text,r=document.createDocumentFragment(),s=document.createElement("section");Object.assign(s.style,{width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(e),position:"fixed",visibility:"hidden"});const o=document.createElement("ul");return Object.assign(o.style,{listStyleType:"inherit",padding:"0",margin:"0"}),t.forEach(i=>{const a=document.createElement("li");Object.assign(a.style,this._styleToDomStyle(i.style)),i.fragments.forEach(l=>{const h=document.createElement("span");Object.assign(h.style,this._styleToDomStyle(l.style)),h.appendChild(document.createTextNode(l.content)),a.appendChild(h)}),o.appendChild(a)}),s.appendChild(o),r.appendChild(s),document.body.appendChild(r),{dom:s,destory:()=>{var i;return(i=s.parentNode)==null?void 0:i.removeChild(s)}}}_measureDom(t){const e=[],r=[],s=[];return t.querySelectorAll("li").forEach((o,i)=>{const a=o.getBoundingClientRect();e.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),o.querySelectorAll("span").forEach((l,h)=>{const u=l.getBoundingClientRect();r.push({paragraphIndex:i,fragmentIndex:h,left:u.left,top:u.top,width:u.width,height:u.height});const c=l.firstChild;if(c instanceof window.Text){const f=document.createRange();f.selectNodeContents(c);const d=c.data??"";Array.from(d).forEach((g,m)=>{var w;const p=d.indexOf(g),C=p+g.length;f.setStart(c,Math.max(p,0)),f.setEnd(c,C);const S=((w=f.getClientRects)==null?void 0:w.call(f))??[f.getBoundingClientRect()];let v=S[S.length-1];S.length>1&&v.width<2&&(v=S[S.length-2]);const P=f.toString();P!==""&&v&&v.width+v.height!==0&&s.push({content:P,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:h,characterIndex:m,top:v.top,left:v.left,height:v.height,width:v.width,textWidth:-1,textHeight:-1})})}})}),{paragraphs:e,fragments:r,characters:s}}measureDom(t){const{paragraphs:e}=this._text,r=t.getBoundingClientRect(),s=this._measureDom(t);s.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),s.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const o=[];let i=0;return s.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:u}=a;o.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const c=e[l].fragments[h].characters[u],{fontHeight:f,isVertical:d}=c,g=o[i];c.inlineBox.left=g.left,c.inlineBox.top=g.top,c.inlineBox.width=g.width,c.inlineBox.height=g.height,d?(c.lineBox.left=g.left+(g.width-f)/2,c.lineBox.top=g.top,c.lineBox.width=f,c.lineBox.height=g.height):(c.lineBox.left=g.left,c.lineBox.top=g.top+(g.height-f)/2,c.lineBox.width=g.width,c.lineBox.height=f),i++}),{paragraphs:e,boundingBox:new q(0,0,r.width,r.height)}}measure(t){let e;t||({dom:t,destory:e}=this.createDom());const r=this.measureDom(t);return e==null||e(),r}}class fa{constructor(){B(this,"eventListeners",new Map)}addEventListener(t,e,r){const s={value:e,options:r},o=this.eventListeners.get(t);return o?Array.isArray(o)?o.push(s):this.eventListeners.set(t,[o,s]):this.eventListeners.set(t,s),this}removeEventListener(t,e,r){var o,i;if(!e)return this.eventListeners.delete(t),this;const s=this.eventListeners.get(t);if(!s)return this;if(Array.isArray(s)){const a=[];for(let l=0,h=s.length;l<h;l++){const u=s[l];(u.value!==e||typeof r=="object"&&(r!=null&&r.once)&&(typeof u.options=="boolean"||!((o=u.options)!=null&&o.once)))&&a.push(u)}a.length?this.eventListeners.set(t,a.length===1?a[0]:a):this.eventListeners.delete(t)}else s.value===e&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof s.options=="boolean"||(i=s.options)!=null&&i.once)&&this.eventListeners.delete(t);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(t){return this.eventListeners.has(t)}dispatchEvent(t,e){var s,o;const r=this.eventListeners.get(t);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const l=r[a];typeof l.options=="object"&&((s=l.options)!=null&&s.once)&&this.off(t,l.value,l.options),l.value.apply(this,[e])}else typeof r.options=="object"&&((o=r.options)!=null&&o.once)&&this.off(t,r.value,r.options),r.value.apply(this,[e]);return!0}else return!1}on(t,e,r){return this.addEventListener(t,e,r)}once(t,e){return this.addEventListener(t,e,{once:!0})}off(t,e,r){return this.removeEventListener(t,e,r)}emit(t,e){this.dispatchEvent(t,e)}}function en(){const n=[],t=[],e=new Map;async function r(s){let o=e.get(s);if(!o){s.startsWith("http")&&(s=await fetch(s).then(l=>l.text()));const i=Hs(s),a=Ys(i);o={dom:i,paths:a},e.set(s,o)}return o}return{name:"highlight",paths:n,update:async s=>{n.length=0;let o=[],i,a;s.forEachCharacter(l=>{const{isVertical:h,computedStyle:u,inlineBox:c}=l;!Nt(u.highlightImage)&&l.glyphBox?(!a||Kt(a.highlightImage,u.highlightImage)&&Kt(a.highlightColormap,u.highlightColormap)&&Kt(a.highlightLine,u.highlightLine)&&Kt(a.highlightSize,u.highlightSize)&&Kt(a.highlightThickness,u.highlightThickness))&&(i!=null&&i.length)&&(h?i[0].inlineBox.left===c.left:i[0].inlineBox.top===c.top)&&i[0].fontSize===u.fontSize?i.push(l):(i=[],i.push(l),o.push(i)):i!=null&&i.length&&(i=[],o.push(i)),a=u}),o=o.filter(l=>l.length);for(let l=0;l<o.length;l++){const h=o[l],u=h[0],c=q.from(...h.map(D=>D.glyphBox)),{computedStyle:f}=u,{fontSize:d,writingMode:g,highlightImage:m,highlightReferImage:p,highlightColormap:C,highlightLine:S,highlightSize:v,highlightThickness:P}=f,w=g.includes("vertical"),x=Ye(P,{fontSize:d,total:c.width})/c.width,T=Ir(C),{paths:_,dom:O}=await r(m),E=Te(_,!0),N=d/E.width*2,M=new q().copy(c);w&&(M.width=c.height,M.height=c.width,M.left=c.left+c.width);const gt=Math.floor(M.width);let U=gt;if(v!=="cover"&&(U=Ye(v,{fontSize:d,total:c.width}),M.width=U),!Nt(p)&&Nt(S)){const D=Te((await r(p)).paths,!0);E.copy(D)}else{let D;if(Nt(S))if(E.width/E.height>4){D="underline";const k=O.getAttribute("viewBox");if(k){const[V,A,bt,W]=k.split(" ").map(G=>Number(G)),Y=A+W/2;E.y<Y&&E.y+E.height>Y?D="line-through":E.y+E.height<Y?D="overline":D="underline"}}else D="outline";else D=S;switch(D){case"outline":{const k=M.width*.2,V=M.height*.2;M.width+=k,M.height+=V,w?(M.x-=V/2,M.y-=k/2,M.x+=M.height):(M.x-=k/2,M.y-=V/2);break}case"overline":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width:M.y=u.inlineBox.top;break;case"line-through":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width-u.strikeoutPosition+M.height/2:M.y=u.inlineBox.top+u.strikeoutPosition-M.height/2;break;case"underline":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width-u.underlinePosition:M.y=u.inlineBox.top+u.underlinePosition;break}}const z=new St().translate(-E.x,-E.y).scale(M.width/E.width,M.height/E.height);w&&z.rotate(-Math.PI/2),z.translate(M.x,M.y);for(let D=0;D<Math.ceil(gt/U);D++){const k=z.clone();w?k.translate(0,D*M.width):k.translate(D*M.width,0),_.forEach(V=>{const A=V.clone().matrix(k);A.style.strokeWidth&&(A.style.strokeWidth*=N*x),A.style.strokeMiterlimit&&(A.style.strokeMiterlimit*=N),A.style.strokeDashoffset&&(A.style.strokeDashoffset*=N),A.style.strokeDasharray&&(A.style.strokeDasharray=A.style.strokeDasharray.map(bt=>bt*N)),A.style.fill&&A.style.fill in T&&(A.style.fill=T[A.style.fill]),A.style.stroke&&A.style.stroke in T&&(A.style.stroke=T[A.style.stroke]),n.push(A),gt!==U&&(w?t[n.length-1]=new q(c.left-c.width*2,c.top,c.width*4,c.height):t[n.length-1]=new q(c.left,c.top-c.height*2,c.width,c.height*4))})}}},renderOrder:-1,render:(s,o)=>{n.forEach((i,a)=>{if(te({ctx:s,path:i,fontSize:o.computedStyle.fontSize,clipRect:t[a]}),o.debug){const l=Te([i]);l&&s.strokeRect(l.x,l.y,l.width,l.height)}})}}}function rn(){const n=[];return{name:"listStyle",paths:n,update:t=>{n.length=0;const{paragraphs:e,isVertical:r,fontSize:s}=t,o=s*.45;e.forEach(i=>{const{computedStyle:a}=i,{listStyleImage:l,listStyleColormap:h,listStyleSize:u,listStyleType:c,color:f}=a,d=Ir(h);let g=u,m;if(!Nt(l))m=l;else if(!Nt(c)){const P=s*.38/2;switch(g=g==="cover"?P*2:g,c){case"disc":m=`<svg width="${P*2}" height="${P*2}" xmlns="http://www.w3.org/2000/svg">
4
+ }`)),document.head.appendChild(r),this}get(t){let e;return t&&(e=this.loaded.get(this.familyToUrl.get(t)??t)),e??this.fallbackFont}set(t,e){return this.familyToUrl.set(t,e.src),this.loaded.set(e.src,e),this}delete(t){const e=this.familyToUrl.get(t)??t;return this.familyToUrl.delete(e),this.loaded.delete(e),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(t,e={}){const{cancelOther:r,injectFontFace:s=!0,injectStyleTag:o=!0,...i}=e,{src:a}=t;if(this.loaded.has(a))return r&&(this.loading.forEach(f=>f.cancel()),this.loading.clear()),u(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,i),this.loading.set(a,l)),r&&this.loading.forEach((f,d)=>{f!==l&&(f.cancel(),this.loading.delete(d))}),l.when.then(f=>{if(this.loaded.has(a))return u(this.loaded.get(a));{const d=c(f);return e.noAdd||this.loaded.set(t.src,d),d.familySet.forEach(g=>{this.familyToUrl.set(g,a),typeof document<"u"&&(s&&this.injectFontFace(g,f),o&&this.injectStyleTag(g,a))}),d}}).catch(f=>{if(f instanceof DOMException&&f.message==="The user aborted a request.")return c();throw f}).finally(()=>{this.loading.delete(a)});function h(){return t.family?Array.isArray(t.family)?t.family:[t.family]:[]}function u(f){return h().forEach(d=>{f.familySet.add(d)}),f}function c(f=new ArrayBuffer(0)){let d;function g(){return d||(d=f.byteLength?lo(f,!1):void 0),d}function m(){const p=g();if(p instanceof It||p instanceof br)return p.sfnt}return{...t,buffer:f,familySet:new Set(h()),getFont:g,getSfnt:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(t=>t.when))}};Ce(Os,"defaultRequestInit",{cache:"force-cache"});let uo=Os;const fo=new uo,po={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Sr(n,t){const{fill:e="#000",stroke:r="none",strokeWidth:s=r==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:u=0,shadowOffsetY:c=0,shadowBlur:f=0,shadowColor:d="rgba(0, 0, 0, 0)"}=t;n.fillStyle=e,n.strokeStyle=r,n.lineWidth=s,n.lineCap=o,n.lineJoin=po[i],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=u,n.shadowOffsetY=c,n.shadowBlur=f,n.shadowColor=d}class b{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new b(1/0,1/0)}static get MIN(){return new b(-1/0,-1/0)}get array(){return[this.x,this.y]}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const r=-t/180*Math.PI,s=this.x-e.x,o=-(this.y-e.y),i=Math.sin(r),a=Math.cos(r);return this.set(e.x+(s*a-o*i),e.y-(s*i+o*a)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,r={x:0,y:0}){const s=t<0?r.x-this.x+r.x:this.x,o=e<0?r.y-this.y+r.y:this.y;return this.x=s*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,r={x:0,y:0}){const s=this.x-r.x,o=this.y-r.y;return this.x=r.x+(s+Math.tan(t)*o),this.y=r.y+(o+Math.tan(e)*s),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,r=this.y,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6],this.y=s[1]*e+s[4]*r+s[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new b(this.x,this.y)}}class q{constructor(t=0,e=0,r=0,s=0){this.left=t,this.top=e,this.width=r,this.height=s}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new b((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new q;if(t.length===1)return t[0].clone();const e=t[0],r=t.slice(1).reduce((s,o)=>(s.left=Math.min(s.left,o.left),s.top=Math.min(s.top,o.top),s.right=Math.max(s.right,o.right),s.bottom=Math.max(s.bottom,o.bottom),s),{left:(e==null?void 0:e.left)??0,top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0});return new q(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new q(this.left,this.top,this.width,this.height)}}var go=Object.defineProperty,yo=(n,t,e)=>t in n?go(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mo=(n,t,e)=>(yo(n,t+"",e),e);class St{constructor(t=1,e=0,r=0,s=0,o=1,i=0,a=0,l=0,h=1){mo(this,"elements",[]),this.set(t,e,r,s,o,i,a,l,h)}set(t,e,r,s,o,i,a,l,h){const u=this.elements;return u[0]=t,u[1]=s,u[2]=a,u[3]=e,u[4]=o,u[5]=l,u[6]=r,u[7]=i,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,s=e.elements,o=this.elements,i=r[0],a=r[3],l=r[6],h=r[1],u=r[4],c=r[7],f=r[2],d=r[5],g=r[8],m=s[0],p=s[3],C=s[6],S=s[1],v=s[4],P=s[7],w=s[2],x=s[5],T=s[8];return o[0]=i*m+a*S+l*w,o[3]=i*p+a*v+l*x,o[6]=i*C+a*P+l*T,o[1]=h*m+u*S+c*w,o[4]=h*p+u*v+c*x,o[7]=h*C+u*P+c*T,o[2]=f*m+d*S+g*w,o[5]=f*p+d*v+g*x,o[8]=f*C+d*P+g*T,this}invert(){const t=this.elements,e=t[0],r=t[1],s=t[2],o=t[3],i=t[4],a=t[5],l=t[6],h=t[7],u=t[8],c=u*i-a*h,f=a*l-u*o,d=h*o-i*l,g=e*c+r*f+s*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/g;return t[0]=c*m,t[1]=(s*h-u*r)*m,t[2]=(a*r-s*i)*m,t[3]=f*m,t[4]=(u*e-s*l)*m,t[5]=(s*o-a*e)*m,t[6]=d*m,t[7]=(r*l-h*e)*m,t[8]=(i*e-r*o)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(Pr.makeScale(t,e)),this}rotate(t){return this.premultiply(Pr.makeRotation(-t)),this}translate(t,e){return this.premultiply(Pr.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Pr=new St;function As(n,t,e,r){const s=n*e+t*r,o=Math.sqrt(n*n+t*t)*Math.sqrt(e*e+r*r);let i=Math.acos(Math.max(-1,Math.min(1,s/o)));return n*r-t*e<0&&(i=-i),i}function wo(n,t,e,r,s,o,i,a){if(t===0||e===0){n.lineTo(a.x,a.y);return}r=r*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const l=(i.x-a.x)/2,h=(i.y-a.y)/2,u=Math.cos(r)*l+Math.sin(r)*h,c=-Math.sin(r)*l+Math.cos(r)*h;let f=t*t,d=e*e;const g=u*u,m=c*c,p=g/f+m/d;if(p>1){const E=Math.sqrt(p);t=E*t,e=E*e,f=t*t,d=e*e}const C=f*m+d*g,S=(f*d-C)/C;let v=Math.sqrt(Math.max(0,S));s===o&&(v=-v);const P=v*t*c/e,w=-v*e*u/t,x=Math.cos(r)*P-Math.sin(r)*w+(i.x+a.x)/2,T=Math.sin(r)*P+Math.cos(r)*w+(i.y+a.y)/2,_=As(1,0,(u-P)/t,(c-w)/e),O=As((u-P)/t,(c-w)/e,(-u-P)/t,(-c-w)/e)%(Math.PI*2);n.ellipse(x,T,t,e,r,_,_+O,o===1)}function oe(n,t){return n-(t-n)}function Is(n,t){const e=new b,r=new b;for(let s=0,o=n.length;s<o;s++){const i=n[s];if(i.type==="m"||i.type==="M")i.type==="m"?e.add(i):e.copy(i),t.moveTo(e.x,e.y),r.copy(e);else if(i.type==="h"||i.type==="H")i.type==="h"?e.x+=i.x:e.x=i.x,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="v"||i.type==="V")i.type==="v"?e.y+=i.y:e.y=i.y,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="l"||i.type==="L")i.type==="l"?e.add(i):e.copy(i),t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="c"||i.type==="C")i.type==="c"?(t.bezierCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(t.bezierCurveTo(oe(e.x,r.x),oe(e.y,r.y),e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(oe(e.x,r.x),oe(e.y,r.y),i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(t.quadraticCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x,e.y+i.y),r.x=e.x+i.x1,r.y=e.y+i.y1,e.add(i)):(t.quadraticCurveTo(i.x1,i.y1,i.x,i.y),r.x=i.x1,r.y=i.y1,e.copy(i));else if(i.type==="t"||i.type==="T"){const a=oe(e.x,r.x),l=oe(e.y,r.y);r.x=a,r.y=l,i.type==="t"?(t.quadraticCurveTo(a,l,e.x+i.x,e.y+i.y),e.add(i)):(t.quadraticCurveTo(a,l,i.x,i.y),e.copy(i))}else if(i.type==="a"||i.type==="A"){const a=e.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;e.add(i)}else{if(e.equals(i))continue;e.copy(i)}r.copy(e),wo(t,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,a,e)}else i.type==="z"||i.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",i)}}const tt={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Et(n,t,e=0){let a=0,l=!0,h="",u="";const c=[];function f(p,C,S){const v=new SyntaxError(`Unexpected character "${p}" at index ${C}.`);throw v.partial=S,v}function d(){h!==""&&(u===""?c.push(Number(h)):c.push(Number(h)*10**Number(u))),h="",u=""}let g;const m=n.length;for(let p=0;p<m;p++){if(g=n[p],Array.isArray(t)&&t.includes(c.length%e)&&tt.FLAGS.test(g)){a=1,h=g,d();continue}if(a===0){if(tt.WHITESPACE.test(g))continue;if(tt.DIGIT.test(g)||tt.SIGN.test(g)){a=1,h=g;continue}if(tt.POINT.test(g)){a=2,h=g;continue}tt.COMMA.test(g)&&(l&&f(g,p,c),l=!0)}if(a===1){if(tt.DIGIT.test(g)){h+=g;continue}if(tt.POINT.test(g)){h+=g,a=2;continue}if(tt.EXP.test(g)){a=3;continue}tt.SIGN.test(g)&&h.length===1&&tt.SIGN.test(h[0])&&f(g,p,c)}if(a===2){if(tt.DIGIT.test(g)){h+=g;continue}if(tt.EXP.test(g)){a=3;continue}tt.POINT.test(g)&&h[h.length-1]==="."&&f(g,p,c)}if(a===3){if(tt.DIGIT.test(g)){u+=g;continue}if(tt.SIGN.test(g)){if(u===""){u+=g;continue}u.length===1&&tt.SIGN.test(u)&&f(g,p,c)}}tt.WHITESPACE.test(g)?(d(),a=0,l=!1):tt.COMMA.test(g)?(d(),a=0,l=!0):tt.SIGN.test(g)?(d(),a=1,h=g):tt.POINT.test(g)?(d(),a=2,h=g):f(g,p,c)}return d(),c}function xo(n){const t={x:0,y:0},e={x:0,y:0};let r="";for(let s=0,o=n.length;s<o;s++){const i=n[s];switch(i.type){case"m":case"M":if(i.x===e.x&&i.y===e.y)continue;r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y,t.x=i.x,t.y=i.y;break;case"h":case"H":r+=`${i.type} ${i.x}`,e.x=i.x;break;case"v":case"V":r+=`${i.type} ${i.y}`,e.y=i.y;break;case"l":case"L":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"c":case"C":r+=`${i.type} ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"s":case"S":r+=`${i.type} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"q":case"Q":r+=`${i.type} ${i.x1} ${i.y1} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"t":case"T":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"a":case"A":r+=`${i.type} ${i.rx} ${i.ry} ${i.angle} ${i.largeArcFlag} ${i.sweepFlag} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"z":case"Z":r+=i.type,e.x=t.x,e.y=t.y;break}}return r}const vo=/[a-df-z][^a-df-z]*/gi;function $s(n){const t=[],e=n.match(vo);if(!e)return t;for(let r=0,s=e.length;r<s;r++){const o=e[r],i=o.charAt(0),a=o.slice(1).trim();let l;switch(i){case"m":case"M":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)h===0?t.push({type:i,x:l[h],y:l[h+1]}):t.push({type:i==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=Et(a);for(let h=0,u=l.length;h<u;h++)t.push({type:i,x:l[h]});break;case"v":case"V":l=Et(a);for(let h=0,u=l.length;h<u;h++)t.push({type:i,y:l[h]});break;case"l":case"L":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)t.push({type:i,x:l[h],y:l[h+1]});break;case"c":case"C":l=Et(a);for(let h=0,u=l.length;h<u;h+=6)t.push({type:i,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=Et(a);for(let h=0,u=l.length;h<u;h+=4)t.push({type:i,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=Et(a);for(let h=0,u=l.length;h<u;h+=4)t.push({type:i,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=Et(a);for(let h=0,u=l.length;h<u;h+=2)t.push({type:i,x:l[h],y:l[h+1]});break;case"a":case"A":l=Et(a,[3,4],7);for(let h=0,u=l.length;h<u;h+=7)t.push({type:i,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":t.push({type:i});break;default:console.warn(o)}}return t}var bo=Object.defineProperty,So=(n,t,e)=>t in n?bo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Cr=(n,t,e)=>(So(n,typeof t!="symbol"?t+"":t,e),e);class Zt{constructor(){Cr(this,"arcLengthDivisions",200),Cr(this,"_cacheArcLengths"),Cr(this,"_needsUpdate",!1)}isClockwise(){const t=this.getPoint(1),e=this.getPoint(.5),r=this.getPoint(1);return(e.x-t.x)*(r.y-e.y)-(e.y-t.y)*(r.x-e.x)<0}getPointAt(t,e=new b){return this.getPoint(this.getUToTMapping(t),e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}forEachControlPoints(t){return this.getControlPoints().forEach(t),this}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===t+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const e=[];let r,s=this.getPoint(0),o=0;e.push(0);for(let i=1;i<=t;i++)r=this.getPoint(i/t),o+=r.distanceTo(s),e.push(o),s=r;return this._cacheArcLengths=e,e}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(t,e){const r=this.getLengths();let s=0;const o=r.length;let i;e?i=e:i=t*r[o-1];let a=0,l=o-1,h;for(;a<=l;)if(s=Math.floor(a+(l-a)/2),h=r[s]-i,h<0)a=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===i)return s/(o-1);const u=r[s],f=r[s+1]-u,d=(i-u)/f;return(s+d)/(o-1)}getTangent(t,e=new b){const s=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(s)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new b){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let r=0,s=1,o=(r+s)/2;for(;s-r>e;){o=(r+s)/2;const i=this.getPoint(o);if(i.distanceTo(t)<e)return o;i.x<t.x?r=o:s=o}return o}matrix(t){return this.forEachControlPoints(e=>e.applyMatrix3(t)),this}getMinMax(t=b.MAX,e=b.MIN){return this.getPoints().forEach(r=>{t.min(r),e.max(r)}),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new q(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.getPoints().map((t,e)=>e===0?{type:"M",x:t.x,y:t.y}:{type:"L",x:t.x,y:t.y})}toData(){return xo(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}function Bs(n,t,e,r,s){const o=(r-t)*.5,i=(s-e)*.5,a=n*n,l=n*a;return(2*e-2*r+o+i)*l+(-3*e+3*r-2*o-i)*a+o*n+e}function Po(n,t){const e=1-n;return e*e*t}function Co(n,t){return 2*(1-n)*n*t}function _o(n,t){return n*n*t}function Ds(n,t,e,r){return Po(n,t)+Co(n,e)+_o(n,r)}function Mo(n,t){const e=1-n;return e*e*e*t}function To(n,t){const e=1-n;return 3*e*e*n*t}function Oo(n,t){return 3*(1-n)*n*n*t}function Ao(n,t){return n*n*n*t}function Es(n,t,e,r,s){return Mo(n,t)+To(n,e)+Oo(n,r)+Ao(n,s)}class Io extends Zt{constructor(t=new b,e=new b,r=new b,s=new b){super(),this.start=t,this.startControl=e,this.endControl=r,this.end=s}getPoint(t,e=new b){const{start:r,startControl:s,endControl:o,end:i}=this;return e.set(Es(t,r.x,s.x,o.x,i.x),Es(t,r.y,s.y,o.y,i.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(t,e,r){const s=e*e-4*t*r;if(s<0)return[];const o=Math.sqrt(s),i=(-e+o)/(2*t),a=(-e-o)/(2*t);return[i,a].filter(l=>l>=0&&l<=1)}getMinMax(t=b.MAX,e=b.MIN){const r=this.start,s=this.startControl,o=this.endControl,i=this.end,a=this._solveQuadratic(3*(s.x-r.x),6*(o.x-s.x),3*(i.x-o.x)),l=this._solveQuadratic(3*(s.y-r.y),6*(o.y-s.y),3*(i.y-o.y)),h=[0,1,...a,...l];return((c,f)=>{for(const d of c)for(let g=0;g<=f;g++){const m=g/f-.5,p=Math.min(1,Math.max(0,d+m)),C=this.getPoint(p);t.x=Math.min(t.x,C.x),t.y=Math.min(t.y,C.y),e.x=Math.max(e.x,C.x),e.y=Math.max(e.y,C.y)}})(h,10),{min:t,max:e}}toCommands(){const{start:t,startControl:e,endControl:r,end:s}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:r.x,y2:r.y,x:s.x,y:s.y}]}drawTo(t){const{start:e,startControl:r,endControl:s,end:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(r.x,r.y,s.x,s.y,o.x,o.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.startControl.copy(t.startControl),this.endControl.copy(t.endControl),this.end.copy(t.end),this}}const $o=new St,Us=new St,ks=new St,je=new b;class Bo extends Zt{constructor(t=new b,e=1,r=1,s=0,o=0,i=Math.PI*2,a=!1){super(),this.center=t,this.radiusX=e,this.radiusY=r,this.rotation=s,this.startAngle=o,this.endAngle=i,this.clockwise=a}isClockwise(){return this.clockwise}getPoint(t,e=new b){const r=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.clockwise&&!o&&(s===r?s=-r:s=s-r);const i=this.startAngle+t*s;let a=this.center.x+this.radiusX*Math.cos(i),l=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const h=Math.cos(this.rotation),u=Math.sin(this.rotation),c=a-this.center.x,f=l-this.center.y;a=c*h-f*u+this.center.x,l=c*u+f*h+this.center.y}return e.set(a,l)}toCommands(){const{center:t,radiusX:e,radiusY:r,startAngle:s,endAngle:o,clockwise:i,rotation:a}=this,{x:l,y:h}=t,u=l+e*Math.cos(s)*Math.cos(a)-r*Math.sin(s)*Math.sin(a),c=h+e*Math.cos(s)*Math.sin(a)+r*Math.sin(s)*Math.cos(a),f=Math.abs(s-o),d=f>Math.PI?1:0,g=i?1:0,m=a*180/Math.PI;if(f>=2*Math.PI){const p=s+Math.PI,C=l+e*Math.cos(p)*Math.cos(a)-r*Math.sin(p)*Math.sin(a),S=h+e*Math.cos(p)*Math.sin(a)+r*Math.sin(p)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:g,x:C,y:S},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:g,x:u,y:c}]}else{const p=l+e*Math.cos(o)*Math.cos(a)-r*Math.sin(o)*Math.sin(a),C=h+e*Math.cos(o)*Math.sin(a)+r*Math.sin(o)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:d,sweepFlag:g,x:p,y:C}]}}drawTo(t){const{center:e,radiusX:r,radiusY:s,rotation:o,startAngle:i,endAngle:a,clockwise:l}=this;return t.ellipse(e.x,e.y,r,s,o,i,a,!l),this}matrix(t){return je.set(this.center.x,this.center.y),je.applyMatrix3(t),this.center.x=je.x,this.center.y=je.y,Uo(t)?Do(this,t):Eo(this,t),this}getControlPoints(){return[this.center]}getMinMax(t=b.MAX,e=b.MIN){const{center:r,radiusX:s,radiusY:o,rotation:i}=this,{x:a,y:l}=r,h=Math.cos(i),u=Math.sin(i),c=Math.sqrt(s*s*h*h+o*o*u*u),f=Math.sqrt(s*s*u*u+o*o*h*h);return t.x=Math.min(t.x,a-c),t.y=Math.min(t.y,l-f),e.x=Math.max(e.x,a+c),e.y=Math.max(e.y,l+f),{min:t,max:e}}copy(t){return super.copy(t),this.center.x=t.center.x,this.center.y=t.center.y,this.radiusX=t.radiusX,this.radiusY=t.radiusY,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}}function Do(n,t){const e=n.radiusX,r=n.radiusY,s=Math.cos(n.rotation),o=Math.sin(n.rotation),i=new b(e*s,e*o),a=new b(-r*o,r*s),l=i.applyMatrix3(t),h=a.applyMatrix3(t),u=$o.set(l.x,h.x,0,l.y,h.y,0,0,0,1),c=Us.copy(u).invert(),g=ks.copy(c).transpose().multiply(c).elements,m=ko(g[0],g[1],g[4]),p=Math.sqrt(m.rt1),C=Math.sqrt(m.rt2);if(n.radiusX=1/p,n.radiusY=1/C,n.rotation=Math.atan2(m.sn,m.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=Us.set(p,0,0,0,C,0,0,0,1),P=ks.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),w=v.multiply(P).multiply(u),x=T=>{const{x:_,y:O}=new b(Math.cos(T),Math.sin(T)).applyMatrix3(w);return Math.atan2(O,_)};n.startAngle=x(n.startAngle),n.endAngle=x(n.endAngle),Ls(t)&&(n.clockwise=!n.clockwise)}}function Eo(n,t){const e=Fs(t),r=zs(t);n.radiusX*=e,n.radiusY*=r;const s=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);n.rotation+=s,Ls(t)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function Ls(n){const t=n.elements;return t[0]*t[4]-t[1]*t[3]<0}function Uo(n){const t=n.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const r=Fs(n),s=zs(n);return Math.abs(e/(r*s))>Number.EPSILON}function Fs(n){const t=n.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function zs(n){const t=n.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function ko(n,t,e){let r,s,o,i,a;const l=n+e,h=n-e,u=Math.sqrt(h*h+4*t*t);return l>0?(r=.5*(l+u),a=1/r,s=n*a*e-t*a*t):l<0?s=.5*(l-u):(r=.5*u,s=-.5*u),h>0?o=h+u:o=h-u,Math.abs(o)>2*Math.abs(t)?(a=-2*t/o,i=1/Math.sqrt(1+a*a),o=a*i):Math.abs(t)===0?(o=1,i=0):(a=-.5*o/t,o=1/Math.sqrt(1+a*a),i=a*o),h>0&&(a=o,o=-i,i=a),{rt1:r,rt2:s,cs:o,sn:i}}class _r extends Zt{constructor(t=new b,e=new b){super(),this.start=t,this.end=e}getPoint(t,e=new b){return t===1?e.copy(this.end):e.copy(this.end).sub(this.start).scale(t).add(this.start),e}getPointAt(t,e=new b){return this.getPoint(t,e)}getTangent(t,e=new b){return e.subVectors(this.end,this.start).normalize()}getTangentAt(t,e=new b){return this.getTangent(t,e)}getControlPoints(){return[this.start,this.end]}getMinMax(t=b.MAX,e=b.MIN){const{start:r,end:s}=this;return t.x=Math.min(t.x,r.x,s.x),t.y=Math.min(t.y,r.y,s.y),e.x=Math.max(e.x,r.x,s.x),e.y=Math.max(e.y,r.y,s.y),{min:t,max:e}}toCommands(){const{start:t,end:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}drawTo(t){const{start:e,end:r}=this;return t.lineTo(e.x,e.y),t.lineTo(r.x,r.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.end.copy(t.end),this}}class Lo extends Zt{constructor(t=new b,e=new b,r=new b){super(),this.start=t,this.control=e,this.end=r}getPoint(t,e=new b){const{start:r,control:s,end:o}=this;return e.set(Ds(t,r.x,s.x,o.x),Ds(t,r.y,s.y,o.y)),e}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(t=b.MAX,e=b.MIN){const{start:r,control:s,end:o}=this,i=.5*(r.x+s.x),a=.5*(r.y+s.y),l=.5*(r.x+o.x),h=.5*(r.y+o.y);return t.x=Math.min(t.x,r.x,o.x,i,l),t.y=Math.min(t.y,r.y,o.y,a,h),e.x=Math.max(e.x,r.x,o.x,i,l),e.y=Math.max(e.y,r.y,o.y,a,h),{min:t,max:e}}toCommands(){const{start:t,control:e,end:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:r.x,y:r.y}]}drawTo(t){const{start:e,control:r,end:s}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(r.x,r.y,s.x,s.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.control.copy(t.control),this.end.copy(t.end),this}}var Fo=Object.defineProperty,zo=(n,t,e)=>t in n?Fo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ns=(n,t,e)=>(zo(n,typeof t!="symbol"?t+"":t,e),e);class No extends Zt{constructor(t,e,r=1,s=0,o=1){super(),this.center=t,this.rx=e,this.aspectRatio=r,this.start=s,this.end=o,Ns(this,"curves",[]),Ns(this,"curveT",0),this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:e}=this.center,r=this.rx,s=this.rx/this.aspectRatio,o=[new b(t-r,e-s),new b(t+r,e-s),new b(t+r,e+s),new b(t-r,e+s)];for(let i=0;i<4;i++)this.curves.push(new _r(o[i].clone(),o[(i+1)%4].clone()));return this}getCurve(t){let e=(t*(this.end-this.start)+this.start)%1;e<0&&(e+=1),e*=(1+this.aspectRatio)*2;let r;return e<this.aspectRatio?(r=0,this.curveT=e/this.aspectRatio):e<this.aspectRatio+1?(r=1,this.curveT=(e-this.aspectRatio)/1):e<2*this.aspectRatio+1?(r=2,this.curveT=(e-this.aspectRatio-1)/this.aspectRatio):(r=3,this.curveT=(e-2*this.aspectRatio-1)/1),this.curves[r]}getPoint(t,e){return this.getCurve(t).getPoint(this.curveT,e)}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){return this.getCurve(t).getTangent(this.curveT,e)}getNormal(t,e){return this.getCurve(t).getNormal(this.curveT,e)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=b.MAX,e=b.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(e=>e.drawTo(t)),this}}class qo extends Zt{constructor(t=[]){super(),this.points=t}getPoint(t,e=new b){const{points:r}=this,s=(r.length-1)*t,o=Math.floor(s),i=s-o,a=r[o===0?o:o-1],l=r[o],h=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return e.set(Bs(i,a.x,l.x,h.x,u.x),Bs(i,a.y,l.y,h.y,u.y)),e}getControlPoints(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++)this.points.push(t.points[e].clone());return this}}var Go=Object.defineProperty,Ro=(n,t,e)=>t in n?Go(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_e=(n,t,e)=>(Ro(n,typeof t!="symbol"?t+"":t,e),e);class Me extends Zt{constructor(t){super(),_e(this,"curves",[]),_e(this,"startPoint"),_e(this,"currentPoint",new b),_e(this,"autoClose",!1),_e(this,"_cacheLengths",[]),t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++){const{x:s,y:o}=t[e];this.lineTo(s,o)}return this}addCommands(t){return Is(t,this),this}addData(t){return this.addCommands($s(t)),this}getPoint(t,e=new b){const r=t*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=r){const i=s[o]-r,a=this.curves[o],l=a.getLength();return a.getPointAt(l===0?0:1-i/l,e)}o++}return e}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let e=0;for(let r=0,s=this.curves.length;r<s;r++)e+=this.curves[r].getLength(),t.push(e);return this._cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[],r=this.curves;let s;for(let o=0,i=r.length;o<i;o++){const l=r[o].getPoints(t);for(let h=0;h<l.length;h++){const u=l[h];s!=null&&s.equals(u)||(e.push(u),s=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;t.equals(e)||(this.curves.push(new _r(e.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint.set(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){return this.currentPoint.equals({x:t,y:e})||this.curves.push(new _r(this.currentPoint.clone(),new b(t,e))),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,r,s,o,i){return this.currentPoint.equals({x:o,y:i})||this.curves.push(new Io(this.currentPoint.clone(),new b(t,e),new b(r,s),new b(o,i))),this._setCurrentPoint({x:o,y:i}),this}quadraticCurveTo(t,e,r,s){return this.currentPoint.equals({x:r,y:s})||this.curves.push(new Lo(this.currentPoint.clone(),new b(t,e),new b(r,s))),this._setCurrentPoint({x:r,y:s}),this}arc(t,e,r,s,o,i){return this.ellipse(t,e,r,r,0,s,o,i),this}relativeArc(t,e,r,s,o,i){const a=this.currentPoint;return this.arc(t+a.x,e+a.y,r,s,o,i),this}arcTo(t,e,r,s,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,r,s,o,i,a,l=!0){const h=new Bo(new b(t,e),r,s,o,i,a,!l);if(this.curves.length>0){const u=h.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}return this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeEllipse(t,e,r,s,o,i,a,l){const h=this.currentPoint;return this.ellipse(t+h.x,e+h.y,r,s,o,i,a,l),this}rect(t,e,r,s){return this.curves.push(new No(new b(t+r/2,e+s/2),r/2,r/s)),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){return this.curves.push(new qo([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=b.MAX,e=b.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new q(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var r;const e=(r=this.curves[0])==null?void 0:r.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++)this.curves.push(t.curves[e].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Wo(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Vo(n,t,e,r){const s=t.clone().sub(n),o=r.clone().sub(e),i=e.clone().sub(n),a=s.cross(o);if(a===0)return new b((n.x+e.x)/2,(n.y+e.y)/2);const l=i.cross(o)/a;return Math.abs(l)>1?new b((n.x+e.x)/2,(n.y+e.y)/2):new b(n.x+l*s.x,n.y+l*s.y)}var Xo=Object.defineProperty,jo=(n,t,e)=>t in n?Xo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mr=(n,t,e)=>(jo(n,typeof t!="symbol"?t+"":t,e),e);class Pt{constructor(t,e={}){Mr(this,"currentPath",new Me),Mr(this,"paths",[this.currentPath]),Mr(this,"style"),t&&(t instanceof Pt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t)),this.style=e}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){return t instanceof Pt?this.paths.push(...t.paths.map(e=>e.clone())):this.paths.push(t),this}closePath(){const t=this.startPoint;return t&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new Me().moveTo(t.x,t.y),this.paths.push(this.currentPath))),this}moveTo(t,e){const{currentPoint:r,curves:s}=this.currentPath;return r.equals({x:t,y:e})||(s.length?(this.currentPath=new Me().moveTo(t,e),this.paths.push(this.currentPath)):this.currentPath.moveTo(t,e)),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}bezierCurveTo(t,e,r,s,o,i){return this.currentPath.bezierCurveTo(t,e,r,s,o,i),this}quadraticCurveTo(t,e,r,s){return this.currentPath.quadraticCurveTo(t,e,r,s),this}arc(t,e,r,s,o,i){return this.currentPath.arc(t,e,r,s,o,i),this}arcTo(t,e,r,s,o){return this.currentPath.arcTo(t,e,r,s,o),this}ellipse(t,e,r,s,o,i,a,l){return this.currentPath.ellipse(t,e,r,s,o,i,a,l),this}rect(t,e,r,s){return this.currentPath.rect(t,e,r,s),this}addCommands(t){return Is(t,this),this}addData(t){return this.addCommands($s(t)),this}splineThru(t){return this.currentPath.splineThru(t),this}getControlPoints(){return this.paths.flatMap(t=>t.getControlPoints())}getCurves(){return this.paths.flatMap(t=>t.curves)}scale(t,e=t,r={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.scale(t,e,r)}),this}skew(t,e=0,r={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.skew(t,e,r)}),this}rotate(t,e={x:0,y:0}){return this.getControlPoints().forEach(r=>{r.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getCurves(),r=[],s=[],o=[];e.forEach((a,l)=>{const h=a.getControlPoints(),u=a.isClockwise();o[l]=h,s[l]=u;const c=h[0],f=h[h.length-1]??c;r.push({start:u?f:c,end:u?c:f,index:l})});const i=[];return r.forEach((a,l)=>{i[l]=[],r.forEach((h,u)=>{u!==l&&h.start.equals(a.end)&&i[l].push(h.index)})}),e.forEach((a,l)=>{const h=s[l];o[l].forEach(c=>{const f=a.getTForPoint(c),d=a.getNormal(f).scale(h?t:-t);c.add(d)})}),i.forEach((a,l)=>{const h=o[l];a.forEach(u=>{const c=o[u],f=Vo(h[h.length-1],h[h.length-2]??h[h.length-1],c[0],c[1]??c[0]);f&&(h[h.length-1].copy(f),c[0].copy(f))})}),this}matrix(t){return this.getCurves().forEach(e=>e.matrix(t)),this}getMinMax(t=b.MAX,e=b.MIN,r=!0){const s=this.strokeWidth;return this.getCurves().forEach(o=>{if(o.getMinMax(t,e),r&&s>1){const i=s/2,a=o.isClockwise(),l=[];for(let h=0;h<=1;h+=1/o.arcLengthDivisions){const u=o.getPoint(h),c=o.getNormal(h),f=c.clone().scale(a?i:-i),d=c.clone().scale(a?-i:i);l.push(u.clone().add(f),u.clone().add(d),u.clone().add({x:i,y:0}),u.clone().add({x:-i,y:0}),u.clone().add({x:0,y:i}),u.clone().add({x:0,y:-i}),u.clone().add({x:i,y:i}),u.clone().add({x:-i,y:-i}))}t.min(...l),e.max(...l)}}),{min:t,max:e}}getBoundingBox(t=!0){const{min:e,max:r}=this.getMinMax(void 0,void 0,t);return new q(e.x,e.y,r.x-e.x,r.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:s="none"}=e;return t.beginPath(),t.save(),Sr(t,e),this.paths.forEach(o=>{o.drawTo(t)}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:s="none"}=e;return t.beginPath(),t.save(),Sr(t,e),this.getControlPoints().forEach(o=>{t.moveTo(o.x,o.y),t.arc(o.x,o.y,4,0,Math.PI*2)}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.paths.flatMap(t=>t.toCommands())}toData(){return this.paths.map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const s in t)t[s]!==void 0&&(e[Wo(s)]=t[s]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const s in e)e[s]!==void 0&&(r+=`${s}:${e[s]};`);return`<path d="${this.toData()}" style="${r}"></path>`}toSvgString(){const{x:t,y:e,width:r,height:s}=this.getBoundingBox(),o=this.toSvgPathString();return`<svg viewBox="${t} ${e} ${r} ${s}" width="${r}px" height="${s}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...r}=t,{left:s,top:o,width:i,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=i*e,l.height=a*e,l.style.width=`${i}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(e,e),h.translate(-s,-o),this.drawTo(h,r)),l}copy(t){return this.currentPath=t.currentPath.clone(),this.paths=t.paths.map(e=>e.clone()),this.style={...t.style},this}clone(){return new this.constructor().copy(this)}}const Tr="px",qs=90,Gs=["mm","cm","in","pt","pc","px"],Or={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function R(n){let t="px";if(typeof n=="string"||n instanceof String)for(let r=0,s=Gs.length;r<s;r++){const o=Gs[r];if(n.endsWith(o)){t=o,n=n.substring(0,n.length-o.length);break}}let e;return t==="px"&&Tr!=="px"?e=Or.in[Tr]/qs:(e=Or[t][Tr],e<0&&(e=Or[t].in*qs)),e*Number.parseFloat(n)}const Ho=new St,He=new St,Rs=new St,Ws=new St;function Yo(n,t,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const r=Zo(n);return e.length>0&&r.premultiply(e[e.length-1]),t.copy(r),e.push(r),r}function Zo(n){const t=new St,e=Ho;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&t.translate(R(n.getAttribute("x")),R(n.getAttribute("y"))),n.hasAttribute("transform")){const r=n.getAttribute("transform").split(")");for(let s=r.length-1;s>=0;s--){const o=r[s].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const l=o.slice(0,i),h=Et(o.slice(i+1));switch(e.identity(),l){case"translate":if(h.length>=1){const u=h[0];let c=0;h.length>=2&&(c=h[1]),e.translate(u,c)}break;case"rotate":if(h.length>=1){let u=0,c=0,f=0;u=h[0]*Math.PI/180,h.length>=3&&(c=h[1],f=h[2]),He.makeTranslation(-c,-f),Rs.makeRotation(u),Ws.multiplyMatrices(Rs,He),He.makeTranslation(c,f),e.multiplyMatrices(He,Ws)}break;case"scale":h.length>=1&&e.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&e.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&e.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&e.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}t.premultiply(e)}}return t}function Ko(n){return new Pt().addPath(new Me().arc(R(n.getAttribute("cx")||0),R(n.getAttribute("cy")||0),R(n.getAttribute("r")||0),0,Math.PI*2))}function Qo(n,t){if(!(!n.sheet||!n.sheet.cssRules||!n.sheet.cssRules.length))for(let e=0;e<n.sheet.cssRules.length;e++){const r=n.sheet.cssRules[e];if(r.type!==1)continue;const s=r.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),o={};for(let i=r.style.length,a=0;a<i;a++){const l=r.style.item(a);o[l]=r.style.getPropertyValue(l)}for(let i=0;i<s.length;i++)t[s[i]]=Object.assign(t[s[i]]||{},{...o})}}function Jo(n){return new Pt().addPath(new Me().ellipse(R(n.getAttribute("cx")||0),R(n.getAttribute("cy")||0),R(n.getAttribute("rx")||0),R(n.getAttribute("ry")||0),0,0,Math.PI*2))}function ta(n){return new Pt().moveTo(R(n.getAttribute("x1")||0),R(n.getAttribute("y1")||0)).lineTo(R(n.getAttribute("x2")||0),R(n.getAttribute("y2")||0))}function ea(n){const t=new Pt,e=n.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const ra=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function sa(n){var r;const t=new Pt;let e=0;return(r=n.getAttribute("points"))==null||r.replace(ra,(s,o,i)=>{const a=R(o),l=R(i);return e===0?t.moveTo(a,l):t.lineTo(a,l),e++,s}),t.currentPath.autoClose=!0,t}const na=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ia(n){var r;const t=new Pt;let e=0;return(r=n.getAttribute("points"))==null||r.replace(na,(s,o,i)=>{const a=R(o),l=R(i);return e===0?t.moveTo(a,l):t.lineTo(a,l),e++,s}),t.currentPath.autoClose=!1,t}function oa(n){const t=R(n.getAttribute("x")||0),e=R(n.getAttribute("y")||0),r=R(n.getAttribute("rx")||n.getAttribute("ry")||0),s=R(n.getAttribute("ry")||n.getAttribute("rx")||0),o=R(n.getAttribute("width")),i=R(n.getAttribute("height")),a=1-.551915024494,l=new Pt;return l.moveTo(t+r,e),l.lineTo(t+o-r,e),(r!==0||s!==0)&&l.bezierCurveTo(t+o-r*a,e,t+o,e+s*a,t+o,e+s),l.lineTo(t+o,e+i-s),(r!==0||s!==0)&&l.bezierCurveTo(t+o,e+i-s*a,t+o-r*a,e+i,t+o-r,e+i),l.lineTo(t+r,e+i),(r!==0||s!==0)&&l.bezierCurveTo(t+r*a,e+i,t,e+i-s*a,t,e+i-s),l.lineTo(t,e+s),(r!==0||s!==0)&&l.bezierCurveTo(t,e+s*a,t+r*a,e,t+r,e),l}function Ut(n,t,e){t=Object.assign({},t);let r={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(u=>u.trim());for(let u=0;u<h.length;u++)r=Object.assign(r,e[`.${h[u]}`])}n.hasAttribute("id")&&(r=Object.assign(r,e[`#${n.getAttribute("id")}`]));for(let h=n.style.length,u=0;u<h;u++){const c=n.style.item(u),f=n.style.getPropertyValue(c);t[c]=f,r[c]=f}function s(h,u,c=o){n.hasAttribute(h)&&(t[u]=c(n.getAttribute(h))),r[h]&&(t[u]=c(r[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function i(h){return Math.max(0,Math.min(1,R(h)))}function a(h){return Math.max(0,R(h))}function l(h){return h.split(" ").filter(u=>u!=="").map(u=>R(u))}return s("fill","fill"),s("fill-opacity","fillOpacity",i),s("fill-rule","fillRule"),s("opacity","opacity",i),s("stroke","stroke"),s("stroke-opacity","strokeOpacity",i),s("stroke-width","strokeWidth",a),s("stroke-linecap","strokeLinecap"),s("stroke-linejoin","strokeLinejoin"),s("stroke-miterlimit","strokeMiterlimit",a),s("stroke-dasharray","strokeDasharray",l),s("stroke-dashoffset","strokeDashoffset",R),s("visibility","visibility"),t}function Ar(n,t,e=[],r={}){var c;if(n.nodeType!==1)return e;let s=!1,o=null,i={...t};switch(n.nodeName){case"svg":i=Ut(n,i,r);break;case"style":Qo(n,r);break;case"g":i=Ut(n,i,r);break;case"path":i=Ut(n,i,r),n.hasAttribute("d")&&(o=ea(n));break;case"rect":i=Ut(n,i,r),o=oa(n);break;case"polygon":i=Ut(n,i,r),o=sa(n);break;case"polyline":i=Ut(n,i,r),o=ia(n);break;case"circle":i=Ut(n,i,r),o=Ko(n);break;case"ellipse":i=Ut(n,i,r),o=Jo(n);break;case"line":i=Ut(n,i,r),o=ta(n);break;case"defs":s=!0;break;case"use":{i=Ut(n,i,r);const d=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),g=(c=n.viewportElement)==null?void 0:c.getElementById(d);g?Ar(g,i,e,r):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(n);break}if(i.display==="none")return e;Object.assign(t,i);const a=new St,l=[],h=Yo(n,a,l);o&&(o.matrix(a),e.push(o),o.style=t);const u=n.childNodes;for(let f=0,d=u.length;f<d;f++){const g=u[f];s&&g.nodeName!=="style"&&g.nodeName!=="defs"||Ar(g,t,e,r)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),e}const Vs="data:image/svg+xml;",Xs=`${Vs}base64,`,js=`${Vs}charset=utf8,`;function Hs(n){if(typeof n=="string"){let t;return n.startsWith(Xs)?(n=n.substring(Xs.length,n.length),t=atob(n)):n.startsWith(js)?(n=n.substring(js.length,n.length),t=decodeURIComponent(n)):t=n,new DOMParser().parseFromString(t,"image/svg+xml").documentElement}else return n}function Ys(n){return Ar(Hs(n),{})}function Te(n,t=!0){if(!n.length)return;const e=b.MAX,r=b.MIN;return n.forEach(s=>s.getMinMax(e,r,t)),new q(e.x,e.y,r.x-e.x,r.y-e.y)}const aa=new Set(["©","®","÷"]),la=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),ha={1:"italic",32:"bold"},ca={1:"italic",2:"bold"},Zs={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Ks{constructor(t,e,r){B(this,"path",new Pt);B(this,"lineBox",new q);B(this,"inlineBox",new q);B(this,"glyphBox");B(this,"advanceWidth",0);B(this,"advanceHeight",0);B(this,"underlinePosition",0);B(this,"underlineThickness",0);B(this,"strikeoutPosition",0);B(this,"strikeoutSize",0);B(this,"ascender",0);B(this,"descender",0);B(this,"typoAscender",0);B(this,"typoDescender",0);B(this,"typoLineGap",0);B(this,"winAscent",0);B(this,"winDescent",0);B(this,"xHeight",0);B(this,"capHeight",0);B(this,"baseline",0);B(this,"centerDiviation",0);B(this,"fontStyle");this.content=t,this.index=e,this.parent=r}get center(){var t;return(t=this.glyphBox)==null?void 0:t.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(t){const e=this.computedStyle.fontFamily,r=t??fo,s=e?r.get(e):r.fallbackFont;return s==null?void 0:s.getSfnt()}updateGlyph(t=this._getFontSfnt()){if(!t)return this;const{hhea:e,os2:r,post:s,head:o}=t,i=o.unitsPerEm,a=e.ascent,l=e.descent,{content:h,computedStyle:u,isVertical:c}=this,{fontSize:f}=u,d=i/f,g=t.getAdvanceWidth(h,f),m=(a+Math.abs(l))/d,p=a/d;return this.advanceWidth=g,this.advanceHeight=m,this.inlineBox.width=c?m:g,this.inlineBox.height=c?g:m,this.underlinePosition=(a-s.underlinePosition)/d,this.underlineThickness=s.underlineThickness/d,this.strikeoutPosition=(a-r.yStrikeoutPosition)/d,this.strikeoutSize=r.yStrikeoutSize/d,this.ascender=a/d,this.descender=l/d,this.typoAscender=r.sTypoAscender/d,this.typoDescender=r.sTypoDescender/d,this.typoLineGap=r.sTypoLineGap/d,this.winAscent=r.usWinAscent/d,this.winDescent=r.usWinDescent/d,this.xHeight=r.sxHeight/d,this.capHeight=r.sCapHeight/d,this.baseline=p,this.centerDiviation=m/2-p,this.fontStyle=ha[r.fsSelection]??ca[o.macStyle],this}update(t){const e=this._getFontSfnt(t);if(!e)return this;this.updateGlyph(e);const{isVertical:r,content:s,computedStyle:o,baseline:i,inlineBox:a,ascender:l,descender:h,typoAscender:u,fontStyle:c,advanceWidth:f,advanceHeight:d}=this,{left:g,top:m}=a,p=o.fontStyle==="italic"&&c!=="italic";let C=g,S=m+i,v;const P=new Pt;if(r&&(C+=(d-f)/2,Math.abs(f-d)>.1&&(S-=(l-u)/(l+Math.abs(h))*d),v=void 0),r&&!aa.has(s)&&(s.codePointAt(0)<=256||la.has(s))){P.addCommands(e.getPathCommands(s,C,m+i-(d-f)/2,o.fontSize));const x={y:m-(d-f)/2+d/2,x:C+f/2};p&&this._italic(P,r?{x:x.x,y:m-(d-f)/2+i}:void 0),P.rotate(90,x)}else v!==void 0?(P.addCommands(e.glyphs.get(v).getPathCommands(C,S,o.fontSize)),p&&this._italic(P,r?{x:C+f/2,y:m+u/(l+Math.abs(h))*d}:void 0)):(P.addCommands(e.getPathCommands(s,C,S,o.fontSize)),p&&this._italic(P,r?{x:C+d/2,y:S}:void 0));const w=o.fontWeight??400;return w in Zs&&(w===700||w==="bold")&&c!=="bold"&&P.bold(Zs[w]*o.fontSize*.05),P.style={fill:o.color,stroke:o.textStrokeWidth?o.textStrokeColor:"none",strokeWidth:o.textStrokeWidth?o.textStrokeWidth*o.fontSize*.03:0},this.path=P,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(t,e){t.skew(-.24,0,e||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(t,e,r){var s;if((s=this.path.paths[0])!=null&&s.curves.length)return this.path.getMinMax(t,e,r)}getGlyphBoundingBox(t){const e=this.getGlyphMinMax(void 0,void 0,t);if(!e)return;const{min:r,max:s}=e;return new q(r.x,r.y,s.x-r.x,s.y-r.y)}drawTo(t,e={}){const r=this.computedStyle,s={ctx:t,path:this.path,fontSize:r.fontSize,color:r.color,...e};if(this.glyphBox)te(s);else{t.save(),t.beginPath();const o=this.path.style,i={...o,fill:s.color??o.fill,stroke:s.textStrokeColor??o.stroke,strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize:o.strokeWidth,shadowOffsetX:(s.shadowOffsetX??0)*s.fontSize,shadowOffsetY:(s.shadowOffsetY??0)*s.fontSize,shadowBlur:(s.shadowBlur??0)*s.fontSize,shadowColor:s.shadowColor};Sr(t,i),t.font=`${s.fontSize}px ${s.fontFamily}`,this.isVertical?(t.textBaseline="middle",t.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(t.textBaseline="alphabetic",t.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),t.restore()}}}function Ye(n,t){return typeof n=="number"?n:n.endsWith("%")?(n=n.substring(0,n.length-1),Math.ceil(Number(n)/100*t.total)):n.endsWith("rem")?(n=n.substring(0,n.length-3),Number(n)*t.fontSize):n.endsWith("em")?(n=n.substring(0,n.length-2),Number(n)*t.fontSize):Number(n)}function Ir(n){const t=Nt(n)?{}:n;return Object.keys(t).reduce((e,r)=>{let s=t[r];const o=$r(r),i=$r(s);return o&&(r=o),i&&(s=i),e[r]=s,e},{})}function Nt(n){return!n||n==="none"}function Qs(n,t){const e=Object.keys(n),r=Object.keys(t);return Array.from(new Set([...e,...r])).every(o=>Kt(n[o],t[o]))}function Kt(n,t){const e=typeof n;return e===typeof t?e==="object"?Qs(n,t):n===t:!1}function $r(n){const t=n.startsWith("#")?n.slice(1):n;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(t))return null;const r=t.length===3?t.split("").map(a=>a+a).join(""):t,s=Number.parseInt(r.slice(0,2),16),o=Number.parseInt(r.slice(2,4),16),i=Number.parseInt(r.slice(4,6),16);return`rgb(${s}, ${o}, ${i})`}function Ze(n){if(!n)return n;const t={};for(const e in n)n[e]!==""&&n[e]!==void 0&&(t[e]=n[e]);return t}class Js{constructor(t,e={},r){B(this,"inlineBox",new q);this.content=t,this.style=e,this.parent=r,this.updateComputedStyle().initCharacters()}get computedContent(){const t=this.computedStyle;return t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Ze(this.style)},this}initCharacters(){const t=[];let e=0;for(const r of this.computedContent)t.push(new Ks(r,e++,this));return this.characters=t,this}}class ae{constructor(t,e){B(this,"lineBox",new q);B(this,"fragments",[]);this.style=t,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Ze(this.parentStyle),...Ze(this.style)},this}addFragment(t,e){const r=new Js(t,e,this);return this.fragments.push(r),r}}function ua(n){return n}class tn{constructor(t){this._text=t}_styleToDomStyle(t){const e={...t};for(const r in t)["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur"].includes(r)?e[r]=`${t[r]}px`:e[r]=t[r];return e}createDom(){const{paragraphs:t,computedStyle:e}=this._text,r=document.createDocumentFragment(),s=document.createElement("section");Object.assign(s.style,{width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(e),position:"fixed",visibility:"hidden"});const o=document.createElement("ul");return Object.assign(o.style,{listStyleType:"inherit",padding:"0",margin:"0"}),t.forEach(i=>{const a=document.createElement("li");Object.assign(a.style,this._styleToDomStyle(i.style)),i.fragments.forEach(l=>{const h=document.createElement("span");Object.assign(h.style,this._styleToDomStyle(l.style)),h.appendChild(document.createTextNode(l.content)),a.appendChild(h)}),o.appendChild(a)}),s.appendChild(o),r.appendChild(s),document.body.appendChild(r),{dom:s,destory:()=>{var i;return(i=s.parentNode)==null?void 0:i.removeChild(s)}}}_measureDom(t){const e=[],r=[],s=[];return t.querySelectorAll("li").forEach((o,i)=>{const a=o.getBoundingClientRect();e.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),o.querySelectorAll("span").forEach((l,h)=>{const u=l.getBoundingClientRect();r.push({paragraphIndex:i,fragmentIndex:h,left:u.left,top:u.top,width:u.width,height:u.height});const c=l.firstChild;if(c instanceof window.Text){const f=document.createRange();f.selectNodeContents(c);const d=c.data??"";Array.from(d).forEach((g,m)=>{var w;const p=d.indexOf(g),C=p+g.length;f.setStart(c,Math.max(p,0)),f.setEnd(c,C);const S=((w=f.getClientRects)==null?void 0:w.call(f))??[f.getBoundingClientRect()];let v=S[S.length-1];S.length>1&&v.width<2&&(v=S[S.length-2]);const P=f.toString();P!==""&&v&&v.width+v.height!==0&&s.push({content:P,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:h,characterIndex:m,top:v.top,left:v.left,height:v.height,width:v.width,textWidth:-1,textHeight:-1})})}})}),{paragraphs:e,fragments:r,characters:s}}measureDom(t){const{paragraphs:e}=this._text,r=t.getBoundingClientRect(),s=this._measureDom(t);s.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),s.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const o=[];let i=0;return s.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:u}=a;o.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const c=e[l].fragments[h].characters[u],{fontHeight:f,isVertical:d}=c,g=o[i];c.inlineBox.left=g.left,c.inlineBox.top=g.top,c.inlineBox.width=g.width,c.inlineBox.height=g.height,d?(c.lineBox.left=g.left+(g.width-f)/2,c.lineBox.top=g.top,c.lineBox.width=f,c.lineBox.height=g.height):(c.lineBox.left=g.left,c.lineBox.top=g.top+(g.height-f)/2,c.lineBox.width=g.width,c.lineBox.height=f),i++}),{paragraphs:e,boundingBox:new q(0,0,r.width,r.height)}}measure(t){let e;t||({dom:t,destory:e}=this.createDom());const r=this.measureDom(t);return e==null||e(),r}}class fa{constructor(){B(this,"eventListeners",new Map)}addEventListener(t,e,r){const s={value:e,options:r},o=this.eventListeners.get(t);return o?Array.isArray(o)?o.push(s):this.eventListeners.set(t,[o,s]):this.eventListeners.set(t,s),this}removeEventListener(t,e,r){var o,i;if(!e)return this.eventListeners.delete(t),this;const s=this.eventListeners.get(t);if(!s)return this;if(Array.isArray(s)){const a=[];for(let l=0,h=s.length;l<h;l++){const u=s[l];(u.value!==e||typeof r=="object"&&(r!=null&&r.once)&&(typeof u.options=="boolean"||!((o=u.options)!=null&&o.once)))&&a.push(u)}a.length?this.eventListeners.set(t,a.length===1?a[0]:a):this.eventListeners.delete(t)}else s.value===e&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof s.options=="boolean"||(i=s.options)!=null&&i.once)&&this.eventListeners.delete(t);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(t){return this.eventListeners.has(t)}dispatchEvent(t,e){var s,o;const r=this.eventListeners.get(t);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const l=r[a];typeof l.options=="object"&&((s=l.options)!=null&&s.once)&&this.off(t,l.value,l.options),l.value.apply(this,[e])}else typeof r.options=="object"&&((o=r.options)!=null&&o.once)&&this.off(t,r.value,r.options),r.value.apply(this,[e]);return!0}else return!1}on(t,e,r){return this.addEventListener(t,e,r)}once(t,e){return this.addEventListener(t,e,{once:!0})}off(t,e,r){return this.removeEventListener(t,e,r)}emit(t,e){this.dispatchEvent(t,e)}}function en(){const n=[],t=[],e=new Map;async function r(s){let o=e.get(s);if(!o){s.startsWith("http")&&(s=await fetch(s).then(l=>l.text()));const i=Hs(s),a=Ys(i);o={dom:i,paths:a},e.set(s,o)}return o}return{name:"highlight",paths:n,update:async s=>{t.length=0,n.length=0;let o=[],i,a;s.forEachCharacter(l=>{const{isVertical:h,computedStyle:u,inlineBox:c}=l;!Nt(u.highlightImage)&&l.glyphBox?(!a||Kt(a.highlightImage,u.highlightImage)&&Kt(a.highlightColormap,u.highlightColormap)&&Kt(a.highlightLine,u.highlightLine)&&Kt(a.highlightSize,u.highlightSize)&&Kt(a.highlightThickness,u.highlightThickness))&&(i!=null&&i.length)&&(h?i[0].inlineBox.left===c.left:i[0].inlineBox.top===c.top)&&i[0].fontSize===u.fontSize?i.push(l):(i=[],i.push(l),o.push(i)):i!=null&&i.length&&(i=[],o.push(i)),a=u}),o=o.filter(l=>l.length);for(let l=0;l<o.length;l++){const h=o[l],u=h[0],c=q.from(...h.map(D=>D.glyphBox)),{computedStyle:f}=u,{fontSize:d,writingMode:g,highlightImage:m,highlightReferImage:p,highlightColormap:C,highlightLine:S,highlightSize:v,highlightThickness:P}=f,w=g.includes("vertical"),x=Ye(P,{fontSize:d,total:c.width})/c.width,T=Ir(C),{paths:_,dom:O}=await r(m),E=Te(_,!0),N=d/E.width*2,M=new q().copy(c);w&&(M.width=c.height,M.height=c.width,M.left=c.left+c.width);const gt=Math.floor(M.width);let U=gt;if(v!=="cover"&&(U=Ye(v,{fontSize:d,total:c.width}),M.width=U),!Nt(p)&&Nt(S)){const D=Te((await r(p)).paths,!0);E.copy(D)}else{let D;if(Nt(S))if(E.width/E.height>4){D="underline";const k=O.getAttribute("viewBox");if(k){const[V,A,bt,W]=k.split(" ").map(G=>Number(G)),Y=A+W/2;E.y<Y&&E.y+E.height>Y?D="line-through":E.y+E.height<Y?D="overline":D="underline"}}else D="outline";else D=S;switch(D){case"outline":{const k=M.width*.2,V=M.height*.2;M.width+=k,M.height+=V,w?(M.x-=V/2,M.y-=k/2,M.x+=M.height):(M.x-=k/2,M.y-=V/2);break}case"overline":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width:M.y=u.inlineBox.top;break;case"line-through":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width-u.strikeoutPosition+M.height/2:M.y=u.inlineBox.top+u.strikeoutPosition-M.height/2;break;case"underline":M.height=E.height*N,w?M.x=u.inlineBox.left+u.inlineBox.width-u.underlinePosition:M.y=u.inlineBox.top+u.underlinePosition;break}}const z=new St().translate(-E.x,-E.y).scale(M.width/E.width,M.height/E.height);w&&z.rotate(-Math.PI/2),z.translate(M.x,M.y);for(let D=0;D<Math.ceil(gt/U);D++){const k=z.clone();w?k.translate(0,D*M.width):k.translate(D*M.width,0),_.forEach(V=>{const A=V.clone().matrix(k);A.style.strokeWidth&&(A.style.strokeWidth*=N*x),A.style.strokeMiterlimit&&(A.style.strokeMiterlimit*=N),A.style.strokeDashoffset&&(A.style.strokeDashoffset*=N),A.style.strokeDasharray&&(A.style.strokeDasharray=A.style.strokeDasharray.map(bt=>bt*N)),A.style.fill&&A.style.fill in T&&(A.style.fill=T[A.style.fill]),A.style.stroke&&A.style.stroke in T&&(A.style.stroke=T[A.style.stroke]),n.push(A),gt!==U&&(w?t[n.length-1]=new q(c.left-c.width*2,c.top,c.width*4,c.height):t[n.length-1]=new q(c.left,c.top-c.height*2,c.width,c.height*4))})}}},renderOrder:-1,render:(s,o)=>{n.forEach((i,a)=>{if(te({ctx:s,path:i,fontSize:o.computedStyle.fontSize,clipRect:t[a]}),o.debug){const l=Te([i]);l&&s.strokeRect(l.x,l.y,l.width,l.height)}})}}}function rn(){const n=[];return{name:"listStyle",paths:n,update:t=>{n.length=0;const{paragraphs:e,isVertical:r,fontSize:s}=t,o=s*.45;e.forEach(i=>{const{computedStyle:a}=i,{listStyleImage:l,listStyleColormap:h,listStyleSize:u,listStyleType:c,color:f}=a,d=Ir(h);let g=u,m;if(!Nt(l))m=l;else if(!Nt(c)){const P=s*.38/2;switch(g=g==="cover"?P*2:g,c){case"disc":m=`<svg width="${P*2}" height="${P*2}" xmlns="http://www.w3.org/2000/svg">
5
5
  <circle cx="${P}" cy="${P}" r="${P}" fill="${f}" />
6
6
  </svg>`;break}}if(!m)return;const p=Ys(m),C=Te(p),S=i.lineBox,v=i.fragments[0].inlineBox;if(v){const P=g==="cover"?1:Ye(g,{total:s,fontSize:s})/s,w=new St;if(r){const x=s/C.height*P;w.translate(-C.left,-C.top),w.rotate(Math.PI/2),w.scale(x,x),w.translate(s/2-C.height*x/2,0),w.translate(S.left+(S.width-s)/2,v.top-o)}else{const x=s/C.height*P;w.translate(-C.left,-C.top),w.translate(-C.width,0),w.scale(x,x),w.translate(0,s/2-C.height*x/2),w.translate(v.left-o,S.top+(S.height-s)/2)}n.push(...p.map(x=>{const T=x.clone();return T.matrix(w),T.style.fill&&T.style.fill in d&&(T.style.fill=d[T.style.fill]),T.style.stroke&&T.style.stroke in d&&(T.style.stroke=d[T.style.stroke]),T}))}})}}}const Xt=new b,le=new St,jt=new St;function sn(){return{name:"render",getBoundingBox:n=>{const{characters:t,fontSize:e,effects:r}=n,s=[];return t.forEach(o=>{r==null||r.forEach(i=>{if(!o.glyphBox)return;const a=o.glyphBox.clone(),l=Ke(n,i);Xt.set(a.left,a.top),Xt.applyMatrix3(l),a.left=Xt.x,a.top=Xt.y,Xt.set(a.right,a.bottom),Xt.applyMatrix3(l),a.width=Xt.x-a.left,a.height=Xt.y-a.top;const h=(i.shadowOffsetX??0)*e,u=(i.shadowOffsetY??0)*e,c=Math.max(.1,i.textStrokeWidth??0)*e;a.left+=h-c,a.top+=u-c,a.width+=c*2,a.height+=c*2,s.push(a)})}),s.length?q.from(...s):void 0},render:(n,t)=>{const{paragraphs:e,glyphBox:r,effects:s,style:o}=t;function i(a,l){n.fillStyle=a,n.fillRect(l.left,l.top,l.width,l.height)}o!=null&&o.backgroundColor&&i(o.backgroundColor,new q(0,0,n.canvas.width,n.canvas.height)),e.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&i(a.style.backgroundColor,a.lineBox)}),s?s.forEach(a=>{$t(a,r,n),n.save();const[l,h,u,c,f,d]=Ke(t,a).transpose().elements;n.transform(l,c,h,f,u,d),t.forEachCharacter(g=>{var m;(m=g.parent.style)!=null&&m.backgroundColor&&i(g.parent.style.backgroundColor,g.inlineBox),g.drawTo(n,a)}),n.restore()}):e.forEach(a=>{a.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&i(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(u=>{u.drawTo(n)})})}),t.debug&&e.forEach(a=>{n.strokeRect(a.lineBox.x,a.lineBox.y,a.lineBox.width,a.lineBox.height)})}}}function Ke(n,t){const{fontSize:e,glyphBox:r}=n,s=(t.translateX??0)*e,o=(t.translateY??0)*e,i=Math.PI*2,a=(t.skewX??0)/360*i,l=(t.skewY??0)/360*i,{left:h,top:u,width:c,height:f}=r,d=h+c/2,g=u+f/2;return le.identity(),jt.makeTranslation(s,o),le.multiply(jt),jt.makeTranslation(d,g),le.multiply(jt),jt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),le.multiply(jt),jt.makeTranslation(-d,-g),le.multiply(jt),le.clone()}function nn(){const n=[];return{name:"textDecoration",paths:n,update:t=>{n.length=0;const e=[];let r,s;t.forEachCharacter(o=>{const{computedStyle:i,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:u,strikeoutPosition:c,strikeoutSize:f}=o;if(Nt(i.textDecoration))s=void 0;else{let d=!1;if((s==null?void 0:s.textDecoration)===i.textDecoration&&(s==null?void 0:s.writingMode)===i.writingMode&&(s==null?void 0:s.color)===i.color&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(i.textDecoration){case"underline":r[0].underlinePosition===h&&r[0].underlineThickness===u&&(d=!0);break;case"line-through":r[0].strikeoutPosition===c&&r[0].strikeoutSize===f&&(d=!0);break}d?r.push(o):(r=[],r.push(o),e.push(r)),s=i}}),e.forEach(o=>{const{computedStyle:i,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:u,strikeoutSize:c}=o[0],{textDecoration:f,color:d}=i,{left:g,top:m,width:p,height:C}=q.from(...o.map(x=>x.inlineBox));let S=a?g+p:m;const v=a?-1:1;let P=0;switch(f){case"overline":P=h*2;break;case"underline":S+=v*l,P=h*2;break;case"line-through":S+=v*u,P=c*2;break}S-=P;let w;a?w=new Pt([{type:"M",x:S,y:m},{type:"L",x:S,y:m+C},{type:"L",x:S+P,y:m+C},{type:"L",x:S+P,y:m},{type:"Z"}],{fill:d}):w=new Pt([{type:"M",x:g,y:S},{type:"L",x:g+p,y:S},{type:"L",x:g+p,y:S+P},{type:"L",x:g,y:S+P},{type:"Z"}],{fill:d}),n.push(w)})},render:(t,e)=>{const{effects:r,computedStyle:s}=e;r?r.forEach(o=>{t.save();const[i,a,l,h,u,c]=Ke(e,o).transpose().elements;t.transform(i,h,a,u,l,c),n.forEach(f=>{te({ctx:t,path:f,fontSize:s.fontSize,...o})}),t.restore()}):n.forEach(o=>{te({ctx:t,path:o,fontSize:s.fontSize})})}}}const Br={writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%",shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,translateX:0,translateY:0,skewX:0,skewY:0};class Dr extends fa{constructor(e={}){super();B(this,"debug");B(this,"content");B(this,"style");B(this,"effects");B(this,"measureDom");B(this,"needsUpdate",!0);B(this,"computedStyle",{...Br});B(this,"paragraphs",[]);B(this,"lineBox",new q);B(this,"rawGlyphBox",new q);B(this,"glyphBox",new q);B(this,"pathBox",new q);B(this,"boundingBox",new q);B(this,"measurer",new tn(this));B(this,"plugins",new Map);B(this,"fonts");this.debug=e.debug??!1,this.content=e.content??"",this.style=e.style??{},this.measureDom=e.measureDom,this.effects=e.effects,this.fonts=e.fonts,this.use(rn()).use(nn()).use(en()).use(sn())}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(r=>r.characters))}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((r,s)=>{r.fragments.forEach((o,i)=>{o.characters.forEach((a,l)=>{e(a,{paragraphIndex:s,fragmentIndex:i,characterIndex:l})})})}),this}updateParagraphs(){this.computedStyle={...Br,...this.style};let{content:e,computedStyle:r}=this;const s=[];if(typeof e=="string"){const o=new ae({},r);o.addFragment(e),s.push(o)}else{e=Array.isArray(e)?e:[e];for(const o of e)if(typeof o=="string"){const i=new ae({},r);i.addFragment(o),s.push(i)}else if(Array.isArray(o)){const i=new ae({},r);o.forEach(a=>{if(typeof a=="string")i.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&i.addFragment(l,h)}}),s.push(i)}else if("fragments"in o){const{fragments:i,...a}=o,l=new ae(a,r);i.forEach(h=>{const{content:u,...c}=h;u!==void 0&&l.addFragment(u,c)}),s.push(l)}else if("content"in o){const{content:i,...a}=o;if(i!==void 0){const l=new ae(a,r);l.addFragment(i),s.push(l)}}}return this.paragraphs=s,this}async measure(e=this.measureDom){var i,a;const r={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const s=this.measurer.measure(e);this.paragraphs=s.paragraphs,this.lineBox=s.boundingBox,this.characters.forEach(l=>{l.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox();const o=Array.from(this.plugins.values());o.sort((l,h)=>(l.updateOrder??0)-(h.updateOrder??0));for(let l=0;l<o.length;l++)await((a=(i=o[l]).update)==null?void 0:a.call(i,this));this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const l in r)s[l]=this[l],this[l]=r[l];return this.emit("measure",{text:this,result:s}),s}getGlyphBox(){const e=b.MAX,r=b.MIN;return this.characters.forEach(s=>{if(!s.getGlyphMinMax(e,r)){const{inlineBox:o}=s,i=new b(o.left,o.top),a=new b(o.left+o.width,o.top+o.height);e.min(i,a),r.max(i,a)}}),new q(e.x,e.y,r.x-e.x,r.y-e.y)}updatePathBox(){return this.pathBox=q.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):Te(e.paths??[])).filter(Boolean)),this}updateBoundingBox(){const{lineBox:e,rawGlyphBox:r,pathBox:s}=this,o=Math.min(s.left,s.left+e.left-r.left),i=Math.min(s.top,s.top+e.top-r.top),a=Math.max(s.right,s.right+e.right-r.right),l=Math.max(s.bottom,s.bottom+e.bottom-r.bottom);return this.boundingBox=new q(o,i,a-o,l-i),this}requestUpdate(){return this.needsUpdate=!0,this}async update(){const e=await this.measure();for(const r in e)this[r]=e[r];this.emit("update",{text:this})}async render(e){var a;const{view:r,pixelRatio:s=2}=e,o=r.getContext("2d");if(!o)return;this.needsUpdate&&await this.update(),Lr(o,s,this.boundingBox),Fr(o,this);const i=Array.from(this.plugins.values());i.sort((l,h)=>(l.renderOrder??0)-(h.renderOrder??0));for(let l=0;l<i.length;l++){const h=i[l];if(h.render)(a=h.render)==null||a.call(h,o,this);else if(h.paths){const u=this.computedStyle;h.paths.forEach(c=>{te({ctx:o,path:c,fontSize:u.fontSize})})}}this.emit("render",{text:this,view:r,pixelRatio:s})}}function pa(n){return new Dr(n).measure()}function da(n){return new Dr(n).render(n)}L.Character=Ks,L.Fragment=Js,L.Measurer=tn,L.Paragraph=ae,L.Text=Dr,L.defaultTextStyles=Br,L.definePlugin=ua,L.drawPath=te,L.filterEmpty=Ze,L.getTransform2D=Ke,L.hexToRgb=$r,L.highlight=en,L.isEqualObject=Qs,L.isEqualValue=Kt,L.isNone=Nt,L.listStyle=rn,L.measureText=pa,L.parseColor=ot,L.parseColormap=Ir,L.parseValueNumber=Ye,L.render=sn,L.renderText=da,L.setupView=Lr,L.textDecoration=nn,L.uploadColor=$t,L.uploadColors=Fr,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -839,6 +839,7 @@ function highlight() {
839
839
  name: "highlight",
840
840
  paths,
841
841
  update: async (text) => {
842
+ clipRects.length = 0;
842
843
  paths.length = 0;
843
844
  let groups = [];
844
845
  let group;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "0.5.11",
4
+ "version": "0.5.12",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",