modern-text 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -9
- package/dist/index.js +1 -1
- package/dist/index.mjs +11 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -567,36 +567,38 @@ class Measurer {
|
|
|
567
567
|
switch (rootStyle.textAlign) {
|
|
568
568
|
case "start":
|
|
569
569
|
case "left":
|
|
570
|
-
style.justifyContent = "start";
|
|
570
|
+
style.justifyContent = "flex-start";
|
|
571
571
|
break;
|
|
572
572
|
case "center":
|
|
573
573
|
style.justifyContent = "center";
|
|
574
574
|
break;
|
|
575
575
|
case "end":
|
|
576
576
|
case "right":
|
|
577
|
-
style.justifyContent = "end";
|
|
577
|
+
style.justifyContent = "flex-end";
|
|
578
578
|
break;
|
|
579
579
|
}
|
|
580
580
|
switch (rootStyle.verticalAlign) {
|
|
581
581
|
case "top":
|
|
582
|
-
style.alignItems = "
|
|
582
|
+
style.alignItems = "flex-start";
|
|
583
583
|
break;
|
|
584
584
|
case "middle":
|
|
585
585
|
style.alignItems = "center";
|
|
586
586
|
break;
|
|
587
587
|
case "bottom":
|
|
588
|
-
style.alignItems = "end";
|
|
588
|
+
style.alignItems = "flex-end";
|
|
589
589
|
break;
|
|
590
590
|
}
|
|
591
591
|
const isFlex = Boolean(style.justifyContent || style.alignItems);
|
|
592
592
|
Object.assign(dom.style, {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
593
|
+
...this._styleToDomStyle({
|
|
594
|
+
...style,
|
|
595
|
+
boxSizing: style.boxSizing ?? "border-box",
|
|
596
|
+
display: style.display ?? (isFlex ? "inline-flex" : void 0),
|
|
597
|
+
width: style.width ?? "max-content",
|
|
598
|
+
height: style.height ?? "max-content"
|
|
599
|
+
}),
|
|
597
600
|
whiteSpace: "pre-wrap",
|
|
598
601
|
wordBreak: "break-all",
|
|
599
|
-
...this._styleToDomStyle(style),
|
|
600
602
|
position: "fixed",
|
|
601
603
|
visibility: "hidden"
|
|
602
604
|
});
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
font-family: "${e}";
|
|
3
3
|
src: url(${t});
|
|
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,o)=>r||this.loaded.get(o),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:o=!0,...i}=t,{src:a}=e;if(this.loaded.has(a))return n&&(this.loading.forEach(u=>u.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,i),this.loading.set(a,l)),n&&this.loading.forEach((u,d)=>{u!==l&&(u.cancel(),this.loading.delete(d))}),l.when.then(u=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const d=f(u);return t.noAdd||this.loaded.set(e.src,d),d.familySet.forEach(p=>{this.familyToUrl.set(p,a),typeof document<"u"&&(r&&this.injectFontFace(p,u),o&&this.injectStyleTag(p,a))}),d}}).catch(u=>{if(u instanceof DOMException&&u.message==="The user aborted a request.")return f();throw u}).finally(()=>{this.loading.delete(a)});function h(){return e.family?Array.isArray(e.family)?e.family:[e.family]:[]}function c(u){return h().forEach(d=>{u.familySet.add(d)}),u}function f(u=new ArrayBuffer(0)){let d;function p(){return d||(d=u.byteLength?zs(u,!1):void 0),d}function m(){const y=p();if(y instanceof Ft||y instanceof Bn)return y.sfnt}return{...e,buffer:u,familySet:new Set(h()),getFont:p,getSFNT:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}};M(un,"defaultRequestInit",{cache:"force-cache"});let Dn=un;const Ns=new Dn;function js(s,e,t=2){const n=e&&e.length,r=n?e[0]*t:s.length;let o=Pr(s,0,r,t,!0);const i=[];if(!o||o.next===o.prev)return i;let a,l,h;if(n&&(o=Vs(s,e,o,t)),s.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 d=s[u],p=s[u+1];d<a&&(a=d),p<l&&(l=p),d>c&&(c=d),p>f&&(f=p)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return De(o,i,t,a,l,h,0),i}function Pr(s,e,t,n,r){let o;if(r===ro(s,e,t,n)>0)for(let i=e;i<t;i+=n)o=Ir(i/n|0,s[i],s[i+1],o);else for(let i=t-n;i>=e;i-=n)o=Ir(i/n|0,s[i],s[i+1],o);return o&&ye(o,o.next)&&(Fe(o),o=o.next),o}function ie(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(ye(t,t.next)||tt(t.prev,t,t.next)===0)){if(Fe(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function De(s,e,t,n,r,o,i){if(!s)return;!i&&o&&Ks(s,n,r,o);let a=s;for(;s.prev!==s.next;){const l=s.prev,h=s.next;if(o?qs(s,n,r,o):Rs(s)){e.push(l.i,s.i,h.i),Fe(s),s=h.next,a=h.next;continue}if(s=h,s===a){i?i===1?(s=Gs(ie(s),e),De(s,e,t,n,r,o,2)):i===2&&Ws(s,e,t,n,r,o):De(ie(s),e,t,n,r,o,1);break}}}function Rs(s){const e=s.prev,t=s,n=s.next;if(tt(e,t,n)>=0)return!1;const r=e.x,o=t.x,i=n.x,a=e.y,l=t.y,h=n.y,c=Math.min(r,o,i),f=Math.min(a,l,h),u=Math.max(r,o,i),d=Math.max(a,l,h);let p=n.next;for(;p!==e;){if(p.x>=c&&p.x<=u&&p.y>=f&&p.y<=d&&Ue(r,a,o,l,i,h,p.x,p.y)&&tt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function qs(s,e,t,n){const r=s.prev,o=s,i=s.next;if(tt(r,o,i)>=0)return!1;const a=r.x,l=o.x,h=i.x,c=r.y,f=o.y,u=i.y,d=Math.min(a,l,h),p=Math.min(c,f,u),m=Math.max(a,l,h),y=Math.max(c,f,u),A=Un(d,p,e,t,n),P=Un(m,y,e,t,n);let v=s.prevZ,C=s.nextZ;for(;v&&v.z>=A&&C&&C.z<=P;){if(v.x>=d&&v.x<=m&&v.y>=p&&v.y<=y&&v!==r&&v!==i&&Ue(a,c,l,f,h,u,v.x,v.y)&&tt(v.prev,v,v.next)>=0||(v=v.prevZ,C.x>=d&&C.x<=m&&C.y>=p&&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(;v&&v.z>=A;){if(v.x>=d&&v.x<=m&&v.y>=p&&v.y<=y&&v!==r&&v!==i&&Ue(a,c,l,f,h,u,v.x,v.y)&&tt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;C&&C.z<=P;){if(C.x>=d&&C.x<=m&&C.y>=p&&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 Gs(s,e){let t=s;do{const n=t.prev,r=t.next.next;!ye(n,r)&&kr(n,t,t.next,r)&&Le(n,r)&&Le(r,n)&&(e.push(n.i,t.i,r.i),Fe(t),Fe(t.next),t=s=r),t=t.next}while(t!==s);return ie(t)}function Ws(s,e,t,n,r,o){let i=s;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&to(i,a)){let l=Ar(i,a);i=ie(i,i.next),l=ie(l,l.next),De(i,e,t,n,r,o,0),De(l,e,t,n,r,o,0);return}a=a.next}i=i.next}while(i!==s)}function Vs(s,e,t,n){const r=[];for(let o=0,i=e.length;o<i;o++){const a=e[o]*n,l=o<i-1?e[o+1]*n:s.length,h=Pr(s,a,l,n,!1);h===h.next&&(h.steiner=!0),r.push(Js(h))}r.sort(Xs);for(let o=0;o<r.length;o++)t=Hs(r[o],t);return t}function Xs(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function Hs(s,e){const t=Zs(s,e);if(!t)return e;const n=Ar(t,s);return ie(n,n.next),ie(t,t.next)}function Zs(s,e){let t=e;const n=s.x,r=s.y;let o=-1/0,i;if(ye(s,t))return t;do{if(ye(s,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>o&&(o=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&&Tr(r<h?n:o,r,l,h,r<h?o:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);Le(t,s)&&(f<c||f===c&&(t.x>i.x||t.x===i.x&&Ys(i,t)))&&(i=t,c=f)}t=t.next}while(t!==a);return i}function Ys(s,e){return tt(s.prev,s,e.prev)<0&&tt(e.next,s,s.next)<0}function Ks(s,e,t,n){let r=s;do r.z===0&&(r.z=Un(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,Qs(r)}function Qs(s){let e,t=1;do{let n=s,r;s=null;let o=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--),o?o.nextZ=r:s=r,r.prevZ=o,o=r;n=i}o.nextZ=null,t*=2}while(e>1);return s}function Un(s,e,t,n,r){return s=(s-t)*r|0,e=(e-n)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Js(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Tr(s,e,t,n,r,o,i,a){return(r-i)*(e-a)>=(s-i)*(o-a)&&(s-i)*(n-a)>=(t-i)*(e-a)&&(t-i)*(o-a)>=(r-i)*(n-a)}function Ue(s,e,t,n,r,o,i,a){return!(s===i&&e===a)&&Tr(s,e,t,n,r,o,i,a)}function to(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!eo(s,e)&&(Le(s,e)&&Le(e,s)&&no(s,e)&&(tt(s.prev,s,e.prev)||tt(s,e.prev,e))||ye(s,e)&&tt(s.prev,s,s.next)>0&&tt(e.prev,e,e.next)>0)}function tt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function ye(s,e){return s.x===e.x&&s.y===e.y}function kr(s,e,t,n){const r=tn(tt(s,e,t)),o=tn(tt(s,e,n)),i=tn(tt(t,n,s)),a=tn(tt(t,n,e));return!!(r!==o&&i!==a||r===0&&Je(s,t,e)||o===0&&Je(s,n,e)||i===0&&Je(t,s,n)||a===0&&Je(t,e,n))}function Je(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function tn(s){return s>0?1:s<0?-1:0}function eo(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&kr(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Le(s,e){return tt(s.prev,s,s.next)<0?tt(s,e,s.next)>=0&&tt(s,s.prev,e)>=0:tt(s,e,s.prev)<0||tt(s,s.next,e)<0}function no(s,e){let t=s,n=!1;const r=(s.x+e.x)/2,o=(s.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function Ar(s,e){const t=Ln(s.i,s.x,s.y),n=Ln(e.i,e.x,e.y),r=s.next,o=e.prev;return s.next=e,e.prev=s,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Ir(s,e,t,n){const r=Ln(s,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 Fe(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Ln(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ro(s,e,t,n){let r=0;for(let o=e,i=t-n;o<t;o+=n)r+=(s[i]-s[o])*(s[o+1]+s[i+1]),i=o;return r}function io(s,e,t,n={}){const{radius:r=1}=n;s.moveTo(e,t),s.arc(e,t,r,0,Math.PI*2)}const so={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Fn(s,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:f=0,shadowBlur:u=0,shadowColor:d="rgba(0, 0, 0, 0)"}=e;s.fillStyle=t,s.strokeStyle=n,s.lineWidth=r,s.lineCap=o,s.lineJoin=so[i],s.miterLimit=a,s.setLineDash(l),s.lineDashOffset=h,s.shadowOffsetX=c,s.shadowOffsetY=f,s.shadowBlur=u,s.shadowColor=d}class k{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new k(1/0,1/0)}static get MIN(){return new k(-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,o=-(this.y-t.y),i=Math.sin(n),a=Math.cos(n);return this.set(t.x+(r*a-o*i),t.y-(r*i+o*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,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*o),this.y=n.y+(o+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 k(this.x,this.y)}}class H{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 k((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 H;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.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 H(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 H(this.left,this.top,this.width,this.height)}}class Pt{constructor(e=1,t=0,n=0,r=0,o=1,i=0,a=0,l=0,h=1){M(this,"elements",[]);this.set(e,t,n,r,o,i,a,l,h)}set(e,t,n,r,o,i,a,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=a,c[3]=t,c[4]=o,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,o=this.elements,i=n[0],a=n[3],l=n[6],h=n[1],c=n[4],f=n[7],u=n[2],d=n[5],p=n[8],m=r[0],y=r[3],A=r[6],P=r[1],v=r[4],C=r[7],x=r[2],b=r[5],S=r[8];return o[0]=i*m+a*P+l*x,o[3]=i*y+a*v+l*b,o[6]=i*A+a*C+l*S,o[1]=h*m+c*P+f*x,o[4]=h*y+c*v+f*b,o[7]=h*A+c*C+f*S,o[2]=u*m+d*P+p*x,o[5]=u*y+d*v+p*b,o[8]=u*A+d*C+p*S,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=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*o,d=h*o-i*l,p=t*f+n*u+r*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;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*o-a*t)*m,e[6]=d*m,e[7]=(n*l-h*t)*m,e[8]=(i*t-n*o)*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 Pt;function _r(s,e,t,n){const r=s*t+e*n,o=Math.sqrt(s*s+e*e)*Math.sqrt(t*t+n*n);let i=Math.acos(Math.max(-1,Math.min(1,r/o)));return s*n-e*t<0&&(i=-i),i}function oo(s,e,t,n,r,o,i,a){if(e===0||t===0){s.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,d=t*t;const p=c*c,m=f*f,y=p/u+m/d;if(y>1){const $=Math.sqrt(y);e=$*e,t=$*t,u=e*e,d=t*t}const A=u*m+d*p,P=(u*d-A)/A;let v=Math.sqrt(Math.max(0,P));r===o&&(v=-v);const C=v*e*f/t,x=-v*t*c/e,b=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=_r(1,0,(c-C)/e,(f-x)/t),_=_r((c-C)/e,(f-x)/t,(-c-C)/e,(-f-x)/t)%(Math.PI*2);s.ellipse(b,S,e,t,n,w,w+_,o===0)}const it={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function qt(s,e,t=0){let a=0,l=!0,h="",c="";const f=[];function u(y,A,P){const v=new SyntaxError(`Unexpected character "${y}" at index ${A}.`);throw v.partial=P,v}function d(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let p;const m=s.length;for(let y=0;y<m;y++){if(p=s[y],Array.isArray(e)&&e.includes(f.length%t)&&it.FLAGS.test(p)){a=1,h=p,d();continue}if(a===0){if(it.WHITESPACE.test(p))continue;if(it.DIGIT.test(p)||it.SIGN.test(p)){a=1,h=p;continue}if(it.POINT.test(p)){a=2,h=p;continue}it.COMMA.test(p)&&(l&&u(p,y,f),l=!0)}if(a===1){if(it.DIGIT.test(p)){h+=p;continue}if(it.POINT.test(p)){h+=p,a=2;continue}if(it.EXP.test(p)){a=3;continue}it.SIGN.test(p)&&h.length===1&&it.SIGN.test(h[0])&&u(p,y,f)}if(a===2){if(it.DIGIT.test(p)){h+=p;continue}if(it.EXP.test(p)){a=3;continue}it.POINT.test(p)&&h[h.length-1]==="."&&u(p,y,f)}if(a===3){if(it.DIGIT.test(p)){c+=p;continue}if(it.SIGN.test(p)){if(c===""){c+=p;continue}c.length===1&&it.SIGN.test(c)&&u(p,y,f)}}it.WHITESPACE.test(p)?(d(),a=0,l=!1):it.COMMA.test(p)?(d(),a=0,l=!0):it.SIGN.test(p)?(d(),a=1,h=p):it.POINT.test(p)?(d(),a=2,h=p):u(p,y,f)}return d(),f}function ge(s,e){return s-(e-s)}function Or(s,e){const t=new k,n=new k;for(let r=0,o=s.length;r<o;r++){const i=s[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(ge(t.x,n.x),ge(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(ge(t.x,n.x),ge(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=ge(t.x,n.x),l=ge(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),oo(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 ao(s){let e,t;const n=[];for(let r=0,o=s.length;r<o;r++){const i=s[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 lo=/[a-df-z][^a-df-z]*/gi;function Er(s){const e=[],t=s.match(lo);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],i=o.charAt(0),a=o.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(o)}}return e}function Br(s,e,t,n,r){const o=(n-e)*.5,i=(r-t)*.5,a=s*s,l=s*a;return(2*t-2*n+o+i)*l+(-3*t+3*n-2*o-i)*a+o*s+t}function ho(s,e){const t=1-s;return t*t*t*e}function co(s,e){const t=1-s;return 3*t*t*s*e}function fo(s,e){return 3*(1-s)*s*s*e}function uo(s,e){return s*s*s*e}function Dr(s,e,t,n,r){return ho(s,e)+co(s,t)+fo(s,n)+uo(s,r)}function po(s,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:i=0,indicesOffset:a=0}=e;const l=js(s,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*o;for(let c=0;c<s.length;c+=2)t[h]=s[c],t[h+1]=s[c+1],h+=o}return{vertices:t,indices:n}}const yo=8,en=11920929e-14,go=1;function mo(s,e,t,n,r,o,i,a,l=.5,h){const f=Math.min(.99,Math.max(0,l));let u=(go-f)/1;return u*=u,zn(s,e,t,n,r,o,i,a,h,u,0),h.push(i,a),h}function zn(s,e,t,n,r,o,i,a,l,h,c){if(c>yo)return;const f=(s+t)/2,u=(e+n)/2,d=(t+r)/2,p=(n+o)/2,m=(r+i)/2,y=(o+a)/2,A=(f+d)/2,P=(u+p)/2,v=(d+m)/2,C=(p+y)/2,x=(A+v)/2,b=(P+C)/2;if(c>0){let S=i-s,w=a-e;const _=Math.abs((t-i)*w-(n-a)*S),$=Math.abs((r-i)*w-(o-a)*S);if(_>en&&$>en){if((_+$)*(_+$)<=h*(S*S+w*w)){l.push(x,b);return}}else if(_>en){if(_*_<=h*(S*S+w*w)){l.push(x,b);return}}else if($>en){if($*$<=h*(S*S+w*w)){l.push(x,b);return}}else if(S=x-(s+i)/2,w=b-(e+a)/2,S*S+w*w<=h){l.push(x,b);return}}zn(s,e,f,u,A,P,x,b,l,h,c+1),zn(x,b,v,C,m,y,i,a,l,h,c+1)}const xo=8,wo=11920929e-14,vo=1;function bo(s,e,t,n,r,o,i=.5,a){const h=Math.min(.99,Math.max(0,i));let c=(vo-h)/1;return c*=c,Nn(a,s,e,t,n,r,o,c,0),a.push(r,o),a}function Nn(s,e,t,n,r,o,i,a,l){if(l>xo)return;const h=(e+n)/2,c=(t+r)/2,f=(n+o)/2,u=(r+i)/2,d=(h+f)/2,p=(c+u)/2;let m=o-e,y=i-t;const A=Math.abs((n-o)*y-(r-i)*m);if(A>wo){if(A*A<=a*(m*m+y*y)){s.push(d,p);return}}else if(m=d-(e+o)/2,y=p-(t+i)/2,m*m+y*y<=a){s.push(d,p);return}Nn(s,e,t,h,c,d,p,a,l+1),Nn(s,d,p,f,u,o,i,a,l+1)}function So(s,e){const t=1-s;return t*t*e}function Co(s,e){return 2*(1-s)*s*e}function Mo(s,e){return s*s*e}function Ur(s,e,t,n){return So(s,e)+Co(s,t)+Mo(s,n)}const Po=1e-4,Lr=1e-4;function To(s,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:i=!0}=e,a=Po;if(s.length===0)return{vertices:t,indices:n};const l=r;let h=l.alignment;if(r.alignment!==.5){let L=ko(s);o&&(L*=-1),h=(h-.5)*L+.5}const c={x:s[0],y:s[1]},f={x:s[s.length-2],y:s[s.length-1]},u=i,d=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(u){s=s.slice(),d&&(s.pop(),s.pop(),f.x=s[s.length-2],f.y=s[s.length-1]);const L=(c.x+f.x)*.5,D=(f.y+c.y)*.5;s.unshift(L,D),s.push(L,D)}const p=t,m=s.length/2;let y=s.length;const A=p.length/2,P=l.width/2,v=P*P,C=l.miterLimit*l.miterLimit;let x=s[0],b=s[1],S=s[2],w=s[3],_=0,$=0,B=-(b-w),I=x-S,j=0,T=0,U=Math.sqrt(B*B+I*I);B/=U,I/=U,B*=P,I*=P;const V=h,E=(1-V)*2,O=V*2;u||(l.cap==="round"?y+=se(x-B*(E-O)*.5,b-I*(E-O)*.5,x-B*E,b-I*E,x+B*O,b+I*O,p,!0)+2:l.cap==="square"&&(y+=Fr(x,b,B,I,E,O,!0,p))),p.push(x-B*E,b-I*E),p.push(x+B*O,b+I*O);for(let L=1;L<m-1;++L){x=s[(L-1)*2],b=s[(L-1)*2+1],S=s[L*2],w=s[L*2+1],_=s[(L+1)*2],$=s[(L+1)*2+1],B=-(b-w),I=x-S,U=Math.sqrt(B*B+I*I),B/=U,I/=U,B*=P,I*=P,j=-(w-$),T=S-_,U=Math.sqrt(j*j+T*T),j/=U,T/=U,j*=P,T*=P;const D=S-x,Z=b-w,W=S-_,G=$-w,R=D*W+Z*G,K=Z*W-G*D,X=K<0;if(Math.abs(K)<.001*Math.abs(R)){p.push(S-B*E,w-I*E),p.push(S+B*O,w+I*O),R>=0&&(l.join==="round"?y+=se(S,w,S-B*E,w-I*E,S-j*E,w-T*E,p,!1)+4:y+=2,p.push(S-j*O,w-T*O),p.push(S+j*E,w+T*E));continue}const nt=(-B+x)*(-I+w)-(-B+S)*(-I+b),Wt=(-j+_)*(-T+w)-(-j+S)*(-T+$),Et=(D*Wt-W*nt)/K,Ct=(G*nt-Z*Wt)/K,kt=(Et-S)*(Et-S)+(Ct-w)*(Ct-w),ht=S+(Et-S)*E,At=w+(Ct-w)*E,$t=S-(Et-S)*O,zt=w-(Ct-w)*O,Bt=Math.min(D*D+Z*Z,W*W+G*G),li=X?E:O,ma=Bt+li*li*v;kt<=ma?l.join==="bevel"||kt/v>C?(X?(p.push(ht,At),p.push(S+B*O,w+I*O),p.push(ht,At),p.push(S+j*O,w+T*O)):(p.push(S-B*E,w-I*E),p.push($t,zt),p.push(S-j*E,w-T*E),p.push($t,zt)),y+=2):l.join==="round"?X?(p.push(ht,At),p.push(S+B*O,w+I*O),y+=se(S,w,S+B*O,w+I*O,S+j*O,w+T*O,p,!0)+4,p.push(ht,At),p.push(S+j*O,w+T*O)):(p.push(S-B*E,w-I*E),p.push($t,zt),y+=se(S,w,S-B*E,w-I*E,S-j*E,w-T*E,p,!1)+4,p.push(S-j*E,w-T*E),p.push($t,zt)):(p.push(ht,At),p.push($t,zt)):(p.push(S-B*E,w-I*E),p.push(S+B*O,w+I*O),l.join==="round"?X?y+=se(S,w,S+B*O,w+I*O,S+j*O,w+T*O,p,!0)+2:y+=se(S,w,S-B*E,w-I*E,S-j*E,w-T*E,p,!1)+2:l.join==="miter"&&kt/v<=C&&(X?(p.push($t,zt),p.push($t,zt)):(p.push(ht,At),p.push(ht,At)),y+=2),p.push(S-j*E,w-T*E),p.push(S+j*O,w+T*O),y+=2)}x=s[(m-2)*2],b=s[(m-2)*2+1],S=s[(m-1)*2],w=s[(m-1)*2+1],B=-(b-w),I=x-S,U=Math.sqrt(B*B+I*I),B/=U,I/=U,B*=P,I*=P,p.push(S-B*E,w-I*E),p.push(S+B*O,w+I*O),u||(l.cap==="round"?y+=se(S-B*(E-O)*.5,w-I*(E-O)*.5,S-B*E,w-I*E,S+B*O,w+I*O,p,!1)+2:l.cap==="square"&&(y+=Fr(S,w,B,I,E,O,!1,p)));const q=Lr*Lr;for(let L=A;L<y+A-2;++L)x=p[L*2],b=p[L*2+1],S=p[(L+1)*2],w=p[(L+1)*2+1],_=p[(L+2)*2],$=p[(L+2)*2+1],!(Math.abs(x*(w-$)+S*($-b)+_*(b-w))<q)&&n.push(L,L+1,L+2);return{vertices:t,indices:n}}function ko(s){const e=s.length;if(e<6)return 1;let t=0;for(let n=0,r=s[e-2],o=s[e-1];n<e;n+=2){const i=s[n],a=s[n+1];t+=(i-r)*(a+o),r=i,o=a}return t<0?-1:1}function Fr(s,e,t,n,r,o,i,a){const l=s-t*r,h=e-n*r,c=s+t*o,f=e+n*o;let u,d;i?(u=n,d=-t):(u=-n,d=t);const p=l+u,m=h+d,y=c+u,A=f+d;return a.push(p,m),a.push(y,A),2}function se(s,e,t,n,r,o,i,a){const l=t-s,h=n-e;let c=Math.atan2(l,h),f=Math.atan2(r-s,o-e);a&&c<f?c+=Math.PI*2:!a&&c>f&&(f+=Math.PI*2);let u=c;const d=f-c,p=Math.abs(d),m=Math.sqrt(l*l+h*h),y=(15*p*Math.sqrt(m)/Math.PI>>0)+1,A=d/y;if(u+=A,a){i.push(s,e),i.push(t,n);for(let P=1,v=u;P<y;P++,v+=A)i.push(s,e),i.push(s+Math.sin(v)*m,e+Math.cos(v)*m);i.push(s,e),i.push(r,o)}else{i.push(t,n),i.push(s,e);for(let P=1,v=u;P<y;P++,v+=A)i.push(s+Math.sin(v)*m,e+Math.cos(v)*m),i.push(s,e);i.push(r,o),i.push(s,e)}return y*2}class me{constructor(){M(this,"arcLengthDivision",200);M(this,"_arcLengths")}getPointAt(e,t=new k){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 k;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new k;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,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 o=e[n],i=e[n+1];t.push(new k(o,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),o=1;o<=e;o++){const i=this.getPoint(o/e);n+=i.distanceTo(r),t.push(n),r=i}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/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]-o,h<0)a=i+1;else if(h>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(r-1);const c=n[i],u=n[i+1]-c,d=(o-c)/u;return(i+d)/(r-1)}getTangent(e,t=new k){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new k){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,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const i=this.getPoint(o);if(i.distanceTo(e)<t)return o;i.x<e.x?n=o:r=o}return o}getMinMax(e=k.MAX,t=k.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;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 H(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return po(this.getAdaptivePointArray(),e)}strokeTriangulate(e){return To(this.getAdaptivePointArray(),e)}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return ao(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 Ao=new Pt,$r=new Pt,zr=new Pt,nn=new k;class jn extends me{constructor(e=new k,t=new k,n=new k,r=0,o=0,i=Math.PI*2,a=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,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}getPoint(e,t=new k){const n=Math.PI*2;let r=this.endAngle-this.startAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.clockwise&&!o&&(r===n?r=-n:r=r-n);const i=this.startAngle+e*r;let a=this.cx+this.rx*Math.cos(i),l=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),f=a-this.cx,u=l-this.cy;a=f*h-u*c+this.cx,l=f*c+u*h+this.cy}return t.set(a,l)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:i,clockwise:a,rotate:l}=this,h=e+n*Math.cos(o)*Math.cos(l)-r*Math.sin(o)*Math.sin(l),c=t+n*Math.cos(o)*Math.sin(l)+r*Math.sin(o)*Math.cos(l),f=Math.abs(o-i),u=f>Math.PI?1:0,d=a?1:0,p=l*180/Math.PI;if(f>=2*Math.PI){const m=o+Math.PI,y=e+n*Math.cos(m)*Math.cos(l)-r*Math.sin(m)*Math.sin(l),A=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:p,largeArcFlag:0,sweepFlag:d,x:y,y:A},{type:"A",rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:d,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:p,largeArcFlag:u,sweepFlag:d,x:m,y}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:i,startAngle:a,endAngle:l,clockwise:h}=this;return e.ellipse(t,n,r,o,i,a,l,!h),this}applyTransform(e){return nn.set(this.cx,this.cy),nn.applyMatrix3(e),this.cx=nn.x,this.cy=nn.y,Oo(e)?Io(this,e):_o(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:i,dy:a}=this;if(!(r>=0&&o>=0&&i>=0&&a>=0))return e;const l=Math.ceil(2.3*Math.sqrt(r+o)),h=l*8+(i?4:0)+(a?4:0);if(h===0)return e;const c=[];if(l===0)c[0]=c[6]=t+i,c[1]=c[3]=n+a,c[2]=c[4]=t-i,c[5]=c[7]=n-a;else{let f=0,u=l*4+(i?2:0)+2,d=u,p=h,m=i+r,y=a,A=t+m,P=t-m,v=n+y;if(c[f++]=A,c[f++]=v,c[--u]=v,c[--u]=P,a){const x=n-y;c[d++]=P,c[d++]=x,c[--p]=x,c[--p]=A}for(let x=1;x<l;x++){const b=Math.PI/2*(x/l),S=i+Math.cos(b)*r,w=a+Math.sin(b)*o,_=t+S,$=t-S,B=n+w,I=n-w;c[f++]=_,c[f++]=B,c[--u]=B,c[--u]=$,c[d++]=$,c[d++]=I,c[--p]=I,c[--p]=_}m=i,y=a+o,A=t+m,P=t-m,v=n+y;const C=n-y;c[f++]=A,c[f++]=v,c[--p]=C,c[--p]=A,i&&(c[f++]=P,c[f++]=v,c[--p]=C,c[--p]=P)}return Array.prototype.push.apply(e,c),e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=0,indicesOffset:i=0}=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=o;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=k.MAX,t=k.MIN){const{cx:n,cy:r,rx:o,ry:i,rotate:a}=this,l=Math.cos(a),h=Math.sin(a),c=Math.sqrt(o*o*l*l+i*i*h*h),f=Math.sqrt(o*o*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 Io(s,e){const t=s.rx,n=s.ry,r=Math.cos(s.rotate),o=Math.sin(s.rotate),i=new k(t*r,t*o),a=new k(-n*o,n*r),l=i.applyMatrix3(e),h=a.applyMatrix3(e),c=Ao.set(l.x,h.x,0,l.y,h.y,0,0,0,1),f=$r.copy(c).invert(),p=zr.copy(f).transpose().multiply(f).elements,m=Eo(p[0],p[1],p[4]),y=Math.sqrt(m.rt1),A=Math.sqrt(m.rt2);if(s.rx=1/y,s.ry=1/A,s.rotate=Math.atan2(m.sn,m.cs),!((s.endAngle-s.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=$r.set(y,0,0,0,A,0,0,0,1),C=zr.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),x=v.multiply(C).multiply(c),b=S=>{const{x:w,y:_}=new k(Math.cos(S),Math.sin(S)).applyMatrix3(x);return Math.atan2(_,w)};s.startAngle=b(s.startAngle),s.endAngle=b(s.endAngle),Nr(e)&&(s.clockwise=!s.clockwise)}}function _o(s,e){const t=jr(e),n=Rr(e);s.rx*=t,s.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);s.rotate+=r,Nr(e)&&(s.startAngle*=-1,s.endAngle*=-1,s.clockwise=!s.clockwise)}function Nr(s){const e=s.elements;return e[0]*e[4]-e[1]*e[3]<0}function Oo(s){const e=s.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=jr(s),r=Rr(s);return Math.abs(t/(n*r))>Number.EPSILON}function jr(s){const e=s.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Rr(s){const e=s.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Eo(s,e,t){let n,r,o,i,a;const l=s+t,h=s-t,c=Math.sqrt(h*h+4*e*e);return l>0?(n=.5*(l+c),a=1/n,r=s*a*t-e*a*e):l<0?r=.5*(l-c):(n=.5*c,r=-.5*c),h>0?o=h+c:o=h-c,Math.abs(o)>2*Math.abs(e)?(a=-2*e/o,i=1/Math.sqrt(1+a*a),o=a*i):Math.abs(e)===0?(o=1,i=0):(a=-.5*o/e,o=1/Math.sqrt(1+a*a),i=a*o),h>0&&(a=o,o=-i,i=a),{rt1:n,rt2:r,cs:o,sn:i}}class Bo extends jn{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,i=!1){super(new k(e,t),new k(n,n),new k(0,0),0,r,o,i)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:i,clockwise:a}=this;return e.arc(t,n,r,o,i,!a),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:i,clockwise:a}=this;let l=Math.abs(o-i);(!a&&o>i||a&&i>o)&&(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=o;c*=a?1:-1;for(let u=0;u<h+1;u++){const d=Math.cos(f),p=Math.sin(f),m=t+d*r,y=n+p*r;e.push(m,y),f+=c}return e}}class $e extends me{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof $e?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new k){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const i=r[o]-n,a=this.curves[o],l=a.getLength();return a.getPointAt(l===0?0:1-i/l,t)}o++}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())}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),t=e.length-1}),e}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=k.MAX,t=k.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new H(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 Rn extends me{constructor(e=new k,t=new k,n=new k,r=new k){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,i,a,l){return new Rn(new k(e,t),new k(n,r),new k(o,i),new k(a,l))}getPoint(e,t=new k){const{p1:n,cp1:r,cp2:o,p2:i}=this;return t.set(Dr(e,n.x,r.x,o.x,i.x),Dr(e,n.y,r.y,o.y,i.y))}getAdaptivePointArray(e=[]){return mo(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 o=Math.sqrt(r),i=(-t+o)/(2*e),a=(-t-o)/(2*e);return[i,a].filter(l=>l>=0&&l<=1)}getMinMax(e=k.MAX,t=k.MIN){const{p1:n,cp1:r,cp2:o,p2:i}=this,a=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(i.x-o.x)),l=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(i.y-o.y)),h=[0,1,...a,...l];return((f,u)=>{for(const d of f)for(let p=0;p<=u;p++){const m=p/u-.5,y=Math.min(1,Math.max(0,d+m)),A=this.getPoint(y);e.x=Math.min(e.x,A.x),e.y=Math.min(e.y,A.y),t.x=Math.max(t.x,A.x),t.y=Math.max(t.y,A.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:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.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 Do extends jn{constructor(e=0,t=0,n=1,r=1,o=0,i=0,a=Math.PI*2,l=!1){super(new k(e,t),new k(n,r),new k,o,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 Qt extends me{constructor(e=new k,t=new k){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new Qt(new k(e,t),new k(n,r))}getPoint(e,t=new k){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new k){return this.getPoint(e,t)}getTangent(e,t=new k){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new k){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=k.MAX,t=k.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}]}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 Uo extends $e{}class qn extends me{constructor(e=new k,t=new k,n=new k){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,i){return new qn(new k(e,t),new k(n,r),new k(o,i))}getPoint(e,t=new k){const{p1:n,cp:r,p2:o}=this;return t.set(Ur(e,n.x,r.x,o.x),Ur(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return bo(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=k.MAX,t=k.MIN){const{p1:n,cp:r,p2:o}=this,i=.5*(n.x+r.x),a=.5*(n.y+r.y),l=.5*(n.x+o.x),h=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,i,l),e.y=Math.min(e.y,n.y,o.y,a,h),t.x=Math.max(t.x,n.x,o.x,i,l),t.y=Math.max(t.y,n.y,o.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 Lo 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,o=[new k(e,t),new k(e+n,t),new k(e+n,t+r),new k(e,t+r)];return this.curves=[new Qt(o[0],o[1]),new Qt(o[1],o[2]),new Qt(o[2],o[3]),new Qt(o[3],o[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:o=0,indicesOffset:i=0}=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;o*=r,t[o+u]=f[0],t[o+u+1]=f[1],u+=r,t[o+u]=f[2],t[o+u+1]=f[3],u+=r,t[o+u]=f[6],t[o+u+1]=f[7],u+=r,t[o+u]=f[4],t[o+u+1]=f[5],u+=r;const d=o/r;return n[i++]=d,n[i++]=d+1,n[i++]=d+2,n[i++]=d+1,n[i++]=d+3,n[i++]=d+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 Fo extends jn{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,i=n/2,a=r/2,l=e+i,h=t+a,c=Math.max(0,Math.min(o,Math.min(i,a))),f=c,u=i-c,d=a-f;return this._center=new k(l,h),this._radius=new k(c,f),this._diff=new k(u,d),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:i}=this;return e.roundRect(t,n,r,o,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 $o extends me{constructor(e=[]){super(),this.points=e}getPoint(e,t=new k){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),i=r-o,a=n[o===0?o:o-1],l=n[o],h=n[o>n.length-2?n.length-1:o+1],c=n[o>n.length-3?n.length-1:o+2];return t.set(Br(i,a.x,l.x,h.x,c.x),Br(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 rn extends $e{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:o,y:i}=t[n];this.lineTo(o,i)}return this}addCommands(t){return Or(t,this),this}addData(t){return this.addCommands(Er(t)),this}getUnevenPointArray(t=40,n=[]){return super.getUnevenPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}getSpacedPointArray(t=40,n=[]){return super.getSpacedPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}_setCurrentPoint(t){return this.currentPoint=new k(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 Qt(n,t)),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new k(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(Qt.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,o,i,a){const l=this.currentPoint;return l!=null&&l.equals({x:i,y:a})||this.curves.push(Rn.from((l==null?void 0:l.x)??0,(l==null?void 0:l.y)??0,t,n,r,o,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(t,n,r,o){const i=this.currentPoint;return i!=null&&i.equals({x:r,y:o})||this.curves.push(qn.from((i==null?void 0:i.x)??0,(i==null?void 0:i.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,i,a){const l=new Bo(t,n,r,o,i,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeArc(t,n,r,o,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,o,i,a),this}arcTo(t,n,r,o,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,i,a,l,h=!0){const c=new Do(t,n,r,o,i,a,l,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(t,n,r,o,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,o,i,a,l,h),this}rect(t,n,r,o){const i=new Lo(t,n,r,o);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,i){const a=new Fo(t,n,r,o,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new k;return this.curves.push(new $o([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(o=>o.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 zo(s){return s.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function No(s,e,t,n){const r=e.clone().sub(s),o=n.clone().sub(t),i=t.clone().sub(s),a=r.cross(o);if(a===0)return new k((s.x+t.x)/2,(s.y+t.y)/2);const l=i.cross(o)/a;return Math.abs(l)>1?new k((s.x+t.x)/2,(s.y+t.y)/2):new k(s.x+l*r.x,s.y+l*r.y)}class Tt extends $e{constructor(t,n={}){super();M(this,"currentCurve",new rn);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 rn().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 rn,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,o,i,a){return this.currentCurve.bezierCurveTo(t,n,r,o,i,a),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,i,a){return this.currentCurve.arc(t,n,r,o,i,a),this}arcTo(t,n,r,o,i){return this.currentCurve.arcTo(t,n,r,o,i),this}ellipse(t,n,r,o,i,a,l,h){return this.currentCurve.ellipse(t,n,r,o,i,a,l,h),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,i){return this.currentCurve.roundRect(t,n,r,o,i),this}reset(){return this.currentCurve=new rn,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return Or(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(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.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=[],o=[],i=[];n.forEach((l,h)=>{const c=l.getControlPointRefs(),f=l.isClockwise();i[h]=c,o[h]=f;const u=c[0],d=c[c.length-1]??u;r.push({start:f?d:u,end:f?u:d,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=o[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],d=No(c[c.length-1],c[c.length-2]??c[c.length-1],u[0],u[1]??u[0]);d&&(c[c.length-1].copy(d),u[0].copy(d))})}),this}getMinMax(t=k.MAX,n=k.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(i=>{if(i.getMinMax(t,n),r&&o>1){const a=o/2,l=i.isClockwise(),h=[];for(let c=0;c<=1;c+=1/i.arcLengthDivision){const f=i.getPoint(c),u=i.getNormal(c),d=u.clone().scale(l?a:-a),p=u.clone().scale(l?-a:a);h.push(f.clone().add(d),f.clone().add(p),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}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new H(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),Fn(t,n),this.curves.forEach(i=>{i.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),Fn(t,n),this.getControlPointRefs().forEach(i=>{io(t,i.x,i.y,{radius:4})}),r!=="none"&&t.fill(),o!=="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 o in t)t[o]!==void 0&&(n[zo(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);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 Gn{constructor(e=[]){this.paths=e}getBoundingBox(e=!0){if(!this.paths.length)return;const t=k.MAX,n=k.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new H(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=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">${o}</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:o,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,-o),this.paths.forEach(c=>{c.drawTo(h,n)})),l}}const qr="data:image/svg+xml;",Gr=`${qr}base64,`,Wr=`${qr}charset=utf8,`;function Vr(s){if(typeof s=="string"){let e;s.startsWith(Gr)?(s=s.substring(Gr.length,s.length),e=atob(s)):s.startsWith(Wr)?(s=s.substring(Wr.length,s.length),e=decodeURIComponent(s)):e=s;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
|
|
5
|
-
${e}`);return t.documentElement}else return s}const jo="px",Ro=90,Xr=["mm","cm","in","pt","pc","px"],Hr={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 Y(s){let e="px";if(typeof s=="string"||s instanceof String)for(let n=0,r=Xr.length;n<r;n++){const o=Xr[n];if(s.endsWith(o)){e=o,s=s.substring(0,s.length-o.length);break}}let t;return t=Hr[e][jo],t<0&&(t=Hr[e].in*Ro),t*Number.parseFloat(s)}const qo=new Pt,sn=new Pt,Zr=new Pt,Yr=new Pt;function Go(s,e,t){if(!(s.hasAttribute("transform")||s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))))return null;const n=Wo(s);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function Wo(s){const e=new Pt,t=qo;if(s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))&&e.translate(Y(s.getAttribute("x")),Y(s.getAttribute("y"))),s.hasAttribute("transform")){const n=s.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const l=o.slice(0,i),h=qt(o.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]),sn.makeTranslation(-f,-u),Zr.makeRotation(c),Yr.multiplyMatrices(Zr,sn),sn.makeTranslation(f,u),t.multiplyMatrices(sn,Yr)}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 Vo(s){return new Tt().arc(Y(s.getAttribute("cx")||0),Y(s.getAttribute("cy")||0),Y(s.getAttribute("r")||0),0,Math.PI*2)}function Xo(s,e){if(!(!s.sheet||!s.sheet.cssRules||!s.sheet.cssRules.length))for(let t=0;t<s.sheet.cssRules.length;t++){const n=s.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),o={};for(let i=n.style.length,a=0;a<i;a++){const l=n.style.item(a);o[l]=n.style.getPropertyValue(l)}for(let i=0;i<r.length;i++)e[r[i]]=Object.assign(e[r[i]]||{},{...o})}}function Ho(s){return new Tt().ellipse(Y(s.getAttribute("cx")||0),Y(s.getAttribute("cy")||0),Y(s.getAttribute("rx")||0),Y(s.getAttribute("ry")||0),0,0,Math.PI*2)}function Zo(s){return new Tt().moveTo(Y(s.getAttribute("x1")||0),Y(s.getAttribute("y1")||0)).lineTo(Y(s.getAttribute("x2")||0),Y(s.getAttribute("y2")||0))}function Yo(s){const e=new Tt,t=s.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Ko=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Qo(s){var n;const e=new Tt;let t=0;return(n=s.getAttribute("points"))==null||n.replace(Ko,(r,o,i)=>{const a=Y(o),l=Y(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!0,e}const Jo=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ta(s){var n;const e=new Tt;let t=0;return(n=s.getAttribute("points"))==null||n.replace(Jo,(r,o,i)=>{const a=Y(o),l=Y(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!1,e}function ea(s){const e=Y(s.getAttribute("x")||0),t=Y(s.getAttribute("y")||0),n=Y(s.getAttribute("rx")||s.getAttribute("ry")||0),r=Y(s.getAttribute("ry")||s.getAttribute("rx")||0),o=Y(s.getAttribute("width")),i=Y(s.getAttribute("height")),a=1-.551915024494,l=new Tt;return l.moveTo(e+n,t),l.lineTo(e+o-n,t),(n!==0||r!==0)&&l.bezierCurveTo(e+o-n*a,t,e+o,t+r*a,e+o,t+r),l.lineTo(e+o,t+i-r),(n!==0||r!==0)&&l.bezierCurveTo(e+o,t+i-r*a,e+o-n*a,t+i,e+o-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 Gt(s,e,t){e=Object.assign({},e);let n={};if(s.hasAttribute("class")){const h=s.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]}`])}s.hasAttribute("id")&&(n=Object.assign(n,t[`#${s.getAttribute("id")}`]));for(let h=s.style.length,c=0;c<h;c++){const f=s.style.item(c),u=s.style.getPropertyValue(f);e[f]=u,n[f]=u}function r(h,c,f=o){s.hasAttribute(h)&&(e[c]=f(s.getAttribute(h))),n[h]&&(e[c]=f(n[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function i(h){return Math.max(0,Math.min(1,Y(h)))}function a(h){return Math.max(0,Y(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>Y(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",Y),r("visibility","visibility"),e}function Wn(s,e,t=[],n={}){var f;if(s.nodeType!==1)return t;let r=!1,o=null,i={...e};switch(s.nodeName){case"svg":i=Gt(s,i,n);break;case"style":Xo(s,n);break;case"g":i=Gt(s,i,n);break;case"path":i=Gt(s,i,n),s.hasAttribute("d")&&(o=Yo(s));break;case"rect":i=Gt(s,i,n),o=ea(s);break;case"polygon":i=Gt(s,i,n),o=Qo(s);break;case"polyline":i=Gt(s,i,n),o=ta(s);break;case"circle":i=Gt(s,i,n),o=Vo(s);break;case"ellipse":i=Gt(s,i,n),o=Ho(s);break;case"line":i=Gt(s,i,n),o=Zo(s);break;case"defs":r=!0;break;case"use":{i=Gt(s,i,n);const d=(s.getAttributeNS("http://www.w3.org/1999/xlink","href")||s.getAttribute("href")||"").substring(1),p=(f=s.viewportElement)==null?void 0:f.getElementById(d);p?Wn(p,i,t,n):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(s);break}if(i.display==="none")return t;const a=new Pt,l=[],h=Go(s,a,l);o&&(o.applyTransform(a),t.push(o),o.style={...i});const c=s.childNodes;for(let u=0,d=c.length;u<d;u++){const p=c[u];r&&p.nodeName!=="style"&&p.nodeName!=="defs"||Wn(p,i,t,n)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}function Kr(s){return new Gn(Wn(Vr(s),{}))}const na=new Set(["©","®","÷"]),ra=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),ia={1:"italic",32:"bold"},sa={1:"italic",2:"bold"},Qr={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Jr{constructor(e,t,n){M(this,"path",new Tt);M(this,"lineBox",new H);M(this,"inlineBox",new H);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 center(){var e;return(e=this.glyphBox)==null?void 0:e.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??Ns,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:o}=e,i=o.unitsPerEm,a=t.ascent,l=t.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:u}=c,d=i/u,p=e.getAdvanceWidth(h,u),m=(a+Math.abs(l))/d,y=a/d;return this.advanceWidth=p,this.advanceHeight=m,this.inlineBox.width=f?m:p,this.inlineBox.height=f?p:m,this.underlinePosition=(a-r.underlinePosition)/d,this.underlineThickness=r.underlineThickness/d,this.strikeoutPosition=(a-n.yStrikeoutPosition)/d,this.strikeoutSize=n.yStrikeoutSize/d,this.ascender=a/d,this.descender=l/d,this.typoAscender=n.sTypoAscender/d,this.typoDescender=n.sTypoDescender/d,this.typoLineGap=n.sTypoLineGap/d,this.winAscent=n.usWinAscent/d,this.winDescent=n.usWinDescent/d,this.xHeight=n.sxHeight/d,this.capHeight=n.sCapHeight/d,this.baseline=y,this.centerDiviation=m/2-y,this.fontStyle=ia[n.fsSelection]??sa[o.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:n,content:r,computedStyle:o,baseline:i,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:u,advanceHeight:d}=this,{left:p,top:m}=a,y=o.fontStyle==="italic"&&f!=="italic";let A=p,P=m+i,v;const C=new Tt;if(n&&(A+=(d-u)/2,Math.abs(u-d)>.1&&(P-=(l-c)/(l+Math.abs(h))*d),v=void 0),n&&!na.has(r)&&(r.codePointAt(0)<=256||ra.has(r))){C.addCommands(t.getPathCommands(r,A,m+i-(d-u)/2,o.fontSize));const b={y:m-(d-u)/2+d/2,x:A+u/2};y&&this._italic(C,n?{x:b.x,y:m-(d-u)/2+i}:void 0),C.rotate(90,b)}else v!==void 0?(C.addCommands(t.glyphs.get(v).getPathCommands(A,P,o.fontSize)),y&&this._italic(C,n?{x:A+u/2,y:m+c/(l+Math.abs(h))*d}:void 0)):(C.addCommands(t.getPathCommands(r,A,P,o.fontSize)),y&&this._italic(C,n?{x:A+d/2,y:P}:void 0));const x=o.fontWeight??400;return x in Qr&&(x===700||x==="bold")&&f!=="bold"&&C.bold(Qr[x]*o.fontSize*.05),C.style={fill:o.color,stroke:o.textStrokeWidth?o.textStrokeColor:"none",strokeWidth:o.textStrokeWidth?o.textStrokeWidth*o.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 H(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)le(r);else{e.save(),e.beginPath();const o=this.path.style,i={...o,fill:r.color??o.fill,stroke:r.textStrokeColor??o.stroke,strokeWidth:r.textStrokeWidth?r.textStrokeWidth*r.fontSize:o.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 on(s,e){return typeof s=="number"?s:s.endsWith("%")?(s=s.substring(0,s.length-1),Math.ceil(Number(s)/100*e.total)):s.endsWith("rem")?(s=s.substring(0,s.length-3),Number(s)*e.fontSize):s.endsWith("em")?(s=s.substring(0,s.length-2),Number(s)*e.fontSize):Number(s)}function Vn(s){const e=Xt(s)?{}:s;return Object.keys(e).reduce((t,n)=>{let r=e[n];const o=Xn(n),i=Xn(r);return o&&(n=o),i&&(r=i),t[n]=r,t},{})}function Xt(s){return!s||s==="none"}function ti(s,e){const t=Object.keys(s),n=Object.keys(e);return Array.from(new Set([...t,...n])).every(o=>oe(s[o],e[o]))}function oe(s,e){const t=typeof s;return t===typeof e?t==="object"?ti(s,e):s===e:!1}function Xn(s){const e=s.startsWith("#")?s.slice(1):s;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),o=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgb(${r}, ${o}, ${i})`}function an(s){if(!s)return s;const e={};for(const t in s)s[t]!==""&&s[t]!==void 0&&(e[t]=s[t]);return e}function ln(s){return s.startsWith("http://")||s.startsWith("https://")||s.startsWith("blob://")}class ei{constructor(e,t={},n){M(this,"inlineBox",new H);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,...an(this.style)},this}initCharacters(){const e=[];let t=0;for(const n of this.computedContent)e.push(new Jr(n,t++,this));return this.characters=e,this}}class xe{constructor(e,t){M(this,"lineBox",new H);M(this,"fragments",[]);this.style=e,this.parentStyle=t,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...an(this.parentStyle),...an(this.style)},this}addFragment(e,t){const n=new ei(e,t,this);return this.fragments.push(n),n}}function oa(s){return s}const ve=class ve{_styleToDomStyle(e){const t={};for(const n in e){const r=e[n];ve.notZeroStyles.has(n)&&r===0||(typeof r=="number"&&ve.pxStyles.has(n)?t[n]=`${r}px`:t[n]=r)}return t}createParagraphDom(e,t){const n=document.createDocumentFragment(),r=document.createElement("section"),o={...t},i=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":o.justifyContent="start";break;case"center":o.justifyContent="center";break;case"end":case"right":o.justifyContent="end";break}switch(t.verticalAlign){case"top":o.alignItems="top";break;case"middle":o.alignItems="center";break;case"bottom":o.alignItems="end";break}const a=!!(o.justifyContent||o.alignItems);Object.assign(r.style,{boxSizing:"border-box",display:a?"inline-flex":void 0,width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(o),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(o=>{var f;const i=r+=n.substring(r).indexOf(o),a=i+o.length;r+=o.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((o,i)=>{const a=o.getBoundingClientRect();t.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),o.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(d=>{r.push({...d,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 o=[];let i=0;return r.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;o.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:d}=f,p=o[i];f.inlineBox.left=p.left,f.inlineBox.top=p.top,f.inlineBox.width=p.width,f.inlineBox.height=p.height,d?(f.lineBox.left=p.left+(p.width-u)/2,f.lineBox.top=p.top,f.lineBox.width=u,f.lineBox.height=p.height):(f.lineBox.left=p.left,f.lineBox.top=p.top+(p.height-u)/2,f.lineBox.width=p.width,f.lineBox.height=u),i++}),{paragraphs:e,boundingBox:new H(0,0,n.width,n.height)}}measure(e,t,n){let r;n||({dom:n,destory:r}=this.createParagraphDom(e,t));const o=this.measureParagraphDom(e,n);return r==null||r(),o}};M(ve,"notZeroStyles",new Set(["width","height"])),M(ve,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let hn=ve;function aa(){return{overflow:"visible",alignContent:"stretch",alignItems:"stretch",alignSelf:"auto",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",borderWidth:0,border:"none",direction:"inherit",display:"flex",flex:0,flexBasis:"auto",flexDirection:"row",flexGrow:0,flexShrink:1,flexWrap:"nowrap",height:"auto",justifyContent:"flex-start",gap:0,marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,margin:0,maxHeight:0,maxWidth:0,minHeight:0,minWidth:0,paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,padding:0,top:0,bottom:0,left:0,right:0,position:"static",boxSizing:"content-box",width:"auto"}}function la(){return{boxShadow:"none"}}function ha(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ca(){return{...ha(),...aa(),...la(),visibility:"visible",filter:"none",opacity:1,backgroundImage:"none",backgroundColor:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",pointerEvents:"auto"}}function fa(){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 ua(){return{...ca(),...fa()}}class pa{constructor(){M(this,"eventListeners",new Map)}addEventListener(e,t,n){const r={value:t,options:n},o=this.eventListeners.get(e);return o?Array.isArray(o)?o.push(r):this.eventListeners.set(e,[o,r]):this.eventListeners.set(e,r),this}removeEventListener(e,t,n){var o,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"||!((o=c.options)!=null&&o.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,o;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"&&((o=n.options)!=null&&o.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 ni(){return{name:"background"}}function cn(s){const{highlight:e,highlightImage:t,highlightReferImage:n,highlightColormap:r,highlightLine:o,highlightSize:i,highlightThickness:a}=s;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)??o??"none",size:(e==null?void 0:e.size)??i??"cover",thickness:(e==null?void 0:e.thickness)??a??"100%"}}function ri(){const s=[],e=[],t=new Map,n=new Map;async function r(i){if(!t.has(i)){t.set(i,i);try{t.set(i,await fetch(i).then(a=>a.text()))}catch(a){console.warn(a),t.delete(i)}}}function o(i){let a=n.get(i);if(!a){const l=Vr(ln(i)?t.get(i)??i:i),h=Kr(l);a={dom:l,pathSet:h},n.set(i,a)}return a}return{name:"highlight",paths:s,load:async i=>{const a=new Set;i.forEachCharacter(l=>{const{computedStyle:h}=l,{image:c,referImage:f}=cn(h);ln(c)&&a.add(c),ln(f)&&a.add(f)}),await Promise.all(Array.from(a).map(l=>r(l)))},update:i=>{e.length=0,s.length=0;let a=[],l,h;i.forEachCharacter(c=>{const{computedStyle:f}=c,u=cn(f),{image:d,colormap:p,line:m,size:y,thickness:A}=u;if(Xt(d))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:P,isVertical:v}=c,{fontSize:C}=f;(!h||oe(h.image,d)&&oe(h.colormap,p)&&oe(h.line,m)&&oe(h.size,y)&&oe(h.thickness,A))&&(l!=null&&l.length)&&(v?l[0].inlineBox.left===P.left:l[0].inlineBox.top===P.top)&&l[0].fontSize===C?l.push(c):(l=[],l.push(c),a.push(l))}h=u}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],u=f[0],d=H.from(...f.filter(O=>O.glyphBox).map(O=>O.glyphBox)),{computedStyle:p}=u,{fontSize:m,writingMode:y}=p,{image:A,referImage:P,colormap:v,line:C,size:x,thickness:b}=cn(p),S=y.includes("vertical"),w=on(b,{fontSize:m,total:d.width})/d.width,_=Vn(v),{pathSet:$,dom:B}=o(A),I=$.getBoundingBox(!0),j=m/I.width*2,T=new H().copy(d);S&&(T.width=d.height,T.height=d.width,T.left=d.left+d.width);const U=Math.floor(T.width);let V=U;if(x!=="cover"&&(V=on(x,{fontSize:m,total:d.width})||U,T.width=V),!Xt(P)&&Xt(C)){const O=o(P).pathSet.getBoundingBox(!0);I.copy(O)}else{let O;if(Xt(C))if(I.width/I.height>4){O="underline";const q=B.getAttribute("viewBox");if(q){const[L,D,Z,W]=q.split(" ").map(R=>Number(R)),G=D+W/2;I.y<G&&I.y+I.height>G?O="line-through":I.y+I.height<G?O="overline":O="underline"}}else O="outline";else O=C;switch(O){case"outline":{const q=T.width*.2,L=T.height*.2;T.width+=q,T.height+=L,S?(T.x-=L/2,T.y-=q/2,T.x+=T.height):(T.x-=q/2,T.y-=L/2);break}case"overline":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width:T.y=u.inlineBox.top;break;case"line-through":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width-u.strikeoutPosition+T.height/2:T.y=u.inlineBox.top+u.strikeoutPosition-T.height/2;break;case"underline":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width-u.underlinePosition:T.y=u.inlineBox.top+u.underlinePosition;break}}const E=new Pt().translate(-I.x,-I.y).scale(T.width/I.width,T.height/I.height);S&&E.rotate(-Math.PI/2),E.translate(T.x,T.y);for(let O=0;O<Math.ceil(U/V);O++){const q=E.clone();S?q.translate(0,O*T.width):q.translate(O*T.width,0),$.paths.forEach(L=>{const D=L.clone().applyTransform(q);D.style.strokeWidth&&(D.style.strokeWidth*=j*w),D.style.strokeMiterlimit&&(D.style.strokeMiterlimit*=j),D.style.strokeDashoffset&&(D.style.strokeDashoffset*=j),D.style.strokeDasharray&&(D.style.strokeDasharray=D.style.strokeDasharray.map(Z=>Z*j)),D.style.fill&&D.style.fill in _&&(D.style.fill=_[D.style.fill]),D.style.stroke&&D.style.stroke in _&&(D.style.stroke=_[D.style.stroke]),s.push(D),U!==V&&(S?e[s.length-1]=new H(d.left-d.width*2,d.top,d.width*4,d.height):e[s.length-1]=new H(d.left,d.top-d.height*2,d.width,d.height*4))})}}},renderOrder:-1,render:(i,a)=>{s.forEach((l,h)=>{if(le({ctx:i,path:l,fontSize:a.computedStyle.fontSize,clipRect:e[h]}),a.debug){const c=new Gn([l]).getBoundingBox();c&&i.strokeRect(c.x,c.y,c.width,c.height)}})}}}function da(s,e){return`<svg width="${s*2}" height="${s*2}" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
+
${e}`);return t.documentElement}else return s}const jo="px",Ro=90,Xr=["mm","cm","in","pt","pc","px"],Hr={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 Y(s){let e="px";if(typeof s=="string"||s instanceof String)for(let n=0,r=Xr.length;n<r;n++){const o=Xr[n];if(s.endsWith(o)){e=o,s=s.substring(0,s.length-o.length);break}}let t;return t=Hr[e][jo],t<0&&(t=Hr[e].in*Ro),t*Number.parseFloat(s)}const qo=new Pt,sn=new Pt,Zr=new Pt,Yr=new Pt;function Go(s,e,t){if(!(s.hasAttribute("transform")||s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))))return null;const n=Wo(s);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function Wo(s){const e=new Pt,t=qo;if(s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))&&e.translate(Y(s.getAttribute("x")),Y(s.getAttribute("y"))),s.hasAttribute("transform")){const n=s.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const l=o.slice(0,i),h=qt(o.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]),sn.makeTranslation(-f,-u),Zr.makeRotation(c),Yr.multiplyMatrices(Zr,sn),sn.makeTranslation(f,u),t.multiplyMatrices(sn,Yr)}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 Vo(s){return new Tt().arc(Y(s.getAttribute("cx")||0),Y(s.getAttribute("cy")||0),Y(s.getAttribute("r")||0),0,Math.PI*2)}function Xo(s,e){if(!(!s.sheet||!s.sheet.cssRules||!s.sheet.cssRules.length))for(let t=0;t<s.sheet.cssRules.length;t++){const n=s.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),o={};for(let i=n.style.length,a=0;a<i;a++){const l=n.style.item(a);o[l]=n.style.getPropertyValue(l)}for(let i=0;i<r.length;i++)e[r[i]]=Object.assign(e[r[i]]||{},{...o})}}function Ho(s){return new Tt().ellipse(Y(s.getAttribute("cx")||0),Y(s.getAttribute("cy")||0),Y(s.getAttribute("rx")||0),Y(s.getAttribute("ry")||0),0,0,Math.PI*2)}function Zo(s){return new Tt().moveTo(Y(s.getAttribute("x1")||0),Y(s.getAttribute("y1")||0)).lineTo(Y(s.getAttribute("x2")||0),Y(s.getAttribute("y2")||0))}function Yo(s){const e=new Tt,t=s.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Ko=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Qo(s){var n;const e=new Tt;let t=0;return(n=s.getAttribute("points"))==null||n.replace(Ko,(r,o,i)=>{const a=Y(o),l=Y(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!0,e}const Jo=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ta(s){var n;const e=new Tt;let t=0;return(n=s.getAttribute("points"))==null||n.replace(Jo,(r,o,i)=>{const a=Y(o),l=Y(i);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,r}),e.currentCurve.autoClose=!1,e}function ea(s){const e=Y(s.getAttribute("x")||0),t=Y(s.getAttribute("y")||0),n=Y(s.getAttribute("rx")||s.getAttribute("ry")||0),r=Y(s.getAttribute("ry")||s.getAttribute("rx")||0),o=Y(s.getAttribute("width")),i=Y(s.getAttribute("height")),a=1-.551915024494,l=new Tt;return l.moveTo(e+n,t),l.lineTo(e+o-n,t),(n!==0||r!==0)&&l.bezierCurveTo(e+o-n*a,t,e+o,t+r*a,e+o,t+r),l.lineTo(e+o,t+i-r),(n!==0||r!==0)&&l.bezierCurveTo(e+o,t+i-r*a,e+o-n*a,t+i,e+o-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 Gt(s,e,t){e=Object.assign({},e);let n={};if(s.hasAttribute("class")){const h=s.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]}`])}s.hasAttribute("id")&&(n=Object.assign(n,t[`#${s.getAttribute("id")}`]));for(let h=s.style.length,c=0;c<h;c++){const f=s.style.item(c),u=s.style.getPropertyValue(f);e[f]=u,n[f]=u}function r(h,c,f=o){s.hasAttribute(h)&&(e[c]=f(s.getAttribute(h))),n[h]&&(e[c]=f(n[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function i(h){return Math.max(0,Math.min(1,Y(h)))}function a(h){return Math.max(0,Y(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>Y(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",Y),r("visibility","visibility"),e}function Wn(s,e,t=[],n={}){var f;if(s.nodeType!==1)return t;let r=!1,o=null,i={...e};switch(s.nodeName){case"svg":i=Gt(s,i,n);break;case"style":Xo(s,n);break;case"g":i=Gt(s,i,n);break;case"path":i=Gt(s,i,n),s.hasAttribute("d")&&(o=Yo(s));break;case"rect":i=Gt(s,i,n),o=ea(s);break;case"polygon":i=Gt(s,i,n),o=Qo(s);break;case"polyline":i=Gt(s,i,n),o=ta(s);break;case"circle":i=Gt(s,i,n),o=Vo(s);break;case"ellipse":i=Gt(s,i,n),o=Ho(s);break;case"line":i=Gt(s,i,n),o=Zo(s);break;case"defs":r=!0;break;case"use":{i=Gt(s,i,n);const d=(s.getAttributeNS("http://www.w3.org/1999/xlink","href")||s.getAttribute("href")||"").substring(1),p=(f=s.viewportElement)==null?void 0:f.getElementById(d);p?Wn(p,i,t,n):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(s);break}if(i.display==="none")return t;const a=new Pt,l=[],h=Go(s,a,l);o&&(o.applyTransform(a),t.push(o),o.style={...i});const c=s.childNodes;for(let u=0,d=c.length;u<d;u++){const p=c[u];r&&p.nodeName!=="style"&&p.nodeName!=="defs"||Wn(p,i,t,n)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}function Kr(s){return new Gn(Wn(Vr(s),{}))}const na=new Set(["©","®","÷"]),ra=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),ia={1:"italic",32:"bold"},sa={1:"italic",2:"bold"},Qr={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Jr{constructor(e,t,n){M(this,"path",new Tt);M(this,"lineBox",new H);M(this,"inlineBox",new H);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 center(){var e;return(e=this.glyphBox)==null?void 0:e.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??Ns,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:o}=e,i=o.unitsPerEm,a=t.ascent,l=t.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:u}=c,d=i/u,p=e.getAdvanceWidth(h,u),m=(a+Math.abs(l))/d,y=a/d;return this.advanceWidth=p,this.advanceHeight=m,this.inlineBox.width=f?m:p,this.inlineBox.height=f?p:m,this.underlinePosition=(a-r.underlinePosition)/d,this.underlineThickness=r.underlineThickness/d,this.strikeoutPosition=(a-n.yStrikeoutPosition)/d,this.strikeoutSize=n.yStrikeoutSize/d,this.ascender=a/d,this.descender=l/d,this.typoAscender=n.sTypoAscender/d,this.typoDescender=n.sTypoDescender/d,this.typoLineGap=n.sTypoLineGap/d,this.winAscent=n.usWinAscent/d,this.winDescent=n.usWinDescent/d,this.xHeight=n.sxHeight/d,this.capHeight=n.sCapHeight/d,this.baseline=y,this.centerDiviation=m/2-y,this.fontStyle=ia[n.fsSelection]??sa[o.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:n,content:r,computedStyle:o,baseline:i,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:u,advanceHeight:d}=this,{left:p,top:m}=a,y=o.fontStyle==="italic"&&f!=="italic";let A=p,P=m+i,v;const C=new Tt;if(n&&(A+=(d-u)/2,Math.abs(u-d)>.1&&(P-=(l-c)/(l+Math.abs(h))*d),v=void 0),n&&!na.has(r)&&(r.codePointAt(0)<=256||ra.has(r))){C.addCommands(t.getPathCommands(r,A,m+i-(d-u)/2,o.fontSize));const b={y:m-(d-u)/2+d/2,x:A+u/2};y&&this._italic(C,n?{x:b.x,y:m-(d-u)/2+i}:void 0),C.rotate(90,b)}else v!==void 0?(C.addCommands(t.glyphs.get(v).getPathCommands(A,P,o.fontSize)),y&&this._italic(C,n?{x:A+u/2,y:m+c/(l+Math.abs(h))*d}:void 0)):(C.addCommands(t.getPathCommands(r,A,P,o.fontSize)),y&&this._italic(C,n?{x:A+d/2,y:P}:void 0));const x=o.fontWeight??400;return x in Qr&&(x===700||x==="bold")&&f!=="bold"&&C.bold(Qr[x]*o.fontSize*.05),C.style={fill:o.color,stroke:o.textStrokeWidth?o.textStrokeColor:"none",strokeWidth:o.textStrokeWidth?o.textStrokeWidth*o.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 H(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)le(r);else{e.save(),e.beginPath();const o=this.path.style,i={...o,fill:r.color??o.fill,stroke:r.textStrokeColor??o.stroke,strokeWidth:r.textStrokeWidth?r.textStrokeWidth*r.fontSize:o.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 on(s,e){return typeof s=="number"?s:s.endsWith("%")?(s=s.substring(0,s.length-1),Math.ceil(Number(s)/100*e.total)):s.endsWith("rem")?(s=s.substring(0,s.length-3),Number(s)*e.fontSize):s.endsWith("em")?(s=s.substring(0,s.length-2),Number(s)*e.fontSize):Number(s)}function Vn(s){const e=Xt(s)?{}:s;return Object.keys(e).reduce((t,n)=>{let r=e[n];const o=Xn(n),i=Xn(r);return o&&(n=o),i&&(r=i),t[n]=r,t},{})}function Xt(s){return!s||s==="none"}function ti(s,e){const t=Object.keys(s),n=Object.keys(e);return Array.from(new Set([...t,...n])).every(o=>oe(s[o],e[o]))}function oe(s,e){const t=typeof s;return t===typeof e?t==="object"?ti(s,e):s===e:!1}function Xn(s){const e=s.startsWith("#")?s.slice(1):s;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),o=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgb(${r}, ${o}, ${i})`}function an(s){if(!s)return s;const e={};for(const t in s)s[t]!==""&&s[t]!==void 0&&(e[t]=s[t]);return e}function ln(s){return s.startsWith("http://")||s.startsWith("https://")||s.startsWith("blob://")}class ei{constructor(e,t={},n){M(this,"inlineBox",new H);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,...an(this.style)},this}initCharacters(){const e=[];let t=0;for(const n of this.computedContent)e.push(new Jr(n,t++,this));return this.characters=e,this}}class xe{constructor(e,t){M(this,"lineBox",new H);M(this,"fragments",[]);this.style=e,this.parentStyle=t,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...an(this.parentStyle),...an(this.style)},this}addFragment(e,t){const n=new ei(e,t,this);return this.fragments.push(n),n}}function oa(s){return s}const ve=class ve{_styleToDomStyle(e){const t={};for(const n in e){const r=e[n];ve.notZeroStyles.has(n)&&r===0||(typeof r=="number"&&ve.pxStyles.has(n)?t[n]=`${r}px`:t[n]=r)}return t}createParagraphDom(e,t){const n=document.createDocumentFragment(),r=document.createElement("section"),o={...t},i=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":o.justifyContent="flex-start";break;case"center":o.justifyContent="center";break;case"end":case"right":o.justifyContent="flex-end";break}switch(t.verticalAlign){case"top":o.alignItems="flex-start";break;case"middle":o.alignItems="center";break;case"bottom":o.alignItems="flex-end";break}const a=!!(o.justifyContent||o.alignItems);Object.assign(r.style,{...this._styleToDomStyle({...o,boxSizing:o.boxSizing??"border-box",display:o.display??(a?"inline-flex":void 0),width:o.width??"max-content",height:o.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(o=>{var f;const i=r+=n.substring(r).indexOf(o),a=i+o.length;r+=o.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((o,i)=>{const a=o.getBoundingClientRect();t.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),o.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(d=>{r.push({...d,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 o=[];let i=0;return r.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;o.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:d}=f,p=o[i];f.inlineBox.left=p.left,f.inlineBox.top=p.top,f.inlineBox.width=p.width,f.inlineBox.height=p.height,d?(f.lineBox.left=p.left+(p.width-u)/2,f.lineBox.top=p.top,f.lineBox.width=u,f.lineBox.height=p.height):(f.lineBox.left=p.left,f.lineBox.top=p.top+(p.height-u)/2,f.lineBox.width=p.width,f.lineBox.height=u),i++}),{paragraphs:e,boundingBox:new H(0,0,n.width,n.height)}}measure(e,t,n){let r;n||({dom:n,destory:r}=this.createParagraphDom(e,t));const o=this.measureParagraphDom(e,n);return r==null||r(),o}};M(ve,"notZeroStyles",new Set(["width","height"])),M(ve,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let hn=ve;function aa(){return{overflow:void 0,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 la(){return{boxShadow:"none"}}function ha(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ca(){return{...aa(),...ha(),...la(),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"}}function fa(){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 ua(){return{...ca(),...fa()}}class pa{constructor(){M(this,"eventListeners",new Map)}addEventListener(e,t,n){const r={value:t,options:n},o=this.eventListeners.get(e);return o?Array.isArray(o)?o.push(r):this.eventListeners.set(e,[o,r]):this.eventListeners.set(e,r),this}removeEventListener(e,t,n){var o,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"||!((o=c.options)!=null&&o.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,o;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"&&((o=n.options)!=null&&o.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 ni(){return{name:"background"}}function cn(s){const{highlight:e,highlightImage:t,highlightReferImage:n,highlightColormap:r,highlightLine:o,highlightSize:i,highlightThickness:a}=s;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)??o??"none",size:(e==null?void 0:e.size)??i??"cover",thickness:(e==null?void 0:e.thickness)??a??"100%"}}function ri(){const s=[],e=[],t=new Map,n=new Map;async function r(i){if(!t.has(i)){t.set(i,i);try{t.set(i,await fetch(i).then(a=>a.text()))}catch(a){console.warn(a),t.delete(i)}}}function o(i){let a=n.get(i);if(!a){const l=Vr(ln(i)?t.get(i)??i:i),h=Kr(l);a={dom:l,pathSet:h},n.set(i,a)}return a}return{name:"highlight",paths:s,load:async i=>{const a=new Set;i.forEachCharacter(l=>{const{computedStyle:h}=l,{image:c,referImage:f}=cn(h);ln(c)&&a.add(c),ln(f)&&a.add(f)}),await Promise.all(Array.from(a).map(l=>r(l)))},update:i=>{e.length=0,s.length=0;let a=[],l,h;i.forEachCharacter(c=>{const{computedStyle:f}=c,u=cn(f),{image:d,colormap:p,line:m,size:y,thickness:A}=u;if(Xt(d))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:P,isVertical:v}=c,{fontSize:C}=f;(!h||oe(h.image,d)&&oe(h.colormap,p)&&oe(h.line,m)&&oe(h.size,y)&&oe(h.thickness,A))&&(l!=null&&l.length)&&(v?l[0].inlineBox.left===P.left:l[0].inlineBox.top===P.top)&&l[0].fontSize===C?l.push(c):(l=[],l.push(c),a.push(l))}h=u}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],u=f[0],d=H.from(...f.filter(O=>O.glyphBox).map(O=>O.glyphBox)),{computedStyle:p}=u,{fontSize:m,writingMode:y}=p,{image:A,referImage:P,colormap:v,line:C,size:x,thickness:b}=cn(p),S=y.includes("vertical"),w=on(b,{fontSize:m,total:d.width})/d.width,_=Vn(v),{pathSet:$,dom:B}=o(A),I=$.getBoundingBox(!0),j=m/I.width*2,T=new H().copy(d);S&&(T.width=d.height,T.height=d.width,T.left=d.left+d.width);const U=Math.floor(T.width);let V=U;if(x!=="cover"&&(V=on(x,{fontSize:m,total:d.width})||U,T.width=V),!Xt(P)&&Xt(C)){const O=o(P).pathSet.getBoundingBox(!0);I.copy(O)}else{let O;if(Xt(C))if(I.width/I.height>4){O="underline";const q=B.getAttribute("viewBox");if(q){const[L,D,Z,W]=q.split(" ").map(R=>Number(R)),G=D+W/2;I.y<G&&I.y+I.height>G?O="line-through":I.y+I.height<G?O="overline":O="underline"}}else O="outline";else O=C;switch(O){case"outline":{const q=T.width*.2,L=T.height*.2;T.width+=q,T.height+=L,S?(T.x-=L/2,T.y-=q/2,T.x+=T.height):(T.x-=q/2,T.y-=L/2);break}case"overline":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width:T.y=u.inlineBox.top;break;case"line-through":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width-u.strikeoutPosition+T.height/2:T.y=u.inlineBox.top+u.strikeoutPosition-T.height/2;break;case"underline":T.height=I.height*j,S?T.x=u.inlineBox.left+u.inlineBox.width-u.underlinePosition:T.y=u.inlineBox.top+u.underlinePosition;break}}const E=new Pt().translate(-I.x,-I.y).scale(T.width/I.width,T.height/I.height);S&&E.rotate(-Math.PI/2),E.translate(T.x,T.y);for(let O=0;O<Math.ceil(U/V);O++){const q=E.clone();S?q.translate(0,O*T.width):q.translate(O*T.width,0),$.paths.forEach(L=>{const D=L.clone().applyTransform(q);D.style.strokeWidth&&(D.style.strokeWidth*=j*w),D.style.strokeMiterlimit&&(D.style.strokeMiterlimit*=j),D.style.strokeDashoffset&&(D.style.strokeDashoffset*=j),D.style.strokeDasharray&&(D.style.strokeDasharray=D.style.strokeDasharray.map(Z=>Z*j)),D.style.fill&&D.style.fill in _&&(D.style.fill=_[D.style.fill]),D.style.stroke&&D.style.stroke in _&&(D.style.stroke=_[D.style.stroke]),s.push(D),U!==V&&(S?e[s.length-1]=new H(d.left-d.width*2,d.top,d.width*4,d.height):e[s.length-1]=new H(d.left,d.top-d.height*2,d.width,d.height*4))})}}},renderOrder:-1,render:(i,a)=>{s.forEach((l,h)=>{if(le({ctx:i,path:l,fontSize:a.computedStyle.fontSize,clipRect:e[h]}),a.debug){const c=new Gn([l]).getBoundingBox();c&&i.strokeRect(c.x,c.y,c.width,c.height)}})}}}function da(s,e){return`<svg width="${s*2}" height="${s*2}" xmlns="http://www.w3.org/2000/svg">
|
|
6
6
|
<circle cx="${s}" cy="${s}" r="${s}" fill="${e}" />
|
|
7
7
|
</svg>`}function ii(){const s=[];return{name:"listStyle",paths:s,update:e=>{s.length=0;const{paragraphs:t,isVertical:n,fontSize:r}=e,o=r*.45;t.forEach(i=>{const{computedStyle:a}=i,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:u}=a,d=Vn(c);let p=f,m;if(!Xt(h))m=h;else if(!Xt(u)){const v=r*.38/2;switch(p=p==="cover"?v*2:p,u){case"disc":m=da(v,String(l));break}}if(!m)return;const y=Kr(m),A=y.getBoundingBox();let P;i.fragments.forEach(v=>{v.characters.forEach(C=>{const{inlineBox:x}=C;if(n?(P==null?void 0:P.inlineBox.left)!==x.left:(P==null?void 0:P.inlineBox.top)!==x.top){P=C;const b=p==="cover"?1:on(p,{total:r,fontSize:r})/r,S=new Pt;if(n){const w=r/A.height*b;S.translate(-A.left,-A.top).rotate(Math.PI/2).scale(w,w).translate(x.left+(x.width-A.height*w)/2,x.top-o)}else{const w=r/A.height*b;S.translate(-A.left,-A.top).scale(w,w).translate(x.left-A.width*w-o,x.top+(x.height-A.height*w)/2)}s.push(...y.paths.map(w=>{const _=w.clone();return _.applyTransform(S),_.style.fill&&_.style.fill in d&&(_.style.fill=d[_.style.fill]),_.style.stroke&&_.style.stroke in d&&(_.style.stroke=d[_.style.stroke]),_}))}})})})}}}function si(){return{name:"outline"}}const Jt=new k,we=new Pt,te=new Pt;function oi(){return{name:"render",getBoundingBox:s=>{const{characters:e,fontSize:t,effects:n}=s,r=[];return e.forEach(o=>{n==null||n.forEach(i=>{if(!o.glyphBox)return;const a=o.glyphBox.clone(),l=fn(s,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?H.from(...r):void 0},render:(s,e)=>{const{paragraphs:t,glyphBox:n,effects:r,style:o}=e;function i(a,l){s.fillStyle=a,s.fillRect(l.left,l.top,l.width,l.height)}o!=null&&o.backgroundColor&&i(o.backgroundColor,new H(0,0,s.canvas.width,s.canvas.height)),t.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&i(a.style.backgroundColor,a.lineBox)}),r?r.forEach(a=>{Nt(a,n,s),s.save();const[l,h,c,f,u,d]=fn(e,a).transpose().elements;s.transform(l,f,h,u,c,d),e.forEachCharacter(p=>{var m;(m=p.parent.style)!=null&&m.backgroundColor&&i(p.parent.style.backgroundColor,p.inlineBox),p.drawTo(s,a)}),s.restore()}):t.forEach(a=>{a.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&i(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(s)})})}),e.debug&&t.forEach(a=>{s.strokeRect(a.lineBox.x,a.lineBox.y,a.lineBox.width,a.lineBox.height)})}}}function fn(s,e){const{fontSize:t,glyphBox:n}=s,r=(e.translateX??0)*t,o=(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,d=h+f/2,p=c+u/2;return we.identity(),te.makeTranslation(r,o),we.multiply(te),te.makeTranslation(d,p),we.multiply(te),te.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),we.multiply(te),te.makeTranslation(-d,-p),we.multiply(te),we.clone()}function ai(){const s=[];return{name:"textDecoration",paths:s,update:e=>{s.length=0;const t=[];let n,r;e.forEachCharacter(o=>{const{computedStyle:i,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:u}=o,{color:d,textDecoration:p,writingMode:m}=i;if(Xt(p))r=void 0;else{let y=!1;if((r==null?void 0:r.textDecoration)===p&&(r==null?void 0:r.writingMode)===m&&(r==null?void 0:r.color)===d&&(a?n[0].inlineBox.left===l.left:n[0].inlineBox.top===l.top))switch(p){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(o):(n=[],n.push(o),t.push(n)),r=i}}),t.forEach(o=>{const{computedStyle:i,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=o[0],{color:u,textDecoration:d}=i,{left:p,top:m,width:y,height:A}=H.from(...o.map(b=>b.inlineBox));let P=a?p+y:m;const v=a?-1:1;let C=0;switch(d){case"overline":C=h*2;break;case"underline":P+=v*l,C=h*2;break;case"line-through":P+=v*c,C=f*2;break}P-=C;let x;a?x=new Tt([{type:"M",x:P,y:m},{type:"L",x:P,y:m+A},{type:"L",x:P+C,y:m+A},{type:"L",x:P+C,y:m},{type:"Z"}],{fill:u}):x=new Tt([{type:"M",x:p,y:P},{type:"L",x:p+y,y:P},{type:"L",x:p+y,y:P+C},{type:"L",x:p,y:P+C},{type:"Z"}],{fill:u}),s.push(x)})},render:(e,t)=>{const{effects:n,computedStyle:r}=t;n?n.forEach(o=>{e.save();const[i,a,l,h,c,f]=fn(t,o).transpose().elements;e.transform(i,h,a,c,l,f),s.forEach(u=>{le({ctx:e,path:u,fontSize:r.fontSize,...o})}),e.restore()}):s.forEach(o=>{le({ctx:e,path:o,fontSize:r.fontSize})})}}}const Hn=ua();class Zn extends pa{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",{...Hn});M(this,"paragraphs",[]);M(this,"lineBox",new H);M(this,"rawGlyphBox",new H);M(this,"glyphBox",new H);M(this,"pathBox",new H);M(this,"boundingBox",new H);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(ni()).use(si()).use(ii()).use(ai()).use(ri()).use(oi()),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((o,i)=>{o.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={...Hn,...this.style};let{content:t,computedStyle:n}=this;const r=[];if(typeof t=="string"){const o=new xe({},n);o.addFragment(t),r.push(o)}else{t=Array.isArray(t)?t:[t];for(const o of t)if(typeof o=="string"){const i=new xe({},n);i.addFragment(o),r.push(i)}else if(Array.isArray(o)){const i=new xe({},n);o.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 o){const{fragments:i,...a}=o,l=new xe(a,n);i.forEach(h=>{const{content:c,...f}=h;c!==void 0&&l.addFragment(c,f)}),r.push(l)}else if("content"in o){const{content:i,...a}=o;if(i!==void 0){const l=new xe(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(o=>{o.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((o,i)=>(o.updateOrder??0)-(i.updateOrder??0)).forEach(o=>{var i;(i=o.update)==null||i.call(o,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const o in n)r[o]=this[o],this[o]=n[o];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const t=k.MAX,n=k.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(t,n)){const{inlineBox:o}=r,i=new k(o.left,o.top),a=new k(o.left+o.width,o.top+o.height);t.min(i,a),n.max(i,a)}}),new H(t.x,t.y,n.x-t.x,n.y-t.y)}updatePathBox(){return this.pathBox=H.from(this.glyphBox,...Array.from(this.plugins.values()).map(t=>t.getBoundingBox?t.getBoundingBox(this):new Gn(t.paths??[]).getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){const{lineBox:t,rawGlyphBox:n,pathBox:r}=this,o=Math.min(r.left,r.left+t.left-n.left),i=Math.min(r.top,r.top+t.top-n.top),a=Math.max(r.right,r.right+t.right-n.right),l=Math.max(r.bottom,r.bottom+t.bottom-n.bottom);return this.boundingBox=new H(o,i,a-o,l-i),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,o=n.getContext("2d");o&&(this.needsUpdate&&this.update(),Yn(o,r,this.boundingBox),Kn(o,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,o,this);else if(i.paths){const l=this.computedStyle;i.paths.forEach(h=>{le({ctx:o,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:n,pixelRatio:r}))}}function ya(s,e){const t=new Zn(s);return e?t.load().then(()=>t.measure()):t.measure()}function ga(s,e){const t=new Zn(s);return e?t.load().then(()=>t.render(s)):t.render(s)}N.Character=Jr,N.Fragment=ei,N.Measurer=hn,N.Paragraph=xe,N.Text=Zn,N.background=ni,N.definePlugin=oa,N.drawPath=le,N.filterEmpty=an,N.getHighlightStyle=cn,N.getTransform2D=fn,N.hexToRgb=Xn,N.highlight=ri,N.isEqualObject=ti,N.isEqualValue=oe,N.isNone=Xt,N.listStyle=ii,N.measureText=ya,N.needsFetch=ln,N.outline=si,N.parseColor=ct,N.parseColormap=Vn,N.parseValueNumber=on,N.render=oi,N.renderText=ga,N.setupView=Yn,N.textDecoration=ai,N.textDefaultStyle=Hn,N.uploadColor=Nt,N.uploadColors=Kn,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -565,36 +565,38 @@ class Measurer {
|
|
|
565
565
|
switch (rootStyle.textAlign) {
|
|
566
566
|
case "start":
|
|
567
567
|
case "left":
|
|
568
|
-
style.justifyContent = "start";
|
|
568
|
+
style.justifyContent = "flex-start";
|
|
569
569
|
break;
|
|
570
570
|
case "center":
|
|
571
571
|
style.justifyContent = "center";
|
|
572
572
|
break;
|
|
573
573
|
case "end":
|
|
574
574
|
case "right":
|
|
575
|
-
style.justifyContent = "end";
|
|
575
|
+
style.justifyContent = "flex-end";
|
|
576
576
|
break;
|
|
577
577
|
}
|
|
578
578
|
switch (rootStyle.verticalAlign) {
|
|
579
579
|
case "top":
|
|
580
|
-
style.alignItems = "
|
|
580
|
+
style.alignItems = "flex-start";
|
|
581
581
|
break;
|
|
582
582
|
case "middle":
|
|
583
583
|
style.alignItems = "center";
|
|
584
584
|
break;
|
|
585
585
|
case "bottom":
|
|
586
|
-
style.alignItems = "end";
|
|
586
|
+
style.alignItems = "flex-end";
|
|
587
587
|
break;
|
|
588
588
|
}
|
|
589
589
|
const isFlex = Boolean(style.justifyContent || style.alignItems);
|
|
590
590
|
Object.assign(dom.style, {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
...this._styleToDomStyle({
|
|
592
|
+
...style,
|
|
593
|
+
boxSizing: style.boxSizing ?? "border-box",
|
|
594
|
+
display: style.display ?? (isFlex ? "inline-flex" : void 0),
|
|
595
|
+
width: style.width ?? "max-content",
|
|
596
|
+
height: style.height ?? "max-content"
|
|
597
|
+
}),
|
|
595
598
|
whiteSpace: "pre-wrap",
|
|
596
599
|
wordBreak: "break-all",
|
|
597
|
-
...this._styleToDomStyle(style),
|
|
598
600
|
position: "fixed",
|
|
599
601
|
visibility: "hidden"
|
|
600
602
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-text",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "Measure and render text in a way that describes the DOM.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"modern-font": "^0.4.0",
|
|
61
|
-
"modern-idoc": "^0.2.
|
|
61
|
+
"modern-idoc": "^0.2.11",
|
|
62
62
|
"modern-path2d": "^1.2.10"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|