modern-text 1.3.3 → 1.3.4
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 +3 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1638,6 +1638,9 @@ class Text extends EventEmitter {
|
|
|
1638
1638
|
this.effects = options.effects;
|
|
1639
1639
|
this.fonts = options.fonts;
|
|
1640
1640
|
this.use(background()).use(outline()).use(listStyle()).use(textDecoration()).use(highlight()).use(render());
|
|
1641
|
+
(options.plugins ?? []).forEach((plugin) => {
|
|
1642
|
+
this.use(plugin);
|
|
1643
|
+
});
|
|
1641
1644
|
this.updateParagraphs();
|
|
1642
1645
|
}
|
|
1643
1646
|
use(plugin) {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
}`)),document.head.appendChild(n),this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(n=>this.familyToUrl.get(n.trim())??this.familyToUrl.get(n)??n)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((r,s)=>r||this.loaded.get(s),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(e,t={}){const{cancelOther:n,injectFontFace:r=!0,injectStyleTag:s=!0,...i}=t;let a,l;if(typeof e=="string"?a=e:{src:a,family:l}=e,this.loaded.has(a))return n&&(this.loading.forEach(p=>p.cancel()),this.loading.clear()),f(this.loaded.get(a));let h=this.loading.get(a);return h||(h=this._createRequest(a,i),this.loading.set(a,h)),n&&this.loading.forEach((p,d)=>{p!==h&&(p.cancel(),this.loading.delete(d))}),h.when.then(p=>{if(this.loaded.has(a))return f(this.loaded.get(a));{const d=u(p);return t.noAdd||this.loaded.set(a,d),d.familySet.forEach(m=>{this.familyToUrl.set(m,a),typeof document<"u"&&(r&&this.injectFontFace(m,p),s&&this.injectStyleTag(m,a))}),d}}).catch(p=>{if(p instanceof DOMException&&p.message==="The user aborted a request.")return u();throw p}).finally(()=>{this.loading.delete(a)});function c(){return l?Array.isArray(l)?l:[l]:[]}function f(p){return c().forEach(d=>{p.familySet.add(d)}),p}function u(p=new ArrayBuffer(0)){let d;function m(){return d||(d=p.byteLength?js(p,!1):void 0),d}function y(){const P=m();if(P instanceof Ft||P instanceof En)return P.sfnt}return{src:a,family:l,buffer:p,familySet:new Set(c()),getFont:m,getSFNT:y}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}};M(un,"defaultRequestInit",{cache:"force-cache"});let Dn=un;const Gs=new Dn;function Rs(o,e,t=2){const n=e&&e.length,r=n?e[0]*t:o.length;let s=Tr(o,0,r,t,!0);const i=[];if(!s||s.next===s.prev)return i;let a,l,h;if(n&&(s=Hs(o,e,s,t)),o.length>80*t){a=1/0,l=1/0;let c=-1/0,f=-1/0;for(let u=t;u<r;u+=t){const p=o[u],d=o[u+1];p<a&&(a=p),d<l&&(l=d),p>c&&(c=p),d>f&&(f=d)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return Le(s,i,t,a,l,h,0),i}function Tr(o,e,t,n,r){let s;if(r===so(o,e,t,n)>0)for(let i=e;i<t;i+=n)s=_r(i/n|0,o[i],o[i+1],s);else for(let i=t-n;i>=e;i-=n)s=_r(i/n|0,o[i],o[i+1],s);return s&&ge(s,s.next)&&($e(s),s=s.next),s}function se(o,e){if(!o)return o;e||(e=o);let t=o,n;do if(n=!1,!t.steiner&&(ge(t,t.next)||tt(t.prev,t,t.next)===0)){if($e(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Le(o,e,t,n,r,s,i){if(!o)return;!i&&s&&Js(o,n,r,s);let a=o;for(;o.prev!==o.next;){const l=o.prev,h=o.next;if(s?Vs(o,n,r,s):qs(o)){e.push(l.i,o.i,h.i),$e(o),o=h.next,a=h.next;continue}if(o=h,o===a){i?i===1?(o=Ws(se(o),e),Le(o,e,t,n,r,s,2)):i===2&&Xs(o,e,t,n,r,s):Le(se(o),e,t,n,r,s,1);break}}}function qs(o){const e=o.prev,t=o,n=o.next;if(tt(e,t,n)>=0)return!1;const r=e.x,s=t.x,i=n.x,a=e.y,l=t.y,h=n.y,c=Math.min(r,s,i),f=Math.min(a,l,h),u=Math.max(r,s,i),p=Math.max(a,l,h);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=u&&d.y>=f&&d.y<=p&&Ue(r,a,s,l,i,h,d.x,d.y)&&tt(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Vs(o,e,t,n){const r=o.prev,s=o,i=o.next;if(tt(r,s,i)>=0)return!1;const a=r.x,l=s.x,h=i.x,c=r.y,f=s.y,u=i.y,p=Math.min(a,l,h),d=Math.min(c,f,u),m=Math.max(a,l,h),y=Math.max(c,f,u),P=Ln(p,d,e,t,n),T=Ln(m,y,e,t,n);let b=o.prevZ,C=o.nextZ;for(;b&&b.z>=P&&C&&C.z<=T;){if(b.x>=p&&b.x<=m&&b.y>=d&&b.y<=y&&b!==r&&b!==i&&Ue(a,c,l,f,h,u,b.x,b.y)&&tt(b.prev,b,b.next)>=0||(b=b.prevZ,C.x>=p&&C.x<=m&&C.y>=d&&C.y<=y&&C!==r&&C!==i&&Ue(a,c,l,f,h,u,C.x,C.y)&&tt(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;b&&b.z>=P;){if(b.x>=p&&b.x<=m&&b.y>=d&&b.y<=y&&b!==r&&b!==i&&Ue(a,c,l,f,h,u,b.x,b.y)&&tt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;C&&C.z<=T;){if(C.x>=p&&C.x<=m&&C.y>=d&&C.y<=y&&C!==r&&C!==i&&Ue(a,c,l,f,h,u,C.x,C.y)&&tt(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function Ws(o,e){let t=o;do{const n=t.prev,r=t.next.next;!ge(n,r)&&kr(n,t,t.next,r)&&Fe(n,r)&&Fe(r,n)&&(e.push(n.i,t.i,r.i),$e(t),$e(t.next),t=o=r),t=t.next}while(t!==o);return se(t)}function Xs(o,e,t,n,r,s){let i=o;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&no(i,a)){let l=Ir(i,a);i=se(i,i.next),l=se(l,l.next),Le(i,e,t,n,r,s,0),Le(l,e,t,n,r,s,0);return}a=a.next}i=i.next}while(i!==o)}function Hs(o,e,t,n){const r=[];for(let s=0,i=e.length;s<i;s++){const a=e[s]*n,l=s<i-1?e[s+1]*n:o.length,h=Tr(o,a,l,n,!1);h===h.next&&(h.steiner=!0),r.push(eo(h))}r.sort(Zs);for(let s=0;s<r.length;s++)t=Ys(r[s],t);return t}function Zs(o,e){let t=o.x-e.x;if(t===0&&(t=o.y-e.y,t===0)){const n=(o.next.y-o.y)/(o.next.x-o.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function Ys(o,e){const t=Ks(o,e);if(!t)return e;const n=Ir(t,o);return se(n,n.next),se(t,t.next)}function Ks(o,e){let t=e;const n=o.x,r=o.y;let s=-1/0,i;if(ge(o,t))return t;do{if(ge(o,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s&&(s=f,i=t.x<t.next.x?t:t.next,f===n))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,l=i.x,h=i.y;let c=1/0;t=i;do{if(n>=t.x&&t.x>=l&&n!==t.x&&Ar(r<h?n:s,r,l,h,r<h?s:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);Fe(t,o)&&(f<c||f===c&&(t.x>i.x||t.x===i.x&&Qs(i,t)))&&(i=t,c=f)}t=t.next}while(t!==a);return i}function Qs(o,e){return tt(o.prev,o,e.prev)<0&&tt(e.next,o,o.next)<0}function Js(o,e,t,n){let r=o;do r.z===0&&(r.z=Ln(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==o);r.prevZ.nextZ=null,r.prevZ=null,to(r)}function to(o){let e,t=1;do{let n=o,r;o=null;let s=null;for(e=0;n;){e++;let i=n,a=0;for(let h=0;h<t&&(a++,i=i.nextZ,!!i);h++);let l=t;for(;a>0||l>0&&i;)a!==0&&(l===0||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:o=r,r.prevZ=s,s=r;n=i}s.nextZ=null,t*=2}while(e>1);return o}function Ln(o,e,t,n,r){return o=(o-t)*r|0,e=(e-n)*r|0,o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,o|e<<1}function eo(o){let e=o,t=o;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==o);return t}function Ar(o,e,t,n,r,s,i,a){return(r-i)*(e-a)>=(o-i)*(s-a)&&(o-i)*(n-a)>=(t-i)*(e-a)&&(t-i)*(s-a)>=(r-i)*(n-a)}function Ue(o,e,t,n,r,s,i,a){return!(o===i&&e===a)&&Ar(o,e,t,n,r,s,i,a)}function no(o,e){return o.next.i!==e.i&&o.prev.i!==e.i&&!ro(o,e)&&(Fe(o,e)&&Fe(e,o)&&io(o,e)&&(tt(o.prev,o,e.prev)||tt(o,e.prev,e))||ge(o,e)&&tt(o.prev,o,o.next)>0&&tt(e.prev,e,e.next)>0)}function tt(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function ge(o,e){return o.x===e.x&&o.y===e.y}function kr(o,e,t,n){const r=en(tt(o,e,t)),s=en(tt(o,e,n)),i=en(tt(t,n,o)),a=en(tt(t,n,e));return!!(r!==s&&i!==a||r===0&&tn(o,t,e)||s===0&&tn(o,n,e)||i===0&&tn(t,o,n)||a===0&&tn(t,e,n))}function tn(o,e,t){return e.x<=Math.max(o.x,t.x)&&e.x>=Math.min(o.x,t.x)&&e.y<=Math.max(o.y,t.y)&&e.y>=Math.min(o.y,t.y)}function en(o){return o>0?1:o<0?-1:0}function ro(o,e){let t=o;do{if(t.i!==o.i&&t.next.i!==o.i&&t.i!==e.i&&t.next.i!==e.i&&kr(t,t.next,o,e))return!0;t=t.next}while(t!==o);return!1}function Fe(o,e){return tt(o.prev,o,o.next)<0?tt(o,e,o.next)>=0&&tt(o,o.prev,e)>=0:tt(o,e,o.prev)<0||tt(o,o.next,e)<0}function io(o,e){let t=o,n=!1;const r=(o.x+e.x)/2,s=(o.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==o);return n}function Ir(o,e){const t=Un(o.i,o.x,o.y),n=Un(e.i,e.x,e.y),r=o.next,s=e.prev;return o.next=e,e.prev=o,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function _r(o,e,t,n){const r=Un(o,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function $e(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function Un(o,e,t){return{i:o,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function so(o,e,t,n){let r=0;for(let s=e,i=t-n;s<t;s+=n)r+=(o[i]-o[s])*(o[s+1]+o[i+1]),i=s;return r}function oo(o,e,t,n={}){const{radius:r=1}=n;o.moveTo(e,t),o.arc(e,t,r,0,Math.PI*2)}const ao={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Fn(o,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:i="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:f=0,shadowBlur:u=0,shadowColor:p="rgba(0, 0, 0, 0)"}=e;o.fillStyle=t,o.strokeStyle=n,o.lineWidth=r,o.lineCap=s,o.lineJoin=ao[i],o.miterLimit=a,o.setLineDash(l),o.lineDashOffset=h,o.shadowOffsetX=c,o.shadowOffsetY=f,o.shadowBlur=u,o.shadowColor=p}class A{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new A(1/0,1/0)}static get MIN(){return new A(-1/0,-1/0)}get array(){return[this.x,this.y]}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,s=-(this.y-t.y),i=Math.sin(n),a=Math.cos(n);return this.set(t.x+(r*a-s*i),t.y-(r*i+s*a)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){const r=e<0?n.x-this.x+n.x:this.x,s=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=s*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,s=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*s),this.y=n.y+(s+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new A(this.x,this.y)}}class X{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new A((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new X;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,s)=>(r.left=Math.min(r.left,s.left),r.top=Math.min(r.top,s.top),r.right=Math.max(r.right,s.right),r.bottom=Math.max(r.bottom,s.bottom),r),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new X(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new X(this.left,this.top,this.width,this.height)}}class Mt{constructor(e=1,t=0,n=0,r=0,s=1,i=0,a=0,l=0,h=1){M(this,"elements",[]);this.set(e,t,n,r,s,i,a,l,h)}set(e,t,n,r,s,i,a,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=n,c[7]=i,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,i=n[0],a=n[3],l=n[6],h=n[1],c=n[4],f=n[7],u=n[2],p=n[5],d=n[8],m=r[0],y=r[3],P=r[6],T=r[1],b=r[4],C=r[7],x=r[2],v=r[5],S=r[8];return s[0]=i*m+a*T+l*x,s[3]=i*y+a*b+l*v,s[6]=i*P+a*C+l*S,s[1]=h*m+c*T+f*x,s[4]=h*y+c*b+f*v,s[7]=h*P+c*C+f*S,s[2]=u*m+p*T+d*x,s[5]=u*y+p*b+d*v,s[8]=u*P+p*C+d*S,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],a=e[5],l=e[6],h=e[7],c=e[8],f=c*i-a*h,u=a*l-c*s,p=h*s-i*l,d=t*f+n*u+r*p;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/d;return e[0]=f*m,e[1]=(r*h-c*n)*m,e[2]=(a*n-r*i)*m,e[3]=u*m,e[4]=(c*t-r*l)*m,e[5]=(r*s-a*t)*m,e[6]=p*m,e[7]=(n*l-h*t)*m,e[8]=(i*t-n*s)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply($n.makeScale(e,t)),this}rotate(e){return this.premultiply($n.makeRotation(-e)),this}translate(e,t){return this.premultiply($n.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const $n=new Mt;function Or(o,e,t,n){const r=o*t+e*n,s=Math.sqrt(o*o+e*e)*Math.sqrt(t*t+n*n);let i=Math.acos(Math.max(-1,Math.min(1,r/s)));return o*n-e*t<0&&(i=-i),i}function lo(o,e,t,n,r,s,i,a){if(e===0||t===0){o.lineTo(a.x,a.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const l=(i.x-a.x)/2,h=(i.y-a.y)/2,c=Math.cos(n)*l+Math.sin(n)*h,f=-Math.sin(n)*l+Math.cos(n)*h;let u=e*e,p=t*t;const d=c*c,m=f*f,y=d/u+m/p;if(y>1){const z=Math.sqrt(y);e=z*e,t=z*t,u=e*e,p=t*t}const P=u*m+p*d,T=(u*p-P)/P;let b=Math.sqrt(Math.max(0,T));r===s&&(b=-b);const C=b*e*f/t,x=-b*t*c/e,v=Math.cos(n)*C-Math.sin(n)*x+(i.x+a.x)/2,S=Math.sin(n)*C+Math.cos(n)*x+(i.y+a.y)/2,w=Or(1,0,(c-C)/e,(f-x)/t),k=Or((c-C)/e,(f-x)/t,(-c-C)/e,(-f-x)/t)%(Math.PI*2);o.ellipse(v,S,e,t,n,w,w+k,s===0)}const it={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function qt(o,e,t=0){let a=0,l=!0,h="",c="";const f=[];function u(y,P,T){const b=new SyntaxError(`Unexpected character "${y}" at index ${P}.`);throw b.partial=T,b}function p(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let d;const m=o.length;for(let y=0;y<m;y++){if(d=o[y],Array.isArray(e)&&e.includes(f.length%t)&&it.FLAGS.test(d)){a=1,h=d,p();continue}if(a===0){if(it.WHITESPACE.test(d))continue;if(it.DIGIT.test(d)||it.SIGN.test(d)){a=1,h=d;continue}if(it.POINT.test(d)){a=2,h=d;continue}it.COMMA.test(d)&&(l&&u(d,y,f),l=!0)}if(a===1){if(it.DIGIT.test(d)){h+=d;continue}if(it.POINT.test(d)){h+=d,a=2;continue}if(it.EXP.test(d)){a=3;continue}it.SIGN.test(d)&&h.length===1&&it.SIGN.test(h[0])&&u(d,y,f)}if(a===2){if(it.DIGIT.test(d)){h+=d;continue}if(it.EXP.test(d)){a=3;continue}it.POINT.test(d)&&h[h.length-1]==="."&&u(d,y,f)}if(a===3){if(it.DIGIT.test(d)){c+=d;continue}if(it.SIGN.test(d)){if(c===""){c+=d;continue}c.length===1&&it.SIGN.test(c)&&u(d,y,f)}}it.WHITESPACE.test(d)?(p(),a=0,l=!1):it.COMMA.test(d)?(p(),a=0,l=!0):it.SIGN.test(d)?(p(),a=1,h=d):it.POINT.test(d)?(p(),a=2,h=d):u(d,y,f)}return p(),f}function me(o,e){return o-(e-o)}function Br(o,e){const t=new A,n=new A;for(let r=0,s=o.length;r<s;r++){const i=o[r];if(i.type==="m"||i.type==="M")i.type==="m"?t.add(i):t.copy(i),e.moveTo(t.x,t.y),n.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,e.lineTo(t.x,t.y),n.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,e.lineTo(t.x,t.y),n.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?t.add(i):t.copy(i),e.lineTo(t.x,t.y),n.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),n.x=t.x+i.x2,n.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),n.x=i.x2,n.y=i.y2,t.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(me(t.x,n.x),me(t.y,n.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),n.x=t.x+i.x2,n.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(me(t.x,n.x),me(t.y,n.y),i.x2,i.y2,i.x,i.y),n.x=i.x2,n.y=i.y2,t.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),n.x=t.x+i.x1,n.y=t.y+i.y1,t.add(i)):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),n.x=i.x1,n.y=i.y1,t.copy(i));else if(i.type==="t"||i.type==="T"){const a=me(t.x,n.x),l=me(t.y,n.y);n.x=a,n.y=l,i.type==="t"?(e.quadraticCurveTo(a,l,t.x+i.x,t.y+i.y),t.add(i)):(e.quadraticCurveTo(a,l,i.x,i.y),t.copy(i))}else if(i.type==="a"||i.type==="A"){const a=t.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.add(i)}else{if(t.equals(i))continue;t.copy(i)}n.copy(t),lo(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,a,t)}else i.type==="z"||i.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",i)}}function ho(o){let e,t;const n=[];for(let r=0,s=o.length;r<s;r++){const i=o[r];switch(i.type){case"m":case"M":if(i.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&i.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${i.type} ${i.x} ${i.y}`),t={x:i.x,y:i.y},e={x:i.x,y:i.y};break;case"h":case"H":n.push(`${i.type} ${i.x}`),t={x:i.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${i.type} ${i.y}`),t={x:(t==null?void 0:t.x)??0,y:i.y};break;case"l":case"L":n.push(`${i.type} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"c":case"C":n.push(`${i.type} ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"s":case"S":n.push(`${i.type} ${i.x2} ${i.y2} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"q":case"Q":n.push(`${i.type} ${i.x1} ${i.y1} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"t":case"T":n.push(`${i.type} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"a":case"A":n.push(`${i.type} ${i.rx} ${i.ry} ${i.angle} ${i.largeArcFlag} ${i.sweepFlag} ${i.x} ${i.y}`),t={x:i.x,y:i.y};break;case"z":case"Z":n.push(i.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const co=/[a-df-z][^a-df-z]*/gi;function Er(o){const e=[],t=o.match(co);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const s=t[n],i=s.charAt(0),a=s.slice(1).trim();let l;switch(i){case"m":case"M":l=qt(a);for(let h=0,c=l.length;h<c;h+=2)h===0?e.push({type:i,x:l[h],y:l[h+1]}):e.push({type:i==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=qt(a);for(let h=0,c=l.length;h<c;h++)e.push({type:i,x:l[h]});break;case"v":case"V":l=qt(a);for(let h=0,c=l.length;h<c;h++)e.push({type:i,y:l[h]});break;case"l":case"L":l=qt(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:i,x:l[h],y:l[h+1]});break;case"c":case"C":l=qt(a);for(let h=0,c=l.length;h<c;h+=6)e.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=qt(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:i,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=qt(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:i,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=qt(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:i,x:l[h],y:l[h+1]});break;case"a":case"A":l=qt(a,[3,4],7);for(let h=0,c=l.length;h<c;h+=7)e.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":e.push({type:i});break;default:console.warn(s)}}return e}function Dr(o,e,t,n,r){const s=(n-e)*.5,i=(r-t)*.5,a=o*o,l=o*a;return(2*t-2*n+s+i)*l+(-3*t+3*n-2*s-i)*a+s*o+t}function fo(o,e){const t=1-o;return t*t*t*e}function uo(o,e){const t=1-o;return 3*t*t*o*e}function po(o,e){return 3*(1-o)*o*o*e}function yo(o,e){return o*o*o*e}function Lr(o,e,t,n,r){return fo(o,e)+uo(o,t)+po(o,n)+yo(o,r)}function Ur(o,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:s=2,verticesOffset:i=t.length/s,indicesOffset:a=n.length}=e;const l=Rs(o,r,2);if(l){for(let c=0;c<l.length;c+=3)n[a++]=l[c]+i,n[a++]=l[c+1]+i,n[a++]=l[c+2]+i;let h=i*s;for(let c=0;c<o.length;c+=2)t[h]=o[c],t[h+1]=o[c+1],h+=s}return{vertices:t,indices:n}}const go=8,nn=11920929e-14,mo=1;function xo(o,e,t,n,r,s,i,a,l=.5,h=[]){const f=Math.min(.99,Math.max(0,l));let u=(mo-f)/1;return u*=u,zn(o,e,t,n,r,s,i,a,h,u,0),h.push(i,a),h}function zn(o,e,t,n,r,s,i,a,l,h,c){if(c>go)return;const f=(o+t)/2,u=(e+n)/2,p=(t+r)/2,d=(n+s)/2,m=(r+i)/2,y=(s+a)/2,P=(f+p)/2,T=(u+d)/2,b=(p+m)/2,C=(d+y)/2,x=(P+b)/2,v=(T+C)/2;if(c>0){let S=i-o,w=a-e;const k=Math.abs((t-i)*w-(n-a)*S),z=Math.abs((r-i)*w-(s-a)*S);if(k>nn&&z>nn){if((k+z)*(k+z)<=h*(S*S+w*w)){l.push(x,v);return}}else if(k>nn){if(k*k<=h*(S*S+w*w)){l.push(x,v);return}}else if(z>nn){if(z*z<=h*(S*S+w*w)){l.push(x,v);return}}else if(S=x-(o+i)/2,w=v-(e+a)/2,S*S+w*w<=h){l.push(x,v);return}}zn(o,e,f,u,P,T,x,v,l,h,c+1),zn(x,v,b,C,m,y,i,a,l,h,c+1)}const wo=8,vo=11920929e-14,bo=1;function So(o,e,t,n,r,s,i=.5,a=[]){const h=Math.min(.99,Math.max(0,i));let c=(bo-h)/1;return c*=c,Nn(a,o,e,t,n,r,s,c,0),a.push(r,s),a}function Nn(o,e,t,n,r,s,i,a,l){if(l>wo)return;const h=(e+n)/2,c=(t+r)/2,f=(n+s)/2,u=(r+i)/2,p=(h+f)/2,d=(c+u)/2;let m=s-e,y=i-t;const P=Math.abs((n-s)*y-(r-i)*m);if(P>vo){if(P*P<=a*(m*m+y*y)){o.push(p,d);return}}else if(m=p-(e+s)/2,y=d-(t+i)/2,m*m+y*y<=a){o.push(p,d);return}Nn(o,e,t,h,c,p,d,a,l+1),Nn(o,p,d,f,u,s,i,a,l+1)}function Mo(o,e){const t=1-o;return t*t*e}function Co(o,e){return 2*(1-o)*o*e}function Po(o,e){return o*o*e}function Fr(o,e,t,n){return Mo(o,e)+Co(o,t)+Po(o,n)}const To=1e-4,$r=1e-4;function Ao(o,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:s=!1,closed:i=!0}=e,a=To;if(o.length===0)return{vertices:t,indices:n};const l=r;let h=l.alignment;if(r.alignment!==.5){let L=ko(o);s&&(L*=-1),h=(h-.5)*L+.5}const c={x:o[0],y:o[1]},f={x:o[o.length-2],y:o[o.length-1]},u=i,p=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(u){o=o.slice(),p&&(o.pop(),o.pop(),f.x=o[o.length-2],f.y=o[o.length-1]);const L=(c.x+f.x)*.5,$=(f.y+c.y)*.5;o.unshift(L,$),o.push(L,$)}const d=t,m=o.length/2;let y=o.length;const P=d.length/2,T=l.width/2,b=T*T,C=l.miterLimit*l.miterLimit;let x=o[0],v=o[1],S=o[2],w=o[3],k=0,z=0,O=-(v-w),B=x-S,U=0,D=0,_=Math.sqrt(O*O+B*B);O/=_,B/=_,O*=T,B*=T;const H=h,I=(1-H)*2,E=H*2;u||(l.cap==="round"?y+=oe(x-O*(I-E)*.5,v-B*(I-E)*.5,x-O*I,v-B*I,x+O*E,v+B*E,d,!0)+2:l.cap==="square"&&(y+=zr(x,v,O,B,I,E,!0,d))),d.push(x-O*I,v-B*I),d.push(x+O*E,v+B*E);for(let L=1;L<m-1;++L){x=o[(L-1)*2],v=o[(L-1)*2+1],S=o[L*2],w=o[L*2+1],k=o[(L+1)*2],z=o[(L+1)*2+1],O=-(v-w),B=x-S,_=Math.sqrt(O*O+B*B),O/=_,B/=_,O*=T,B*=T,U=-(w-z),D=S-k,_=Math.sqrt(U*U+D*D),U/=_,D/=_,U*=T,D*=T;const $=S-x,W=v-w,F=S-k,V=z-w,R=$*F+W*V,Y=W*F-V*$,Z=Y<0;if(Math.abs(Y)<.001*Math.abs(R)){d.push(S-O*I,w-B*I),d.push(S+O*E,w+B*E),R>=0&&(l.join==="round"?y+=oe(S,w,S-O*I,w-B*I,S-U*I,w-D*I,d,!1)+4:y+=2,d.push(S-U*E,w-D*E),d.push(S+U*I,w+D*I));continue}const nt=(-O+x)*(-B+w)-(-O+S)*(-B+v),Wt=(-U+k)*(-D+w)-(-U+S)*(-D+z),Bt=($*Wt-F*nt)/Y,Ct=(V*nt-W*Wt)/Y,At=(Bt-S)*(Bt-S)+(Ct-w)*(Ct-w),ht=S+(Bt-S)*I,kt=w+(Ct-w)*I,zt=S-(Bt-S)*E,Nt=w-(Ct-w)*E,Et=Math.min($*$+W*W,F*F+V*V),ci=Z?I:E,xa=Et+ci*ci*b;At<=xa?l.join==="bevel"||At/b>C?(Z?(d.push(ht,kt),d.push(S+O*E,w+B*E),d.push(ht,kt),d.push(S+U*E,w+D*E)):(d.push(S-O*I,w-B*I),d.push(zt,Nt),d.push(S-U*I,w-D*I),d.push(zt,Nt)),y+=2):l.join==="round"?Z?(d.push(ht,kt),d.push(S+O*E,w+B*E),y+=oe(S,w,S+O*E,w+B*E,S+U*E,w+D*E,d,!0)+4,d.push(ht,kt),d.push(S+U*E,w+D*E)):(d.push(S-O*I,w-B*I),d.push(zt,Nt),y+=oe(S,w,S-O*I,w-B*I,S-U*I,w-D*I,d,!1)+4,d.push(S-U*I,w-D*I),d.push(zt,Nt)):(d.push(ht,kt),d.push(zt,Nt)):(d.push(S-O*I,w-B*I),d.push(S+O*E,w+B*E),l.join==="round"?Z?y+=oe(S,w,S+O*E,w+B*E,S+U*E,w+D*E,d,!0)+2:y+=oe(S,w,S-O*I,w-B*I,S-U*I,w-D*I,d,!1)+2:l.join==="miter"&&At/b<=C&&(Z?(d.push(zt,Nt),d.push(zt,Nt)):(d.push(ht,kt),d.push(ht,kt)),y+=2),d.push(S-U*I,w-D*I),d.push(S+U*E,w+D*E),y+=2)}x=o[(m-2)*2],v=o[(m-2)*2+1],S=o[(m-1)*2],w=o[(m-1)*2+1],O=-(v-w),B=x-S,_=Math.sqrt(O*O+B*B),O/=_,B/=_,O*=T,B*=T,d.push(S-O*I,w-B*I),d.push(S+O*E,w+B*E),u||(l.cap==="round"?y+=oe(S-O*(I-E)*.5,w-B*(I-E)*.5,S-O*I,w-B*I,S+O*E,w+B*E,d,!1)+2:l.cap==="square"&&(y+=zr(S,w,O,B,I,E,!1,d)));const q=$r*$r;for(let L=P;L<y+P-2;++L)x=d[L*2],v=d[L*2+1],S=d[(L+1)*2],w=d[(L+1)*2+1],k=d[(L+2)*2],z=d[(L+2)*2+1],!(Math.abs(x*(w-z)+S*(z-v)+k*(v-w))<q)&&n.push(L,L+1,L+2);return{vertices:t,indices:n}}function ko(o){const e=o.length;if(e<6)return 1;let t=0;for(let n=0,r=o[e-2],s=o[e-1];n<e;n+=2){const i=o[n],a=o[n+1];t+=(i-r)*(a+s),r=i,s=a}return t<0?-1:1}function zr(o,e,t,n,r,s,i,a){const l=o-t*r,h=e-n*r,c=o+t*s,f=e+n*s;let u,p;i?(u=n,p=-t):(u=-n,p=t);const d=l+u,m=h+p,y=c+u,P=f+p;return a.push(d,m),a.push(y,P),2}function oe(o,e,t,n,r,s,i,a){const l=t-o,h=n-e;let c=Math.atan2(l,h),f=Math.atan2(r-o,s-e);a&&c<f?c+=Math.PI*2:!a&&c>f&&(f+=Math.PI*2);let u=c;const p=f-c,d=Math.abs(p),m=Math.sqrt(l*l+h*h),y=(15*d*Math.sqrt(m)/Math.PI>>0)+1,P=p/y;if(u+=P,a){i.push(o,e),i.push(t,n);for(let T=1,b=u;T<y;T++,b+=P)i.push(o,e),i.push(o+Math.sin(b)*m,e+Math.cos(b)*m);i.push(o,e),i.push(r,s)}else{i.push(t,n),i.push(o,e);for(let T=1,b=u;T<y;T++,b+=P)i.push(o+Math.sin(b)*m,e+Math.cos(b)*m),i.push(o,e);i.push(r,s),i.push(o,e)}return y*2}class xe{constructor(){M(this,"arcLengthDivision",200);M(this,"_arcLengths")}getPointAt(e,t=new A){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){return this.getControlPointRefs().forEach(t=>{t.applyMatrix3(e)}),this}getUnevenPointArray(e=5,t=[]){const n=new A;for(let r=0,s=Math.max(1,e)-1;r<=s;r++)this.getPoint(r/s,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new A;for(let r=0,s=Math.max(1,e)-1;r<=s;r++)this.getPointAt(r/s,n),t.push(n.x,n.y);return t}getAdaptivePointArray(e=[]){return this.getUnevenPointArray(5,e)}_pointArrayToPoint(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){const s=e[n],i=e[n+1];t.push(new A(s,i))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedPointArray(e);return this._pointArrayToPoint(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenPointArray(e);return this._pointArrayToPoint(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptivePointArray();return this._pointArrayToPoint(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenPointArray(e):n=this.getAdaptivePointArray(),this._pointArrayToPoint(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),s=1;s<=e;s++){const i=this.getPoint(s/e);n+=i.distanceTo(r),t.push(n),r=i}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,s=t??e*n[r-1];if(r<2)return s/n[0];let i=0,a=0,l=r-1,h;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),h=n[i]-s,h<0)a=i+1;else if(h>0)l=i-1;else{l=i;break}if(i=l,n[i]===s)return i/(r-1);const c=n[i],u=n[i+1]-c,p=(s-c)/u;return(i+p)/(r-1)}getTangent(e,t=new A){const r=Math.max(0,e-1e-4),s=Math.min(1,e+1e-4);return t.copy(this.getPoint(s).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new A){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,s=(n+r)/2;for(;r-n>t;){s=(n+r)/2;const i=this.getPoint(s);if(i.distanceTo(e)<t)return s;i.x<e.x?n=s:r=s}return s}getMinMax(e=A.MAX,t=A.MIN){const n=this.getPoints();for(let r=0,s=n.length;r<s;r++){const i=n[r];e.min(i),t.max(i)}return{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return Ur(this.getAdaptivePointArray(),e)}strokeTriangulate(e){return Ao(this.getAdaptivePointArray(),e)}toTriangulatedSVGString(e=this.fillTriangulate(),t=0){const{vertices:n,indices:r}=e,s={x:-t,y:-t},i={x:t,y:t},a=c=>{const f=n[c*2],u=n[c*2+1];return s.x=Math.min(s.x,f+t),i.x=Math.max(i.x,f+t),s.y=Math.min(s.y,u+t),i.y=Math.max(i.y,u+t),[f,u]};let l="";for(let c=0,f=r.length;c<f;c+=3){const u=a(r[c]),p=a(r[c+1]),d=a(r[c+2]);l+=`<polygon points="${u.join(",")} ${p.join(",")} ${d.join(",")}" fill="none" stroke="black" />`}const h=[s.x,s.y,i.x-s.x,i.y-s.y];return`<svg width="${h[2]}" height="${h[3]}" viewBox="${h.join(" ")}" xmlns="http://www.w3.org/2000/svg">${l}</svg>`}toTriangulatedSVG(e,t){return new DOMParser().parseFromString(this.toTriangulatedSVGString(e,t),"image/svg+xml").documentElement}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const s=t[n];n===0?e.push({type:"M",x:s.x,y:s.y}):e.push({type:"L",x:s.x,y:s.y})}return e}toData(){return ho(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Io=new Mt,Nr=new Mt,jr=new Mt,rn=new A;class jn extends xe{constructor(e=new A,t=new A,n=new A,r=0,s=0,i=Math.PI*2,a=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=s,this.endAngle=i,this.clockwise=a}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const n=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new A){const n=this._getDeltaAngle(),r=this.startAngle+e*n;let s=this.cx+this.rx*Math.cos(r),i=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const a=Math.cos(this.rotate),l=Math.sin(this.rotate),h=s-this.cx,c=i-this.cy;s=h*a-c*l+this.cx,i=h*l+c*a+this.cy}return t.set(s,i)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:s,endAngle:i,clockwise:a,rotate:l}=this,h=e+n*Math.cos(s)*Math.cos(l)-r*Math.sin(s)*Math.sin(l),c=t+n*Math.cos(s)*Math.sin(l)+r*Math.sin(s)*Math.cos(l),f=Math.abs(s-i),u=f>Math.PI?1:0,p=a?1:0,d=l*180/Math.PI;if(f>=2*Math.PI){const m=s+Math.PI,y=e+n*Math.cos(m)*Math.cos(l)-r*Math.sin(m)*Math.sin(l),P=t+n*Math.cos(m)*Math.sin(l)+r*Math.sin(m)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:n,ry:r,angle:d,largeArcFlag:0,sweepFlag:p,x:y,y:P},{type:"A",rx:n,ry:r,angle:d,largeArcFlag:0,sweepFlag:p,x:h,y:c}]}else{const m=e+n*Math.cos(i)*Math.cos(l)-r*Math.sin(i)*Math.sin(l),y=t+n*Math.cos(i)*Math.sin(l)+r*Math.sin(i)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:n,ry:r,angle:d,largeArcFlag:u,sweepFlag:p,x:m,y}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:s,rotate:i,startAngle:a,endAngle:l,clockwise:h}=this;return e.ellipse(t,n,r,s,i,a,l,!h),this}applyTransform(e){return rn.set(this.cx,this.cy),rn.applyMatrix3(e),this.cx=rn.x,this.cy=rn.y,Bo(e)?_o(this,e):Oo(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:s,dx:i,dy:a}=this;if(!(r>=0&&s>=0&&i>=0&&a>=0))return e;const l=Math.ceil(2.3*Math.sqrt(r+s)),h=t,c=n,f=l*8+(i?4:0)+(a?4:0);if(f===0)return e;if(l===0)return e[0]=e[6]=h+i,e[1]=e[3]=c+a,e[2]=e[4]=h-i,e[5]=e[7]=c-a,e;let u=0,p=l*4+(i?2:0)+2,d=p,m=f,y=i+r,P=a,T=h+y,b=h-y,C=c+P;if(e[u++]=T,e[u++]=C,e[--p]=C,e[--p]=b,a){const v=c-P;e[d++]=b,e[d++]=v,e[--m]=v,e[--m]=T}for(let v=1;v<l;v++){const S=Math.PI/2*(v/l),w=i+Math.cos(S)*r,k=a+Math.sin(S)*s,z=h+w,O=h-w,B=c+k,U=c-k;e[u++]=z,e[u++]=B,e[--p]=B,e[--p]=O,e[d++]=O,e[d++]=U,e[--m]=U,e[--m]=z}y=i,P=a+s,T=h+y,b=h-y,C=c+P;const x=c-P;return e[u++]=T,e[u++]=C,e[--m]=x,e[--m]=T,i&&(e[u++]=b,e[u++]=C,e[--m]=x,e[--m]=b),e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:s=t.length/r,indicesOffset:i=n.length}=e;const a=this.getAdaptivePointArray();if(a.length===0)return{vertices:t,indices:n};let l=0,h=0;for(let u=0;u<a.length;u+=2)l+=a[u],h+=a[u+1];l/=a.length/2,h/=a.length/2;let c=s;t[c*r]=l,t[c*r+1]=h;const f=c++;for(let u=0;u<a.length;u+=2)t[c*r]=a[u],t[c*r+1]=a[u+1],u>0&&(n[i++]=c,n[i++]=f,n[i++]=c-1),c++;return n[i++]=f+1,n[i++]=f,n[i++]=c-1,{vertices:t,indices:n}}getMinMax(e=A.MAX,t=A.MIN){const{cx:n,cy:r,rx:s,ry:i,rotate:a}=this,l=Math.cos(a),h=Math.sin(a),c=Math.sqrt(s*s*l*l+i*i*h*h),f=Math.sqrt(s*s*h*h+i*i*l*l);return e.x=Math.min(e.x,n-c),e.y=Math.min(e.y,r-f),t.x=Math.max(t.x,n+c),t.y=Math.max(t.y,r+f),{min:e,max:t}}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function _o(o,e){const t=o.rx,n=o.ry,r=Math.cos(o.rotate),s=Math.sin(o.rotate),i=new A(t*r,t*s),a=new A(-n*s,n*r),l=i.applyMatrix3(e),h=a.applyMatrix3(e),c=Io.set(l.x,h.x,0,l.y,h.y,0,0,0,1),f=Nr.copy(c).invert(),d=jr.copy(f).transpose().multiply(f).elements,m=Eo(d[0],d[1],d[4]),y=Math.sqrt(m.rt1),P=Math.sqrt(m.rt2);if(o.rx=1/y,o.ry=1/P,o.rotate=Math.atan2(m.sn,m.cs),!((o.endAngle-o.startAngle)%(2*Math.PI)<Number.EPSILON)){const b=Nr.set(y,0,0,0,P,0,0,0,1),C=jr.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),x=b.multiply(C).multiply(c),v=S=>{const{x:w,y:k}=new A(Math.cos(S),Math.sin(S)).applyMatrix3(x);return Math.atan2(k,w)};o.startAngle=v(o.startAngle),o.endAngle=v(o.endAngle),Gr(e)&&(o.clockwise=!o.clockwise)}}function Oo(o,e){const t=Rr(e),n=qr(e);o.rx*=t,o.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);o.rotate+=r,Gr(e)&&(o.startAngle*=-1,o.endAngle*=-1,o.clockwise=!o.clockwise)}function Gr(o){const e=o.elements;return e[0]*e[4]-e[1]*e[3]<0}function Bo(o){const e=o.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=Rr(o),r=qr(o);return Math.abs(t/(n*r))>Number.EPSILON}function Rr(o){const e=o.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function qr(o){const e=o.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Eo(o,e,t){let n,r,s,i,a;const l=o+t,h=o-t,c=Math.sqrt(h*h+4*e*e);return l>0?(n=.5*(l+c),a=1/n,r=o*a*t-e*a*e):l<0?r=.5*(l-c):(n=.5*c,r=-.5*c),h>0?s=h+c:s=h-c,Math.abs(s)>2*Math.abs(e)?(a=-2*e/s,i=1/Math.sqrt(1+a*a),s=a*i):Math.abs(e)===0?(s=1,i=0):(a=-.5*s/e,s=1/Math.sqrt(1+a*a),i=a*s),h>0&&(a=s,s=-i,i=a),{rt1:n,rt2:r,cs:s,sn:i}}class Do extends jn{constructor(e=0,t=0,n=1,r=0,s=Math.PI*2,i=!1){super(new A(e,t),new A(n,n),new A,0,r,s,i)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:s,endAngle:i,clockwise:a}=this;return e.arc(t,n,r,s,i,!a),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,startAngle:s,endAngle:i,clockwise:a}=this;let l=Math.abs(s-i);(!a&&s>i||a&&i>s)&&(l=2*Math.PI-l);let h=Math.max(6,Math.floor(6*r**(1/3)*(l/Math.PI)));h=Math.max(h,3);let c=l/h,f=s;c*=a?1:-1;for(let u=0;u<h+1;u++){const p=Math.cos(f),d=Math.sin(f),m=t+p*r,y=n+d*r;e.push(m,y),f+=c}return e}}class Ht extends xe{constructor(e=new A,t=new A){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new Ht(new A(e,t),new A(n,r))}getPoint(e,t=new A){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new A){return this.getPoint(e,t)}getTangent(e,t=new A){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new A){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=A.MAX,t=A.MIN){const{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e,max:t}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:s=t.length/r,indicesOffset:i=n.length}=e;const a=this.p1.x,l=this.p1.y,h=this.p2.x-this.p1.x||1,c=this.p2.y-this.p2.y||1,f=[a,l,a+h,l,a+h,l+c,a,l+c];let u=0;s*=r,t[s+u]=f[0],t[s+u+1]=f[1],u+=r,t[s+u]=f[2],t[s+u+1]=f[3],u+=r,t[s+u]=f[6],t[s+u+1]=f[7],u+=r,t[s+u]=f[4],t[s+u+1]=f[5],u+=r;const p=s/r;return n[i++]=p,n[i++]=p+1,n[i++]=p+2,n[i++]=p+1,n[i++]=p+3,n[i++]=p+2,{vertices:t,indices:n}}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class ze extends xe{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof ze?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new A){const n=e*this.getLength(),r=this.getLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const i=r[s]-n,a=this.curves[s],l=a.getLength();return a.getPointAt(l===0?0:1-i/l,t)}s++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){return e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),e}getSpacedPointArray(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedPointArray(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}fillTriangulate(e){const t=(e==null?void 0:e.indices)??[],n=(e==null?void 0:e.vertices)??[],r=[],s=()=>{if(r.length){const i=[];r.forEach(a=>{const l=a.p1.x,h=a.p1.y;(i[i.length-2]!==l||i[i.length-1]!==h)&&i.push(l,h),i.push(a.p2.x,a.p2.y)}),Ur(i,{...e,indices:t,vertices:n}),r.length=0}};return this.curves.forEach(i=>{i instanceof Ht?r.push(i):(s(),i.fillTriangulate({...e,indices:t,vertices:n}))}),s(),{indices:t,vertices:n}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=A.MAX,t=A.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Gn extends xe{constructor(e=new A,t=new A,n=new A,r=new A){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,s,i,a,l){return new Gn(new A(e,t),new A(n,r),new A(s,i),new A(a,l))}getPoint(e,t=new A){const{p1:n,cp1:r,cp2:s,p2:i}=this;return t.set(Lr(e,n.x,r.x,s.x,i.x),Lr(e,n.y,r.y,s.y,i.y))}getAdaptivePointArray(e=[]){return xo(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){const r=t*t-4*e*n;if(r<0)return[];const s=Math.sqrt(r),i=(-t+s)/(2*e),a=(-t-s)/(2*e);return[i,a].filter(l=>l>=0&&l<=1)}getMinMax(e=A.MAX,t=A.MIN){const{p1:n,cp1:r,cp2:s,p2:i}=this,a=this._solveQuadratic(3*(r.x-n.x),6*(s.x-r.x),3*(i.x-s.x)),l=this._solveQuadratic(3*(r.y-n.y),6*(s.y-r.y),3*(i.y-s.y)),h=[0,1,...a,...l];return((f,u)=>{for(const p of f)for(let d=0;d<=u;d++){const m=d/u-.5,y=Math.min(1,Math.max(0,p+m)),P=this.getPoint(y);e.x=Math.min(e.x,P.x),e.y=Math.min(e.y,P.y),t.x=Math.max(t.x,P.x),t.y=Math.max(t.y,P.y)}})(h,10),{min:e,max:t}}toCommands(){const{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp1:n,cp2:r,p2:s}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,s.x,s.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class Lo extends jn{constructor(e=0,t=0,n=1,r=1,s=0,i=0,a=Math.PI*2,l=!1){super(new A(e,t),new A(n,r),new A,s,i,a,l)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Uo extends ze{}class Rn extends xe{constructor(e=new A,t=new A,n=new A){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,s,i){return new Rn(new A(e,t),new A(n,r),new A(s,i))}getPoint(e,t=new A){const{p1:n,cp:r,p2:s}=this;return t.set(Fr(e,n.x,r.x,s.x),Fr(e,n.y,r.y,s.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return So(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=A.MAX,t=A.MIN){const{p1:n,cp:r,p2:s}=this,i=.5*(n.x+r.x),a=.5*(n.y+r.y),l=.5*(n.x+s.x),h=.5*(n.y+s.y);return e.x=Math.min(e.x,n.x,s.x,i,l),e.y=Math.min(e.y,n.y,s.y,a,h),t.x=Math.max(t.x,n.x,s.x,i,l),t.y=Math.max(t.y,n.y,s.y,a,h),{min:e,max:t}}toCommands(){const{p1:e,cp:t,p2:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){const{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class Fo extends Uo{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){const{x:e,y:t,width:n,height:r}=this,s=[new A(e,t),new A(e+n,t),new A(e+n,t+r),new A(e,t+r)];return this.curves=[new Ht(s[0],s[1]),new Ht(s[1],s[2]),new Ht(s[2],s[3]),new Ht(s[3],s[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:s=t.length/r,indicesOffset:i=n.length}=e;const{x:a,y:l,width:h,height:c}=this,f=[a,l,a+h,l,a+h,l+c,a,l+c];let u=0;s*=r,t[s+u]=f[0],t[s+u+1]=f[1],u+=r,t[s+u]=f[2],t[s+u+1]=f[3],u+=r,t[s+u]=f[6],t[s+u+1]=f[7],u+=r,t[s+u]=f[4],t[s+u+1]=f[5],u+=r;const p=s/r;return n[i++]=p,n[i++]=p+1,n[i++]=p+2,n[i++]=p+1,n[i++]=p+3,n[i++]=p+2,{vertices:t,indices:n}}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class $o extends jn{constructor(e=0,t=0,n=1,r=1,s=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=s,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:s}=this,i=n/2,a=r/2,l=e+i,h=t+a,c=Math.max(0,Math.min(s,Math.min(i,a))),f=c;return this._center=new A(l,h),this._radius=new A(c,f),this._diff=new A(i-c,a-f),this}drawTo(e){const{x:t,y:n,width:r,height:s,radius:i}=this;return e.roundRect(t,n,r,s,i),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class zo extends xe{constructor(e=[]){super(),this.points=e}getPoint(e,t=new A){const{points:n}=this,r=(n.length-1)*e,s=Math.floor(r),i=r-s,a=n[s===0?s:s-1],l=n[s],h=n[s>n.length-2?n.length-1:s+1],c=n[s>n.length-3?n.length-1:s+2];return t.set(Dr(i,a.x,l.x,h.x,c.x),Dr(i,a.y,l.y,h.y,c.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class sn extends ze{constructor(t){super();M(this,"startPoint");M(this,"currentPoint");M(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:s,y:i}=t[n];this.lineTo(s,i)}return this}addCommands(t){return Br(t,this),this}addData(t){return this.addCommands(Er(t)),this}_closePointArray(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenPointArray(t=40,n=[]){return this._closePointArray(super.getUnevenPointArray(t,n))}getSpacedPointArray(t=40,n=[]){return this._closePointArray(super.getSpacedPointArray(t,n))}getAdaptivePointArray(t=[]){return this._closePointArray(super.getAdaptivePointArray(t))}_setCurrentPoint(t){return this.currentPoint=new A(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new Ht(n.clone(),t.clone())),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new A(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(Ht.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,s,i,a){const l=this.currentPoint;return l!=null&&l.equals({x:i,y:a})||this.curves.push(Gn.from((l==null?void 0:l.x)??0,(l==null?void 0:l.y)??0,t,n,r,s,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(t,n,r,s){const i=this.currentPoint;return i!=null&&i.equals({x:r,y:s})||this.curves.push(Rn.from((i==null?void 0:i.x)??0,(i==null?void 0:i.y)??0,t,n,r,s)),this._setCurrentPoint({x:r,y:s}),this}arc(t,n,r,s,i,a){const l=new Do(t,n,r,s,i,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeArc(t,n,r,s,i,a){var l,h;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((h=this.currentPoint)==null?void 0:h.y)??0,this.arc(t,n,r,s,i,a),this}arcTo(t,n,r,s,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,s,i,a,l,h=!0){const c=new Lo(t,n,r,s,i,a,l,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(t,n,r,s,i,a,l,h){var c,f;return t+=((c=this.currentPoint)==null?void 0:c.x)??0,n+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(t,n,r,s,i,a,l,h),this}rect(t,n,r,s){const i=new Fo(t,n,r,s);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,s,i){const a=new $o(t,n,r,s,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new A;return this.curves.push(new zo([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function No(o){return o.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function jo(o,e,t,n){const r=e.clone().sub(o),s=n.clone().sub(t),i=t.clone().sub(o),a=r.cross(s);if(a===0)return new A((o.x+t.x)/2,(o.y+t.y)/2);const l=i.cross(s)/a;return Math.abs(l)>1?new A((o.x+t.x)/2,(o.y+t.y)/2):new A(o.x+l*r.x,o.y+l*r.y)}class Tt extends ze{constructor(t,n={}){super();M(this,"currentCurve",new sn);M(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof Tt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){const n=this.curves.findIndex(r=>r===this.currentCurve);return n>-1&&this.curves.splice(n,1),t instanceof Tt?this.curves.push(...t.curves.filter(r=>r.curves.length).map(r=>r.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new sn().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new sn,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,s,i,a){return this.currentCurve.bezierCurveTo(t,n,r,s,i,a),this}quadraticCurveTo(t,n,r,s){return this.currentCurve.quadraticCurveTo(t,n,r,s),this}arc(t,n,r,s,i,a){return this.currentCurve.arc(t,n,r,s,i,a),this}arcTo(t,n,r,s,i){return this.currentCurve.arcTo(t,n,r,s,i),this}ellipse(t,n,r,s,i,a,l,h){return this.currentCurve.ellipse(t,n,r,s,i,a,l,h),this}rect(t,n,r,s){return this.currentCurve.rect(t,n,r,s),this}roundRect(t,n,r,s,i){return this.currentCurve.roundRect(t,n,r,s,i),this}reset(){return this.currentCurve=new sn,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return Br(t,this),this}addData(t){return this.addCommands(Er(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.getFlatCurves(),r=[],s=[],i=[];n.forEach((l,h)=>{const c=l.getControlPointRefs(),f=l.isClockwise();i[h]=c,s[h]=f;const u=c[0],p=c[c.length-1]??u;r.push({start:f?p:u,end:f?u:p,index:h})});const a=[];return r.forEach((l,h)=>{a[h]=[],r.forEach((c,f)=>{var u;c.start&&l.end&&f!==h&&((u=c.start)!=null&&u.equals(l.end))&&a[h].push(c.index)})}),n.forEach((l,h)=>{const c=s[h];i[h].forEach(f=>{f.add(l.getNormal(l.getTForPoint(f)).scale(c?t:-t))})}),a.forEach((l,h)=>{const c=i[h];l.forEach(f=>{const u=i[f],p=jo(c[c.length-1],c[c.length-2]??c[c.length-1],u[0],u[1]??u[0]);p&&(c[c.length-1].copy(p),u[0].copy(p))})}),this}getMinMax(t=A.MAX,n=A.MIN,r=!0){const s=this.strokeWidth;return this.curves.forEach(i=>{if(i.getMinMax(t,n),r&&s>1){const a=s/2,l=i.isClockwise(),h=[];for(let c=0;c<=1;c+=1/i.arcLengthDivision){const f=i.getPoint(c),u=i.getNormal(c),p=u.clone().scale(l?a:-a),d=u.clone().scale(l?-a:a);h.push(f.clone().add(p),f.clone().add(d),f.clone().add({x:a,y:0}),f.clone().add({x:-a,y:0}),f.clone().add({x:0,y:a}),f.clone().add({x:0,y:-a}),f.clone().add({x:a,y:a}),f.clone().add({x:-a,y:-a}))}t.min(...h),n.max(...h)}}),{min:t,max:n}}strokeTriangulate(t){const n=(t==null?void 0:t.indices)??[],r=(t==null?void 0:t.vertices)??[];return this.curves.forEach(s=>{s.strokeTriangulate({...t,indices:n,vertices:r})}),{indices:n,vertices:r}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new X(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:s="none"}=n;return t.beginPath(),t.save(),Fn(t,n),this.curves.forEach(i=>{i.drawTo(t)}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:s="none"}=n;return t.beginPath(),t.save(),Fn(t,n),this.getControlPointRefs().forEach(i=>{oo(t,i.x,i.y,{radius:4})}),r!=="none"&&t.fill(),s!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSVGPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},n={};for(const s in t)t[s]!==void 0&&(n[No(s)]=t[s]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const s in n)n[s]!==void 0&&(r+=`${s}:${n[s]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class ae{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=A.MAX,n=A.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new X(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),s=this.paths.map(i=>i.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${n} ${r}" width="${n}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:s,width:i,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=i*t,l.height=a*t,l.style.width=`${i}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(t,t),h.translate(-r,-s),this.paths.forEach(c=>{c.drawTo(h,n)})),l}}const Vr="data:image/svg+xml;",Wr=`${Vr}base64,`,Xr=`${Vr}charset=utf8,`;function Hr(o){if(typeof o=="string"){let e;o.startsWith(Wr)?(o=o.substring(Wr.length,o.length),e=atob(o)):o.startsWith(Xr)?(o=o.substring(Xr.length,o.length),e=decodeURIComponent(o)):e=o;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
|
|
5
5
|
${e}`);return t.documentElement}else return o}const Go="px",Ro=90,Zr=["mm","cm","in","pt","pc","px"],Yr={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 K(o){let e="px";if(typeof o=="string"||o instanceof String)for(let n=0,r=Zr.length;n<r;n++){const s=Zr[n];if(o.endsWith(s)){e=s,o=o.substring(0,o.length-s.length);break}}let t;return t=Yr[e][Go],t<0&&(t=Yr[e].in*Ro),t*Number.parseFloat(o)}const qo=new Mt,on=new Mt,Kr=new Mt,Qr=new Mt;function Vo(o,e,t){if(!(o.hasAttribute("transform")||o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))))return null;const n=Wo(o);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function Wo(o){const e=new Mt,t=qo;if(o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))&&e.translate(K(o.getAttribute("x")),K(o.getAttribute("y"))),o.hasAttribute("transform")){const n=o.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const s=n[r].trim();if(s==="")continue;const i=s.indexOf("("),a=s.length;if(i>0&&i<a){const l=s.slice(0,i),h=qt(s.slice(i+1));switch(t.identity(),l){case"translate":if(h.length>=1){const c=h[0];let f=0;h.length>=2&&(f=h[1]),t.translate(c,f)}break;case"rotate":if(h.length>=1){let c=0,f=0,u=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],u=h[2]),on.makeTranslation(-f,-u),Kr.makeRotation(c),Qr.multiplyMatrices(Kr,on),on.makeTranslation(f,u),t.multiplyMatrices(on,Qr)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function Xo(o){return new Tt().arc(K(o.getAttribute("cx")||0),K(o.getAttribute("cy")||0),K(o.getAttribute("r")||0),0,Math.PI*2)}function Ho(o,e){if(!(!o.sheet||!o.sheet.cssRules||!o.sheet.cssRules.length))for(let t=0;t<o.sheet.cssRules.length;t++){const n=o.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),s={};for(let i=n.style.length,a=0;a<i;a++){const l=n.style.item(a);s[l]=n.style.getPropertyValue(l)}for(let i=0;i<r.length;i++)e[r[i]]=Object.assign(e[r[i]]||{},{...s})}}function Zo(o){return new Tt().ellipse(K(o.getAttribute("cx")||0),K(o.getAttribute("cy")||0),K(o.getAttribute("rx")||0),K(o.getAttribute("ry")||0),0,0,Math.PI*2)}function Yo(o){return new Tt().moveTo(K(o.getAttribute("x1")||0),K(o.getAttribute("y1")||0)).lineTo(K(o.getAttribute("x2")||0),K(o.getAttribute("y2")||0))}function Ko(o){const e=new Tt,t=o.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Qo=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Jo(o){var n;const e=new Tt;let t=0;return(n=o.getAttribute("points"))==null||n.replace(Qo,(r,s,i)=>{const a=K(s),l=K(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!0,e}const ta=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ea(o){var n;const e=new Tt;let t=0;return(n=o.getAttribute("points"))==null||n.replace(ta,(r,s,i)=>{const a=K(s),l=K(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!1,e}function na(o){const e=K(o.getAttribute("x")||0),t=K(o.getAttribute("y")||0),n=K(o.getAttribute("rx")||o.getAttribute("ry")||0),r=K(o.getAttribute("ry")||o.getAttribute("rx")||0),s=K(o.getAttribute("width")),i=K(o.getAttribute("height")),a=1-.551915024494,l=new Tt;return l.moveTo(e+n,t),l.lineTo(e+s-n,t),(n!==0||r!==0)&&l.bezierCurveTo(e+s-n*a,t,e+s,t+r*a,e+s,t+r),l.lineTo(e+s,t+i-r),(n!==0||r!==0)&&l.bezierCurveTo(e+s,t+i-r*a,e+s-n*a,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),(n!==0||r!==0)&&l.bezierCurveTo(e+n*a,t+i,e,t+i-r*a,e,t+i-r),l.lineTo(e,t+r),(n!==0||r!==0)&&l.bezierCurveTo(e,t+r*a,e+n*a,t,e+n,t),l}function Vt(o,e,t){e=Object.assign({},e);let n={};if(o.hasAttribute("class")){const h=o.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)n=Object.assign(n,t[`.${h[c]}`])}o.hasAttribute("id")&&(n=Object.assign(n,t[`#${o.getAttribute("id")}`]));for(let h=o.style.length,c=0;c<h;c++){const f=o.style.item(c),u=o.style.getPropertyValue(f);e[f]=u,n[f]=u}function r(h,c,f=s){o.hasAttribute(h)&&(e[c]=f(o.getAttribute(h))),n[h]&&(e[c]=f(n[h]))}function s(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,K(h)))}function a(h){return Math.max(0,K(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>K(c))}return r("fill","fill"),r("fill-opacity","fillOpacity",i),r("fill-rule","fillRule"),r("opacity","opacity",i),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",i),r("stroke-width","strokeWidth",a),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",a),r("stroke-dasharray","strokeDasharray",l),r("stroke-dashoffset","strokeDashoffset",K),r("visibility","visibility"),e}function qn(o,e,t=[],n={}){var f;if(o.nodeType!==1)return t;let r=!1,s=null,i={...e};switch(o.nodeName){case"svg":i=Vt(o,i,n);break;case"style":Ho(o,n);break;case"g":i=Vt(o,i,n);break;case"path":i=Vt(o,i,n),o.hasAttribute("d")&&(s=Ko(o));break;case"rect":i=Vt(o,i,n),s=na(o);break;case"polygon":i=Vt(o,i,n),s=Jo(o);break;case"polyline":i=Vt(o,i,n),s=ea(o);break;case"circle":i=Vt(o,i,n),s=Xo(o);break;case"ellipse":i=Vt(o,i,n),s=Zo(o);break;case"line":i=Vt(o,i,n),s=Yo(o);break;case"defs":r=!0;break;case"use":{i=Vt(o,i,n);const p=(o.getAttributeNS("http://www.w3.org/1999/xlink","href")||o.getAttribute("href")||"").substring(1),d=(f=o.viewportElement)==null?void 0:f.getElementById(p);d?qn(d,i,t,n):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(o);break}if(i.display==="none")return t;const a=new Mt,l=[],h=Vo(o,a,l);s&&(s.applyTransform(a),t.push(s),s.style={...i});const c=o.childNodes;for(let u=0,p=c.length;u<p;u++){const d=c[u];r&&d.nodeName!=="style"&&d.nodeName!=="defs"||qn(d,i,t,n)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}function Jr(o){var t;const e=Hr(o);return new ae(qn(e,{}),(t=e.getAttribute("viewBox"))==null?void 0:t.trim().split(" ").map(n=>Number(n)))}const ra=new Set(["©","®","÷"]),ia=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),sa={1:"italic",32:"bold"},oa={1:"italic",2:"bold"},ti={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class ei{constructor(e,t,n){M(this,"path",new Tt);M(this,"lineBox",new X);M(this,"inlineBox",new X);M(this,"glyphBox");M(this,"advanceWidth",0);M(this,"advanceHeight",0);M(this,"underlinePosition",0);M(this,"underlineThickness",0);M(this,"strikeoutPosition",0);M(this,"strikeoutSize",0);M(this,"ascender",0);M(this,"descender",0);M(this,"typoAscender",0);M(this,"typoDescender",0);M(this,"typoLineGap",0);M(this,"winAscent",0);M(this,"winDescent",0);M(this,"xHeight",0);M(this,"capHeight",0);M(this,"baseline",0);M(this,"centerDiviation",0);M(this,"fontStyle");this.content=e,this.index=t,this.parent=n}get compatibleGlyphBox(){const e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new X(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new X(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.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(e){const t=this.computedStyle.fontFamily,n=e??Gs,r=t?n.get(t):n.fallbackFont;return r==null?void 0:r.getSFNT()}updateGlyph(e=this._getFontSFNT()){if(!e)return this;const{hhea:t,os2:n,post:r,head:s}=e,i=s.unitsPerEm,a=t.ascent,l=t.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:u}=c,p=i/u,d=e.getAdvanceWidth(h,u),m=(a+Math.abs(l))/p,y=a/p;return this.advanceWidth=d,this.advanceHeight=m,this.inlineBox.width=f?m:d,this.inlineBox.height=f?d:m,this.underlinePosition=(a-r.underlinePosition)/p,this.underlineThickness=r.underlineThickness/p,this.strikeoutPosition=(a-n.yStrikeoutPosition)/p,this.strikeoutSize=n.yStrikeoutSize/p,this.ascender=a/p,this.descender=l/p,this.typoAscender=n.sTypoAscender/p,this.typoDescender=n.sTypoDescender/p,this.typoLineGap=n.sTypoLineGap/p,this.winAscent=n.usWinAscent/p,this.winDescent=n.usWinDescent/p,this.xHeight=n.sxHeight/p,this.capHeight=n.sCapHeight/p,this.baseline=y,this.centerDiviation=m/2-y,this.fontStyle=sa[n.fsSelection]??oa[s.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:n,content:r,computedStyle:s,baseline:i,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:u,advanceHeight:p}=this,{left:d,top:m}=a,y=s.fontStyle==="italic"&&f!=="italic";let P=d,T=m+i,b;const C=new Tt;if(n&&(P+=(p-u)/2,Math.abs(u-p)>.1&&(T-=(l-c)/(l+Math.abs(h))*p),b=void 0),n&&!ra.has(r)&&(r.codePointAt(0)<=256||ia.has(r))){C.addCommands(t.getPathCommands(r,P,m+i-(p-u)/2,s.fontSize));const v={y:m-(p-u)/2+p/2,x:P+u/2};y&&this._italic(C,n?{x:v.x,y:m-(p-u)/2+i}:void 0),C.rotate(90,v)}else b!==void 0?(C.addCommands(t.glyphs.get(b).getPathCommands(P,T,s.fontSize)),y&&this._italic(C,n?{x:P+u/2,y:m+c/(l+Math.abs(h))*p}:void 0)):(C.addCommands(t.getPathCommands(r,P,T,s.fontSize)),y&&this._italic(C,n?{x:P+p/2,y:T}:void 0));const x=s.fontWeight??400;return x in ti&&(x===700||x==="bold")&&f!=="bold"&&C.bold(ti[x]*s.fontSize*.05),C.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=C,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,n){var r;if((r=this.path.curves[0])!=null&&r.curves.length)return this.path.getMinMax(e,t,n)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:n,max:r}=t;return new X(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(e,t={}){const n=this.computedStyle,r={ctx:e,path:this.path,fontSize:n.fontSize,color:n.color,...t};if(this.glyphBox)ne(r);else{e.save(),e.beginPath();const s=this.path.style,i={...s,fill:r.color??s.fill,stroke:r.textStrokeColor??s.stroke,strokeWidth:r.textStrokeWidth?r.textStrokeWidth*r.fontSize:s.strokeWidth,shadowOffsetX:(r.shadowOffsetX??0)*r.fontSize,shadowOffsetY:(r.shadowOffsetY??0)*r.fontSize,shadowBlur:(r.shadowBlur??0)*r.fontSize,shadowColor:r.shadowColor};Fn(e,i),e.font=`${r.fontSize}px ${r.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function Vn(){const o=new Map;async function e(n){if(!o.has(n)){o.set(n,n);try{o.set(n,await fetch(n).then(r=>r.text()))}catch(r){console.warn(r),o.delete(n)}}}function t(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}return{loaded:o,needsLoad:t,load:e}}function Wn(o){const e=new Map;function t(n){let r=e.get(n);if(!r){const s=Hr(o.needsLoad(n)?o.loaded.get(n)??n:n),i=Jr(s);r={dom:s,pathSet:i},e.set(n,r)}return r}return{parsed:e,parse:t}}function an(o,e){return typeof o=="number"?o:o.endsWith("%")?(o=o.substring(0,o.length-1),Math.ceil(Number(o)/100*e.total)):o.endsWith("rem")?(o=o.substring(0,o.length-3),Number(o)*e.fontSize):o.endsWith("em")?(o=o.substring(0,o.length-2),Number(o)*e.fontSize):Number(o)}function Xn(o){const e=$t(o)?{}:o;return Object.keys(e).reduce((t,n)=>{let r=e[n];const s=Hn(n),i=Hn(r);return s&&(n=s),i&&(r=i),t[n]=r,t},{})}function $t(o){return!o||o==="none"}function ni(o,e){const t=Object.keys(o),n=Object.keys(e);return Array.from(new Set([...t,...n])).every(s=>le(o[s],e[s]))}function le(o,e){const t=typeof o;return t===typeof e?t==="object"?ni(o,e):o===e:!1}function Hn(o){const e=o.startsWith("#")?o.slice(1):o;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(e))return null;const n=e.length===3?e.split("").map(a=>a+a).join(""):e,r=Number.parseInt(n.slice(0,2),16),s=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgb(${r}, ${s}, ${i})`}function ln(o){if(!o)return o;const e={};for(const t in o)o[t]!==""&&o[t]!==void 0&&(e[t]=o[t]);return e}class ri{constructor(e,t={},n){M(this,"inlineBox",new X);this.content=e,this.style=t,this.parent=n,this.updateComputedStyle().initCharacters()}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...ln(this.style)},this}initCharacters(){const e=[];let t=0;for(const n of this.computedContent)e.push(new ei(n,t++,this));return this.characters=e,this}}class we{constructor(e,t){M(this,"lineBox",new X);M(this,"fragments",[]);this.style=e,this.parentStyle=t,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...ln(this.parentStyle),...ln(this.style)},this}addFragment(e,t){const n=new ri(e,t,this);return this.fragments.push(n),n}}function aa(o){return o}const be=class be{_styleToDomStyle(e){const t={};for(const n in e){const r=e[n];be.notZeroStyles.has(n)&&r===0||(typeof r=="number"&&be.pxStyles.has(n)?t[n]=`${r}px`:t[n]=r)}return t}createParagraphDom(e,t){const n=document.createDocumentFragment(),r=document.createElement("section"),s={...t},i=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":s.justifyContent="flex-start";break;case"center":s.justifyContent="center";break;case"end":case"right":s.justifyContent="flex-end";break}switch(t.verticalAlign){case"top":s.alignItems="flex-start";break;case"middle":s.alignItems="center";break;case"bottom":s.alignItems="flex-end";break}const a=!!(s.justifyContent||s.alignItems);Object.assign(r.style,{...this._styleToDomStyle({...s,boxSizing:s.boxSizing??"border-box",display:s.display??(a?"inline-flex":void 0),width:s.width??"max-content",height:s.height??"max-content"}),whiteSpace:"pre-wrap",wordBreak:"break-all",position:"fixed",visibility:"hidden"});const l=document.createElement("ul");return Object.assign(l.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:a&&i?"100%":void 0,height:a&&!i?"100%":void 0}),e.forEach(h=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._styleToDomStyle(h.style)}),h.fragments.forEach(f=>{const u=document.createElement("span");Object.assign(u.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),u.appendChild(document.createTextNode(f.content)),c.appendChild(u)}),l.appendChild(c)}),r.appendChild(l),n.appendChild(r),document.body.appendChild(n),{dom:r,destory:()=>{var h;return(h=r.parentNode)==null?void 0:h.removeChild(r)}}}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const n=e.data??"";let r=0;return Array.from(n).map(s=>{var f;const i=r+=n.substring(r).indexOf(s),a=i+s.length;r+=s.length,t.setStart(e,Math.max(i,0)),t.setEnd(e,a);const l=((f=t.getClientRects)==null?void 0:f.call(t))??[t.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=t.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(e){const t=[],n=[],r=[];return e.querySelectorAll("li").forEach((s,i)=>{const a=s.getBoundingClientRect();t.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();n.push({paragraphIndex:i,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(u=>{r.push({...u,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(u=>{u.firstChild instanceof window.Text&&this.measureDomText(u.firstChild).forEach(p=>{r.push({...p,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:n,characters:r}}measureParagraphDom(e,t){const n=t.getBoundingClientRect(),r=this.measureDom(t);r.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-n.left,l.lineBox.top=a.top-n.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),r.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-n.left,l.inlineBox.top=a.top-n.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let i=0;return r.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-n.left,top:a.top-n.top});const f=e[l].fragments[h].characters[c],{fontHeight:u,isVertical:p}=f,d=s[i];f.inlineBox.left=d.left,f.inlineBox.top=d.top,f.inlineBox.width=d.width,f.inlineBox.height=d.height,p?(f.lineBox.left=d.left+(d.width-u)/2,f.lineBox.top=d.top,f.lineBox.width=u,f.lineBox.height=d.height):(f.lineBox.left=d.left,f.lineBox.top=d.top+(d.height-u)/2,f.lineBox.width=d.width,f.lineBox.height=u),i++}),{paragraphs:e,boundingBox:new X(0,0,n.width,n.height)}}measure(e,t,n){let r;n||({dom:n,destory:r}=this.createParagraphDom(e,t));const s=this.measureParagraphDom(e,n);return r==null||r(),s}};M(be,"notZeroStyles",new Set(["width","height"])),M(be,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let hn=be;function la(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function ha(){return{boxShadow:"none"}}function ca(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function fa(){return{...la(),...ca(),...ha(),backgroundImage:"none",backgroundColor:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"#000000",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function ua(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing: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:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function pa(){return{...fa(),...ua()}}class da{constructor(){M(this,"eventListeners",new Map)}addEventListener(e,t,n){const r={value:t,options:n},s=this.eventListeners.get(e);return s?Array.isArray(s)?s.push(r):this.eventListeners.set(e,[s,r]):this.eventListeners.set(e,r),this}removeEventListener(e,t,n){var s,i;if(!t)return this.eventListeners.delete(e),this;const r=this.eventListeners.get(e);if(!r)return this;if(Array.isArray(r)){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l];(c.value!==t||typeof n=="object"&&(n!=null&&n.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else r.value===t&&(typeof n=="boolean"||!(n!=null&&n.once)||typeof r.options=="boolean"||(i=r.options)!=null&&i.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,t){var r,s;const n=this.eventListeners.get(e);if(n){if(Array.isArray(n))for(let i=n.length,a=0;a<i;a++){const l=n[a];typeof l.options=="object"&&((r=l.options)!=null&&r.once)&&this.off(e,l.value,l.options),l.value.apply(this,[t])}else typeof n.options=="object"&&((s=n.options)!=null&&s.once)&&this.off(e,n.value,n.options),n.value.apply(this,[t]);return!0}else return!1}on(e,t,n){return this.addEventListener(e,t,n)}once(e,t){return this.addEventListener(e,t,{once:!0})}off(e,t,n){return this.removeEventListener(e,t,n)}emit(e,t){this.dispatchEvent(e,t)}}function ii(){const o=new ae,e=Vn(),t=Wn(e);return{name:"background",pathSet:o,load:async n=>{const{backgroundImage:r}=n.style;r&&e.needsLoad(r)&&await e.load(r)},update:n=>{o.paths.length=0;const{style:r,lineBox:s,isVertical:i}=n;if($t(r.backgroundImage))return;const{pathSet:a}=t.parse(r.backgroundImage),l=a.getBoundingBox(!0),h=new Mt;if(h.translate(-l.x,-l.y),i){h.scale(s.height/l.width,s.width/l.height);const c=s.height/2,f=s.width/2;h.translate(-c,-f),h.rotate(-Math.PI/2),h.translate(f,c)}else h.scale(s.width/l.width,s.height/l.height);h.translate(s.x,s.y),a.paths.forEach(c=>{o.paths.push(c.clone().applyTransform(h))})},render:(n,r)=>{const{boundingBox:s,computedStyle:i}=r;$t(i.backgroundColor)||(n.fillStyle=i.backgroundColor,n.fillRect(...s.array)),o.paths.forEach(a=>{if(ne({ctx:n,path:a,fontSize:i.fontSize}),r.debug){const l=new ae([a]).getBoundingBox();l&&n.strokeRect(l.x,l.y,l.width,l.height)}})}}}function cn(o){const{highlight:e,highlightImage:t,highlightReferImage:n,highlightColormap:r,highlightLine:s,highlightSize:i,highlightThickness:a}=o;return{image:(e==null?void 0:e.image)??t??"none",referImage:(e==null?void 0:e.referImage)??n??"none",colormap:(e==null?void 0:e.colormap)??r??"none",line:(e==null?void 0:e.line)??s??"none",size:(e==null?void 0:e.size)??i??"cover",thickness:(e==null?void 0:e.thickness)??a??"100%"}}function si(){const o=new ae,e=[],t=Vn(),n=Wn(t);return{name:"highlight",pathSet:o,load:async r=>{const s=new Set;r.forEachCharacter(i=>{const{computedStyle:a}=i,{image:l,referImage:h}=cn(a);t.needsLoad(l)&&s.add(l),t.needsLoad(h)&&s.add(h)}),await Promise.all(Array.from(s).map(i=>t.load(i)))},update:r=>{e.length=0,o.paths.length=0;let s=[],i,a;r.forEachCharacter(l=>{const{computedStyle:h}=l,c=cn(h),{image:f,colormap:u,line:p,size:d,thickness:m}=c;if($t(f))i!=null&&i.length&&(i=[],s.push(i));else{const{inlineBox:y,isVertical:P}=l,{fontSize:T}=h;(!a||le(a.image,f)&&le(a.colormap,u)&&le(a.line,p)&&le(a.size,d)&&le(a.thickness,m))&&(i!=null&&i.length)&&(P?i[0].inlineBox.left===y.left:i[0].inlineBox.top===y.top)&&i[0].fontSize===T?i.push(l):(i=[],i.push(l),s.push(i))}a=c}),s=s.filter(l=>l.length);for(let l=0;l<s.length;l++){const h=s[l],c=h[0],f=X.from(...h.map(L=>L.compatibleGlyphBox));if(!f.height||!f.width)continue;const{computedStyle:u,isVertical:p,inlineBox:d,compatibleGlyphBox:m,strikeoutPosition:y,underlinePosition:P}=c,{fontSize:T}=u,{image:b,referImage:C,colormap:x,line:v,size:S,thickness:w}=cn(u),k=an(w,{fontSize:T,total:f.width})/f.width,z=Xn(x),{pathSet:O,dom:B}=n.parse(b),U=O.getBoundingBox(!0),D=T/U.width*2,_=new X().copy(f);p&&(_.width=f.height,_.height=f.width,_.left=f.left+f.width);const H=Math.floor(_.width);let I=H;S!=="cover"&&(I=an(S,{fontSize:T,total:f.width})||H,_.width=I);const E=!$t(C)&&$t(v);if(E)U.copy(n.parse(C).pathSet.getBoundingBox(!0));else{let L;if($t(v))if(U.width/U.height>4){L="underline";const $=B.getAttribute("viewBox");if($){const[W,F,V,R]=$.split(" ").map(Z=>Number(Z)),Y=F+R/2;U.y<Y&&U.y+U.height>Y?L="line-through":U.y+U.height<Y?L="overline":L="underline"}}else L="outline";else L=v;switch(L){case"outline":{const $=_.width*.2,W=_.height*.2;p?(_.x-=W/2,_.y-=$/2,_.x-=_.height):(_.x-=$/2,_.y-=W/2),_.width+=$,_.height+=W;break}case"overline":_.height=U.height*D,p?_.x=d.left+d.width:_.y=d.top;break;case"line-through":_.height=U.height*D,p?_.x=d.left+d.width-y+_.height/2:_.y=d.top+y-_.height/2;break;case"underline":_.height=U.height*D,p?_.x=m.left+m.width-P:_.y=d.top+P;break}}const q=new Mt;if(q.translate(-U.x,-U.y),q.scale(_.width/U.width,_.height/U.height),p){const L=_.width/2,$=_.height/2;E||q.translate(-L,-$),q.rotate(-Math.PI/2),E||q.translate($,L)}q.translate(_.x,_.y);for(let L=0;L<Math.ceil(H/I);L++){const $=q.clone();p?$.translate(0,L*_.width):$.translate(L*_.width,0),O.paths.forEach(W=>{const F=W.clone().applyTransform($);F.style.strokeWidth&&(F.style.strokeWidth*=D*k),F.style.strokeMiterlimit&&(F.style.strokeMiterlimit*=D),F.style.strokeDashoffset&&(F.style.strokeDashoffset*=D),F.style.strokeDasharray&&(F.style.strokeDasharray=F.style.strokeDasharray.map(V=>V*D)),F.style.fill&&F.style.fill in z&&(F.style.fill=z[F.style.fill]),F.style.stroke&&F.style.stroke in z&&(F.style.stroke=z[F.style.stroke]),o.paths.push(F),H!==I&&(p?e[o.paths.length-1]=new X(f.left-f.width*2,f.top,f.width*4,f.height):e[o.paths.length-1]=new X(f.left,f.top-f.height*2,f.width,f.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{const r=[];return o.paths.forEach((s,i)=>{const a=e[i];let l=s.getBoundingBox();if(a){const h=Math.max(l.x,a.x),c=Math.max(l.y,a.y),f=Math.min(l.right,a.right),u=Math.min(l.bottom,a.bottom);l=new X(h,c,f-h,u-c)}r.push(l)}),X.from(...r)},render:(r,s)=>{o.paths.forEach((i,a)=>{if(ne({ctx:r,path:i,fontSize:s.computedStyle.fontSize,clipRect:e[a]}),s.debug){const l=new ae([i]).getBoundingBox();l&&r.strokeRect(l.x,l.y,l.width,l.height)}})}}}function ya(o,e){return`<svg width="${o*2}" height="${o*2}" xmlns="http://www.w3.org/2000/svg">
|
|
6
6
|
<circle cx="${o}" cy="${o}" r="${o}" fill="${e}" />
|
|
7
|
-
</svg>`}function oi(){const o=new ae;return{name:"listStyle",pathSet:o,update:e=>{o.paths.length=0;const{paragraphs:t,isVertical:n,fontSize:r}=e,s=r*.45;t.forEach(i=>{const{computedStyle:a}=i,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:u}=a,p=Xn(c);let d=f,m;if(!$t(h))m=h;else if(!$t(u)){const b=r*.38/2;switch(d=d==="cover"?b*2:d,u){case"disc":m=ya(b,String(l));break}}if(!m)return;const y=Jr(m),P=y.getBoundingBox();let T;i.fragments.forEach(b=>{b.characters.forEach(C=>{const{inlineBox:x}=C;if(n?(T==null?void 0:T.inlineBox.left)!==x.left:(T==null?void 0:T.inlineBox.top)!==x.top){T=C;const v=d==="cover"?1:an(d,{total:r,fontSize:r})/r,S=new Mt;if(n){const w=r/P.height*v;S.translate(-P.left,-P.top).rotate(Math.PI/2).scale(w,w).translate(x.left+(x.width-P.height*w)/2,x.top-s)}else{const w=r/P.height*v;S.translate(-P.left,-P.top).scale(w,w).translate(x.left-P.width*w-s,x.top+(x.height-P.height*w)/2)}o.paths.push(...y.paths.map(w=>{const k=w.clone();return k.applyTransform(S),k.style.fill&&k.style.fill in p&&(k.style.fill=p[k.style.fill]),k.style.stroke&&k.style.stroke in p&&(k.style.stroke=p[k.style.stroke]),k}))}})})})}}}function ai(){return{name:"outline"}}const Jt=new A,ve=new Mt,te=new Mt;function li(){return{name:"render",getBoundingBox:o=>{const{characters:e,fontSize:t,effects:n}=o,r=[];return e.forEach(s=>{n==null||n.forEach(i=>{if(!s.glyphBox)return;const a=s.glyphBox.clone(),l=fn(o,i);Jt.set(a.left,a.top),Jt.applyMatrix3(l),a.left=Jt.x,a.top=Jt.y,Jt.set(a.right,a.bottom),Jt.applyMatrix3(l),a.width=Jt.x-a.left,a.height=Jt.y-a.top;const h=(i.shadowOffsetX??0)*t,c=(i.shadowOffsetY??0)*t,f=Math.max(.1,i.textStrokeWidth??0)*t;a.left+=h-f,a.top+=c-f,a.width+=f*2,a.height+=f*2,r.push(a)})}),r.length?X.from(...r):void 0},render:(o,e)=>{const{paragraphs:t,glyphBox:n,effects:r}=e;r?r.forEach(s=>{jt(s,n,o),o.save();const[i,a,l,h,c,f]=fn(e,s).transpose().elements;o.transform(i,h,a,c,l,f),e.forEachCharacter(u=>{u.drawTo(o,s)}),o.restore()}):t.forEach(s=>{s.fragments.forEach(i=>{i.characters.forEach(a=>{a.drawTo(o)})})}),e.debug&&t.forEach(s=>{o.strokeRect(s.lineBox.x,s.lineBox.y,s.lineBox.width,s.lineBox.height)})}}}function fn(o,e){const{fontSize:t,glyphBox:n}=o,r=(e.translateX??0)*t,s=(e.translateY??0)*t,i=Math.PI*2,a=(e.skewX??0)/360*i,l=(e.skewY??0)/360*i,{left:h,top:c,width:f,height:u}=n,p=h+f/2,d=c+u/2;return ve.identity(),te.makeTranslation(r,s),ve.multiply(te),te.makeTranslation(p,d),ve.multiply(te),te.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),ve.multiply(te),te.makeTranslation(-p,-d),ve.multiply(te),ve.clone()}function hi(){const o=new ae;return{name:"textDecoration",pathSet:o,update:e=>{o.paths.length=0;const t=[];let n,r;e.forEachCharacter(s=>{const{computedStyle:i,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:u}=s,{color:p,textDecoration:d,writingMode:m}=i;if($t(d))r=void 0;else{let y=!1;if((r==null?void 0:r.textDecoration)===d&&(r==null?void 0:r.writingMode)===m&&(r==null?void 0:r.color)===p&&(a?n[0].inlineBox.left===l.left:n[0].inlineBox.top===l.top))switch(d){case"underline":n[0].underlinePosition===h&&n[0].underlineThickness===c&&(y=!0);break;case"line-through":n[0].strikeoutPosition===f&&n[0].strikeoutSize===u&&(y=!0);break}y?n.push(s):(n=[],n.push(s),t.push(n)),r=i}}),t.forEach(s=>{const{computedStyle:i,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=s[0],{color:u,textDecoration:p}=i,d=X.from(...s.map(S=>S.inlineBox)),{left:m,top:y,width:P,height:T}=d;let b=a?m+P:y;const C=a?-1:1;let x=0;switch(p){case"overline":x=h*2;break;case"underline":b+=C*l,x=h*2;break;case"line-through":b+=C*c,x=f*2;break}b-=x;let v;a?v=new Tt([{type:"M",x:b,y},{type:"L",x:b,y:y+T},{type:"L",x:b+x,y:y+T},{type:"L",x:b+x,y},{type:"Z"}],{fill:u}):v=new Tt([{type:"M",x:m,y:b},{type:"L",x:m+P,y:b},{type:"L",x:m+P,y:b+x},{type:"L",x:m,y:b+x},{type:"Z"}],{fill:u}),o.paths.push(v)})},render:(e,t)=>{const{effects:n,computedStyle:r}=t;n?n.forEach(s=>{e.save();const[i,a,l,h,c,f]=fn(t,s).transpose().elements;e.transform(i,h,a,c,l,f),o.paths.forEach(u=>{ne({ctx:e,path:u,fontSize:r.fontSize,...s})}),e.restore()}):o.paths.forEach(s=>{ne({ctx:e,path:s,fontSize:r.fontSize})})}}}const Zn=pa();class Yn extends da{constructor(t={}){super();M(this,"debug");M(this,"content");M(this,"style");M(this,"effects");M(this,"measureDom");M(this,"needsUpdate",!0);M(this,"computedStyle",{...Zn});M(this,"paragraphs",[]);M(this,"lineBox",new X);M(this,"rawGlyphBox",new X);M(this,"glyphBox",new X);M(this,"pathBox",new X);M(this,"boundingBox",new X);M(this,"measurer",new hn);M(this,"plugins",new Map);M(this,"fonts");this.debug=t.debug??!1,this.content=t.content??"",this.style=t.style??{},this.measureDom=t.measureDom,this.effects=t.effects,this.fonts=t.fonts,this.use(ii()).use(ai()).use(oi()).use(hi()).use(si()).use(li()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(n=>n.characters))}use(t){return this.plugins.set(t.name,t),this}forEachCharacter(t){return this.paragraphs.forEach((n,r)=>{n.fragments.forEach((s,i)=>{s.characters.forEach((a,l)=>{t(a,{paragraphIndex:r,fragmentIndex:i,characterIndex:l})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(t=>{var n;return(n=t.load)==null?void 0:n.call(t,this)}))}updateParagraphs(){this.computedStyle={...Zn,...this.style};let{content:t,computedStyle:n}=this;const r=[];if(typeof t=="string"){const s=new we({},n);s.addFragment(t),r.push(s)}else{t=Array.isArray(t)?t:[t];for(const s of t)if(typeof s=="string"){const i=new we({},n);i.addFragment(s),r.push(i)}else if(Array.isArray(s)){const i=new we({},n);s.forEach(a=>{if(typeof a=="string")i.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&i.addFragment(l,h)}}),r.push(i)}else if("fragments"in s){const{fragments:i,...a}=s,l=new we(a,n);i.forEach(h=>{const{content:c,...f}=h;c!==void 0&&l.addFragment(c,f)}),r.push(l)}else if("content"in s){const{content:i,...a}=s;if(i!==void 0){const l=new we(a,n);l.addFragment(i),r.push(l)}}}return this.paragraphs=r,this}measure(t=this.measureDom){const n={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,t);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,i)=>(s.updateOrder??0)-(i.updateOrder??0)).forEach(s=>{var i;(i=s.update)==null||i.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in n)r[s]=this[s],this[s]=n[s];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const t=A.MAX,n=A.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(t,n)){const{inlineBox:s}=r,{left:i,top:a,width:l,height:h}=s,c=new A(i,a),f=new A(i+l,a+h);t.min(c,f),n.max(c,f)}}),new X(t.x,t.y,n.x-t.x,n.y-t.y)}updatePathBox(){return this.pathBox=X.from(this.glyphBox,...Array.from(this.plugins.values()).map(t=>{var n;return t.getBoundingBox?t.getBoundingBox(this):(n=t.pathSet)==null?void 0:n.getBoundingBox()}).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=X.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const n in t)this[n]=t[n];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(t){const{view:n,pixelRatio:r=2}=t,s=n.getContext("2d");s&&(this.needsUpdate&&this.update(),Kn(s,r,this.boundingBox),Qn(s,this),Array.from(this.plugins.values()).sort((i,a)=>(i.renderOrder??0)-(a.renderOrder??0)).forEach(i=>{var a;if(i.render)(a=i.render)==null||a.call(i,s,this);else if(i.pathSet){const l=this.computedStyle;i.pathSet.paths.forEach(h=>{ne({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:n,pixelRatio:r}))}}function ga(o,e){const t=new Yn(o);return e?t.load().then(()=>t.measure()):t.measure()}function ma(o,e){const t=new Yn(o);return e?t.load().then(()=>t.render(o)):t.render(o)}G.Character=ei,G.Fragment=ri,G.Measurer=hn,G.Paragraph=we,G.Text=Yn,G.background=ii,G.createSVGLoader=Vn,G.createSVGParser=Wn,G.definePlugin=aa,G.drawPath=ne,G.filterEmpty=ln,G.getHighlightStyle=cn,G.getTransform2D=fn,G.hexToRgb=Hn,G.highlight=si,G.isEqualObject=ni,G.isEqualValue=le,G.isNone=$t,G.listStyle=oi,G.measureText=ga,G.outline=ai,G.parseColor=ct,G.parseColormap=Xn,G.parseValueNumber=an,G.render=li,G.renderText=ma,G.setupView=Kn,G.textDecoration=hi,G.textDefaultStyle=Zn,G.uploadColor=jt,G.uploadColors=Qn,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
7
|
+
</svg>`}function oi(){const o=new ae;return{name:"listStyle",pathSet:o,update:e=>{o.paths.length=0;const{paragraphs:t,isVertical:n,fontSize:r}=e,s=r*.45;t.forEach(i=>{const{computedStyle:a}=i,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:u}=a,p=Xn(c);let d=f,m;if(!$t(h))m=h;else if(!$t(u)){const b=r*.38/2;switch(d=d==="cover"?b*2:d,u){case"disc":m=ya(b,String(l));break}}if(!m)return;const y=Jr(m),P=y.getBoundingBox();let T;i.fragments.forEach(b=>{b.characters.forEach(C=>{const{inlineBox:x}=C;if(n?(T==null?void 0:T.inlineBox.left)!==x.left:(T==null?void 0:T.inlineBox.top)!==x.top){T=C;const v=d==="cover"?1:an(d,{total:r,fontSize:r})/r,S=new Mt;if(n){const w=r/P.height*v;S.translate(-P.left,-P.top).rotate(Math.PI/2).scale(w,w).translate(x.left+(x.width-P.height*w)/2,x.top-s)}else{const w=r/P.height*v;S.translate(-P.left,-P.top).scale(w,w).translate(x.left-P.width*w-s,x.top+(x.height-P.height*w)/2)}o.paths.push(...y.paths.map(w=>{const k=w.clone();return k.applyTransform(S),k.style.fill&&k.style.fill in p&&(k.style.fill=p[k.style.fill]),k.style.stroke&&k.style.stroke in p&&(k.style.stroke=p[k.style.stroke]),k}))}})})})}}}function ai(){return{name:"outline"}}const Jt=new A,ve=new Mt,te=new Mt;function li(){return{name:"render",getBoundingBox:o=>{const{characters:e,fontSize:t,effects:n}=o,r=[];return e.forEach(s=>{n==null||n.forEach(i=>{if(!s.glyphBox)return;const a=s.glyphBox.clone(),l=fn(o,i);Jt.set(a.left,a.top),Jt.applyMatrix3(l),a.left=Jt.x,a.top=Jt.y,Jt.set(a.right,a.bottom),Jt.applyMatrix3(l),a.width=Jt.x-a.left,a.height=Jt.y-a.top;const h=(i.shadowOffsetX??0)*t,c=(i.shadowOffsetY??0)*t,f=Math.max(.1,i.textStrokeWidth??0)*t;a.left+=h-f,a.top+=c-f,a.width+=f*2,a.height+=f*2,r.push(a)})}),r.length?X.from(...r):void 0},render:(o,e)=>{const{paragraphs:t,glyphBox:n,effects:r}=e;r?r.forEach(s=>{jt(s,n,o),o.save();const[i,a,l,h,c,f]=fn(e,s).transpose().elements;o.transform(i,h,a,c,l,f),e.forEachCharacter(u=>{u.drawTo(o,s)}),o.restore()}):t.forEach(s=>{s.fragments.forEach(i=>{i.characters.forEach(a=>{a.drawTo(o)})})}),e.debug&&t.forEach(s=>{o.strokeRect(s.lineBox.x,s.lineBox.y,s.lineBox.width,s.lineBox.height)})}}}function fn(o,e){const{fontSize:t,glyphBox:n}=o,r=(e.translateX??0)*t,s=(e.translateY??0)*t,i=Math.PI*2,a=(e.skewX??0)/360*i,l=(e.skewY??0)/360*i,{left:h,top:c,width:f,height:u}=n,p=h+f/2,d=c+u/2;return ve.identity(),te.makeTranslation(r,s),ve.multiply(te),te.makeTranslation(p,d),ve.multiply(te),te.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),ve.multiply(te),te.makeTranslation(-p,-d),ve.multiply(te),ve.clone()}function hi(){const o=new ae;return{name:"textDecoration",pathSet:o,update:e=>{o.paths.length=0;const t=[];let n,r;e.forEachCharacter(s=>{const{computedStyle:i,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:u}=s,{color:p,textDecoration:d,writingMode:m}=i;if($t(d))r=void 0;else{let y=!1;if((r==null?void 0:r.textDecoration)===d&&(r==null?void 0:r.writingMode)===m&&(r==null?void 0:r.color)===p&&(a?n[0].inlineBox.left===l.left:n[0].inlineBox.top===l.top))switch(d){case"underline":n[0].underlinePosition===h&&n[0].underlineThickness===c&&(y=!0);break;case"line-through":n[0].strikeoutPosition===f&&n[0].strikeoutSize===u&&(y=!0);break}y?n.push(s):(n=[],n.push(s),t.push(n)),r=i}}),t.forEach(s=>{const{computedStyle:i,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=s[0],{color:u,textDecoration:p}=i,d=X.from(...s.map(S=>S.inlineBox)),{left:m,top:y,width:P,height:T}=d;let b=a?m+P:y;const C=a?-1:1;let x=0;switch(p){case"overline":x=h*2;break;case"underline":b+=C*l,x=h*2;break;case"line-through":b+=C*c,x=f*2;break}b-=x;let v;a?v=new Tt([{type:"M",x:b,y},{type:"L",x:b,y:y+T},{type:"L",x:b+x,y:y+T},{type:"L",x:b+x,y},{type:"Z"}],{fill:u}):v=new Tt([{type:"M",x:m,y:b},{type:"L",x:m+P,y:b},{type:"L",x:m+P,y:b+x},{type:"L",x:m,y:b+x},{type:"Z"}],{fill:u}),o.paths.push(v)})},render:(e,t)=>{const{effects:n,computedStyle:r}=t;n?n.forEach(s=>{e.save();const[i,a,l,h,c,f]=fn(t,s).transpose().elements;e.transform(i,h,a,c,l,f),o.paths.forEach(u=>{ne({ctx:e,path:u,fontSize:r.fontSize,...s})}),e.restore()}):o.paths.forEach(s=>{ne({ctx:e,path:s,fontSize:r.fontSize})})}}}const Zn=pa();class Yn extends da{constructor(t={}){super();M(this,"debug");M(this,"content");M(this,"style");M(this,"effects");M(this,"measureDom");M(this,"needsUpdate",!0);M(this,"computedStyle",{...Zn});M(this,"paragraphs",[]);M(this,"lineBox",new X);M(this,"rawGlyphBox",new X);M(this,"glyphBox",new X);M(this,"pathBox",new X);M(this,"boundingBox",new X);M(this,"measurer",new hn);M(this,"plugins",new Map);M(this,"fonts");this.debug=t.debug??!1,this.content=t.content??"",this.style=t.style??{},this.measureDom=t.measureDom,this.effects=t.effects,this.fonts=t.fonts,this.use(ii()).use(ai()).use(oi()).use(hi()).use(si()).use(li()),(t.plugins??[]).forEach(n=>{this.use(n)}),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(n=>n.characters))}use(t){return this.plugins.set(t.name,t),this}forEachCharacter(t){return this.paragraphs.forEach((n,r)=>{n.fragments.forEach((s,i)=>{s.characters.forEach((a,l)=>{t(a,{paragraphIndex:r,fragmentIndex:i,characterIndex:l})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(t=>{var n;return(n=t.load)==null?void 0:n.call(t,this)}))}updateParagraphs(){this.computedStyle={...Zn,...this.style};let{content:t,computedStyle:n}=this;const r=[];if(typeof t=="string"){const s=new we({},n);s.addFragment(t),r.push(s)}else{t=Array.isArray(t)?t:[t];for(const s of t)if(typeof s=="string"){const i=new we({},n);i.addFragment(s),r.push(i)}else if(Array.isArray(s)){const i=new we({},n);s.forEach(a=>{if(typeof a=="string")i.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&i.addFragment(l,h)}}),r.push(i)}else if("fragments"in s){const{fragments:i,...a}=s,l=new we(a,n);i.forEach(h=>{const{content:c,...f}=h;c!==void 0&&l.addFragment(c,f)}),r.push(l)}else if("content"in s){const{content:i,...a}=s;if(i!==void 0){const l=new we(a,n);l.addFragment(i),r.push(l)}}}return this.paragraphs=r,this}measure(t=this.measureDom){const n={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,t);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,i)=>(s.updateOrder??0)-(i.updateOrder??0)).forEach(s=>{var i;(i=s.update)==null||i.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in n)r[s]=this[s],this[s]=n[s];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const t=A.MAX,n=A.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(t,n)){const{inlineBox:s}=r,{left:i,top:a,width:l,height:h}=s,c=new A(i,a),f=new A(i+l,a+h);t.min(c,f),n.max(c,f)}}),new X(t.x,t.y,n.x-t.x,n.y-t.y)}updatePathBox(){return this.pathBox=X.from(this.glyphBox,...Array.from(this.plugins.values()).map(t=>{var n;return t.getBoundingBox?t.getBoundingBox(this):(n=t.pathSet)==null?void 0:n.getBoundingBox()}).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=X.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const n in t)this[n]=t[n];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(t){const{view:n,pixelRatio:r=2}=t,s=n.getContext("2d");s&&(this.needsUpdate&&this.update(),Kn(s,r,this.boundingBox),Qn(s,this),Array.from(this.plugins.values()).sort((i,a)=>(i.renderOrder??0)-(a.renderOrder??0)).forEach(i=>{var a;if(i.render)(a=i.render)==null||a.call(i,s,this);else if(i.pathSet){const l=this.computedStyle;i.pathSet.paths.forEach(h=>{ne({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:n,pixelRatio:r}))}}function ga(o,e){const t=new Yn(o);return e?t.load().then(()=>t.measure()):t.measure()}function ma(o,e){const t=new Yn(o);return e?t.load().then(()=>t.render(o)):t.render(o)}G.Character=ei,G.Fragment=ri,G.Measurer=hn,G.Paragraph=we,G.Text=Yn,G.background=ii,G.createSVGLoader=Vn,G.createSVGParser=Wn,G.definePlugin=aa,G.drawPath=ne,G.filterEmpty=ln,G.getHighlightStyle=cn,G.getTransform2D=fn,G.hexToRgb=Hn,G.highlight=si,G.isEqualObject=ni,G.isEqualValue=le,G.isNone=$t,G.listStyle=oi,G.measureText=ga,G.outline=ai,G.parseColor=ct,G.parseColormap=Xn,G.parseValueNumber=an,G.render=li,G.renderText=ma,G.setupView=Kn,G.textDecoration=hi,G.textDefaultStyle=Zn,G.uploadColor=jt,G.uploadColors=Qn,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1636,6 +1636,9 @@ class Text extends EventEmitter {
|
|
|
1636
1636
|
this.effects = options.effects;
|
|
1637
1637
|
this.fonts = options.fonts;
|
|
1638
1638
|
this.use(background()).use(outline()).use(listStyle()).use(textDecoration()).use(highlight()).use(render());
|
|
1639
|
+
(options.plugins ?? []).forEach((plugin) => {
|
|
1640
|
+
this.use(plugin);
|
|
1641
|
+
});
|
|
1639
1642
|
this.updateParagraphs();
|
|
1640
1643
|
}
|
|
1641
1644
|
use(plugin) {
|