modern-text 0.4.1 → 0.4.2
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 +4 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1185,10 +1185,10 @@ class Text {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
updateBoundingBox() {
|
|
1187
1187
|
const { lineBox, rawGlyphBox, pathBox } = this;
|
|
1188
|
-
const left = pathBox.left + lineBox.left - rawGlyphBox.left;
|
|
1189
|
-
const top = pathBox.top + lineBox.top - rawGlyphBox.top;
|
|
1190
|
-
const right = pathBox.right + lineBox.right - rawGlyphBox.right;
|
|
1191
|
-
const bottom = pathBox.bottom + lineBox.bottom - rawGlyphBox.bottom;
|
|
1188
|
+
const left = Math.min(pathBox.left, pathBox.left + lineBox.left - rawGlyphBox.left);
|
|
1189
|
+
const top = Math.min(pathBox.top, pathBox.top + lineBox.top - rawGlyphBox.top);
|
|
1190
|
+
const right = Math.max(pathBox.right, pathBox.right + lineBox.right - rawGlyphBox.right);
|
|
1191
|
+
const bottom = Math.max(pathBox.bottom, pathBox.bottom + lineBox.bottom - rawGlyphBox.bottom);
|
|
1192
1192
|
this.boundingBox = new modernPath2d.BoundingBox(
|
|
1193
1193
|
left,
|
|
1194
1194
|
top,
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
src: url(${e});
|
|
4
4
|
}`)),document.head.appendChild(r),this}get(t){let e;return t&&(e=this.loaded.get(this.familyToUrl.get(t)??t)),e??this.fallbackFont}set(t,e){return this.familyToUrl.set(t,e.src),this.loaded.set(e.src,e),this}delete(t){const e=this.familyToUrl.get(t)??t;return this.familyToUrl.delete(e),this.loaded.delete(e),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(t,e={}){const{cancelOther:r,injectFontFace:n=!0,injectStyleTag:o=!0,...i}=e,{src:a}=t;if(this.loaded.has(a))return r&&(this.loading.forEach(p=>p.cancel()),this.loading.clear()),u(this.loaded.get(a));let h=this.loading.get(a);return h||(h=this._createRequest(a,i),this.loading.set(a,h)),r&&this.loading.forEach((p,g)=>{p!==h&&(p.cancel(),this.loading.delete(g))}),h.when.then(p=>{if(this.loaded.has(a))return u(this.loaded.get(a));{const g=c(p);return e.noAdd||this.loaded.set(t.src,g),g.familySet.forEach(d=>{this.familyToUrl.set(d,a),typeof document<"u"&&(n&&this.injectFontFace(d,p),o&&this.injectStyleTag(d,a))}),g}}).catch(p=>{if(p instanceof DOMException&&p.message==="The user aborted a request.")return c();throw p}).finally(()=>{this.loading.delete(a)});function l(){return t.family?Array.isArray(t.family)?t.family:[t.family]:[]}function u(p){return l().forEach(g=>{p.familySet.add(g)}),p}function c(p=new ArrayBuffer(0)){let g;function d(){return g||(g=p.byteLength?ro(p,!1):void 0),g}function m(){const f=d();if(f instanceof At||f instanceof wr)return f.sfnt}return{...t,buffer:p,familySet:new Set(l()),getFont:d,getSfnt:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(t=>t.when))}};Me(Cn,"defaultRequestInit",{cache:"force-cache"});let io=Cn;const oo=new io,ao={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Pn(s,t){const{fill:e="#000",stroke:r="none",strokeWidth:n=r==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:a=0,strokeDasharray:h=[],strokeDashoffset:l=0,shadowOffsetX:u=0,shadowOffsetY:c=0,shadowBlur:p=0,shadowColor:g="rgba(0, 0, 0, 0)"}=t;s.fillStyle=e,s.strokeStyle=r,s.lineWidth=n,s.lineCap=o,s.lineJoin=ao[i],s.miterLimit=a,s.setLineDash(h),s.lineDashOffset=l,s.shadowOffsetX=u,s.shadowOffsetY=c,s.shadowBlur=p,s.shadowColor=g}class v{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new v(1/0,1/0)}static get MIN(){return new v(-1/0,-1/0)}get array(){return[this.x,this.y]}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const r=-t/180*Math.PI,n=this.x-e.x,o=-(this.y-e.y),i=Math.sin(r),a=Math.cos(r);return this.set(e.x+(n*a-o*i),e.y-(n*i+o*a)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,r={x:0,y:0}){const n=t<0?r.x-this.x+r.x:this.x,o=e<0?r.y-this.y+r.y:this.y;return this.x=n*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,r={x:0,y:0}){const n=this.x-r.x,o=this.y-r.y;return this.x=r.x+(n+Math.tan(t)*o),this.y=r.y+(o+Math.tan(e)*n),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new v(this.x,this.y)}}class E{constructor(t=0,e=0,r=0,n=0){this.left=t,this.top=e,this.width=r,this.height=n}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new v((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new E;if(t.length===1)return t[0].clone();const e=t[0],r=t.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(e==null?void 0:e.left)??0,top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0});return new E(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new E(this.left,this.top,this.width,this.height)}}var lo=Object.defineProperty,ho=(s,t,e)=>t in s?lo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,co=(s,t,e)=>(ho(s,t+"",e),e);class vt{constructor(t=1,e=0,r=0,n=0,o=1,i=0,a=0,h=0,l=1){co(this,"elements",[]),this.set(t,e,r,n,o,i,a,h,l)}set(t,e,r,n,o,i,a,h,l){const u=this.elements;return u[0]=t,u[1]=n,u[2]=a,u[3]=e,u[4]=o,u[5]=h,u[6]=r,u[7]=i,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,o=this.elements,i=r[0],a=r[3],h=r[6],l=r[1],u=r[4],c=r[7],p=r[2],g=r[5],d=r[8],m=n[0],f=n[3],b=n[6],P=n[1],M=n[4],T=n[7],w=n[2],x=n[5],A=n[8];return o[0]=i*m+a*P+h*w,o[3]=i*f+a*M+h*x,o[6]=i*b+a*T+h*A,o[1]=l*m+u*P+c*w,o[4]=l*f+u*M+c*x,o[7]=l*b+u*T+c*A,o[2]=p*m+g*P+d*w,o[5]=p*f+g*M+d*x,o[8]=p*b+g*T+d*A,this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],h=t[6],l=t[7],u=t[8],c=u*i-a*l,p=a*h-u*o,g=l*o-i*h,d=e*c+r*p+n*g;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/d;return t[0]=c*m,t[1]=(n*l-u*r)*m,t[2]=(a*r-n*i)*m,t[3]=p*m,t[4]=(u*e-n*h)*m,t[5]=(n*o-a*e)*m,t[6]=g*m,t[7]=(r*h-l*e)*m,t[8]=(i*e-r*o)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(xr.makeScale(t,e)),this}rotate(t){return this.premultiply(xr.makeRotation(-t)),this}translate(t,e){return this.premultiply(xr.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const xr=new vt;function Tn(s,t,e,r){const n=s*e+t*r,o=Math.sqrt(s*s+t*t)*Math.sqrt(e*e+r*r);let i=Math.acos(Math.max(-1,Math.min(1,n/o)));return s*r-t*e<0&&(i=-i),i}function uo(s,t,e,r,n,o,i,a){if(t===0||e===0){s.lineTo(a.x,a.y);return}r=r*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const h=(i.x-a.x)/2,l=(i.y-a.y)/2,u=Math.cos(r)*h+Math.sin(r)*l,c=-Math.sin(r)*h+Math.cos(r)*l;let p=t*t,g=e*e;const d=u*u,m=c*c,f=d/p+m/g;if(f>1){const L=Math.sqrt(f);t=L*t,e=L*e,p=t*t,g=e*e}const b=p*m+g*d,P=(p*g-b)/b;let M=Math.sqrt(Math.max(0,P));n===o&&(M=-M);const T=M*t*c/e,w=-M*e*u/t,x=Math.cos(r)*T-Math.sin(r)*w+(i.x+a.x)/2,A=Math.sin(r)*T+Math.cos(r)*w+(i.y+a.y)/2,S=Tn(1,0,(u-T)/t,(c-w)/e),C=Tn((u-T)/t,(c-w)/e,(-u-T)/t,(-c-w)/e)%(Math.PI*2);s.ellipse(x,A,t,e,r,S,S+C,o===1)}function ne(s,t){return s-(t-s)}function _n(s,t){const e=new v,r=new v;for(let n=0,o=s.length;n<o;n++){const i=s[n];if(i.type==="m"||i.type==="M")i.type==="m"?e.add(i):e.copy(i),t.moveTo(e.x,e.y),r.copy(e);else if(i.type==="h"||i.type==="H")i.type==="h"?e.x+=i.x:e.x=i.x,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="v"||i.type==="V")i.type==="v"?e.y+=i.y:e.y=i.y,t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="l"||i.type==="L")i.type==="l"?e.add(i):e.copy(i),t.lineTo(e.x,e.y),r.copy(e);else if(i.type==="c"||i.type==="C")i.type==="c"?(t.bezierCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(t.bezierCurveTo(ne(e.x,r.x),ne(e.y,r.y),e.x+i.x2,e.y+i.y2,e.x+i.x,e.y+i.y),r.x=e.x+i.x2,r.y=e.y+i.y2,e.add(i)):(t.bezierCurveTo(ne(e.x,r.x),ne(e.y,r.y),i.x2,i.y2,i.x,i.y),r.x=i.x2,r.y=i.y2,e.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(t.quadraticCurveTo(e.x+i.x1,e.y+i.y1,e.x+i.x,e.y+i.y),r.x=e.x+i.x1,r.y=e.y+i.y1,e.add(i)):(t.quadraticCurveTo(i.x1,i.y1,i.x,i.y),r.x=i.x1,r.y=i.y1,e.copy(i));else if(i.type==="t"||i.type==="T"){const a=ne(e.x,r.x),h=ne(e.y,r.y);r.x=a,r.y=h,i.type==="t"?(t.quadraticCurveTo(a,h,e.x+i.x,e.y+i.y),e.add(i)):(t.quadraticCurveTo(a,h,i.x,i.y),e.copy(i))}else if(i.type==="a"||i.type==="A"){const a=e.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;e.add(i)}else{if(e.equals(i))continue;e.copy(i)}r.copy(e),uo(t,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,a,e)}else i.type==="z"||i.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",i)}}const K={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Ut(s,t,e=0){let a=0,h=!0,l="",u="";const c=[];function p(f,b,P){const M=new SyntaxError(`Unexpected character "${f}" at index ${b}.`);throw M.partial=P,M}function g(){l!==""&&(u===""?c.push(Number(l)):c.push(Number(l)*10**Number(u))),l="",u=""}let d;const m=s.length;for(let f=0;f<m;f++){if(d=s[f],Array.isArray(t)&&t.includes(c.length%e)&&K.FLAGS.test(d)){a=1,l=d,g();continue}if(a===0){if(K.WHITESPACE.test(d))continue;if(K.DIGIT.test(d)||K.SIGN.test(d)){a=1,l=d;continue}if(K.POINT.test(d)){a=2,l=d;continue}K.COMMA.test(d)&&(h&&p(d,f,c),h=!0)}if(a===1){if(K.DIGIT.test(d)){l+=d;continue}if(K.POINT.test(d)){l+=d,a=2;continue}if(K.EXP.test(d)){a=3;continue}K.SIGN.test(d)&&l.length===1&&K.SIGN.test(l[0])&&p(d,f,c)}if(a===2){if(K.DIGIT.test(d)){l+=d;continue}if(K.EXP.test(d)){a=3;continue}K.POINT.test(d)&&l[l.length-1]==="."&&p(d,f,c)}if(a===3){if(K.DIGIT.test(d)){u+=d;continue}if(K.SIGN.test(d)){if(u===""){u+=d;continue}u.length===1&&K.SIGN.test(u)&&p(d,f,c)}}K.WHITESPACE.test(d)?(g(),a=0,h=!1):K.COMMA.test(d)?(g(),a=0,h=!0):K.SIGN.test(d)?(g(),a=1,l=d):K.POINT.test(d)?(g(),a=2,l=d):p(d,f,c)}return g(),c}function fo(s){const t={x:0,y:0},e={x:0,y:0};let r="";for(let n=0,o=s.length;n<o;n++){const i=s[n];switch(i.type){case"m":case"M":if(i.x===e.x&&i.y===e.y)continue;r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y,t.x=i.x,t.y=i.y;break;case"h":case"H":r+=`${i.type} ${i.x}`,e.x=i.x;break;case"v":case"V":r+=`${i.type} ${i.y}`,e.y=i.y;break;case"l":case"L":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"c":case"C":r+=`${i.type} ${i.x1} ${i.y1} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"s":case"S":r+=`${i.type} ${i.x2} ${i.y2} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"q":case"Q":r+=`${i.type} ${i.x1} ${i.y1} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"t":case"T":r+=`${i.type} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"a":case"A":r+=`${i.type} ${i.rx} ${i.ry} ${i.angle} ${i.largeArcFlag} ${i.sweepFlag} ${i.x} ${i.y}`,e.x=i.x,e.y=i.y;break;case"z":case"Z":r+=i.type,e.x=t.x,e.y=t.y;break}}return r}const po=/[a-df-z][^a-df-z]*/gi;function In(s){const t=[],e=s.match(po);if(!e)return t;for(let r=0,n=e.length;r<n;r++){const o=e[r],i=o.charAt(0),a=o.slice(1).trim();let h;switch(i){case"m":case"M":h=Ut(a);for(let l=0,u=h.length;l<u;l+=2)l===0?t.push({type:i,x:h[l],y:h[l+1]}):t.push({type:i==="m"?"l":"L",x:h[l],y:h[l+1]});break;case"h":case"H":h=Ut(a);for(let l=0,u=h.length;l<u;l++)t.push({type:i,x:h[l]});break;case"v":case"V":h=Ut(a);for(let l=0,u=h.length;l<u;l++)t.push({type:i,y:h[l]});break;case"l":case"L":h=Ut(a);for(let l=0,u=h.length;l<u;l+=2)t.push({type:i,x:h[l],y:h[l+1]});break;case"c":case"C":h=Ut(a);for(let l=0,u=h.length;l<u;l+=6)t.push({type:i,x1:h[l],y1:h[l+1],x2:h[l+2],y2:h[l+3],x:h[l+4],y:h[l+5]});break;case"s":case"S":h=Ut(a);for(let l=0,u=h.length;l<u;l+=4)t.push({type:i,x2:h[l],y2:h[l+1],x:h[l+2],y:h[l+3]});break;case"q":case"Q":h=Ut(a);for(let l=0,u=h.length;l<u;l+=4)t.push({type:i,x1:h[l],y1:h[l+1],x:h[l+2],y:h[l+3]});break;case"t":case"T":h=Ut(a);for(let l=0,u=h.length;l<u;l+=2)t.push({type:i,x:h[l],y:h[l+1]});break;case"a":case"A":h=Ut(a,[3,4],7);for(let l=0,u=h.length;l<u;l+=7)t.push({type:i,rx:h[l],ry:h[l+1],angle:h[l+2],largeArcFlag:h[l+3],sweepFlag:h[l+4],x:h[l+5],y:h[l+6]});break;case"z":case"Z":t.push({type:i});break;default:console.warn(o)}}return t}var go=Object.defineProperty,yo=(s,t,e)=>t in s?go(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,vr=(s,t,e)=>(yo(s,typeof t!="symbol"?t+"":t,e),e);class Yt{constructor(){vr(this,"arcLengthDivisions",200),vr(this,"_cacheArcLengths"),vr(this,"_needsUpdate",!1)}isClockwise(){const t=this.getPoint(1),e=this.getPoint(.5),r=this.getPoint(1);return(e.x-t.x)*(r.y-e.y)-(e.y-t.y)*(r.x-e.x)<0}getPointAt(t,e=new v){return this.getPoint(this.getUToTMapping(t),e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}forEachControlPoints(t){return this.getControlPoints().forEach(t),this}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===t+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const e=[];let r,n=this.getPoint(0),o=0;e.push(0);for(let i=1;i<=t;i++)r=this.getPoint(i/t),o+=r.distanceTo(n),e.push(o),n=r;return this._cacheArcLengths=e,e}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(t,e){const r=this.getLengths();let n=0;const o=r.length;let i;e?i=e:i=t*r[o-1];let a=0,h=o-1,l;for(;a<=h;)if(n=Math.floor(a+(h-a)/2),l=r[n]-i,l<0)a=n+1;else if(l>0)h=n-1;else{h=n;break}if(n=h,r[n]===i)return n/(o-1);const u=r[n],p=r[n+1]-u,g=(i-u)/p;return(n+g)/(o-1)}getTangent(t,e=new v){const n=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(n)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new v){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let r=0,n=1,o=(r+n)/2;for(;n-r>e;){o=(r+n)/2;const i=this.getPoint(o);if(i.distanceTo(t)<e)return o;i.x<t.x?r=o:n=o}return o}matrix(t){return this.forEachControlPoints(e=>e.applyMatrix3(t)),this}getMinMax(t=v.MAX,e=v.MIN){return this.getPoints().forEach(r=>{t.min(r),e.max(r)}),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new E(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.getPoints().map((t,e)=>e===0?{type:"M",x:t.x,y:t.y}:{type:"L",x:t.x,y:t.y})}toData(){return fo(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}function Dn(s,t,e,r,n){const o=(r-t)*.5,i=(n-e)*.5,a=s*s,h=s*a;return(2*e-2*r+o+i)*h+(-3*e+3*r-2*o-i)*a+o*s+e}function mo(s,t){const e=1-s;return e*e*t}function wo(s,t){return 2*(1-s)*s*t}function xo(s,t){return s*s*t}function An(s,t,e,r){return mo(s,t)+wo(s,e)+xo(s,r)}function vo(s,t){const e=1-s;return e*e*e*t}function bo(s,t){const e=1-s;return 3*e*e*s*t}function Mo(s,t){return 3*(1-s)*s*s*t}function So(s,t){return s*s*s*t}function On(s,t,e,r,n){return vo(s,t)+bo(s,e)+Mo(s,r)+So(s,n)}class Co extends Yt{constructor(t=new v,e=new v,r=new v,n=new v){super(),this.start=t,this.startControl=e,this.endControl=r,this.end=n}getPoint(t,e=new v){const{start:r,startControl:n,endControl:o,end:i}=this;return e.set(On(t,r.x,n.x,o.x,i.x),On(t,r.y,n.y,o.y,i.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(t,e,r){const n=e*e-4*t*r;if(n<0)return[];const o=Math.sqrt(n),i=(-e+o)/(2*t),a=(-e-o)/(2*t);return[i,a].filter(h=>h>=0&&h<=1)}getMinMax(t=v.MAX,e=v.MIN){const r=this.start,n=this.startControl,o=this.endControl,i=this.end,a=this._solveQuadratic(3*(n.x-r.x),6*(o.x-n.x),3*(i.x-o.x)),h=this._solveQuadratic(3*(n.y-r.y),6*(o.y-n.y),3*(i.y-o.y)),l=[0,1,...a,...h];return((c,p)=>{for(const g of c)for(let d=0;d<=p;d++){const m=d/p-.5,f=Math.min(1,Math.max(0,g+m)),b=this.getPoint(f);t.x=Math.min(t.x,b.x),t.y=Math.min(t.y,b.y),e.x=Math.max(e.x,b.x),e.y=Math.max(e.y,b.y)}})(l,10),{min:t,max:e}}toCommands(){const{start:t,startControl:e,endControl:r,end:n}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:r.x,y2:r.y,x:n.x,y:n.y}]}drawTo(t){const{start:e,startControl:r,endControl:n,end:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(r.x,r.y,n.x,n.y,o.x,o.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.startControl.copy(t.startControl),this.endControl.copy(t.endControl),this.end.copy(t.end),this}}const Po=new vt,Nn=new vt,zn=new vt,Ve=new v;class To extends Yt{constructor(t=new v,e=1,r=1,n=0,o=0,i=Math.PI*2,a=!1){super(),this.center=t,this.radiusX=e,this.radiusY=r,this.rotation=n,this.startAngle=o,this.endAngle=i,this.clockwise=a}isClockwise(){return this.clockwise}getPoint(t,e=new v){const r=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=r;for(;n>r;)n-=r;n<Number.EPSILON&&(o?n=0:n=r),this.clockwise&&!o&&(n===r?n=-r:n=n-r);const i=this.startAngle+t*n;let a=this.center.x+this.radiusX*Math.cos(i),h=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const l=Math.cos(this.rotation),u=Math.sin(this.rotation),c=a-this.center.x,p=h-this.center.y;a=c*l-p*u+this.center.x,h=c*u+p*l+this.center.y}return e.set(a,h)}toCommands(){const{center:t,radiusX:e,radiusY:r,startAngle:n,endAngle:o,clockwise:i,rotation:a}=this,{x:h,y:l}=t,u=h+e*Math.cos(n)*Math.cos(a)-r*Math.sin(n)*Math.sin(a),c=l+e*Math.cos(n)*Math.sin(a)+r*Math.sin(n)*Math.cos(a),p=Math.abs(n-o),g=p>Math.PI?1:0,d=i?1:0,m=a*180/Math.PI;if(p>=2*Math.PI){const f=n+Math.PI,b=h+e*Math.cos(f)*Math.cos(a)-r*Math.sin(f)*Math.sin(a),P=l+e*Math.cos(f)*Math.sin(a)+r*Math.sin(f)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:d,x:b,y:P},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:0,sweepFlag:d,x:u,y:c}]}else{const f=h+e*Math.cos(o)*Math.cos(a)-r*Math.sin(o)*Math.sin(a),b=l+e*Math.cos(o)*Math.sin(a)+r*Math.sin(o)*Math.cos(a);return[{type:"M",x:u,y:c},{type:"A",rx:e,ry:r,angle:m,largeArcFlag:g,sweepFlag:d,x:f,y:b}]}}drawTo(t){const{center:e,radiusX:r,radiusY:n,rotation:o,startAngle:i,endAngle:a,clockwise:h}=this;return t.ellipse(e.x,e.y,r,n,o,i,a,!h),this}matrix(t){return Ve.set(this.center.x,this.center.y),Ve.applyMatrix3(t),this.center.x=Ve.x,this.center.y=Ve.y,Do(t)?_o(this,t):Io(this,t),this}getControlPoints(){return[this.center]}getMinMax(t=v.MAX,e=v.MIN){const{center:r,radiusX:n,radiusY:o,rotation:i}=this,{x:a,y:h}=r,l=Math.cos(i),u=Math.sin(i),c=Math.sqrt(n*n*l*l+o*o*u*u),p=Math.sqrt(n*n*u*u+o*o*l*l);return t.x=Math.min(t.x,a-c),t.y=Math.min(t.y,h-p),e.x=Math.max(e.x,a+c),e.y=Math.max(e.y,h+p),{min:t,max:e}}copy(t){return super.copy(t),this.center.x=t.center.x,this.center.y=t.center.y,this.radiusX=t.radiusX,this.radiusY=t.radiusY,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}}function _o(s,t){const e=s.radiusX,r=s.radiusY,n=Math.cos(s.rotation),o=Math.sin(s.rotation),i=new v(e*n,e*o),a=new v(-r*o,r*n),h=i.applyMatrix3(t),l=a.applyMatrix3(t),u=Po.set(h.x,l.x,0,h.y,l.y,0,0,0,1),c=Nn.copy(u).invert(),d=zn.copy(c).transpose().multiply(c).elements,m=Ao(d[0],d[1],d[4]),f=Math.sqrt(m.rt1),b=Math.sqrt(m.rt2);if(s.radiusX=1/f,s.radiusY=1/b,s.rotation=Math.atan2(m.sn,m.cs),!((s.endAngle-s.startAngle)%(2*Math.PI)<Number.EPSILON)){const M=Nn.set(f,0,0,0,b,0,0,0,1),T=zn.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),w=M.multiply(T).multiply(u),x=A=>{const{x:S,y:C}=new v(Math.cos(A),Math.sin(A)).applyMatrix3(w);return Math.atan2(C,S)};s.startAngle=x(s.startAngle),s.endAngle=x(s.endAngle),Un(t)&&(s.clockwise=!s.clockwise)}}function Io(s,t){const e=Ln(t),r=En(t);s.radiusX*=e,s.radiusY*=r;const n=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);s.rotation+=n,Un(t)&&(s.startAngle*=-1,s.endAngle*=-1,s.clockwise=!s.clockwise)}function Un(s){const t=s.elements;return t[0]*t[4]-t[1]*t[3]<0}function Do(s){const t=s.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const r=Ln(s),n=En(s);return Math.abs(e/(r*n))>Number.EPSILON}function Ln(s){const t=s.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function En(s){const t=s.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function Ao(s,t,e){let r,n,o,i,a;const h=s+e,l=s-e,u=Math.sqrt(l*l+4*t*t);return h>0?(r=.5*(h+u),a=1/r,n=s*a*e-t*a*t):h<0?n=.5*(h-u):(r=.5*u,n=-.5*u),l>0?o=l+u:o=l-u,Math.abs(o)>2*Math.abs(t)?(a=-2*t/o,i=1/Math.sqrt(1+a*a),o=a*i):Math.abs(t)===0?(o=1,i=0):(a=-.5*o/t,o=1/Math.sqrt(1+a*a),i=a*o),l>0&&(a=o,o=-i,i=a),{rt1:r,rt2:n,cs:o,sn:i}}class br extends Yt{constructor(t=new v,e=new v){super(),this.start=t,this.end=e}getPoint(t,e=new v){return t===1?e.copy(this.end):e.copy(this.end).sub(this.start).scale(t).add(this.start),e}getPointAt(t,e=new v){return this.getPoint(t,e)}getTangent(t,e=new v){return e.subVectors(this.end,this.start).normalize()}getTangentAt(t,e=new v){return this.getTangent(t,e)}getControlPoints(){return[this.start,this.end]}getMinMax(t=v.MAX,e=v.MIN){const{start:r,end:n}=this;return t.x=Math.min(t.x,r.x,n.x),t.y=Math.min(t.y,r.y,n.y),e.x=Math.max(e.x,r.x,n.x),e.y=Math.max(e.y,r.y,n.y),{min:t,max:e}}toCommands(){const{start:t,end:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}drawTo(t){const{start:e,end:r}=this;return t.lineTo(e.x,e.y),t.lineTo(r.x,r.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.end.copy(t.end),this}}class Oo extends Yt{constructor(t=new v,e=new v,r=new v){super(),this.start=t,this.control=e,this.end=r}getPoint(t,e=new v){const{start:r,control:n,end:o}=this;return e.set(An(t,r.x,n.x,o.x),An(t,r.y,n.y,o.y)),e}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(t=v.MAX,e=v.MIN){const{start:r,control:n,end:o}=this,i=.5*(r.x+n.x),a=.5*(r.y+n.y),h=.5*(r.x+o.x),l=.5*(r.y+o.y);return t.x=Math.min(t.x,r.x,o.x,i,h),t.y=Math.min(t.y,r.y,o.y,a,l),e.x=Math.max(e.x,r.x,o.x,i,h),e.y=Math.max(e.y,r.y,o.y,a,l),{min:t,max:e}}toCommands(){const{start:t,control:e,end:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:r.x,y:r.y}]}drawTo(t){const{start:e,control:r,end:n}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(r.x,r.y,n.x,n.y),this}copy(t){return super.copy(t),this.start.copy(t.start),this.control.copy(t.control),this.end.copy(t.end),this}}var No=Object.defineProperty,zo=(s,t,e)=>t in s?No(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,$n=(s,t,e)=>(zo(s,typeof t!="symbol"?t+"":t,e),e);class Uo extends Yt{constructor(t,e,r=1,n=0,o=1){super(),this.center=t,this.rx=e,this.aspectRatio=r,this.start=n,this.end=o,$n(this,"curves",[]),$n(this,"curveT",0),this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:e}=this.center,r=this.rx,n=this.rx/this.aspectRatio,o=[new v(t-r,e-n),new v(t+r,e-n),new v(t+r,e+n),new v(t-r,e+n)];for(let i=0;i<4;i++)this.curves.push(new br(o[i].clone(),o[(i+1)%4].clone()));return this}getCurve(t){let e=(t*(this.end-this.start)+this.start)%1;e<0&&(e+=1),e*=(1+this.aspectRatio)*2;let r;return e<this.aspectRatio?(r=0,this.curveT=e/this.aspectRatio):e<this.aspectRatio+1?(r=1,this.curveT=(e-this.aspectRatio)/1):e<2*this.aspectRatio+1?(r=2,this.curveT=(e-this.aspectRatio-1)/this.aspectRatio):(r=3,this.curveT=(e-2*this.aspectRatio-1)/1),this.curves[r]}getPoint(t,e){return this.getCurve(t).getPoint(this.curveT,e)}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){return this.getCurve(t).getTangent(this.curveT,e)}getNormal(t,e){return this.getCurve(t).getNormal(this.curveT,e)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=v.MAX,e=v.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(e=>e.drawTo(t)),this}}class Lo extends Yt{constructor(t=[]){super(),this.points=t}getPoint(t,e=new v){const{points:r}=this,n=(r.length-1)*t,o=Math.floor(n),i=n-o,a=r[o===0?o:o-1],h=r[o],l=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return e.set(Dn(i,a.x,h.x,l.x,u.x),Dn(i,a.y,h.y,l.y,u.y)),e}getControlPoints(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++)this.points.push(t.points[e].clone());return this}}var Eo=Object.defineProperty,$o=(s,t,e)=>t in s?Eo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Se=(s,t,e)=>($o(s,typeof t!="symbol"?t+"":t,e),e);class Ce extends Yt{constructor(t){super(),Se(this,"curves",[]),Se(this,"startPoint"),Se(this,"currentPoint",new v),Se(this,"autoClose",!1),Se(this,"_cacheLengths",[]),t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++){const{x:n,y:o}=t[e];this.lineTo(n,o)}return this}addCommands(t){return _n(t,this),this}addData(t){return this.addCommands(In(t)),this}getPoint(t,e=new v){const r=t*this.getLength(),n=this.getCurveLengths();let o=0;for(;o<n.length;){if(n[o]>=r){const i=n[o]-r,a=this.curves[o],h=a.getLength();return a.getPointAt(h===0?0:1-i/h,e)}o++}return e}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let e=0;for(let r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this._cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[],r=this.curves;let n;for(let o=0,i=r.length;o<i;o++){const h=r[o].getPoints(t);for(let l=0;l<h.length;l++){const u=h[l];n!=null&&n.equals(u)||(e.push(u),n=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;t.equals(e)||(this.curves.push(new br(e.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint.set(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){return this.currentPoint.equals({x:t,y:e})||this.curves.push(new br(this.currentPoint.clone(),new v(t,e))),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,r,n,o,i){return this.currentPoint.equals({x:o,y:i})||this.curves.push(new Co(this.currentPoint.clone(),new v(t,e),new v(r,n),new v(o,i))),this._setCurrentPoint({x:o,y:i}),this}quadraticCurveTo(t,e,r,n){return this.currentPoint.equals({x:r,y:n})||this.curves.push(new Oo(this.currentPoint.clone(),new v(t,e),new v(r,n))),this._setCurrentPoint({x:r,y:n}),this}arc(t,e,r,n,o,i){return this.ellipse(t,e,r,r,0,n,o,i),this}relativeArc(t,e,r,n,o,i){const a=this.currentPoint;return this.arc(t+a.x,e+a.y,r,n,o,i),this}arcTo(t,e,r,n,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,r,n,o,i,a,h=!0){const l=new To(new v(t,e),r,n,o,i,a,!h);if(this.curves.length>0){const u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}return this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,e,r,n,o,i,a,h){const l=this.currentPoint;return this.ellipse(t+l.x,e+l.y,r,n,o,i,a,h),this}rect(t,e,r,n){return this.curves.push(new Uo(new v(t+r/2,e+n/2),r/2,r/n)),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){return this.curves.push(new Lo([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=v.MAX,e=v.MIN){return this.curves.forEach(r=>r.getMinMax(t,e)),{min:t,max:e}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new E(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var r;const e=(r=this.curves[0])==null?void 0:r.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(n=>n.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++)this.curves.push(t.curves[e].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function ko(s){return s.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Bo(s,t,e,r){const n=t.clone().sub(s),o=r.clone().sub(e),i=e.clone().sub(s),a=n.cross(o);if(a===0)return new v((s.x+e.x)/2,(s.y+e.y)/2);const h=i.cross(o)/a;return Math.abs(h)>1?new v((s.x+e.x)/2,(s.y+e.y)/2):new v(s.x+h*n.x,s.y+h*n.y)}var jo=Object.defineProperty,Fo=(s,t,e)=>t in s?jo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Mr=(s,t,e)=>(Fo(s,typeof t!="symbol"?t+"":t,e),e);class Pt{constructor(t){Mr(this,"currentPath",new Ce),Mr(this,"paths",[this.currentPath]),Mr(this,"style",{}),t&&(t instanceof Pt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){return t instanceof Pt?this.paths.push(...t.paths.map(e=>e.clone())):this.paths.push(t),this}closePath(){const t=this.startPoint;return t&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new Ce().moveTo(t.x,t.y),this.paths.push(this.currentPath))),this}moveTo(t,e){const{currentPoint:r,curves:n}=this.currentPath;return r.equals({x:t,y:e})||(n.length?(this.currentPath=new Ce().moveTo(t,e),this.paths.push(this.currentPath)):this.currentPath.moveTo(t,e)),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}bezierCurveTo(t,e,r,n,o,i){return this.currentPath.bezierCurveTo(t,e,r,n,o,i),this}quadraticCurveTo(t,e,r,n){return this.currentPath.quadraticCurveTo(t,e,r,n),this}arc(t,e,r,n,o,i){return this.currentPath.arc(t,e,r,n,o,i),this}arcTo(t,e,r,n,o){return this.currentPath.arcTo(t,e,r,n,o),this}ellipse(t,e,r,n,o,i,a,h){return this.currentPath.ellipse(t,e,r,n,o,i,a,h),this}rect(t,e,r,n){return this.currentPath.rect(t,e,r,n),this}addCommands(t){return _n(t,this),this}addData(t){return this.addCommands(In(t)),this}splineThru(t){return this.currentPath.splineThru(t),this}getControlPoints(){return this.paths.flatMap(t=>t.getControlPoints())}getCurves(){return this.paths.flatMap(t=>t.curves)}scale(t,e=t,r={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.scale(t,e,r)}),this}skew(t,e=0,r={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.skew(t,e,r)}),this}rotate(t,e={x:0,y:0}){return this.getControlPoints().forEach(r=>{r.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getCurves(),r=[],n=[],o=[];e.forEach((a,h)=>{const l=a.getControlPoints(),u=a.isClockwise();o[h]=l,n[h]=u;const c=l[0],p=l[l.length-1]??c;r.push({start:u?p:c,end:u?c:p,index:h})});const i=[];return r.forEach((a,h)=>{i[h]=[],r.forEach((l,u)=>{u!==h&&l.start.equals(a.end)&&i[h].push(l.index)})}),e.forEach((a,h)=>{const l=n[h];o[h].forEach(c=>{const p=a.getTForPoint(c),g=a.getNormal(p).scale(l?t:-t);c.add(g)})}),i.forEach((a,h)=>{const l=o[h];a.forEach(u=>{const c=o[u],p=Bo(l[l.length-1],l[l.length-2]??l[l.length-1],c[0],c[1]??c[0]);p&&(l[l.length-1].copy(p),c[0].copy(p))})}),this}matrix(t){return this.getCurves().forEach(e=>e.matrix(t)),this}getMinMax(t=v.MAX,e=v.MIN,r=!0){const n=this.strokeWidth;return this.getCurves().forEach(o=>{if(o.getMinMax(t,e),r&&n>1){const i=n/2,a=o.isClockwise(),h=[];for(let l=0;l<=1;l+=1/o.arcLengthDivisions){const u=o.getPoint(l),c=o.getNormal(l),p=c.clone().scale(a?i:-i),g=c.clone().scale(a?-i:i);h.push(u.clone().add(p),u.clone().add(g),u.clone().add({x:i,y:0}),u.clone().add({x:-i,y:0}),u.clone().add({x:0,y:i}),u.clone().add({x:0,y:-i}),u.clone().add({x:i,y:i}),u.clone().add({x:-i,y:-i}))}t.min(...h),e.max(...h)}}),{min:t,max:e}}getBoundingBox(t=!0){const{min:e,max:r}=this.getMinMax(void 0,void 0,t);return new E(e.x,e.y,r.x-e.x,r.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:n="none"}=e;return t.beginPath(),t.save(),Pn(t,e),this.paths.forEach(o=>{o.drawTo(t)}),r!=="none"&&t.fill(),n!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:r="#000",stroke:n="none"}=e;return t.beginPath(),t.save(),Pn(t,e),this.getControlPoints().forEach(o=>{t.moveTo(o.x,o.y),t.arc(o.x,o.y,4,0,Math.PI*2)}),r!=="none"&&t.fill(),n!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.paths.flatMap(t=>t.toCommands())}toData(){return this.paths.map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const n in t)t[n]!==void 0&&(e[ko(n)]=t[n]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const n in e)e[n]!==void 0&&(r+=`${n}:${e[n]};`);return`<path d="${this.toData()}" style="${r}"></path>`}toSvgString(){const{x:t,y:e,width:r,height:n}=this.getBoundingBox(),o=this.toSvgPathString();return`<svg viewBox="${t} ${e} ${r} ${n}" width="${r}px" height="${n}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...r}=t,{left:n,top:o,width:i,height:a}=this.getBoundingBox(),h=document.createElement("canvas");h.width=i*e,h.height=a*e,h.style.width=`${i}px`,h.style.height=`${a}px`;const l=h.getContext("2d");return l&&(l.scale(e,e),l.translate(-n,-o),this.drawTo(l,r)),h}copy(t){return this.currentPath=t.currentPath.clone(),this.paths=t.paths.map(e=>e.clone()),this.style={...t.style},this}clone(){return new this.constructor().copy(this)}}const Sr="px",kn=90,Bn=["mm","cm","in","pt","pc","px"],Cr={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 $(s){let t="px";if(typeof s=="string"||s instanceof String)for(let r=0,n=Bn.length;r<n;r++){const o=Bn[r];if(s.endsWith(o)){t=o,s=s.substring(0,s.length-o.length);break}}let e;return t==="px"&&Sr!=="px"?e=Cr.in[Sr]/kn:(e=Cr[t][Sr],e<0&&(e=Cr[t].in*kn)),e*Number.parseFloat(s)}const Go=new vt,We=new vt,jn=new vt,Fn=new vt;function qo(s,t,e){if(!(s.hasAttribute("transform")||s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))))return null;const r=Ro(s);return e.length>0&&r.premultiply(e[e.length-1]),t.copy(r),e.push(r),r}function Ro(s){const t=new vt,e=Go;if(s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))&&t.translate($(s.getAttribute("x")),$(s.getAttribute("y"))),s.hasAttribute("transform")){const r=s.getAttribute("transform").split(")");for(let n=r.length-1;n>=0;n--){const o=r[n].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const h=o.slice(0,i),l=Ut(o.slice(i+1));switch(e.identity(),h){case"translate":if(l.length>=1){const u=l[0];let c=0;l.length>=2&&(c=l[1]),e.translate(u,c)}break;case"rotate":if(l.length>=1){let u=0,c=0,p=0;u=l[0]*Math.PI/180,l.length>=3&&(c=l[1],p=l[2]),We.makeTranslation(-c,-p),jn.makeRotation(u),Fn.multiplyMatrices(jn,We),We.makeTranslation(c,p),e.multiplyMatrices(We,Fn)}break;case"scale":l.length>=1&&e.scale(l[0],l[1]??l[0]);break;case"skewX":l.length===1&&e.set(1,Math.tan(l[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":l.length===1&&e.set(1,0,0,Math.tan(l[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":l.length===6&&e.set(l[0],l[2],l[4],l[1],l[3],l[5],0,0,1);break}}t.premultiply(e)}}return t}function Vo(s){return new Pt().addPath(new Ce().arc($(s.getAttribute("cx")||0),$(s.getAttribute("cy")||0),$(s.getAttribute("r")||0),0,Math.PI*2))}function Wo(s,t){if(!(!s.sheet||!s.sheet.cssRules||!s.sheet.cssRules.length))for(let e=0;e<s.sheet.cssRules.length;e++){const r=s.sheet.cssRules[e];if(r.type!==1)continue;const n=r.selectorText.split(/,/g).filter(Boolean).map(i=>i.trim()),o={};for(let i=r.style.length,a=0;a<i;a++){const h=r.style.item(a);o[h]=r.style.getPropertyValue(h)}for(let i=0;i<n.length;i++)t[n[i]]=Object.assign(t[n[i]]||{},{...o})}}function Qo(s){return new Pt().addPath(new Ce().ellipse($(s.getAttribute("cx")||0),$(s.getAttribute("cy")||0),$(s.getAttribute("rx")||0),$(s.getAttribute("ry")||0),0,0,Math.PI*2))}function Xo(s){return new Pt().moveTo($(s.getAttribute("x1")||0),$(s.getAttribute("y1")||0)).lineTo($(s.getAttribute("x2")||0),$(s.getAttribute("y2")||0))}function Yo(s){const t=new Pt,e=s.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const Ho=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Zo(s){var r;const t=new Pt;let e=0;return(r=s.getAttribute("points"))==null||r.replace(Ho,(n,o,i)=>{const a=$(o),h=$(i);return e===0?t.moveTo(a,h):t.lineTo(a,h),e++,n}),t.currentPath.autoClose=!0,t}const Ko=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Jo(s){var r;const t=new Pt;let e=0;return(r=s.getAttribute("points"))==null||r.replace(Ko,(n,o,i)=>{const a=$(o),h=$(i);return e===0?t.moveTo(a,h):t.lineTo(a,h),e++,n}),t.currentPath.autoClose=!1,t}function ta(s){const t=$(s.getAttribute("x")||0),e=$(s.getAttribute("y")||0),r=$(s.getAttribute("rx")||s.getAttribute("ry")||0),n=$(s.getAttribute("ry")||s.getAttribute("rx")||0),o=$(s.getAttribute("width")),i=$(s.getAttribute("height")),a=1-.551915024494,h=new Pt;return h.moveTo(t+r,e),h.lineTo(t+o-r,e),(r!==0||n!==0)&&h.bezierCurveTo(t+o-r*a,e,t+o,e+n*a,t+o,e+n),h.lineTo(t+o,e+i-n),(r!==0||n!==0)&&h.bezierCurveTo(t+o,e+i-n*a,t+o-r*a,e+i,t+o-r,e+i),h.lineTo(t+r,e+i),(r!==0||n!==0)&&h.bezierCurveTo(t+r*a,e+i,t,e+i-n*a,t,e+i-n),h.lineTo(t,e+n),(r!==0||n!==0)&&h.bezierCurveTo(t,e+n*a,t+r*a,e,t+r,e),h}function Lt(s,t,e){t=Object.assign({},t);let r={};if(s.hasAttribute("class")){const l=s.getAttribute("class").split(/\s/).filter(Boolean).map(u=>u.trim());for(let u=0;u<l.length;u++)r=Object.assign(r,e[`.${l[u]}`])}s.hasAttribute("id")&&(r=Object.assign(r,e[`#${s.getAttribute("id")}`]));for(let l=s.style.length,u=0;u<l;u++){const c=s.style.item(u),p=s.style.getPropertyValue(c);t[c]=p,r[c]=p}function n(l,u,c=o){s.hasAttribute(l)&&(t[u]=c(s.getAttribute(l))),r[l]&&(t[u]=c(r[l]))}function o(l){return l.startsWith("url")&&console.warn("url access in attributes is not implemented."),l}function i(l){return Math.max(0,Math.min(1,$(l)))}function a(l){return Math.max(0,$(l))}function h(l){return l.split(" ").filter(u=>u!=="").map(u=>$(u))}return n("fill","fill"),n("fill-opacity","fillOpacity",i),n("fill-rule","fillRule"),n("opacity","opacity",i),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",i),n("stroke-width","strokeWidth",a),n("stroke-linecap","strokeLinecap"),n("stroke-linejoin","strokeLinejoin"),n("stroke-miterlimit","strokeMiterlimit",a),n("stroke-dasharray","strokeDasharray",h),n("stroke-dashoffset","strokeDashoffset",$),n("visibility","visibility"),t}function Pr(s,t,e=[],r={}){var c;if(s.nodeType!==1)return e;let n=!1,o=null,i={...t};switch(s.nodeName){case"svg":i=Lt(s,i,r);break;case"style":Wo(s,r);break;case"g":i=Lt(s,i,r);break;case"path":i=Lt(s,i,r),s.hasAttribute("d")&&(o=Yo(s));break;case"rect":i=Lt(s,i,r),o=ta(s);break;case"polygon":i=Lt(s,i,r),o=Zo(s);break;case"polyline":i=Lt(s,i,r),o=Jo(s);break;case"circle":i=Lt(s,i,r),o=Vo(s);break;case"ellipse":i=Lt(s,i,r),o=Qo(s);break;case"line":i=Lt(s,i,r),o=Xo(s);break;case"defs":n=!0;break;case"use":{i=Lt(s,i,r);const g=(s.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),d=(c=s.viewportElement)==null?void 0:c.getElementById(g);d?Pr(d,i,e,r):console.warn(`'use node' references non-existent node id: ${g}`);break}default:console.warn(s);break}if(i.display==="none")return e;Object.assign(t,i);const a=new vt,h=[],l=qo(s,a,h);o&&(o.matrix(a),e.push(o),o.style=t);const u=s.childNodes;for(let p=0,g=u.length;p<g;p++){const d=u[p];n&&d.nodeName!=="style"&&d.nodeName!=="defs"||Pr(d,t,e,r)}return l&&(h.pop(),h.length>0?a.copy(h[h.length-1]):a.identity()),e}const Gn="data:image/svg+xml;",qn=`${Gn}base64,`,Rn=`${Gn}charset=utf8,`;function ea(s){if(typeof s=="string"){let t;return s.startsWith(qn)?(s=s.substring(qn.length,s.length),t=atob(s)):s.startsWith(Rn)?(s=s.substring(Rn.length,s.length),t=decodeURIComponent(s)):t=s,new DOMParser().parseFromString(t,"image/svg+xml").documentElement}else return s}function Vn(s){return Pr(ea(s),{})}function Qe(s,t=!0){if(!s.length)return;const e=v.MAX,r=v.MIN;return s.forEach(n=>n.getMinMax(e,r,t)),new E(e.x,e.y,r.x-e.x,r.y-e.y)}const ra=new Set(["©","®","÷"]),na=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),sa={1:"italic",32:"bold"},ia={1:"italic",2:"bold"},Wn={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Qn{constructor(t,e,r){U(this,"lineBox",new E);U(this,"inlineBox",new E);U(this,"glyphBox");U(this,"underlinePosition",0);U(this,"underlineThickness",0);U(this,"yStrikeoutPosition",0);U(this,"yStrikeoutSize",0);U(this,"baseline",0);U(this,"centerDiviation",0);U(this,"path",new Pt);this.content=t,this.index=e,this.parent=r}get center(){var t;return(t=this.glyphBox)==null?void 0:t.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(t){const e=this.computedStyle.fontFamily,r=t??oo,n=e?r.get(e):r.fallbackFont;return n==null?void 0:n.getSfnt()}updateGlyph(t=this._getFontSfnt()){if(!t)return this;const{unitsPerEm:e,ascender:r,descender:n,os2:o,post:i}=t,{content:a,computedStyle:h}=this,{fontSize:l}=h,u=e/l,c=t.getAdvanceWidth(a,l),p=(r+Math.abs(n))/u,g=r/u,d=(r-o.yStrikeoutPosition)/u,m=o.yStrikeoutSize/u,f=(r-i.underlinePosition)/u,b=i.underlineThickness/u;return this.inlineBox.width=c,this.inlineBox.height=p,this.underlinePosition=f,this.underlineThickness=b,this.yStrikeoutPosition=d,this.yStrikeoutSize=m,this.baseline=g,this.centerDiviation=p/2-g,this}update(t){const e=this._getFontSfnt(t);if(!e)return this;this.updateGlyph(e);const{isVertical:r,content:n,computedStyle:o,baseline:i,inlineBox:a}=this,{os2:h,head:l,ascender:u,descender:c}=e,p=h.sTypoAscender,g=sa[h.fsSelection]??ia[l.macStyle],{left:d,top:m}=a,f=o.fontStyle==="italic"&&g!=="italic";let b=d,P=m+i,M;const T=new Pt;if(r&&(b+=(a.height-a.width)/2,Math.abs(a.width-a.height)>.1&&(P-=(u-p)/(u+Math.abs(c))*a.height),M=void 0),r&&!ra.has(n)&&(n.codePointAt(0)<=256||na.has(n))){T.addCommands(e.getPathCommands(n,b,m+i-(a.height-a.width)/2,o.fontSize)??[]);const x={y:m-(a.height-a.width)/2+a.height/2,x:b+a.width/2};f&&this._italic(T,r?{x:x.x,y:m-(a.height-a.width)/2+i}:void 0),T.rotate(90,x)}else M!==void 0?(T.addCommands(e.glyphs.get(M).getPathCommands(b,P,o.fontSize)),f&&this._italic(T,r?{x:b+a.width/2,y:m+p/(u+Math.abs(c))*a.height}:void 0)):(T.addCommands(e.getPathCommands(n,b,P,o.fontSize)??[]),f&&this._italic(T,r?{x:b+a.height/2,y:P}:void 0));T.addCommands(this._decoration());const w=o.fontWeight??400;return w in Wn&&(w===700||w==="bold")&&g!=="bold"&&T.bold(Wn[w]*o.fontSize*.05),T.style={fill:o.color,stroke:o.textStrokeWidth?o.textStrokeColor:"none",strokeWidth:o.textStrokeWidth?o.textStrokeWidth*o.fontSize*.03:0},this.path=T,this.glyphBox=this.getGlyphBoundingBox(),this}_decoration(){const{isVertical:t,underlinePosition:e,yStrikeoutPosition:r}=this,{textDecoration:n,fontSize:o}=this.computedStyle,{left:i,top:a,width:h,height:l}=this.inlineBox,u=.1*o;let c;switch(n){case"underline":t?c=i:c=a+e;break;case"line-through":t?c=i+h/2:c=a+r;break;case"none":default:return[]}return t?[{type:"M",x:c,y:a},{type:"L",x:c,y:a+l},{type:"L",x:c+u,y:a+l},{type:"L",x:c+u,y:a},{type:"Z"}]:[{type:"M",x:i,y:c},{type:"L",x:i+h,y:c},{type:"L",x:i+h,y:c+u},{type:"L",x:i,y:c+u},{type:"Z"}]}_italic(t,e){t.skew(-.24,0,e||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(t,e,r){var n;if((n=this.path.paths[0])!=null&&n.curves.length)return this.path.getMinMax(t,e,r)}getGlyphBoundingBox(t){const e=this.getGlyphMinMax(void 0,void 0,t);if(!e)return;const{min:r,max:n}=e;return new E(r.x,r.y,n.x-r.x,n.y-r.y)}drawTo(t,e={}){Te({ctx:t,path:this.path,fontSize:this.computedStyle.fontSize,color:this.computedStyle.color,...e})}}function se(s){return!s||s==="none"}function Xe(s){if(!s)return s;const t={};for(const e in s)s[e]!==""&&s[e]!==void 0&&(t[e]=s[e]);return t}class Xn{constructor(t,e={},r){U(this,"inlineBox",new E);this.content=t,this.style=e,this.parent=r,this.updateComputedStyle().initCharacters()}get computedContent(){const t=this.computedStyle;return t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Xe(this.style)},this}initCharacters(){const t=[];let e=0;for(const r of this.computedContent)t.push(new Qn(r,e++,this));return this.characters=t,this}}class ie{constructor(t,e){U(this,"lineBox",new E);U(this,"fragments",[]);this.style=t,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Xe(this.parentStyle),...Xe(this.style)},this}addFragment(t,e){const r=new Xn(t,e,this);return this.fragments.push(r),r}}function oa(s){return s}class Yn{constructor(t){this._text=t}_styleToDomStyle(t){const e={...t};for(const r in t)["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur"].includes(r)?e[r]=`${t[r]}px`:e[r]=t[r];return e}createDom(){const{paragraphs:t,computedStyle:e}=this._text,r=document.createDocumentFragment(),n=document.createElement("section");Object.assign(n.style,{width:"max-content",height:"max-content",...this._styleToDomStyle(e),position:"absolute",visibility:"hidden"});const o=document.createElement("ul");return Object.assign(o.style,{listStyleType:"inherit",padding:"0",margin:"0"}),t.forEach(i=>{const a=document.createElement("li");Object.assign(a.style,this._styleToDomStyle(i.style)),i.fragments.forEach(h=>{const l=document.createElement("span");Object.assign(l.style,this._styleToDomStyle(h.style)),l.appendChild(document.createTextNode(h.content)),/\s/.test(h.content)&&(l.style.whiteSpace="pre"),a.appendChild(l)}),o.appendChild(a)}),n.appendChild(o),r.appendChild(n),document.body.appendChild(r),{dom:n,destory:()=>{var i;return(i=n.parentNode)==null?void 0:i.removeChild(n)}}}_measureDom(t){const e=[],r=[],n=[];return t.querySelectorAll("li").forEach((o,i)=>{const a=o.getBoundingClientRect();e.push({paragraphIndex:i,left:a.left,top:a.top,width:a.width,height:a.height}),o.querySelectorAll("span").forEach((h,l)=>{var p;const u=h.getBoundingClientRect();r.push({paragraphIndex:i,fragmentIndex:l,left:u.left,top:u.top,width:u.width,height:u.height});const c=h.firstChild;if(c instanceof window.Text){const g=document.createRange();g.selectNodeContents(c);const d=c.data?c.data.length:0;let m=0;for(;m<=d;){g.setStart(c,Math.max(m-1,0)),g.setEnd(c,m);const f=((p=g.getClientRects)==null?void 0:p.call(g))??[g.getBoundingClientRect()];let b=f[f.length-1];f.length>1&&b.width<2&&(b=f[f.length-2]);const P=g.toString();P!==""&&b&&b.width+b.height!==0&&n.push({content:P,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:l,characterIndex:m-1,top:b.top,left:b.left,height:b.height,width:b.width,textWidth:-1,textHeight:-1}),m++}}})}),{paragraphs:e,fragments:r,characters:n}}measureDom(t){const{paragraphs:e}=this._text,r=t.getBoundingClientRect(),n=this._measureDom(t);n.paragraphs.forEach(a=>{const h=e[a.paragraphIndex];h.lineBox.left=a.left-r.left,h.lineBox.top=a.top-r.top,h.lineBox.width=a.width,h.lineBox.height=a.height}),n.fragments.forEach(a=>{const h=e[a.paragraphIndex].fragments[a.fragmentIndex];h.inlineBox.left=a.left-r.left,h.inlineBox.top=a.top-r.top,h.inlineBox.width=a.width,h.inlineBox.height=a.height});const o=[];let i=0;return n.characters.forEach(a=>{const{paragraphIndex:h,fragmentIndex:l,characterIndex:u}=a;o.push({...a,newParagraphIndex:h,left:a.left-r.left,top:a.top-r.top});const c=e[h].fragments[l].characters[u],p=o[i];c.inlineBox.left=p.left,c.inlineBox.top=p.top,c.inlineBox.width=p.width,c.inlineBox.height=p.height;const g=c.fontHeight;c.lineBox.left=p.left,c.lineBox.top=p.top+(p.height-g)/2,c.lineBox.height=g,c.lineBox.width=p.width,i++}),{paragraphs:e,boundingBox:new E(0,0,r.width,r.height)}}measure(t){let e;t||({dom:t,destory:e}=this.createDom());const r=this.measureDom(t);return e==null||e(),r}}const aa="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3MiIgaGVpZ2h0PSI3MiIgdmlld0JveD0iMCAwIDcyIDcyIiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMyLjQwMjkgMjhIMzUuMTU5NFYzMy4xNzcxQzM1Ljk4MjEgMzIuMzExNSAzNi45NzEgMzEuODczNyAzOC4wOTQ4IDMxLjg3MzdDMzkuNjY3NiAzMS44NzM3IDQwLjkxNjYgMzIuNDI5NSA0MS44MzkgMzMuNTQzN0w0MS44NDAzIDMzLjU0NTNDNDIuNjcxNyAzNC41NzA1IDQzLjA5MTUgMzUuODU1OSA0My4wOTE1IDM3LjM4NzdDNDMuMDkxNSAzOC45NzYxIDQyLjY3MjkgNDAuMzAyOCA0MS44MTgzIDQxLjMzMDRMNDEuODE3MSA0MS4zMzE4QzQwLjg3MzEgNDIuNDQ2MSAzOS41ODMyIDQzIDM3Ljk3MjEgNDNDMzYuNzQ3NyA0MyAzNS43NDg4IDQyLjY1OTkgMzQuOTk1OCA0MS45NjkzVjQyLjcyNDdIMzIuNDAyOVYyOFpNMzcuNTQyOCAzNC4wOTI0QzM2Ljg1NDkgMzQuMDkyNCAzNi4zMDE0IDM0LjM1NjEgMzUuODQ4NyAzNC45MDA0TDM1Ljg0NTIgMzQuOTA0NkMzNS4zMzU4IDM1LjQ4NTMgMzUuMDc3NiAzNi4yOTc2IDM1LjA3NzYgMzcuMzQ4NFYzNy41MDU3QzM1LjA3NzYgMzguNDY0IDM1LjI3NzIgMzkuMjQ0MyAzNS42OTQzIDM5LjgyNzlDMzYuMTQ0MSA0MC40NTg3IDM2Ljc3MjYgNDAuNzgxMyAzNy42MjQ1IDQwLjc4MTNDMzguNTg3NCA0MC43ODEzIDM5LjI3MDcgNDAuNDUyNyAzOS43MTUyIDM5LjgxMjdDNDAuMDcyOCAzOS4yNjg0IDQwLjI3MzcgMzguNDY3MyA0MC4yNzM3IDM3LjM4NzdDNDAuMjczNyAzNi4zMTA1IDQwLjA1MzMgMzUuNTMxMyAzOS42NzgzIDM1LjAwNzdDMzkuMjM3MSAzNC40MDcxIDM4LjUzNDIgMzQuMDkyNCAzNy41NDI4IDM0LjA5MjRaIiBmaWxsPSIjMjIyNTI5Ii8+PHBhdGggZD0iTTQ5Ljg2MTQgMzEuODczN0M0OC4xNTM1IDMxLjg3MzcgNDYuODAxNiAzMi40MjM5IDQ1LjgzNDggMzMuNTM5MkM0NC45MzcgMzQuNTQ3MiA0NC40OTY2IDM1Ljg1NiA0NC40OTY2IDM3LjQyN0M0NC40OTY2IDM5LjAzNjggNDQuOTM2NyA0MC4zNjU5IDQ1Ljg1NTkgNDEuMzk0M0M0Ni44MDMxIDQyLjQ3MDYgNDguMTM0OCA0MyA0OS44MjA1IDQzQzUxLjIyNiA0MyA1Mi4zODI2IDQyLjY1NjMgNTMuMjQ3OSA0MS45Njk3QzU0LjEzNTkgNDEuMjYxNCA1NC43MDYxIDQwLjE4ODcgNTQuOTU3MyAzOC43NzkxTDU1IDM4LjUzOTdINTIuMjQ4NEw1Mi4yMjU5IDM4LjcyMDFDNTIuMTM3OSAzOS40MjUxIDUxLjg5MjUgMzkuOTI3OCA1MS41MTA5IDQwLjI1NThDNTEuMTI5NSA0MC41ODM1IDUwLjU4MzEgNDAuNzYxNiA0OS44NDA5IDQwLjc2MTZDNDkuMDAwMSA0MC43NjE2IDQ4LjM5NDkgNDAuNDcxNSA0Ny45OTA3IDM5LjkyMzdMNDcuOTg3NCAzOS45MTk0QzQ3LjUzNTYgMzkuMzQwMSA0Ny4zMTQ0IDM4LjUwNjIgNDcuMzE0NCAzNy40MDc0QzQ3LjMxNDQgMzYuMzMyMiA0Ny41NTQ0IDM1LjUxNzcgNDguMDA1OCAzNC45NTY4TDQ4LjAwNzggMzQuOTU0M0M0OC40NTM3IDM0LjM4MjUgNDkuMDYxOCAzNC4xMTIxIDQ5Ljg2MTQgMzQuMTEyMUM1MC41MjMgMzQuMTEyMSA1MS4wNDUxIDM0LjI2MTUgNTEuNDI3MiAzNC41NDA3QzUxLjc4ODQgMzQuODE5NCA1Mi4wNTMgMzUuMjQ0NyA1Mi4xODgxIDM1Ljg1NzFMNTIuMjIzOSAzNi4wMTk0SDU0Ljk1NDhMNTQuOTE3IDM1Ljc4MzVDNTQuNzA2MyAzNC40NjYgNTQuMTUzNiAzMy40NzAxIDUzLjI2MzQgMzIuODAxOUw1My4yNjAyIDMyLjc5OTVDNTIuMzk1MSAzMi4xNzU1IDUxLjI2MjEgMzEuODczNyA0OS44NjE0IDMxLjg3MzdaIiBmaWxsPSIjMjIyNTI5Ii8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yNS43NTYxIDI4LjI3NTNIMjIuNzQ0TDE3IDQyLjcyNDdIMjAuMDE0MUwyMS4zNDI5IDM5LjIwNDlIMjcuMTU3MkwyOC40ODYgNDIuNzI0N0gzMS41MDAxTDI1Ljc1NjEgMjguMjc1M1pNMjIuMjEyNSAzNi45MDc2TDI0LjI1OTYgMzEuNDUzOUwyNi4yODg1IDM2LjkwNzZIMjIuMjEyNVoiIGZpbGw9IiMyMjI1MjkiLz48L3N2Zz4=";function la(s,t,e){if(s==="cover")return 0;if(typeof s=="string")if(s.endsWith("%")){const r=Number(s.substring(0,s.length-1))/100;return Math.ceil(r*e/t)}else return s.endsWith("rem")?Number(s.substring(0,s.length-3)):Math.ceil(Number(s)/t);else return Math.ceil(s/t)}function ha(s,t,e){return typeof s=="string"?s.endsWith("%")?Number(s.substring(0,s.length-1))/100:s.endsWith("rem")?Number(s.substring(0,s.length-3))*t/e:Number(s)/e:s/e}function ca(s,t,e,r){let n;r?n={x:e.width/t.height,y:e.height/t.width}:n={x:e.width/t.width,y:e.height/t.height};const o=e.center.add(s.center.sub(t.center).scale(n.x,n.y)).sub({x:s.width/2*n.x,y:s.height/2*n.y}),i=new vt;return i.translate(-s.left,-s.top),r&&(i.translate(-s.width/2,-s.height/2),i.rotate(Math.PI/2),i.translate(s.width/2,s.height/2)),i.scale(n.x,n.y),i.translate(o.x,o.y),i}function Hn(){const s=[],t=[],e=new Map;function r(n){let o=e.get(n);return o||(o=Vn(n),e.set(n,o)),o}return{name:"highlight",paths:s,update:n=>{s.length=0;const{characters:o}=n;let i;const a=[];let h;o.forEach(l=>{const{isVertical:u,computedStyle:c}=l;!se(c.highlightImage)&&l.glyphBox&&(c.highlightSize!=="1rem"&&(h==null?void 0:h.highlightImage)===c.highlightImage&&(h==null?void 0:h.highlightSize)===c.highlightSize&&(h==null?void 0:h.highlightStrokeWidth)===c.highlightStrokeWidth&&(h==null?void 0:h.highlightOverflow)===c.highlightOverflow&&(i!=null&&i.length)&&(u?i[0].inlineBox.left===l.inlineBox.left:i[0].inlineBox.top===l.inlineBox.top)&&i[0].fontSize===l.fontSize?i.push(l):(i=[],i.push(l),a.push(i))),h=c}),a.filter(l=>l.length).map(l=>{const u=l[0];return{style:u.computedStyle,baseline:u.baseline,box:E.from(...l.map(c=>c.glyphBox))}}).forEach(l=>{const{style:u,box:c,baseline:p}=l,{fontSize:g,writingMode:d}=u,m=d.includes("vertical"),f=ha(u.highlightStrokeWidth,g,c.width),b=la(u.highlightSize,g,c.width),P=se(u.highlightOverflow)?b?"hidden":"visible":u.highlightOverflow,M=r(se(u.highlightReferImage)?aa:u.highlightReferImage),T=r(u.highlightImage),w=Qe(T,!0),x=Qe(M,!1),A=b?g*b:m?c.height:c.width,S=p*.8,C=ca(w,x,new E(c.left,c.top,m?S:A,m?A:S),m),L=g/w.width*2,W=Math.ceil(c.width/A);for(let B=0;B<W;B++){const bt=C.clone().translate(B*A,0);T.forEach(O=>{const D=O.clone().matrix(bt);D.style.strokeWidth&&(D.style.strokeWidth*=L*f),D.style.strokeMiterlimit&&(D.style.strokeMiterlimit*=L),D.style.strokeDashoffset&&(D.style.strokeDashoffset*=L),D.style.strokeDasharray&&(D.style.strokeDasharray=D.style.strokeDasharray.map(j=>j*L)),s.push(D),t[s.length-1]=P==="hidden"?new E(c.left,c.top-c.height,c.width,c.height*3):void 0})}})},renderOrder:-1,render:(n,o)=>{s.forEach((i,a)=>{Te({ctx:n,path:i,clipRect:t[a],fontSize:o.computedStyle.fontSize})})}}}function Zn(s,t,e){return s==="cover"?1:typeof s=="string"?s.endsWith("%")?Number(s.substring(0,s.length-1))/100:s.endsWith("rem")?Number(s.substring(0,s.length-3))*t/e:Number(s)/e:s/e}function Kn(){const s=[];return{name:"listStyle",paths:s,update:t=>{s.length=0;const{paragraphs:e,isVertical:r,fontSize:n}=t,o=n*.45;e.forEach(i=>{const{computedStyle:a}=i;let h=a.listStyleSize,l;if(!se(a.listStyleImage))l=a.listStyleImage;else if(!se(a.listStyleType)){const d=n*.38/2;switch(h=h==="cover"?d*2:h,a.listStyleType){case"disc":l=`<svg width="${d*2}" height="${d*2}" xmlns="http://www.w3.org/2000/svg">
|
|
5
5
|
<circle cx="${d}" cy="${d}" r="${d}" fill="${a.color}" />
|
|
6
|
-
</svg>`;break}}if(!l)return;const u=Vn(l),c=Qe(u),p=i.lineBox,g=i.fragments[0].inlineBox;if(g){const d=new vt;if(r){const m=Zn(h,n,n),f=n/c.height*m;d.translate(-c.left,-c.top),d.rotate(Math.PI/2),d.scale(f,f),d.translate(n/2-c.height*f/2,0),d.translate(p.left+(p.width-n)/2,g.top-o)}else{const m=Zn(h,n,n),f=n/c.height*m;d.translate(-c.left,-c.top),d.translate(-c.width,0),d.scale(f,f),d.translate(0,n/2-c.height*f/2),d.translate(g.left-o,p.top+(p.height-n)/2)}s.push(...u.map(m=>m.clone().matrix(d)))}})}}}const Vt=new v,oe=new vt,Wt=new vt;function Jn(){return{name:"render",getBoundingBox:s=>{const{characters:t,fontSize:e,effects:r}=s,n=[];return t.forEach(o=>{r==null||r.forEach(i=>{if(!o.glyphBox)return;const a=o.glyphBox.clone(),h=Tr(s,i);Vt.set(a.left,a.top),Vt.applyMatrix3(h),a.left=Vt.x,a.top=Vt.y,Vt.set(a.right,a.bottom),Vt.applyMatrix3(h),a.width=Vt.x-a.left,a.height=Vt.y-a.top;const l=(i.shadowOffsetX??0)*e,u=(i.shadowOffsetY??0)*e,c=Math.max(.1,i.textStrokeWidth??0)*e;a.left+=l-c,a.top+=u-c,a.width+=c*2,a.height+=c*2,n.push(a)})}),n.length?E.from(...n):void 0},render:(s,t)=>{const{characters:e,paragraphs:r,glyphBox:n,effects:o,style:i}=t;function a(h,l){s.fillStyle=h,s.fillRect(l.left,l.top,l.width,l.height)}i!=null&&i.backgroundColor&&a(i.backgroundColor,new E(0,0,s.canvas.width,s.canvas.height)),r.forEach(h=>{var l;(l=h.style)!=null&&l.backgroundColor&&a(h.style.backgroundColor,h.lineBox)}),o?o.forEach(h=>{Ot(h,n,s),s.save();const[l,u,c,p,g,d]=Tr(t,h).transpose().elements;s.transform(l,p,u,g,c,d),e.forEach(m=>{var f;(f=m.parent.style)!=null&&f.backgroundColor&&a(m.parent.style.backgroundColor,m.inlineBox),m.drawTo(s,h)}),s.restore()}):r.forEach(h=>{h.fragments.forEach(l=>{var u;(u=l.style)!=null&&u.backgroundColor&&a(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(s)})})})}}}function Tr(s,t){const{fontSize:e,glyphBox:r}=s,n=(t.translateX??0)*e,o=(t.translateY??0)*e,i=Math.PI*2,a=(t.skewX??0)/360*i,h=(t.skewY??0)/360*i,{left:l,top:u,width:c,height:p}=r,g=l+c/2,d=u+p/2;return oe.identity(),Wt.makeTranslation(n,o),oe.multiply(Wt),Wt.makeTranslation(g,d),oe.multiply(Wt),Wt.set(1,Math.tan(a),0,Math.tan(h),1,0,0,0,1),oe.multiply(Wt),Wt.makeTranslation(-g,-d),oe.multiply(Wt),oe.clone()}const _r={writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",listStyleType:"none",listStyleImage:"none",listStyleSize:"cover",listStylePosition:"outside",highlightReferImage:"none",highlightImage:"none",highlightSize:"cover",highlightStrokeWidth:"100%",highlightOverflow:"none",shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,translateX:0,translateY:0,skewX:0,skewY:0};class Ir{constructor(t={}){U(this,"content");U(this,"style");U(this,"effects");U(this,"measureDom");U(this,"needsUpdate",!0);U(this,"computedStyle",{..._r});U(this,"paragraphs",[]);U(this,"lineBox",new E);U(this,"rawGlyphBox",new E);U(this,"glyphBox",new E);U(this,"pathBox",new E);U(this,"boundingBox",new E);U(this,"measurer",new Yn(this));U(this,"plugins",new Map);U(this,"fonts");const{content:e="",style:r={},measureDom:n,effects:o,fonts:i}=t;this.content=e,this.style=r,this.measureDom=n,this.effects=o,this.fonts=i,this.use(Jn()).use(Hn()).use(Kn())}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(e=>e.characters))}use(t){return this.plugins.set(t.name,t),this}updateParagraphs(){this.computedStyle={..._r,...this.style};let{content:t,computedStyle:e}=this;const r=[];if(typeof t=="string"){const n=new ie({},e);n.addFragment(t),r.push(n)}else{t=Array.isArray(t)?t:[t];for(const n of t)if(typeof n=="string"){const o=new ie({},e);o.addFragment(n),r.push(o)}else if(Array.isArray(n)){const o=new ie({},e);n.forEach(i=>{if(typeof i=="string")o.addFragment(i);else{const{content:a,...h}=i;a!==void 0&&o.addFragment(a,h)}}),r.push(o)}else if("fragments"in n){const{fragments:o,...i}=n,a=new ie(i,e);o.forEach(h=>{const{content:l,...u}=h;l!==void 0&&a.addFragment(l,u)}),r.push(a)}else if("content"in n){const{content:o,...i}=n;if(o!==void 0){const a=new ie(i,e);a.addFragment(o),r.push(a)}}}return this.paragraphs=r,this}measure(t=this.measureDom){const e={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(t);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(o=>{o.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),[...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 e)r[o]=this[o],this[o]=e[o];return r}getGlyphBox(){const t=v.MAX,e=v.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(t,e)){const{inlineBox:n}=r,o=new v(n.left,n.top),i=new v(n.left+n.width,n.top+n.height);t.min(o,i),e.max(o,i)}}),new E(t.x,t.y,e.x-t.x,e.y-t.y)}updatePathBox(){const t=[...this.plugins.values()];return this.pathBox=E.from(this.glyphBox,...t.map(e=>e.getBoundingBox?e.getBoundingBox(this):Qe(e.paths??[])).filter(Boolean)),this}updateBoundingBox(){const{lineBox:t,rawGlyphBox:e,pathBox:r}=this,n=r.left+t.left-e.left,o=r.top+t.top-e.top,i=r.right+t.right-e.right,a=r.bottom+t.bottom-e.bottom;return this.boundingBox=new E(n,o,i-n,a-o),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const e in t)this[e]=t[e];return this}render(t){const{view:e,pixelRatio:r=2}=t,n=e.getContext("2d");return n?(this.needsUpdate&&this.update(),Nr(n,r,this.boundingBox),zr(n,this),[...this.plugins.values()].sort((i,a)=>(i.renderOrder??0)-(a.renderOrder??0)).forEach(i=>{var a;i.render?(a=i.render)==null||a.call(i,n,this):i.paths&&i.paths.forEach(h=>{Te({ctx:n,path:h,fontSize:this.computedStyle.fontSize})})}),this):this}}function ua(s){return new Ir(s).measure()}function fa(s){return new Ir(s).render(s)}z.Character=Qn,z.Fragment=Xn,z.Measurer=Yn,z.Paragraph=ie,z.Text=Ir,z.defaultTextStyles=_r,z.definePlugin=oa,z.drawPath=Te,z.filterEmpty=Xe,z.getTransform2D=Tr,z.highlight=Hn,z.isNone=se,z.listStyle=Kn,z.measureText=ua,z.parseColor=ot,z.render=Jn,z.renderText=fa,z.setupView=Nr,z.uploadColor=Ot,z.uploadColors=zr,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|
|
6
|
+
</svg>`;break}}if(!l)return;const u=Vn(l),c=Qe(u),p=i.lineBox,g=i.fragments[0].inlineBox;if(g){const d=new vt;if(r){const m=Zn(h,n,n),f=n/c.height*m;d.translate(-c.left,-c.top),d.rotate(Math.PI/2),d.scale(f,f),d.translate(n/2-c.height*f/2,0),d.translate(p.left+(p.width-n)/2,g.top-o)}else{const m=Zn(h,n,n),f=n/c.height*m;d.translate(-c.left,-c.top),d.translate(-c.width,0),d.scale(f,f),d.translate(0,n/2-c.height*f/2),d.translate(g.left-o,p.top+(p.height-n)/2)}s.push(...u.map(m=>m.clone().matrix(d)))}})}}}const Vt=new v,oe=new vt,Wt=new vt;function Jn(){return{name:"render",getBoundingBox:s=>{const{characters:t,fontSize:e,effects:r}=s,n=[];return t.forEach(o=>{r==null||r.forEach(i=>{if(!o.glyphBox)return;const a=o.glyphBox.clone(),h=Tr(s,i);Vt.set(a.left,a.top),Vt.applyMatrix3(h),a.left=Vt.x,a.top=Vt.y,Vt.set(a.right,a.bottom),Vt.applyMatrix3(h),a.width=Vt.x-a.left,a.height=Vt.y-a.top;const l=(i.shadowOffsetX??0)*e,u=(i.shadowOffsetY??0)*e,c=Math.max(.1,i.textStrokeWidth??0)*e;a.left+=l-c,a.top+=u-c,a.width+=c*2,a.height+=c*2,n.push(a)})}),n.length?E.from(...n):void 0},render:(s,t)=>{const{characters:e,paragraphs:r,glyphBox:n,effects:o,style:i}=t;function a(h,l){s.fillStyle=h,s.fillRect(l.left,l.top,l.width,l.height)}i!=null&&i.backgroundColor&&a(i.backgroundColor,new E(0,0,s.canvas.width,s.canvas.height)),r.forEach(h=>{var l;(l=h.style)!=null&&l.backgroundColor&&a(h.style.backgroundColor,h.lineBox)}),o?o.forEach(h=>{Ot(h,n,s),s.save();const[l,u,c,p,g,d]=Tr(t,h).transpose().elements;s.transform(l,p,u,g,c,d),e.forEach(m=>{var f;(f=m.parent.style)!=null&&f.backgroundColor&&a(m.parent.style.backgroundColor,m.inlineBox),m.drawTo(s,h)}),s.restore()}):r.forEach(h=>{h.fragments.forEach(l=>{var u;(u=l.style)!=null&&u.backgroundColor&&a(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(s)})})})}}}function Tr(s,t){const{fontSize:e,glyphBox:r}=s,n=(t.translateX??0)*e,o=(t.translateY??0)*e,i=Math.PI*2,a=(t.skewX??0)/360*i,h=(t.skewY??0)/360*i,{left:l,top:u,width:c,height:p}=r,g=l+c/2,d=u+p/2;return oe.identity(),Wt.makeTranslation(n,o),oe.multiply(Wt),Wt.makeTranslation(g,d),oe.multiply(Wt),Wt.set(1,Math.tan(a),0,Math.tan(h),1,0,0,0,1),oe.multiply(Wt),Wt.makeTranslation(-g,-d),oe.multiply(Wt),oe.clone()}const _r={writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",listStyleType:"none",listStyleImage:"none",listStyleSize:"cover",listStylePosition:"outside",highlightReferImage:"none",highlightImage:"none",highlightSize:"cover",highlightStrokeWidth:"100%",highlightOverflow:"none",shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,translateX:0,translateY:0,skewX:0,skewY:0};class Ir{constructor(t={}){U(this,"content");U(this,"style");U(this,"effects");U(this,"measureDom");U(this,"needsUpdate",!0);U(this,"computedStyle",{..._r});U(this,"paragraphs",[]);U(this,"lineBox",new E);U(this,"rawGlyphBox",new E);U(this,"glyphBox",new E);U(this,"pathBox",new E);U(this,"boundingBox",new E);U(this,"measurer",new Yn(this));U(this,"plugins",new Map);U(this,"fonts");const{content:e="",style:r={},measureDom:n,effects:o,fonts:i}=t;this.content=e,this.style=r,this.measureDom=n,this.effects=o,this.fonts=i,this.use(Jn()).use(Hn()).use(Kn())}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(e=>e.characters))}use(t){return this.plugins.set(t.name,t),this}updateParagraphs(){this.computedStyle={..._r,...this.style};let{content:t,computedStyle:e}=this;const r=[];if(typeof t=="string"){const n=new ie({},e);n.addFragment(t),r.push(n)}else{t=Array.isArray(t)?t:[t];for(const n of t)if(typeof n=="string"){const o=new ie({},e);o.addFragment(n),r.push(o)}else if(Array.isArray(n)){const o=new ie({},e);n.forEach(i=>{if(typeof i=="string")o.addFragment(i);else{const{content:a,...h}=i;a!==void 0&&o.addFragment(a,h)}}),r.push(o)}else if("fragments"in n){const{fragments:o,...i}=n,a=new ie(i,e);o.forEach(h=>{const{content:l,...u}=h;l!==void 0&&a.addFragment(l,u)}),r.push(a)}else if("content"in n){const{content:o,...i}=n;if(o!==void 0){const a=new ie(i,e);a.addFragment(o),r.push(a)}}}return this.paragraphs=r,this}measure(t=this.measureDom){const e={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(t);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(o=>{o.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),[...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 e)r[o]=this[o],this[o]=e[o];return r}getGlyphBox(){const t=v.MAX,e=v.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(t,e)){const{inlineBox:n}=r,o=new v(n.left,n.top),i=new v(n.left+n.width,n.top+n.height);t.min(o,i),e.max(o,i)}}),new E(t.x,t.y,e.x-t.x,e.y-t.y)}updatePathBox(){const t=[...this.plugins.values()];return this.pathBox=E.from(this.glyphBox,...t.map(e=>e.getBoundingBox?e.getBoundingBox(this):Qe(e.paths??[])).filter(Boolean)),this}updateBoundingBox(){const{lineBox:t,rawGlyphBox:e,pathBox:r}=this,n=Math.min(r.left,r.left+t.left-e.left),o=Math.min(r.top,r.top+t.top-e.top),i=Math.max(r.right,r.right+t.right-e.right),a=Math.max(r.bottom,r.bottom+t.bottom-e.bottom);return this.boundingBox=new E(n,o,i-n,a-o),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const e in t)this[e]=t[e];return this}render(t){const{view:e,pixelRatio:r=2}=t,n=e.getContext("2d");return n?(this.needsUpdate&&this.update(),Nr(n,r,this.boundingBox),zr(n,this),[...this.plugins.values()].sort((i,a)=>(i.renderOrder??0)-(a.renderOrder??0)).forEach(i=>{var a;i.render?(a=i.render)==null||a.call(i,n,this):i.paths&&i.paths.forEach(h=>{Te({ctx:n,path:h,fontSize:this.computedStyle.fontSize})})}),this):this}}function ua(s){return new Ir(s).measure()}function fa(s){return new Ir(s).render(s)}z.Character=Qn,z.Fragment=Xn,z.Measurer=Yn,z.Paragraph=ie,z.Text=Ir,z.defaultTextStyles=_r,z.definePlugin=oa,z.drawPath=Te,z.filterEmpty=Xe,z.getTransform2D=Tr,z.highlight=Hn,z.isNone=se,z.listStyle=Kn,z.measureText=ua,z.parseColor=ot,z.render=Jn,z.renderText=fa,z.setupView=Nr,z.uploadColor=Ot,z.uploadColors=zr,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1183,10 +1183,10 @@ class Text {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
updateBoundingBox() {
|
|
1185
1185
|
const { lineBox, rawGlyphBox, pathBox } = this;
|
|
1186
|
-
const left = pathBox.left + lineBox.left - rawGlyphBox.left;
|
|
1187
|
-
const top = pathBox.top + lineBox.top - rawGlyphBox.top;
|
|
1188
|
-
const right = pathBox.right + lineBox.right - rawGlyphBox.right;
|
|
1189
|
-
const bottom = pathBox.bottom + lineBox.bottom - rawGlyphBox.bottom;
|
|
1186
|
+
const left = Math.min(pathBox.left, pathBox.left + lineBox.left - rawGlyphBox.left);
|
|
1187
|
+
const top = Math.min(pathBox.top, pathBox.top + lineBox.top - rawGlyphBox.top);
|
|
1188
|
+
const right = Math.max(pathBox.right, pathBox.right + lineBox.right - rawGlyphBox.right);
|
|
1189
|
+
const bottom = Math.max(pathBox.bottom, pathBox.bottom + lineBox.bottom - rawGlyphBox.bottom);
|
|
1190
1190
|
this.boundingBox = new BoundingBox(
|
|
1191
1191
|
left,
|
|
1192
1192
|
top,
|