emf-converter 4.26.0 → 4.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lite.mjs ADDED
@@ -0,0 +1 @@
1
+ function ms(t,e,n){let r=o=>o.toString(16).padStart(2,"0");return `#${r(t&255)}${r(e&255)}${r(n&255)}`}function ue(t){let e=(t>>>24&255)/255,n=t>>>16&255,r=t>>>8&255,o=t&255;return `rgba(${n},${r},${o},${e.toFixed(3)})`}function Ta(t,e,n){let r=Math.min(1,Math.max(0,n)),o=(f,m)=>Math.round(f+(m-f)*r),s=t>>>24&255,i=e>>>24&255,a=o(t>>>16&255,e>>>16&255),u=o(t>>>8&255,e>>>8&255),l=o(t&255,e&255),c=o(s,i)/255;return `rgba(${a},${u},${l},${c.toFixed(3)})`}function im(t){let e=/^#([0-9a-f]{6})$/i.exec(t);if(e)return `#${(16777215^parseInt(e[1],16)).toString(16).padStart(6,"0")}`;let n=/^#([0-9a-f]{3})$/i.exec(t);if(n){let[o,s,i]=n[1].split("").map(u=>parseInt(u+u,16)),a=u=>(255-u).toString(16).padStart(2,"0");return `#${a(o)}${a(s)}${a(i)}`}let r=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(t);if(r){let o=255-Math.min(255,parseInt(r[1],10)),s=255-Math.min(255,parseInt(r[2],10)),i=255-Math.min(255,parseInt(r[3],10));return r[4]!==void 0?`rgba(${o},${s},${i},${r[4]})`:`rgb(${o},${s},${i})`}return t}function am(t,e,n,r,o,s,i,a,u,l){let c=0,f=o-1,m=e,b=e+n;for(;m+1<b&&f>=0;){let h=t.getUint8(m),p=t.getUint8(m+1);if(m+=2,h===0)if(p===0)c=0,f--;else {if(p===1)break;if(p===2){if(m+1>=b)break;c+=t.getUint8(m),f-=t.getUint8(m+1),m+=2;}else {let d=p;if(i){let x=Math.ceil(d/2),y=0;for(let g=0;g<x&&m<b;g++){let M=t.getUint8(m++);for(let P=0;P<2&&y<d;P++){let E=P===0?M>>4&15:M&15;E<a.length&&c<r&&l(c,o-1-f,a[E][0],a[E][1],a[E][2],255),c++,y++;}}x&1&&m++;}else {for(let x=0;x<d&&m<b&&c<r;x++){let y=t.getUint8(m++);y<a.length&&l(c,o-1-f,a[y][0],a[y][1],a[y][2],255),c++;}d&1&&m++;}}}else if(i){let d=p>>4&15,x=p&15;for(let y=0;y<h&&c<r;y++){let g=(y&1)===0?d:x;g<a.length&&l(c,o-1-f,a[g][0],a[g][1],a[g][2],255),c++;}}else {let d=p,x=d<a.length?a[d]:[0,0,0];for(let y=0;y<h&&c<r;y++)l(c,o-1-f,x[0],x[1],x[2],255),c++;}}return Et(new Uint8ClampedArray(u.buffer,u.byteOffset,u.byteLength),r,o)}function Aa(t){if(t===0)return 0;let e=0,n=t;for(;(n&1)===0;)n>>>=1,e++;return e}var M1=3;function um(t,e,n,r,o){let s=0,i=0,a=0,u=0,l=0,c=0,f=1,m=1,b=1;if(r===M1){let h=e+n;if(h+12>t.byteLength)return null;s=t.getUint32(h,true),i=t.getUint32(h+4,true),a=t.getUint32(h+8,true),u=Aa(s),l=Aa(i),c=Aa(a),f=s>>>u||1,m=i>>>l||1,b=a>>>c||1;}else o===16&&(s=31744,i=992,a=31,u=10,l=5,c=0,f=31,m=31,b=31);return {rMask:s,gMask:i,bMask:a,rShift:u,gShift:l,bShift:c,rMax:f,gMax:m,bMax:b}}function lm(t,e,n,r,o,s,i,a,u,l=false){let c=Math.floor((s*n+31)/32)*4,{rMask:f,gMask:m,bMask:b,rShift:h,gShift:p,bShift:d,rMax:x,gMax:y,bMax:g}=a;for(let M=0;M<r;M++){let P=o?M:r-1-M,E=e+P*c;if(!(E+c>t.byteLength))for(let R=0;R<n;R++){let T=(M*n+R)*4;if(s===1){let A=E+(R>>3),w=t.getUint8(A)>>7-(R&7)&1;w<i.length&&(u[T]=i[w][0],u[T+1]=i[w][1],u[T+2]=i[w][2]),u[T+3]=255;}else if(s===4){let A=E+(R>>1),w=(R&1)===0?t.getUint8(A)>>4&15:t.getUint8(A)&15;w<i.length&&(u[T]=i[w][0],u[T+1]=i[w][1],u[T+2]=i[w][2]),u[T+3]=255;}else if(s===8){let A=t.getUint8(E+R);A<i.length&&(u[T]=i[A][0],u[T+1]=i[A][1],u[T+2]=i[A][2]),u[T+3]=255;}else if(s===16){let A=t.getUint16(E+R*2,true);u[T]=Math.round(((A&f)>>>h)*255/x),u[T+1]=Math.round(((A&m)>>>p)*255/y),u[T+2]=Math.round(((A&b)>>>d)*255/g),u[T+3]=255;}else if(s===24){let A=E+R*3;u[T]=t.getUint8(A+2),u[T+1]=t.getUint8(A+1),u[T+2]=t.getUint8(A),u[T+3]=255;}else {let A=E+R*4,w=t.getUint8(A),I=t.getUint8(A+1),S=t.getUint8(A+2),v=t.getUint8(A+3);u[T]=S,u[T+1]=I,u[T+2]=w,u[T+3]=v===0&&!l?255:v;}}}}function Ue(t,e,n,r,o,s=false){if(e<0||n<0||e+40>t.byteLength||n+r>t.byteLength)return null;let i=t.getUint32(e,true);if(i<40||e+i>t.byteLength)return null;let a=t.getInt32(e+4,true),u=t.getInt32(e+8,true),l=t.getUint16(e+12,true),c=t.getUint16(e+14,true),f=t.getUint32(e+16,true);if(l!==1||a<=0||u===0||a>8192||Math.abs(u)>8192)return null;let m=0,b=1,h=2,p=3;if(c!==1&&c!==4&&c!==8&&c!==16&&c!==24&&c!==32||f===b&&c!==8||f===h&&c!==4||f===p&&c!==16&&c!==32||f!==m&&f!==b&&f!==h&&f!==p)return null;let d=Math.abs(u),x=u<0,y=[];if(c<=8){let P=1<<c,E=t.getUint32(e+32,true)||P,R=Math.min(E,P),T=e+i,A=!!o&&o.length>0;if(T+R*(A?2:4)>t.byteLength)return null;for(let w=0;w<R;w++){if(A){let C=t.getUint16(T+w*2,true),U=o[C<o.length?C:0];y.push([U>>16&255,U>>8&255,U&255]);continue}let I=t.getUint8(T+w*4),S=t.getUint8(T+w*4+1),v=t.getUint8(T+w*4+2);y.push([v,S,I]);}}let g=um(t,e,i,f,c);if(!g)return null;let M=new Uint8ClampedArray(a*d*4);return f===b||f===h?am(t,n,r,a,d,x,f===h,y,M,(E,R,T,A,w,I)=>{let S=(R*a+E)*4;M[S]=T,M[S+1]=A,M[S+2]=w,M[S+3]=I;}):(lm(t,n,a,d,x,c,y,g,M,s),Et(M,a,d))}var cm=[[0,0,0,255,0,0,0,0],[8,8,8,8,8,8,8,8],[128,64,32,16,8,4,2,1],[1,2,4,8,16,32,64,128],[8,8,8,255,8,8,8,8],[129,66,36,24,24,36,66,129]];function wr(t,e,n){return ((cm[t]??cm[0])[n&7]>>7-(e&7)&1)===1}function fs(t){let e=/^#([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(t.trim());if(!e)return 0;let n=e[1].length===3?e[1].replace(/./g,r=>r+r):e[1];return parseInt(n,16)}function wa(t,e,n){if(e+16>t.byteLength)return null;let r=t.getInt32(e+4,true),o=t.getInt32(e+8,true),s=t.getUint16(e+14,true),i=Math.abs(o);if(s!==1||r<=0||i===0||r>256||i>256)return null;let a=(r+31>>5)*4;if(n+a*i>t.byteLength)return null;let u=new Uint8Array(r*i);for(let l=0;l<i;l++){let c=o>0?i-1-l:l,f=n+l*a;for(let m=0;m<r;m++)u[c*r+m]=t.getUint8(f+(m>>3))>>7-(m&7)&1;}return {width:r,height:i,bits:u}}function mm(t,e,n,r,o=null){if(n+24>t.byteLength)return null;let s=t.getUint32(n+8,true),i=t.getUint32(n+16,true),a=t.getUint32(n+20,true),u=e+s,l=e+i,c=u+16<=t.byteLength?t.getUint16(u+14,true):0;if(r||c===1){let h=wa(t,u,l);if(h&&r)return {kind:"mono",...h}}let f=Ue(t,u,l,a,o);if(!f)return null;let m=new Uint32Array(f.width*f.height),b=f.data;for(let h=0;h<m.length;h++)m[h]=b[h*4]<<16|b[h*4+1]<<8|b[h*4+2];return {kind:"bitmap",width:f.width,height:f.height,rgb:m}}function Qt(t){if(t.brushStyle===1)return {kind:"none"};let e=t.brushPattern;if(!e)return {kind:"solid",rgb:fs(t.brushColor)};if(e.kind==="bitmap")return {kind:"tile",width:e.width,height:e.height,rgb:e.rgb};let n=fs(t.bkColor);if(e.kind==="hatch"){let s=fs(t.brushColor),i=new Uint32Array(64);for(let a=0;a<8;a++)for(let u=0;u<8;u++)i[a*8+u]=wr(e.hatch,u,a)?s:n;return {kind:"tile",width:8,height:8,rgb:i}}let r=fs(t.textColor),o=new Uint32Array(e.width*e.height);for(let s=0;s<o.length;s++)o[s]=e.bits[s]?n:r;return {kind:"tile",width:e.width,height:e.height,rgb:o}}function qn(t,e,n,r,o){let s=((e-r)%t.width+t.width)%t.width,i=((n-o)%t.height+t.height)%t.height;return t.rgb[i*t.width+s]}function Sa(t){let e=[],n=0;for(let r=0;r<t.length;r++)e.push(n),n+=t[r];return e}function bs(t){let e=0;for(let n of t)e+=n;return e}function hs(t,e,n,r){let o=t.slice();if(n===0||r<=0)return o;let s=0;for(let i=0;i<o.length&&i<e.length;i++){if(e[i]!==32)continue;let a=Math.round(s*n/r);s++;let u=Math.round(s*n/r);o[i]+=u-a;}return o}function fm(t,e){return e==="center"?-t/2:e==="right"?-t:0}var E1=Math.PI/180;function bm(t){let n=(t%3600+3600)%3600*Ia/3600,r=Math.floor(n),o=n-r,s=r*2*Math.PI/Ia,i=(r+1)*2*Math.PI/Ia;return o===0?{sin:Math.sin(s),cos:Math.cos(s)}:{sin:(1-o)*Math.sin(s)+o*Math.sin(i),cos:(1-o)*Math.cos(s)+o*Math.cos(i)}}var Ia=128;function hm(t){return -(t/10)*E1}var P1=1.15;function pm(t){return t===0?0:t<0?-t:t/P1}var $=(...t)=>{},z=(...t)=>{};var R1=[137,80,78,71,13,10,26,10];function va(t){return t.length>=8&&R1.every((e,n)=>t[n]===e)}async function T1(t){if(typeof DecompressionStream=="function"&&typeof Response=="function")try{let e=new Blob([t]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}catch{}return Ca(t)}var A1=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],w1=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I1=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],S1=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],v1=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function po(t,e){let n=new Uint16Array(16);for(let s=0;s<e;s++)n[t[s]]++;n[0]=0;let r=new Uint16Array(16);for(let s=1;s<16;s++)r[s]=r[s-1]+n[s-1];let o=new Uint16Array(e);for(let s=0;s<e;s++)t[s]&&(o[r[t[s]]++]=s);return {counts:n,symbols:o}}function Ca(t){let e=2,n=0,r=0,o=new Uint8Array(Math.max(1024,t.length*4)),s=0,i=m=>{if(s+m>o.length){let b=new Uint8Array(Math.max(o.length*2,s+m));b.set(o.subarray(0,s)),o=b;}},a=m=>{for(;r<m;){if(e>=t.length)throw new Error("inflate: unexpected end of data");n|=t[e++]<<r,r+=8;}let b=n&(1<<m)-1;return n>>>=m,r-=m,b},u=m=>{let b=0,h=0,p=0;for(let d=1;d<16;d++){b|=a(1);let x=m.counts[d];if(b-x<h)return m.symbols[p+(b-h)];p+=x,h=h+x<<1,b<<=1;}throw new Error("inflate: bad Huffman code")},l=null,c=null,f=0;for(;!f;){f=a(1);let m=a(2);if(m===0){n=0,r=0;let p=t[e]|t[e+1]<<8;e+=4,i(p),o.set(t.subarray(e,e+p),s),s+=p,e+=p;continue}let b,h;if(m===1){if(!l||!c){let p=new Uint8Array(288);p.fill(8,0,144),p.fill(9,144,256),p.fill(7,256,280),p.fill(8,280,288),l=po(p,288),c=po(new Uint8Array(30).fill(5),30);}b=l,h=c;}else if(m===2){let p=a(5)+257,d=a(5)+1,x=a(4)+4,y=new Uint8Array(19);for(let P=0;P<x;P++)y[v1[P]]=a(3);let g=po(y,19),M=new Uint8Array(p+d);for(let P=0;P<p+d;){let E=u(g);if(E<16)M[P++]=E;else if(E===16){let R=M[P-1];for(let T=3+a(2);T>0;T--)M[P++]=R;}else E===17?P+=3+a(3):P+=11+a(7);}b=po(M.subarray(0,p),p),h=po(M.subarray(p),d);}else throw new Error("inflate: invalid block type");for(;;){let p=u(b);if(p<256)i(1),o[s++]=p;else {if(p===256)break;{let d=p-257,x=A1[d]+a(w1[d]),y=u(h),g=I1[y]+a(S1[y]);i(x);for(let M=0;M<x;M++)o[s]=o[s-g],s++;}}}}return o.subarray(0,s)}var C1=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]];function U1(t,e,n){let r=t+e-n,o=Math.abs(r-t),s=Math.abs(r-e),i=Math.abs(r-n);return o<=s&&o<=i?t:s<=i?e:n}function _1(t,e,n,r,o){let s=-1;for(let i=0;i<r;i++){let a=t[e],u=e+1;for(let l=0;l<n;l++){let c=l>=o?t[u+l-o]:0,f=s>=0?t[s+l]:0,m=s>=0&&l>=o?t[s+l-o]:0,b=t[u+l];switch(a){case 1:b+=c;break;case 2:b+=f;break;case 3:b+=c+f>>1;break;case 4:b+=U1(c,f,m);break}t[u+l]=b&255;}s=u,e=u+n;}return e}async function dm(t){if(!va(t))return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,r=0,o=0,s=-1,i=0,a=null,u=null,l=[],c=0;for(let I=8;I+12<=t.length;){let S=e.getUint32(I),v=String.fromCharCode(t[I+4],t[I+5],t[I+6],t[I+7]),C=t.subarray(I+8,Math.min(t.length,I+8+S));if(v==="IHDR"&&C.length>=13)n=e.getUint32(I+8),r=e.getUint32(I+12),o=C[8],s=C[9],i=C[12];else if(v==="PLTE")a=C;else if(v==="tRNS")u=C;else if(v==="IDAT")l.push(C),c+=C.length;else if(v==="IEND")break;I+=12+S;}let f={0:1,2:3,3:1,4:2,6:4}[s],m=s===0?[1,2,4,8,16].includes(o):s===3?[1,2,4,8].includes(o):[8,16].includes(o);if(!f||!m||n<=0||r<=0||c===0||s===3&&!a||n*r>268435456)return null;let b=new Uint8Array(c),h=0;for(let I of l)b.set(I,h),h+=I.length;let p;try{p=await T1(b);}catch{return null}let d=f*o,x=Math.max(1,d>>3),y=new Uint8ClampedArray(n*r*4),g=(1<<o)-1,M=u&&s===0&&u.length>=2?u[0]<<8|u[1]:-1,P=u&&s===2&&u.length>=6?[u[0]<<8|u[1],u[2]<<8|u[3],u[4]<<8|u[5]]:null,E=(I,S)=>{if(o===8)return p[I+S];if(o===16)return p[I+S*2]<<8|p[I+S*2+1];let v=S*o;return p[I+(v>>3)]>>8-o-(v&7)&g},R=I=>o===16?I>>8:o===8?I:Math.round(I*255/g),T=(I,S,v,C,U)=>{for(let D=0;D<S;D++){let L=(v*n+C+D*U)*4;if(s===3){let F=E(I,D);y[L]=a[F*3]??0,y[L+1]=a[F*3+1]??0,y[L+2]=a[F*3+2]??0,y[L+3]=u&&F<u.length?u[F]:255;}else if(s===0||s===4){let F=E(I,D*f),B=R(F);y[L]=B,y[L+1]=B,y[L+2]=B,y[L+3]=s===4?R(E(I,D*f+1)):F===M?0:255;}else {let F=E(I,D*f),B=E(I,D*f+1),X=E(I,D*f+2);y[L]=R(F),y[L+1]=R(B),y[L+2]=R(X),y[L+3]=s===6?R(E(I,D*f+3)):P&&F===P[0]&&B===P[1]&&X===P[2]?0:255;}}},A=0,w=i===1?C1:[[0,0,1,1]];for(let[I,S,v,C]of w){let U=Math.ceil((n-I)/v),D=Math.ceil((r-S)/C);if(U<=0||D<=0)continue;let L=Math.ceil(U*d/8);if(A+D*(L+1)>p.length)return null;let F=A;A=_1(p,A,L,D,x);for(let B=0;B<D;B++)T(F+B*(L+1)+1,U,S+B*C,I,v);}return {width:n,height:r,data:y}}function xm(t){return null}function ps(t){if(t.length<4||t[0]!==255||t[1]!==216)return null;for(let e=2;e+4<=t.length;){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}if(n===216||n===1||n>=208&&n<=215||n===0){e+=2;continue}if(n===217||n===218)break;let r=t[e+2]*256+t[e+3];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204){if(e+10>t.length)return "standard";if(t[e+4]!==8)return "unsupported";let o=t[e+9];return n===201||n===202||o===4?"bundled":"standard"}e+=2+r;}return "standard"}async function ym(){return null}var zt=class{constructor(){this.data=new Int32Array(96);this.length=0;}add(e,n,r){if(r<=n)return;let o=this.length*3;if(o>0&&this.data[o-3]===e&&this.data[o-1]===n){this.data[o-1]=r;return}if(o+3>this.data.length){let s=new Int32Array(this.data.length*2);s.set(this.data),this.data=s;}this.data[o]=e,this.data[o+1]=n,this.data[o+2]=r,this.length++;}append(e){for(let n=0;n<e.length*3;n+=3)this.add(e.data[n],e.data[n+1],e.data[n+2]);}bounds(){if(this.length===0)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0,s=this.data;for(let i=0;i<this.length*3;i+=3)s[i]<n&&(n=s[i]),s[i]+1>o&&(o=s[i]+1),s[i+1]<e&&(e=s[i+1]),s[i+2]>r&&(r=s[i+2]);return {x0:e,y0:n,x1:r,y1:o}}};function gm(t,e){return Math.floor(t/e)}function xo(t,e){return -Math.floor(-t/e)}function Kn(t,e,n=new zt,r=-1/0,o=1/0){let s=[],i=1/0,a=-1/0;for(let h of t){let p=h.length>>1;if(!(p<2))for(let d=0;d<p;d++){let x=d+1===p?0:d+1,y=h[d*2],g=h[d*2+1],M=h[x*2],P=h[x*2+1];if(g===P)continue;let E=P>g?1:-1,R=E>0?y:M,T=E>0?g:P,A=E>0?M:y,w=E>0?P:g,I=xo(T,16),S=xo(w,16);S<=I||(s.push([I,S,R,T,A-R,w-T,E]),I<i&&(i=I),S>a&&(a=S));}}if(s.length===0)return n;s.sort((h,p)=>h[0]-p[0]);let u=Math.max(i,Math.ceil(r)),l=Math.min(a,Math.floor(o)),c=[],f=0,m=[],b=[];for(;f<s.length&&s[f][1]<=u;)f++;for(let h=u;h<l;h++){for(;f<s.length&&s[f][0]<=h;)s[f][1]>h&&c.push(s[f]),f++;for(let x=c.length-1;x>=0;x--)(c[x][1]<=h||c[x][0]>h)&&c[x][1]<=h&&c.splice(x,1);m.length=0,b.length=0;let p=h*16;for(let x of c){if(x[0]>h)continue;let y=x[2]*x[5]+(p-x[3])*x[4];m.push(xo(y,x[5]*16)),b.push(x[6]);}let d=m.length;if(!(d<2)){for(let x=1;x<d;x++){let y=m[x],g=b[x],M=x-1;for(;M>=0&&m[M]>y;)m[M+1]=m[M],b[M+1]=b[M],M--;m[M+1]=y,b[M+1]=g;}if(e){let x=0,y=0;for(let g=0;g<d;g++){let M=x;x+=b[g],M===0&&x!==0?y=m[g]:M!==0&&x===0&&n.add(h,y,m[g]);}}else for(let x=0;x+1<d;x+=2)n.add(h,m[x],m[x+1]);}}return n}function L1(t,e){return Math.abs(t)!==Math.abs(e)?10:e>0?2:t>0?136:68}function Mm(t,e,n,r){let o=Math.abs(t)+Math.abs(e),s=8*n;if(o<s)return true;if(o>s)return false;let i;return t===0?i=e<0?1:2:e===0?i=t<0?4:8:t<0?i=e<0?16:64:i=e<0?32:128,(r&i)!==0}function gs(t,e,n,r,o){let s=n-t,i=r-e;if(s===0&&i===0)return;let a=L1(s,i),u=Math.abs(s)>=Math.abs(i),l=u?t:e,c=u?e:t,f=u?n:r,m=u?r:n,b=f>l?1:-1,h=Math.abs(f-l),p=(m-c)*b,d=Math.abs(s)===Math.abs(i),x=Math.min(l,f),y=Math.max(l,f),g=(E,R,T)=>u?Mm(E,R,T,a):Mm(R,E,T,a),M=b>0?gm(x,16)-1:xo(y,16)+1,P=b>0?xo(y,16)+1:gm(x,16)-1;for(let E=M;b>0?E<=P:E>=P;E+=b){let R=E*16,T=c*h+(R-l)*p,A=T/h/16,w=Math.round(A);for(let I=w-1;I<=w+1;I++){let S=I*16,v=T-S*h,C=x-R,U=y-R,D;if(d){let L=p/h,F=v/h,B=Math.max(C,Math.min(0,U)),X=Math.max(C,Math.min(-F/L,U));D=g(2*B,2*(F+L*B),2)||g(2*X,2*(F+L*X),2)||g(B+X,2*F+L*(B+X),2);}else {let L=Math.max(C,Math.min(0,U));D=g(L*h,v+L*p,h);}D&&(g(f-R,m-S,1)||(u?o(E,I):o(I,E)));}}}var Em=10,Ua=3,Rm=6*10912,D1=Rm*8;function hn(t,e){return Math.floor(t/2**e)}var Ms=class{constructor(e,n,r,o){let s=2**Em;this.e0=e*s,this.e1=(o-e)*s,this.e2=6*(n-r-r+o)*s,this.e3=6*(e-n-n+r)*s;}lazyHalve(e){this.e2=hn(this.e2+this.e3,1),this.e1=hn(this.e1-hn(this.e2,e),1);}steadyState(e){let n=2**Ua;this.e0*=n,this.e1*=n;let r=e-Ua;r<0?(this.e2*=2**-r,this.e3*=2**-r):(this.e2=hn(this.e2,r),this.e3=hn(this.e3,r));}halve(){this.e2=hn(this.e2+this.e3,3),this.e1=hn(this.e1-this.e2,1),this.e3=hn(this.e3,2);}double(){this.e1+=this.e1+this.e2,this.e3*=4,this.e2=this.e2*8-this.e3;}step(){this.e0+=this.e1;let e=this.e2;this.e1+=e,this.e2+=e-this.e3,this.e3=e;}error(){return Math.max(Math.abs(this.e2),Math.abs(this.e3))}parentErrorDividedBy4(){return Math.max(Math.abs(this.e3),Math.abs(this.e2+this.e2-this.e3))}value(){let e=Em+Ua;return hn(this.e0+2**(e-1),e)}};function Tm(t,e,n,r,o,s,i,a,u,l=1){let c=Rm*l,f=D1*l,m=new Ms(t,n,o,i),b=new Ms(e,r,s,a),h=1,p=0;for(;p<40&&(m.error()>c*2**p||b.error()>c*2**p);)p+=2,m.lazyHalve(p),b.lazyHalve(p),h*=2;m.steadyState(p),b.steadyState(p);for(let d=0;h>0&&d<1<<20;d++){for(Math.max(m.error(),b.error())>f&&(m.halve(),b.halve(),h*=2);h%2===0&&m.parentErrorDividedBy4()<=f/4&&b.parentErrorDividedBy4()<=f/4;)m.double(),b.double(),h/=2;h--,m.step(),b.step(),u.push(m.value(),b.value());}}var Ie=.5522847498307936;function Jn(t,e,n,r){return {ax:t,ay:e,exx:n-t,exy:0,eyx:0,eyy:r-e}}function pn(t,e=false){if(!e)return wm(t,false);let{halfX:n,...r}=t,o=Am(r),s=[];for(let a=o.length-2;a>=0;a-=2)s.push(o[a],o[a+1]);let i=Math.abs(r.exx)%2;if(s[18]+=i,s[6]-=i,n)for(let a of [0,1,2,3,4,5,12])s[2*a]++;return s}function Am(t){return wm(t,true)}function wm(t,e){let n=(w,I)=>I?Math.ceil(w/2):Math.floor(w/2),r=w=>n(w,false),o=w=>n(w,true),s=w=>Math.floor(w/2)+Math.ceil(Ie*Math.ceil(w/2)),i=w=>Math.ceil(w/2)-Math.ceil(Ie*Math.ceil(w/2)),a=w=>n(w,false),u=w=>n(w,true),l=w=>Math.floor(w/2)-Math.floor(Ie*Math.floor(w/2)),c=w=>w-l(w),f=w=>w%2===0?Math.ceil(Ie*Math.floor(w/2)):Math.floor(Ie*Math.ceil(w/2)),m=e?w=>a(w)-f(w):l,b=e?w=>a(w)-f(w):l,h=e?w=>u(w)+f(w):c,p=e?w=>u(w)+f(w):c,d=()=>0,x=w=>w,{ax:y,ay:g,exx:M,exy:P,eyx:E,eyy:R}=t,T=[],A=(w,I)=>{T.push(y+w(M)+I(E),g+w(P)+I(R));};if(A(x,u),A(x,m),A(s,d),A(r,d),A(i,d),A(d,b),A(d,a),A(d,h),A(i,x),A(o,x),A(s,x),A(x,p),A(x,u),t.halfX)for(let w of [0,1,2,3,4,5,12])T[2*w]++;return T}function Da(t,e,n,r){return pn(Jn(t,e,n,r))}function Fa(t){let e=[t[0],t[1]];for(let n=2;n+5<t.length;n+=6)Tm(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],e);return e}function Im(t,e,n,r,o,s,i=false,a=false,u=false,l){let c=n-t,f=r-e;if(l){let E=(T,A)=>Math.floor(Math.fround(T*A)+.5),R=u?Math.floor(c/2):Math.ceil(c/2);o=2*Math.min(E(R,l[0]),R),s=2*Math.min(E(a?Math.ceil(f/2):Math.floor(f/2),l[1]),a?Math.ceil(f/2):Math.floor(f/2));}let m=Math.min(Math.abs(o),c),b=Math.min(Math.abs(s),f);(m===0||b===0)&&(m=0,b=0);let h=i||a?Math.round(b/2):Math.floor(f/2)-Math.floor((f-b)/2),p=i?Math.round(n-m/2):Math.floor(n-m/2),d=n-p,x=a?Math.ceil(Ie*h):Math.floor(Ie*h),y=u?Math.floor(Ie*d):Math.ceil(Ie*d),g=[n,e+h,n,e+h-x,n-d+y,e,p,e],M=E=>t+n-E,P=E=>e+r-E;return [g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],M(g[6]),g[7],M(g[4]),g[5],M(g[2]),g[3],M(g[0]),g[1],M(g[0]),P(g[1]),M(g[2]),P(g[3]),M(g[4]),P(g[5]),M(g[6]),P(g[7]),g[6],P(g[7]),g[4],P(g[5]),g[2],P(g[3]),g[0],P(g[1])]}var La=2*Math.PI/128,ds=t=>Ln(t)[0],xs=t=>Ln(t)[1];function ka(t,e){let n=[],r=(a,u)=>{if(Math.abs(u-a)<90){n.push({from:a,to:u,first:true});return}let l=Math.min(a,u),c=Math.max(a,u),f=Math.floor(c/90)-Math.floor(l/90)+1,m=[];for(let h=Math.floor(l/90)+1;h*90<c;h++)m.push(h*90);u<a&&m.reverse();let b=[a,...m,u];for(;b.length-1<f;)b.push(u);for(let h=0;h+1<b.length;h++)n.push({from:b[h],to:b[h+1],first:h===0});},o=e<0?-1:1,s=Math.min(8,Math.trunc(Math.abs(e)/360)),i=t+e-o*s*360;r(t,i);for(let a=1;a<=s;a++)r(i+o*360*(a-1),t+o*360*a),r(t+o*360*a,i+o*360*a);return n}function Sm(t,e,n,r,o,s){let i=o*Math.PI/180,a=s*Math.PI/180,u=4/3*Math.tan((a-i)/4),l=t+n*ds(i),c=e-r*xs(i),f=t+n*ds(a),m=e-r*xs(a);return [l-u*n*xs(i),c-u*r*ds(i),f+u*n*xs(a),m+u*r*ds(a),f,m]}function vm(t,e,n){let r=Math.min(t.ax,t.ax+t.exx),o=Math.min(t.ay,t.ay+t.eyy),s=Math.abs(t.exx),i=Math.abs(t.eyy),a=r+s/2,u=o+i/2,l=Da(r,o,r+s,o+i),c=Am(Jn(r,o,r+s,o+i)),f=e*Math.PI/180,m=Math.abs(n)<=3?[Math.cos(f),Math.sin(f)]:Ln(f),b=[Math.round(a+s/2*m[0]),Math.round(u-i/2*m[1])];for(let h of ka(e,n)){let p=h.to-h.from;if(!h.first&&Math.abs(p)===90&&h.from%90===0){let y=(Math.min(h.from,h.to)/90%4+4)%4*6;p>0?b.push(l[y+2],l[y+3],l[y+4],l[y+5],l[y+6],l[y+7]):b.push(c[y+4],c[y+5],c[y+2],c[y+3],c[y],c[y+1]);continue}let d=Cm(h.from*Math.PI/180,h.to*Math.PI/180,Math.abs(n)<=3);for(let x=0;x<6;x+=2)b.push(Math.round(a+s/2*d.ctrl[x]),Math.round(u-i/2*d.ctrl[x+1]));}return b}var F1=3*Math.PI/180,ys=(()=>{let t=[],e=[];for(let n=0;n<=129;n++)t.push(Math.fround(Math.cos(n*La))),e.push(Math.fround(Math.sin(n*La)));for(let n=0;n<=128;n+=32)t[n]=[1,0,-1,0,1][n/32],e[n]=[0,1,0,-1,0][n/32];return {cos:t,sin:e}})();function Ln(t){let e=t%(2*Math.PI);e<0&&(e+=2*Math.PI);let n=Math.fround(e/La),r=Math.min(127,Math.floor(n)),o=n-r;return [ys.cos[r]*(1-o)+ys.cos[r+1]*o,ys.sin[r]*(1-o)+ys.sin[r+1]*o]}var _a=Array.from({length:33},(t,e)=>Math.atan(e/32));function Pm(t){let e=t*32,n=Math.min(31,Math.floor(e));return _a[n]+(_a[n+1]-_a[n])*(e-n)}function k1(t,e){let n=Math.abs(t),r=Math.abs(e);if(n===0&&r===0)return 0;let o=r<=n?Pm(Math.fround(r/n)):Math.PI/2-Pm(Math.fround(n/r));return t>=0?e>=0?o:2*Math.PI-o:e>=0?Math.PI-o:Math.PI+o}function Cm(t,e,n,r=1/0){let o=n?l=>[Math.cos(l),Math.sin(l)]:Ln,s=o(t),i=o(e);if(n&&6e-8*r/Math.abs(Math.sin(e-t))>.5){let l=Math.fround,c=[l(s[0]),l(s[1])],f=[l(i[0]),l(i[1])],m=l(l(c[0]*f[1])-l(c[1]*f[0]));if(m!==0){let b=[l(l(f[1]-c[1])/m),l(l(c[0]-f[0])/m)],h=l(Ln(Math.abs(e-t)/2)[0]),p=l(l(l(4/3)*h)/l(1+h));return {start:s,ctrl:[l(c[0]+l(p*l(b[0]-c[0]))),l(c[1]+l(p*l(b[1]-c[1]))),l(f[0]+l(p*l(b[0]-f[0]))),l(f[1]+l(p*l(b[1]-f[1]))),i[0],i[1]]}}}let a=s[0]*i[1]-s[1]*i[0],u;if(Math.abs(a)<1e-12)u=[s[0],s[1],i[0],i[1],i[0],i[1]];else {let l=[(i[1]-s[1])/a,(s[0]-i[0])/a],c=Ln(Math.abs(e-t)/2)[0],f=4/3*c/(1+c);u=[s[0]+f*(l[0]-s[0]),s[1]+f*(l[1]-s[1]),i[0]+f*(l[0]-i[0]),i[1]+f*(l[1]-i[1]),i[0],i[1]];}return {start:s,ctrl:u}}function Um(t,e,n,r,o,s,i,a,u,l=false,c=false,f=false){let m=n-t,b=r-e,h=Math.PI/2,p=Math.ceil(m/2),d=u?Math.ceil(b/2):Math.floor(b/2),x=t+Math.ceil(m/2),y=e+Math.ceil(b/2),g=(t+n)/2,M=(e+r)/2,P=(k,W)=>k1((k-g)/(m/2||1),-(W-M)/(b/2||1)),E=P(o,s),R=P(i,a),T=k=>u?(2*Math.PI-k)%(2*Math.PI):k,A=R!==E&&Math.abs(T(R)-T(E))<=F1,w=u?-1:1;if(w>0)for(;R<=E;)R+=2*Math.PI;else for(;R>=E;)R-=2*Math.PI;let I=(k,W)=>Math.fround(k*Math.fround(W)),S=(k,W)=>f?Math.round(x-I(Math.floor(m/2),k)):u&&l?Math.ceil(x+I(p,k)+.5-W):Math.round(x+I(p,k)+(l?1+W:0)),v=k=>Math.round(y-I(d,k)),C=f?Jn(n,e,t,r):Jn(t,e,n,r);l&&(C.halfX=true);let U=pn(C);if(u){let k=pn(C,true);for(let W=0;W<k.length;W+=2)U[k.length-2-W]=k[W],U[k.length-1-W]=k[W+1];}let D=A?[Math.cos(E),Math.sin(E)]:Ln(E),L=[S(D[0],D[1]),v(D[1])],F=k=>Math.abs(k/h-Math.round(k/h))<1e-9,B=k=>(Math.round(k/h)%4+4)%4;c&&F(E)&&(w>0?B(E)===1||B(E)===2:B(E)===2||B(E)===3)&&L.push(L[0],L[1],L[0],L[1],L[0],L[1]);let X=E;for(let k=0;k<8&&(w>0?X<R-1e-12:X>R+1e-12);k++){let W=w>0?Math.floor(X/h+1e-9)*h+h:Math.ceil(X/h-1e-9)*h-h,O=Math.abs(X/h-Math.round(X/h))<1e-9,q=w>0?W>=R-1e-12:W<=R+1e-12,Q=(Math.round(X/h)%4+4)%4,K=(Math.round(W/h)%4+4)%4;if(!(k===0&&(w>0?Q===0||Q===3:Q===0||Q===1)||q&&(w>0?K===1||K===2:K===2||K===3))&&O&&(w>0?W<=R+1e-12:W>=R-1e-12)){let Y=(Math.round(Math.min(X,W)/h)%4+4)%4*6;w>0?L.push(U[Y+2],U[Y+3],U[Y+4],U[Y+5],U[Y+6],U[Y+7]):L.push(U[Y+4],U[Y+5],U[Y+2],U[Y+3],U[Y],U[Y+1]),X=W;continue}let rt=w>0?Math.min(W,R):Math.max(W,R),H=Cm(X,rt,A,Math.max(p,d));for(let Y=0;Y<6;Y+=2)L.push(S(H.ctrl[Y],H.ctrl[Y+1]),v(H.ctrl[Y+1]));X=rt;}if(c&&F(R)&&(w>0?B(R)===3||B(R)===0:B(R)===1||B(R)===0)){let k=Ln(R),W=S(k[0],k[1]),O=v(k[1]);L.push(W,O,W,O,W,O);}return L}var St=class{constructor(){this.figures=[];this.getPath={pts:[],types:[]};this.current=null;}moveTo(e,n){this.current={pts:[e,n],closed:false},this.figures.push(this.current),this.log(e,n,6);}continueAt(e,n){let r=this.current;r&&r.pts[r.pts.length-2]===e&&r.pts[r.pts.length-1]===n||this.moveTo(e,n);}hasOpenFigure(){return this.current!==null}log(e,n,r){this.getPath.pts.push(e,n),this.getPath.types.push(r);}lineTo(e,n){if(!this.current){let r=this.lastPoint();this.moveTo(r?r[0]:e,r?r[1]:n);}this.current.pts.push(e,n),this.log(e,n,2);}bezierTo(e,n,r,o,s,i){if(!this.current){let u=this.lastPoint();this.moveTo(u?u[0]:e,u?u[1]:n);}let a=this.current.pts;this.flattenInto(a[a.length-2],a[a.length-1],e,n,r,o,s,i),this.log(e,n,4),this.log(r,o,4),this.log(s,i,4);}flattenInto(e,n,r,o,s,i,a,u){let l=this.current,c=l.pts.length/2-1;Tm(e,n,r,o,s,i,a,u,l.pts);let f=l.pts.length/2-2;if(f<=c){if(f===c){let p=l.pts.length;l.tangents??(l.tangents=new Map),l.tangentRoles??(l.tangentRoles=new Map),l.tangents.set(c,[l.pts[p-2]-l.pts[p-4],l.pts[p-1]-l.pts[p-3]]),l.tangentRoles.set(c,3);}return}let m=(p,d,x,y,g,M,P,E)=>x!==p||y!==d?[x-p,y-d]:g!==p||M!==d?[g-p,M-d]:P!==p||E!==d?[P-p,E-d]:null,b=m(e,n,r,o,s,i,a,u),h=m(s,i,a,u,a,u,a,u)??m(r,o,a,u,a,u,a,u)??m(e,n,a,u,a,u,a,u);l.curveSegs??(l.curveSegs=new Set);for(let p=c;p<=f;p++)l.curveSegs.add(p);l.tangents??(l.tangents=new Map),l.tangentRoles??(l.tangentRoles=new Map),b&&(l.tangents.set(c,b),l.tangentRoles.set(c,1)),h&&(l.tangents.set(f,h),l.tangentRoles.set(f,2));}addBeziers(e,n){n?this.moveTo(e[0],e[1]):this.lineTo(e[0],e[1]);for(let r=2;r+5<e.length;r+=6){this.flattenInto(e[r-2],e[r-1],e[r],e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]);for(let o=r;o<r+6;o+=2)this.log(e[o],e[o+1],4);}}closeFigure(){if(this.current){this.current.closed=true,this.current=null;let e=this.getPath.types;e[e.length-1]|=1;}}append(e){for(let n of e.figures)this.figures.push({pts:n.pts.slice(),closed:n.closed,tangents:n.tangents&&new Map(n.tangents),tangentRoles:n.tangentRoles&&new Map(n.tangentRoles),curveSegs:n.curveSegs&&new Set(n.curveSegs),roundWiden:n.roundWiden});for(let n=0;n<e.getPath.types.length;n++)this.log(e.getPath.pts[2*n],e.getPath.pts[2*n+1],e.getPath.types[n]);this.current=null;}lastPoint(){let e=this.figures[this.figures.length-1];return e?e.closed?[e.pts[0],e.pts[1]]:[e.pts[e.pts.length-2],e.pts[e.pts.length-1]]:null}};function Ir(t,e,n){return Kn(t.figures.map(r=>r.pts),e,n)}function Sr(t,e){switch(t&15){case 1:return [18,6];case 2:return [3,3];case 3:return [9,6,3,6];case 4:return [9,3,3,3,3,3];case 7:return e&&e.length>0&&e.some(n=>n>0)?e.map(n=>Math.max(0,n)*3):null;case 8:return [1,1];default:return null}}function yo(t,e,n,r=1){let o=Math.max(e,1);switch(t&15){case 1:return [3*o,o];case 2:return [o,o];case 3:return [3*o,o,o,o];case 4:return [3*o,o,o,o,o,o];case 7:return n&&n.some(s=>s>0)?n.map(s=>Math.max(0,s)*r):null;default:return null}}function Es(t){let e=t&15;return e>=1&&e<=4}function Ps(t,e,n,r,o={pos:0},s=true){let i=0;if(r)for(let u of r)i+=u;let a=(u,l)=>{if(!r||i===0){e.add(l,u,u+1);return}let c=o.pos%i;o.pos++;for(let f=0;f<r.length;f++){if(c<r[f]){f%2===0?e.add(l,u,u+1):n&&n.add(l,u,u+1);return}c-=r[f];}};t.figures.forEach((u,l)=>{l>0&&s&&(o.pos=0);let c=u.pts;for(let f=0;f+3<c.length;f+=2)gs(c[f],c[f+1],c[f+2],c[f+3],a);if(u.closed&&c.length>=4){let f=c.length;(c[f-2]!==c[0]||c[f-1]!==c[1])&&gs(c[f-2],c[f-1],c[0],c[1],a);}});}var dn=class{constructor(e,n){this.pixels=new Uint8ClampedArray(0);throw new Error("The emf-converter lite build needs a browser canvas (OffscreenCanvas or document)")}};var te;async function Va(){if(te!==void 0)return te;if(typeof OffscreenCanvas<"u"||typeof document<"u"||typeof process>"u"||!process.versions?.node)return te=null,te;try{te=await ym();}catch{te=null;}return te}var _m=false;function ws(){return typeof OffscreenCanvas>"u"&&typeof document>"u"&&!te}var Zn=1;function za(t,e,n,r,o=Zn,s=8192){let i=Math.max(1,Math.min(o,4)),a=Math.round(t*i),u=Math.round(e*i),l=i,c=i;if(n&&a>n){let h=n/a;a=n,u=Math.round(u*h),l*=h,c*=h;}if(r&&u>r){let h=r/u;a=Math.round(a*h),u=r,l*=h,c*=h;}let f=Math.max(1,Math.floor(s)),m=Math.max(1,Math.min(a,f)),b=Math.max(1,Math.min(u,f));return (m!==a||b!==u)&&console.warn(`[emf-converter] Canvas size clamped from ${a}\xD7${u} to ${m}\xD7${b}. Output may lose detail.`),{w:m,h:b,scaleX:l,scaleY:c}}var Ts={willReadFrequently:true};function Is(t,e,n,r,o=Zn,s=8192){let{w:i,h:a,scaleX:u,scaleY:l}=za(t,e,n,r,o,s);try{if(ws()){$(`createCanvas: using the software rasteriser ${i}\xD7${a}`);let c=new dn(i,a);return {canvas:c,ctx:c.ctx,scaleX:u,scaleY:l}}if(typeof OffscreenCanvas<"u"){$(`createCanvas: using OffscreenCanvas ${i}\xD7${a}, scale=(${u.toFixed(3)},${l.toFixed(3)})`);let c=new OffscreenCanvas(i,a),f=c.getContext("2d",Ts);return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(z('createCanvas: OffscreenCanvas.getContext("2d") returned null'),null)}if(typeof document<"u"){$(`createCanvas: using HTMLCanvasElement ${i}\xD7${a}, scale=(${u.toFixed(3)},${l.toFixed(3)})`);let c=document.createElement("canvas");c.width=i,c.height=a;let f=c.getContext("2d",Ts);return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(z('createCanvas: HTMLCanvasElement.getContext("2d") returned null'),null)}if(te){$(`createCanvas: using @napi-rs/canvas ${i}\xD7${a}, scale=(${u.toFixed(3)},${l.toFixed(3)})`);let c=te.createCanvas(i,a),f=c.getContext("2d");return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(z('createCanvas: @napi-rs/canvas getContext("2d") returned null'),null)}return z("createCanvas: no OffscreenCanvas, no document, and no @napi-rs/canvas, cannot create canvas"),null}catch(c){return null}}function It(t,e){if(t<=0||e<=0)return null;if(t=Math.max(1,Math.min(Math.floor(t),8192)),e=Math.max(1,Math.min(Math.floor(e),8192)),_m);if(typeof OffscreenCanvas<"u"){let r=new OffscreenCanvas(t,e),o=r.getContext("2d",Ts);return o?{canvas:r,ctx:o}:null}if(typeof document<"u"){let r=document.createElement("canvas");r.width=t,r.height=e;let o=r.getContext("2d",Ts);return o?{canvas:r,ctx:o}:null}if(te){let r=te.createCanvas(t,e),o=r.getContext("2d");return o?{canvas:r,ctx:o}:null}let n=new dn(t,e);return {canvas:n,ctx:n.ctx}}function he(t){switch(t){case 1:return {gco:"source-over",colorTransform:"black",exact:true};case 16:return {gco:"source-over",colorTransform:"white",exact:true};case 11:return {gco:"source-over",colorTransform:"skip",exact:true};case 4:return {gco:"source-over",colorTransform:"invert",exact:true};case 6:return {gco:"difference",colorTransform:"white",exact:true};case 7:case 5:return {gco:"difference",colorTransform:"none",exact:false};case 10:return {gco:"difference",colorTransform:"invert",exact:false};case 9:return {gco:"darken",colorTransform:"none",exact:false};case 3:case 2:return {gco:"darken",colorTransform:"invert",exact:false};case 15:case 14:return {gco:"lighten",colorTransform:"none",exact:false};case 12:case 8:return {gco:"lighten",colorTransform:"invert",exact:false};default:return {gco:"source-over",colorTransform:"none",exact:true}}}function vr(t,e){switch(e){case "invert":return im(t);case "black":return "#000000";case "white":return "#ffffff";case "skip":return "rgba(0,0,0,0)";default:return t}}function Cr(t,e){let n=he(e.rop2);if(t.globalCompositeOperation=n.gco,e.penStyle===5){t.strokeStyle="rgba(0,0,0,0)",t.lineWidth=0;return}t.strokeStyle=vr(e.penColor,n.colorTransform),t.lineWidth=Math.max(e.penWidth,1),t.setLineDash(e.penWidth<=1?Sr(e.penStyle,e.penUserStyle)??[]:[]);}function Ur(t,e){let n=he(e.rop2);if(t.globalCompositeOperation=n.gco,Qt(e).kind==="none"){t.fillStyle="rgba(0,0,0,0)";return}t.fillStyle=vr(e.brushColor,n.colorTransform);}function X1(t){if(!t||t===400)return "";let e=Math.round(t/100)*100;return e===700?"bold":e>=100&&e<=900?String(e):t>=700?"bold":""}function _r(t,e){let n=e?.[t.toLowerCase().trim()]??t;return /[\s,]/.test(n)&&!/^["']/.test(n)?`"${n}"`:n}function Ss(t,e=1){return Math.max(pm(t.fontHeight)*Math.abs(e||1),8)}function Lm(t,e,n=1){let r=e.fontItalic?"italic ":"",o=X1(e.fontWeight),s=o?`${o} `:"",i=Ss(e,n),a=_r(e.fontFamily,e.fontFamilyMap);t.font=`${r}${s}${i}px ${a}`;}function Dm(t,e,n,r,o,s=1){if(!e.fontUnderline&&!e.fontStrikeOut)return;let i=Ss(e,s),a=Math.max(1,Math.round(i/14)),u=t.fillStyle;t.fillStyle=e.textColor,e.fontUnderline&&t.fillRect(n,r+Math.round(i*.12),o,a),e.fontStrikeOut&&t.fillRect(n,r-Math.round(i*.3),o,a),t.fillStyle=u;}function Dn(t,e,n){if(n<=0)return "";let r=t.byteLength-e;if(r<=0)return "";let o=Math.min(n,Math.floor(r/2));if(o<=0)return "";let s;try{let a=new Uint8Array(t.buffer,t.byteOffset+e,o*2);s=new TextDecoder("utf-16le").decode(a);}catch{let a=[];for(let u=0;u<o;u++){let l=t.getUint16(e+u*2,true);if(l===0)return a.join("");a.push(String.fromCharCode(l));}return a.join("")}let i=s.indexOf("\0");return i===-1?s:s.slice(0,i)}function vs(t){switch(t){case 0:return {kind:"brush",style:0,color:"#ffffff"};case 1:return {kind:"brush",style:0,color:"#c0c0c0"};case 2:return {kind:"brush",style:0,color:"#808080"};case 3:return {kind:"brush",style:0,color:"#404040"};case 4:return {kind:"brush",style:0,color:"#000000"};case 5:return {kind:"brush",style:1,color:"#000000"};case 6:return {kind:"pen",style:0,widthX:1,color:"#ffffff"};case 7:return {kind:"pen",style:0,widthX:1,color:"#000000"};case 8:return {kind:"pen",style:5,widthX:0,color:"#000000"};case 10:case 11:return {kind:"font",height:12,weight:400,italic:false,underline:false,strikeOut:false,family:"monospace"};case 12:case 13:case 14:case 17:return {kind:"font",height:12,weight:400,italic:false,underline:false,strikeOut:false,family:"sans-serif"};default:return null}}async function Lr(t,e){let n=ps(new Uint8Array(t));if(n==="unsupported")return null;if(ws()){let s=await As(new Uint8Array(t));return s?{drawable:s,width:s.width,height:s.height,close:()=>{}}:null}{if(te)try{let s=await te.loadImage(new Uint8Array(t));return {drawable:s,width:s.width,height:s.height,close:()=>{}}}catch{}else if(typeof createImageBitmap=="function")try{let s=e!==void 0?new Blob([t],{type:e}):new Blob([t]),i=await createImageBitmap(s);return {drawable:i,width:i.width,height:i.height,close:()=>i.close()}}catch{}}let r=await As(new Uint8Array(t)),o=r&&It(r.width,r.height);return !r||!o?null:(Ct(o.ctx,Et(r.data,r.width,r.height),0,0),{drawable:o.canvas,width:r.width,height:r.height,close:()=>{}})}async function As(t){if(va(t))return dm(t);if(t.length>=26&&t[0]===66&&t[1]===77){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(10,true),r=Ue(e,14,n,e.byteLength-n);return r?{data:r.data,width:r.width,height:r.height}:null}return xm()}function le(t,e,n,r,o,s){t.drawImage.call(t,e,n,r,o,s);}function Tt(t,e,n,r,o){return t.getImageData.call(t,e,n,r,o)}function Ct(t,e,n,r){t.putImageData.call(t,e,n,r);}function Cs(t,e,n){return t.createPattern.call(t,e,n)}function Et(t,e,n){if(typeof ImageData<"u")return new ImageData(t,e,n);if(te){let r=te.ImageData;return new r(t,e,n)}return {data:t,width:e,height:n,colorSpace:"srgb"}}function Us(t){let e=t;return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?ps(e)==="standard"?"image/jpeg":null:e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"image/gif":e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}function _s(t){if(t.kind==="rgba")return {w:t.width,h:t.height};if(t.kind!=="encoded")return null;let e=t.bytes,n=new DataView(e.buffer,e.byteOffset,e.byteLength);try{if(t.mime==="image/png"&&e.length>=24)return {w:n.getUint32(16),h:n.getUint32(20)};if(t.mime==="image/gif"&&e.length>=10)return {w:n.getUint16(6,!0),h:n.getUint16(8,!0)};if(t.mime==="image/jpeg")for(let r=2;r+9<e.length;){if(e[r]!==255){r++;continue}let o=e[r+1],s=n.getUint16(r+2);if(o>=192&&o<=207&&o!==196&&o!==200&&o!==204)return {w:n.getUint16(r+7),h:n.getUint16(r+5)};r+=2+s;}if(t.mime==="image/webp"&&e.length>=30){let r=String.fromCharCode(e[12],e[13],e[14],e[15]);if(r==="VP8X")return {w:1+(e[24]|e[25]<<8|e[26]<<16),h:1+(e[27]|e[28]<<8|e[29]<<16)};if(r==="VP8 ")return {w:n.getUint16(26,!0)&16383,h:n.getUint16(28,!0)&16383};if(r==="VP8L"){let o=n.getUint32(21,!0);return {w:(o&16383)+1,h:(o>>14&16383)+1}}}}catch{}return null}function go(t){let e=new DataView(t);if(e.byteLength<26||e.getUint8(0)!==66||e.getUint8(1)!==77)return null;let n=e.getUint32(10,true),r=Ue(e,14,n,e.byteLength-n);return r?{kind:"rgba",data:r.data,width:r.width,height:r.height}:null}var Ls=new Float32Array(1),Fm=new Uint32Array(Ls.buffer);function _(t){let e=Math.fround(t);return e<=t||Number.isNaN(e)?e:e===0?(Fm[0]=2147483649,Ls[0]):(Ls[0]=e,Fm[0]+=e>0?-1:1,Ls[0])}var Ut=Math.fround,Fn=_,Ja=new Float32Array(1),qa=new Uint32Array(Ja.buffer);function km(t){return Ja[0]=t,t>0?qa[0]-=1:t<0?qa[0]+=1:qa[0]=2147483649,Ja[0]}var ut=(t,e)=>Fn(t+e),et=(t,e)=>Fn(t-e),Z=(t,e)=>Fn(t*e);function Pt(t,e){let n=t/e;if(!Number.isFinite(n))return n;let r=Fn(n);return (e>0?r*e>t:r*e<t)&&(r=km(r)),r}function Mo(t){let e=Math.sqrt(t);if(!Number.isFinite(e))return e;let n=Fn(e);return n*n>t&&(n=km(n)),n}function kn(t){let e=Math.floor(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function Ds(t){let e=Math.ceil(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function Bn(t,e,n){return e=Ut(e),n=Ut(n),[ut(ut(Z(e,Ut(t[0])),Z(n,Ut(t[2]))),Ut(t[4])),ut(ut(Z(e,Ut(t[1])),Z(n,Ut(t[3]))),Ut(t[5]))]}var ee=(t,e)=>t>e,Gn=(t,e)=>t>=e,Oe=(t,e)=>!(t>=e),Bm=(t,e)=>!(t>e);var Eo=11920929e-14,Fs=2**30;function xn(t){let e=t>>>24;if(e<Eo)return [0,0,0,0];let n=t>>>16&255,r=t>>>8&255,o=t&255;if(Math.abs(e-255)<Eo)return [e,n,r,o];let s=Pt(e,255);return [e,Z(s,n),Z(s,r),Z(s,o)]}function On(t){let e=ut(Z(Z(t,16),16),.5);return Math.floor(e)+15>>4}function Y1(t,e,n,r,o){let s=r-e,i=o-n,a=Math.abs(s)>Math.abs(i),u=(a?e:n)>>4,l=Math.abs(a?s:i)>>4,c=e,f=n,m,b;if(i>=0?(m=n+15>>4,b=o+15>>4):(s=-s,i=-i,c=r,f=o,m=o+15>>4,b=n+15>>4),b<=m)return null;let h,p;if(s>=0)s<i?(h=0,p=s):(h=Math.trunc(s/i),p=s%i);else {let P=-s;if(P<i)h=-1,p=i-P;else {h=-Math.trunc(P/i);let E=P%i;E>0?(h--,p=i-E):p=0;}}let d=-1,x=f&15;if(x!==0)for(let P=16-x;P>0;P--){d+=p;let E=h+c;d>=0?(d-=i,c=E+1):c=E;}let y=c&15;y!==0&&(d-=(16-y)*i,c+=15);let g=c>>4;d>>=4;let M=new Int32Array(b-m);for(let P=0;P<M.length;P++){M[P]=g,g+=h;let E=d+p;E>=0?(d=E-i,g+=1):d=E;}return {kind:t,yStart:m,yEnd:b,xs:M,xMajor:a,origin:u,steps:l}}var ks=class{constructor(e,n,r={}){this.shading=r;this.edges=[];this.rows=new Map;this.colors=n;let o=[On(e[0]),On(e[2]),On(e[4]),On(e[0])],s=[On(e[1]),On(e[3]),On(e[5]),On(e[1])],i=1/0,a=-1/0;for(let u=0;u<3;u++){let l=Y1(u,o[u],s[u],o[u+1],s[u+1]);l&&(this.edges.push(l),i=Math.min(i,l.yStart),a=Math.max(a,l.yEnd));}this.yMin=i,this.yMax=a;}row(e,n=-Fs,r=Fs){if(e<this.yMin||e>=this.yMax)return null;let o=n===-Fs&&r===Fs?e:`${e}:${n}:${r}`,s=this.rows.get(o);return s===void 0&&(s=this.computeRow(e,n,r),this.rows.set(o,s)),s}computeRow(e,n,r){let o=[];for(let C of this.edges)e>=C.yStart&&e<C.yEnd&&o.push(C);if(o.length<2)return null;let s=o[0],i=o[1];s.xs[e-s.yStart]>i.xs[e-i.yStart]&&([s,i]=[i,s]);let a=s.xs[e-s.yStart],u=i.xs[e-i.yStart];if(a===u)return null;let[l,c]=this.weights(s,e),[f,m]=this.weights(i,e),b=Math.max(a,n),h=Math.min(u,r);if(b>=h)return null;let p=u-a,d=l,x=c,y=et(b,a);if(Math.abs(y)>Eo){let C=Pt(y,p);d=ut(Z(et(f,l),C),l),x=ut(Z(et(m,c),C),c);}let g=et(u,h);if(Math.abs(g)>Eo){let C=Pt(g,p);f=et(f,Z(et(f,l),C)),m=et(m,Z(et(m,c),C));}let M=h-b,P=Pt(et(f,d),M),E=Pt(et(m,x),M),[R,T,A]=this.colors,w=new Uint8Array(M*4),I=[0,0,0,0],{preset:S,adjust:v}=this.shading;for(let C=0;C<M;C++){if(S)S(et(et(1,d),x),I);else {let U=d,D=x;if(v){let L=v(et(et(1,d),x)),F=ut(x,d);if(F!==0){let B=Pt(et(1,L),F);U=Z(d,B),D=Z(x,B);}}for(let L=0;L<4;L++){let F=R[L],B=ut(Z(et(T[L],F),U),F);I[L]=ut(B,Z(et(A[L],F),D));}}d=ut(d,P),x=ut(x,E),Ka(I,w,C*4);}return {xl:b,n:M,argb:w}}weights(e,n){let r=e.xMajor?e.xs[n-e.yStart]:n,o=Pt(Math.abs(r-e.origin),e.steps);return e.kind===0?[o,0]:e.kind===1?[et(1,o),o]:[0,et(1,o)]}};function Ka(t,e,n){let r=t[0];if(!(Math.abs(r)>=Eo)){e[n]=e[n+1]=e[n+2]=e[n+3]=0;return}0>r&&(r=0),r>255&&(r=255),e[n]=Gm(r);for(let o=1;o<4;o++){let s=t[o];0>s&&(s=0),s>r&&(s=r),e[n+o]=Gm(s);}}function Gm(t){let e=Math.floor(ut(t,.5));return Number.isFinite(e)?e&255:0}function Po(t,e,n,r,o=false){if(t===0)return 0;let s=o?Pt(255,t):0,i=a=>Math.min(255,o?Math.floor(Z(a,s)):Math.round(a*255/t));return (t<<24|i(e)<<16|i(n)<<8|i(r))>>>0}var Za=t=>Fn(1-Ut(t));function Bs(t){if(!t||t.factors.length===0)return null;let e=t.factors.length;if(e===1){let o=Ut(t.factors[0]);return o===1?null:s=>o>0&&s>=0&&s<=1?Fn(Math.pow(s,o)):s}let n=t.factors.map(Za).reverse(),r=t.positions.map(Za).reverse();return o=>{if(Oe(o,0)||Oe(1,o))return o;let s=1;if(ee(et(o,r[1]),Om))for(;;){if(s++,s>=e)return o;if(!ee(et(o,r[s]),Om))break}let i=et(r[s],r[s-1]);return ee(i,0)?ut(Z(Pt(et(o,r[s-1]),i),et(n[s],n[s-1])),n[s-1]):Z(ut(n[s],n[s-1]),.5)}}var Om=11920929e-14;function Gs(t){if(!t||t.argb.length<2)return null;let e=t.argb.length,n=t.argb.map(o=>xn(o)).reverse(),r=t.positions.map(Za).reverse();return (o,s)=>{let i;if(Oe(o,0)||Oe(1,o)){i=Gn(0,o)?n[0]:n[e-1];for(let f=0;f<4;f++)s[f]=i[f];return}let a=1;for(;a<e&&ee(o,r[a]);)a++;if(a>=e){i=n[e-1];for(let f=0;f<4;f++)s[f]=i[f];return}let u=n[a-1],l=n[a],c=et(r[a],r[a-1]);if(ee(c,0)){let f=Pt(et(o,r[a-1]),c);for(let m=0;m<4;m++)s[m]=ut(Z(et(l[m],u[m]),f),u[m]);}else for(let f=0;f<4;f++)s[f]=Z(ut(l[f],u[f]),.5);}}var Os=2**30,Nm=Ut(-0.02),Wm=Ut(1.02),Fr=class{constructor(e,n){this.minX=0;this.minY=0;this.width=0;this.height=0;this.e3x=0;this.e3y=0;this.e1x=0;this.e1y=0;this.e2x=0;this.e2y=0;this.p0x=0;this.p0y=0;this.a=0;this.det=0;this.yMin=0;this.yMax=0;this.flags=[0,0,0,0];this.yTop=[0,0,0,0];this.yBottom=[0,0,0,0];this.xTop=[0,0,0,0];this.slope=[0,0,0,0];if(this.constant=n,!e)return;let[r,o,s,i]=e,a=r[0],u=r[1],l=r[0],c=r[1];for(let h=1;h<4;h++){let[p,d]=e[h];p<a?a=p:p>l&&(l=p),d<u?u=d:d>c&&(c=d);}this.minX=a,this.minY=u,this.width=et(l,a),this.height=et(c,u),this.e3x=ut(et(et(r[0],o[0]),s[0]),i[0]),this.e3y=ut(et(et(r[1],o[1]),s[1]),i[1]),this.e1x=et(o[0],r[0]),this.e1y=et(o[1],r[1]),this.e2x=et(s[0],r[0]),this.e2y=et(s[1],r[1]),this.p0x=r[0],this.p0y=r[1],this.a=this.e3x===this.e2x&&this.e3y===this.e2y?0:et(Z(this.e2y,this.e3x),Z(this.e2x,this.e3y)),this.det=et(Z(this.e1x,this.e2y),Z(this.e1y,this.e2x));let f=[r,o,i,s];this.yMin=this.yMax=f[0][1];let m=f[0][0],b=f[0][0];for(let h=0;h<4;h++){let p=f[h],d=f[h+1&3];d[1]>p[1]?(this.flags[h]=1,this.yTop[h]=p[1],this.yBottom[h]=d[1],this.xTop[h]=p[0],this.slope[h]=Pt(et(d[0],p[0]),et(d[1],p[1]))):p[1]>d[1]?(this.flags[h]=2,this.yTop[h]=d[1],this.yBottom[h]=p[1],this.xTop[h]=d[0],this.slope[h]=Pt(et(d[0],p[0]),et(d[1],p[1]))):(this.flags[h]=0,this.yTop[h]=p[1],this.yBottom[h]=p[1],this.xTop[h]=p[0],this.slope[h]=0),p[0]<m&&(m=p[0]),p[0]>b&&(b=p[0]),p[1]<this.yMin&&(this.yMin=p[1]),p[1]>this.yMax&&(this.yMax=p[1]);}}spans(e,n,r){if(this.constant<0&&this.flags.every(c=>c===0))return [];let o=e;if(ee(this.minY,o))return [];if(Gn(o,ut(this.minY,this.height)))return [];let s=n,i=r;if(ee(this.minX,i))return [];if(Gn(s,ut(this.minX,this.width)))return [];if(ee(this.yMin,o))return [];if(Gn(o,this.yMax))return [];let a=[];for(let c=0;c<4;c++)this.flags[c]&&(Oe(o,this.yTop[c])||Bm(this.yBottom[c],o)||a.push(ut(Z(et(o,this.yTop[c]),this.slope[c]),this.xTop[c])));let u=a.length&-2;if(u<2)return [];a.length=u,a.sort((c,f)=>c-f);let l=[];for(let c=0;c<u;c+=2){let f=a[c],m=a[c+1];if(Gn(f,i)||Gn(s,m))continue;f<s&&(f=s),m>i&&(m=i);let b=Ds(f),h=Ds(m);h>b&&l.push(b,h);}return l}parameter(e,n,r){if(this.constant>=0)return r[0]=r[1]=this.constant,true;let o=et(this.p0x,e),s=et(this.p0y,n),i=this.a,a=et(ut(Z(this.e3x,s),this.det),Z(this.e3y,o)),u=et(Z(this.e1x,s),Z(this.e1y,o)),l=0,c=0,f=0;if(i!==0||i!==i){let y=et(Z(a,a),Z(Z(i,4),u)),g=ut(i,i);if(ee(y,0)){l=2;let M=Mo(y),P=ut(u,u),E=Oe(a,0)?et(M,a):et(-a,M),R=Pt(P,E),T=Pt(E,g);(ee(0,R)||ee(R,1))&&(Oe(T,0)||Oe(1,T)||([R,T]=[T,R])),c=R,f=T;}else y===0&&(l=1,c=Pt(-a,g));}else {if(a===0)return false;l=1,c=Pt(-u,a);}if(l===0)return false;let[m,b]=this.solveU(c,o,s);if(l===1)return b?(r[0]=m,r[1]=c,true):false;let h=y=>!(ee(Nm,y)||ee(y,Wm)),p=y=>!(Oe(y,Nm)||Oe(Wm,y));if(b&&h(m)&&h(c))return r[0]=m,r[1]=c,true;let[d,x]=this.solveU(f,o,s);return x&&p(d)&&p(f)?(r[0]=d,r[1]=f,true):b?(r[0]=m,r[1]=c,true):false}solveU(e,n,r){let o=ut(Z(this.e3x,e),this.e1x),s=ut(Z(this.e3y,e),this.e1y);return ee(Math.abs(o),Math.abs(s))?[Pt(-ut(Z(e,this.e2x),n),o),true]:ee(Math.abs(s),0)?[Pt(-ut(Z(e,this.e2y),r),s),true]:[0,false]}},Qa=class{constructor(e,n,r,o,s){this.rows=new Map;this.quads=e,this.table=n,this.n=r,this.x0=o,this.width=s;}colorAt(e,n,r=-Os,o=Os){let s=r===-Os&&o===Os?n:`${n}:${r}:${o}`,i=this.rows.get(s);if(i===void 0&&(i=this.computeRow(n,r,o),this.rows.set(s,i)),!i)return null;let a=e-this.x0;if(a<0||a>=this.width)return null;let u=i[a];return u<0?null:u}colorForPosition(e){let n=Ut(e);return ee(0,n)?n=0:n<1||(n=1),this.table[kn(ut(Z(this.n,n),.5))]}computeRow(e,n,r){let o=null,s=[0,0],i=Math.max(n,this.x0-2),a=Math.min(r,this.x0+this.width+2);for(let u of this.quads){let l=u.spans(e,i,a);if(!l.length)continue;o||(o=new Float64Array(this.width).fill(-1)),s[0]=s[1]=0;let c=[];for(let m=0;m<l.length;m+=2)for(let b=l[m];b<l[m+1];b++)u.parameter(b,e,s),c.push(s[0]);let f=0;for(let m=0;m<l.length;m+=2)for(let b=l[m];b<l[m+1];b++){let h=this.colorForPosition(c[f++]),p=b-this.x0;p>=0&&p<this.width&&(o[p]=h);}}return o}};function tu(t,e){if(t.length===0)return 0;let n=Ut(t[0].x),r=Ut(t[0].y),o=n,s=r;for(let p of t){let d=Ut(p.x),x=Ut(p.y);d>o?o=d:d<n&&(n=d),x>s?s=x:x<r&&(r=x);}let i=et(o,n),a=et(s,r),u=(p,d)=>[ut(Z(d,Ut(e[2])),Z(p,Ut(e[0]))),ut(Z(d,Ut(e[3])),Z(p,Ut(e[1])))],l=u(0,0),c=u(i,0),f=u(i,a),m=u(0,a),b=(p,d)=>{let x=et(p[0],d[0]),y=et(p[1],d[1]);return Mo(ut(Z(x,x),Z(y,y)))},h=ut(b(c,m),b(l,f));return Math.max(1,Ds(h))}function Dr(t){return Z(kn(ut(Z(t,16),.5)),.0625)}function Hm(t,e){let n=t.boundary.length;if(n<2)return null;let r=tu(t.boundary,e),o=xn(t.centerArgb),s=xn(t.boundaryArgb[0]??4278190080),i=new Uint32Array(r+2),a=Pt(1,r),u=Bs(t.blend),l=Gs(t.preset),c=0,f=[0,0,0,0],m=new Uint8Array(4);for(let A=0;A<r+2;A++){if(l)l(c,f);else {let w=u?u(c):c;for(let I=0;I<4;I++)f[I]=ut(Z(et(s[I],o[I]),w),o[I]);}Ka(f,m,0),i[A]=(m[0]<<24|m[1]<<16|m[2]<<8|m[3])>>>0,c=ut(c,a);}let b=Bn(e,t.center.x,t.center.y),h=Dr(b[0]),p=Dr(b[1]),d=Ut(t.focus?.x??0),x=Ut(t.focus?.y??0),y=d!==0||x!==0,g=[],M=[],P=h,E=h;for(let A=0;A<n;A++){let w=A+1<n?A+1:0,I=t.boundary[A],S=t.boundary[w];if(I.x===S.x&&I.y===S.y){g.push(new Fr(null,-1)),y&&M.push(new Fr(null,-1));continue}let v=Bn(e,I.x,I.y),C=Bn(e,S.x,S.y),U=Dr(v[0]),D=Dr(v[1]),L=Dr(C[0]),F=Dr(C[1]);P=Math.min(P,U,L),E=Math.max(E,U,L);let B=h,X=p,k=h,W=p;y&&(B=ut(Z(et(U,h),d),h),k=ut(Z(et(L,h),d),h),X=ut(Z(et(D,p),x),p),W=ut(Z(et(F,p),x),p),M.push(new Fr([[h,p],[B,X],[h,p],[k,W]],0))),g.push(new Fr([[B,X],[U,D],[k,W],[L,F]],-1));}let R=Math.floor(P)-2,T=Math.ceil(E)+3-R;return new Qa(y?[...g,...M]:g,i,r,R,T)}var jm=2.2;function $1(t,e){if(t<=3)return 16;let n=Math.abs(e.w)+Math.abs(e.h);return n>512?256:n>128?64:16}function j1(t){return t.preset?t.preset.positions.length:t.blend?t.blend.positions.length:2}function V1(t,e,n){let r=Math.min(t.length,e.length);if(r===0)return n;if(n<=t[0])return e[0];for(let o=1;o<r;o++)if(n<=t[o]){let s=t[o]-t[o-1],i=s>0?(n-t[o-1])/s:1;return e[o-1]+(e[o]-e[o-1])*i}return e[r-1]}function kr(t,e){let n=t>>>24&255,r=n/255,o=s=>{let i=t>>>s&255;return (e?255*Math.pow(i/255,jm):i)*r*(n<255?1-2**-40:1)};return [o(16),o(8),o(0),n]}function Xm(t,e,n){return [t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n,t[3]+(e[3]-t[3])*n]}var eu=new Float32Array(1),z1=new Int32Array(eu.buffer);function ot(t){let e=Math.fround(t);return Math.abs(e)>Math.abs(t)?(eu[0]=e,z1[0]-=1,eu[0]):e}function q1(t,e,n){let r=Math.min(t.length,e.length);if(r===0)return n;if(n<=t[0])return e[0];for(let o=1;o<r;o++)if(n<=t[o]){let s=ot(t[o]-t[o-1]),i=s>0?ot(ot(n-t[o-1])/s):1;return ot(e[o-1]+ot(ot(e[o]-e[o-1])*i))}return e[r-1]}function J1(t,e,n){let r=ot(1-n),o=(s,i)=>ot(ot(s*r)+ot(i*n));return [o(t[0],e[0]),o(t[1],e[1]),o(t[2],e[2]),o(t[3],e[3])]}function K1(t,e){let n=t.gammaCorrected;if(t.preset&&t.preset.positions.length>0){let{positions:s,argb:i}=t.preset,a=Math.min(s.length,i.length);if(e<=s[0]||a===1)return kr(i[0],n);for(let u=1;u<a;u++)if(e<=s[u]){let l=s[u]-s[u-1],c=l>0?(e-s[u-1])/l:1;return Xm(kr(i[u-1],n),kr(i[u],n),c)}return kr(i[a-1],n)}let r=kr(t.startArgb,n),o=kr(t.endArgb,n);return t.blend&&!n?J1(r,o,q1(t.blend.positions,t.blend.factors,e)):Xm(r,o,t.blend?V1(t.blend.positions,t.blend.factors,e):e)}function Z1(t,e){if(e<=0)return 0;let n=e/255,r=Math.round(Math.min(1,Math.max(0,t/n/255))*1023)/1023;return 255*Math.pow(r,1/jm)*n}function nu(t,e){let n=$1(j1(t),e),r=new Uint8Array((n+1)*4);for(let o=0;o<=n;o++){let s=K1(t,o/n),i=o*4;for(let a=0;a<3;a++){let u=t.gammaCorrected?Z1(s[a],s[3]):s[a];r[i+a]=Math.min(255,Math.max(0,Math.floor(u+.5)));}r[i+3]=Math.min(255,Math.max(0,Math.floor(s[3]+.5)));}return {intervals:n,knots:r}}function ru(t){if(t.ramp)return t.ramp;let e=t.stops;return e.length===2&&e[0].offset===0&&e[1].offset===1&&e[0].argb!==void 0&&e[1].argb!==void 0?{startArgb:e[0].argb,endArgb:e[1].argb,preset:null,blend:null,gammaCorrected:false}:null}function Q1(t,e){let n=e*4,r=t.knots[n+3];if(r===0)return 0;let o=s=>Math.min(255,Math.round(s*255/r));return (r<<24|o(t.knots[n])<<16|o(t.knots[n+1])<<8|o(t.knots[n+2]))>>>0}function Vm(t){let e=[];for(let n=0;n<=t.intervals;n++){let r=Q1(t,n),o=(r>>>24&255)/255;e.push({offset:n/t.intervals,color:`rgba(${r>>>16&255},${r>>>8&255},${r&255},${Number(o.toFixed(4))})`,argb:r});}return e}var Ns=65536;function Ym(t,e,n){let r=(n==="tile-flip-x"||n==="tile-flip-xy"?2:1)*e*Ns;return (t%r+r)%r}function ou(t,e){return Math.min(255,Math.floor(t*Math.floor(255*65536/e)/65536))}function tx(t,e,n,r,o=false){let s=t.intervals,i=Math.floor(e/Ns),a=Math.floor(e/256)&255,u=i<=s?i:2*s-i,l=i+1<=s?i+1:Math.max(0,2*s-i-1),c=t.knots,f=Math.min(s,u)*4,m=Math.min(s,l)*4,b=c[f+3]*(256-a)+c[m+3]*a+128>>8;if(b!==0){for(let h=0;h<3;h++){let p=c[f+h]*(256-a)+c[m+h]*a+128>>8;n[r+h]=b===255?p:o?ou(p,b):Math.round(p*255/b);}n[r+3]=b;}}function ex(t,e,n,r){let o=t.intervals,s=Math.floor(e/Ns),i=Math.floor(e/256)&255,a=s<=o?s:2*o-s,u=s+1<=o?s+1:Math.max(0,2*o-s-1),l=t.knots,c=Math.min(o,a)*4,f=Math.min(o,u)*4;for(let m=0;m<4;m++)n[r+m]=l[c+m]*(256-i)+l[f+m]*i+128>>8;}function $m(t,e){return [_(_(t[0]*e[0])+_(t[1]*e[2])),_(_(t[0]*e[1])+_(t[1]*e[3])),_(_(t[2]*e[0])+_(t[3]*e[2])),_(_(t[2]*e[1])+_(t[3]*e[3])),_(_(_(t[4]*e[0])+_(t[5]*e[2]))+e[4]),_(_(_(t[4]*e[1])+_(t[5]*e[3]))+e[5])]}function nx(t){let e=_(_(t[0]*t[3])-_(t[1]*t[2]));if(e===0)return null;let n=_(1/e),r=[_(t[3]*n),_(-t[1]*n),_(-t[2]*n),_(t[0]*n),_(_(_(t[5]*t[2])-_(t[4]*t[3]))*n),_(_(_(t[4]*t[1])-_(t[5]*t[0]))*n)];return r.every(Number.isFinite)?r:null}function rx(t){let e=Math.fround(t.x),n=Math.fround(t.y),r=Math.fround(t.w),o=Math.fround(t.h),s=[e,n],i=[_(e+r),n],a=[e,_(n+o)],u=_(_(_(_(r+e)*_(n+o))-_(n*e))+_(_(-o*e)-_(n*r)));if(Math.abs(u)<11920929e-14)return [1,0,0,1,0,0];let l=_(1/u),c=_(_(_(e+r)*_(n+o))-_(e*n)),f=_(-e*o),m=_(-n*r);return [_(_(_(o*i[0])+_(-o*s[0]))*l),_(_(_(o*i[1])+_(-o*s[1]))*l),_(_(_(r*a[0])+_(-r*s[0]))*l),_(_(_(r*a[1])+_(-r*s[1]))*l),_(_(_(_(f*i[0])+_(c*s[0]))+_(m*a[0]))*l),_(_(_(_(f*i[1])+_(c*s[1]))+_(m*a[1]))*l)]}function ox(t,e,n,r){let o=Math.fround(t.x),s=Math.fround(t.y),i=Math.fround(t.w),a=Math.fround(t.h),u=r*Ns,l=_(o+i),c=_(s+a),f=_(_(l-o)/u),m=_(_(c-s)/u),b=[f,0,0,m,_(l-_(f*u)),_(c-_(m*u))],h=$m(e.map(p=>Math.fround(p)),n.map(p=>Math.fround(p)));return nx($m(b,h))}function zm(t,e,n,r=false,o={x:0,y:0}){let s=t.rect,i=ru(t);if(!s||!i||!(Math.abs(s.w)>1e-9))return null;let a=nu(i,s),u=a.intervals,l=ox(s,t.transform??rx(s),e,u);if(!l)return null;let c=n?.5:0,f=Math.floor(_(l[0]+.5)),m=Math.floor(_(l[2]+.5)),b=Math.floor(_(l[4]+(l[0]+l[2])*c+.5))-o.x*f-o.y*m,h=(p,d,x,y,g)=>{for(let M=0;M<y;M++){let P=b+p*f+(d+M)*m;for(let E=0;E<x;E++,P+=f)tx(a,Ym(P,u,t.wrapMode),g,(M*x+E)*4,r);}};return r&&(h.premultiplied=(p,d,x,y,g)=>{for(let M=0;M<y;M++){let P=b+p*f+(d+M)*m;for(let E=0;E<x;E++,P+=f)ex(a,Ym(P,u,t.wrapMode),g,(M*x+E)*4);}}),h}var To=[1,0,0,1,0,0];function Xt(t,e){return [t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}function Km(t){let e=t[0]*t[3]-t[1]*t[2];return !Number.isFinite(e)||Math.abs(e)<1e-12?null:[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e]}function Ro(t,e,n){let r=o=>{let s=t>>>o&255,i=e>>>o&255;return Math.round(s+(i-s)*n)};return (r(24)<<24|r(16)<<16|r(8)<<8|r(0))>>>0}function sx(t,e,n){let r=t>>>24&255,o=e>>>24&255;if(r===o)return Ro(t,e,n);let s=Math.round(r+(o-r)*n);if(s===0)return 0;let i=a=>{let u=(t>>>a&255)*r/255,l=(e>>>a&255)*o/255;return Math.min(255,Math.max(0,Math.round((u+(l-u)*n)*255/s)))};return (s<<24|i(16)<<16|i(8)<<8|i(0))>>>0}function Zm(t,e=To){return tu(t,e)}function ix(t,e,n){let r=Math.min(t.length,e.length);if(r===0)return n;if(n<=t[0])return e[0];for(let o=1;o<r;o++)if(n<=t[o]){let s=t[o]-t[o-1],i=s>0?(n-t[o-1])/s:1;return e[o-1]+(e[o]-e[o-1])*i}return e[r-1]}function qm(t,e){if(t.length===0||t.some(n=>n.argb===void 0))return null;if(e<=t[0].offset)return t[0].argb;for(let n=1;n<t.length;n++){let r=t[n];if(e<=r.offset){let o=t[n-1],s=r.offset-o.offset;return Ro(o.argb,r.argb,s>0?(e-o.offset)/s:1)}}return t[t.length-1].argb}function Ws(t,e,n,r,o){let{center:s,boundary:i,boundaryArgb:a}=t,u=i.length,l=e-s.x,c=n-s.y,f=(r?.x??e)-s.x,m=(r?.y??n)-s.y,b=-1,h=0,p=0,d=1e-9;for(let T=0;T<u;T++){let A=i[T],w=i[(T+1)%u],I=A.x-s.x,S=A.y-s.y,v=w.x-A.x,C=w.y-A.y,U=I*C-S*v;if(Math.abs(U)<1e-12)continue;let D=(l*C-c*v)/U,L=(I*c-S*l)/U;if(D<-d||L<-d||L>D+d||D>1+d)continue;b=T;let F=(f*C-m*v)/U,B=(I*m-S*f)/U;h=Math.max(0,F),p=F>0?Math.min(1,Math.max(0,B/F)):0;}let x=b<0?1/0:h;if(t.focus){let T=Math.min(1,Math.max(0,t.focus.x)),A=Math.min(1,Math.max(0,t.focus.y));if(T===A)x=x<=T?0:(x-T)/(1-T);else if(x>0){let w=1-T,I=1-A,S=1/0,v=false;for(let C=0;C<u;C++){let U=i[C],D=i[(C+1)%u],L=U.x-s.x,F=U.y-s.y,B=D.x-U.x,X=D.y-U.y,k=L*X-F*B;if(Math.abs(k)<1e-12)continue;if(T===0&&A>0&&Math.abs((r?.x??e)-s.x)<d&&B>0&&Math.max(L,L+B)>0&&Math.abs(X)>d){let Y=(((r?.y??n)-s.y)/A-F)/X;Y>=-d&&Y<=1+d&&(v=true);}if((T>0||Math.abs(l)<d)&&(A>0||Math.abs(c)<d)){let Y=T>0?l/T:0,N=A>0?c/A:0,G=(Y*X-N*B)/k,j=(L*N-F*Y)/k;G>=-d&&G<=1+d&&j>=-d&&j<=G+d&&(v=true,b<0&&(b=C));}let W=k*w*I,O=k*(T*I+A*w)-l*X*I+c*B*w,q=k*T*A-l*X*A+c*B*T,Q=O*O-4*W*q,K=Math.abs(W)<1e-12?Math.abs(O)>1e-12?[-q/O]:[]:Q>=0?[(-O-Math.sqrt(Q))/(2*W),(-O+Math.sqrt(Q))/(2*W)]:[],V=0,rt=0,H=0;for(let Y of K){if(Y<-d||Y>1+d)continue;let N=T+w*Y,G=A+I*Y;if(G===0&&N>0&&Math.abs(c)<d&&X>0&&Math.max(F,F+X)>0&&Math.abs(B)>d){let tt=(l/N-L)/B;if(tt>=-d&&tt<=1+d){V=1,rt=0,H=Math.min(1,Math.max(0,tt));break}}if(N<=0||G<=0)continue;let j=Math.abs(B)>Math.abs(X)?(l/N-L)/B:(c/G-F)/X;j>=-d&&j<=1+d&&(V++,rt=Math.max(0,Y),H=Math.min(1,Math.max(0,j)));}V===1&&(S=rt,b=C,p=H);}x=v?0:Number.isFinite(S)?S:x;}}if(b<0||!Number.isFinite(x))return null;o&&(o.s=x);let y=1-x;if(t.preset&&t.preset.positions.length>0){let{positions:T,argb:A}=t.preset;if(y<=T[0])return A[0];for(let w=1;w<T.length;w++)if(y<=T[w]){let I=T[w]-T[w-1];return Ro(A[w-1],A[w],I>0?(y-T[w-1])/I:1)}return A[T.length-1]}let g=a[b]??t.centerArgb,M=a[(b+1)%u]??g,P=Ro(g,M,p),E=t.blend?ix(t.blend.positions,t.blend.factors,y):y,R=Math.min(1,Math.max(0,E));return P>>>24!==t.centerArgb>>>24&&a.every(T=>T===a[0])?sx(P,t.centerArgb,R):Ro(P,t.centerArgb,R)}var ax=2048;function Qm(t){return {x:t==="tile-flip-x"||t==="tile-flip-xy",y:t==="tile-flip-y"||t==="tile-flip-xy"}}function Hs(t,e,n,r,o,s,i,a,u){if(typeof t.createPattern!="function")return null;let l=o==="clamp"?{x:false,y:false}:Qm(o),c=n*(l.x?2:1),f=r*(l.y?2:1),m=It(c,f);if(!m)return null;let b=e.w/n,h=e.h/r,p=P=>{let E=P%n*b+(.5+a.phaseX)*b;return P<n?E:e.w-a.lagX-(E-(.5+a.phaseX)*b)-.5*b},d=P=>{let E=(P%r+.5)*h;return P<r?E:e.h-a.lagY-E},x=new Uint8ClampedArray(c*f*4);for(let P=0;P<f;P++){let E=e.y+d(P);for(let R=0;R<c;R++){let T=u(e.x+p(R),E);if(T===null)continue;let A=(P*c+R)*4;x[A]=T>>>16&255,x[A+1]=T>>>8&255,x[A+2]=T&255,x[A+3]=T>>>24&255;}}Ct(m.ctx,Et(x,c,f),0,0);let y=Cs(t,m.canvas,o==="clamp"?"no-repeat":"repeat");if(!y||typeof y.setTransform!="function")return null;let g=[b,0,0,h,e.x+a.phaseX*b,e.y],M=Xt([1,0,0,1,i.x,i.y],Xt(s,g));try{y.setTransform({a:M[0],b:M[1],c:M[2],d:M[3],e:M[4],f:M[5]});}catch{return null}return y}function Ao(t){let e=Km(t);return e?{x:e[0]*.5+e[2]*.5,y:e[1]*.5+e[3]*.5}:{x:0,y:0}}var ux=4;function su(t,e,n){let r=e==="x"?Math.hypot(t[0],t[1]):Math.hypot(t[2],t[3]);return Math.max(2,Math.min(ax,Math.ceil(Math.abs(n)*r*ux)))}function tf(t,e){let n=e??To,r=(c,f)=>({x:n[0]*c+n[2]*f+n[4],y:n[1]*c+n[3]*f+n[5]}),o=r(t.x,t.y+t.h/2),s=r(t.x+t.w,t.y+t.h/2),i=n[3],a=-n[2],u=i*i+a*a;if(u<1e-12)return {x1:o.x,y1:o.y,x2:s.x,y2:s.y};let l=((s.x-o.x)*i+(s.y-o.y)*a)/u;return {x1:o.x,y1:o.y,x2:o.x+i*l,y2:o.y+a*l}}function lx(t,e){if(typeof t.createLinearGradient!="function")return null;let n=e.rect?tf(e.rect,e.transform):e;if(n.x1===n.x2&&n.y1===n.y2)return null;let r=t.createLinearGradient(n.x1,n.y1,n.x2,n.y2);for(let o of e.stops)r.addColorStop(o.offset,o.color);return r}var Jm=1e-5,cx=2048;function mx(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}function fx(t,e,n,r){let o=mx(t),s=Km(r);if(!o||!s||typeof t.createLinearGradient!="function")return null;let i=tf(n,e.transform),a=Ao(r),u=i.x2-i.x1,l=i.y2-i.y1,c=i.x1+a.x+u*Jm,f=i.y1+a.y+l*Jm,m=u*u+l*l;if(!(m>1e-12))return null;let b=1/0,h=-1/0;for(let[P,E]of [[0,0],[o.w,0],[0,o.h],[o.w,o.h]]){let R=P-r[4],T=E-r[5],A=s[0]*R+s[2]*T,w=s[1]*R+s[3]*T,I=((A-c)*u+(w-f)*l)/m;b=Math.min(b,I),h=Math.max(h,I);}let p=Math.floor(b),d=Math.max(p+1,Math.ceil(h));if(d-p>cx)return null;let x=t.createLinearGradient(c+u*p,f+l*p,c+u*d,f+l*d),y=d-p,g=Qm(e.wrapMode).x,M=[...e.stops].reverse();for(let P=p;P<d;P++){let E=g&&(P%2+2)%2===1;for(let R of E?M:e.stops){let T=E?1-R.offset:R.offset;x.addColorStop(Math.min(1,Math.max(0,(P-p+T)/y)),R.color);}}return x}function bx(t){let e=t.rect?ru(t):null;return e&&t.rect?Vm(nu(e,t.rect)):t.stops}function hx(t,e,n){let r={...e,stops:bx(e)},o=r.rect;if(r.wrapMode!=="clamp"&&o&&o.w!==0){let s=fx(t,r,o,n);if(s)return s;if(qm(r.stops,0)!==null){let i=r.transform??To,a=su(Xt(n,i),"x",o.w),u=Hs(t,o,a,1,r.wrapMode,i,Ao(n),{phaseX:.5,lagX:0,lagY:0},l=>qm(r.stops,(l-o.x)/o.w));if(u)return u}}return lx(t,r)}function px(t){if(t.length<3)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of t)e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),o=Math.max(o,s.y);return r>e&&o>n?{x:e,y:n,w:r-e,h:o-n}:null}function dx(t,e,n,r){let o=px(e.boundary);if(!o)return null;let s=e.transform??To,i=Xt(r,s),a=Math.hypot(i[0],i[1]),u=Math.hypot(i[2],i[3]);return Hs(t,o,su(i,"x",o.w),su(i,"y",o.h),n,s,Ao(r),{phaseX:0,lagX:a>0?1/a:0,lagY:u>0?1/u:0},(l,c)=>Ws(e,l,c))}function xx(t,e){if(!(e.r>0)||typeof t.createRadialGradient!="function")return null;let n=t.createRadialGradient(e.cx,e.cy,0,e.cx,e.cy,e.r);for(let r of e.stops)n.addColorStop(r.offset,r.color);return n}function ef(t,e,n=To){try{if(e.type==="linear")return hx(t,e,n);if(e.shape){let r=dx(t,e.shape,e.wrapMode,n);if(r)return r;$("createBrushGradient: path gradient pattern unavailable, using the radial approximation");}return xx(t,e)}catch{return null}}var yx=Uint8Array.from({length:256},(t,e)=>e);function nf(t,e){return yx}var gx={"633C80A4-1843-482B-9EF2-BE2834C5FDD4":"blur","D3A1DBE1-8EC4-4C17-9F4C-EA97AD1C343D":"brightnessContrast","537E597D-251E-48DA-9664-29CA496B70F8":"colorBalance","DD6A0022-58E4-4A67-9D9B-D48EB881A53D":"colorCurve","A7CE72A9-0F7F-40D7-B3CC-D0C02D5C3212":"colorLookupTable","718F2615-7933-40E3-A511-5F68FE14DD74":"colorMatrix","8B2DD6C3-EB07-4D87-A5F0-7108E26A9C5F":"hueSaturationLightness","99C354EC-2A31-4F3A-8C34-17A803B33A25":"levels","74D29D05-69A4-4266-9549-3CC52836B632":"redEyeCorrection","63CBF3EE-C526-402C-8F71-62C540BF5142":"sharpen","1077AF00-2848-4441-9489-44AD4C2D7A2C":"tint"},af=8192;var Br={All:0,Red:1,Green:2,Blue:3},Xs=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0");function Mx(t,e){let n=[];for(let r=0;r<8;r++)n.push(Xs(t.getUint8(e+8+r),2));return [Xs(t.getUint32(e,true),8),Xs(t.getUint16(e+4,true),4),Xs(t.getUint16(e+6,true),4),n.slice(0,2).join(""),n.slice(2).join("")].join("-")}var kt=(t,e,n)=>t<e?e:t>n?n:t,Ex=12;function uf(t,e,n){if(n<20||e<0||e+n>t.byteLength)return null;let r=gx[Mx(t,e)],o=t.getUint32(e+16,true);if(!r||20+o>n)return null;let s=e+20,i=(l,c,f)=>kt(t.getInt32(s+4*l,true),c,f),a=(l,c,f)=>{let m=t.getFloat32(s+4*l,true);return Number.isFinite(m)?kt(m,c,f):0},u=l=>o>=l;switch(r){case "blur":return u(8)?{kind:r,radius:a(0,0,255),expandEdge:t.getUint32(s+4,true)!==0}:null;case "brightnessContrast":return u(8)?{kind:r,brightness:i(0,-255,255),contrast:i(1,-100,100)}:null;case "colorBalance":return u(12)?{kind:r,cyanRed:i(0,-100,100),magentaGreen:i(1,-100,100),yellowBlue:i(2,-100,100)}:null;case "colorCurve":{if(!u(Ex))return null;let l=t.getInt32(s,true),c=t.getInt32(s+4,true),f=t.getInt32(s+8,true),m=l<2?-255:l<6?-100:l===6?1:0,b=l===7?254:l<2||l===6?255:100;return l<0||l>7||c<0||c>3||f<m||f>b?null:{kind:r,adjustment:l,channel:c,intensity:f}}case "colorLookupTable":{if(!u(1024))return null;let l=c=>new Uint8Array(t.buffer.slice(t.byteOffset+s+256*c,t.byteOffset+s+256*(c+1)));return {kind:r,b:l(0),g:l(1),r:l(2),a:l(3)}}case "colorMatrix":{if(!u(100))return null;let l=[];for(let c=0;c<25;c++){let f=t.getFloat32(s+4*c,true);if(!Number.isFinite(f))return null;l.push(f);}return {kind:r,matrix:l}}case "hueSaturationLightness":return u(12)?{kind:r,hue:i(0,-180,180),saturation:i(1,-100,100),lightness:i(2,-100,100)}:null;case "levels":return u(12)?{kind:r,highlight:i(0,0,100),midtone:i(1,-100,100),shadow:i(2,0,100)}:null;case "redEyeCorrection":{if(!u(4))return null;let l=t.getInt32(s,true);if(l<0||4+16*l>o)return null;let c=[];for(let f=0;f<l;f++){let m=s+4+16*f;c.push({left:t.getInt32(m,true),top:t.getInt32(m+4,true),right:t.getInt32(m+8,true),bottom:t.getInt32(m+12,true)});}return {kind:r,areas:c}}case "sharpen":return u(8)?{kind:r,radius:a(0,0,255),amount:a(1,0,100)}:null;case "tint":return u(8)?{kind:r,hue:i(0,-180,180),amount:i(1,-100,100)}:null}}var lf=t=>Math.ceil(t-.5);function lu(t,e=Math.round){let n=new Uint8Array(256);for(let r=0;r<256;r++)n[r]=kt(e(t(r)),0,255);return n}function rf(t){let e=1,n=0,r=50;for(;Math.abs(t)>=r&&r<100;)e++,n=r,r=(r+100)/2;return e=Math.abs(t)===100?10:Math.min(10,ot(e+ot(ot(Math.abs(t)-n)/ot(r-n)))),t<0?ot(e):ot(1/ot(e))}function Px(t,e){let n=e>=100?1e6:e>=0?100/(100-e):(100+e)/100,r=t/2;return lu(o=>(o+r-127.5)*n+127.5+r)}function iu(t){return lu(e=>e*(Math.floor((1+t/100)*65536)/65536))}function Rx(t,e){if(!Number.isInteger(t)||t<0||t>7)return null;return nf().slice()}function Tx(t,e,n){if(t!==n){let i=t>n,a=ot((i?n:t)*255/100),u=ot((i?t:n)*255/100),l=ot(1/ot(u-a)),c=rf(e),f=new Uint8Array(256);for(let m=0;m<256;m++){let b=kt(ot(ot(m-a)*l),0,1);e!==0&&(b=ot(b**c));let h=i?ot(255*b):ot(255-ot(255*b));f[m]=kt(Math.floor(h+.5),0,255);}return f}let r=n*255/100-(t===n&&n<50?1:0),o=t===n?1:(t-n)*255/100,s=rf(e);return lu(i=>{let a=kt((i-r)/o,0,1);return 255*(t>=n?a**s:1-(1-a)**s)},lf)}function wo(t,e,n,r,o=null){let s=new Uint8ClampedArray(t);for(let i=0;i<s.length;i+=4)e&&(s[i]=e[t[i]]),n&&(s[i+1]=n[t[i+1]]),r&&(s[i+2]=r[t[i+2]]),o&&(s[i+3]=o[t[i+3]]);return s}function Ax(t,e){let n=new Uint8ClampedArray(t.length);for(let r=0;r<t.length;r+=4){let o=t[r]/255,s=t[r+1]/255,i=t[r+2]/255,a=t[r+3]/255;for(let u=0;u<4;u++){let l=o*e[u]+s*e[5+u]+i*e[10+u]+a*e[15+u]+e[20+u];n[r+u]=Math.round(kt(l,0,1)*255);}}return n}var $e=43,Ys=255;function wx(t,e,n){let r=Math.max(t,e,n),o=r-Math.min(t,e,n),s=u=>Math.floor(u*$e/o);if(r===t&&e>=n)return s(e-n);if(r===n&&n!==t)return t>=e?170+s(t-e):127+s(n-e);if(r===e)return n>=t?86+s(n-t):43+s(e-t);let i=s(n-e),a=(256-i-(i>=40?1:0))%256;return a-Math.floor((a+42)/86)}function Ix(t,e,n,r){let o=new Uint8ClampedArray(t),s=Math.round(e*Ys/360),i=65536+Math.floor(n*65536/100),a=Math.round(255*Math.floor(r*65536/100)/65536);for(let u=0;u<t.length;u+=4){let l=t[u],c=t[u+1],f=t[u+2],m=Math.max(l,c,f),b=Math.min(l,c,f),h=kt((m+b>>1)+a,0,255);if(m===b){o[u]=o[u+1]=o[u+2]=h;continue}let p=m+b,d=kt(Math.round(Math.floor((m-b)*255/(p<=255?p:510-p))*i/65536),0,255),x=h<=127?Math.floor(h*(255+d)/255):h+d-Math.floor(h*d/255),y=2*h-x,g=x,M=((wx(l,c,f)+s)%Ys+Ys)%Ys,P=M+Math.floor((M+41)/85),E=Math.min(5,Math.floor(P/$e)),R=P-E*$e,T=y+Math.floor((g-y)*R/$e),A=y+Math.floor((g-y)*($e-R)/$e),[w,I,S]=[[g,T,y],[A,g,y],[y,g,T],[y,A,g],[T,y,g],[g,y,A]][E];o[u]=w,o[u+1]=I,o[u+2]=S;}return o}function Sx(t,e,n){let r=(Math.round(e*255/360)+256)%256,o=(r+Math.floor((r+41)/85))%258,s=Math.min(5,Math.floor(o/$e)),i=o-s*$e,a=Math.floor(Nn*i/$e),u=Math.floor(Nn*($e-i)/$e),[l,c,f]=[[Nn,a,0],[u,Nn,0],[0,Nn,a],[0,u,Nn],[a,0,Nn],[Nn,0,u]][s],m=Math.sign(n)*Math.floor((255*Math.abs(n)+49)/100),b=255-m,h=new Uint8ClampedArray(t);for(let p=0;p<t.length;p+=4){let d=t[p],x=t[p+1],y=t[p+2],g=m*Math.max(d,x,y)>>8,M=b*d+l*g,P=b*x+c*g,E=b*y+f*g,R=54*d+183*x+19*y-(54*(M>>8)+183*(P>>8)+19*(E>>8));h[p]=R+M>>8,h[p+1]=R+P>>8,h[p+2]=R+E>>8;}return h}var Nn=254;function vx(t,e,n,r){let o=new Uint8ClampedArray(t),s={x:0,y:0,set:false};for(let i of r)Ox(o,e,kt(i.left,0,e),kt(i.top,0,n),kt(i.right,0,e),kt(i.bottom,0,n),s);return o}var $s=60,Cx=15,Ux=2/9,_x=1;function Lx(t,e){return Math.floor((9*t+2*e+5)/11)}var au=5/16,of=[25,40,80],Dx=[.25,.5,.66,.75],Fx=40,kx=.33,Bx=5;function Gx(t,e,n){let r=0,o=0,s=0;for(let i=0;i<n;i++)for(let a=0;a<e;a++){let u=255-t[i*e+a];r=ot(r+ot(u*a)),o=ot(o+ot(u*i)),s=ot(s+u);}return {cx:ot(ot(r/s)+.5),cy:ot(ot(o/s)+.5)}}function Ox(t,e,n,r,o,s,i){let a=o-n,u=s-r,l=a*u;if(!(l>0))return;let c=new Float64Array(l),f=new Float64Array(l),m=new Int32Array(l),b=0,h=0,p=0;for(let Q=0;Q<u;Q++)for(let K=0;K<a;K++){let V=((r+Q)*e+n+K)*4,rt=t[V],H=t[V+1],Y=t[V+2],N=Q*a+K;f[N]=H+Ux*Y;let G=Lx(H,Y);m[N]=G;let j=rt-Math.max(H,Y);if(j>0){c[N]=j;let tt=ot(G>=1?j/G:_x);b=ot(b+ot(tt*K)),h=ot(h+ot(tt*Q)),p=ot(p+tt);}}if(p===0)return;i.set&&(b=ot(b+ot(i.x-.5)),h=ot(h+ot(i.y-.5)));let d=ot(ot(b/p)+.5),x=ot(ot(h/p)+.5);i.x=n+d,i.y=r+x,i.set=true;let y=false;Math.hypot(d-a/2,x-u/2)>=(a+u)/6&&(y=true,{cx:d,cy:x}=Gx(m,a,u));let g=n+d,M=r+x,P=Math.round(d)>a/2?a-d+.5:d-.5,E=Math.round(x)>u/2?u-x+.5:x-.5,R=g>M?Math.min(P,M-.5):Math.min(E,g-.5);if(!(R>0))return;let T=Int32Array.from(m).sort(),A=T[Math.floor(.7*l)],w=A-T[Math.floor(.3*l)],I=T[l-1],S=l>1?T[l-2]:-1,v=-1;I>S&&I-A>=Fx&&(v=m.indexOf(I));let C=0;for(;C<of.length&&w>of[C];)C++;let U=Dx[C],D=new Uint8Array(l),L=new Float64Array(l),F=new Float64Array($s),B=new Float64Array($s),X=new Float64Array($s),k=180/Math.PI,W=ot(R*R);for(let Q=0;Q<u;Q++)for(let K=0;K<a;K++){let V=K+.5-d,rt=Q+.5-x,H=Q*a+K,Y=ot(ot(V*V)+ot(rt*rt));L[H]=ot(Math.sqrt(Y));let N=Math.atan2(rt,V)*k;N<0&&(N+=360);let G=V===0&&rt===0?Cx:rt===0?0:Math.min($s-1,Math.floor(N/6));D[H]=G,Y<W&&(F[G]+=c[H],B[G]+=f[H],X[G]++);}v>=0&&!(L[v]<R)&&(v=-1);let O=ot,q=O(U);for(let Q=0;Q<u;Q++)for(let K=0;K<a;K++){let V=Q*a+K,rt=c[V];if(rt<=0||L[V]>=R)continue;let H=D[V],Y=O(F[H]/X[H]),N=O(B[H]/X[H]),G=N>0?O(f[V]/N):1,j=O(1-O(L[V]/R)),tt=G<2?O(.5*O(O(1-G)*O(1-G))):0,lt=Math.max(O(q*O(j*j)),tt,y?O(kx*j):0),ct=O(O(1-lt)*Y);if(v>=0){let at=K-v%a,mt=Q-Math.floor(v/a);ct=Math.min(ct,Bx*(at*at+mt*mt));}if(ct>=rt)continue;let ht=rt-ct,ft=((r+Q)*e+n+K)*4;t[ft]=Math.round(t[ft]-(1-au)*ht),t[ft+1]=Math.round(t[ft+1]+au*ht),t[ft+2]=Math.round(t[ft+2]+au*ht);}}function cf(t){let e=Math.ceil(t),n=new Float64Array(2*e+1);if(e===0)return n[0]=1,n;let r=ot(ot(1.4)/Math.fround(t)),o=new Float64Array(e+1);o[0]=1;let s=0,i=1;for(let u=1;u<=e;u++)s=ot(s+r),o[u]=ot(Math.exp(-ot(s*s))),i=ot(i+ot(2*o[u]));let a=ot(256/i);for(let u=0;u<=e;u++){let l=ot(o[u]*a)/256;n[e+u]=l,n[e-u]=l;}return n}function uu(t,e){if(e===1)return 0;for(;t<0||t>=e;)t=t<0?-t:2*(e-1)-t;return t}function mf(t,e,n,r,o=0,s=false,i=Math.ceil(n/e)){let a=cf(r),u=(a.length-1)/2,l=(u|1)>=e?m=>Math.max(0,Math.min(e-1,m)):m=>uu(m,e),c=(u|1)>=n?m=>Math.max(0,Math.min(n-1,m)):m=>uu(m,n),f=new Float64Array(e*n*4);for(let m=0;m<n;m++){let b=m*e*4;for(let h=0;h<e;h++){let p=0,d=0,x=0,y=0;for(let M=-u;M<=u;M++){let P=b+l(h+M)*4,E=M===0?a[u]*128:a[M+u]*256,R=M===0?2:1;p+=R*Math.round(E*t[P]),d+=R*Math.round(E*t[P+1]),x+=R*Math.round(E*t[P+2]),y+=R*Math.round(E*t[P+3]);}let g=b+h*4;f[g]=Math.floor((p+128)/256),f[g+1]=Math.floor((d+128)/256),f[g+2]=Math.floor((x+128)/256),f[g+3]=Math.floor((y+128)/256);}}if(u>0&&o>=0&&o<n){let m=f.slice(),b=Math.min(n,o+i);for(let h=o;h<b;h++){let p=new Float64Array(e*4);for(let d=-u;d<=u;d++){let x=h+d;if(s&&x<o)continue;let y=c(x)*e*4,g=d===0?a[u]*128:a[d+u]*256,M=d===0?2:1;for(let P=0;P<e*4;P++)p[P]+=M*Math.round(g*m[y+P])/256;}f.set(p,h*e*4);}}return f}function ff(t){return t<20?1:t<40?2:t<=80?4:t<160?8:16}function sf(t,e,n,r,o,s,i,a={start:0,size:t,pad:0}){let u=Math.ceil(a.size/n),l=u+2*a.pad,c=(r.length-1)/2,f=(c|1)>=o?d=>kt(d,0,l-1):d=>uu(d,l),m=new Float64Array(l),b=new Float64Array(l),h=r.map(d=>d*256),p=h[c]/2;h[c]=0;for(let d=0;d<e;d++)for(let x=0;x<4;x++){for(let M=a.pad;M<a.pad+u;M++){let P=a.start+(M-a.pad)*n,E=Math.min(a.start+a.size,P+n),R=0;for(let T=P;T<E;T++)R+=s(T,d,x);m[M]=Math.floor(R/(E-P));}for(let M=0;M<l;M++){let P=0;if(M>=c&&M+c<l)for(let E=0;E<h.length;E++)P+=Math.round(h[E]*m[M-c+E]);else for(let E=0;E<h.length;E++){let R=M-c+E;P+=Math.round(h[E]*(a.zeroOutside&&(R<0||R>=l)?0:m[f(R)]));}P+=2*Math.round(p*m[M]),b[M]=Math.floor((P+128)/256);}let y=u===1&&a.pad>0,g=u===1&&a.size-Math.ceil(n/2)===1?a.start+a.size-1:-1;for(let M=0;M<t;M++){if(M===g){a.pad>0&&i(M,d,x,0);continue}let P=(M-a.start+.5)/n-.5;if(y){let T=Math.abs(M-a.start-(Math.min(a.size,n/2)-.5))/n;i(M,d,x,kt(Math.floor((1+T)*b[a.pad]+1e-9),0,255));continue}let E=kt(Math.floor(P),0,Math.max(0,u-2)),R=P-E;i(M,d,x,kt(Math.floor((1-R)*b[a.pad+E]+R*b[a.pad+Math.min(u-1,E+1)]+1e-9),0,255));}}}function cu(t,e,n,r,o,s=false){let i=ff(r);if(i===1)return mf(t,e,n,r);let a=cf(r/i),u=o?Math.ceil(Math.ceil(r)/i):0,l=o?{start:o.x,size:o.w,pad:u,zeroOutside:true}:s?{start:0,size:e,pad:0,zeroOutside:true}:void 0,c=o?{start:o.y,size:o.h,pad:u,zeroOutside:true}:s?{start:0,size:n,pad:0,zeroOutside:true}:void 0,f=new Uint8Array(t);sf(e,n,i,a,Math.ceil(e/i),(b,h,p)=>t[(h*e+b)*4+p],(b,h,p,d)=>{f[(h*e+b)*4+p]=d;},l);let m=Float64Array.from(f);return sf(n,e,i,a,Math.ceil(n/i),(b,h,p)=>f[(b*e+h)*4+p],(b,h,p,d)=>{m[(b*e+h)*4+p]=d;},c),m}function Nx(t,e,n,r){return Uint8ClampedArray.from(cu(t,e,n,r),Math.round)}function Wx(t,e){return lf(64*e/(250-2*e))/64}function Hx(t,e,n,r,o){let s=cu(t,e,n,r),i=Wx(r,o),a=new Uint8ClampedArray(t);for(let u=0;u<t.length;u+=4){for(let l=0;l<3;l++)a[u+l]=Math.round(t[u+l]+i*(t[u+l]-Math.round(s[u+l])));a[u+3]=Math.max(t[u+3],a[u],a[u+1],a[u+2]);}return a}function Xx(t,e,n,r){if(e<=0||n<=0||t.length!==e*n*4)return null;switch(r.kind){case "blur":return Nx(t,e,n,r.radius);case "sharpen":return Hx(t,e,n,r.radius,r.amount);case "brightnessContrast":{let o=Px(r.brightness,r.contrast);return wo(t,o,o,o)}case "colorBalance":return wo(t,iu(r.cyanRed),iu(r.magentaGreen),iu(r.yellowBlue));case "colorCurve":{let o=Rx(r.adjustment,r.intensity),s=r.channel;if(!o||s<Br.All||s>Br.Blue)return null;let i=a=>s===Br.All||s===a?o:null;return wo(t,i(Br.Red),i(Br.Green),i(Br.Blue))}case "colorLookupTable":return wo(t,r.r,r.g,r.b,r.a);case "colorMatrix":return Ax(t,r.matrix);case "hueSaturationLightness":return Ix(t,r.hue,r.saturation,r.lightness);case "levels":{let o=Tx(r.highlight,r.midtone,r.shadow);return wo(t,o,o,o)}case "redEyeCorrection":return vx(t,e,n,r.areas);case "tint":return Sx(t,r.hue,r.amount)}}function js(t,e,n,r,o,s,i,a,u,l){for(let c=0;c<s;c++){let f=((r+c)*e+n)*4;i.set(t.subarray(f,f+o*4),((l+c)*a+u)*4);}}function Yx(t,e,n,r,o,s,i,a,u){let l=Math.ceil(r),c=i-o+2*l,f=a-s+2*l,m=new Uint8ClampedArray(c*f*4);if(u)js(t,e,o,s,i-o,a-s,m,c,l,l);else {let x=Math.max(0,o-l),y=Math.max(0,s-l),g=Math.min(e,i+l),M=Math.min(n,a+l);js(t,e,x,y,g-x,M-y,m,c,x-(o-l),y-(s-l));}let b=ff(r)>1?cu(m,c,f,r,u?{x:l,y:l,w:i-o,h:a-s}:void 0,true):mf(m,c,f,r,u?l:0,u,Math.ceil((a-s)/(i-o))),h=i-o,p=new Uint8ClampedArray(h*(a-s)*4),d=new Uint8ClampedArray((a-s)*4);for(let x=0;x<a-s;x++){let y=((x+l)*c+l)*4;for(let g=0;g<h*4;g++)p[x*h*4+g]=Math.round(b[y+g]);for(let g=0;g<4;g++)d[x*4+g]=Math.round(b[y+h*4+g]);}return {out:p,halo:d}}function bf(t){let e=new Uint8ClampedArray(t);for(let n=0;n<e.length;n+=4){let r=e[n+3];if(r!==255)for(let o=0;o<3;o++)e[n+o]=r===0?0:Math.min(255,Math.floor(Math.round(e[n+o]*r/255)*255/r));}return e}function hf(t,e,n,r,o){if(e<=0||n<=0||t.length!==e*n*4)return null;let s=0,i=0,a=e,u=n;if(o&&(s=kt(Math.floor(o.x),0,e),i=kt(Math.floor(o.y),0,n),a=kt(Math.ceil(o.x+o.w)+1,0,e),u=kt(Math.ceil(o.y+o.h)+1,0,n),a<=s||u<=i||o.x+o.w<=s||o.y+o.h<=i))return null;let l=a-s,c=u-i,f=o?Math.min(l,Math.ceil(o.x+o.w)-s):l,m=o?Math.min(c,Math.ceil(o.y+o.h)-i):c,b=x=>{if(f===l&&m===c)return {rgba:x,x:s,y:i,width:l,height:c};let y=new Uint8ClampedArray(f*m*4);return js(x,l,0,0,f,m,y,f,0,0),{rgba:y,x:s,y:i,width:f,height:m}};if(o&&r.kind==="blur"&&r.expandEdge){let x=Math.ceil(o.x+o.w)<e&&Math.ceil(o.y+o.h)<n,{out:y,halo:g}=Yx(t,e,n,r.radius,s,i,a,u,x),M=b(y);return f===l&&m===c&&(M.haloRight=g),M}let h=t;(l!==e||c!==n)&&(h=new Uint8ClampedArray(l*c*4),js(t,e,s,i,l,c,h,l,0,0));let p=r.kind==="redEyeCorrection"?{kind:r.kind,areas:r.areas.map(x=>({left:x.left-s,top:x.top-i,right:x.right-s,bottom:x.bottom-i}))}:r,d=Xx(h,l,c,p);return d?b(d):null}function pf(t,e,n,r,o,s){let i=Math.abs(o),a=o>0,l=n*4+3&-4,c=l*r,f=new Uint8Array(c);for(let m=0;m<r;m++){let b=a?m:r-1-m,h=e+b*i,p=(r-1-m)*l;switch(s){case 2498570:case 925707:{for(let d=0;d<n;d++){let x=h+d*4;if(x+3>=t.byteLength)break;let y=t.getUint8(x),g=t.getUint8(x+1),M=t.getUint8(x+2),P=t.getUint8(x+3);s===925707&&P>0&&P<255&&(M=Math.min(255,Math.round(M*255/P)),g=Math.min(255,Math.round(g*255/P)),y=Math.min(255,Math.round(y*255/P)));let E=p+d*4;f[E]=y,f[E+1]=g,f[E+2]=M,f[E+3]=P;}break}case 139273:{for(let d=0;d<n;d++){let x=h+d*4;if(x+3>=t.byteLength)break;let y=p+d*4;f[y]=t.getUint8(x),f[y+1]=t.getUint8(x+1),f[y+2]=t.getUint8(x+2),f[y+3]=255;}break}case 137224:{for(let d=0;d<n;d++){let x=h+d*3;if(x+2>=t.byteLength)break;let y=p+d*4;f[y]=t.getUint8(x),f[y+1]=t.getUint8(x+1),f[y+2]=t.getUint8(x+2),f[y+3]=255;}break}default:return null}}return $x(f,l,n,r,c)}function df(t,e,n,r,o,s){let i=Math.abs(o),a=o>0,u=new Uint8ClampedArray(n*r*4);for(let l=0;l<r;l++){let c=a?l:r-1-l,f=e+c*i,m=l*n*4;switch(s){case 2498570:case 925707:{for(let b=0;b<n;b++){let h=f+b*4;if(h+3>=t.byteLength)break;let p=t.getUint8(h),d=t.getUint8(h+1),x=t.getUint8(h+2),y=t.getUint8(h+3);s===925707&&y>0&&y<255&&(x=Math.min(255,Math.round(x*255/y)),d=Math.min(255,Math.round(d*255/y)),p=Math.min(255,Math.round(p*255/y)));let g=m+b*4;u[g]=x,u[g+1]=d,u[g+2]=p,u[g+3]=y;}break}case 139273:{for(let b=0;b<n;b++){let h=f+b*4;if(h+3>=t.byteLength)break;let p=m+b*4;u[p]=t.getUint8(h+2),u[p+1]=t.getUint8(h+1),u[p+2]=t.getUint8(h),u[p+3]=255;}break}case 137224:{for(let b=0;b<n;b++){let h=f+b*3;if(h+2>=t.byteLength)break;let p=m+b*4;u[p]=t.getUint8(h+2),u[p+1]=t.getUint8(h+1),u[p+2]=t.getUint8(h),u[p+3]=255;}break}default:return null}}return u}function $x(t,e,n,r,o){let a=122+o,u=new ArrayBuffer(a),l=new DataView(u),c=new Uint8Array(u);return l.setUint8(0,66),l.setUint8(1,77),l.setUint32(2,a,true),l.setUint32(6,0,true),l.setUint32(10,122,true),l.setUint32(14,108,true),l.setInt32(18,n,true),l.setInt32(22,r,true),l.setUint16(26,1,true),l.setUint16(28,32,true),l.setUint32(30,3,true),l.setUint32(34,o,true),l.setInt32(38,2835,true),l.setInt32(42,2835,true),l.setUint32(46,0,true),l.setUint32(50,0,true),l.setUint32(54,16711680,true),l.setUint32(58,65280,true),l.setUint32(62,255,true),l.setUint32(66,4278190080,true),l.setUint32(70,1934772034,true),c.set(t,122),u}var xf=Math.fround;function rn(t){return Math.floor(xf(xf(t)*256+.5))+15>>4}function Ne(t,e,n,r){let o=1/0,s=1/0,i=-1/0,a=-1/0;for(let E=0;E<8;E+=2)o=Math.min(o,t[E]),i=Math.max(i,t[E]),s=Math.min(s,t[E+1]),a=Math.max(a,t[E+1]);let u=o-16,l=s-16,c=[t[0]-u,t[2]-u,t[4]-u,t[6]-u],f=[t[1]-l,t[3]-l,t[5]-l,t[7]-l],m=(E,R)=>Math.floor(E/2**R),b=[c[0]*1024,(c[3]-c[0])*1024,3*(c[1]-2*c[2]+c[3])*2048,3*(c[0]-2*c[1]+c[2])*2048],h=[f[0]*1024,(f[3]-f[0])*1024,3*(f[1]-2*f[2]+f[3])*2048,3*(f[0]-2*f[1]+f[2])*2048],p=1,d=0,y=(E,R)=>Math.abs(E)>Math.abs(R)?Math.abs(E):Math.abs(R);for(let E=0;E<40;E++){let R=24576*2**d;if(y(b[2],b[3])<=R&&y(h[2],h[3])<=R)break;d+=2;for(let T of [b,h])T[2]=m(T[2]+T[3],1),T[1]=m(T[1]-m(T[2],d),1);p*=2;}for(let E of [b,h]){E[0]*=8,E[1]*=8;let R=d-3;R>=0?(E[2]=m(E[2],R),E[3]=m(E[3],R)):(E[2]*=2**-R,E[3]*=2**-R);}let g=E=>{E[0]+=E[1];let R=E[2];E[1]+=R,E[2]=R+R-E[3],E[3]=R;},M=1/p,P=M;g(b),g(h),p--;for(let E=0;E<1<<22;E++){if(e.push(m(b[0]+4096,13)+u,m(h[0]+4096,13)+l),r?.push(P),p===0)return;if(Math.max(y(b[2],b[3]),y(h[2],h[3]))>196608){for(let R of [b,h])R[2]=m(R[2]+R[3],3),R[1]=m(R[1]-R[2],1),R[3]=m(R[3],2);p*=2,M/=2;}for(;p%2===0&&y(b[3],2*b[2]-b[3])<=49152&&y(h[3],2*h[2]-h[3])<=49152;){for(let R of [b,h])R[3]*=4,R[1]=R[2]+2*R[1],R[2]=R[2]*8-R[3];p/=2,M*=2;}p--,P+=M,g(b),g(h);}}function jx(t,e,n,r,o,s,i,a){let u=Math.hypot(t-2*n+o,e-2*r+s),l=Math.hypot(n-2*o+i,r-2*s+a),c=Math.ceil(Math.sqrt(.75*Math.max(u,l)/.05));return Math.min(4096,Math.max(1,c))}function yf(t,e){if(!(t>.05))return 1;let n=2*Math.acos(1-.05/t),r=Math.ceil(Math.abs(e)/n);return Math.min(4096,Math.max(1,r))}function gf(t,e){let n=t%e;return n<0?n+e:n}function Gr(t){let e=[],n=[],r=false,o=0,s=0,i=()=>{n.length>=6&&e.push(n),n=[];},a=(l,c)=>{i(),n=[l,c],r=true,o=l,s=c;},u=(l,c)=>{if(!r){a(l,c);return}n.push(l,c),o=l,s=c;};for(let l of t)switch(l.op){case "moveTo":a(l.x,l.y);break;case "lineTo":u(l.x,l.y);break;case "rect":a(l.x,l.y),u(l.x+l.w,l.y),u(l.x+l.w,l.y+l.h),u(l.x,l.y+l.h),a(l.x,l.y);break;case "closePath":if(r){let c=n[0],f=n[1];a(c,f);}break;case "bezierCurveTo":{r||a(l.cp1x,l.cp1y);let c=o,f=s,m=jx(c,f,l.cp1x,l.cp1y,l.cp2x,l.cp2y,l.x,l.y);for(let b=1;b<m;b++){let h=b/m,p=1-h,d=p*p*p,x=3*p*p*h,y=3*p*h*h,g=h*h*h;u(d*c+x*l.cp1x+y*l.cp2x+g*l.x,d*f+x*l.cp1y+y*l.cp2y+g*l.y);}u(l.x,l.y);break}case "arcTo":{if(!r){a(l.x1,l.y1);break}let c=o,f=s,m=c-l.x1,b=f-l.y1,h=l.x2-l.x1,p=l.y2-l.y1,d=Math.hypot(m,b),x=Math.hypot(h,p),y=m*p-b*h;if(l.radius<=0||d===0||x===0||Math.abs(y)<1e-9*d*x){u(l.x1,l.y1);break}let g=m/d,M=b/d,P=h/x,E=p/x,R=Math.max(-1,Math.min(1,g*P+M*E)),T=Math.acos(R)/2,A=l.radius/Math.tan(T),w=l.x1+g*A,I=l.y1+M*A,S=l.x1+P*A,v=l.y1+E*A,C=g+P,U=M+E,D=Math.hypot(C,U),L=l.radius/Math.sin(T),F=l.x1+C/D*L,B=l.y1+U/D*L,X=Math.atan2(I-B,w-F),k=Math.atan2(v-B,S-F)-X;k>Math.PI?k-=2*Math.PI:k<-Math.PI&&(k+=2*Math.PI),u(w,I);let W=yf(l.radius,k);for(let O=1;O<=W;O++){let q=X+k*O/W;u(F+l.radius*Math.cos(q),B+l.radius*Math.sin(q));}break}case "ellipse":{let c=2*Math.PI,f;if(l.ccw){let y=l.startAngle-l.endAngle;f=-(y>=c?c:gf(y,c));}else {let y=l.endAngle-l.startAngle;f=y>=c?c:gf(y,c);}let m=Math.cos(l.rotation),b=Math.sin(l.rotation),h=y=>{let g=l.rx*Math.cos(y),M=l.ry*Math.sin(y);return [l.cx+g*m-M*b,l.cy+g*b+M*m]},[p,d]=h(l.startAngle);u(p,d);let x=yf(Math.max(Math.abs(l.rx),Math.abs(l.ry)),f);for(let y=1;y<=x;y++){let[g,M]=h(l.startAngle+f*y/x);u(g,M);}break}}return i(),e}function Vx(t){let e=Math.floor(t.x),n=Math.floor(t.y),r=Math.max(e,Math.min(e+32768,Math.ceil(t.x+t.w))),o=Math.max(n,Math.min(n+32768,Math.ceil(t.y+t.h)));return {x0:e,y0:n,x1:r,y1:o}}function Ef(...t){let e=1/0,n=1/0,r=-1/0,o=-1/0,s=(u,l)=>{Math.abs(u)<8388608&&Math.abs(l)<8388608&&(e=Math.min(e,u),n=Math.min(n,l),r=Math.max(r,u),o=Math.max(o,l));};for(let u of t)for(let l of u??[])for(let c of Gr(l.cmds))for(let f=0;f<c.length;f+=2)s(c[f],c[f+1]);if(!Number.isFinite(e))return {x:0,y:0,w:0,h:0};let i=Math.floor(e),a=Math.floor(n);return {x:i,y:a,w:Math.ceil(r)-i,h:Math.ceil(o)-a}}function zx(t,e,n){let r=[];for(let o of Gr(t.cmds)){let s=o.length/2;for(let i=0;i<s;i++){let a=o[2*i],u=o[2*i+1],l=(i+1)%s,c=o[2*l],f=o[2*l+1];if(u===f||!Number.isFinite(a+u+c+f))continue;let m=f>u?1:-1,b=m>0?a:c,h=m>0?u:f,p=m>0?f:u,d=(c-a)/(f-u),x=Math.max(e,Math.ceil(h-.5)),y=Math.min(n,Math.ceil(p-.5));x>=y||r.push({row0:x,row1:y,x:b+(x+.5-h)*d,slope:d,dir:m});}}return r.sort((o,s)=>o.row0-s.row0),r}function qx(t,e){let n=[],r=zx(t,e.y0,e.y1),o=t.fillRule==="evenodd",s=[],i=0,a=[];for(let u=e.y0;u<e.y1;u++){for(;i<r.length&&r[i].row0===u;)s.push(r[i++]);s=s.filter(m=>m.row1>u),a.length=0;for(let m of s)a.push({x:m.x+(u-m.row0)*m.slope,dir:m.dir});a.sort((m,b)=>m.x-b.x);let l=[],c=0,f=0;for(let m of a){let b=o?(c&1)!==0:c!==0;c+=m.dir;let h=o?(c&1)!==0:c!==0;if(!b&&h)f=m.x;else if(b&&!h){let p=Math.max(e.x0,Math.ceil(f-.5)),d=Math.min(e.x1,Math.ceil(m.x-.5));p<d&&(l.length>0&&l[l.length-1]>=p?l[l.length-1]=Math.max(l[l.length-1],d):l.push(p,d));}}n.push(l);}return n}function Pf(t,e,n){let r=[],o=0,s=0,i=false,a=false,u=false;for(;o<t.length||s<e.length;){let l=Math.min(o<t.length?t[o]:1/0,s<e.length?e[s]:1/0);for(;o<t.length&&t[o]===l;)i=!i,o++;for(;s<e.length&&e[s]===l;)a=!a,s++;let c=n(i,a);c!==u&&(r.push(l),u=c);}return r}function Mf(t,e){let n=e.x1>e.x0?[e.x0,e.x1]:[],r=[];for(let o=e.y0;o<e.y1;o++)r.push(n);for(let o of t??[]){let s=qx(o,e);r=r.map((i,a)=>i.length===0?i:Pf(i,s[a],Rf));}return r}var Rf=(t,e)=>t&&e,Jx={replace:(t,e)=>e,intersect:Rf,union:(t,e)=>t||e,xor:(t,e)=>t!==e,exclude:(t,e)=>t&&!e,complement:(t,e)=>e&&!t};function Kx(t,e){if(t.length!==e.length)return false;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return false;return true}function Zx(t,e){let n=[],r=0;for(let o=1;o<=t.length;o++){if(o<t.length&&Kx(t[o],t[r]))continue;let s=t[r];for(let i=0;i<s.length;i+=2)n.push({x:s[i],y:e+r,w:s[i+1]-s[i],h:o-r});r=o;}return n}function Qn(t,e,n,r){let o=Vx(r);if(o.x1<=o.x0||o.y1<=o.y0)return [];let s=Mf(t,o),i=Mf(e,o),a=Jx[n],u=s.map((l,c)=>Pf(l,i[c],a));return Zx(u,o.y0)}function Tf(t){return t.w>32768||t.h>32768}var Qx=8192;function tr(t,e,n){if(n<12)return null;t.getUint32(e,true);let o=t.getUint32(e+4,true),s=t.getUint32(e+8,true);if(o===0||o>1e5)return null;let i=(s&16384)!==0;if(12+(o*(i?4:8)+o)>n)return null;let f=[],m=e+12;for(let p=0;p<o;p++)i?(f.push({x:t.getInt16(m,true),y:t.getInt16(m+2,true)}),m+=4):(f.push({x:t.getFloat32(m,true),y:t.getFloat32(m+4,true)}),m+=8);let b=m+3&-4,h=new Uint8Array(t.buffer,t.byteOffset+b,o);return {kind:"plus-path",points:f,types:new Uint8Array(h),fillRule:s&Qx?"nonzero":"evenodd"}}function ty(t,e){let n=(u,l)=>e[0]*u+e[2]*l+e[4],r=(u,l)=>e[1]*u+e[3]*l+e[5],o=[],s=t.points,i=t.types,a=0;for(;a<s.length;){let u=i[a]&15,l=(i[a]&128)!==0;if(u===0)o.push({op:"moveTo",x:n(s[a].x,s[a].y),y:r(s[a].x,s[a].y)}),a++;else if(u===3){if(a+2<s.length){o.push({op:"bezierCurveTo",cp1x:n(s[a].x,s[a].y),cp1y:r(s[a].x,s[a].y),cp2x:n(s[a+1].x,s[a+1].y),cp2y:r(s[a+1].x,s[a+1].y),x:n(s[a+2].x,s[a+2].y),y:r(s[a+2].x,s[a+2].y)}),(i[a+2]&128)!==0&&o.push({op:"closePath"}),a+=3;continue}break}else o.push({op:"lineTo",x:n(s[a].x,s[a].y),y:r(s[a].x,s[a].y)}),a++;l&&o.push({op:"closePath"});}return o}var ey=512;function ny(t,e,n,r,o,s,i,a){let u=(i-o)*(e-s)-(a-s)*(t-o),l=(i-o)*(r-s)-(a-s)*(n-o),c=(n-t)*(s-e)-(r-e)*(o-t),f=(n-t)*(a-e)-(r-e)*(i-t);return u*l<0&&c*f<0}function ry(t){let e=Gr(t);if(e.length!==1)return false;let n=e[0],r=n.length/2;if(r<3)return true;if(r>ey)return false;for(let o=0;o<r;o++){let s=(o+1)%r;for(let i=o+2;i<r;i++){let a=(i+1)%r;if(a!==o&&ny(n[2*o],n[2*o+1],n[2*s],n[2*s+1],n[2*i],n[2*i+1],n[2*a],n[2*a+1]))return false}}return true}function mu(t,e){let n=ty(t,e);return {cmds:n,fillRule:t.fillRule??"nonzero",simple:ry(n)}}function Or(t,e){t.beginPath();let n=e.points,r=e.types,o=0;for(;o<n.length;){let s=r[o]&15,i=(r[o]&128)!==0;if(s===0)t.moveTo(n[o].x,n[o].y),o++;else if(s===1)t.lineTo(n[o].x,n[o].y),o++;else if(s===3)if(o+2<n.length){t.bezierCurveTo(n[o].x,n[o].y,n[o+1].x,n[o+1].y,n[o+2].x,n[o+2].y),(r[o+2]&128)!==0&&t.closePath(),o+=3;continue}else break;else t.lineTo(n[o].x,n[o].y),o++;i&&t.closePath();}}var uy=1,Js=2,wf=4,If=8,ly=64,cy=128,Vs=4096;function Nr(t){return t>>>12===900097}function bu(t,e){return [t.getFloat32(e,true),t.getFloat32(e+4,true),t.getFloat32(e+8,true),t.getFloat32(e+12,true),t.getFloat32(e+16,true),t.getFloat32(e+20,true)]}function zs(t,e,n){return {x:t[0]*e+t[2]*n+t[4],y:t[1]*e+t[3]*n+t[5]}}function my(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function hu(t){switch(t){case 0:return "tile";case 1:return "tile-flip-x";case 2:return "tile-flip-y";case 3:return "tile-flip-xy";default:return "clamp"}}function Sf(t){return t.map(e=>({...e,offset:my(e.offset)})).sort((e,n)=>e.offset-n.offset)}function vf(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>Vs)return null;let o=e+4,s=o+r*4,i=s+r*4;if(i>n)return null;let a=[];for(let u=0;u<r;u++){let l=t.getUint32(s+u*4,true);a.push({offset:t.getFloat32(o+u*4,true),color:ue(l),argb:l});}return {stops:a,next:i}}function Cf(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>Vs)return null;let o=e+4,s=o+r*4,i=s+r*4;if(i>n)return null;let a=[];for(let u=0;u<r;u++)a.push({pos:t.getFloat32(o+u*4,true),factor:t.getFloat32(s+u*4,true)});return {entries:a,next:i}}function fy(t,e,n){if(e+40>n)return null;let r=t.getUint32(e,true),o=hu(t.getUint32(e+4,true)),s=t.getFloat32(e+8,true),i=t.getFloat32(e+12,true),a=t.getFloat32(e+16,true),u=t.getFloat32(e+20,true),l=t.getUint32(e+24,true),c=t.getUint32(e+28,true),f=e+40,m=null;r&Js&&f+24<=n&&(m=bu(t,f),f+=24);let b=[{offset:0,color:ue(l),argb:l},{offset:1,color:ue(c),argb:c}],h={startArgb:l,endArgb:c,preset:null,blend:null,gammaCorrected:(r&cy)!==0};if(r&wf){let x=vf(t,f,n);x&&(b=x.stops,h.preset={positions:x.stops.map(y=>y.offset),argb:x.stops.map(y=>y.argb??0)});}else if(r&If){let x=Cf(t,f,n);x&&(b=x.entries.map(y=>({offset:y.pos,color:Ta(l,c,y.factor),argb:pu(l,c,y.factor)})),h.blend={positions:x.entries.map(y=>y.pos),factors:x.entries.map(y=>y.factor)});}let p={x:s,y:i+u/2},d={x:s+a,y:i+u/2};return m&&(p=zs(m,p.x,p.y),d=zs(m,d.x,d.y)),$(`parseEmfPlusBrushObject: linear gradient (${p.x.toFixed(1)},${p.y.toFixed(1)})\u2192(${d.x.toFixed(1)},${d.y.toFixed(1)}), ${b.length} stop(s)`),{kind:"plus-brush",color:ue(l),gradient:{type:"linear",x1:p.x,y1:p.y,x2:d.x,y2:d.y,stops:Sf(b),wrapMode:o,rect:{x:s,y:i,w:a,h:u},transform:m,ramp:h}}}function Uf(t,e,n){if(e+28>n||t.getUint32(e+4,true)!==1)return null;let o=t.getInt32(e+8,true),s=t.getInt32(e+12,true),i=t.getInt32(e+16,true),a=t.getUint32(e+20,true),u=e+28,l=Math.abs(i);if(o<=0||s<=0||o>8192||s>8192||u+l*s>n)return null;let c=df(t,u,o,s,i,a);return c?{width:o,height:s,rgba:c}:null}function _f(t,e,n){if(e+28>n||t.getUint32(e+4,true)!==1||Uf(t,e,n))return null;let r=e+28;return r<n?{start:r,end:n}:null}function Lf(t,e,n){if(e+8>n)return null;let r=t.getUint32(e,true),o=e+8;return r&Js&&o+24<=n&&(o+=24),o}function by(t,e,n,r){if(e+8>n)return null;let o=t.getUint32(e,true),s=hu(t.getUint32(e+4,true)),i=e+8,a=null;o&Js&&i+24<=n&&(a=bu(t,i),i+=24);let u=Uf(t,i,n)??r??null;if(!u)return null;let l={width:u.width,height:u.height,rgba:u.rgba,wrapMode:s,transform:a},c=0,f=0,m=0,b=u.width*u.height;for(let p=0;p<b;p++)c+=u.rgba[p*4],f+=u.rgba[p*4+1],m+=u.rgba[p*4+2];let h=b>0?`rgba(${Math.round(c/b)},${Math.round(f/b)},${Math.round(m/b)},1)`:"rgba(128,128,128,1)";return $(`parseEmfPlusBrushObject: texture fill ${u.width}x${u.height}, wrapMode=${s}`),{kind:"plus-brush",color:h,texture:l}}function hy(t,e,n){if(e+24>n)return null;let r=t.getUint32(e,true),o=hu(t.getUint32(e+4,true)),s=t.getUint32(e+8,true),i=t.getFloat32(e+12,true),a=t.getFloat32(e+16,true),u=t.getUint32(e+20,true);if(u>Vs)return {kind:"plus-brush",color:ue(s)};let l=[],c=e+24;for(let A=0;A<u&&c+4<=n;A++)l.push(t.getUint32(c,true)),c+=4;let f=[],m=[],b,h=A=>l.length>0?l[Math.min(A,l.length-1)]:s;if(r&uy){if(c+4<=n){let A=t.getInt32(c,true);if(c+=4,A>0&&c+A<=n){let w=tr(t,c,A);if(w){let I=xy(w.points,w.types,h);f=I.points,m=I.argb;let S=w.points.length;for(let v=0;v<w.points.length;v++){if(v>0&&(w.types[v]&7)===0){S=v;break}if(w.types[v]&128){S=v+1;break}}w.types.slice(0,S).some(v=>(v&7)===3)&&(b={points:w.points.slice(0,S),types:w.types.slice(0,S)});}c+=A;}}}else if(c+4<=n){let A=t.getUint32(c,true);if(c+=4,A>0&&A<=Vs&&c+A*8<=n){for(let w=0;w<A;w++)f.push({x:t.getFloat32(c+w*8,true),y:t.getFloat32(c+w*8+4,true)}),m.push(h(w));c+=A*8;}}let p=null;r&Js&&c+24<=n&&(p=bu(t,c),c+=24);let d={x:i,y:a},x=p,y=x?f.map(A=>zs(x,A.x,A.y)):f;x&&({x:i,y:a}=zs(x,i,a));let g=l.length>0?l[0]:s,M=[{offset:0,color:ue(s),argb:s},{offset:1,color:ue(g),argb:g}],P=null,E=null;if(r&wf){let A=vf(t,c,n);A&&(M=A.stops.map(w=>({...w,offset:1-w.offset})),E={positions:A.stops.map(w=>w.offset),argb:A.stops.map(w=>w.argb??0)},c=A.next);}else if(r&If){let A=Cf(t,c,n);A&&(M=A.entries.map(w=>({offset:1-w.pos,color:Ta(g,s,w.factor),argb:pu(g,s,w.factor)})),P={positions:A.entries.map(w=>w.pos),factors:A.entries.map(w=>w.factor)},c=A.next);}let R=null;r&ly&&c+12<=n&&t.getUint32(c,true)===2&&(R={x:t.getFloat32(c+4,true),y:t.getFloat32(c+8,true)});let T=0;for(let A of y){let w=Math.hypot(A.x-i,A.y-a);w>T&&(T=w);}return T>0?($(`parseEmfPlusBrushObject: path gradient centre=(${i.toFixed(1)},${a.toFixed(1)}), ${f.length} boundary point(s)`),{kind:"plus-brush",color:ue(s),gradient:{type:"radial",cx:i,cy:a,r:T,stops:Sf(M),wrapMode:o,shape:{center:d,centerArgb:s,boundary:f,source:b,boundaryArgb:m,blend:P,preset:E,focus:R,transform:p}}}):{kind:"plus-brush",color:ue(s)}}function pu(t,e,n){let r=Math.min(1,Math.max(0,n)),o=0;for(let s=24;s>=0;s-=8){let i=t>>>s&255,a=e>>>s&255;o=o*256+Math.round(i+(a-i)*r);}return o>>>0}var py=.25,dy=10;function Af(t,e,n){let r=n.x-e.x,o=n.y-e.y,s=Math.hypot(r,o);return s<1e-12?Math.hypot(t.x-e.x,t.y-e.y):Math.abs((t.x-e.x)*o-(t.y-e.y)*r)/s}function qs(t,e,n,r,o,s=0,i=1,a=0){if(Math.max(Af(e,t,r),Af(n,t,r))<=py||a>=dy){o.push({x:r.x,y:r.y,t:i});return}let l=(x,y)=>({x:(x.x+y.x)/2,y:(x.y+y.y)/2}),c=l(t,e),f=l(e,n),m=l(n,r),b=l(c,f),h=l(f,m),p=l(b,h),d=(s+i)/2;qs(t,c,b,p,o,s,d,a+1),qs(p,h,m,r,o,d,i,a+1);}function xy(t,e,n){let r=[],o=[];for(let i=0;i<t.length;i++){let a=e[i]&7;if(i>0&&a===0)break;if(a===3&&i>0&&i+2<t.length){let u=t.slice(i-1,i+3).flatMap(b=>[rn(b.x),rn(b.y)]);r[r.length-1]={x:u[0]/16,y:u[1]/16};let l=n(i-1),c=n(i+2),f=[],m=[];Ne(u,f,void 0,m);for(let b=0;b<m.length;b++)r.push({x:f[b*2]/16,y:f[b*2+1]/16}),o.push(pu(l,c,m[b]));if(i+=2,e[i]&128)break;continue}if(r.push(t[i]),o.push(n(i)),e[i]&128)break}let s=r.length;return s>1&&r[0].x===r[s-1].x&&r[0].y===r[s-1].y&&(r.pop(),o.pop()),{points:r,argb:o}}function Ks(t,e,n,r,o=e){if(n<8)return null;let s=e+n,i=Nr(t.getUint32(e,true)),a=e+(i?4:0);if(a+8>s)return null;let u=t.getUint32(a,true),l=a+4;switch(u){case 0:return {kind:"plus-brush",color:ue(t.getUint32(l,true))};case 1:if(l+12<=s){let c=t.getUint32(l+4,true);return {kind:"plus-brush",color:ue(c),hatch:{style:t.getUint32(l,true),fore:c,back:t.getUint32(l+8,true)}}}return l+8<=s?{kind:"plus-brush",color:ue(t.getUint32(l+4,true))}:{kind:"plus-brush",color:"rgba(0,0,0,1)"};case 2:{let c=r?.get(o);return by(t,l,s,c)??{kind:"plus-brush",color:"rgba(0,0,0,1)"}}case 4:return fy(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};case 3:return hy(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};default:return {kind:"plus-brush",color:"rgba(0,0,0,1)"}}}function yy(t){let e=t[0]*t[3]-t[1]*t[2];if(!Number.isFinite(e)||Math.abs(e)<1e-12)return null;let n=t[3]/e,r=-t[1]/e,o=-t[2]/e,s=t[0]/e;return [n,r,o,s,-(n*t[4]+o*t[5]),-(r*t[4]+s*t[5])]}function Io(t,e){return {x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}function er(t,e,n,r,o,s){let i=Math.PI/2,a=Math.max(1,Math.ceil(Math.abs(s)/i-1e-9)),u=f=>({x:t+n*Math.cos(f),y:e+r*Math.sin(f)}),l=f=>({x:-n*Math.sin(f),y:r*Math.cos(f)}),c=[];for(let f=0;f<a;f++){let m=o+f*Math.sign(s)*i,b=f===a-1?o+s-m:Math.sign(s)*i,h=4/3*Math.tan(b/4),p=m+b,d=u(m),x=u(p),y=l(m),g=l(p);c.push([d,{x:d.x+h*y.x,y:d.y+h*y.y},{x:x.x-h*g.x,y:x.y-h*g.y},x]);}return c}function Df(t,e){let n=yy(e);if(!n)return t;let r=null,o=null,s=l=>{t.moveTo(l.x,l.y),r=l,o=l;},i=l=>{t.lineTo(l.x,l.y),r=l;},a=(l,c,f,m)=>{let b=[];qs(Io(e,l),Io(e,c),Io(e,f),Io(e,m),b);for(let h=0;h<b.length-1;h++){let p=Io(n,b[h]);t.lineTo(p.x,p.y);}i(m);},u={beginPath(){t.beginPath(),r=null,o=null;},moveTo(l,c){s({x:l,y:c});},lineTo(l,c){if(!r){s({x:l,y:c});return}i({x:l,y:c});},closePath(){t.closePath(),r=o;},rect(l,c,f,m){s({x:l,y:c}),i({x:l+f,y:c}),i({x:l+f,y:c+m}),i({x:l,y:c+m}),t.closePath(),r={x:l,y:c};},bezierCurveTo(l,c,f,m,b,h){let p=r??{x:l,y:c};r||s(p),a(p,{x:l,y:c},{x:f,y:m},{x:b,y:h});},ellipse(l,c,f,m,b,h,p,d){let x=p-h;d?(x=x>0?x-2*Math.PI*Math.ceil(x/(2*Math.PI)):x,x<-2*Math.PI&&(x=-2*Math.PI)):(x=x<0?x+2*Math.PI*Math.ceil(-x/(2*Math.PI)):x,x>2*Math.PI&&(x=2*Math.PI));let y=Math.cos(b),g=Math.sin(b),M=R=>b===0?R:{x:l+(R.x-l)*y-(R.y-c)*g,y:c+(R.x-l)*g+(R.y-c)*y},P=er(l,c,f,m,h,x).map(R=>R.map(M));if(P.length===0)return;let E=P[0][0];r?i(E):s(E);for(let[R,T,A,w]of P)a(R,T,A,w);}};return new Proxy(t,{get(l,c){if(typeof c=="string"&&c in u)return u[c];let f=l[c];return typeof f=="function"?f.bind(l):f},set(l,c,f){return l[c]=f,true}})}var xt=Math.fround;function Of(t,e,n){let r=e.map(m=>xt(m)),o=(m,b)=>rn(xt(xt(xt(r[0]*xt(m))+xt(r[2]*xt(b)))+r[4])),s=(m,b)=>rn(xt(xt(xt(r[1]*xt(m))+xt(r[3]*xt(b)))+r[5])),i=[],a=null,u=null,l=(m,b)=>{a={pts:[o(m,b),s(m,b)],closed:false,curved:false},i.push(a),u={x:m,y:b};},c=(m,b)=>{if(!a){l(m,b);return}a.pts.push(o(m,b),s(m,b));},f={beginPath(){a=null,u=null;},moveTo:l,lineTo:c,bezierCurveTo(m,b,h,p,d,x){a||l(m,b);let y=a;y.curved=true;let g=y.pts.length;Ne([y.pts[g-2],y.pts[g-1],o(m,b),s(m,b),o(h,p),s(h,p),o(d,x),s(d,x)],y.pts);},ellipse(m,b,h,p,d,x,y,g){let M=y-x;g?(M=M>0?M-2*Math.PI*Math.ceil(M/(2*Math.PI)):M,M=Math.max(M,-2*Math.PI)):(M=M<0?M+2*Math.PI*Math.ceil(-M/(2*Math.PI)):M,M=Math.min(M,2*Math.PI));let P=Math.cos(d),E=Math.sin(d),R=w=>d===0?w:{x:m+(w.x-m)*P-(w.y-b)*E,y:b+(w.x-m)*E+(w.y-b)*P},T=er(m,b,h,p,x,M);if(T.length===0)return;let A=R(T[0][0]);a?c(A.x,A.y):l(A.x,A.y);for(let w of T){let[,I,S,v]=w.map(R);f.bezierCurveTo(I.x,I.y,S.x,S.y,v.x,v.y);}},rect(m,b,h,p){l(m,b),c(m+h,b),c(m+h,b+p),c(m,b+p),f.closePath();},closePath(){if(a&&u){a.closed=true;let m=u;l(m.x,m.y);}}};return t(f),i.filter(m=>m.pts.length>=4)}function Ff(t){let e=t.pts;return !t.closed||e.length<4?e:[...e,e[0],e[1]]}var kf=32;function gy(t){let e=t.length/2,n=[];for(let r=0;r<e-1;r+=kf-1)n.push(t.slice(2*r,2*Math.min(e,r+kf)));return n}function My(t,e,n,r,o,s,i){let a=xt(n/16-t/16),u=xt(r/16-e/16);if(a===0&&u===0)return;let l=Math.abs(a),c=Math.abs(u),f=c<l,m=false,b;f?(b=u>=0?1:-1,a<0&&(m=true,[t,e,n,r]=[n,r,t,e],b=-b)):(b=a>=0?1:-1,u<0&&(m=true,[t,e,n,r]=[n,r,t,e],b=-b));let h=f?t:e,p=f?n:r,d=f?e:t,x=f?r:n,y=xt(f?xt(b*c)/l:xt(b*l)/c),g=p-h,M=(x-d)*b,P=0,E=0,R=0;if(i){let N=y===0?0:xt(1/y),G=(f?i.x:i.y)*16-8,j=(f?i.x+i.w:i.y+i.h)*16-8,tt=(f?i.y:i.x)*16-8,lt=(f?i.y+i.h:i.x+i.w)*16-8;if(h<G||p>j){if(h>j||p<G)return;if(h<G){let at=xt(xt((G-h)*y)+d),mt=Math.floor(at);d=mt,h=G,P=xt(at-mt);}if(p>j){let at=xt(xt((j-p)*y)+x),mt=Math.floor(at);o=true,x=mt,p=j,E=xt(at-mt);}}let ct=b===1,ht=ct?d:x,ft=ct?x:d;if(ht<tt||ft>lt){if(ht>lt||ft<tt)return;if(ht<tt){let at=Math.floor(xt(xt(tt-xt(ht+(ct?P:E)))*N));ct?(h+=at,d=tt):(p+=at,x=tt);}if(ft>lt){let at=Math.floor(xt(xt(lt-xt(ft+(ct?E:P)))*N));ct?(p+=at,x=lt):(h+=at,d=lt),o=true;}}E!==0&&(x&15)===8&&x++,P!==0&&(R=Math.floor(xt(xt(2*g*b)*P)));}let T=f&&g===M,A=T&&b===1,w=A?8:7,I=(N,G)=>{let j=Math.abs(N)+Math.abs(G);return j<8?true:j!==8?false:G===0&&N===(A?-8:8)||N===0&&G===8?true:T&&(A?N<0:N>0)&&G>0},S=h+w&-16,v=p+w&-16,C=I(h-S,d-(d+7&-16)),U=I(p-v,x-(x+7&-16)),D=h&15,L=p&15;m&&!o?(C||D<=8)&&(S+=16):D<=8&&!C&&(S+=16),!m&&!o?(L>8||U)&&(v-=16):!U&&L>8&&(v-=16);let F=S>>4,B=v>>4;if(B<F)return;let X=Math.floor((S-h)*y+d+P),k=X+7&-16,W=k>>4,O=R-((k-X)*b+8)*2*g>>4;if(!i){for(let N=F;N<=B;N++)f?s(N,W):s(W,N),O+=2*M,O>0&&(W+=b,O-=2*g);return}let Q=Math.floor((v-p)*y+x+E)+7>>4,K=f?i.x:i.y,V=(f?i.x+i.w:i.y+i.h)-1,rt=f?i.y:i.x,H=(f?i.y+i.h:i.x+i.w)-1,Y=(Q-W)*b;for(let N=F;N<=B&&Y>=0;N++)N>=K&&N<=V&&W>=rt&&W<=H&&(f?s(N,W):s(W,N)),O+=2*M,O>0&&(W+=b,O-=2*g,Y--);}var Bf=[0,-8,-8,0,0,8,8,0];function Gf(t,e){return Math.abs(e)>Math.abs(t)?e<0?1:3:t<0?2:0}function Ey(t){let e=t.length/2;if(e<2)return [];let n=[],r=[],o=m=>t[2*m],s=m=>t[2*m+1],i=Gf(o(1)-o(0),s(1)-s(0)),a=m=>Bf[2*(m&3)],u=m=>Bf[2*(m&3)+1];n.push(o(0)-a(i),s(0)-u(i),o(0)+a(i+1),s(0)+u(i+1));for(let m=0;m+1<e&&(n.push(o(m)+a(i),s(m)+u(i),o(m+1)+a(i),s(m+1)+u(i)),r.push(o(m)-a(i),s(m)-u(i),o(m+1)-a(i),s(m+1)-u(i)),!(m+2>=e));m++){let b=Gf(o(m+2)-o(m+1),s(m+2)-s(m+1));if(b!==i){let h=o(m+1)-o(m),p=s(m+1)-s(m),d=o(m+2)-o(m+1),x=s(m+2)-s(m+1),y=o(m+1),g=s(m+1);if(h*x>=p*d){let M=i-1&3;M!==b&&n.push(y+a(M),g+u(M)),r.push(y,g);}else {let M=i+1&3;M!==b&&r.push(y-a(M),g-u(M)),n.push(y,g);}i=b;}}let l=o(e-1),c=s(e-1);n.push(l+a(i-1),c+u(i-1),l-a(i),c-u(i));let f=n.slice();for(let m=r.length-2;m>=0;m-=2)f.push(r[m],r[m+1]);return f}function Nf(t,e,n){if(!e.antialias&&e.opaqueSolid&&!t.some(o=>o.curved)){let o=e.half?8:0,s=new Uint8ClampedArray(n.w*n.h),i=(u,l)=>{let c=u-n.x,f=l-n.y;c>=0&&f>=0&&c<n.w&&f<n.h&&(s[f*n.w+c]=255);},a=e.clip&&!Py(t,e.clip,o)?e.clip:void 0;for(let u of t){let l=Ff(u);for(let c=0;c+3<l.length;c+=2)My(l[c]-o,l[c+1]-o,l[c+2]-o,l[c+3]-o,true,i,a);}return s}let r=[];for(let o of t)for(let s of gy(Ff(o))){let i=Ey(s);i.length>=6&&r.push(i);}return ne(r,false,e.antialias,e.half,n)}function Py(t,e,n){let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let a of t)for(let u=0;u+1<a.pts.length;u+=2){let l=(a.pts[u]-n)/16,c=(a.pts[u+1]-n)/16;r=Math.min(r,l),s=Math.max(s,l),o=Math.min(o,c),i=Math.max(i,c);}return Math.floor(r-.5)-1>=e.x&&Math.floor(o-.5)-1>=e.y&&Math.ceil(s+.5)+1<=e.x+e.w-1&&Math.ceil(i+.5)+1<=e.y+e.h-1}function Ft(t){return Math.ceil(Math.round(t*256-1e-6)/16)}function Wf(t){return Math.floor(t*16+.5-1e-4)}function Ry(t){let e=t.map(Wf);if(e.length===10&&e[0]===e[8]&&e[1]===e[9]&&(e=e.slice(0,8)),e.length!==8)return null;let[n,r,o,s,i,a,u,l]=e;return r===s&&o===i&&a===l&&u===n||n===o&&s===a&&i===u&&l===r?e:null}function yn(t,e){let n=[],r=null,o=null,s=(m,b)=>e[0]*m+e[2]*b+e[4],i=(m,b)=>e[1]*m+e[3]*b+e[5],a=(m,b)=>{r={pts:[s(m,b),i(m,b)],closed:false,curved:false},n.push(r),o={x:m,y:b};},u=(m,b)=>{if(!r){a(m,b);return}r.pts.push(s(m,b),i(m,b));},l=(m,b,h,p,d,x)=>{r||a(m,b);let y=r;y.curved=true;let g=y.pts.length,M=(I,S)=>Math.abs(I-y.pts[g-2])<.001&&Math.abs(S-y.pts[g-1])<.001,P=M(s(m,b),i(m,b))&&M(s(h,p),i(h,p))&&M(s(d,x),i(d,x)),E=I=>Ft(I),R=E(y.pts[g-2]),T=E(y.pts[g-1]);y.pts[g-2]=R/16,y.pts[g-1]=T/16,P&&(y.splits??(y.splits=[])).push({x:R/16,y:T/16});let A=[],w=[R,T,E(s(m,b)),E(i(m,b)),E(s(h,p)),E(i(h,p)),E(s(d,x)),E(i(d,x))];Ne(w,A);for(let I of A)y.pts.push(I/16);},c=()=>{if(r&&o){r.closed=true;let m=o;a(m.x,m.y);}};return t({beginPath(){r=null,o=null;},moveTo:a,lineTo:u,closePath:c,rect(m,b,h,p){a(m,b),u(m+h,b),u(m+h,b+p),u(m,b+p),c();},bezierCurveTo:l,ellipse(m,b,h,p,d,x,y,g){let M=y-x;g?(M=M>0?M-2*Math.PI*Math.ceil(M/(2*Math.PI)):M,M=Math.max(M,-2*Math.PI)):(M=M<0?M+2*Math.PI*Math.ceil(-M/(2*Math.PI)):M,M=Math.min(M,2*Math.PI));let P=Math.cos(d),E=Math.sin(d),R=w=>d===0?w:{x:m+(w.x-m)*P-(w.y-b)*E,y:b+(w.x-m)*E+(w.y-b)*P},T=er(m,b,h,p,x,M);if(T.length===0)return;let A=R(T[0][0]);r?u(A.x,A.y):a(A.x,A.y);for(let w of T){let[,I,S,v]=w.map(R);l(I.x,I.y,S.x,S.y,v.x,v.y);}}}),n.filter(m=>m.pts.length>=4)}function Hf(t,e,n=false){return yn(t,e).map(r=>(n&&!r.curved?Ry(r.pts):null)??r.pts.map(Ft)).filter(r=>r.length>=6)}function Ty(t,e){let n=Math.floor(t/e);for(;n*e>t;)n--;for(;(n+1)*e<=t;)n++;return n*e===t?n:n+1}function So(t,e){let n=1/0,r=1/0,o=-1/0,s=-1/0;for(let c of t)for(let f=0;f<c.length;f+=2)n=Math.min(n,c[f]),o=Math.max(o,c[f]),r=Math.min(r,c[f+1]),s=Math.max(s,c[f+1]);if(!Number.isFinite(n))return null;let i=Math.max(0,Math.floor(n/16)-1),a=Math.max(0,Math.floor(r/16)-1),u=Math.min(e.w,Math.ceil(o/16)+2),l=Math.min(e.h,Math.ceil(s/16)+2);return u>i&&l>a?{x:i,y:a,w:u-i,h:l-a}:null}function ne(t,e,n,r,o){let s=n?8:1,i=n?4:1,a=16/s,u=16/i,l=r?8:0,c=16*o.x+l-(n?8:0),f=16*o.y+l-(n?8:0),m=o.w*s,b=[];for(let y of t){let g=y.length/2;for(let M=0;M<g;M++){let P=(M+1)%g,E=y[2*M],R=y[2*M+1],T=y[2*P],A=y[2*P+1];R!==A&&b.push({ax:E,ay:R,bx:T,by:A,top:Math.min(R,A),bottom:Math.max(R,A),w:A>R?1:-1});}}let h=new Uint8ClampedArray(o.w*o.h),p=new Int32Array(o.w),d=new Int32Array(m+1),x=[];for(let y=0;y<o.h;y++){p.fill(0);for(let M=0;M<i;M++){let P=f+u*(y*i+M);x.length=0;for(let T of b){if(P<T.top||P>=T.bottom)continue;let A=T.by-T.ay,w=T.ax*A+(T.bx-T.ax)*(P-T.ay);A<0&&(A=-A,w=-w);let I=Ty(w-c*A,a*A);x.push({k:Math.min(Math.max(I,0),m),w:T.w});}if(x.length<2)continue;x.sort((T,A)=>T.k-A.k),d.fill(0);let E=0;for(let T=0;T+1<x.length;T++)E+=x[T].w,(e?(E&1)!==0:E!==0)&&x[T+1].k>x[T].k&&(d[x[T].k]++,d[x[T+1].k]--);let R=0;for(let T=0;T<m;T++)R+=d[T],R>0&&p[T/s|0]++;}let g=s*i;for(let M=0;M<o.w;M++){let P=p[M];h[y*o.w+M]=P===0?0:P>=g?255:Math.round(P*255/g);}}return h}function Xf(t,e,n){let r=[1,0,0,1,0,0],o=null;for(let a of t){let u;try{u=yn(a.build,r).map(c=>c.pts.map(Wf));}catch{return null}let l=ne(u,a.evenOdd,false,n,e);if(o)for(let c=0;c<l.length;c++)o[c]=o[c]&&l[c];else o=l;}let s=[];if(!o)return s;let i=new Map;for(let a=0;a<e.h;a++){let u=new Map;for(let l=0;l<e.w;){if(!o[a*e.w+l]){l++;continue}let c=l;for(;c<e.w&&o[a*e.w+c];)c++;let f=l+","+c,m=i.get(f);if(m)m.h++,u.set(f,m),i.delete(f);else {let b={x:e.x+l,y:e.y+a,w:c-l,h:1};s.push(b),u.set(f,b);}l=c;}i=u;}return s}var Wr=Math.fround,_e=(t,e)=>_(t+e),ce=(t,e)=>_(t-e),Yt=(t,e)=>_(t*e),du=(t,e)=>_(t/e),xu=11920928955078125e-23;function Qs(t,e){let n=ce(Wr(e.x),Wr(t.x)),r=ce(Wr(e.y),Wr(t.y)),o=_e(Yt(r,r),Yt(n,n)),s=0;return o>0&&(s=_(Math.sqrt(o)),n=du(n,s),r=du(r,s)),{gx:n,gy:r,len:s}}function Ay(t,e){let n=Math.sqrt(t*t+e*e);return n<xu?0:_(n)}var Zs=Wr(.552284777),wy=[[1,0],[1,Zs],[Zs,1],[0,1],[-Zs,1],[-1,Zs],[-1,0]];function Iy(t,e,n,r,o){let s=o?-e.gx:e.gx,i=o?-e.gy:e.gy,a=_e(n,r),u=Yt(ce(n,r),.5),l=_e(Yt(Yt(a,e.gy),.5),t.x),c=ce(t.y,Yt(Yt(a,e.gx),.5)),f=Yt(u,i),m=Yt(-u,s);return (b,h)=>({x:_e(ce(Yt(b,f),Yt(h,m)),l),y:_e(_e(Yt(h,f),Yt(b,m)),c)})}function Yf(t,e,n,r,o){let s=Iy(t,e,n,r,o),i=[];for(let a of [.5,-0.5])for(let[u,l]of wy)i.push(s(_e(Yt(u,.5),a),Yt(l,.5)));return i}function $f(t,e,n){return n<0?{x:_e(t.x,Yt(-n,e.gy)),y:_e(t.y,Yt(-n,-e.gx))}:{x:ce(t.x,Yt(n,e.gy)),y:ce(t.y,Yt(n,-e.gx))}}function jf(t,e,n,r){let o=t.length;if(o<2||n.length===0)return [];let s=0;for(let y of n)s=_e(s,y);if(!(s>0))return [];let i=Wr(r%s);i<0&&(i=_e(i,s));let a=0;for(let y=0;y<1e6;y++){let g=n[a%n.length];if(g>i){i=ce(g,i);break}i=ce(i,g),a++;}let u=a%2===0,l=a+1,c=[0];for(let y=1;y<o;y++)c.push(Qs(t[y-1],t[y]).len);let f,m,b;(f=t[o-1],m=0,b=Ay(ce(t[0].x,f.x),ce(t[0].y,f.y)));let h=i,p=[],d=null,x=(y,g)=>Math.abs(ce(y.x,g.x))<xu&&Math.abs(ce(y.y,g.y))<xu;for(let y=0;m<o&&y<1e7;y++){let g=t[m];if(h>b)h=ce(h,b),u&&(x(f,g)?(d&&d.length>1&&p.push(d),d=null):(d??(d=[f]),d.push(g))),f=g,m++,m<o&&(b=c[m]);else {let M=du(h,b),P={x:_e(Yt(ce(g.x,f.x),M),f.x),y:_e(Yt(ce(g.y,f.y),M),f.y)};b=ce(b,h),u&&(x(f,P)?d&&d.length>1&&p.push(d):(d??(d=[f]),d.push(P),p.push(d)),d=null),f=P,h=n[l%n.length],l++,u=!u;}}return u&&d&&d.length>1&&p.push(d),p}function vo(t,e,n,r){let o=[];if(!(e>0)||r===0)return o;let s=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2)-1e-9)),i=[];for(let a=0;a<s;a++)i.push(...er(t.x,t.y,e,e,n+r*a/s,r/s));for(let[a,u,l,c]of i){let f=[];Ne([Ft(a.x),Ft(a.y),Ft(u.x),Ft(u.y),Ft(l.x),Ft(l.y),Ft(c.x),Ft(c.y)],f);for(let m=0;m+1<f.length;m+=2)o.push({x:f[m]/16,y:f[m+1]/16});}return o}function Vf(t,e){let n=[];for(let r=0;r+1<t.length;r+=2){let o={x:t[r],y:t[r+1]},s=n[n.length-1];(!s||Math.abs(s.x-o.x)>1e-9||Math.abs(s.y-o.y)>1e-9)&&n.push(o);}if(e&&n.length>1){let r=n[0],o=n[n.length-1];Math.abs(r.x-o.x)<=1e-9&&Math.abs(r.y-o.y)<=1e-9&&n.pop();}return n}var Sy=.99;function Xr(t,e){let n=Math.hypot(e.x-t.x,e.y-t.y),r=(e.x-t.x)/n,o=(e.y-t.y)/n;return {ux:r,uy:o,nx:-o,ny:r}}function Qf(t,e,n,r,o,s=false){let i={x:t.x+e.nx*r,y:t.y+e.ny*r},a={x:t.x+n.nx*r,y:t.y+n.ny*r};if(r===0)return [t];let u=e.ux*n.uy-e.uy*n.ux;if(Math.abs(u)<1e-12&&e.ux*n.ux+e.uy*n.uy>0)return [a];let l=u*r<0;if(!l&&s){let p=e.ux*n.uy-e.uy*n.ux,d=((a.x-i.x)*n.uy-(a.y-i.y)*n.ux)/p;return [{x:i.x+e.ux*d,y:i.y+e.uy*d}]}if(o.join===2&&e.ux*n.ux+e.uy*n.uy>Sy)return [i];if(!l)return [i,a];if(o.join===2){let p=Math.atan2(i.y-t.y,i.x-t.x),d=Math.atan2(a.y-t.y,a.x-t.x)-p;for(;d>Math.PI;)d-=2*Math.PI;for(;d<-Math.PI;)d+=2*Math.PI;return [i,...vo(t,Math.abs(r),p,d),a]}if(o.join===1)return [i,a];let c=e.ux*n.uy-e.uy*n.ux,f=((a.x-i.x)*n.uy-(a.y-i.y)*n.ux)/c,m={x:i.x+e.ux*f,y:i.y+e.uy*f},b=Math.hypot(m.x-t.x,m.y-t.y),h=o.miterLimit*o.half;if(b<=h)return [m];if(o.join===3){let p=(d,x)=>{let y=x.x-d.x,g=x.y-d.y,M=d.x-t.x,P=d.y-t.y,E=y*y+g*g,R=M*y+P*g,T=M*M+P*P-h*h,A=Math.max(0,R*R-E*T),w=E===0?0:(-R+Math.sqrt(A))/E;return {x:d.x+y*w,y:d.y+g*w}};return [p(i,m),p(a,m)]}return [i,a]}function zf(t,e,n,r,o,s,i=false){let a=(c,f)=>({x:t.x+e.nx*c+e.ux*f,y:t.y+e.ny*c+e.uy*f}),u=o&15;switch(o===17?1:o===18?2:o===19||o===20?3:o>=16?0:u){case 1:return [a(r,s),a(n,s)];case 2:{if(i){let p=Math.abs(r-n)/4,d=Math.atan2(e.ny,e.nx),x=(n+r)/2,y=(r+x)/2,g=(n+x)/2;return [a(r,0),...vo(a(y,0),p,d,-Math.PI),a(x,0),...vo(a(g,0),p,d,-Math.PI),a(n,0)]}let c=(n+r)/2,f=Math.abs(r-n)/2,m=Math.abs(c)>1e-9?a(c,0):t,b=Math.atan2(e.ny,e.nx)+(r<c?Math.PI:0),h=r>c?-Math.PI:Math.PI;return [a(r,0),...vo(m,f,b,h),a(n,0)]}case 3:return i?[a(r,0),a(n,0)]:Math.abs(n+r)>1e-9?[a(r,0),a(n,0)]:[a(r,0),a((n+r)/2,s),a(n,0)];default:return [a(r,0),a(n,0)]}}function ti(t,e,n,r){let o=t.length,s=[],i=e?o:o-1,a=Array.from({length:i},(u,l)=>Xr(t[l],t[(l+1)%o]));for(let u=0;u<o;u++){let l=u-1>=0?u-1:e?i-1:-1,c=u<i?u:-1;if(l>=0&&c>=0)s.push(...Qf(t[u],a[l],a[c],n,r,e&&!!r.compound));else {let f=a[c>=0?c:l];s.push({x:t[u].x+f.nx*n,y:t[u].y+f.ny*n});}}return s}function vy(t,e,n,r){let o=n.dashCapWidth??2*n.half,s=n.dashCap!==0?o:0,i=n.dash.map((g,M)=>M%2===0?Math.max(g-s,Uy*o):g+s),a=i.reduce((g,M)=>g+M,0),u=[];if(!(a>0))return u;let l=e?[t[t.length-1],...t]:t,c=((n.dashOffset-(e?s:0))%a+a)%a,f=0;for(;c>=i[f];)c-=i[f],f=(f+1)%i.length;let m=i[f]-c,b=f%2===0,h=b?[l[0]]:null,p=b,d=n.dashMetric,x=l.slice(1).map((g,M)=>{let P=g.x-l[M].x,E=g.y-l[M].y;return d?Math.hypot(d[0]*P+d[2]*E,d[1]*P+d[3]*E):Math.hypot(P,E)}),y=g=>x.slice(g+1).reduce((M,P)=>M+P,0);for(let g=0;g+1<l.length;g++){let M=l[g],P=l[g+1],E=x[g],R=0;for(;E-R>m+1e-9;){R+=m;let T={x:M.x+(P.x-M.x)*R/E,y:M.y+(P.y-M.y)*R/E};b&&h?(h.push(T),u.push({pts:h,first:p,last:!e&&s>0&&E-R+y(g)<=n.half+1e-9}),h=null):(h=[T],p=!e&&s>0&&u.length===0&&x.slice(0,g).reduce((A,w)=>A+w,0)+R<=n.half+1e-9),b=!b,f=(f+1)%i.length,m=i[f];}m-=E-R,b&&h&&(h.push(P),r&&g+2<l.length&&r.some(T=>Math.abs(T.x-P.x)<1e-6&&Math.abs(T.y-P.y)<1e-6)&&(u.push({pts:h,first:p,last:false}),h=[P],p=false)),E=0;}return b&&h&&h.length>1&&u.push({pts:h,first:p,last:true}),u.filter(g=>g.pts.length>1)}function Cy(t,e){let n=_(e.dashCapWidth??2*e.half),r=_(Math.fround(.001)*n),o=e.dash.map((i,a)=>{let u=_(i);if(a%2===1)return _(u+n);let l=_(u-n);return r>l?r:l}),s=[];for(let i=0;i+1<t.length;i+=2)s.push({x:Math.fround(t[i]),y:Math.fround(t[i+1])});return s.length>1&&s[0].x===s[s.length-1].x&&s[0].y===s[s.length-1].y&&s.pop(),jf(s,true,o,_(_(e.dashOffset)-n)).map(i=>({pts:i,first:false,last:false}))}function qf(t,e,n,r,o){let s=Yf({x:Math.fround(t.x),y:Math.fround(t.y)},e,r,n,o),i=[s[0]];for(let[a,u,l,c]of [[0,1,2,3],[3,4,5,6],[7,8,9,10],[10,11,12,13]]){let f=[];Ne([a,u,l,c].flatMap(m=>[Ft(s[m].x),Ft(s[m].y)]),f);for(let m=0;m+1<f.length;m+=2)i.push({x:f[m]/16,y:f[m+1]/16});}return i.reverse()}var Jf=20;function Kf(t,e,n,r){let o=e?t[t.length-1]:t[0],s=e?t[t.length-2]:t[1],i=Xr(s,o),a=(l,c)=>({x:o.x+i.ux*l+i.nx*c,y:o.y+i.uy*l+i.ny*c});if(r===18)return vo(o,2*n,Math.atan2(i.uy,i.ux),2*Math.PI);if(r===19)return [a(-2*n,0),a(0,-2*n),a(2*n,0),a(0,2*n)];let u=Math.SQRT2*n;return [a(-u,-u),a(u,-u),a(u,u),a(-u,u)]}function Zf(t,e,n){let r=2*n,o=e?t[t.length-1]:t[0],s=e?t[t.length-2]:t[1],i=Math.hypot(s.x-o.x,s.y-o.y),a=(s.x-o.x)/i,u=(s.y-o.y)/i,l=2*r,c=2*r/Math.sqrt(3),f={x:o.x+a*l,y:o.y+u*l};return i>l&&(e?t[t.length-1]=f:t[0]=f),[o,{x:f.x-u*c,y:f.y+a*c},{x:f.x+u*c,y:f.y-a*c}]}var Uy=.001;function Hr(t){let e=0;for(let n=0;n<t.length;n++){let r=t[n],o=t[(n+1)%t.length];e+=r.x*o.y-o.x*r.y;}return e/2}function _y(t,e){let n=false;for(let r=0,o=t.length-1;r<t.length;o=r++){let s=t[r],i=t[o];s.y>e.y!=i.y>e.y&&e.x<(i.x-s.x)*(e.y-s.y)/(i.y-s.y)+s.x&&(n=!n);}return n}function Ly(t,e){let n=Hr(t)>0?1:-1,r=t.length,o=Array.from({length:r},(i,a)=>Xr(t[a],t[(a+1)%r])),s=t.map((i,a)=>{let u=o[(a+r-1)%r],l=o[a],c=u.nx*n,f=u.ny*n,m=l.nx*n,b=l.ny*n,h=1+c*m+f*b;return h<1e-9?{x:i.x+c*e,y:i.y+f*e}:{x:i.x+(c+m)*e/h,y:i.y+(f+b)*e/h}});return Math.sign(Hr(s))!==n||s.some(i=>!_y(t,i))}function Dy(t,e,n){let r=Hr(t)>0?1:-1,o=t.length,s=Array.from({length:o},(a,u)=>Xr(t[u],t[(u+1)%o])),i=[];for(let a=0;a<o;a++){let u=s[(a+o-1)%o],l=s[a],c=r*e;if((u.ux*l.uy-u.uy*l.ux)*c<0)i.push(...Qf(t[a],u,l,c,n));else {let m=u.nx*r,b=u.ny*r,h=l.nx*r,p=l.ny*r,d=1+m*h+b*p;i.push(d<1e-9?{x:t[a].x+m*e,y:t[a].y+b*e}:{x:t[a].x+(m+h)*e/d,y:t[a].y+(b+p)*e/d});}}return i}function Wn(t,e){let n=[],r=e.half;for(let o of t){let s=Vf(o.pts,o.closed);if(s.length<2)continue;let i=o.closed&&s.length>2,a=-r,u=r;if(e.inset&&i&&!e.dash&&!e.compound){n.push(s.slice()),Ly(s,2*r)||n.push(Dy(s,2*r,e).reverse());continue}e.inset&&i&&(Hr(s)>0?(a=0,u=2*r):(a=-2*r,u=0));let l=[],c=e.compound;if(c&&c.length>=2)for(let p=0;p+1<c.length;p+=2)l.push([a+(u-a)*c[p],a+(u-a)*c[p+1]]);else l.push([a,u]);let f=e.inset&&i?{...e,dashOffset:e.dashOffset*2}:e,m=!!e.dash&&!!e.doubleRoundCap&&e.dashCap===2&&i,b=m?Cy(o.pts,e):e.dash?vy(s,i,f,o.splits):[{pts:s,first:true,last:true}],h=!e.dash&&i;for(let p of b){let d=Vf(p.pts.flatMap(M=>[M.x,M.y]),false);if(d.length<2)continue;let x=[],y=null,g=null;!h&&!(e.dash&&i)&&(p.first&&e.startCap>=17&&e.startCap<=19&&(x.push(Kf(d,false,r,e.startCap)),y=0),p.last&&e.endCap>=17&&e.endCap<=19&&(x.push(Kf(d,true,r,e.endCap)),g=0),p.first&&e.startCap===Jf&&(x.push(Zf(d,false,r)),y=0),p.last&&e.endCap===Jf&&(x.push(Zf(d,true,r)),g=0));for(let[M,P]of l){if(h){n.push(ti(d,true,P,e)),n.push(ti(d,true,M,e).reverse());continue}let E=ti(d,false,P,e),R=ti(d,false,M,e).reverse(),T=Xr(d[d.length-2],d[d.length-1]),A=Xr(d[1],d[0]),w=g??(p.last&&!(e.dash&&i)?e.endCap:e.dashCap),I=y??(p.first&&!(e.dash&&i)?e.startCap:e.dashCap),S=m?Qs(d[d.length-2],d[d.length-1]):null,v=m?Qs(d[0],d[1]):null,C=S?qf(d[d.length-1],S,M,P,false):zf(d[d.length-1],T,M,P,w,r,e.doubleRoundCap),U=v?qf(d[0],v,M,P,true):zf(d[0],A,-P,-M,I,r,e.doubleRoundCap);if(v&&(E[0]=$f(d[0],v,P)),w===0&&C.length===2&&E.length>2&&R.length>2){let F=(k,W)=>(k.x-W.x)*T.ux+(k.y-W.y)*T.uy<-1e-9,B=E[E.length-2],X=R[1];F(C[0],B)&&(C[0]={x:B.x,y:B.y}),F(C[1],X)&&(C[1]={x:X.x,y:X.y});}let D=[...E.slice(I===1?1:0,-1),...C,...R.slice(1,-1),...U];n.push(D);let L=Math.sign(Hr(D));for(let F of x)n.push(Math.sign(Hr(F))===L?F:F.slice().reverse());}}}return n}var Fy=1,ky=2,je=11920928955078125e-23,it=Math.fround;function yu(t,e){let n=t.length;if(n<2)return 0;let o=(e[n-1]&128)!==0?t[n-1]:t[0],s=0;for(let i=0;i<n;i++){let a=t[i],u=it(o.x-a.x);if(Math.abs(u)>=je){let l=it(-a.x/u);if(!(l<-je)&&!(it(l-1)>je)){let c=it(it(it(o.y-a.y)*l)+a.y);s=Math.min(s,c);}}o=a;}return s<0?-s:0}function By(t,e,n,r){let o=it(e),s=it(it(t)*.5),i=[{x:s,y:-o},{x:0,y:0},{x:-s,y:-o}];r&&n!==0&&i.push({x:0,y:it(it(n)-o)});let a=new Uint8Array(i.length);return a.fill(1),a[0]=0,r&&(a[i.length-1]|=128),{kind:"plus-path",points:i,types:a,fillRule:"nonzero"}}function n0(t,e,n){let r=e+n;if(n<8||r>t.byteLength)return null;let o=t.getInt32(e+4,true),s=e+8,i=b=>t.getFloat32(s+b,true),a=b=>t.getUint32(s+b,true);if(o===1){if(s+52>r)return null;let b=i(0),h=i(4),p=i(8),d=a(12)!==0,x=By(b,h,p,d),y=yu(x.points,x.types);return {kind:"plus-customlinecap",capType:1,baseCap:0,baseInset:b!==0?it(h/b):0,strokeStartCap:a(16),strokeEndCap:a(20),strokeJoin:a(24),strokeMiterLimit:i(28),widthScale:i(32),fillPath:d?x:null,linePath:d?null:x,fillLength:d?y:0,strokeLength:d?0:y,arrow:{width:b,height:h,middleInset:p,filled:d}}}if(o!==0||s+48>r)return null;let u=a(0),l=s+48,c=()=>{if(l+4>r)return null;let b=t.getInt32(l,true);if(l+=4,b<=0||l+b>r)return null;let h=tr(t,l,b);return l+=b,h},f=u&Fy?c():null,m=u&ky?c():null;return {kind:"plus-customlinecap",capType:0,baseCap:a(4),baseInset:i(8),strokeStartCap:a(12),strokeEndCap:a(16),strokeJoin:a(20),strokeMiterLimit:i(24),widthScale:i(28),fillPath:f,linePath:m,fillLength:f?yu(f.points,f.types):0,strokeLength:m?yu(m.points,m.types):0}}function Gy(t,e,n,r){let o=it(r.x-n.x),s=it(r.y-n.y),i=Math.sqrt(it(it(o*o)+it(s*s)));if(i<je)return null;let a=it(1/i),u=it(o*a),l=it(s*a),c=it(t.x-n.x),f=it(t.y-n.y),m=it(it(f*f)+it(c*c)),b=it(it(f*l)+it(c*u));if(b<je&&m>=e)return null;let h=e-m+b*b;if(h<je)return null;let p=Math.sqrt(h),d=null;if(m>=e){let y=b-p;y>je&&y>=0&&(d=y);}if(d===null){let y=p+b;y>je&&y>=0&&(d=y);}if(d===null)return null;let x=it(d);return {x:it(it(x*u)+n.x),y:it(it(x*l)+n.y)}}function Oy(t,e,n,r,o){let s=t.length,i=g=>n?s-1-g:g,a={...t[i(0)]},u=0,l=false,c=false,f=i(0);for(;u<s;){let g=t[i(u)];f=i(u);let M=it(g.x-a.x),P=it(g.y-a.y);if(it(it(M*M)+it(P*P))>r){l=true;break}c=e[i(u)],e[i(u)]=true,u++;}let m=i(Math.max(0,u-1));l&&!c&&(e[m]=false);let b=t[m],h=Gy(a,r,t[f],b)??{x:b.x,y:b.y},p=it(h.x-a.x),d=it(h.y-a.y),x=Math.sqrt(p*p+d*d);x>je?(p=it(p/x),d=it(d/x)):(p=0,d=0);let y=it(1-o);return t[m]={x:it(it(it(a.x-h.x)*y)+h.x),y:it(it(it(a.y-h.y)*y)+h.y)},{x:p,y:d}}function t0(t,e,n,r){let o=it(n.y*r),s=it(-n.x*r),i=it(n.x*r),a=it(n.y*r),u=t.points.map(l=>({x:it(it(it(o*l.x)+it(i*l.y))+e.x),y:it(it(it(s*l.x)+it(a*l.y))+e.y)}));return {...t,points:u}}function e0(t,e){let n=yn(r=>{let o=t.points,s=t.types,i=0;for(;i<o.length;){let a=s[i]&7;if(a===0||i===0)r.moveTo(o[i].x,o[i].y),i++;else if(a===3&&i+2<o.length){r.bezierCurveTo(o[i].x,o[i].y,o[i+1].x,o[i+1].y,o[i+2].x,o[i+2].y),i+=3,s[i-1]&128&&r.closePath();continue}else r.lineTo(o[i].x,o[i].y),i++;s[i-1]&128&&r.closePath();}},[1,0,0,1,0,0]);return e?n.map(r=>({...r,closed:true})):n}function r0(t,e,n,r,o={}){let s=[],i=[],a=[],u=o.minFillScale??2;for(let l of t){if(l.closed||!n&&!r){s.push(l),i.push({start:false,end:false});continue}let c=[];for(let d=0;d+1<l.pts.length;d+=2)c.push({x:l.pts[d],y:l.pts[d+1]});if(c.length<2){s.push(l),i.push({start:false,end:false});continue}let f=new Array(c.length).fill(false),m={...c[0]},b={...c[c.length-1]},h=(d,x,y)=>{let g=y?d.fillPath:d.linePath;if(!g||g.points.length===0)return;let M=it(d.widthScale*e),P,E;y?(P=d.fillLength,E=Math.max(M,1)):(P=Math.abs(d.strokeLength)<je?1:d.strokeLength,E=M);let R=y&&Math.abs(P)<je?0:it(d.baseInset/P),T=it(P*E),A=Oy(c,f,x,it(T*T),R),w={x:-A.x,y:-A.y},I=x?b:m;if(y){let S=t0(g,I,w,Math.max(E,u));for(let v of e0(S,true)){let C=[];for(let U=0;U+1<v.pts.length;U+=2)C.push({x:v.pts[U],y:v.pts[U+1]});a.push(C);}}else {let S=t0(g,I,w,E),v={half:Math.max(M,1)/2,join:(o.widenJoin??(C=>C))(d.strokeJoin),miterLimit:10,startCap:d.strokeStartCap,endCap:d.strokeEndCap,dashCap:0,dash:null,dashOffset:0,compound:null,inset:false};a.push(...(o.widen??Wn)(e0(S,false),v).map(C=>C.reverse()));}};n&&h(n,false,true),r&&h(r,true,true),n&&h(n,false,false),r&&h(r,true,false);let p=[];c.forEach((d,x)=>{f[x]||p.push(d.x,d.y);}),p.length>=4&&(s.push({pts:p,closed:false,curved:l.curved}),i.push({start:!!n,end:!!r}));}return {figures:s,capped:i,polygons:a}}var o0=1,s0=2,i0=4,a0=8,u0=16,gu=32,l0=64,c0=128,m0=256,f0=512,b0=1024,Mu=2048,h0=4096,Co=1024;function p0(t,e,n,r,o=e){if(n<20)return null;let s=e+n,i=Nr(t.getUint32(e,true)),a=t.getUint32(e+(i?8:4),true),u=t.getFloat32(e+16,true),l=e+20,c=()=>{if(l+4>s)return;let b=t.getUint32(l,true);return l+=4,b},f=()=>{if(l+4>s)return;let b=t.getFloat32(l,true);return l+=4,b},m={kind:"plus-pen",color:"rgba(0,0,0,1)",width:u,dashStyle:0};if(i&&(m.unit=t.getUint32(e+12,true)),a&o0&&(l+24<=s&&(m.transform=[0,4,8,12,16,20].map(b=>t.getFloat32(l+b,true))),l+=24),a&s0&&(m.startCap=c()),a&i0&&(m.endCap=c()),a&a0&&(m.lineJoin=c()),a&u0&&(m.miterLimit=f()),a&gu&&(m.dashStyle=c()??0),a&l0&&(m.dashCap=c()),a&c0&&(m.dashOffset=f()),a&m0){let b=c()??0;b>0&&b<=Co&&l+b*4<=s&&(m.dashPattern=Array.from({length:b},(h,p)=>t.getFloat32(l+p*4,true)),a&gu||(m.dashStyle=5)),l+=Math.min(b,Co)*4;}if(a&f0&&(m.alignment=c()),a&b0){let b=c()??0;b>=2&&b<=Co&&l+b*4<=s&&(m.compound=Array.from({length:b},(h,p)=>t.getFloat32(l+p*4,true))),l+=Math.min(b,Co)*4;}for(let b of [Mu,h0])if(a&b){let h=c()??0,p=l+h<=s?n0(t,l,h):null;b===Mu?m.customStartCap=p:m.customEndCap=p,l+=h;}if(l+8<=s){let b=Ks(t,l,s-l,r,o);b&&(m.color=b.color,m.brush=b);}return m}function d0(t,e,n){if(n<20)return null;let r=e+n,o=Nr(t.getUint32(e,true)),s=t.getUint32(e+(o?8:4),true),i=e+20,a=()=>{let u=i+4<=r?t.getUint32(i,true):0;i+=4+Math.min(u,Co)*4;};s&o0&&(i+=24);for(let u of [s0,i0,a0,u0,gu,l0,c0])s&u&&(i+=4);s&m0&&a(),s&f0&&(i+=4),s&b0&&a();for(let u of [Mu,h0])if(s&u){let l=i+4<=r?t.getUint32(i,true):0;i+=4+l;}return i+8<=r?i:null}function ei(t,e,n,r){let o=null,s=t.getUint32(e+4,true);if(s===1&&n>=28){let a=t.getUint32(e+24,true);if(a===0){let u=t.getInt32(e+8,true),l=t.getInt32(e+12,true),c=t.getInt32(e+16,true),f=t.getUint32(e+20,true);$(` Bitmap(Pixel): ${u}\xD7${l}, stride=${c}, pixelFormat=0x${f.toString(16).padStart(8,"0")}`);let m=e+28,b=Math.abs(c);if(u>0&&l>0&&u<=8192&&l<=8192&&m+b*l<=t.byteLength){let h=pf(t,m,u,l,c,f);h?($(` Bitmap(Pixel): decoded successfully, size=${h.byteLength} bytes`),o=h):z(" Bitmap(Pixel): decodeEmfPlusBitmapPixels returned null");}}else if(a===1){let u=e+28,l=n-28;if($(` Bitmap(Compressed): imgLen=${l}, imgStart=0x${u.toString(16)}`),l>0&&u+l<=t.byteLength){if(o=t.buffer.slice(t.byteOffset+u,t.byteOffset+u+l),o.byteLength>=4){let c=new Uint8Array(o,0,4);$(` Bitmap(Compressed): first 4 bytes = [${Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join(" ")}]`);}}}else ;}else if(s===2&&n>=12){t.getUint32(e+8,true);let u=t.getUint32(e+12,true);let c=e+16;if(u>0&&c+u<=t.byteLength){if(o=t.buffer.slice(t.byteOffset+c,t.byteOffset+c+u),o.byteLength>=4){new DataView(o).getUint32(0,true);}}else z(` Metafile: out of bounds or empty (mfStart=0x${c.toString(16)}, mfDataSize=${u}, viewLen=${t.byteLength})`);}return {data:o,type:s}}function x0(t,e,n){if(n<28)return null;let r=t.getFloat32(e+4,true),o=t.getUint32(e+8,true),s=t.getInt32(e+12,true),i=t.getUint32(e+20,true),a="sans-serif";return i>0&&e+24+i*2<=e+n&&(a=Dn(t,e+24,i)||"sans-serif"),{kind:"plus-font",emSize:r||12,flags:s,family:a,unit:o}}var Ny=64*1024*1024;function ni(){return {continuationBuffer:null,continuationObjectId:-1,continuationObjectType:0,continuationTotalSize:0,continuationOffset:0,continuationKey:void 0}}function y0(t){t.continuationBuffer=null,t.continuationObjectId=-1,t.continuationObjectType=0,t.continuationTotalSize=0,t.continuationOffset=0,t.continuationKey=void 0;}function Wy(t,e,n,r){let o=t.continuationBuffer;if(!o)return;let s=n,i=r;i>=4&&e.getUint32(n,true)===t.continuationTotalSize&&(s+=4,i-=4);let a=Math.max(0,Math.min(i,t.continuationTotalSize-t.continuationOffset));o.set(new Uint8Array(e.buffer,e.byteOffset+s,a),t.continuationOffset),t.continuationOffset+=a;}function Hy(t,e){let n=t.continuationBuffer,r=n?{view:new DataView(n.buffer,n.byteOffset,n.byteLength),flags:t.continuationObjectType<<8|e,dataOff:0,dataSize:t.continuationTotalSize,cacheKey:t.continuationKey??-1}:null;return y0(t),r}function ri(t,e,n,r,o){let s=(n&32768)!==0,i=n&255,a=t.continuationBuffer!==null&&i===t.continuationObjectId;if(!s&&!a)return {view:e,flags:n,dataOff:r,dataSize:o,cacheKey:r};if(s&&!a){if(t.continuationBuffer!==null&&z(`EMFPLUS_OBJECT continuation: object ${t.continuationObjectId} never completed, dropping it`),y0(t),o<4)return null;let u=e.getUint32(r,true),l=e.byteLength-r;if(u<=0||u>Ny||u>l)return null;t.continuationBuffer=new Uint8Array(u),t.continuationObjectId=i,t.continuationObjectType=n>>8&127,t.continuationTotalSize=u,t.continuationOffset=0,t.continuationKey=r;}return Wy(t,e,r,o),!s||t.continuationOffset>=t.continuationTotalSize?Hy(t,i):null}function Xy(t,e){let n=t.flags>>8&127;if(n!==1&&n!==2||t.dataSize<8)return;let{view:r}=t,o=t.dataOff+t.dataSize,s=t.dataOff;if(n===2){let c=d0(r,t.dataOff,t.dataSize);if(c===null)return;s=c;}let i=Nr(r.getUint32(s,true)),a=s+(i?4:0);if(a+8>o||r.getUint32(a,true)!==2)return;let u=Lf(r,a+4,o);if(u===null)return;let l=_f(r,u,o);l&&e.push({key:t.cacheKey,view:r,byteStart:l.start,byteEnd:l.end});}function Yy(t,e,n,r,o){let s=e+n,i=e,a=0,u=5e5;for(;i+12<=s&&a<u;){let l=t.getUint16(i,true),c=t.getUint16(i+2,true),f=t.getUint32(i+4,true),m=t.getUint32(i+8,true);if(f<12||i+f>s)break;if(a++,l===16392){let b=ri(r,t,c,i+12,m);b&&o(b);}i+=f;}}function wu(t,e){let n=ni(),r=0,o=t.byteLength,s=0,i=5e5;for(;r+8<=o&&s<i;){let a=t.getUint32(r,true),u=t.getUint32(r+4,true);if(u<8||r+u>o)break;if(s++,a===70&&u>=16){let l=r+8,c=t.getUint32(l,true);t.getUint32(l+4,true)===726027589&&c>4&&Yy(t,l+8,c-4,n,e);}else if(a===14)break;r+=u;}}function $y(t){let e=[];return wu(t,n=>Xy(n,e)),e}async function Iu(t,e,n){let r=n-e;if(r<=0)return null;let o=new Uint8Array(t.buffer,t.byteOffset+e,r),s=new ArrayBuffer(r);new Uint8Array(s).set(o);try{let i=await Lr(s);if(!i)return null;let{width:a,height:u}=i;if(a<=0||u<=0||a>8192||u>8192)return i.close(),null;let l=It(a,u);if(!l)return i.close(),null;le(l.ctx,i.drawable,0,0,a,u),i.close();let c=Tt(l.ctx,0,0,a,u);return {width:a,height:u,rgba:new Uint8ClampedArray(c.data.buffer.slice(0))}}catch(i){return z("preDecodeEmfPlusTextures: failed to decode a compressed texture image:",i instanceof Error?i.message:i),null}}async function si(t){let e=new Map,n;try{n=$y(t);}catch(r){return z("preDecodeEmfPlusTextures: scan failed:",r instanceof Error?r.message:r),e}if(n.length===0)return e;$(`preDecodeEmfPlusTextures: found ${n.length} compressed-texture candidate(s)`);for(let r of n){let o=await Iu(r.view,r.byteStart,r.byteEnd);o&&(e.set(r.key,o),$(`preDecodeEmfPlusTextures: decoded texture for key=0x${r.key.toString(16)}: ${o.width}x${o.height}`));}return e}var vu=3;async function Cu(t,e=0){let n=new Map,r=[];try{wu(t,o=>{if((o.flags>>8&127)!==5||o.dataSize<8)return;let i=ei(o.view,o.dataOff,o.dataSize,o.flags&255);i.data&&i.data.byteLength>0&&r.push({key:o.cacheKey,type:i.type,data:i.data});});}catch(o){return z("preDecodeEmfPlusImages: scan failed:",o instanceof Error?o.message:o),n}for(let o of r){let s=new DataView(o.data,0,o.data.byteLength);if(o.type===2){if(e>=vu)continue;n.set(o.key,{kind:"metafile",caches:await jy(s,e+1)});continue}let i=await Iu(s,0,o.data.byteLength);i&&(n.set(o.key,{kind:"bitmap",...i}),$(`preDecodeEmfPlusImages: decoded image key=0x${o.key.toString(16)}: ${i.width}x${i.height}`));}return n}async function jy(t,e=0){return {textures:await si(t),images:await Cu(t,e)}}function g0(t,e,n){if(!n)return (t%e+e)%e;let r=(t%(2*e)+2*e)%(2*e);return r<e?r:2*e-1-r}function Vy(t,e,n,r,o,s,i,a){let u=Math.floor(t+1e-9),l=Math.floor(e+1e-9),c=Math.round(Math.max(0,t-u)*2048)/2048,f=Math.round(Math.max(0,e-l)*2048)/2048,m=s==="clamp",b=s==="tile-flip-x"||s==="tile-flip-xy",h=s==="tile-flip-y"||s==="tile-flip-xy",p=0,d=0,x=0,y=0;for(let g=0;g<4;g++){let M=u+(g&1),P=l+(g>>1),E=(g&1?c:1-c)*(g>>1?f:1-f);if(E<=0)continue;let R,T;if(m){if(M<0||P<0||M>=n||P>=r)continue;R=M,T=P;}else R=g0(M,n,b),T=g0(P,r,h);let A=(T*n+R)*4,w=o[A+3];p+=E*Math.round(o[A]*w/255),d+=E*Math.round(o[A+1]*w/255),x+=E*Math.round(o[A+2]*w/255),y+=E*w;}y=Math.round(y),!(y<=0)&&(i[a]=Math.round(Math.round(p)*255/y),i[a+1]=Math.round(Math.round(d)*255/y),i[a+2]=Math.round(Math.round(x)*255/y),i[a+3]=y);}function ii(t,e=false){let[n,r,o,s,i,a]=[t[0],t[1],t[2],t[3],t[4],t[5]].map(Math.fround),u=e?_(_(_(_(.5*n)+_(.5*o))+i)-.5):i,l=e?_(_(_(_(.5*r)+_(.5*s))+a)-.5):a,c=_(_(n*s)-_(r*o));if(!Number.isFinite(c)||c===0)return null;let f=_(1/c);return [_(s*f),_(-r*f),_(-o*f),_(n*f),_(_(_(o*l)-_(s*u))*f),_(_(_(r*u)-_(n*l))*f)]}function E0(t,e,n,r,o,s,i,a,u,l,c){let f=new Float64Array(a),m=new Float64Array(a);for(let b=0;b<u;b++){let h=0;for(;h<a;){let p=a;if(c){for(;h<a&&c[b*a+h]===0;)h++;if(h>=a)break;for(p=h;p<a&&c[b*a+p]!==0;)p++;}let d=p-h,x=f.subarray(h,p),y=m.subarray(h,p);zy(t,s+h,i+b,x,y,d);for(let g=0;g<d;g++)Vy(x[g],y[g],e,n,r,o,l,(b*a+h+g)*4);h=p;}}}function zy(t,e,n,r,o,s=r.length){if(s<=0)return;let[i,a,u,l,c,f]=t,m=P=>[_(_(_(i*P)+_(u*n))+c),_(_(_(a*P)+_(l*n))+f)],[b,h]=m(e),[p,d]=m(e+s),x=_(_(p-b)/s),y=_(_(d-h)/s),g=b,M=h;for(let P=0;P<s;P++)r[P]=g,o[P]=M,g=_(g+x),M=_(M+y);}var M0=[1,0,0,1,0,0];function qy(t,e){return (t[e+3]<<24|t[e]<<16|t[e+1]<<8|t[e+2])>>>0}function P0(t,e,n=M0){let{width:r,height:o,rgba:s}=e;if(r<=0||o<=0)return null;try{let i=e.transform??M0,a=(u,l)=>{let c=Math.floor(u),f=Math.floor(l);return c<0||f<0||c>=r||f>=o?null:qy(s,(f*r+c)*4)};return Hs(t,{x:0,y:0,w:r,h:o},r,o,e.wrapMode,i,Ao(n),{phaseX:0,lagX:0,lagY:0},a)}catch{return null}}var _u=new Float32Array(1),Uu=new Uint32Array(_u.buffer);function R0(t){return _u[0]=t,t>0?Uu[0]-=1:t<0?Uu[0]+=1:Uu[0]=2147483649,_u[0]}function st(t,e){let n=t+e,r=n-t,o=t-(n-r)+(e-r),s=_(n);return Math.fround(n)===n&&o<0?R0(n):s}var $t=(t,e)=>st(t,-e),J=(t,e)=>_(t*e);function nr(t,e){let n=_(t/e);return (e>0?n*e>t:n*e<t)&&(n=R0(n)),n}var ai=.000596046448;function Lu(t){let[e,n,r,o,s,i]=t,a=Math.abs(e),u=Math.abs(o),l=Math.abs(n),c=Math.abs(r),f=a>u?a:u,m=l>c?n:c,b;f>m?b=a>u?e:o:b=l>c?n:r;let h=_(Math.abs(b)*ai),p=15;return h>l&&h>c?(p=3,ai>Math.abs($t(e,1))&&ai>Math.abs($t(o,1))&&(p=1)):h>Math.abs($t(e,o))&&h>Math.abs(st(r,n))&&(p=ai>Math.abs($t(st(J(n,n),J(e,e)),1))?5:7),s===0&&i===0&&(p&=-2),p}function Uo(t,e){let[n,r,o,s,i,a]=t,[u,l,c,f]=e,m=-f,b=-c,h=$t(J(st(c,u),st(l,f)),J(l,u)),p=st(h,$t(J(m,u),J(l,c)));if(!(Math.abs(p)>=11920929e-14))return null;let d=nr(1,p),x=J(st(J(f,o),J(m,n)),d),y=J(st(J(f,s),J(m,r)),d),g=J(st(J(c,i),J(b,n)),d),M=J(st(J(c,a),J(b,r)),d),P=J(-u,f),E=J(-l,c),R=$t(J(st(u,c),st(l,f)),J(u,l)),T=J(st(st(J(P,o),J(R,n)),J(E,i)),d),A=J(st(st(J(P,s),J(R,r)),J(E,a)),d);return [x,y,g,M,T,A]}function _o(t,e){let n=Lu(t),[r,o,s,i,a,u]=t,l=[];for(let c=0;c<e.length;c+=2){let f=e[c],m=e[c+1];n===0?l.push(f,m):(n&-2)===0?l.push(st(a,f),st(u,m)):(n&-4)===0?l.push(st(J(r,f),a),st(J(i,m),u)):l.push(st(st(J(f,r),J(m,s)),a),st(st(J(f,o),J(m,i)),u));}return l}function Jy(t,e){let n=Uo(t,e);if(!n)return null;let[r,o,s,i]=e;return _o(n,[r,o,st(r,s),o,r,st(o,i)])}function ui(t,e){let[n,r,o,s,i,a]=t,[u,l,c,f,m,b]=e;return [st(J(n,u),J(r,c)),st(J(n,l),J(r,f)),st(J(o,u),J(s,c)),st(J(o,l),J(s,f)),st(st(J(i,u),J(a,c)),m),st(st(J(i,l),J(a,f)),b)]}function Du(t,e,n){let r=Jy(t,e);if(!r)return null;let o=Uo(r,e);return o?ui(o,n):null}function Fu(t){let[e,n,r,o,s,i]=t,a=$t(J(e,o),J(n,r));if(!Number.isFinite(a)||a===0)return null;let u=nr(1,a);return [J(o,u),J(-n,u),J(-r,u),J(e,u),J($t(J(r,i),J(o,s)),u),J($t(J(n,s),J(e,i)),u)]}function T0(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=Lu(t),b=E=>m===0?[E,n]:(m&-2)===0?[st(E,c),st(n,f)]:(m&-4)===0?[st(J(E,i),c),st(J(n,l),f)]:[st(st(J(i,E),J(u,n)),c),st(st(J(a,E),J(l,n)),f)],[h,p]=b(e),[d,x]=b(e+r),y=nr($t(d,h),r),g=nr($t(x,p),r),M=h,P=p;for(let E=0;E<r;E++)o[E]=M,s[E]=P,M=st(M,y),P=st(P,g);}function A0(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=Lu(t),b=A=>m===0?[A,n]:(m&-2)===0?[st(A,c),st(n,f)]:(m&-4)===0?[st(J(A,i),c),st(J(n,l),f)]:[st(st(J(i,A),J(u,n)),c),st(st(J(a,A),J(l,n)),f)],[h,p]=b(e),[d,x]=b(e+r),y=A=>{let w=Math.floor(st(J(A,65536),.5));return w>=-2147483648&&w<=2147483647?w:-2147483648},g=(A,w)=>M(nr(J($t(w,A),65536),r)),M=A=>{let w=Math.floor(st(A,.5));return w>=-2147483648&&w<=2147483647?w:-2147483648},P=y(h),E=y(p),R=g(h,d),T=g(p,x);for(let A=0;A<r;A++)o[A]=P,s[A]=E,P=P+R|0,E=E+T|0;}function Ky(t,e){let[n,r,o,s]=t.map(Math.fround),[i,a,u,l]=e.map(Math.fround),c=st(n,o),f=st(r,s),m=st(i,u),b=st(a,l);if(n===c||r===f)return null;let h=nr($t(m,i),$t(c,n)),p=nr($t(b,a),$t(f,r)),d=$t(m,J(h,c)),x=$t(b,J(p,f));return _o([h,0,0,p,d,x],[n,r,c,r,n,f])}function w0(t,e){let[n,r,o,s]=e.map(Math.fround),i=_o(t,[n,r,st(n,o),st(r,s)]);return [i[0],i[1],$t(i[2],i[0]),$t(i[3],i[1])]}function I0(t,e,n){let r=Ky(t,e);if(!r)return null;let o=Uo(r,t);return o?ui(o,n):null}var S0=[[-1675,5953,56660,6337,-1739],[-1612,5575,56650,6727,-1804],[-1550,5203,56630,7123,-1870],[-1489,4837,56600,7525,-1937],[-1429,4477,56561,7931,-2004],[-1371,4125,56510,8345,-2073],[-1313,3777,56451,8763,-2142],[-1257,3437,56381,9187,-2212],[-1202,3103,56301,9617,-2283],[-1148,2775,56211,10053,-2355],[-1095,2453,56112,10493,-2427],[-1044,2139,56002,10939,-2500],[-993,1829,55884,11389,-2573],[-945,1529,55754,11845,-2647],[-897,1233,55616,12305,-2721],[-851,945,55467,12771,-2796],[-806,663,55309,13241,-2871],[-762,387,55142,13715,-2946],[-720,119,54964,14195,-3022],[-679,-143,54778,14677,-3097],[-639,-399,54582,15165,-3173],[-600,-649,54377,15657,-3249],[-563,-891,54162,16153,-3325],[-528,-1125,53937,16653,-3401],[-493,-1355,53705,17155,-3476],[-460,-1577,53462,17663,-3552],[-429,-1791,53210,18173,-3627],[-398,-2001,52950,18687,-3702],[-369,-2203,52681,19203,-3776],[-341,-2399,52403,19723,-3850],[-315,-2587,52116,20245,-3923],[-289,-2771,51821,20771,-3996],[-265,-2947,51517,21299,-4068],[-243,-3115,51204,21829,-4139],[-221,-3279,50884,22361,-4209],[-201,-3435,50554,22897,-4279],[-182,-3585,50217,23433,-4347],[-164,-3729,49872,23971,-4414],[-147,-3867,49518,24513,-4481],[-131,-3999,49158,25053,-4545],[-117,-4123,48788,25597,-4609],[-103,-4243,48412,26141,-4671],[-90,-4357,48029,26685,-4731],[-79,-4463,47637,27231,-4790],[-68,-4565,47239,27777,-4847],[-59,-4659,46833,28323,-4902],[-50,-4749,46421,28869,-4955],[-42,-4833,46002,29415,-5006],[-35,-4911,45576,29961,-5055],[-29,-4983,45143,30507,-5102],[-24,-5049,44704,31051,-5146],[-19,-5111,44259,31595,-5188],[-15,-5167,43807,32139,-5228],[-11,-5219,43351,32679,-5264],[-8,-5265,42888,33219,-5298],[-6,-5305,42419,33757,-5329],[-4,-5341,41944,34295,-5358],[-3,-5371,41464,34829,-5383],[-2,-5397,40980,35359,-5404],[-1,-5419,40490,35889,-5423],[0,-5437,39996,36415,-5438],[0,-5449,39497,36937,-5449],[0,-5457,38993,37457,-5457],[0,-5461,38485,37973,-5461]];function ku(t){return t<64?{first:-2,weights:S0[t]}:{first:-1,weights:S0[127-t].slice().reverse()}}var Zy=(()=>{let t=new Int32Array(512).fill(Number.NaN);for(let e=0;e<128;e++){let{first:n,weights:r}=ku(e),o=-32768;for(let s=0;s<=5;s++){let i=128*(n+s)-64-e-1;i>=-256&&i<=255&&(t[i+256]=o),s<5&&(o+=r[s]);}}return t})();function li(t){return t<-256?-32768:t>255?32768:Zy[t+256]}var Bu=1/65536;function Qy(t){return t<=-128?0:t>=128?65536:32768+(t<0?-(512*-t-2*t*t):512*t-2*t*t)}function t2(t){return t<-256?0:t>255?65536:32768+li(t)}var Bt=t=>t|0,C0=(t,e)=>Math.floor(t*e/65536);function e2(t){return t>=-32768&&t<=32767}function U0(t){let[e,n,r,o]=t.src.map(Math.fround),[s,i,a,u]=t.dest.map(Math.fround);if(![e,n,r,o,s,i,a,u].every(e2))return null;let l=t.kernel==="cubic"?2:1,c=t.kernel==="cubic"?131072:65536,f=.5,m=G=>kn(ut(Z(G,65536),f)),b=m(Pt(r,a));m(Pt(a,r));let p=m(Pt(o,u));m(Pt(u,o));if(b===0||p===0)return null;let x=G=>kn(ut(Z(G,16),f)),y=x(s),g=x(ut(Z(r,Pt(a,r)),s)),M=x(i),P=x(ut(Z(o,Pt(u,o)),i)),E=Math.min(y,g),R=Math.max(y,g),T=Math.min(M,P),A=Math.max(M,P),w=E+15>>4,I=Bt(E<<12),S=Bt(R<<12),v=Bt(T<<12),C=Bt(A<<12),U=G=>_(G),D=U(b),L,F;b<0?(L=U(S+65535>>16),F=ut(s,a)):(L=U(I>>16),F=s);let B=et(F,L);B=Z(B,D),B=Z(B,Bu),B=ut(B,e);let X=m(B),k=(G,j)=>{let tt=m(Pt(Z(l,G),j));return tt<0&&(tt=-tt),tt<c?c:tt},W=k(r,a),O=kn(ut(Z(Pt(65536,U(W)),65536),f)),q=U(p),Q;if(p<0){let G=U(C+65535>>16);G=et(G,ut(u,i)),G=Z(G,q),G=Z(G,Bu),Q=m(et(n,G));}else {let G=U(v>>16);G=et(G,i),G=Z(G,q),G=Z(G,Bu),Q=m(ut(G,n));}let K=k(o,u),V=kn(ut(Z(Pt(65536,U(K)),65536),f)),rt=v>>16,H=(S+65535>>16)-(I>>16)+1,Y=2*(K+65535>>16)+1,N=(G,j)=>{let tt=j-32768;return tt>=-2147483648&&tt<=2147483647&&tt-G>=-2147483648&&tt+G<=2147483647};return !N(W,X)||!N(K,Q)?null:{request:t,firstColumn:w,columns:H,firstRow:rt,xStart:X,xStep:b,xStretch:W,xRecip:O,yStart:Q,yStep:p,yStretch:K,yRecip:V,kernelRows:Y,table:t.kernel==="cubic"?t2:Qy,shift:t.kernel==="cubic"?8:9,rows:new Map}}function Gu(t,e,n){if(!n)return (t%e+e)%e;let r=(t%e+e)%e;return Math.floor(t/e)%2!==0?e-r-1:r}function n2(t){return [t>>>16&255,t>>>8&255,t&255,t>>>24]}function _0(t,e){let{request:n,columns:r,xStart:o,xStep:s,xStretch:i,xRecip:a,table:u,shift:l}=t,{width:c,wrap:f=4,clampArgb:m=0}=n,b=n.kernel==="cubic",h=new Uint8Array(r*4),p=n2(m),d=f===1||f===3,x=Bt(o-32768),y=[0,0,0,0];for(let g=0;g<r;g++){let M=Bt(i+65535+x),P=M>>16,E=Bt(M-2*i)>>16;y[0]=y[1]=y[2]=y[3]=0;let R=0,T=(D,L,F)=>{let B=u(Bt(D)>>l),X=B-R;R=B,y[0]+=L[F]*X,y[1]+=L[F+1]*X,y[2]+=L[F+2]*X,y[3]+=L[F+3]*X;},A=D=>C0(Bt(Bt(D<<16)-x),a),w=E<0?0:E,I=P<c-1?P:c-1,S=A(E);for(let D=E;D<Math.min(w,P+1);D++)f===4||!e?T(S,p,0):T(S,e,Gu(D,c,d)*4),S=Bt(S+a);if(w<=I){S=A(w);for(let D=w;D<=I;D++)e?T(S,e,D*4):T(S,p,0),S=Bt(S+a);}let v=Math.max(I+1,E);if(v<=P){S=A(v);for(let D=v;D<=P;D++)f===4||!e?T(S,p,0):T(S,e,Gu(D,c,d)*4),S=Bt(S+a);}let C=g*4,U=Math.max(0,Math.min(255,y[3]+32768>>16));h[C+3]=U;for(let D=0;D<3;D++){let L=y[D]+32768>>16;h[C+D]=b?Math.max(0,Math.min(U,L)):Math.min(255,L);}x=Bt(x+s);}return h}function v0(t,e){let{request:n}=t,{height:r,width:o,wrap:s=4}=n,i=e;if(i<0||i>=r){if(s===4)return null;i=Gu(i,r,s===2||s===3);}let a=t.rows.get(i);if(!a){let u=n.pixels instanceof Uint8Array||n.pixels instanceof Uint8ClampedArray?n.pixels.subarray(i*o*4,(i+1)*o*4):Uint8Array.from(Array.prototype.slice.call(n.pixels,i*o*4,(i+1)*o*4));a=_0(t,u),t.rows.set(i,a);}return a}function r2(t){let e=t.rows.get(Number.NaN);return e||(e=_0(t,null),t.rows.set(Number.NaN,e)),e}function L0(t,e,n,r){let{firstColumn:o,columns:s,firstRow:i,yStart:a,yStep:u,yStretch:l,yRecip:c,kernelRows:f,table:m,shift:b}=t,h=Math.max(n,o),p=Math.min(r,o+s);if(p<h||p-h>s)return null;let d=p-h,x=Math.max(e,i),y=Bt(a-32768+Bt((x-i)*u)),g=Bt(y+l+65535)>>16,M=Bt(y-l+65535)>>16;if(g<M)return null;let P=C0(Bt(Bt(M<<16)-y),c),E=0,R=[],T=[];for(let I=0;I<f;I++){let S=M+I;if(S>g){T.push(0),R.push(null);continue}let v=m(Bt(P)>>b);T.push(v-E),E=v,P=Bt(P+c),R.push(S>=0&&S<t.request.height?v0(t,S):t.request.wrap===4||t.request.wrap===void 0?r2(t):v0(t,S));}let A=t.request.kernel==="cubic",w=new Uint8Array(d*4);for(let I=0;I<d;I++){let S=(h-o+I)*4,v=0,C=0,U=0,D=0;for(let B=0;B<f;B++){let X=R[B];if(!X)continue;let k=T[B];v+=X[S]*k,C+=X[S+1]*k,U+=X[S+2]*k,D+=X[S+3]*k;}let L=I*4,F=Math.max(0,Math.min(255,D+32768>>16));w[L+3]=F;for(let[B,X]of [[0,v],[1,C],[2,U]]){let k=X+32768>>16;w[L+B]=A?Math.max(0,Math.min(F,k)):Math.min(255,k);}}return {x:h,pixels:w}}var o2={0:"bilinear",1:"bilinear",2:"hq-bicubic",3:"bilinear",4:"bicubic",5:"nearest",6:"hq-bilinear",7:"hq-bicubic"},s2=new Set([2,4]),Wu=16*1024*1024;function N0(t){return o2[t]??"bilinear"}function Ee(t){return s2.has(t)}function W0(t){let e=t[0]*t[3]-t[1]*t[2];if(!Number.isFinite(e)||Math.abs(e)<1e-12)return null;let n=t[3]/e,r=-t[1]/e,o=-t[2]/e,s=t[0]/e;return [n,r,o,s,-(n*t[4]+o*t[5]),-(r*t[4]+s*t[5])]}var Yr=1e-6,$r=1e-9,i2=1+2**-21,D0=5e-4,Se=16;function a2(t){let e=t.toDevice,n=(l,c)=>[Math.round((e[0]*l+e[2]*c+e[4])*Se)/Se,Math.round((e[1]*l+e[3]*c+e[5])*Se)/Se],[r,o]=n(t.srcX,t.srcY),[s,i,a,u]=e;return [s,i,a,u,r-s*t.srcX-a*t.srcY,o-i*t.srcX-u*t.srcY]}function u2(t){let e=t.toDevice,n=(p,d)=>[e[0]*p+e[2]*d+e[4],e[1]*p+e[3]*d+e[5]],[r,o]=n(t.srcX,t.srcY),s=Math.round(r*Se)/Se,i=Math.round(o*Se)/Se,[a,u]=n(t.srcX+t.srcW,t.srcY),[l,c]=n(t.srcX,t.srcY+t.srcH),f=(a-s)/t.srcW,m=(u-i)/t.srcW,b=(l-s)/t.srcH,h=(c-i)/t.srcH;return [f,m,b,h,s-f*t.srcX-b*t.srcY,i-m*t.srcX-h*t.srcY]}function l2(t,e){let n=Math.abs(t);return n<1?((e+2)*n-(e+3))*n*n+1:n<2?e*(((n-5)*n+8)*n-4):0}function c2(t){let e=Math.min(1,Math.abs(t));return Math.sign(t)*(e-e*e/2)}function m2(t,e){let n=Math.min(2,Math.abs(t)),r;if(n<1)r=(e+2)*n**4/4-(e+3)*n**3/3+n;else {let o=(e+2)/4-(e+3)/3+1,s=i=>e*(i**4/4-5*i**3/3+4*i*i-4*i);r=o+s(n)-s(1);}return Math.sign(t)*r}function Nu(t){return Math.ceil(t*(1-15e-8))}function k0(t,e){let n=Nu(t)-e;return n>=-1&&n<=1}function B0(t,e,n){let r=t-Math.round(t);if(r>-1/64+1e-9)return r<=1/64+1e-9;if(Math.abs(r+1/64)>1e-9||!mi(n.srcW)||!mi(n.srcH))return false;let o=(e-Math.round(e))*128;return n.srcW*n.srcH*Math.max(n.srcW,n.srcH)<=256||Math.abs(o-Math.round(o))<1e-9}var f2=-0.5,b2=-1;function ci(t,e,n){switch(t){case "bilinear":return {radius:1,weight:(r,o)=>Math.max(0,1-Math.abs(r-o))};case "bicubic":return {radius:2,weight:(r,o)=>l2(r-o,f2)};case "hq-bilinear":case "hq-bicubic":{if(n)return {radius:.5,weight:(a,u)=>Math.floor(u+.5)===a?1:0};let r=Math.min(1,Math.abs(e)),o=t==="hq-bicubic",s=o?2:1,i=o?a=>m2(a,b2):c2;return {radius:s/r+.5,weight:(a,u)=>i(r*(a+.5-u))-i(r*(a-.5-u))}}default:return {radius:.5,weight:(r,o)=>Math.floor(o+.5)===r?1:0}}}function h2(t,e,n,r,o,s,i,a,u={wrap:void 0,clamp:null},l=false,c=false,f=false){let[m,b,h,p]=a?[r,o,s,i]:[s,i,r,o],[d,x,y,g]=a?[n.x0,n.x1,n.y0,n.y1]:[n.y0,n.y1,n.x0,n.x1],M=0,P=0,E=0,R=0;for(let T=0;T<b.length;T++){let A=b[T],w=m+T;if(A===0)continue;let I=Lo(w,d,x,a?u.mirrorX:u.mirrorY,u);if(I===jr)continue;let S=0,v=0,C=0,U=0;for(let L=0;L<p.length;L++){let F=p[L],B=h+L;if(F===0)continue;let X=Lo(B,y,g,a?u.mirrorY:u.mirrorX,u);if(X===jr)continue;let k,W=0;X===or||I===or?k=u.clamp??[0,0,0,0]:(k=t,W=(a?X*e+I:I*e+X)*4);let O=k[W+3],q=F*O/255,Q=!!u.literal&&k===u.clamp;S+=c||Q?F*k[W]:l||f?F*Math.round(O*k[W]/255):q*k[W],v+=c||Q?F*k[W+1]:l||f?F*Math.round(O*k[W+1]/255):q*k[W+1],C+=c||Q?F*k[W+2]:l||f?F*Math.round(O*k[W+2]/255):q*k[W+2],U+=F*O;}l&&(S=Math.trunc(S),v=Math.trunc(v),C=Math.trunc(C),U=Math.trunc(U)),U=Math.min(255,Math.max(0,U));let D=u.literal&&f?1/0:U;M+=A*Math.min(D,Math.max(0,S)),P+=A*Math.min(D,Math.max(0,v)),E+=A*Math.min(D,Math.max(0,C)),R+=A*U;}return [M,P,E,R]}var jr=-1,or=-2;function H0(t,e){let n=e>>>24;return t==="clamp"&&n>0&&n<255}function Lo(t,e,n,r,o){if(t>=e&&t<n)return t;if(!o.wrap)return jr;if(o.wrap==="clamp")return or;let s=n-e;if(!r)return e+((t-e)%s+s)%s;let i=((t-e)%(2*s)+2*s)%(2*s);return e+(i<s?i:2*s-1-i)}function p2(t){let e=t-Math.floor(t);return e===0?t:Math.floor(t)+1-e}function on(t,e,n,r,o,s={}){let{plainRotated:i=false,keepOrigin:a=false,premultSource:u=false,premultOut:l=false,rasterQuad:c,rasterHalf:f=false,chainPad:m=0}=typeof s=="boolean"?{plainRotated:s}:s;if(r.rightHalo&&r.rightHalo.length===n*4){let nt=new Uint8ClampedArray((e+1)*n*4);for(let bt=0;bt<n;bt++)nt.set(t.subarray(bt*e*4,(bt+1)*e*4),bt*(e+1)*4),nt.set(r.rightHalo.subarray(bt*4,bt*4+4),(bt*(e+1)+e)*4);return on(nt,e+1,n,{...r,rightHalo:void 0},o)}if(r.wrap==="clamp"&&!((r.clampArgb??0)>>>24)&&(r.kernel==="hq-bicubic"||r.kernel==="hq-bilinear"))return on(t,e,n,{...r,wrap:void 0,clampArgb:void 0},o,s);if(r.kernel==="nearest"&&!r.wrap)return A2(t,e,n,r,o);let b=!a&&(r.kernel==="bilinear"||r.kernel==="bicubic")&&(r.toDevice[1]!==0||r.toDevice[2]!==0),h=a||b?r.toDevice:a2(r),p=r.kernel,d=p==="hq-bilinear"||p==="hq-bicubic";d&&(h[1]!==0||h[2]!==0)&&Math.abs(h[1])<=D0*Math.abs(h[0])&&Math.abs(h[2])<=D0*Math.abs(h[3])&&(h=[h[0],0,0,h[3],h[4],h[5]]);let x=h[1]===0&&h[2]===0;d&&!x&&!a&&(h=u2(r));let g=p==="bicubic"&&x&&!r.halfPixelOffset&&h[0]===1&&h[3]===1&&B0(h[4],h[5],r)&&B0(h[5],h[4],r),P=0,E=0;if(d&&!x){let nt=Math.hypot(h[0],h[1])*r.srcW,bt=Math.hypot(h[2],h[3])*r.srcH,Mt=k0(nt,r.srcW)||k0(bt,r.srcH);return T2(t,e,n,r,o,h,p,Mt)}let R=p==="bicubic";if(d&&x&&!u){let nt=E2(t,e,n,r,o,h,l);if(nt!==void 0)return nt}if(d&&x){let nt=h[0]*r.srcX+h[4];h=[h[0],0,0,h[3],h[4]+p2(nt)-nt,h[5]];}let T=W0(h);if(!T)return null;let A=Math.max(0,Math.floor(r.srcX)),w=Math.max(0,Math.floor(r.srcY)),I=Math.min(e,Math.ceil(r.srcX+r.srcW)),S=Math.min(n,Math.ceil(r.srcY+r.srcH));if(I<=A||S<=w)return null;let v=1/0,C=1/0,U=-1/0,D=-1/0;for(let[nt,bt]of [[r.srcX,r.srcY],[r.srcX+r.srcW,r.srcY],[r.srcX,r.srcY+r.srcH],[r.srcX+r.srcW,r.srcY+r.srcH]]){let Mt=h[0]*nt+h[2]*bt+h[4],Ht=h[1]*nt+h[3]*bt+h[5];v=Math.min(v,Mt),C=Math.min(C,Ht),U=Math.max(U,Mt),D=Math.max(D,Ht);}let L=Math.max(0,Math.floor(v)-1),F=Math.max(0,Math.floor(C)-1),B=Math.min(o.w,Math.ceil(U)+1),X=Math.min(o.h,Math.ceil(D)+1),k=B-L,W=X-F;if(!(k>0&&W>0)||k*W>Wu)return null;let O=c?ne([c],false,false,f,{x:L,y:F,w:k,h:W}):b?ne([[[r.srcX,r.srcY],[r.srcX+r.srcW,r.srcY],[r.srcX+r.srcW,r.srcY+r.srcH],[r.srcX,r.srcY+r.srcH]].flatMap(([nt,bt])=>[Ft(h[0]*nt+h[2]*bt+h[4]),Ft(h[1]*nt+h[3]*bt+h[5])])],false,false,!!r.halfPixelOffset,{x:L,y:F,w:k,h:W}):null,q=Math.hypot(h[0],h[1]),Q=Math.hypot(h[2],h[3]),K=nt=>Math.abs(nt-Math.round(nt))<1e-9,V=x&&Math.abs(q-1)<1e-9&&K(h[4]),rt=x&&Math.abs(Q-1)<1e-9&&K(h[5]),H=V&&rt,Y=ci(p,q,H),N=ci(p,Q,H),G=new Uint8ClampedArray(k*W*4),j=r.halfPixelOffset?.5:0,tt=r.srcX+r.srcW,lt=r.srcY+r.srcH,ct=[],ht=[];Math.hypot(T[0],T[2]);Math.hypot(T[1],T[3]);let mt=r.clampArgb??0,Rt={wrap:r.wrap,clamp:[mt>>>16&255,mt>>>8&255,mt&255,mt>>>24&255],literal:H0(r.wrap,mt),mirrorX:r.wrap==="tile-flip-x"||r.wrap==="tile-flip-xy",mirrorY:r.wrap==="tile-flip-y"||r.wrap==="tile-flip-xy"},Ae=Math.round(T[0]*re),Kt=Math.round(T[1]*re),Wt=!i&&(p==="bilinear"||p==="bicubic"&&!x)?ii(h):null,ve=null;if((Wt||i)&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&(p==="bilinear"||p==="bicubic")&&!r.halfPixelOffset&&!r.chainHalf&&!r.wrap){let nt=Du(r.worldPoints,r.chainSrc??[r.srcX,r.srcY,r.srcW,r.srcH],r.worldMatrix);ve=nt&&Fu(nt);}else if(i&&r.chainHalf&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&r.chainSrc&&(p==="bilinear"||p==="bicubic")){let nt=r.worldMatrix,bt=Du(r.worldPoints,r.chainSrc,[nt[0],nt[1],nt[2],nt[3],_(nt[4]-.5),_(nt[5]-.5)]);ve=bt&&Fu(bt);}let me=new Float64Array(k),Ar=new Float64Array(k),Cn=new Int32Array(k),He=new Int32Array(k),Xe=0,vt=(nt,bt)=>{let Mt=nt+Yr,Ht=bt+$r,ye=T[0]*Mt+T[2]*Ht+T[4],ie=T[1]*Mt+T[3]*Ht+T[5];return !(ye<r.srcX||ie<r.srcY||ye>=tt||ie>=lt)};Wt&&!ve&&r.pointsForm&&p==="bilinear"&&x&&(Wt[0]=Math.fround(1/Math.fround(h[0])));for(let nt=0;nt<W;nt++){let bt=F+nt+j,Mt=-1,Ht=0,ye=0,ie=0,ae=0,ge=0;for(let pt=0;pt<k;pt++){let fe=L+pt+j,wt=T[0]*(fe-P)+T[2]*(bt-E)+T[4],gt=T[1]*(fe-P)+T[3]*(bt-E)+T[5],Zt=fe+Yr,we=bt+$r,Dt=T[0]*Zt+T[2]*we+T[4],Ye=T[1]*Zt+T[3]*we+T[5];if(O?!O[nt*k+pt]:Dt<r.srcX||Ye<r.srcY||Dt>=tt||Ye>=lt)continue;if(ve){if(Mt<0){Mt=pt,Xe=pt;let be=pt+1;for(;be<k&&(O?O[nt*k+be]!==0:vt(L+be+j,bt));)be++;R?A0(ve,L+pt,F+nt,be-pt,Cn,He):T0(ve,L+pt,F+nt,be-pt,me,Ar);}R?(wt=(Cn[pt-Xe]+m*re)/re,gt=(He[pt-Xe]+m*re)/re):(wt=me[pt-Xe]+m,gt=Ar[pt-Xe]+m);}else if(Wt){if(Mt<0){Mt=pt,ge=pt;let be=Math.fround(r.toDevice[0]*r.srcX+r.toDevice[2]*r.srcY+r.toDevice[4]),mn=Math.fround(r.toDevice[1]*r.srcX+r.toDevice[3]*r.srcY+r.toDevice[5]),_n=_(fe-be),fn=_(bt-mn);ie=_(_(_(Wt[0]*_n)+_(Wt[2]*fn))+Math.fround(r.srcX)),ae=_(_(_(Wt[1]*_n)+_(Wt[3]*fn))+Math.fround(r.srcY));}for(;ge<pt;ge++)ie=_(ie+Wt[0]),ae=_(ae+Wt[1]);wt=ie,gt=ae,r.pointsForm&&p==="bilinear"&&x&&(gt=r.srcY+(ae-r.srcY)*i2);}R&&(ve||Wt?(wt=Math.floor(wt*64)/64,gt=Math.floor(gt*64)/64):(Mt<0&&(Mt=pt,Ht=Math.round(wt*re),ye=Math.round(gt*re)),wt=Math.floor((Ht+(pt-Mt)*Ae)/(re/64))/64,gt=Math.floor((ye+(pt-Mt)*Kt)/(re/64))/64),g&&(wt=Math.round(wt),gt=Math.round(gt)));let en={x0:0,y0:0,x1:e,y1:n},nn=(be,mn)=>{let _n=Math.ceil(be-Y.radius),fn=Math.floor(be+Y.radius),sm=Math.ceil(mn-N.radius),g1=Math.floor(mn+N.radius);ct.length=0,ht.length=0;for(let bn=_n;bn<=fn;bn++)ct.push(R?Math.round(Y.weight(bn,be)*65536)/65536:Y.weight(bn,be));for(let bn=sm;bn<=g1;bn++)ht.push(R?Math.round(N.weight(bn,mn)*65536)/65536:N.weight(bn,mn));return h2(t,e,en,_n,ct,sm,ht,p==="bicubic",Rt,R,u,p==="bilinear")};p==="bilinear"&&(wt=Math.floor(wt)+Math.round((wt-Math.floor(wt))*2048)/2048,gt=Math.floor(gt)+Math.round((gt-Math.floor(gt))*2048)/2048);let[Un,ln,Ce,Me]=nn(wt,gt);if(Me<=0)continue;if(R){if(Un=Math.trunc(Un),ln=Math.trunc(ln),Ce=Math.trunc(Ce),Me=Math.trunc(Me),Me<=0)continue}else if((u||p==="bilinear")&&(Un=Math.round(Un),ln=Math.round(ln),Ce=Math.round(Ce),Me=Math.round(Me),Me<=0))continue;let cn=Math.min(255,Me),cs=(nt*k+pt)*4;G[cs]=Math.min(Math.max(0,Un),cn)*255/cn,G[cs+1]=Math.min(Math.max(0,ln),cn)*255/cn,G[cs+2]=Math.min(Math.max(0,Ce),cn)*255/cn,G[cs+3]=cn;}}return {x:L,y:F,w:k,h:W,rgba:G}}var rr=128;function mi(t){return Number.isInteger(t)&&t>0&&(t&t-1)===0}function X0(t){return !t.pointsForm||mi(t.srcW)&&mi(t.srcH)}function d2(t,e,n){return X0(t)?e===1?-(n?2:1)*65536+(t.kernel==="hq-bicubic"?1:0):0:e<=1?1:0}function G0(t){return t<1?Y0(65536/t):Math.round(65536/t)}var x2=.027;function Y0(t){return Math.floor(t+.5+x2)}function O0(t){return t>512?0:t>256?2:t>64?1:0}var y2=.9375-1e-9;function g2(t){return t<=-128?-32768:t>=128?32768:t<0?-(512*-t-2*t*t):512*t-2*t*t}function M2(t,e,n,r,o,s,i){let a=[],u=t?2*Math.round(Math.fround(e)*32768):Math.round(4294967296/n),l=(t?2:1)*(n/65536)+1;for(let c=s;c<=i;c++){let f=r(c),m=o+f/65536,b=Math.ceil(m-l),h=Math.floor(m+l),p=[],d=Number.NaN;for(let x=b;x<=h+1;x++){let y=((x-.5-o)*65536-f)*u/33554432,g=Math.floor(y),M=t?li(g):g2(g);x>b&&p.push((M-d)/65536),d=M;}a.push({first:b,weights:p});}return a}function E2(t,e,n,r,o,s,i){let a=r.kernel,u=s[0]<0,l=Math.abs(s[0]),c=s[3];if(!(l>0&&c>0)||r.rightHalo)return;let f=vt=>Math.abs(vt-Math.round(vt))<1e-9;if(l===1&&c===1&&!u&&f(s[4])&&f(s[5]))return;let m=u&&l===1,b=r.halfPixelOffset?.5:0,h=s[0]*r.srcX+s[4]-b,p=h+s[0]*r.srcW,d=r.toDevice[0]*(r.srcX+r.srcW)+r.toDevice[4]-b,x=u?d:_(_(Math.fround(r.toDevice[0])*r.srcX)+_(r.toDevice[4]))-b,y=u?Math.round(d*Se)/Se:Math.min(h,p),g=s[3]*r.srcY+s[5]-b,M=u?y+l*r.srcW:Math.max(h,p),P=g+s[3]*r.srcH,E=u?.5:Math.ceil(x*Se-.5)/Se,R=!u&&Number.isInteger(E)&&x-E>1e-5,T=!u&&Number.isInteger(E)&&E-x>1e-5,A=Math.ceil(R?x-Yr:y-Yr),w=Math.ceil(R?x+l*r.srcW-Yr:M-Yr)-1,I=_(_(Math.fround(r.toDevice[3])*r.srcY)+_(r.toDevice[5]))-b,S=Math.ceil(I*Se-.5)/Se,v=Number.isInteger(S)&&I-S>1e-5,C=Math.ceil(v?I-$r:g-$r),U=Math.ceil(v?I+s[3]*r.srcH-$r:P-$r)-1,D=Math.max(0,A),L=Math.max(0,C),F=Math.min(o.w-1,w),B=Math.min(o.h-1,U);if(F<D||B<L)return null;let X=F-D+1,k=B-L+1;if(X*k>Wu)return null;let W=P2(t,e,n,r,D,L,X,k,i);if(W)return W;let O=a==="hq-bicubic",q=O?.5:1,Q=G0(l),K=G0(c),V=r.nominalScale;if(V&&!u&&Math.abs(V[0]/l-1)<1e-5&&Math.abs(V[1]/c-1)<1e-5){let vt=Math.fround,nt=vt(1/vt(V[0]*V[1])),bt=(Mt,Ht)=>Ht<1?Y0(Mt):Math.round(Mt);Q=bt(65536*vt(V[1]*nt),l),K=bt(65536*vt(V[0]*nt),c);}let rt=A-x,H=rt<1e-5?0:rt,Y=Math.max(0,C-I);if(u&&(r.halfPixelOffset||!f(r.srcX)||!f(r.srcW)))return;let N=w-A+1+H,G=x-Math.floor(x),j=u?0:R?Math.round((1+G)*Q):T?Math.round((G-1)*Q):H>1e-9?Math.round((1-H)*Q):0,tt=Y>1e-9?Math.round(Y*K):0,lt=x-Math.floor(x),ct=u||lt>=y2?0:-O0(x),ht=O0(I),ft=ci(a,l,false),at=ci(a,c,false),mt=(vt,nt,bt,Mt,Ht,ye,ie,ae,ge=false)=>{let pt=[],fe=((nt&nt-1)===0?0:Math.round(r.srcW/170))+(ge?d2(r,ie,H>1e-9):0),wt=Dt=>ge?Math.round((N-Dt)*nt)+fe:Dt*nt+bt;if(ge&&m&&H<=1e-9&&X0(r)){for(let Dt=Ht;Dt<=ye;Dt++)pt.push({first:Math.round(Mt+wt(Dt)/65536),weights:[1]});return pt}let gt=Mt*rr,Zt=Math.abs(gt-Math.round(gt))<1e-6;if(ie<1&&Zt)return M2(O,ie,nt,Dt=>wt(Dt)+ae,Mt,Ht,ye);let we=O&&Zt;for(let Dt=Ht;Dt<=ye;Dt++){let Ye=Math.floor((wt(Dt)-1)/(65536/rr));if(we){let Ce=Math.round(gt)+Ye,Me=ku((Ce%rr+rr)%rr);pt.push({first:Math.floor(Ce/rr)+Me.first,weights:Me.weights.map(cn=>cn/65536)});continue}let en=Mt+(Ye+q)/rr,nn=Math.ceil(en-vt.radius),Un=Math.floor(en+vt.radius),ln=[];for(let Ce=nn;Ce<=Un;Ce++)ln.push(vt.weight(Ce,en));pt.push({first:nn,weights:ln});}return pt},Rt=mt(ft,Q,j,r.srcX,D-A,F-A,l,ct,u),Ae=mt(at,K,tt,r.srcY,L-C,B-C,c,ht),Kt=1/0,Wt=-1/0;for(let vt of Ae)Kt=Math.min(Kt,vt.first),Wt=Math.max(Wt,vt.first+vt.weights.length-1);let ve=r.clampArgb??0,me=r.wrap?{wrap:r.wrap,clamp:[ve>>>16&255,ve>>>8&255,ve&255,ve>>>24&255],literal:H0(r.wrap,ve),mirrorX:r.wrap==="tile-flip-x"||r.wrap==="tile-flip-xy",mirrorY:r.wrap==="tile-flip-y"||r.wrap==="tile-flip-xy"}:null;me||(Kt=Math.max(0,Kt),Wt=Math.min(n-1,Wt));let Ar=Math.max(0,Wt-Kt+1),Cn=Math.abs(c-1)<1e-9?1/0:Math.ceil((O?2:1)/Math.min(1,c)),He=new Uint8Array(Ar*X*4);for(let vt=0;vt<Ar;vt++){let nt=Kt+vt;if(me&&(Number.isFinite(Cn)&&(nt=Lo(nt,Math.max(0,r.srcY-Cn),Math.min(n,r.srcY+r.srcH+Cn),me.mirrorY,me)),nt!==jr&&nt!==or&&(nt=Lo(nt,0,n,me.mirrorY,me))),nt===jr||nt!==or&&(nt<r.srcY-Cn||nt>r.srcY+r.srcH+Cn-1))continue;let bt=nt*e;for(let Mt=0;Mt<X;Mt++){let Ht=Rt[Mt],ye=0,ie=0,ae=0,ge=0;for(let gt=0;gt<Ht.weights.length;gt++){let Zt=Ht.first+gt,we=t,Dt=0;if(me){if(Zt=Lo(Zt,0,e,me.mirrorX,me),Zt===jr)continue}else if(Zt<0||Zt>=e)continue;Zt===or||nt===or?we=me?.clamp??[0,0,0,0]:Dt=(bt+Zt)*4;let Ye=we[Dt+3];if(Ye===0)continue;let en=Ht.weights[gt],nn=!!me?.literal&&we===me.clamp;ye+=en*(nn?we[Dt]:Math.round(we[Dt]*Ye/255)),ie+=en*(nn?we[Dt+1]:Math.round(we[Dt+1]*Ye/255)),ae+=en*(nn?we[Dt+2]:Math.round(we[Dt+2]*Ye/255)),ge+=en*Ye;}let pt=Math.min(255,Math.max(0,Math.round(ge))),fe=(vt*X+Mt)*4,wt=me?.literal?255:pt;He[fe]=Math.min(wt,Math.max(0,Math.round(ye))),He[fe+1]=Math.min(wt,Math.max(0,Math.round(ie))),He[fe+2]=Math.min(wt,Math.max(0,Math.round(ae))),He[fe+3]=pt;}}let Xe=new Uint8ClampedArray(X*k*4);for(let vt=0;vt<k;vt++){let nt=Ae[vt];for(let bt=0;bt<X;bt++){let Mt=0,Ht=0,ye=0,ie=0;for(let fe=0;fe<nt.weights.length;fe++){let wt=nt.first+fe-Kt;if(wt<0||wt>=Ar)continue;let gt=(wt*X+bt)*4,Zt=nt.weights[fe];Mt+=Zt*He[gt],Ht+=Zt*He[gt+1],ye+=Zt*He[gt+2],ie+=Zt*He[gt+3];}let ae=Math.min(255,Math.max(0,Math.round(ie)));if(ae===0)continue;let ge=(vt*X+bt)*4,pt=i?1:255/ae;Xe[ge]=Math.min(ae,Math.max(0,Math.round(Mt)))*pt,Xe[ge+1]=Math.min(ae,Math.max(0,Math.round(Ht)))*pt,Xe[ge+2]=Math.min(ae,Math.max(0,Math.round(ye)))*pt,Xe[ge+3]=ae;}}return {x:D,y:L,w:X,h:k,rgba:Xe,premultiplied:i}}function P2(t,e,n,r,o,s,i,a,u){let l=r.worldMatrix;if(r.halfPixelOffset||!l||r.wrap||r.srcX!==0||r.srcY!==0||r.srcW!==e||r.srcH!==n)return;let c=[r.srcX,r.srcY,r.srcW,r.srcH],f=r.worldRect?null:r.worldPoints?Uo(r.worldPoints,c):null,m=r.worldRect?I0(c,r.worldRect,l):f?ui(f,l):null;if(!m||!(m[0]>0&&m[3]>0))return;let b=w0(m,c),h=new Uint8Array(e*n*4);for(let x=0;x<e*n*4;x+=4){let y=t[x+3];h[x]=Math.round(t[x]*y/255),h[x+1]=Math.round(t[x+1]*y/255),h[x+2]=Math.round(t[x+2]*y/255),h[x+3]=y;}let p=U0({kernel:r.kernel==="hq-bicubic"?"cubic":"tent",pixels:h,width:e,height:n,src:c,dest:b});if(!p)return;let d=new Uint8ClampedArray(i*a*4);for(let x=0;x<a;x++){let y=L0(p,s+x,o,o+i);if(y)for(let g=0;g<y.pixels.length/4;g++){let M=y.pixels.subarray(g*4,g*4+4),P=M[3];if(P===0)continue;let E=(x*i+y.x-o+g)*4,R=u?1:255/P;d[E]=M[0]*R,d[E+1]=M[1]*R,d[E+2]=M[2]*R,d[E+3]=P;}}return {x:o,y:s,w:i,h:a,rgba:d,premultiplied:u}}function R2(t,e){let n=_o(e,t),r=(o,s)=>Math.ceil(Mo(st(Z(s,s),Z(o,o))));return [r(st(n[2],-n[0]),st(n[3],-n[1])),r(st(n[4],-n[0]),st(n[5],-n[1]))]}function T2(t,e,n,r,o,s,i,a){let u=!!(r.pointsForm&&r.worldPoints&&r.worldMatrix&&!r.wrap),l=u?R2(r.worldPoints,r.worldMatrix):null,c=l?Math.abs(l[0]-r.srcW)<=1.0000001||Math.abs(l[1]-r.srcH)<=1.0000001:a,f=r.wrap?0:2,m,b,h,p,d,x,y,g,M,P=r.halfPixelOffset,E=0,R=0;if(c){b=e+2*f,h=n+2*f,m=new Uint8ClampedArray(b*h*4);for(let I=0;I<n;I++)for(let S=0;S<e;S++){let v=(I*e+S)*4,C=t[v+3],U=((I+f)*b+S+f)*4;m[U]=Math.round(t[v]*C/255),m[U+1]=Math.round(t[v+1]*C/255),m[U+2]=Math.round(t[v+2]*C/255),m[U+3]=C;}[p,d,x,y]=s,g=s[4]-(P?.5:0),M=s[5]-(P?.5:0);}else {let I=l?l[0]:Nu(Math.hypot(s[0],s[1])*r.srcW),S=l?l[1]:Nu(Math.hypot(s[2],s[3])*r.srcH);E=I,R=S;let v=I/r.srcW,C=S/r.srcH,U=on(t,e,n,{srcX:r.srcX,srcY:r.srcY,srcW:r.srcW,srcH:r.srcH,toDevice:[v,0,0,C,-r.srcX*v,-r.srcY*C],kernel:i,halfPixelOffset:false,wrap:r.wrap,clampArgb:r.clampArgb},{w:I,h:S},{premultOut:true});if(!U)return null;if(!U.premultiplied)for(let F=0;F<U.rgba.length;F+=4){let B=U.rgba[F+3];U.rgba[F]=Math.round(U.rgba[F]*B/255),U.rgba[F+1]=Math.round(U.rgba[F+1]*B/255),U.rgba[F+2]=Math.round(U.rgba[F+2]*B/255);}b=I+2*f,h=S+2*f,m=new Uint8ClampedArray(b*h*4);for(let F=0;F<U.h;F++)for(let B=0;B<U.w;B++){let X=B+U.x,k=F+U.y;X<I&&k<S&&m.set(U.rgba.subarray((F*U.w+B)*4,(F*U.w+B)*4+4),((k+f)*b+X+f)*4);}p=s[0]/v,d=s[1]/v,x=s[2]/C,y=s[3]/C;let D=s[0]*r.srcX+s[2]*r.srcY+s[4],L=s[1]*r.srcX+s[3]*r.srcY+s[5];g=P?D-.5+.5*(p+x):D,M=P?L-.5+.5*(d+y):L;}let T=[[r.srcX,r.srcY],[r.srcX+r.srcW,r.srcY],[r.srcX+r.srcW,r.srcY+r.srcH],[r.srcX,r.srcY+r.srcH]].flatMap(([I,S])=>[Ft(s[0]*I+s[2]*S+s[4]),Ft(s[1]*I+s[3]*S+s[5])]),A=on(m,b,h,{srcX:0,srcY:0,srcW:b,srcH:h,toDevice:[p,d,x,y,g-p*f-x*f,M-d*f-y*f],kernel:i==="hq-bicubic"?"bicubic":"bilinear",halfPixelOffset:false,wrap:r.wrap,clampArgb:r.clampArgb,...u?{pointsForm:true,worldPoints:r.worldPoints,worldMatrix:r.worldMatrix,chainSrc:c?[r.srcX,r.srcY,r.srcW,r.srcH]:[P?-0.5:0,P?-0.5:0,E,R],...P?{chainHalf:true}:{}}:{}},o,{plainRotated:true,keepOrigin:true,premultSource:true,...u?{rasterQuad:T,rasterHalf:P,chainPad:f}:{}});if(!A)return A;let w=ne([T],false,false,P,{x:A.x,y:A.y,w:A.w,h:A.h});for(let I=0;I<A.w*A.h;I++)w[I]||A.rgba.fill(0,I*4,I*4+4);return A}var re=65536;function A2(t,e,n,r,o){let s=r.toDevice,i=W0(s);if(!i)return null;let{srcX:a,srcY:u,srcW:l,srcH:c}=r,f=[[a,u],[a+l,u],[a+l,u+c],[a,u+c]].map(([C,U])=>[s[0]*C+s[2]*U+s[4],s[1]*C+s[3]*U+s[5]]),m=1/0,b=1/0,h=-1/0,p=-1/0;for(let[C,U]of f)m=Math.min(m,C),b=Math.min(b,U),h=Math.max(h,C),p=Math.max(p,U);if(![m,b,h,p].every(Number.isFinite))return null;let d=Math.max(0,Math.floor(m)-1),x=Math.max(0,Math.floor(b)-1),y=Math.min(o.w,Math.ceil(h)+2),g=Math.min(o.h,Math.ceil(p)+2),M=y-d,P=g-x;if(!(M>0&&P>0)||M*P>Wu)return null;let E={x:d,y:x,w:M,h:P},R=ne([f.flatMap(([C,U])=>[Ft(C),Ft(U)])],false,false,r.halfPixelOffset,E),T=Math.max(0,Math.floor(u)),A=Math.min(n,Math.ceil(u+c)),w=r.halfPixelOffset?.5:0,I=Math.round(i[0]*re),S=Math.round(i[1]*re),v=new Uint8ClampedArray(M*P*4);for(let C=0;C<P;C++){let U=x+C+w,D=-1,L=0,F=0;for(let B=0;B<M;B++){if(!R[C*M+B])continue;if(D<0){let Q=d+B+w;D=B,L=Math.round((i[0]*Q+i[2]*U+i[4])*re),F=Math.round((i[1]*Q+i[3]*U+i[5])*re);}let X=B-D,k=Math.floor((L+X*I+re/2)/re),W=Math.floor((F+X*S+re/2)/re);if(k<0||k>=e||W<T||W>=A)continue;let O=(W*e+k)*4,q=(C*M+B)*4;v[q]=t[O],v[q+1]=t[O+1],v[q+2]=t[O+2],v[q+3]=t[O+3];}}return {x:d,y:x,w:M,h:P,rgba:v}}var fi=1<<24;function j0(t,e,n,r){return {cmds:[{op:"rect",x:t,y:e,w:n,h:r}],fillRule:"nonzero",simple:true}}function sn(t){return {cmds:t.map(e=>({op:"rect",x:e.x,y:e.y,w:e.w,h:e.h})),fillRule:"nonzero",simple:true}}function Le(){return {cmds:[{op:"rect",x:0,y:0,w:0,h:0}],fillRule:"nonzero",simple:true}}function w2(t,e,n){return {...t,cmds:t.cmds.map(r=>{switch(r.op){case "rect":return {...r,x:r.x+e,y:r.y+n};case "moveTo":case "lineTo":return {...r,x:r.x+e,y:r.y+n};case "bezierCurveTo":return {...r,cp1x:r.cp1x+e,cp1y:r.cp1y+n,cp2x:r.cp2x+e,cp2y:r.cp2y+n,x:r.x+e,y:r.y+n};case "arcTo":return {...r,x1:r.x1+e,y1:r.y1+n,x2:r.x2+e,y2:r.y2+n};case "ellipse":return {...r,cx:r.cx+e,cy:r.cy+n};case "closePath":return r}})}}function ir(t,e,n){return t?t.map(r=>w2(r,e,n)):null}function Hu(t){return t.simple&&t.fillRule==="nonzero"}function sr(t){return t.fillRule==="evenodd"||Hu(t)}function $0(t){let e=0;for(let n of Gr(t.cmds)){let r=0,o=n.length/2;for(let i=0;i<o;i++){let a=(i+1)%o;r+=n[2*i]*n[2*a+1]-n[2*a]*n[2*i+1];}let s=Math.abs(r)<1e-9?0:Math.sign(r);if(s!==0){if(e!==0&&s!==e)return NaN;e=s;}}return e}function I2(t,e){if(!Hu(t)||!Hu(e))return false;let n=$0(t),r=$0(e);return !Number.isNaN(n)&&!Number.isNaN(r)&&(n===0||r===0||n===r)}function Do(t){return {cmds:[{op:"rect",x:-fi,y:-fi,w:2*fi,h:2*fi},...t.cmds],fillRule:"evenodd",simple:false}}var S2={x:1<<23,y:1<<23,w:1,h:1};function gn(t,e,n,r){let o=r??Ef(t,e),s=Qn(t,e,n,o),i=!Tf(o);return !r&&Qn(t,e,n,S2).length>0&&(i=false),{region:[s.length>0?sn(s):Le()],exact:i}}function Xu(t,e,n,r){switch(n){case "replace":return {region:[e],exact:true};case "intersect":return {region:t?[...t,e]:[e],exact:true};case "exclude":{if(sr(e)){let o=Do(e);return {region:t?[...t,o]:[o],exact:true}}return gn(t,[e],n,r)}case "union":return t?t.length===1&&I2(t[0],e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"nonzero",simple:false}],exact:true}:gn(t,[e],n,r):{region:null,exact:true};case "xor":return t?t.length===1&&sr(t[0])&&sr(e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"evenodd",simple:false}],exact:true}:gn(t,[e],n,r):sr(e)?{region:[Do(e)],exact:true}:gn(t,[e],n,r);case "complement":return t?t.length===1&&sr(t[0])?{region:[e,Do(t[0])],exact:true}:gn(t,[e],n,r):{region:[Le()],exact:true}}}function Yu(t,e,n,r){if(n==="replace")return {region:e,exact:true};if(e&&e.length===1)return Xu(t,e[0],n,r);if(!e)switch(n){case "intersect":return {region:t,exact:true};case "union":return {region:null,exact:true};case "exclude":return {region:[Le()],exact:true};case "xor":case "complement":return t?t.length===1&&sr(t[0])?{region:[Do(t[0])],exact:true}:gn(t,e,n,r):{region:[Le()],exact:true}}switch(n){case "intersect":return {region:t?[...t,...e]:e,exact:true};case "union":return t?gn(t,e,n,r):{region:null,exact:true};case "complement":return t?t.length===1&&sr(t[0])?{region:[...e,Do(t[0])],exact:true}:gn(t,e,n,r):{region:[Le()],exact:true};case "xor":case "exclude":return gn(t,e,n,r)}}function Fo(t,e){for(let n of e)switch(n.op){case "rect":t.rect(n.x,n.y,n.w,n.h);break;case "moveTo":t.moveTo(n.x,n.y);break;case "lineTo":t.lineTo(n.x,n.y);break;case "bezierCurveTo":t.bezierCurveTo(n.cp1x,n.cp1y,n.cp2x,n.cp2y,n.x,n.y);break;case "arcTo":t.arcTo(n.x1,n.y1,n.x2,n.y2,n.radius);break;case "ellipse":t.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,n.startAngle,n.endAngle,n.ccw);break;case "closePath":t.closePath();break}}function v2(t,e){for(let n of e){t.beginPath(),Fo(t,n.cmds);try{t.clip(n.fillRule);}catch{}}}function We(t,e,n=false){let{ctx:r}=t;for(;t.clipSaveDepth>0;)r.restore(),t.clipSaveDepth--;e&&(r.save(),t.clipSaveDepth=1,n&&r.setTransform(1,0,0,1,0,0),v2(r,e));}var C2=[[255,0,0,0,0,0,0,0],[128,128,128,128,128,128,128,128],[128,64,32,16,8,4,2,1],[1,2,4,8,16,32,64,128],[255,128,128,128,128,128,128,128],[129,66,36,24,24,36,66,129],[128,0,0,0,8,0,0,0],[128,0,8,0,128,0,8,0],[136,0,34,0,136,0,34,0],[136,34,136,34,136,34,136,34],[170,68,170,17,170,68,170,17],[170,85,170,81,170,85,170,21],[170,85,170,85,170,85,170,85],[238,85,187,85,238,85,187,85],[119,221,119,221,119,221,119,221],[119,255,221,255,119,255,221,255],[239,255,254,255,239,255,254,255],[255,255,255,247,255,255,255,127],[136,68,34,17,136,68,34,17],[17,34,68,136,17,34,68,136],[204,102,51,153,204,102,51,153],[51,102,204,153,51,102,204,153],[193,224,112,56,28,14,7,131],[131,7,14,28,56,112,224,193],[136,136,136,136,136,136,136,136],[255,0,0,0,255,0,0,0],[85,85,85,85,85,85,85,85],[255,0,255,0,255,0,255,0],[204,204,204,204,204,204,204,204],[255,255,0,0,255,255,0,0],[0,0,136,68,34,17,0,0],[0,0,17,34,68,136,0,0],[240,0,0,0,15,0,0,0],[128,128,128,128,8,8,8,8],[128,8,64,2,16,1,32,4],[177,48,3,27,216,192,12,141],[129,66,36,24,129,66,36,24],[0,24,37,192,0,24,37,192],[1,2,4,8,24,36,66,129],[255,128,128,128,255,8,8,8],[136,84,34,69,136,20,34,81],[170,85,170,85,240,240,240,240],[0,16,8,16,0,128,1,128],[170,0,128,0,128,0,128,0],[128,0,34,0,8,0,34,0],[3,132,72,48,12,2,1,1],[255,102,255,153,255,102,255,153],[119,137,143,143,119,152,248,248],[255,136,136,136,255,136,136,136],[153,102,102,153,153,102,102,153],[240,240,240,240,15,15,15,15],[130,68,40,16,40,68,130,1],[16,56,124,254,124,56,16,0]],V0=234,z0=64;function U2(t,e,n){let r=()=>{let s=((e-n)%8+8)%8;return s===0?V0:s===1||s===7?z0:0},o=()=>{let s=((e+n-7)%8+8)%8;return s===0?V0:s===1||s===7?z0:0};switch(t){case 2:return r();case 3:return o();case 5:return Math.max(r(),o());default:{let s=C2[t];return s&&s[n]&128>>e?256:0}}}function _2(t,e,n){if(n>=256)return t>>>0;if(n<=0)return e>>>0;let r=t>>>24&255,o=e>>>24&255,s=r*n+o*(256-n)>>8;if(s===0)return 0;let i=s<<24;for(let a of [16,8,0]){let u=Math.round((t>>>a&255)*r/255),l=Math.round((e>>>a&255)*o/255),c=u*n+l*(256-n)>>8;i|=Math.min(255,Math.round(c*255/s))<<a;}return i>>>0}function q0(t){let e=new Uint8ClampedArray(256);for(let n=0;n<8;n++)for(let r=0;r<8;r++){let o=_2(t.fore,t.back,U2(t.style,r,n)),s=(n*8+r)*4;e[s]=o>>>16&255,e[s+1]=o>>>8&255,e[s+2]=o&255,e[s+3]=o>>>24&255;}return e}function J0(t,e,n){let r=q0(t),o=n;return (s,i,a,u,l)=>{for(let c=0;c<u;c++)for(let f=0;f<a;f++){let m=s+f+.5,b=i+c+.5,h=Math.floor(o[0]*m+o[2]*b+o[4]),p=Math.floor(o[1]*m+o[3]*b+o[5]),d=((h-e.x)%8+8)%8+((p-e.y)%8+8)%8*8,x=(c*a+f)*4;l[x]=r[d*4],l[x+1]=r[d*4+1],l[x+2]=r[d*4+2],l[x+3]=r[d*4+3];}}}function K0(t,e,n,r,o){if(typeof t.createPattern!="function")return null;let s=It(8,8);if(!s)return null;Ct(s.ctx,Et(q0(e),8,8),0,0);let i=Cs(t,s.canvas,"repeat");if(!i||typeof i.setTransform!="function")return i;let a=r[0]*r[3]-r[1]*r[2];if(!Number.isFinite(a)||Math.abs(a)<1e-12)return i;let u=[r[3]/a,-r[1]/a,-r[2]/a,r[0]/a,(r[2]*r[5]-r[3]*r[4])/a,(r[1]*r[4]-r[0]*r[5])/a],l=o,c=[l[0],l[1],l[2],l[3],l[0]*n.x+l[2]*n.y+l[4],l[1]*n.x+l[3]*n.y+l[5]],f=[u[0]*c[0]+u[2]*c[1],u[1]*c[0]+u[3]*c[1],u[0]*c[2]+u[2]*c[3],u[1]*c[2]+u[3]*c[3],u[0]*c[4]+u[2]*c[5]+u[4],u[1]*c[4]+u[3]*c[5]+u[5]];try{i.setTransform({a:f[0],b:f[1],c:f[2],d:f[3],e:f[4],f:f[5]});}catch{}return i}var bi=class{constructor(){throw new Error("SVG output is not part of the emf-converter lite build")}};function At(t){return false}function Pe(t){return true}function ig(t,e,n){let r=_,o=r(Math.fround(e)*Math.fround(.0174532924)),s=r(Math.sin(o)),i=r(Math.cos(o));return n?[r(r(t[0]*i)-r(t[1]*s)),r(r(t[0]*s)+r(t[1]*i)),r(r(t[2]*i)-r(t[3]*s)),r(r(t[2]*s)+r(t[3]*i)),r(r(t[4]*i)-r(t[5]*s)),r(r(t[4]*s)+r(t[5]*i))]:[r(r(t[0]*i)+r(t[2]*s)),r(r(t[3]*s)+r(t[1]*i)),r(r(t[2]*i)-r(t[0]*s)),r(r(t[3]*i)-r(t[1]*s)),t[4],t[5]]}function Mn(t,e){return [t[0]*e[0]+t[1]*e[2],t[0]*e[1]+t[1]*e[3],t[2]*e[0]+t[3]*e[2],t[2]*e[1]+t[3]*e[3],t[4]*e[0]+t[5]*e[2]+e[4],t[4]*e[1]+t[5]*e[3]+e[5]]}function De(t,e,n){if(e&32768)return ue(n);let r=t.objectTable.get(n&255);return r&&r.kind==="plus-brush"?ju(t,r):"rgba(0,0,0,1)"}function ju(t,e){if(e.gradient){let n=ef(t.ctx,e.gradient,_t(t));if(n)return n}if(e.texture){let n=P0(t.ctx,e.texture,_t(t));if(n)return n}if(e.hatch){let n=K0(t.ctx,e.hatch,t.ext?.renderingOrigin??{x:0,y:0},_t(t),yi(t));if(n)return n}return e.color}var $u=0,di=1,ag=6,ur=96;function lr(t,e,n=ur,r=true){let o;switch(t){case di:o=r?1:n/100;break;case 3:o=n/72;break;case 4:o=n;break;case 5:o=n/300;break;case 6:o=n/25.4;break;default:o=1;break}return o*e}function ug(t){let e=t.videoDisplay??true;return [lr(t.pageUnit,t.pageScale,t.dpiX??ur,e),lr(t.pageUnit,t.pageScale,t.dpiY??ur,e)]}function _t(t){let e=xi(t),n=t.dpiScale,r=[e[0]*n,e[1]*n,e[2]*n,e[3]*n,e[4]*n,e[5]*n],o=t.baseTransform;return o?[o[0]*r[0]+o[2]*r[1],o[1]*r[0]+o[3]*r[1],o[0]*r[2]+o[2]*r[3],o[1]*r[2]+o[3]*r[3],o[0]*r[4]+o[2]*r[5]+o[4],o[1]*r[4]+o[3]*r[5]+o[5]]:r}function En(t){return t.ext||(t.ext={}),t.ext}function xi(t){let e=t.ext;if(e?.tsDevice)return e.tsDevice;let n=t.worldTransform,[r,o]=ug(t),s=[n[0]*r,n[1]*o,n[2]*r,n[3]*o,n[4]*r,n[5]*o];return e?.containerTransform?Mn(s,e.containerTransform):s}function yi(t){let e=t.dpiScale,n=[e,0,0,e,0,0];return t.baseTransform?Mn(n,t.baseTransform):n}function pe(t,e=true){let n=_t(t),r=e?Vu(t):0;t.ctx.setTransform(n[0],n[1],n[2],n[3],n[4]+r,n[5]+r);}function Vu(t){return At(t.ctx)?0:t.antiAlias&&!Ee(t.pixelOffsetMode??0)?.5:0}function nb(t,e){let n=En(t);t.saveStack.push({transform:[...t.worldTransform],snapshot:{clipRegion:t.clipRegion??null,antiAlias:t.antiAlias,interpolationMode:t.interpolationMode,pixelOffsetMode:t.pixelOffsetMode,textRenderingHint:t.textRenderingHint,pageUnit:t.pageUnit,pageScale:t.pageScale,ext:{...n,multiFormatSkip:void 0,pendingEffect:void 0}}}),t.saveIdMap.set(e,t.saveStack.length-1);}function Z0(t,e){let n=t.saveIdMap.get(e);if(n!==void 0&&n<t.saveStack.length){let r=t.saveStack[n];t.worldTransform=[...r.transform];let o=r.snapshot;if(o){t.clipRegion=o.clipRegion,t.antiAlias=o.antiAlias,t.interpolationMode=o.interpolationMode,t.pixelOffsetMode=o.pixelOffsetMode,t.textRenderingHint=o.textRenderingHint,t.pageUnit=o.pageUnit,t.pageScale=o.pageScale;let i=En(t),{multiFormatSkip:a,pendingEffect:u}=i;for(let l of Object.keys(i))delete i[l];Object.assign(i,o.ext,{multiFormatSkip:a,pendingEffect:u});}t.saveStack.length=n;let s=new Map;for(let[i,a]of t.saveIdMap)a<n&&s.set(i,a);t.saveIdMap=s,o&&Vr(t);}}function Q0(t,e,n){let r=xi(t),o=pi(t.ext?.containerClip,t.clipRegion);nb(t,e);let s=En(t);s.containerTransform=n?Mn(n,r):r,s.tsDevice=null,s.containerClip=o,s.compositingMode=void 0,s.compositingQuality=void 0,s.textContrast=void 0,t.clipRegion=null,t.worldTransform=[1,0,0,1,0,0],t.pageUnit=di,t.pageScale=1,t.antiAlias=false,t.interpolationMode=void 0,t.pixelOffsetMode=void 0,t.textRenderingHint=void 0,Vr(t);}function lg(t,e,n,r=ur,o=ur,s=true){let i=n===$u?r/100:lr(n,1,r,s),a=n===$u?o/100:lr(n,1,o,s),u=e.w*i,l=e.h*a;if(!(Math.abs(u)>0&&Math.abs(l)>0)||![t.x,t.y,t.w,t.h,u,l].every(Number.isFinite))return null;let c=t.w/u,f=t.h/l;return [c,0,0,f,t.x-e.x*i*c,t.y-e.y*a*f]}function pi(t,e){let n=[...t??[],...e??[]];return t||e?n:null}function hi(t){return _t(t)}function rb(t,e,n,r,o){let s=(u,l)=>o[0]*u+o[2]*l+o[4],i=(u,l)=>o[1]*u+o[3]*l+o[5];return {cmds:[{op:"moveTo",x:s(t,e),y:i(t,e)},{op:"lineTo",x:s(t+n,e),y:i(t+n,e)},{op:"lineTo",x:s(t+n,e+r),y:i(t+n,e+r)},{op:"lineTo",x:s(t,e+r),y:i(t,e+r)},{op:"closePath"}],fillRule:"nonzero",simple:true}}function cg(t,e){return mu(t.path,e)}var mg={0:"intersect",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"},tb=64;function ko(t,e,n=0,r){if(n>tb)return {region:[Le()],exact:false};switch(t.type){case "rect":return {region:[rb(t.x,t.y,t.width,t.height,e)],exact:true};case "path":return {region:[cg(t,e)],exact:true};case "infinite":return {region:null,exact:true};case "empty":return {region:[Le()],exact:true};case "combine":{let o=ko(t.left,e,n+1,r),s=ko(t.right,e,n+1,r),i=mg[t.combineMode]??"intersect",a=Yu(o.region,s.region,i,r);return {region:a.region,exact:a.exact&&o.exact&&s.exact}}}}var fg={0:"replace",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"};function zu(t){if(!(t.canvasW===void 0||t.canvasH===void 0))return {x:0,y:0,w:t.canvasW,h:t.canvasH}}function ob(t){let e=t.ext;return pi(pi(e?.containerClip,t.clipRegion??void 0)??void 0,e?.tsClip??void 0)}function Vr(t){We(t,ob(t),true);}function sb(t,e){let n=zu(t);if(t.gdiAntialias===true||!e||!n||At(t.ctx))return e;let r=Ee(t.pixelOffsetMode??0),o=Xf(e.map(a=>({build:u=>Fo(u,a.cmds),evenOdd:a.fillRule==="evenodd"})),n,r);if(o)return [sn(o)];let s=(r?0:.5)-1/32,i=ir(e,s,s);return [sn(Qn(i,null,"intersect",n))]}function ib(t,e,n,r){let o=sb(t,e),s=fg[n];let i=Yu(t.clipRegion??null,o,s??"intersect",zu(t));i.exact||z(`${r}: CombineMode ${n} approximated (no canvas domain for an unbounded result)`),t.clipRegion=i.region,Vr(t);}function eb(t,e,n,r){ib(t,[e],n,r);}function ar(t){t.ext?.tsDevice&&(t.ext.tsDevice=null);}function bg(t,e,n){let{view:r}=t;if(n<40||r.getUint32(e,true)&1&&n<296)return;let s=r.getUint8(e+4);t.antiAlias=s===2||s===4||s===5,t.textRenderingHint=r.getUint8(e+5);let i=En(t);i.compositingMode=r.getUint8(e+6),i.compositingQuality=r.getUint8(e+7),i.renderingOrigin={x:r.getInt16(e+8,true),y:r.getInt16(e+10,true)},i.textContrast=r.getUint16(e+12,true),t.interpolationMode=r.getUint8(e+14);let a=[0,4,8,12,16,20].map(u=>r.getFloat32(e+16+u,true));a.every(Number.isFinite)&&(i.tsDevice=a);}function hg(t,e,n,r){let o=r&32767,s=e+n,i=[];if(!(r&32768)){if(e+o*16>s)return null;for(let c=0;c<o;c++){let f=e+c*16;i.push({l:t.getInt32(f,true),t:t.getInt32(f+4,true),r:t.getInt32(f+8,true),b:t.getInt32(f+12,true)});}return i}let a=e,u=()=>{if(a>=s)return null;let c=t.getUint8(a);if(c&128){a+=1;let m=c&127;return m&64?m-128:m}if(a+2>s)return null;let f=c<<8|t.getUint8(a+1);return a+=2,f&16384?f-32768:f},l={l:0,r:0,b:0};for(let c=0;c<o;c++){let f=u(),m=u(),b=u(),h=u();if(f===null||m===null||b===null||h===null)return null;let p=l.b+m,d={l:l.l+f,t:p,r:l.r+b,b:p+h};i.push(d),l=d;}return i}function pg(t,e,n,r){let o=hg(t.view,n,r,e);if(!o)return;let s=yi(t),i=(f,m)=>s[0]*f+s[2]*m+s[4],a=(f,m)=>s[1]*f+s[3]*m+s[5],u=[];for(let f of o)f.r<=f.l||f.b<=f.t||u.push({op:"moveTo",x:i(f.l,f.t),y:a(f.l,f.t)},{op:"lineTo",x:i(f.r,f.t),y:a(f.r,f.t)},{op:"lineTo",x:i(f.r,f.b),y:a(f.r,f.b)},{op:"lineTo",x:i(f.l,f.b),y:a(f.l,f.b)},{op:"closePath"});let l=u.length>0?{cmds:u,fillRule:"nonzero",simple:o.length===1}:Le(),c=En(t);c.tsClip=pi(ob(t)??void 0,sb(t,[l])??void 0),Vr(t);}function ab(t,e,n,r,o){let{view:s}=t;switch(e){case 16426:return ar(t),o>=24&&(t.worldTransform=[s.getFloat32(r,true),s.getFloat32(r+4,true),s.getFloat32(r+8,true),s.getFloat32(r+12,true),s.getFloat32(r+16,true),s.getFloat32(r+20,true)]),true;case 16427:return ar(t),t.worldTransform=[1,0,0,1,0,0],true;case 16428:{if(ar(t),o>=24){let i=[s.getFloat32(r,true),s.getFloat32(r+4,true),s.getFloat32(r+8,true),s.getFloat32(r+12,true),s.getFloat32(r+16,true),s.getFloat32(r+20,true)];n&8192?t.worldTransform=Mn(t.worldTransform,i):t.worldTransform=Mn(i,t.worldTransform);}return true}case 16429:{if(ar(t),o>=8){let i=s.getFloat32(r,true),a=s.getFloat32(r+4,true),u=[1,0,0,1,i,a];n&8192?t.worldTransform=Mn(t.worldTransform,u):t.worldTransform=Mn(u,t.worldTransform);}return true}case 16430:{if(ar(t),o>=8){let i=s.getFloat32(r,true),a=s.getFloat32(r+4,true),u=[i,0,0,a,0,0];n&8192?t.worldTransform=Mn(t.worldTransform,u):t.worldTransform=Mn(u,t.worldTransform);}return true}case 16431:return ar(t),o>=4&&(t.worldTransform=ig(t.worldTransform,s.getFloat32(r,true),(n&8192)!==0)),true;case 16421:return o>=4&&nb(t,s.getUint32(r,true)),true;case 16422:return o>=4&&Z0(t,s.getUint32(r,true)),true;case 16434:{if(o>=16){let i=n>>8&15,a=s.getFloat32(r,true),u=s.getFloat32(r+4,true),l=s.getFloat32(r+8,true),c=s.getFloat32(r+12,true),f=rb(a,u,l,c,hi(t));eb(t,f,i,"SetClipRect");}return true}case 16433:return t.clipRegion=null,Vr(t),true;case 16436:{let i=n&255,a=n>>8&15,u=t.objectTable.get(i);if(u&&u.kind==="plus-region"&&u.nodes.length>0){let l=ko(u.nodes[0],hi(t),0,zu(t));l.exact||z("SetClipRegion: region tree approximated (no canvas domain for an unbounded result)"),ib(t,l.region,a,"SetClipRegion");}return true}case 16435:{let i=n&255,a=n>>8&15,u=t.objectTable.get(i);if(u&&u.kind==="plus-path"){let l=mu(u,hi(t));eb(t,l,a,"SetClipPath");}return true}case 16437:{if(o>=8){let i=s.getFloat32(r,true),a=s.getFloat32(r+4,true);if(t.clipRegion){let u=hi(t),l=u[0]*i+u[2]*a,c=u[1]*i+u[3]*a;t.clipRegion=ir(t.clipRegion,l,c),Vr(t);}}return true}case 16424:return o>=4&&Q0(t,s.getUint32(r,true),null),true;case 16423:{if(o>=36){let i=u=>s.getFloat32(r+u,true),a=lg({x:i(0),y:i(4),w:i(8),h:i(12)},{x:i(16),y:i(20),w:i(24),h:i(28)},n&255,t.dpiX,t.dpiY,t.videoDisplay);Q0(t,s.getUint32(r+32,true),a??[1,0,0,1,0,0]);}return true}case 16425:return o>=4&&Z0(t,s.getUint32(r,true)),true;case 16432:{ar(t);let i=n&255,a=o>=4?s.getFloat32(r,true):1;return i===$u||i>ag||!(a>0)||!Number.isFinite(a)?(true):(t.pageUnit=i,t.pageScale=a,true)}case 16417:return t.interpolationMode=n&255,true;case 16418:return t.pixelOffsetMode=n&255,true;case 16415:return t.textRenderingHint=n&255,true;case 16414:return t.antiAlias=(n&1)!==0,true;case 16420:return En(t).compositingQuality=n&255,true;case 16419:return En(t).compositingMode=n&255,true;case 16413:return o>=8&&(En(t).renderingOrigin={x:s.getInt32(r,true),y:s.getInt32(r+4,true)}),true;case 16416:return En(t).textContrast=n&4095,true;case 16441:return bg(t,r,o),true;case 16442:return pg(t,n,r,o),true;default:return false}}function cb(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}function ub(t,e,n){let r=It(e,n);return r?(Ct(r.ctx,Et(t,e,n),0,0),r):null}function qu(t,e,n){let r=cb(t);if(n.resample&&r){let s=on(e.rgba,e.width,e.height,n.resample,r);if(s){let i=ub(s.rgba,s.w,s.h);if(!i)return false;t.save();try{t.setTransform(1,0,0,1,0,0),t.imageSmoothingEnabled=!1,le(t,i.canvas,s.x,s.y,s.w,s.h);}finally{t.restore();}return true}}let o=ub(e.rgba,e.width,e.height);if(!o)return false;t.save();try{t.setTransform(...n.transform),le(t,o.canvas,n.dx,n.dy,n.dw,n.dh);}finally{t.restore();}return true}function dg(t,e){if(!t.data)return null;let n=new Uint8Array(t.data.slice(0)),r=Us(n);return r?{kind:"encoded",bytes:n,mime:r}:e?{kind:"rgba",data:e.rgba,width:e.width,height:e.height}:go(n.buffer)}function lb(t,e,n,r,o=false){let s=o&&n?{kind:"rgba",data:n.rgba,width:n.width,height:n.height}:dg(e,n);if(!s)return false;let i=t.reserveSlot(),a=t.imageResampling==="exact"&&n&&r.resample?on(n.rgba,n.width,n.height,r.resample,{w:t.canvas.width,h:t.canvas.height}):null,u=r.resample?_s(s):null;if(a){let l={kind:"rgba",data:a.rgba,width:a.w,height:a.h};t.fillSlot(i,l,[1,0,0,1,0,0],a.x,a.y,a.w,a.h);}else if(r.resample&&u){let l=r.resample;t.fillSlotCropped(i,s,l.toDevice,u,l.srcX,l.srcY,l.srcW,l.srcH);}else t.fillSlot(i,s,r.transform,r.dx,r.dy,r.dw,r.dh);return t.shadow&&n&&qu(t.shadow,n,r),true}var Ju=2,Ku=null;function mb(t){Ku=t;}function xg(t,e,n,r,o){let[s,i,a,u,l,c]=t,f=Math.hypot(s,i)*r,m=Math.hypot(a,u)*o;if(!(r>1&&o>1&&f>1&&m>1))return t;let b=(f-1)/f*(r/(r-1)),h=(m-1)/m*(o/(o-1)),p=s*b,d=i*b,x=a*h,y=u*h;return [p,d,x,y,l+(s-p)*e+(a-x)*n,c+(i-d)*e+(u-y)*n]}function yg(t,e,n,r){let o=t.nestingDepth??0;if(!Ku||!r||!e.data||r.unit!==Ju||o>=vu)return false;let{srcX:s,srcY:i,srcW:a,srcH:u}=r;if(!(a>0&&u>0)||![s,i,a,u].every(Number.isFinite))return false;let l=cb(t.ctx);if(!l)return false;let c=xg(Xt(_t(t),r.toWorld(s,i,a,u)),s,i,a,u),f=e.data.slice(0),m=n&&n.kind==="metafile"?n.caches:void 0,{ctx:b}=t;b.save();let h=null;try{b.setTransform(c[0],c[1],c[2],c[3],c[4],c[5]),b.beginPath(),b.rect(s,i,a,u),b.clip(),h=Ku(f,b,l.w,l.h,c,{textureCache:m?.textures,imageCache:m?.images,fontFamilyMap:t.fontFamilyMap,gdiAntialias:t.gdiAntialias,codePages:t.codePages,nestingDepth:o+1});}finally{b.restore();}return h?(t.deferredImages.push(...h),true):false}function gi(t,e,n,r,o){if(o&&o.unit!==Ju)return null;let s=e;if(!s&&t.data){let p=go(t.data.slice(0));p&&p.kind==="rgba"&&(s={rgba:p.data,width:p.width,height:p.height});}if(!s)return null;let i=o&&o.unit===Ju&&o.srcW>0&&o.srcH>0&&[o.srcX,o.srcY,o.srcW,o.srcH].every(Number.isFinite)?o:null,a=hf(bf(s.rgba),s.width,s.height,n,i&&{x:i.srcX,y:i.srcY,w:i.srcW,h:i.srcH});if(!a)return null;let u={kind:"bitmap",width:a.width,height:a.height,rgba:a.rgba};if(!i)return {bitmap:u,draw:r};let l=i.srcX-a.x,c=i.srcY-a.y,f=i.srcW,m=i.srcH,b=[1,0,0,1,a.x,a.y],h=Xt(i.toWorld(i.srcX,i.srcY,i.srcW,i.srcH),b);return {bitmap:u,draw:{...r,transform:Xt(r.transform,h),dx:0,dy:0,dw:a.width,dh:a.height,resample:r.resample&&{...r.resample,srcX:l,srcY:c,srcW:f,srcH:m,toDevice:Xt(r.resample.toDevice,b),rightHalo:a.haloRight}}}}function fb(t,e,n,r,o=null){let s=e.cacheKey!==void 0?t.imageCache?.get(e.cacheKey):void 0;if(e.type===2)return yg(t,e,s,r);let i=s&&s.kind==="bitmap"?s:null,a=o?gi(e,i,o,n,r):null;return a?At(t.ctx)?lb(t.ctx,e,a.bitmap,a.draw,true):qu(t.ctx,a.bitmap,a.draw):o&&!i?false:At(t.ctx)?lb(t.ctx,e,i,n):i?qu(t.ctx,i,n):false}var Zu=class{constructor(e){this.sliceStart=0;this.reason=null;this.signal=e.signal,this.timeoutMs=typeof e.timeoutMs=="number"&&e.timeoutMs>=0?e.timeoutMs:void 0,this.deadline=this.timeoutMs===void 0?1/0:performance.now()+this.timeoutMs,this.yields=!!this.signal;}check(){if(this.reason)throw this.reason.value;if(this.signal?.aborted)this.reason={value:this.signal.reason};else if(performance.now()>this.deadline)this.reason={value:gg()};else return;throw this.reason.value}throwIfTripped(){if(this.reason)throw this.reason.value}get tripped(){return this.reason!==null}remaining(){return {signal:this.signal,timeoutMs:this.timeoutMs===void 0?void 0:Math.max(0,this.deadline-performance.now())}}};function gg(){return new DOMException("The operation was aborted due to timeout","TimeoutError")}var Mi=Symbol("emf-converter.budget");function zr(t){return t?t[Mi]?t[Mi]:t.signal===void 0&&t.timeoutMs===void 0?null:new Zu(t):null}var Hn=null;function Fe(){Hn&&Hn.check();}function qr(){return Hn!==null&&Hn.yields&&performance.now()-Hn.sliceStart>16}function Mg(t,e){let n=Hn;Hn=t,t.sliceStart=performance.now();try{t.check();let r=e();return t.throwIfTripped(),r}finally{Hn=n;}}function Bo(t,e){return t?Mg(t,e):e()}function Eg(){return new Promise(t=>setTimeout(t,0))}async function Qu(t,e){for(;;){let n=Bo(t,()=>e.next());if(n.done)return n.value;await Eg(),t?.check();}}function Ei(t){for(;;){let e=t.next();if(e.done)return e.value}}var Pi=null;function Pg(t,e,n){if(!Pi){Pi=new Uint32Array(256);for(let o=0;o<256;o++){let s=o;for(let i=0;i<8;i++)s=s&1?3988292384^s>>>1:s>>>1;Pi[o]=s>>>0;}}let r=4294967295;for(let o=e;o<n;o++)r=Pi[(r^t[o])&255]^r>>>8;return (r^4294967295)>>>0}function Rg(t){let e=1,n=0;for(let r=0;r<t.length;){let o=Math.min(t.length,r+5552);for(;r<o;r++)e+=t[r],n+=e;e%=65521,n%=65521;}return (n<<16|e)>>>0}function Tg(t){let e=Math.max(1,Math.ceil(t.length/65535)),n=new Uint8Array(2+t.length+e*5+4);n[0]=120,n[1]=1;let r=2;for(let s=0;s<e;s++){let i=s*65535,a=Math.min(65535,t.length-i);n[r++]=s===e-1?1:0,n[r++]=a&255,n[r++]=a>>>8,n[r++]=~a&255,n[r++]=~a>>>8&255,n.set(t.subarray(i,i+a),r),r+=a;}let o=Rg(t);return n[r++]=o>>>24,n[r++]=o>>>16&255,n[r++]=o>>>8&255,n[r++]=o&255,n}async function Ag(t){if(typeof CompressionStream=="function"&&typeof Response=="function")try{let e=new Blob([t]).stream().pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}catch{}return Tg(t)}function wg(t,e,n){let r=t+e-n,o=Math.abs(r-t),s=Math.abs(r-e),i=Math.abs(r-n);return o<=s&&o<=i?t:s<=i?e:n}function bb(t,e){let n=0;for(let r=0;r<e;r++){let o=t[r];n+=o<128?o:256-o;}return n}function Ig(t,e,n){let r=t instanceof Uint8Array||t instanceof Uint8ClampedArray?new Uint8Array(t.buffer,t.byteOffset,t.length):Uint8Array.from(t),o=e*4,s=r.byteOffset%4===0?new Uint32Array(r.buffer,r.byteOffset,e*n):null,i=new Uint8Array((o+1)*n),a=new Uint8Array(o),u=new Uint8Array(o),l=new Uint8Array(o);for(let c=0;c<n;c++){(c&63)===0&&Fe();let f=c*o,m=f-o,b=c*(o+1);if(s&&c>0){let P=f>>2,E=m>>2,R=true;for(let T=0;T<e;T++)if(s[P+T]!==s[E+T]){R=false;break}if(R){i[b]=2;continue}}let h=r.subarray(f,f+o),p=bb(h,o);if(p===0){i.set(h,b+1);continue}let d=0,x=0;for(let P=0;P<4&&P<o;P++){let E=r[f+P];a[P]=E,d+=E<128?E:256-E;}for(let P=4;P<o;P++){let E=r[f+P]-r[f+P-4]&255;a[P]=E,d+=E<128?E:256-E;}if(c>0)for(let P=0;P<o;P++){let E=r[f+P]-r[m+P]&255;u[P]=E,x+=E<128?E:256-E;}else u.set(h),x=p;let y=h,g=0,M=p;if(d<M&&(M=d,y=a,g=1),x<M&&(M=x,y=u,g=2),c>0&&M>o>>3){for(let E=0;E<o;E++){let R=E>=4?r[f+E-4]:0,T=r[m+E],A=E>=4?r[m+E-4]:0;l[E]=r[f+E]-wg(R,T,A)&255;}bb(l,o)<M&&(y=l,g=4);}i[b]=g,i.set(y,b+1);}return i}function tl(t,e){let n=new Uint8Array(12+e.length),r=new DataView(n.buffer);r.setUint32(0,e.length);for(let o=0;o<4;o++)n[4+o]=t.charCodeAt(o);return n.set(e,8),r.setUint32(8+e.length,Pg(n,4,8+e.length)),n}async function Ri(t,e,n){let r=new Uint8Array(13),o=new DataView(r.buffer);o.setUint32(0,e),o.setUint32(4,n),r[8]=8,r[9]=6;let s=await Ag(Ig(t,e,n)),i=[Uint8Array.of(137,80,78,71,13,10,26,10),tl("IHDR",r),tl("IDAT",s),tl("IEND",new Uint8Array(0))],a=i.reduce((c,f)=>c+f.length,0),u=new Uint8Array(a),l=0;for(let c of i)u.set(c,l),l+=c.length;return u}function hb(){throw new Error("JPEG output is not part of the emf-converter lite build")}function pb(){throw new Error("WebP output is not part of the emf-converter lite build")}var Ti=class t{constructor(){this.size=0;}static for(e,n){return new t}};function Oo(t){if($("parseEmfHeader: byteLength =",t.byteLength),t.byteLength<88)return null;let e=t.getUint32(0,true);if(e!==1)return null;let n=t.getInt32(8,true),r=t.getInt32(12,true),o=t.getInt32(16,true),s=t.getInt32(20,true),i=t.getInt32(24,true),a=t.getInt32(28,true),u=t.getInt32(32,true),l=t.getInt32(36,true),c=u-i,f=l-a;return {bounds:{left:n,top:r,right:o,bottom:s},frameW:c,frameH:f}}function db(t){let e=t.bounds.right-t.bounds.left+1,n=t.bounds.bottom-t.bounds.top+1;return e>0&&n>0?({...t.bounds,right:t.bounds.right+1,bottom:t.bounds.bottom+1}):t.frameW>0&&t.frameH>0?($(`getRenderableEmfBounds: bounds invalid (${e}\xD7${n}), falling back to frame ${t.frameW}\xD7${t.frameH}`),{left:0,top:0,right:t.frameW,bottom:t.frameH}):(null)}function el(t){if(t.byteLength<22)return null;let e=t.getUint32(0,true),n=0,r=0,o=0,s=800,i=600,a=96;if(e===2596720087){r=t.getInt16(6,true),o=t.getInt16(8,true),s=t.getInt16(10,true),i=t.getInt16(12,true),a=t.getUint16(14,true)||96,n=22;let f=m=>[1,2].includes(t.getUint16(m,true))&&t.getUint16(m+2,true)===9;t.byteLength>=42&&!f(22)&&t.getUint16(22,true)===0&&f(24)&&(n=24);}if(n+18>t.byteLength)return null;let u=t.getUint16(n,true);if(u!==1&&u!==2)return null;let l=t.getUint16(n+2,true)*2,c=t.getUint32(n+8,true)*2;return {headerSize:n+l,maxRecordSize:c,boundsLeft:r,boundsTop:o,boundsRight:s,boundsBottom:i,unitsPerInch:a,placeable:n>0}}var Dg=[0,8388608,32768,8421376,128,8388736,32896,12632256,12639424,10930928,16776176,10526884,8421504,16711680,65280,16776960,255,16711935,65535,16777215];function Xn(t,e){return t.getUint32(e,true)}function No(t){return t>>>24!==0}function Ve(t){return t.palette?.entries??Dg}function Wo(t,e){let n=t>>>24;if(n&16)return 0;if(n&1){let r=t&65535;return e.length===0?0:e[r<e.length?r:0]}return (t&255)<<16|t&65280|t>>>16&255}function de(t,e){let n=Wo(e,Ve(t));return ms(n>>16&255,n>>8&255,n&255)}function gb(t,e,n){return de(t,Xn(e,n))}function Jr(t,e,n){let r={...t.colorRefs};n!==void 0&&No(n)?r[e]=n:delete r[e],t.colorRefs=r;}function Mb(t){let e=t.colorRefs;e&&(e.pen!==void 0&&(t.penColor=de(t,e.pen)),e.brush!==void 0&&(t.brushColor=de(t,e.brush)),e.text!==void 0&&(t.textColor=de(t,e.text)),e.bk!==void 0&&(t.bkColor=de(t,e.bk)));}function xb(t,e,n){let r=[];for(let o=0;o<n&&e+o*4+4<=t.byteLength;o++){let s=e+o*4;r.push(t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2));}return r}function nl(t,e){let n=t.objectTable.get(e);return n&&n.kind==="palette"?n:null}function yb(t,e){t.state.palette===e&&Mb(t.state);}function Eb(t,e,n,r){let{view:o,state:s}=t;switch(e){case 49:{if(r>=16){let i=o.getUint32(n,true),a=o.getUint16(n+6,true);t.objectTable.set(i,{kind:"palette",entries:xb(o,n+8,Math.min(a,(r-16)/4))});}return true}case 48:{if(r>=12){let i=o.getUint32(n,true);if(i===2147483663)s.palette=null;else {let a=nl(t,i);if(!a)return true;s.palette=a;}Mb(s);}return true}case 50:{if(r>=20){let i=nl(t,o.getUint32(n,true)),a=o.getUint32(n+4,true),u=o.getUint32(n+8,true);if(i){let l=xb(o,n+12,Math.min(u,(r-20)/4));for(let c=0;c<l.length&&a+c<i.entries.length;c++)i.entries[a+c]=l[c];yb(t,i);}}return true}case 51:{if(r>=16){let i=nl(t,o.getUint32(n,true)),a=Math.min(o.getUint32(n+4,true),1024);if(i){for(i.entries.length=Math.min(i.entries.length,a);i.entries.length<a;)i.entries.push(0);yb(t,i);}}return true}case 52:return true;default:return false}}function Gt(t,e){let n=t.state.worldTransform,r=n[0]*e+n[4];if(t.useMappingMode){let o=(r-t.windowOrg.x)/(t.windowExt.cx||1)*(t.viewportExt.cx||1)+t.viewportOrg.x;return t.deviceToCanvas?(o-t.bounds.left)*t.sx:o}return (r-t.bounds.left)*t.sx}function Ot(t,e){let n=t.state.worldTransform,r=n[3]*e+n[5];if(t.useMappingMode){let o=(r-t.windowOrg.y)/(t.windowExt.cy||1)*(t.viewportExt.cy||1)+t.viewportOrg.y;return t.deviceToCanvas?(o-t.bounds.top)*t.sy:o}return (r-t.bounds.top)*t.sy}function qt(t,e){let n=t.state.worldTransform[0]*e;return t.useMappingMode?n/(t.windowExt.cx||1)*(t.viewportExt.cx||1)*(t.deviceToCanvas?t.sx:1):n*t.sx}function oe(t,e){let n=t.state.worldTransform[3]*e;return t.useMappingMode?n/(t.windowExt.cy||1)*(t.viewportExt.cy||1)*(t.deviceToCanvas?t.sy:1):n*t.sy}function Pn(t){return !t.useMappingMode||t.deviceToCanvas?t.sx:1}function Rn(t){return !t.useMappingMode||t.deviceToCanvas?t.sy:1}function rl(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.left)*t.sx:e}function ol(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.top)*t.sy:e}function Kr(t){t.useMappingMode=true;}function jt(t){let e=t.state.worldTransform;return e[1]!==0||e[2]!==0}function yt(t){let e=t.state.worldTransform;if(t.useMappingMode){let o=(t.viewportExt.cx||1)/(t.windowExt.cx||1),s=(t.viewportExt.cy||1)/(t.windowExt.cy||1),[i,a,u,l]=t.deviceToCanvas?[t.sx,t.sy,t.bounds.left,t.bounds.top]:[1,1,0,0];return [e[0]*o*i,e[1]*s*a,e[2]*o*i,e[3]*s*a,((e[4]-t.windowOrg.x)*o+t.viewportOrg.x-u)*i,((e[5]-t.windowOrg.y)*s+t.viewportOrg.y-l)*a]}let n=t.sx||1,r=t.sy||1;return [e[0]*n,e[1]*r,e[2]*n,e[3]*r,(e[4]-t.bounds.left)*n,(e[5]-t.bounds.top)*r]}function Lt(t,e,n){let r=yt(t);return {x:r[0]*e+r[2]*n+r[4],y:r[1]*e+r[3]*n+r[5]}}function Ai(t,e,n,r,o){let s=yt(t),i=Lt(t,e,n),a=s[0]*r,u=s[2]*o,l=s[1]*r,c=s[3]*o,f=a*a+u*u,m=a*l+u*c,b=l*l+c*c,h=(f+b)/2,p=Math.sqrt(Math.max(0,((f-b)/2)**2+m*m)),d=Math.max(0,h+p),x=Math.max(0,h-p),y=.5*Math.atan2(2*m,f-b);return {cx:i.x,cy:i.y,rx:Math.sqrt(d),ry:Math.sqrt(x),rotation:y}}function Pb(t,e){for(let n of e)switch(n.op){case "moveTo":t.moveTo(n.x,n.y);break;case "lineTo":t.lineTo(n.x,n.y);break;case "rect":t.rect(n.x,n.y,n.w,n.h);break;case "bezierCurveTo":t.bezierCurveTo(n.cp1x,n.cp1y,n.cp2x,n.cp2y,n.x,n.y);break;case "arcTo":t.arcTo(n.x1,n.y1,n.x2,n.y2,n.radius);break;case "ellipse":t.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,n.startAngle,n.endAngle,n.ccw);break;case "closePath":t.closePath();break}}function ke(t){let{ctx:e,pathCmds:n}=t;return new Proxy(e,{get(r,o,s){switch(o){case "moveTo":return (i,a)=>(n.push({op:"moveTo",x:i,y:a}),r.moveTo(i,a));case "lineTo":return (i,a)=>(n.push({op:"lineTo",x:i,y:a}),r.lineTo(i,a));case "rect":return (i,a,u,l)=>(n.push({op:"rect",x:i,y:a,w:u,h:l}),r.rect(i,a,u,l));case "bezierCurveTo":return (i,a,u,l,c,f)=>(n.push({op:"bezierCurveTo",cp1x:i,cp1y:a,cp2x:u,cp2y:l,x:c,y:f}),r.bezierCurveTo(i,a,u,l,c,f));case "arcTo":return (i,a,u,l,c)=>(n.push({op:"arcTo",x1:i,y1:a,x2:u,y2:l,radius:c}),r.arcTo(i,a,u,l,c));case "ellipse":return (i,a,u,l,c,f,m,b)=>(n.push({op:"ellipse",cx:i,cy:a,rx:u,ry:l,rotation:c,startAngle:f,endAngle:m,ccw:!!b}),r.ellipse(i,a,u,l,c,f,m,b));case "closePath":return ()=>(n.push({op:"closePath"}),r.closePath());default:{let i=Reflect.get(r,o,s);return typeof i=="function"?i.bind(r):i}}}})}function sl(t){return t>>>16&255}function an(t){let e=t&255;return {usesP:(e>>4&15)!==(e&15),usesS:(e>>2&51)!==(e&51),usesD:(e>>1&85)!==(e&85)}}function Vt(t,e,n,r,o=16777215){let s=0,i=~e,a=~n,u=~r;for(let l=0;l<8;l++)t&1<<l&&(s|=(l&4?e:i)&(l&2?n:a)&(l&1?r:u));return s&o}function wi(t){let e=sl(t);switch(e){case 204:return {kind:"copy"};case 0:return {kind:"solid",color:"black"};case 255:return {kind:"solid",color:"white"};case 170:return {kind:"noop"};case 85:return {kind:"invert-dest"};default:return {kind:"ternary",index:e,operands:an(e)}}}function Rb(t,e,n,r,o,s){let i=t.data,a=e?e.data:null,u=t.width,l=t.height,c=typeof n=="number"?n:0,f=typeof n=="function"?n:null;for(let m=0;m<l;m++)for(let b=0;b<u;b++){let h=(m*u+b)*4,p=i[h]<<16|i[h+1]<<8|i[h+2],d=a?a[h]<<16|a[h+1]<<8|a[h+2]:0,x=f?f(o+b,s+m):c,y=Vt(r,x,d,p);i[h]=y>>16&255,i[h+1]=y>>8&255,i[h+2]=y&255,i[h+3]=255;}}function Tb(t,e,n,r,o,s){let i=n<0?t+n:t,a=r<0?e+r:e,u=Math.abs(n),l=Math.abs(r);i=Math.round(i),a=Math.round(a),u=Math.round(u),l=Math.round(l);let c=Math.min(i+u,Math.round(o)),f=Math.min(a+l,Math.round(s));return i=Math.max(i,0),a=Math.max(a,0),u=c-i,l=f-a,u<=0||l<=0?null:{x:i,y:a,w:u,h:l}}var Fg={9:160,15:250,7:90,10:165,5:80,14:245,3:10,12:175,8:95,2:5};function Yn(t){return t in Fg}function Zr(t){if(!Number.isInteger(t)||t<1||t>16)return;let e=t-1;return (e>>2)*80+(e&3)*5}function il(t,e,n){return t<<16|e<<8|n}function al(t,e){switch(e){case "invert":return ~t&16777215;case "black":return 0;case "white":return 16777215;default:return t}}function Tn(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}function ul(t,e,n){let r=1/0,o=1/0,s=-1/0,i=-1/0,a=0,u=0,l=false,c=(g,M,P=0)=>{r=Math.min(r,g+a-P),o=Math.min(o,M+u-P),s=Math.max(s,g+a+P),i=Math.max(i,M+u+P);},f=()=>{l=true;},m={moveTo:(g,M)=>c(g,M),lineTo:(g,M)=>c(g,M),rect:(g,M,P,E)=>{c(g,M),c(g+P,M+E);},fillRect:(g,M,P,E)=>{c(g,M),c(g+P,M+E);},strokeRect:(g,M,P,E)=>{c(g,M),c(g+P,M+E);},bezierCurveTo:(g,M,P,E,R,T)=>{c(g,M),c(P,E),c(R,T);},quadraticCurveTo:(g,M,P,E)=>{c(g,M),c(P,E);},arcTo:(g,M,P,E)=>{c(g,M),c(P,E);},arc:(g,M,P)=>c(g,M,Math.abs(P)),ellipse:(g,M,P,E)=>c(g,M,Math.max(Math.abs(P),Math.abs(E))),translate:(g,M)=>{a+=g,u+=M;},setTransform:f,transform:f,scale:f,rotate:f},b=()=>{},h=new Proxy(m,{get:(g,M)=>typeof M=="string"&&M in g?g[M]:b,set:()=>true});if(t(h),l)return {x:0,y:0,w:n.w,h:n.h};if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(i))return null;let p=Math.max(0,Math.floor(r-e)),d=Math.max(0,Math.floor(o-e)),x=Math.min(n.w,Math.ceil(s+e)),y=Math.min(n.h,Math.ceil(i+e));return x<=p||y<=d?null:{x:p,y:d,w:x-p,h:y-d}}var kg=1024*1024,mr=null;function ze(t,e){let n=mr&&mr.w>=t&&mr.h>=e?mr:null;if(!n){let o=Math.max(t,mr?.w??0),s=Math.max(e,mr?.h??0),i=o*s<=kg,a=i?It(o,s):It(t,e);if(!a)return null;n={canvas:a.canvas,ctx:a.ctx,w:i?o:t,h:i?s:e},i&&(mr=n);}let r=n.ctx;return r.setTransform(1,0,0,1,0,0),r.globalAlpha=1,r.globalCompositeOperation="source-over",r.clearRect(0,0,t,e),n}function qe(t,e,n,r){Ct(n.ctx,r,0,0);let o=t.drawImage;t.save();try{t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.globalCompositeOperation="source-over",o.call(t,n.canvas,0,0,e.w,e.h,e.x,e.y,e.w,e.h);}finally{t.restore();}}function Ii(t,e){return null}function Si(t,e,n,r,o){let s=null,i=null,a=new Map,u=(c,f,m)=>{c[f*4]=m>>16&255,c[f*4+1]=m>>8&255,c[f*4+2]=m&255,c[f*4+3]=255;};for(let c=0;c<e;c++){if(!n[c]||t[c*4+3]===0)continue;let f=r(c,0),m=r(c,16777215);if(f===m)continue;let b=0,h=0,p=true;for(let x=16;x>=0;x-=8){let y=f>>x&255,g=m>>x&255;if(y===g)h|=y<<x;else if(y===0&&g===255)b|=255<<x;else if(y===255&&g===0)b|=255<<x,h|=255<<x;else {p=false;break}}if(p){t[c*4+3]=0,b!==16777215&&(s??(s=new Uint8ClampedArray(e*4)),u(s,c,b)),h!==0&&(i??(i=new Uint8ClampedArray(e*4)),u(i,c,h));continue}let d=o?.(c);if(d){if(t[c*4+3]=0,d.mode==="multiply"){s??(s=new Uint8ClampedArray(e*4)),u(s,c,d.color);continue}if(d.mode==="difference"){i??(i=new Uint8ClampedArray(e*4)),u(i,c,d.color);continue}let x=a.get(d.mode);x||(x=new Uint8ClampedArray(e*4),a.set(d.mode,x)),u(x,c,d.color);}}let l=[];s&&l.push({mode:"multiply",data:s}),i&&l.push({mode:"difference",data:i});for(let[c,f]of a)l.push({mode:c,data:f});return l}function vi(t,e,n){}function Qr(t,e,n,r){try{let o=Tt(t,e.x,e.y,e.w,e.h),s=o.data,i=ze(e.w,e.h),a=i?Tt(i.ctx,0,0,e.w,e.h):o,u=a.data;for(let f=0;f<e.h;f++)for(let m=0;m<e.w;m++){let b=(f*e.w+m)*4,h=n(e.x+m,e.y+f,il(s[b],s[b+1],s[b+2]));h<0||(u[b]=h>>16&255,u[b+1]=h>>8&255,u[b+2]=h&255,u[b+3]=255);}if(!i)return Ct(t,o,e.x,e.y),!0;let l=Ii(t,e),c=l?Si(u,e.w*e.h,l,(f,m)=>n(e.x+f%e.w,e.y+Math.floor(f/e.w),m),r&&(f=>r(e.x+f%e.w,e.y+Math.floor(f/e.w)))):[];return qe(t,e,i,a),vi(t,e,c),!0}catch{return false}}function ll(t,e,n,r,o=2,s){let i=Zr(e);if(i===void 0||false)return false;if(i===170)return true;let a=Tn(t);if(!a)return false;try{let u=ul(r,o,a);if(!u)return !0;let l=ze(u.w,u.h);if(!l)return !1;let c=l.ctx;c.save();try{c.fillStyle=n,c.strokeStyle=n,c.translate(-u.x,-u.y),r(c);}finally{c.restore();}let f=s!==void 0&&typeof c.isPointInPath=="function",m=/^#([0-9a-f]{6})$/i.exec(n.trim()),b=m?parseInt(m[1],16):-1,h=Tt(c,0,0,u.w,u.h),p=h.data,d=i===240?null:Tt(t,u.x,u.y,u.w,u.h).data,x=d?Ii(t,u):null,y=x?new Int32Array(u.w*u.h):null;for(let M=0;M<p.length;M+=4){let P=p[M+3],E;if(P===0)E=!1;else if(P===255)E=!0;else if(f){let A=(M>>2)%u.w,w=((M>>2)-A)/u.w;E=c.isPointInPath(A+.5,w+.5,s);}else E=P>=128;if(!E){p[M]=0,p[M+1]=0,p[M+2]=0,p[M+3]=0;continue}let R=b>=0?b:il(p[M],p[M+1],p[M+2]);y&&(y[M>>2]=R);let T=R;if(d){let A=il(d[M],d[M+1],d[M+2]);T=Vt(i,R,A,A);}p[M]=T>>16&255,p[M+1]=T>>8&255,p[M+2]=T&255,p[M+3]=255;}let g=[];if(x&&y);return qe(t,u,l,h),vi(t,u,g),!0}catch{return false}}var Bg=16*1024*1024;function Ab(t){if(t.gdiAntialias!==false)return null;if(t.rasterLayer!==void 0)return t.rasterLayer;let e=Tn(t.ctx);return !e||At(t.ctx)||e.w*e.h>Bg?(t.rasterLayer=null,null):(t.rasterLayer={w:e.w,h:e.h,data:new Uint8ClampedArray(e.w*e.h*4),x0:e.w,y0:e.h,x1:0,y1:0},t.rasterLayer)}function Nt(t){let e=t.rasterLayer;if(!e||e.x1<=e.x0||e.y1<=e.y0)return;let n={x:e.x0,y:e.y0,w:e.x1-e.x0,h:e.y1-e.y0},r=new Uint8ClampedArray(n.w*n.h*4);for(let i=0;i<n.h;i++){let a=((n.y+i)*e.w+n.x)*4;r.set(e.data.subarray(a,a+n.w*4),i*n.w*4),e.data.fill(0,a,a+n.w*4);}e.x0=e.w,e.y0=e.h,e.x1=0,e.y1=0;let o=ze(n.w,n.h);if(o){qe(t.ctx,n,o,Et(r,n.w,n.h));return}let s=Tt(t.ctx,n.x,n.y,n.w,n.h);for(let i=0;i<r.length;i+=4)r[i+3]!==0&&(s.data[i]=r[i],s.data[i+1]=r[i+1],s.data[i+2]=r[i+2],s.data[i+3]=255);Ct(t.ctx,s,n.x,n.y);}var Gg=new Set([2,3,4,5,6,7,8,27,41,42,43,44,45,46,47,54,55,56,59,60,61,62,63,64,65,66,68,71,72,73,74,85,86,87,88,89,90,91,92,37,38,39,40,82,93,94,95,9,10,11,12,13,17,18,19,20,21,22,24,25,31,32,33,35,36,57,58,16,23,48,49,50,51,52,99,100,101,102,103,104,105,106,109,110,111,112,113,119,120,121,122]);function Ci(t){return Gg.has(t)}function Sb(t,e,n){if(t.kind!=="tile"||!t.skip)return false;let[r,o]=t.toDevice(e,n),{width:s,height:i}=t.tile,a=((r-t.orgX)%s+s)%s,u=((o-t.orgY)%i+i)%i;return t.skip[u*s+a]===1}function wb(t){return `#${(t&16777215).toString(16).padStart(6,"0")}`}function vb(t){for(let e of [0,16777215])if(Vt(t,e,0,0)!==Vt(t,e,0,16777215))return true;return false}function Cb(t,e){t.beginPath();for(let n of cl(e))t.rect(n.x,n.y,n.w,n.h);}function cl(t){let e=[],n=t.length,r=t.data,o=new Array(n);for(let i=0;i<n;i++)o[i]=i*3;o.sort((i,a)=>r[i+1]-r[a+1]||r[i+2]-r[a+2]||r[i]-r[a]);let s=0;for(;s<n;){let i=o[s],a=r[i+1],u=r[i+2],l=r[i],c=l+1,f=s+1;for(;f<n;){let m=o[f];if(r[m+1]!==a||r[m+2]!==u||r[m]>c)break;r[m]===c&&c++,f++;}e.push({x:a,y:l,w:u-a,h:c-l}),s=f;}return e}function Ib(t,e,n,r="source-over"){t.save();try{t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.globalCompositeOperation=r,t.fillStyle=n,Cb(t,e),t.fill("nonzero");}finally{t.restore();}}function se(t,e,n,r){if(e.length===0)return;let o=Zr(r)??240;if(o===170)return;let s=vb(o)?null:Ab(t);if(!s){Nt(t),Og(t.ctx,e,n,r);return}let{w:i,h:a,data:u}=s,l=e.data,c=n.kind==="solid"?Vt(o,n.rgb,0,0):0;for(let f=0;f<e.length*3;f+=3){let m=l[f];if(m<0||m>=a)continue;let b=Math.max(0,l[f+1]),h=Math.min(i,l[f+2]);if(h<=b)continue;b<s.x0&&(s.x0=b),h>s.x1&&(s.x1=h),m<s.y0&&(s.y0=m),m+1>s.y1&&(s.y1=m+1);let p=(m*i+b)*4;for(let d=b;d<h;d++,p+=4){if(Sb(n,d,m))continue;let x=c;if(n.kind==="tile"){let[y,g]=n.toDevice(d,m);x=Vt(o,qn(n.tile,y,g,n.orgX,n.orgY),0,0);}u[p]=x>>16&255,u[p+1]=x>>8&255,u[p+2]=x&255,u[p+3]=255;}}}function Og(t,e,n,r){if(e.length===0)return;let o=Zr(r)??240;if(o===170)return;let s=vb(o);if(n.kind==="solid"&&!s){Ib(t,e,wb(Vt(o,n.rgb,0,0)));return}if(n.kind==="tile"&&At());let i=e.bounds(),a=Tn(t);if(!i)return;let u=Math.max(0,i.x0),l=Math.max(0,i.y0),c=a?Math.min(a.w,i.x1):i.x1,f=a?Math.min(a.h,i.y1):i.y1;if(c<=u||f<=l)return;let m={x:u,y:l,w:c-u,h:f-l},b=ze(m.w,m.h);if(!b)return;let h=Tt(t,m.x,m.y,m.w,m.h).data,p=Tt(b.ctx,0,0,m.w,m.h),d=p.data,x=e.data;for(let y=0;y<e.length*3;y+=3){let g=x[y];if(g<l||g>=f)continue;let M=Math.max(u,x[y+1]),P=Math.min(c,x[y+2]);for(let E=M;E<P;E++){if(Sb(n,E,g))continue;let R=((g-l)*m.w+(E-u))*4,T;if(n.kind==="solid")T=n.rgb;else {let[w,I]=n.toDevice(E,g);T=qn(n.tile,w,I,n.orgX,n.orgY);}let A=T;if(s){let w=d[R+3]===255?d[R]<<16|d[R+1]<<8|d[R+2]:h[R]<<16|h[R+1]<<8|h[R+2];A=Vt(o,T,w,w);}else A=Vt(o,T,0,0);d[R]=A>>16&255,d[R+1]=A>>8&255,d[R+2]=A&255,d[R+3]=255;}}qe(t,m,b,p);}var Ng=[[[0,-8],[-8,0],[0,8],[8,0]],[[8,-16],[-8,-16],[-16,0],[-8,16],[8,16],[16,0]],[[8,-24],[-8,-24],[-24,-8],[-24,8],[-8,24],[8,24],[24,8],[24,-8]],[[8,-32],[-8,-32],[-24,-24],[-32,-8],[-32,8],[-24,24],[-8,32],[8,32],[24,24],[32,8],[32,-8],[24,-24]],[[8,-40],[-8,-40],[-24,-32],[-32,-24],[-40,-8],[-40,8],[-32,24],[-24,32],[-8,40],[8,40],[24,32],[32,24],[40,8],[40,-8],[32,-24],[24,-32]],[[8,-48],[-8,-48],[-24,-40],[-40,-24],[-48,-8],[-48,8],[-40,24],[-24,40],[-8,48],[8,48],[24,40],[40,24],[48,8],[48,-8],[40,-24],[24,-40]]],bl=104;function Wg(t,e){return t?e?.5:-0.5:0}function Hg(t,e){if(Number.isSafeInteger(t)&&Number.isSafeInteger(e))return Math.floor(t/e);let n=BigInt(Math.round(t)),r=BigInt(Math.round(e)),o=n/r;return n%r!==0n&&n<0n!=r<0n&&(o-=1n),Number(o)}var Ub=new Map;function hl(t,e=t){let n=`${t},${e}`,r=Ub.get(n);if(r)return r;let o;if(t===e&&t<bl){let s=Math.min(6,Math.max(1,Math.floor(t/16+.5)));o=Ng[s-1];}else {let s=Math.ceil(t/2),i=Math.ceil(e/2),a=Fa(Da(-s,-i,s,i)),u=[];for(let l=0;l+1<a.length&&(u.push([a[l],a[l+1]]),!(l>0&&a[l+1]===0));l+=2);u.pop(),o=[...u,...u.map(l=>[0-l[0]||0,0-l[1]||0])];}return Ub.set(n,o),o}var ml=new Map;function Ui(t){return Math.sign(t)*Math.floor(Math.abs(t)+.75)}function Xg(t,e){let n=`${t},${e.join(",")}`,r=ml.get(n);if(r)return r;let o=Math.hypot(e[0],e[1]);if(Math.abs(Math.hypot(e[2],e[3])-o)<1e-4*o&&Math.abs(e[0]*e[2]+e[1]*e[3])<1e-4*o*o&&t*o<bl){let b=hl(Math.round(t*o));return ml.set(n,b),b}let s=t/2,i=e[0]*e[3]-e[1]*e[2]<0?-1:1,a=[Ui(e[0]*s),Ui(e[1]*s)],u=[i*Ui(e[2]*s),i*Ui(e[3]*s)],l=pn({ax:-a[0]-u[0],ay:-a[1]-u[1],exx:2*a[0],exy:2*a[1],eyx:2*u[0],eyy:2*u[1]}),c=Fa(l.slice(0,14)),f=[];for(let b=0;b+1<c.length;b+=2)f.push([c[b],c[b+1]]);f.pop();let m=[...f,...f.map(b=>[0-b[0]||0,0-b[1]||0])];return ml.set(n,m),m}function Yg(t,e,n,r=1,o=r,s){let i=t.length,a=t.some(p=>p[1]===0),u=Math.abs(n)*(r===o?1:r),l=Math.abs(e)*(r===o?2:o);if(s){let p=s[0]*s[3]-s[1]*s[2];l=Math.abs((s[3]*e-s[2]*n)/p),u=Math.abs((-s[1]*e+s[0]*n)/p);}let f=(u>l||u===l&&a?n<0:e<0||e===0&&n<0)?-1:1;s&&s[0]*s[3]-s[1]*s[2]<0&&(f=-f);let m=0,b=-1/0,h=0;for(let p=0;p<i;p++){let d=n*t[p][0]-e*t[p][1],x=f*(e*t[p][0]+n*t[p][1]);(d>b||d===b&&x>h)&&(b=d,m=p,h=x);}return [m,(m+i/2)%i]}function _i(t){return Math.sign(t)*8*Math.floor((Math.abs(t)+4)/8)}function $g(t,e,n,r=t,o){let s=e,i=n,a=s<0||s===0&&i<0;a&&(s=-s,i=-i);let u=o??hl(t,r),l=u.length,c=-i,f=s,m=0,b=-1/0;for(let L=0;L<l;L++){let F=c*u[L][0]+f*u[L][1];F>b&&(b=F,m=L);}a&&m===0&&c*u[l-1][0]+f*u[l-1][1]===b&&(m=l-1);let h=u[(m+l-1)%l],p=u[(m+1)%l],d=u[m],x=c*h[0]+f*h[1],y=c*p[0]+f*p[1],[g,M,P]=x>=y?[h,x,y]:[p,y,x],E=2*(b-M+(b-P)),R=E===0?0:(M-P)/E,T=d[0]+(g[0]-d[0])*R,A=d[1]+(g[1]-d[1])*R,w=M-P,I=L=>Math.sign(E===0?d[L]:d[L]*E+(g[L]-d[L])*w),S=o?[I(0)!==0?-I(0):s===0?0:Math.sign(i),I(1)!==0?I(1):Math.sign(s)]:[s===0?0:Math.sign(i),Math.sign(s)],v=o?m<l/2:m===0&&x>=y,C=[0,1].map(L=>{let F=S[L]+2*Wg(Math.abs(g[L]-d[L])%2===1,v);if(E===0)return 8*(L===1&&i<0?Math.ceil((d[L]+F/2+4)/8)-1:Math.floor((d[L]+F/2+4)/8));let B=d[L]*E+(g[L]-d[L])*w;return 8*Hg(2*B+E*(F+8)-(L===1&&i<0?1:0),16*E)}),U=C[0],D=C[1];return {v:a?[-U,-D]:[U,D],ray:a?[-T,-A]:[T,A]}}function un(t,e){return Math.sqrt(t*t+e*e)}function _b(t,e,n,r=1,o=t,s,i=false,a=i,u=1){if(s){let p=s[0]*s[3]-s[1]*s[2],d=(s[3]*e-s[2]*n)/p,x=(-s[1]*e+s[0]*n)/p,y=Math.hypot(d,x);if(i&&(y=un(Math.sign(d)*Math.floor((Math.abs(d)+8)/16)*16,Math.sign(x)*Math.floor((Math.abs(x)+8)/16)*16),y===0))return [0,0];let g=t/2*r/y,M=a?P=>Math.sign(P)*Math.floor(Math.abs(P)+.5):P=>Math.floor(P+.5);return [M((s[0]*d+s[2]*x)*g),M((s[1]*d+s[3]*x)*g)]}let[c,f]=typeof u=="number"?[u,u]:u,m=t/2*r,b=a?p=>Math.sign(p)*Math.floor(Math.abs(p)+.5):p=>Math.floor(p+.5);if(i&&(t===o||c!==f)){let p=e/c,d=n/f,x=c===1&&f===1?0:8,y=M=>x?Math.sign(M)*Math.floor((Math.abs(M)+x)/16)*16:Math.floor(M/16)*16,g=un(y(p),y(d));return g===0?[0,0]:[b(p/g*m),b(d*f/c/g*m)]}let h=t===o?un(e,n):un(e,n*t/o);return [b(e/h*m),b(n/h*m)]}function Li(t,e,n,r){let o=t*r-e*n;if(o!==0)return o;if(t*n+e*r>=0)return 0;let s=t>=0?1:-1,i=e>=0?1:-1,a=Math.abs(e)>Math.abs(t)||Math.abs(e)===Math.abs(t)&&e>0;return s*i<0!==a?-1:1}var fl=class{constructor(e,n){this.opts=e;this.out=n;this.pts=[];this.pen=e.matrix&&e.deviceNib?Xg(e.width,e.matrix):hl(e.width,e.height),this.n=this.pen.length,this.rr=e.cap==="round"&&e.join==="round",this.originalRoundJoinSides=e.join==="round"&&e.cap!=="flat",this.maxX=Math.max(...this.pen.map(r=>Math.abs(r[0])));}seg(e,n,r,o,s=false){let i=r?r[0]:n[0]-e[0],a=r?r[1]:n[1]-e[1],u=o??[i,a],l=this.opts.deviceNib?this.opts.matrix:void 0,[c,f]=Yg(this.pen,u[0],u[1],this.opts.width,this.opts.height,l),m=s&&o?o:[i,a],b=$g(this.opts.width,m[0],m[1],this.opts.height,l?this.pen:void 0),h=!!o&&i*o[0]+a*o[1]<0;return {dx:i,dy:a,tx:h?o[0]:i,ty:h?o[1]:a,L:c,R:f,v:b.v,vRaw:b.ray,e:_b(this.opts.capWidth??this.opts.width,m[0],m[1],1,this.opts.height??this.opts.capWidth,l,!!(this.opts.wholePixelDashVectors||this.opts.cutToLogicalUnits),void 0,this.opts.logicalScale),pe:[m[0],m[1]],curveEnd:!!o,role:o?.[2]??3,tangentLength:o?o[0]*o[0]+o[1]*o[1]:0,curve:s}}push(e,n){this.pts.push([e[0]+n[0],e[1]+n[1]]);}penAt(e,n){let r=this.pen[n];(e[0]&15)===0&&(e[1]&15)===0?this.push(e,[r[0]-Math.sign(r[0]),r[1]-Math.sign(r[1])]):this.push(e,r);}walk(e,n,r,o,s){if(o&&this.penAt(e,n),n!==r){for(let i=(n+1)%this.n;i!==r;i=(i+1)%this.n)this.penAt(e,i);s&&this.penAt(e,r);}}wedge(e,n,r,o,s,i=-1){let a=Math.PI*2,u=Math.atan2(n[1],n[0]),l=b=>{let h=(u-Math.atan2(b[1],b[0]))%a;return h<0&&(h+=a),h},c=(b,h)=>b[0]*h[1]-b[1]*h[0]===0&&b[0]*h[0]+b[1]*h[1]>0,f=c(n,r)?a:l(r),m=[];for(let b=0;b<this.n;b++){let h=this.pen[b];if(c(n,h))o&&m.push([0,b]);else if(c(r,h))s&&m.push([f,b]);else {let p=l(h);p<f&&m.push([p,b]);}}m.sort((b,h)=>b[0]-h[0]),i>=0&&!m.some(([,b])=>b===i)&&m.push([1/0,i]);for(let[,b]of m)this.penAt(e,b);}extremeTail(e,n,r){let o=this.pen[n];return e&&Math.abs(r.dy)>Math.abs(r.dx)&&Math.abs(o[0])===this.maxX&&o[1]===0?n:-1}joinSide(e,n){if(this.originalRoundJoinSides||e.curve){let r=this.pen[n==="L"?e.L:e.R];return [_i(r[0]),_i(r[1])]}return n==="R"?e.v:[-e.v[0],-e.v[1]]}capSide(e,n){if(this.rr){let r=this.pen[n==="L"?e.L:e.R];return [_i(r[0]),_i(r[1])]}return n==="R"?e.v:[-e.v[0],-e.v[1]]}cap(e,n,r,o=1){let s=r?"L":"R",i=r?"R":"L",{cap:a}=this.opts;if(a==="round"){if(this.push(e,this.capSide(n,s)),this.rr)this.walk(e,n[s],n[i],false,false);else {let c=s==="R"?n.vRaw:[-n.vRaw[0],-n.vRaw[1]];this.wedge(e,c,[-c[0],-c[1]],true,false);}this.push(e,this.capSide(n,i));return}let u=this.capSide(n,s),l=this.capSide(n,i);if(a==="square"){let c=o===1||n.curveEnd?n.e:this.scaledExtension(n,o),f=r?[-c[0],-c[1]]:c;this.push(e,[u[0]+f[0],u[1]+f[1]]),this.push(e,[l[0]+f[0],l[1]+f[1]]);}else this.push(e,u),this.push(e,l);}scaledExtension(e,n){let r=this.opts;if(r.wholePixelDashVectors&&!r.matrix&&!r.dashMetric&&(r.height===void 0||r.height===r.width)){let o=un(Math.floor(e.pe[0]/16),Math.floor(e.pe[1]/16))*16;if(o>0){let s=Math.fround(r.width/2/o),i=a=>Math.sign(a)*Math.floor(Math.fround(Math.abs(a)*s)+.5);return [i(e.pe[0]),i(e.pe[1])]}}return _b(r.width,e.pe[0],e.pe[1],n,r.height,r.deviceNib?r.matrix:void 0,false,!!r.wholePixelDashVectors)}join(e,n,r,o,s){let{cap:i,width:a,miterLimit:u}=this.opts,l=n.curve&&r.curve,c=l?"round":this.opts.join,f=this.originalRoundJoinSides||l,m=this.joinSide(n,o),b=this.joinSide(r,o),h=o==="R"?n.vRaw:[-n.vRaw[0],-n.vRaw[1]],p=o==="R"?r.vRaw:[-r.vRaw[0],-r.vRaw[1]];if(l&&!this.originalRoundJoinSides&&n.curveEnd&&r.curveEnd&&((o==="R"?n:r).role&2)!==0&&((o==="R"?r:n).role&1)!==0){let y=n.tangentLength>=r.tangentLength?n:r;m=b=o==="R"?y.v:[-y.v[0],-y.v[1]];}!l&&!this.originalRoundJoinSides&&(n.curve&&n.curveEnd&&(m=o==="R"?n.v:[-n.v[0],-n.v[1]]),r.curve&&r.curveEnd&&(b=o==="R"?r.v:[-r.v[0],-r.v[1]]));let d=o==="R"?n.R:n.L,x=o==="R"?r.R:r.L;if(f&&(d===x||l&&m[0]===b[0]&&m[1]===b[1])){this.push(e,m);return}if(this.push(e,m),s){if(c==="round")if(f){let y=this.pen[x],g=Math.abs(r.dy)>Math.abs(r.dx),M=o==="L"&&g&&Math.abs(y[0])===this.maxX&&y[0]*y[1]<=0;this.walk(e,d,x,false,M);}else {let y=m[0]===-b[0]&&m[1]===-b[1];(d!==x||y)&&this.wedge(e,h,p,!y,false,this.extremeTail(o==="L"&&!y,x,r));}else if(c==="miter"){let y=zg(m,[n.dx,n.dy],b,[r.dx,r.dy],a,u,o,this.opts.height,this.opts.deviceNib?this.opts.matrix:void 0);y&&this.push(e,y);}}else {if(this.pts.push([e[0],e[1]]),l&&!this.originalRoundJoinSides){if(this.push(e,b),i==="flat"&&d!==x&&!(n.curveEnd&&r.curveEnd)){let y=this.pts.length;this.wedge(e,p,h,false,false,this.extremeTail(o==="L",d,n)),this.pts.length-y<2&&(this.pts.length=y);}this.push(e,m),this.pts.push([e[0],e[1]]);}c==="round"&&i==="flat"&&!l&&(this.push(e,b),d!==x&&this.wedge(e,p,h,false,false,this.extremeTail(o==="L",d,n)),this.push(e,m),this.pts.push([e[0],e[1]]));}this.push(e,b);}flush(){let e=[],n=NaN,r=NaN;for(let[o,s]of this.pts)(o!==n||s!==r)&&(e.push(o,s),n=o,r=s);for(;e.length>=4&&e[0]===e[e.length-2]&&e[1]===e[e.length-1];)e.length-=2;e.length>=6&&this.out.push(e),this.pts=[];}open(e,n,r,o,s=1,i=1){if(e.length<2&&!n?.[0]){this.dot(e[0]);return}let a=[];for(let u=0;u+1<e.length;u++)a.push(this.seg(e[u],e[u+1],n?.[u],r?.[u],o?.[u]));if(a.length===0){let u=this.seg(e[0],e[0],n?.[0],r?.[0],o?.[0]);this.cap(e[0],u,true,s),this.cap(e[0],u,false,i),this.flush();return}this.cap(e[0],a[0],true,s);for(let u=0;u+1<a.length;u++){let l=a[u],c=a[u+1],f=Li(l.tx,l.ty,c.tx,c.ty);f===0?this.push(e[u+1],this.joinSide(l,"R")):this.join(e[u+1],l,c,"R",f<0);}this.cap(e[e.length-1],a[a.length-1],false,i);for(let u=a.length-1;u>0;u--){let l=a[u],c=a[u-1],f=Li(c.tx,c.ty,l.tx,l.ty);f===0?this.push(e[u],this.joinSide(l,"L")):this.join(e[u],l,c,"L",f>0);}this.flush();}closed(e,n,r){let o=e.length,s=[];for(let i=0;i<o;i++)s.push(this.seg(e[i],e[(i+1)%o],void 0,n?.[i],r?.[i]));for(let i=1;i<=o;i++){let a=i%o,u=s[(a+o-1)%o],l=s[a],c=Li(u.tx,u.ty,l.tx,l.ty);c===0?this.push(e[a],this.joinSide(u,"R")):this.join(e[a],u,l,"R",c<0);}this.flush();for(let i=0;i<o;i++){let a=(o-i)%o,u=s[a],l=s[(a+o-1)%o],c=Li(l.tx,l.ty,u.tx,u.ty);c===0?this.push(e[a],this.joinSide(u,"L")):this.join(e[a],u,l,"L",c>0);}this.flush();}dot(e){if(this.opts.cap!=="round")return;let n=e[0]%16===0&&e[1]%16===0,r=this.opts.matrix,o=!this.opts.deviceNib||!r||r[1]===0&&r[2]===0,s=!this.opts.deviceNib&&(this.opts.height===void 0||this.opts.height===this.opts.width)&&this.opts.width<bl;for(let i=0;i<this.n;i++){let a=this.pen[i],u=s?i===0||i===this.n/2:a[0]===0;this.push(e,n&&o&&!u?[a[0]-Math.sign(a[0]),a[1]-Math.sign(a[1])]:a);}this.flush();}};function Di(t){return Math.sign(t)*Math.floor((Math.abs(t)+8)/16)*16}function Lb(t,e,n,r){let o=Math.abs(e)*(n/r),s=Math.fround(t+(e<0?-o:o));return e<0?Math.ceil(s-.5):Math.floor(s+.5)}function jg(t,e,n,r,o,s,i,a){let u=[],l=[];for(let h=0;h<r.length;h+=2){let p=r[h],d=r[h+1]??0,x=Math.min(p,o);l.push(p-x,d+x);}if(l.reduce((h,p)=>h+p,0)<=0)return [];let c=0,f=l[0],m=true,b={pts:[t[0]],dirs:[],draws:[],curves:[],startScale:1,endScale:1};for(let h=0;h+1<t.length;h++){let[p,d]=t[h],[x,y]=t[h+1],g=[x-p,y-d],M=a?a[0]*a[3]-a[1]*a[2]:1,P=a?Math.hypot((a[3]*g[0]-a[2]*g[1])/M,(-a[1]*g[0]+a[0]*g[1])/M):i?Math.hypot(g[0]/i[0],g[1]/i[1]):un(g[0],g[1]),E=i?un(Di(g[0]/i[0]),Di(g[1]/i[1])):a?un(Di((a[3]*g[0]-a[2]*g[1])/M),Di((-a[1]*g[0]+a[0]*g[1])/M)):s?un(Math.floor(g[0]/16),Math.floor(g[1]/16))*16:un(g[0],g[1]);if(E===0){m&&b&&(b.pts.push(t[h+1]),b.dirs.push(g),b.draws.push(e[h]),b.curves.push(n[h]));continue}let R=0;for(;E-R>f||f===0&&m;){R+=f;let T=[Lb(p,g[0],R,E),Lb(d,g[1],R,E)];m&&b?(b.pts.push(T),b.dirs.push(g),b.draws.push(e[h]),b.curves.push(n[h]),b.endScale=b.pts[0]===t[0]&&T[0]===t[0][0]&&T[1]===t[0][1]?1:P/E,u.push(b),b=null):b={pts:[T],dirs:[],draws:[],curves:[],startScale:P/E,endScale:1},m=!m,c=(c+1)%l.length,f=l[c];}f-=E-R,m&&b&&(b.pts.push(t[h+1]),b.dirs.push(g),b.draws.push(e[h]),b.curves.push(n[h]),b.endScale=P/E);}return m&&b&&b.dirs.length>0&&(b.endScale=1,u.push(b)),u}function Vg(t,e,n){let[r,o,s,i]=n,a=r*i-o*s,u=(f,m)=>[(i*f-s*m)/a,(-o*f+r*m)/a],l=new St;for(let f of t.figures){let m=[];for(let h=0;h+1<f.pts.length;h+=2)m.push(...u(f.pts[h],f.pts[h+1]));let b={pts:m,closed:f.closed,roundWiden:f.roundWiden,curveSegs:f.curveSegs,tangentRoles:f.tangentRoles};f.tangents&&(b.tangents=new Map([...f.tangents].map(([h,p])=>[h,u(p[0],p[1])]))),l.figures.push(b);}return Ho(l,{...e,matrix:void 0,height:void 0}).map(f=>{let m=[];for(let b=0;b+1<f.length;b+=2)m.push(Math.round(r*f[b]+s*f[b+1]),Math.round(o*f[b]+i*f[b+1]));return m})}function Ho(t,e){if(e.matrix&&!e.deviceNib)return Vg(t,e,e.matrix);let n=[],r=!!e.dashes&&e.dashes.length>0;for(let o of t.figures){let s=new fl(e,n),i=[],a=[],u=[];for(let c=0;c+1<o.pts.length;c+=2){let f=[o.pts[c],o.pts[c+1]],m=i[i.length-1];if(!(m&&m[0]===f[0]&&m[1]===f[1])){if(m){{let b=o.tangents?.get(c/2-1);a.push(b&&[b[0],b[1],(o.roundWiden?3:o.tangentRoles?.get(c/2-1))??3]);}u.push(!!o.roundWiden||!!o.curveSegs?.has(c/2-1));}i.push(f);}}if(i.length===0)continue;let l=o.closed&&i.length>=2;if(l&&i.length>=2&&i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1]&&(i=i.slice(0,-1)),r){let c=l?[...i,i[0]]:i,f=e.cap==="flat"||e.shortenDashes===false?0:e.dashMetric?e.width/e.dashMetric[0]:e.width,m=l?[...a,void 0]:a,b=l?[...u,!!o.roundWiden]:u;for(let h of jg(c,m,b,e.dashes,f,!!e.wholePixelDashVectors,e.dashMetric,e.deviceNib?e.matrix:void 0)){let p=h.pts,d=h.dirs,x=h.draws,y=h.curves;s.open(p,d.length>0?d:[h.dirs[0]],d.length>0?x:[h.draws[0]],d.length>0?y:[h.curves[0]],h.startScale,h.endScale);}}else l&&i.length>=3||l&&i.length===2?s.closed(i,a,u):s.open(i,void 0,a,u);}return n}function zg(t,e,n,r,o,s,i,a=o,u){let l=e[0]*r[1]-e[1]*r[0];if(l===0)return null;let c=n[0]-t[0],f=n[1]-t[1],m=(c*r[1]-f*r[0])/l,b=t[0]+e[0]*m,h=t[1]+e[1]*m,p=Math.sign(b)*Math.floor(Math.abs(b)+.5),d=Math.sign(h)*Math.floor(Math.abs(h)+.5),x=i==="L"?Math.ceil:Math.floor;if(u){let g=u[0]*u[3]-u[1]*u[2],M=(u[3]*p-u[2]*d)/g,P=(-u[1]*p+u[0]*d)/g;return Math.hypot(Math.round(M/16),Math.round(P/16))>s*o/32?null:[p,d]}let y=a===o?x(d/16):x(d/16)*o/a;return Math.hypot(x(p/16),y)>s*o/32?null:[p,d]}function pl(t){let e=/^#?([0-9a-f]{6})$/i.exec(t.trim());return e?parseInt(e[1],16):0}function dt(t,e,n){let r=yt(t),o=Math.round((r[0]*e+r[2]*n)*16)+Math.round(r[4]*16),s=Math.round((r[1]*e+r[3]*n)*16)+Math.round(r[5]*16),i=t.wholeDevicePixels;if(i){let a=16*i[0],u=16*i[1];return [Math.round(Math.floor(o/a+.5)*a),Math.round(Math.floor(s/u+.5)*u)]}return [o,s]}function Xo(t,e,n,r,o){let[s,i]=dt(t,e,n),[a,u]=dt(t,r,n),[l,c]=dt(t,e,o);return {ax:s,ay:i,exx:a-s,exy:u-i,eyx:l-s,eyy:c-i}}function Re(t){return t.exy===0&&t.eyx===0}function qg(t){let{ax:e,ay:n,exx:r,exy:o,eyx:s,eyy:i}=t;return [e+r,n+o,e,n,e+s,n+i,e+r+s,n+o+i]}function Jg(t){return {ax:t.ax+t.eyx,ay:t.ay+t.eyy,exx:t.exx,exy:t.exy,eyx:-t.eyx,eyy:-t.eyy}}function fr(t,e=false){let n=qg(e?Jg(t):t);t.halfXRect&&(n[4]--,n[6]--);let r=new St;return r.moveTo(n[0],n[1]),r.lineTo(n[2],n[3]),r.lineTo(n[4],n[5]),r.lineTo(n[6],n[7]),r.closeFigure(),r}function Yo(t,e=false){let n=new St;return n.addBeziers(pn(t,e),true),n.closeFigure(),n.figures[0].roundWiden=true,n}function Db(t,e,n,r,o){return Re(t)?(s,i)=>[s,i]:(s,i)=>{let a=r!==0?(s-e)/r:0,u=o!==0?(i-n)/o:0;return [Math.round(t.ax+t.exx*a+t.eyx*u),Math.round(t.ay+t.exy*a+t.eyy*u)]}}function Fb(t){if(Re(t)){let r=t.ax,o=t.ax+t.exx,s=t.ay,i=t.ay+t.eyy;return {l:Math.min(r,o),t:Math.min(s,i),r:Math.max(r,o),b:Math.max(s,i)}}let e=Math.round(Math.hypot(t.exx,t.exy)),n=Math.round(Math.hypot(t.eyx,t.eyy));return {l:0,t:0,r:e,b:n}}function dl(t,e,n,r=false,o=false){let s=Fb(t),i=Re(t)&&t.exx<0,a=Re(t)&&t.eyy<0,u=r!==a,l=Im(s.l,s.t,s.r,s.b,e,n,o,u,i,Re(t)?t.cornerRatio:void 0),c=Db(t,s.l,s.t,s.r-s.l,s.b-s.t),f=[];for(let m=0;m<l.length;m+=2)f.push(...c(l[m],u?s.t+s.b-l[m+1]:l[m+1]));if(t.halfX)if(t.halfXCompat||!u){let m=(s.t+s.b)/2,b=(s.b-s.t)/2||1;for(let h=0;h<16;h++){let p=(m-f[2*h+1])/b;f[2*h]+=h>=8?Math.round(1+p):Math.ceil(p-.5);}}else {let m=t.cornerExact!==void 0&&t.cornerExact[1]*2>=Math.abs(t.eyy)-1e-9;for(let b of m?[1,2,3,4,5,6,8,15]:[0,1,2,3,4,5,6,7])f[2*b]++;}if(t.cornerExact&&Re(t)){let m=s.r-s.l,b=s.b-s.t;if(m>=0&&b>=0){let h=m===0?0:Math.round(t.cornerExact[0]*(i?m-m%2:m+m%2)/m/2),p=b===0?0:Math.round(t.cornerExact[1]*(u?b+b%2:b-b%2)/b/2),d=i?Math.floor(Ie*h):Math.ceil(Ie*h),x=u?Math.ceil(Ie*p):Math.floor(Ie*p),y=(M,P,E)=>{P!==null&&(f[2*M]=P),f[2*M+1]=u?s.t+s.b-E:E;},g=t.halfX?1:0;y(0,null,s.t+p),y(1,null,s.t+p-x),y(2,s.r+g-h+d,s.t),y(3,s.r+g-h,s.t),y(4,s.l+g+h,s.t),y(5,s.l+g+h-d,s.t),y(6,null,s.t+p-x),y(7,null,s.t+p),y(8,null,s.b-p),y(9,null,s.b-p+x),y(10,s.l+h-d,s.b),y(11,s.l+h,s.b),y(12,s.r-h,s.b),y(13,s.r-h+d,s.b),y(14,null,s.b-p+x),y(15,null,s.b-p);}}if(i)for(let m=0;m<f.length;m+=2)f[m]=s.l+s.r-f[m];return f}function ki(t,e,n,r=false,o=false,s=false){if(o)return fr(t,r);let i=dl(t,e,n,r,s),a=new St;for(let u=0;u<4;u++){let l=u*8;a.addBeziers(i.slice(l,l+8),u===0);}return a.closeFigure(),a}function to(t,e,n,r,o,s,i=new St,a){let u=Fb(t),l=Db(t,u.l,u.t,u.r-u.l,u.b-u.t),c=e[0],f=e[1],m=n[0],b=n[1],h=r;if(Re(t))a?(h=r!==a.y,a.x&&(c=u.l+u.r-c,m=u.l+u.r-m)):t.exx<0!=t.eyy<0&&(h=!h);else {let y=t.exx*t.eyy-t.exy*t.eyx||1,g=(M,P)=>{let E=M-t.ax,R=P-t.ay,T=(E*t.eyy-R*t.eyx)/y,A=(t.exx*R-t.exy*E)/y;return [u.l+T*(u.r-u.l),u.t+A*(u.b-u.t)]};[c,f]=g(c,f),[m,b]=g(m,b),y<0&&(h=!h);}let p=!!a?.x&&Re(t),d=Um(u.l,u.t,u.r,u.b,c,f,m,b,h,!!t.halfX,!!t.framed,p),x=[];for(let y=0;y<d.length;y+=2)x.push(...l(d[y],d[y+1]));if(o==="arcto"&&s?(i.continueAt(s[0],s[1]),i.addBeziers(x,false)):i.addBeziers(x,true),o==="pie"){let y=u.r-u.l,g=u.b-u.t,[M,P]=l(u.l+Math.ceil(y/2)+(t.halfX&&!p?1:0),u.t+Math.ceil(g/2));i.lineTo(M,P);}return (o==="pie"||o==="chord")&&i.closeFigure(),{path:i,end:[x[x.length-2],x[x.length-1]]}}var kb=5,Kg=65536;function Bi(t){let e=yt(t),n=Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2])),r=t.wholeDevicePixels;return r?Math.round(t.state.penWidth*n/r[0])*r[0]:t.state.penWidth*n}function xe(t){return ((t.state.penFlags??t.state.penStyle)&Kg)===0&&t.state.penExtended?true:Math.round(Bi(t)/(t.wholeDevicePixels?.[0]??1))<=1}function xl(t){return (t.state.penStyle&15)!==kb}function yl(t,e={}){let{state:n}=t,r=n.penFlags??n.penStyle,o=yt(t),s=t.wholeDevicePixels&&(r&15)===6?n.penWidth*Math.sqrt(Math.abs(o[0]*o[3]-o[1]*o[2])):Bi(t),i=r&3840,a=r&61440,u=!t.wholeDevicePixels&&n.penWidth*Math.abs(o[0])*16>=1&&n.penWidth*Math.abs(o[3])*16>=1&&Math.abs(o[1])<1e-6&&Math.abs(o[2])<1e-6&&Math.abs(Math.abs(o[0])-Math.abs(o[3]))>1e-6,l=o[0]*o[3]-o[1]*o[2],c=Math.abs(o[1])>=1e-6||Math.abs(o[2])>=1e-6,f=Math.abs(o[0])<1e-9&&Math.abs(o[3])<1e-9,m=!t.wholeDevicePixels&&(c&&!f||u&&o[0]<0)&&Math.abs(l)>1e-9&&n.penWidth*Math.sqrt(Math.abs(l))*16>=1,b=Math.abs(o[1])<1e-6&&Math.abs(o[2])<1e-6,h=!t.wholeDevicePixels&&b&&(Math.abs(Math.abs(o[0])-1)>1e-6||Math.abs(Math.abs(o[3])-1)>1e-6),p=n.penExtended?u||m||h?yo(r,n.penWidth,n.penUserStyle,1):yo(r,s,n.penUserStyle,s/(n.penWidth||1)):null,d=(u||h)&&!m&&p?[Math.abs(o[0]),Math.abs(o[3])]:void 0;if(m)return {width:Math.round(n.penWidth*16),matrix:[o[0],o[1],o[2],o[3]],deviceNib:true,cap:e.roundPen||!n.penExtended||i===0?"round":i===256?"square":"flat",join:e.roundPen?"round":e.rectangle&&!n.penExtended?"miter":!n.penExtended||a===0?"round":a===4096?"bevel":"miter",miterLimit:n.miterLimit??10,dashes:p?p.map(y=>y*16):null,shortenDashes:(r&15)!==7,cutToLogicalUnits:!p};let x=h&&!u&&n.penExtended&&(r&15)!==6;return {width:Math.round((u?n.penWidth*Math.abs(o[0]):s)*16),...u?{height:Math.round(n.penWidth*Math.abs(o[3])*16)}:{},cap:e.roundPen||!n.penExtended||i===0?"round":i===256?"square":"flat",join:e.roundPen?"round":e.rectangle&&!n.penExtended?"miter":!n.penExtended||a===0?"round":a===4096?"bevel":"miter",miterLimit:n.miterLimit??10,dashes:p?p.map(y=>y*16):null,...d?{dashMetric:d}:{},shortenDashes:(r&15)!==7,wholePixelDashVectors:Math.abs(o[0]-1)<1e-6&&Math.abs(o[3]-1)<1e-6&&Math.abs(o[1])<1e-6&&Math.abs(o[2])<1e-6,...h?{cutToLogicalUnits:true,logicalScale:u?[Math.abs(o[0]),Math.abs(o[3])]:Math.abs(o[0]),...x?{capWidth:n.penWidth*Math.abs(o[0])*16}:{}}:{}}}function Zg(t){let e=new Uint8Array(64);for(let n=0;n<8;n++)for(let r=0;r<8;r++)e[n*8+r]=wr(t,r,n)?0:1;return e}function Je(t){let e=Qt(t.state);if(e.kind==="none")return null;if(e.kind==="solid")return {kind:"solid",rgb:e.rgb};let n=t.sx||1,r=t.sy||1,{bounds:o,state:s}=t;return {kind:"tile",tile:e,toDevice:(i,a)=>[Math.floor(o.left+(i+.5)/n),Math.floor(o.top+(a+.5)/r)],orgX:s.brushOrgX,orgY:s.brushOrgY,...s.bkMode===1&&s.brushPattern?.kind==="hatch"?{skip:Zg(s.brushPattern.hatch)}:{}}}function Qg(t){if(!t.figures.some(n=>n.tangents))return t;let e=new St;return e.figures=t.figures.map(n=>({pts:n.pts,closed:n.closed,roundWiden:n.roundWiden})),e}function Fi(t,e,n=false){if(!t.wmfLayoutRtl||n)return e;let r=Math.round(16*(t.wholeDevicePixels?.[0]??1)),o=new St;return o.figures=e.figures.map(s=>({...s,pts:s.pts.map((i,a)=>a%2===0?i-r:i)})),o}function Bb(t,e,n){e=Fi(t,e,n.rectangle||n.roundPen);let{ctx:r,state:o}=t,s=!!n.filled;if(n.fill){let c=Je(t);if(c){s=true;let f=n.fillPath?Fi(t,n.fillPath,n.rectangle||n.roundPen):e,m=Ir(f,!!n.winding);se(t,m,c,o.rop2);}}if(!n.stroke||o.penStyle===kb)return true;if(!xe(t)){if(!xl(t))return false;let c=Ho(s?Qg(e):e,yl(t,n));return se(t,Kn(c,true),{kind:"solid",rgb:pl(o.penColor)},o.rop2),true}let i=Sr(o.penFlags??o.penStyle,o.penUserStyle),a=new zt,l=i!==null&&o.bkMode===2&&Es(o.penFlags??o.penStyle)?new zt:null;return Ps(e,a,l,i,n.style??{pos:0}),l&&se(t,l,{kind:"solid",rgb:pl(o.bkColor)},o.rop2),se(t,a,{kind:"solid",rgb:pl(o.penColor)},o.rop2),true}var gl=.5-1/32;function Ml(t,e){return e===0?t:n=>{n.save(),n.translate(e,e),t(n),n.restore();}}function El(t){return t.gdiAntialias===false}function tM(t,e,n){let{ctx:r,bounds:o,state:s}=t,i=Qt(s);if(i.kind!=="tile")return false;let a=t.sx||1,u=t.sy||1,l=Zr(s.rop2)??240,c=s.bkMode===1&&s.brushPattern?.kind==="hatch"?s.brushPattern.hatch:-1,f=(x,y)=>c>=0&&!wr(c,((x-s.brushOrgX)%8+8)%8,((y-s.brushOrgY)%8+8)%8);let m=Tn(r);if(!m||typeof r.isPointInPath!="function")return false;if(l===170)return true;let b=n?ul(n,1,m):{x:0,y:0,w:m.w,h:m.h};if(!b)return true;let h=.5-gl,p=(x,y)=>qn(i,Math.floor(o.left+(x+.5)/a),Math.floor(o.top+(y+.5)/u),s.brushOrgX,s.brushOrgY),d=he(s.rop2);return Qr(r,b,(x,y,g)=>{if(!r.isPointInPath(x+h,y+h,e)||c>=0&&f(Math.floor(o.left+(x+.5)/a),Math.floor(o.top+(y+.5)/u)))return -1;let M=p(x,y);return l===240?M:Vt(l,M,g,g)},(x,y)=>({color:al(p(x,y),d.colorTransform),mode:d.gco}))}function eM(t,e,n="nonzero",r){let{ctx:o,state:s}=t;if(s.brushStyle===1)return;let i=r??e;if(Qt(s).kind==="tile"){r&&r(o);let l=tM(t,n,i);if(r&&e(o),l)return}else {let l=he(s.rop2);if((El(t)||!l.exact&&Yn(s.rop2))&&ll(o,s.rop2,s.brushColor,f=>{Ml(i,gl)(f),f.fill(n);},1,n))return}let a=jt(t)?gl:0,u=a!==0||r!==void 0;u&&Ml(i,a)(o),Ur(o,s),o.fill(n),u&&e(o);}var $o=5;function br(t,e=1){return Math.max(t.penWidth*e,1)}function $n(t){let e=yt(t);return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))||1}function hr(t,e=1){if(t.penStyle===$o)return 0;let n=br(t,e);return Number.isInteger(n)&&n%2===1?.5:0}function Gb(t,e){let{state:n}=e,r=$n(e),o=br(n,r),s=n.penFlags??n.penStyle;t.lineWidth=o;let i=xe(e);if(!i&&n.penExtended){let a=s&3840,u=s&61440;t.lineCap=a===256?"square":a===512?"butt":"round",t.lineJoin=u===4096?"bevel":u===8192?"miter":"round",t.miterLimit=n.miterLimit??10,t.setLineDash(yo(s,o,n.penUserStyle,r)??[]);}else i?(t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.setLineDash([])):(t.lineCap="round",t.lineJoin="round",t.setLineDash([]));}function nM(t){let{state:e}=t;return e.penStyle===$o||!xe(t)?null:Sr(e.penFlags??e.penStyle,e.penUserStyle)}function rM(t,e,n,r){let{ctx:o,state:s}=t,i=s.penFlags??s.penStyle,a=n.reduce((m,b)=>m+b,0),u=he(s.rop2),l=s.bkMode===2&&Es(i),c=[];e.figures.forEach((m,b)=>{b>0&&(r.pos=0);let h=m.closed?[...m.pts,m.pts[0],m.pts[1]]:m.pts;for(let p=0;p+3<h.length;p+=2){let d=0;gs(h[p],h[p+1],h[p+2],h[p+3],()=>{d++;}),d!==0&&(c.push([h[p],h[p+1],h[p+2],h[p+3],r.pos,d]),r.pos+=d);}});let f=m=>m/16+.5;o.save();try{o.globalCompositeOperation=u.gco,o.lineWidth=1,o.lineCap="butt";for(let m of l?["bk","fg"]:["fg"]){o.strokeStyle=vr(m==="bk"?s.bkColor:s.penColor,u.colorTransform);for(let[b,h,p,d,x,y]of c){let g=Math.hypot(p-b,d-h)/16/y;m==="fg"?(o.setLineDash(n.map(M=>M*g)),o.lineDashOffset=x%a*g):o.setLineDash([]),o.beginPath(),o.moveTo(f(b),f(h)),o.lineTo(f(p),f(d)),o.stroke();}}}finally{o.setLineDash([]),o.lineDashOffset=0,o.restore();}}function oM(t,e){let{ctx:n,state:r}=t,o=$n(t),s=hr(r,o),i=Ml(e,s),a=he(r.rop2);r.penStyle!==$o&&(El(t)||!a.exact&&Yn(r.rop2))&&ll(n,r.rop2,r.penColor,l=>{Gb(l,t),i(l),l.stroke();},br(r,o)/2+2)||(s!==0&&i(n),Cr(n,r),r.penStyle!==$o&&Gb(n,t),n.stroke());}function Jt(t,e){let{ctx:n,state:r}=t,o=El(t),s=!he(r.rop2).exact&&Yn(r.rop2),i=r.penStyle===$o,a=!i&&xe(t),u=null,l=()=>(u??(u=e.raster()),u),c=false,f=()=>{c||(e.build(n),c=true);},m=e.fillRule??"nonzero";if(e.fill&&r.brushStyle!==1){let h=Qt(r).kind==="tile";if(o||h||s){let p=Je(t);if(p){let d=Fi(t,l(),e.rectangle||e.roundPen),x=Ir(d,m==="nonzero");e.axisRect&&e.stroke&&a&&(x=sM(x,l())),se(t,x,p,r.rop2);}}else {f();let p=e.axisRect&&e.stroke&&!i?e.axisRect.interior:void 0;eM(t,e.build,m,p);}}if(!e.stroke||i)return;if((a||xl(t))&&(o||s)){Bb(t,l(),{fill:false,stroke:true,style:e.style,rectangle:e.rectangle,roundPen:e.roundPen,filled:!!e.fill&&r.brushStyle!==1});return}let b=nM(t);if(b&&!o&&!s){rM(t,l(),b,e.style??{pos:0});return}Nt(t),f(),oM(t,e.build);}function sM(t,e){let n=new zt;Ps(e,n,null,null);let r=new Map,o=n.data;for(let a=0;a<n.length*3;a+=3){let u=r.get(o[a]);u||(u=[],r.set(o[a],u)),u.push([o[a+1],o[a+2]]);}let s=new zt,i=t.data;for(let a=0;a<t.length*3;a+=3){let u=i[a],l=(r.get(u)??[]).slice().sort((m,b)=>m[0]-b[0]),c=i[a+1],f=i[a+2];for(let[m,b]of l)b<=c||m>=f||(s.add(u,c,Math.min(m,f)),c=Math.max(c,b));s.add(u,c,f);}return s}function Ob(t,e){let n=t.boundary.length;if(n<3||t.boundaryArgb.length<n||t.boundaryArgb.every(l=>l===t.boundaryArgb[0]))return null;let r=Bn(e,t.center.x,t.center.y),o=xn(t.centerArgb),s=t.boundary.map(l=>Bn(e,l.x,l.y)),i=Gs(t.preset),a=i?{preset:i}:{adjust:Bs(t.blend)??void 0},u=[];for(let l=0;l<n;l++){let c=(l+1)%n;t.boundary[l].x===t.boundary[c].x&&t.boundary[l].y===t.boundary[c].y||u.push(new ks([r[0],r[1],s[l][0],s[l][1],s[c][0],s[c][1]],[o,xn(t.boundaryArgb[l]),xn(t.boundaryArgb[c])],a));}return {triangles:u}}function Nb(t,e,n,r,o,s=false){let i=null;for(let a of t.triangles){let u=a.row(n,r,o);if(!u||e<u.xl||e>=u.xl+u.n)continue;let l=(e-u.xl)*4;i=Po(u.argb[l],u.argb[l+1],u.argb[l+2],u.argb[l+3],s);}return i}var Rl=[1,0,0,1,0,0],Tl=16*1024*1024,iM=1e-4;function Ke(t){let e=t[0]*t[3]-t[1]*t[2];if(!Number.isFinite(e)||Math.abs(e)<1e-12)return null;let n=t[3]/e,r=-t[1]/e,o=-t[2]/e,s=t[0]/e;return [n,r,o,s,-(n*t[4]+o*t[5]),-(r*t[4]+s*t[5])]}function aM(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}function uM(t,e,n=false){let{width:r,height:o,rgba:s,wrapMode:i}=t;if(r<=0||o<=0)return null;let a=ii(Xt(e,t.transform??Rl),n);return a?(u,l,c,f,m,b)=>{E0(a,r,o,s,i,u,l,c,f,m,b);}:null}function lM(t){if(t.length<3)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of t)e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),o=Math.max(o,s.y);return r>e&&o>n?{x:e,y:n,w:r-e,h:o-n}:null}function Wb(t,e,n,r,o){let s=t-e,i=Math.floor(s/n),a=s-i*n;return r&&(i%2+2)%2===1?e+n-o-a:e+a}function cM(t,e){let n=1/0,r=1/0,o=-1/0,s=-1/0;for(let[i,a]of [[t.x,t.y],[t.x+t.w,t.y],[t.x,t.y+t.h],[t.x+t.w,t.y+t.h]]){let u=e[0]*i+e[2]*a+e[4],l=e[1]*i+e[3]*a+e[5];n=Math.min(n,u),r=Math.min(r,l),o=Math.max(o,u),s=Math.max(s,l);}return [Math.floor(n+.5),Math.floor(r+.5),Math.floor(o+.5),Math.floor(s+.5)]}function Pl(t,e){let n=1/0,r=1/0,o=-1/0,s=-1/0;for(let i of t){let a=e[0]*i.x+e[2]*i.y+e[4],u=e[1]*i.x+e[3]*i.y+e[5];n=Math.min(n,a),r=Math.min(r,u),o=Math.max(o,a),s=Math.max(s,u);}return [n,r,o,s].every(i=>Math.abs(i-Math.round(i))<1e-6)}var Gi=2048;function Oi(t,e,n){if(!n)return (t%e+e)%e;let r=(t%(2*e)+2*e)%(2*e);return r<e?r:2*e-1-r}function mM(t,e,n){let r=t.points.map(i=>e({x:n[0]*i.x+n[2]*i.y+n[4],y:n[1]*i.x+n[3]*i.y+n[5]})),o=[];for(let i=0;i<r.length;i++)if((t.types[i]&7)===3&&i>0&&i+2<r.length){let a=r.slice(i-1,i+3).flatMap(l=>[rn(l.x),rn(l.y)]);o[o.length-1]={x:a[0]/16,y:a[1]/16};let u=[];Ne(a,u);for(let l=0;l<u.length;l+=2)o.push({x:u[l]/16,y:u[l+1]/16});i+=2;}else o.push(r[i]);let s=o.length;return s>1&&o[0].x===o[s-1].x&&o[0].y===o[s-1].y&&o.pop(),o}function fM(t,e,n){if(Math.abs(n[1])>1e-9||Math.abs(n[2])>1e-9||n[0]<=0||n[3]<=0||!t.boundaryArgb.every(y=>y===t.boundaryArgb[0]))return null;let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let y of t.source?t.source.points:t.boundary){let g=n[0]*y.x+n[4],M=n[3]*y.y+n[5];r=Math.min(r,g),o=Math.min(o,M),s=Math.max(s,g),i=Math.max(i,M);}let a=y=>Math.floor(y+.5),u=a(s)-a(r),l=a(i)-a(o);if(!(s>r)||!(i>o)||u<1||l<1||u*l>4*1024*1024)return null;let c=u/(s-r),f=l/(i-o),m=y=>({x:(n[0]*y.x+n[4]-r)*c,y:(n[3]*y.y+n[5]-o)*f}),b=Xb({...t,boundary:t.source?mM(t.source,m,n):t.boundary.map(m),source:void 0,center:m(t.center),transform:null},"clamp",Rl,false,true);if(!b)return null;let h=e==="tile-flip-x"||e==="tile-flip-xy",p=e==="tile-flip-y"||e==="tile-flip-xy",d=null,x=()=>{if(d)return d;let y=new Uint8ClampedArray(u*l*4);b(0,0,u,l,y),d=new Float64Array(u*l*4);for(let g=0;g<u*l;g++){let M=y[g*4+3];d[g*4]=Math.floor(y[g*4]*M/255+.5),d[g*4+1]=Math.floor(y[g*4+1]*M/255+.5),d[g*4+2]=Math.floor(y[g*4+2]*M/255+.5),d[g*4+3]=M;}return d};return (y,g,M,P,E)=>{let R=x();for(let T=0;T<P;T++){let A=f*(g+T-o),w=Math.floor(A),I=Math.floor((A-w)*Gi+.5)/Gi,S=Oi(w,l,p)*u,v=Oi(w+1,l,p)*u;for(let C=0;C<M;C++){let U=c*(y+C-r),D=Math.floor(U),L=Math.floor((U-D)*Gi+.5)/Gi,F=Oi(D,u,h),B=Oi(D+1,u,h),X=(T*M+C)*4,k=q=>(1-L)*(1-I)*R[(S+F)*4+q]+L*(1-I)*R[(S+B)*4+q]+(1-L)*I*R[(v+F)*4+q]+L*I*R[(v+B)*4+q],W=k(3),O=Math.floor(W+.5);if(O<=0){E[X]=E[X+1]=E[X+2]=E[X+3]=0;continue}for(let q=0;q<3;q++){let Q=Math.floor(k(q)+.5);E[X+q]=Math.min(255,W>=255?Q:Math.floor(Q*255/O+.5));}E[X+3]=O;}}}}function Xb(t,e,n,r=true,o=false){let s=lM(t.boundary),i=Xt(n,t.transform??Rl),a=Ke(i);if(!s||!a)return null;if(e!=="clamp"&&!Pl(t.boundary,i)){let P=fM(t,e,i);if(P)return P}let c=!t.boundaryArgb.every(P=>P===t.boundaryArgb[0])||e!=="clamp"&&!Pl(t.boundary,i)?0:Zm(t.boundary,i),f=e==="clamp"||Pl(t.boundary,i)?Ob(t,i):null,m=c>0?Hm(t,i):null,b=Math.hypot(i[0],i[1]),h=Math.hypot(i[2],i[3]),p=b>0?1/b:0,d=h>0?1/h:0,x=e==="tile-flip-x"||e==="tile-flip-xy",y=e==="tile-flip-y"||e==="tile-flip-xy",g=e==="clamp"?iM:0,M=e==="clamp"?null:cM(s,i);return (P,E,R,T,A,w)=>{let I=M!==null&&P>=M[0]&&P+R<=M[2]&&E>=M[1]&&E+T<=M[3],S=M&&!I?M[0]:P,v=M&&!I?M[2]:P+R,C=o||M!==null&&!I,U=w!==void 0&&!(M&&!I);for(let D=0;D<T;D++){let L=E+D,F=-1;for(let B=0;B<R;B++){if(U&&w[D*R+B]&&B>=F){let V=B;for(;V>0&&w[D*R+V-1];)V--;for(F=B;F<R&&w[D*R+F];)F++;S=P+V,v=P+F;}let X=P+B+g,k=a[0]*X+a[2]*L+a[4],W=a[1]*X+a[3]*L+a[5];if(e!=="clamp"&&(k=Wb(k,s.x,s.w,x,p),W=Wb(W,s.y,s.h,y,d)),e==="clamp"&&W>=s.y+s.h&&!f&&!m)continue;let O=g?{x:k-a[0]*g,y:W-a[1]*g}:void 0,q=null,Q=false;if(f||m){let V=e==="clamp"?P+B:i[0]*k+i[2]*W+i[4],rt=e==="clamp"?L:i[1]*k+i[3]*W+i[5],H=Math.round(V),Y=Math.round(rt);if(Math.abs(V-H)<1e-6&&Math.abs(rt-Y)<1e-6){if(f)q=Nb(f,H,Y,S,v,C),q===null&&r&&(Q=true);else if(m){let N=m.colorAt(H,Y,S,v);N!==null?q=Po(N>>>24,N>>>16&255,N>>>8&255,N&255,C):r&&(Q=true);}}}if(q===null&&!Q)if(m){let V={s:NaN};if(Ws(t,k,W,O,V)!==null){let rt=m.colorForPosition(V.s);q=Po(rt>>>24,rt>>>16&255,rt>>>8&255,rt&255,C);}}else q=Ws(t,k,W,O);if(q===null)continue;let K=(D*R+B)*4;A[K]=q>>>16&255,A[K+1]=q>>>8&255,A[K+2]=q&255,A[K+3]=q>>>24&255;}}}}function no(t,e,n){if(e&32768)return null;let r=t.objectTable.get(n&255);return !r||r.kind!=="plus-brush"?null:Al(t,r)}function Al(t,e){let n=_t(t),r=t.baseTransform,o=r&&r[1]===0&&r[2]===0&&Number.isInteger(r[4])&&Number.isInteger(r[5])&&!t.ext?.tsDevice?{x:r[4],y:r[5]}:{x:0,y:0};if(e.hatch&&!At(t.ctx)){let s=Ke(yi(t));if(s)return J0(e.hatch,t.ext?.renderingOrigin??{x:0,y:0},s)}return e.texture?uM(e.texture,n,Ee(t.pixelOffsetMode??0)):e.gradient&&e.gradient.type==="radial"&&e.gradient.shape?Xb(e.gradient.shape,e.gradient.wrapMode,n):e.gradient&&e.gradient.type==="linear"&&!At(t.ctx)?((o.x!==0||o.y!==0)&&(n=[n[0],n[1],n[2],n[3],n[4]-o.x,n[5]-o.y]),zm(e.gradient,n,Ee(t.pixelOffsetMode??0),t.ext?.compositingMode===1,o)):null}function pr(t,e,n,r=0){if(!t||t.length===0)return {x:0,y:0,w:n.w,h:n.h};let o=1/0,s=1/0,i=-1/0,a=-1/0;for(let b of t){let h=e[0]*b.x+e[2]*b.y+e[4],p=e[1]*b.x+e[3]*b.y+e[5];o=Math.min(o,h),s=Math.min(s,p),i=Math.max(i,h),a=Math.max(a,p);}if(!Number.isFinite(o+s+i+a))return {x:0,y:0,w:n.w,h:n.h};let u=Math.ceil(Math.max(0,r))+1,l=Math.max(0,Math.floor(o)-u),c=Math.max(0,Math.floor(s)-u),f=Math.min(n.w,Math.ceil(i)+u),m=Math.min(n.h,Math.ceil(a)+u);return f>l&&m>c?{x:l,y:c,w:f-l,h:m-c}:null}function An(t,e,n,r,o,s="nonzero"){let{ctx:i}=t,a=aM(i);if(!a||typeof i.clip!="function"||typeof i.drawImage!="function")return false;let u=Vo(t);if(u!=="canvas"){let b=wl(t,e,n);if(b&&hM(t,b,r,o,s,a,u))return true}let l=no(t,e,n);if(!l)return false;let c=pr(o,_t(t),a);if(!c)return true;if(c.w*c.h>Tl)return false;let f=It(c.w,c.h);if(!f)return false;let m=new Uint8ClampedArray(c.w*c.h*4);l(c.x,c.y,c.w,c.h,m),Ct(f.ctx,Et(m,c.w,c.h),0,0),i.save();try{pe(t),i.beginPath(),r(i),i.clip(s),i.setTransform(1,0,0,1,0,0),i.imageSmoothingEnabled=!1,i.drawImage.call(i,f.canvas,c.x,c.y);}finally{i.restore();}return true}function jo(t,e,n,r,o="canvas",s,i=true){let a=o===true?"aliased":o===false?"canvas":o,u=a==="aliased",l=a==="gdiplus-aa",{ctx:c}=t;if(typeof c.drawImage!="function"||n.w*n.h>Tl)return false;let f=It(n.w,n.h),m=It(n.w,n.h);if(!f||!m||typeof f.ctx.getImageData!="function")return false;let b=_t(t),h=f.ctx,p=u?bM(t):i?Vu(t):0;h.setTransform(b[0],b[1],b[2],b[3],b[4]-n.x+p,b[5]-n.y+p),h.fillStyle="#000",h.strokeStyle="#000",r(a!=="canvas"?Df(h,b):h);let d=Tt(h,0,0,n.w,n.h).data;if(l&&s&&typeof h.isPointInPath=="function")for(let y=3;y<d.length;y+=4){let g=d[y];if(g===0||g===255)continue;let M=(y-3)/4,P=M%n.w,E=Math.floor(M/n.w),R=0;for(let T=0;T<4;T++)for(let A=0;A<8;A++)s(h,P+A/8+Hb,E+T/4+Hb)&&R++;d[y]=Math.round(R*255/32);}if(u){let y=s&&typeof h.isPointInPath=="function"?s:null;for(let g=3;g<d.length;g+=4){let M=d[g];if(!(M===0||M===255))if(y){let P=(g-3)/4,E=P%n.w+.5,R=Math.floor(P/n.w)+.5;d[g]=y(h,E,R)?255:0;}else d[g]=M>=128?255:0;}}let x=new Uint8ClampedArray(n.w*n.h*4);e(n.x,n.y,n.w,n.h,x);for(let y=3;y<x.length;y+=4)x[y]=(x[y]*d[y]+127)/255;Ct(m.ctx,Et(x,n.w,n.h),0,0),c.save();try{c.setTransform(1,0,0,1,0,0),c.imageSmoothingEnabled=!1,c.drawImage.call(c,m.canvas,n.x,n.y);}finally{c.restore();}return true}function bM(t){return (Ee(t.pixelOffsetMode??0)?0:.5)-1/32}var Hb=1/1024;function Vo(t){return t.gdiAntialias===true||At(t.ctx)?"canvas":t.antiAlias?"gdiplus-aa":"aliased"}function eo(t){let e=t>>>24&255,n=t>>>16&255,r=t>>>8&255,o=t&255;return (s,i,a,u,l)=>{for(let c=0;c<a*u*4;c+=4)l[c]=n,l[c+1]=r,l[c+2]=o,l[c+3]=e;}}function ro(t){let e=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(t);if(e){let r=e[4]===void 0?1:Number(e[4]),o=s=>Math.min(255,Math.max(0,Math.round(Number(s))));return (Math.round(Math.min(1,Math.max(0,r))*255)<<24|o(e[1])<<16|o(e[2])<<8|o(e[3]))>>>0}let n=/^#([0-9a-f]{6})$/i.exec(t);return n?(4278190080|parseInt(n[1],16))>>>0:null}function wl(t,e,n){if(e&32768)return eo(n>>>0);let r=no(t,e,n);if(r)return r;let o=t.objectTable.get(n&255),s=o&&o.kind==="plus-brush"?ro(o.color):null;return s===null?null:eo(s)}function hM(t,e,n,r,o,s,i){let a=_t(t),u=null;try{u=Hf(n,a,i==="aliased");}catch{u=null;}if(u){let c=So(u,s);if(!c)return true;if(c.w*c.h<=Tl){let f=Ee(t.pixelOffsetMode??0),m=ne(u,o==="evenodd",i==="gdiplus-aa",f,c);return jn(t,e,c,m,1,true)}}let l=pr(r,a,s);return l?jo(t,e,l,c=>{c.beginPath(),n(c),c.fill(o);},i,(c,f,m)=>c.isPointInPath(f,m,o)):true}function pM(t,e,n){let r=true;for(let o=0;o<n.length;o++){let s=o*4,i=n[o],a=t[s+3];if(i===0||a===0){t[s+3]=0;continue}if(e[s+3]!==255){t[s+3]=(a*i+127)/255,r=false;continue}let u=i===255?32:Math.round(i*32/255),l=Math.round(a*u/32);for(let c=0;c<3;c++){let f=Math.round(t[s+c]*a/255);t[s+c]=Math.min(255,Math.round(f*u/32)+Math.round(e[s+c]*(255-l)/255));}t[s+3]=255;}return r}function dM(t,e,n,r=null){for(let o=0;o<n.length;o++){let s=o*4,i=n[o];if(i===0)t[s+3]=0;else if(i!==255){let a=Math.round(i*32/255),u=t[s+3],l=Math.round(u*a/32);if(l>0&&l<255)for(let c=0;c<3;c++){let f=r?r[s+c]:Math.round(t[s+c]*u/255);t[s+c]=ou(Math.round(f*a/32),l);}t[s+3]=l;}}return t}function xM(t,e,n,r){let{ctx:o}=t,s=It(e.w,e.h),i=It(e.w,e.h);if(!s||!i)return false;let a=new Uint8ClampedArray(e.w*e.h*4);for(let u=0;u<r.length;u++)a[u*4+3]=r[u]?255:0;Ct(s.ctx,Et(a,e.w,e.h),0,0),Ct(i.ctx,Et(n,e.w,e.h),0,0),o.save();try{o.setTransform(1,0,0,1,0,0),o.imageSmoothingEnabled=!1;let u=o.drawImage;o.globalCompositeOperation="destination-out",u.call(o,s.canvas,e.x,e.y),o.globalCompositeOperation="source-over",u.call(o,i.canvas,e.x,e.y);}finally{o.restore();}return true}function yM(t){let e=new Uint8Array(256),n=new Uint8Array(256);for(let r=0;r<256;r++)e[r]=Math.round(255*Math.pow(r/255,t)),n[r]=Math.round(255*Math.pow(r/255,1/t));return {lin:e,inv:n}}function gM(t){let e=Math.round(t*6/255);return Math.abs(t-255*e/6)<=.51?e/6:t/255}function MM(t,e,n,r,o=1,s=false){if(e===0)return r;if(s)return n;let i=t.lin[r],a=t.lin[n];return t.inv[Math.min(255,Math.max(0,i+Math.round((a-i)*gM(e)*o)))]}function jn(t,e,n,r,o=1,s=false,i=1){let{ctx:a}=t,u=It(n.w,n.h);if(typeof a.drawImage!="function"||!u)return false;let l=new Uint8ClampedArray(n.w*n.h*4);if(e(n.x,n.y,n.w,n.h,l,o===1?r:void 0),o===1&&t.ext?.compositingMode===1&&typeof a.getImageData=="function"){let c=Tt(a,n.x,n.y,n.w,n.h).data,f=null;return e.premultiplied&&(f=new Uint8ClampedArray(n.w*n.h*4),e.premultiplied(n.x,n.y,n.w,n.h,f)),xM(t,n,dM(l,c,r,f),r)}if(o===1&&s&&typeof a.getImageData=="function"){let c=Tt(a,n.x,n.y,n.w,n.h).data;pM(l,c,r),Ct(u.ctx,Et(l,n.w,n.h),0,0),a.save();try{a.setTransform(1,0,0,1,0,0),a.imageSmoothingEnabled=!1,a.drawImage.call(a,u.canvas,n.x,n.y);}finally{a.restore();}return true}if(o===3){if(typeof a.getImageData!="function")return false;let c=Tt(a,n.x,n.y,n.w,n.h).data,f=yM(i);for(let m=0;m<n.w*n.h;m++){let b=m*4,h=l[b+3]/255,p=false,d=h===1&&r[m*3]===255&&r[m*3+1]===255&&r[m*3+2]===255;for(let x=0;x<3;x++){let y=r[m*3+x];y>0&&(p=true),l[b+x]=MM(f,y,l[b+x],c[b+x],h,d);}l[b+3]=p?255:0;}}else for(let c=3;c<l.length;c+=4)l[c]=(l[c]*r[(c-3)/4]+127)/255;Ct(u.ctx,Et(l,n.w,n.h),0,0),a.save();try{a.setTransform(1,0,0,1,0,0),a.imageSmoothingEnabled=!1,a.drawImage.call(a,u.canvas,n.x,n.y);}finally{a.restore();}return true}function IM(t){let{state:e}=t,r=!he(e.rop2).exact&&Yn(e.rop2),o=e.penStyle===5||(e.penStyle===0||e.penStyle===6)&&xe(t);return r||t.gdiAntialias===false||Qt(e).kind==="tile"||!o}function wn(t){return t.rasterPath??(t.rasterPath=new St),t.rasterPath}function Cl(t,e,n){let r=fr(e,n),o=r.figures[0].pts,s=ke(t);s.moveTo(o[0]/16,o[1]/16);for(let i=2;i<o.length;i+=2)s.lineTo(o[i]/16,o[i+1]/16);s.closePath(),wn(t).append(r);}function jb(t,e,n){let r=ke(t);r.moveTo(e[0]/16,e[1]/16);for(let o=n===6?2:0;o<e.length;o+=n){n===8&&o>0&&r.lineTo(e[o]/16,e[o+1]/16);let s=n===8?o+2:o;r.bezierCurveTo(e[s]/16,e[s+1]/16,e[s+2]/16,e[s+3]/16,e[s+4]/16,e[s+5]/16);}r.closePath();}function oo(t){let e=wn(t),[n,r]=In(t),o=e.figures.length;e.continueAt(n,r),e.figures.length!==o&&ke(t).moveTo(n/16,r/16);}function SM(t){return t.lineStyle??(t.lineStyle={pos:0}),t.lineStyle}function so(t){t.lineStyle={pos:0};}function In(t){let e=t.curFix,{state:n}=t;return e&&e.lx===n.curX&&e.ly===n.curY?[e.x,e.y]:dt(t,n.curX,n.curY)}function Ni(t,e,n,r,o){return Xo(t,Math.min(e,r),Math.min(n,o),Math.max(e,r),Math.max(n,o))}function Yb(t,e,n){let r=yt(t),o=n===0?Math.hypot(r[0],r[1]):Math.hypot(r[2],r[3]);return Math.round(Math.abs(e)*o*16)}var Vb=6;function Wi(t,e,n=false,r=false){if((t.state.penStyle&15)!==Vb||!Re(e)||jt(t))return null;let o=yt(t),s=Pn(t),i=Rn(t),a=Math.abs(t.state.penWidth*o[0])/s*16,u=Math.abs(t.state.penWidth*o[3])/i*16;if(Math.max(a,u)<24)return null;let l=Math.round(a),c=Math.round(u);if(Math.abs(e.exx)/s<l||Math.abs(e.eyy)/i<c)return null;let f=Math.floor(l/2),m=Math.ceil(l/2),b=Math.round((r?Math.floor(c/2):Math.ceil(c/2))*i);return {left:Math.round((n?m:f)*s),right:Math.round((n?f:m)*s),top:b,bottom:b,half:l%2===1&&!n,halfRect:l%2===1&&n}}function vM(t,e){if((t.state.penStyle&15)!==Vb||!Re(e)||jt(t))return false;let n=yt(t),r=Pn(t),o=Rn(t),s=Math.abs(t.state.penWidth*n[0])/r*16,i=Math.abs(t.state.penWidth*n[3])/o*16;return Math.max(s,i)<24?false:Math.abs(e.exx)/r<Math.round(s)||Math.abs(e.eyy)/o<Math.round(i)}function Hi(t,e){let n=t.exx<0?-1:1,r=t.eyy<0?-1:1,o={ax:t.ax+n*e.left,ay:t.ay+r*e.top,exx:t.exx-n*(e.left+e.right),exy:0,eyx:0,eyy:t.eyy-r*(e.top+e.bottom),framed:true};return e.half&&n>0&&(o.halfX=true),e.halfRect&&n>0&&(o.halfXRect=true),o}function CM(t,e,n,r,o,s,i,a){let u=BigInt(2*o-t-n),l=BigInt(2*s-e-r),c=BigInt(2*i-t-n),f=BigInt(2*a-e-r);return u*f===l*c&&u*c+l*f>0n}function UM(t,e,n){let{ctx:r,view:o}=t;if(n>=20){let s=o.getInt32(e,true),i=o.getInt32(e+4,true),a=gb(t.state,o,e+8),u=jt(t)?Lt(t,s,i):{x:Gt(t,s),y:Ot(t,i)};r.fillStyle=a,r.fillRect(u.x,u.y,1,1);}return true}function _M(t,e,n){let{view:r,state:o,inPath:s}=t;if(n>=16&&(o.curX=r.getInt32(e,true),o.curY=r.getInt32(e+4,true),so(t),t.curFix=void 0,s)){let i=jt(t)?Lt(t,o.curX,o.curY):{x:Gt(t,o.curX),y:Ot(t,o.curY)};ke(t).moveTo(i.x,i.y);let a=dt(t,o.curX,o.curY);wn(t).moveTo(a[0],a[1]);}return true}function LM(t,e,n){let{view:r,state:o,inPath:s}=t;if(n>=16){let i=r.getInt32(e,true),a=r.getInt32(e+4,true),u=jt(t),l=u?Lt(t,i,a):{x:Gt(t,i),y:Ot(t,a)},c=dt(t,i,a);if(s)oo(t),ke(t).lineTo(l.x,l.y),wn(t).lineTo(c[0],c[1]);else {let f=u?Lt(t,o.curX,o.curY):{x:Gt(t,o.curX),y:Ot(t,o.curY)},m=In(t);Jt(t,{build:b=>{b.beginPath(),b.moveTo(f.x,f.y),b.lineTo(l.x,l.y);},raster:()=>{let b=new St;return b.moveTo(m[0],m[1]),b.lineTo(c[0],c[1]),b},fill:false,stroke:true,style:SM(t)});}o.curX=i,o.curY=a;}return true}function DM(t,e){let{state:n}=t;if(t.inPath||n.penStyle===5||n.penStyle===6||e.exy!==0||e.eyx!==0||e.exx===0||e.eyy===0||!xe(t))return e;let r=Math.ceil(e.ax/16)*16,o=Math.ceil(e.ay/16)*16;return {...e,ax:r,ay:o,exx:Math.ceil((e.ax+e.exx)/16)*16-r,eyy:Math.ceil((e.ay+e.eyy)/16)*16-o}}function FM(t){if(!Re(t)||t.exx>=0&&t.eyy>=0)return t;let e=t.exx<0?t.ax+t.exx:t.ax,n=t.eyy<0?t.ay+t.eyy:t.ay;return {...t,ax:e,ay:n,exx:Math.abs(t.exx),eyy:Math.abs(t.eyy)}}function kM(t,e,n){let{ctx:r,view:o,state:s,inPath:i}=t;if(n>=24){let a=o.getInt32(e,true),u=o.getInt32(e+4,true),l=o.getInt32(e+8,true),c=o.getInt32(e+12,true),f=DM(t,Ni(t,a,u,l,c)),m=Wi(t,f,true,t.state.arcDirection===2),b=m?Hi(f,m):f,h=t.state.arcDirection===2;if(i||so(t),jt(t)){let M=Lt(t,a,u),P=Lt(t,l,u),E=Lt(t,l,c),R=Lt(t,a,c),T=A=>{A.moveTo(M.x,M.y),A.lineTo(P.x,P.y),A.lineTo(E.x,E.y),A.lineTo(R.x,R.y),A.closePath();};return i?Cl(t,b,h):Jt(t,{build:A=>{A.beginPath(),T(A);},raster:()=>fr(b,h),rectangle:true,fill:true,stroke:true,axisRect:Re(b)?{}:void 0}),true}let d=Gt(t,a),x=Ot(t,u),y=qt(t,l-a),g=oe(t,c-u);if(m&&(d=Math.min(b.ax,b.ax+b.exx)/16,x=Math.min(b.ay,b.ay+b.eyy)/16,y=Math.abs(b.exx)/16,g=Math.abs(b.eyy)/16),i)Cl(t,b,h);else if(IM(t))Jt(t,{build:M=>{M.beginPath(),M.rect(d,x,y,g);},raster:()=>fr(xe(t)?FM(b):b,h),rectangle:true,fill:true,stroke:true,axisRect:{interior:BM(s,d,x,y,g,$n(t))}});else {Ur(r,s),r.fillRect(d,x,y,g),Cr(r,s),r.lineWidth=1;let M=hr(s,$n(t));r.strokeRect(d+M,x+M,y,g);}}return true}function BM(t,e,n,r,o,s=1){if(hr(t,s)===0||br(t,s)!==1)return;let i=Math.min(e,e+r),a=Math.min(n,n+o),u=Math.abs(r)-1,l=Math.abs(o)-1;if(!(u<=0||l<=0))return c=>{c.beginPath(),c.rect(i+1,a+1,u,l);}}var $b=.5522847498307936;function Il(t,e,n,r,o,s,i,a){let u=Math.min(e,r),l=Math.max(e,r),c=Math.min(n,o),f=Math.max(n,o),m=Math.min(Math.abs(s),(l-u)/2),b=Math.min(Math.abs(i),(f-c)/2);if(!a){if(m<=0||b<=0){t.rect(u,c,l-u,f-c);return}let g=Math.PI/2;t.moveTo(u+m,c),t.lineTo(l-m,c),t.ellipse(l-m,c+b,m,b,0,-g,0),t.lineTo(l,f-b),t.ellipse(l-m,f-b,m,b,0,0,g),t.lineTo(u+m,f),t.ellipse(u+m,f-b,m,b,0,g,2*g),t.lineTo(u,c+b),t.ellipse(u+m,c+b,m,b,0,2*g,3*g),t.closePath();return}let h=(g,M)=>{let P=a(g,M);t.moveTo(P.x,P.y);},p=(g,M)=>{let P=a(g,M);t.lineTo(P.x,P.y);},d=(g,M,P,E,R,T)=>{let A=a(g,M),w=a(P,E),I=a(R,T);t.bezierCurveTo(A.x,A.y,w.x,w.y,I.x,I.y);};if(m<=0||b<=0){h(u,c),p(l,c),p(l,f),p(u,f),t.closePath();return}let x=m*$b,y=b*$b;h(u+m,c),p(l-m,c),d(l-m+x,c,l,c+b-y,l,c+b),p(l,f-b),d(l,f-b+y,l-m+x,f,l-m,f),p(u+m,f),d(u+m-x,f,u,f-b+y,u,f-b),p(u,c+b),d(u,c+b-y,u+m-x,c,u+m,c),t.closePath();}function GM(t,e,n){let{view:r,inPath:o}=t;if(n>=32){let s=r.getInt32(e,true),i=r.getInt32(e+4,true),a=r.getInt32(e+8,true),u=r.getInt32(e+12,true),l=r.getInt32(e+16,true),c=r.getInt32(e+20,true),f=t.state.arcDirection===2,m=Ni(t,s,i,a,u),b=Wi(t,m,false,f),h=b?Hi(m,b):m,p=yt(t),d=b?Math.abs(l*p[0])*16:Yb(t,l,0),x=b?Math.abs(c*p[3])*16:Yb(t,c,1),y=(T,A,w)=>b&&A!==0?Math.floor(Math.min(T,A)*w/A):T,g=y(d,Math.abs((a-s)*p[0])*16,Math.abs(h.exx)),M=y(x,Math.abs((u-i)*p[3])*16,Math.abs(h.eyy)),P=b?h:Ll(t,s,i,a,u,true);!b&&P.exx!==m.exx&&Math.abs(m.exx)>0&&Math.abs(m.eyy)>0&&l!==0&&c!==0&&(g=Math.floor(Math.min(d,Math.abs(m.exx))*Math.abs(P.exx)/Math.abs(m.exx)),M=Math.floor(Math.min(x,Math.abs(m.eyy))*Math.abs(P.eyy)/Math.abs(m.eyy))),!b&&P.exx===m.exx&&P.eyy===m.eyy&&l!==0&&c!==0&&a!==s&&u!==i&&!jt(t)&&(P.cornerRatio=[Math.fround(Math.min(Math.abs(l),Math.abs(a-s))/Math.abs(a-s)),Math.fround(Math.min(Math.abs(c),Math.abs(u-i))/Math.abs(u-i))]);let E=b?T=>Il(T,Math.min(h.ax,h.ax+h.exx)/16,Math.min(h.ay,h.ay+h.eyy)/16,Math.max(h.ax,h.ax+h.exx)/16,Math.max(h.ay,h.ay+h.eyy)/16,g/32,M/32,null):jt(t)?T=>Il(T,s,i,a,u,l/2,c/2,(A,w)=>Lt(t,A,w)):T=>Il(T,Gt(t,s),Ot(t,i),Gt(t,a),Ot(t,u),qt(t,l)/2,oe(t,c)/2,null);if(b){let T=Math.abs((a-s)*p[0])*16,A=Math.abs((u-i)*p[3])*16;T>0&&A>0&&(h.cornerExact=[Math.min(d,T)*Math.abs(h.exx)/T,Math.min(x,A)*Math.abs(h.eyy)/A]);}let R=(T=h)=>ki(T,g,M,f,l===0||c===0);if(o){let T=P;l===0||c===0?Cl(t,T,f):(jb(t,dl(T,g,M,f),8),wn(t).append(R(T)));}else so(t),Jt(t,{build:T=>{T.beginPath(),E(T);},raster:()=>R(P),roundPen:true,fill:true,stroke:true});}return true}function Ll(t,e,n,r,o,s=false){let i=s?Ni(t,e,n,r,o):Xo(t,e,n,r,o);if(t.state.penStyle!==5)return i;let a=yt(t);if(a[1]!==0||a[2]!==0)return i;let l=i.ax%16===0&&i.ay%16===0&&i.exx%16===0&&i.eyy%16===0?4:0,c=l,f=i.exx<0?-1:1,m=i.eyy<0?-1:1;return {ax:i.ax-l*f,ay:i.ay-c*m,exx:i.exx+2*l*f,exy:0,eyx:0,eyy:i.eyy+2*c*m}}function OM(t,e,n){let{view:r,inPath:o}=t;if(n>=24){let s=r.getInt32(e,true),i=r.getInt32(e+4,true),a=r.getInt32(e+8,true),u=r.getInt32(e+12,true),l=t.state.arcDirection===2,c=Ni(t,s,i,a,u),f=Wi(t,c,false,t.state.arcDirection===2),m=f?Hi(c,f):c,b=f?{cx:(m.ax+m.exx/2)/16,cy:(m.ay+m.eyy/2)/16,rx:Math.abs(m.exx)/32,ry:Math.abs(m.eyy)/32,rotation:0}:jt(t)?Ai(t,(s+a)/2,(i+u)/2,Math.abs(a-s)/2,Math.abs(u-i)/2):{cx:Gt(t,(s+a)/2),cy:Ot(t,(i+u)/2),rx:Math.abs(qt(t,a-s))/2,ry:Math.abs(oe(t,u-i))/2,rotation:0};if(o){let h=m;jb(t,pn(h,l),6),wn(t).append(Yo(h,l));}else so(t),Jt(t,{build:h=>{h.beginPath(),h.ellipse(b.cx,b.cy,b.rx,b.ry,b.rotation,0,Math.PI*2);},raster:()=>Yo(f?m:Ll(t,s,i,a,u,true),l),roundPen:true,fill:true,stroke:true});}return true}function NM(t,e,n,r){let{ctx:o,view:s,state:i,inPath:a}=t;if(r>=40){let u=s.getInt32(n,true),l=s.getInt32(n+4,true),c=s.getInt32(n+8,true),f=s.getInt32(n+12,true),m=s.getInt32(n+16,true),b=s.getInt32(n+20,true),h=s.getInt32(n+24,true),p=s.getInt32(n+28,true),d=(u+c)/2,x=(l+f)/2,y=Math.abs(c-u)/2,g=Math.abs(f-l)/2,M=Math.atan2((b-x)/(g||1),(m-d)/(y||1)),P=i.arcDirection===2,E=e!==47&&y>0&&g>0&&CM(u,l,c,f,m,b,h,p),R=E?M+(P?2:-2)*Math.PI:Math.atan2((p-x)/(g||1),(h-d)/(y||1)),T=jt(t),A=Xo(t,u,l,c,f);if(e!==55&&vM(t,A))return true;let w=Wi(t,A,false,t.state.arcDirection===2),I=w?Hi(A,w):A,S=w?{cx:(I.ax+I.exx/2)/16,cy:(I.ay+I.eyy/2)/16,rx:Math.abs(I.exx)/32,ry:Math.abs(I.eyy)/32,rotation:0}:T?Ai(t,d,x,y,g):{cx:Gt(t,d),cy:Ot(t,x),rx:Math.abs(qt(t,y)),ry:Math.abs(oe(t,g)),rotation:0},v=e===55,C=e===47||e===46,U=T?Lt(t,d+y*Math.cos(M),x+g*Math.sin(M)):{x:S.cx+S.rx*Math.cos(M),y:S.cy+S.ry*Math.sin(M)},D=O=>{if(e===47?O.moveTo(S.cx,S.cy):!v&&a&&O.moveTo(U.x,U.y),v){if(!a){let q=In(t);O.moveTo(q[0]/16,q[1]/16);}O.lineTo(U.x,U.y);}O.ellipse(S.cx,S.cy,S.rx,S.ry,S.rotation,M,R,!P),C&&O.closePath();},L=v?"arcto":e===47?"pie":e===46?"chord":"arc",F=(O,q,Q)=>{let K=c-u,V=f-l;if(K===0||V===0)return dt(t,q,Q);let rt=(q-u)/K,H=(Q-l)/V;return [O.ax+O.exx*rt+O.eyx*H,O.ay+O.exy*rt+O.eyy*H]},B=yt(t),X=B[0]*B[3]-B[1]*B[2]<0,k=B[1]===0&&B[2]===0,W=(O=false)=>{let q=w?I:O&&C?Ll(t,u,l,c,f):A,Q=q.exx*q.eyy-q.exy*q.eyx<0,K=k&&Re(q)?{x:B[0]<0,y:B[3]<0}:void 0;return {box:q,mirror:K,clockwise:K?P:P!==(X!==Q),s:F(q,m,b),e:E?F(q,m,b):F(q,h,p),from:In(t)}};if(a){v&&oo(t),D(ke(t));let O=W();to(O.box,O.s,O.e,O.clockwise,L,O.from,wn(t),O.mirror),C&&wn(t).closeFigure();}else so(t),o.beginPath(),Jt(t,{build:O=>{O.beginPath(),D(O);},raster:()=>{let O=W(true);return to(O.box,O.s,O.e,O.clockwise,L,O.from,void 0,O.mirror).path},fill:C,stroke:true});if(v){let O=W(),q=to(O.box,O.s,O.e,O.clockwise,"arc",void 0,void 0,O.mirror).end,Q=Math.floor(q[0]/16),K=Math.floor(q[1]/16),V=Ke(yt(t));V?(i.curX=Math.round(V[0]*Q+V[2]*K+V[4]),i.curY=Math.round(V[1]*Q+V[3]*K+V[5])):(i.curX=Math.round(d+y*Math.cos(R)),i.curY=Math.round(x+g*Math.sin(R))),t.curFix=a?{x:q[0],y:q[1],lx:i.curX,ly:i.curY}:{x:Q*16,y:K*16,lx:i.curX,ly:i.curY};}}return true}function WM(t,e,n){let{view:r,state:o,inPath:s}=t;if(n<28)return true;let i=r.getInt32(e,true),a=r.getInt32(e+4,true),u=r.getUint32(e+8,true),l=r.getFloat32(e+12,true),c=r.getFloat32(e+16,true);if(!Number.isFinite(l)||!Number.isFinite(c)||u>2147483647)return true;let f=l*Math.PI/180,m=(l+c)*Math.PI/180,b=i+u*Math.cos(f),h=a-u*Math.sin(f),p=i+u*Math.cos(m),d=a-u*Math.sin(m),x=c<0,y=Math.min(8,Math.trunc(Math.abs(c)/360)),g=Xo(t,i-u,a-u,i+u,a+u),M;if(Re(g))M=vm(g,l,c);else {M=[...dt(t,i+u*Math.cos(f),a-u*Math.sin(f))];for(let v of ka(l,c)){let C=Sm(i,a,u,u,v.from,v.to);for(let U=0;U<6;U+=2)M.push(...dt(t,C[U],C[U+1]));}}let P=[M[M.length-2],M[M.length-1]],E=(v,C)=>{v.continueAt(C[0],C[1]),v.addBeziers(M,false);},R=Ai(t,i,a,u,u),T=Lt(t,b,h),A=v=>{if(v.lineTo(T.x,T.y),u===0)return;let C=Math.min(Math.abs(m-f),Math.PI*2*(y+1));v.ellipse(R.cx,R.cy,R.rx,R.ry,R.rotation,-f,x?-f+C:-f-C,!x);};if(s)oo(t),A(ke(t)),E(wn(t),In(t));else {so(t);let v=In(t),C=Lt(t,o.curX,o.curY);Jt(t,{build:U=>{U.beginPath(),U.moveTo(C.x,C.y),A(U);},raster:()=>{let U=new St;return E(U,v),U},fill:false,stroke:true});}let w=Math.floor(P[0]/16),I=Math.floor(P[1]/16),S=Ke(yt(t));return o.curX=Math.round(S?S[0]*w+S[2]*I+S[4]:p),o.curY=Math.round(S?S[1]*w+S[3]*I+S[5]:d),t.curFix=s?{x:P[0],y:P[1],lx:o.curX,ly:o.curY}:{x:w*16,y:I*16,lx:o.curX,ly:o.curY},true}function zb(t,e,n,r){switch(e){case 15:return UM(t,n,r);case 27:return _M(t,n,r);case 54:return LM(t,n,r);case 43:return kM(t,n,r);case 44:return GM(t,n,r);case 42:return OM(t,n,r);case 41:return WM(t,n,r);case 45:case 55:case 46:case 47:return NM(t,e,n,r);default:return false}}var qb={};var Jb={};var nh=1,rh=2,oh=24,HM={flags:0,illuminant:0,redGamma:1e4,greenGamma:1e4,blueGamma:1e4,referenceBlack:0,referenceWhite:1e4,contrast:0,brightness:0,colorfulness:0,redGreenTint:0},Kb=new Map;function sh(t){let e=Kb.get(t);if(e===void 0){let n=Jb[t];if(e=null,n){let r=Uint8Array.from(atob(n),s=>s.charCodeAt(0)),o=Ca(r);e=new Uint8Array(32768*3);for(let s=0;s<3;s++)for(let i=0;i<32768;i++){let a=i&31?e[(i-1)*3+s]:0;e[i*3+s]=a+o[s*32768+i]&255;}}Kb.set(t,e);}return e}var XM={1:[[1.64737,-0.59174,-0.05494],[.02963,.96126,.00881],[.2911,.40189,.30769]],2:[[1.22319,-0.17765,-0.04515],[.00275,.99054,.00645],[.05514,.12795,.81816]],3:[[1.02833,-0.01775,-0.01086],[.00861,.98431,.00728],[-0.01616,-0.0448,1.05995]],4:[[1.17271,-0.14059,-0.03174],[-474e-5,1.00266,.00183],[.05783,.14663,.79683]],5:[[1.10431,-0.08327,-0.02067],[-336e-5,1.0025,67e-5],[.03344,.09072,.87702]],7:[[.92515,.05628,.01822],[.00318,.9967,34e-5],[-0.02086,-0.06817,1.08783]],8:[[1.31275,-0.26259,-0.04977],[-244e-5,.99695,.00524],[.10854,.23443,.65827]]};function ih(t){return sh(t.illuminant)!==null}var dr=Array.from({length:32},(t,e)=>Math.round(e*255/31));function YM(t){let e=Math.round(t*31/255);return dr[e]===t?255*e/31:t}function Dl(t){let e=KM(t)*255,n=Math.min(30,Math.floor(e*31/255));for(;n<30&&e>=dr[n+1];)n++;for(;n>0&&e<dr[n];)n--;return n+Math.min(1,Math.max(0,(e-dr[n])/(dr[n+1]-dr[n])))}function $M(t,e,n,r){let o=Dl(e),s=Dl(n),i=Dl(r),a=Math.min(30,Math.floor(o)),u=Math.min(30,Math.floor(s)),l=Math.min(30,Math.floor(i)),c=o-a,f=s-u,m=i-l,b=[0,0,0];for(let h=0;h<3;h++){let p=0;for(let d=0;d<8;d++){let x=d&1,y=d>>1&1,g=d>>2&1,M=(x?c:1-c)*(y?f:1-f)*(g?m:1-m);M!==0&&(p+=M*t[(((a+x)*32+u+y)*32+l+g)*3+h]);}b[h]=p/255;}return b}function ah(t){return !!t&&!ih(t)&&t.colorfulness===0&&t.redGreenTint===0}function uh(t,e){let n={flags:t.getUint16(e+2,true),illuminant:t.getUint16(e+4,true),redGamma:t.getUint16(e+6,true),greenGamma:t.getUint16(e+8,true),blueGamma:t.getUint16(e+10,true),referenceBlack:t.getUint16(e+12,true),referenceWhite:t.getUint16(e+14,true),contrast:t.getInt16(e+16,true),brightness:t.getInt16(e+18,true),colorfulness:t.getInt16(e+20,true),redGreenTint:t.getInt16(e+22,true)},r=(s,i,a)=>s>=i&&s<=a;return (n.flags&-4)===0&&r(n.illuminant,0,8)&&r(n.redGamma,2500,65e3)&&r(n.greenGamma,2500,65e3)&&r(n.blueGamma,2500,65e3)&&r(n.referenceBlack,0,4e3)&&r(n.referenceWhite,6e3,1e4)&&r(n.contrast,-100,100)&&r(n.brightness,-100,100)&&r(n.colorfulness,-100,100)&&r(n.redGreenTint,-100,100)?n:null}function kl(t){return !t||t.flags===0&&!ih(t)&&t.redGamma===1e4&&t.greenGamma===1e4&&t.blueGamma===1e4&&t.referenceBlack===0&&t.referenceWhite===1e4&&t.contrast===0&&t.brightness===0&&t.colorfulness===0&&t.redGreenTint===0}var jM=.0148885,VM=.95625,zM=1/100,qM=-Math.PI/3,Ze=[[.4123908,.3575843,.1804808],[.212639,.7151687,.0721923],[.0193308,.1191948,.9505322]],Sn=JM(Ze),qo=Ze.map(t=>t[0]+t[1]+t[2]),lh=qo[0]+15*qo[1]+3*qo[2],Zb=4*qo[0]/lh,Qb=9*qo[1]/lh;function JM(t){let[[e,n,r],[o,s,i],[a,u,l]]=t,c=s*l-i*u,f=i*a-o*l,m=o*u-s*a,b=e*c+n*f+r*m;return [[c/b,(r*u-n*l)/b,(n*i-r*s)/b],[f/b,(e*l-r*a)/b,(r*o-e*i)/b],[m/b,(n*a-e*u)/b,(e*s-n*o)/b]]}var KM=t=>t<0?0:t>1?1:t,xr=t=>t<0?0:t>255?255:t,th=t=>Math.floor(t+.5+1e-7);function ZM(t,e,n,r,o){let s=Ze[0][0]*t+Ze[0][1]*e+Ze[0][2]*n,i=Ze[1][0]*t+Ze[1][1]*e+Ze[1][2]*n,a=Ze[2][0]*t+Ze[2][1]*e+Ze[2][2]*n,u=s+15*i+3*a;if(u<=1e-9||i<=1e-9)return [xr(t),xr(e),xr(n)];let l=4*s/u-Zb,c=9*i/u-Qb,f=Math.cos(o)*r,m=Math.sin(o)*r,b=Math.max(0,Zb+l*f-c*m),h=Math.max(1e-6,Qb+l*m+c*f),p=i*9*b/(4*h),d=i*(12-3*b-20*h)/(4*h),x=[Sn[0][0]*p+Sn[0][1]*i+Sn[0][2]*d,Sn[1][0]*p+Sn[1][1]*i+Sn[1][2]*d,Sn[2][0]*p+Sn[2][1]*i+Sn[2][2]*d],y=Math.min(0,x[0],x[1],x[2]),g=Math.max(255,x[0],x[1],x[2]);if(y<0||g>255){let M=255/(g-y);return [(x[0]-y)*M,(x[1]-y)*M,(x[2]-y)*M]}return x}var eh=new Map;function QM(t){if(t.illuminant!==0&&t.illuminant!==6)return null;let e=`${t.colorfulness},${t.redGreenTint}`,n=eh.get(e);if(n===void 0){let r=qb[e];if(n=null,r){n=new Int8Array(32768*3);for(let o of r)n[o>>1]=o&1?1:-1;}eh.set(e,n);}return n}function Fl(t){let e=Math.round(t*31/255);return dr[e]===t?e:-1}function tE(t){let e=Fl(t[0]),n=Fl(t[1]),r=Fl(t[2]);return e<0||n<0||r<0?-1:(e*32+n)*32+r}function eE(t,e){let n=sh(t.illuminant),r=XM[t.illuminant],o=[t.redGamma/1e4,t.greenGamma/1e4,t.blueGamma/1e4],s=t.referenceBlack/1e4*255,i=Math.max(1e-6,t.referenceWhite/1e4*255-s),a=Math.exp(jM*t.contrast),u=VM*t.brightness,l=t.colorfulness!==0||t.redGreenTint!==0,c=1+zM*t.colorfulness,f=qM*t.redGreenTint/100,m=(t.flags&rh)!==0,b=(t.flags&nh)!==0,h=l&&e?.chromaTies!==false?QM(t):null,p=(d,x)=>{let y=255*(xr(d)/255)**o[x];return y=(y-s)/i*255,y=y*a+u,m&&(y=255*Math.log2(1+7*xr(y)/255)/3),b&&(y=255-xr(y)),th(xr(y))};if(!n&&!l){let d=[0,1,2].map(x=>Uint8Array.from({length:256},(y,g)=>p(g,x)));return x=>d[0][x>>16&255]<<16|d[1][x>>8&255]<<8|d[2][x&255]}return d=>{let x=[d>>16&255,d>>8&255,d&255];if(l){let y=h?tE(x):-1;if(x=x.map(YM),r){let[g,M,P]=x;x=r.map(E=>E[0]*g+E[1]*M+E[2]*P);}x=ZM(x[0],x[1],x[2],c,f),x=x.map(th),h&&y>=0&&(x=x.map((g,M)=>g+h[y*3+M]));}else if(n){let y=$M(n,x[0]/255,x[1]/255,x[2]/255);x=[y[0]*255,y[1]*255,y[2]*255];}return p(x[0],0)<<16|p(x[1],1)<<8|p(x[2],2)}}function ch(t){let n={...HM,illuminant:t.illuminant,colorfulness:t.colorfulness,redGreenTint:t.redGreenTint},r={...t,illuminant:0,colorfulness:0,redGreenTint:0};return {palette:kl(n)?void 0:n,curves:kl(r)?void 0:r}}function Bl(t,e){if(!e||kl(e))return;let n=eE(e),r=new Map;for(let o=0;o+2<t.length;o+=3){let s=t[o]<<16|t[o+1]<<8|t[o+2],i=r.get(s);i===void 0&&(i=n(s),r.size<65536&&r.set(s,i)),t[o]=i>>16&255,t[o+1]=i>>8&255,t[o+2]=i&255;}}var nE=[[238,110,198,70,229,102,204,76,236,108,195,69,228,100,205,78],[46,174,7,134,39,166,12,140,45,171,5,132,36,164,15,142],[209,83,249,122,218,90,239,112,208,80,247,120,215,88,242,114],[18,146,59,185,26,154,49,176,16,144,56,184,25,152,50,178],[226,98,202,74,233,107,192,64,224,96,200,73,232,104,194,66],[35,162,11,138,42,170,1,128,32,160,8,136,40,168,2,130],[219,91,243,115,211,83,253,125,221,93,245,117,212,85,250,123],[28,154,52,178,19,147,61,188,29,157,53,181,22,149,59,187],[235,107,195,67,226,100,205,77,236,109,197,69,229,101,202,76],[43,171,4,131,35,163,14,141,45,173,5,133,38,164,11,139],[207,79,246,119,215,87,240,113,209,81,249,121,216,90,239,111],[15,143,56,183,23,151,49,177,18,145,57,185,25,153,47,175],[222,95,198,71,231,103,193,66,225,97,201,73,232,105,191,63],[32,159,8,135,39,167,1,129,33,161,9,137,42,169,1,127],[222,94,246,118,214,86,252,124,219,92,243,116,212,84,253,126],[30,158,54,181,22,150,60,188,28,156,52,180,21,147,62,190]],rE=66,mh=65;function oE(t){return t<63?t%16:t<=64?14:15}function sE(t){return t<63?t%16:t===63?14:15}var Xi=(t,e)=>(t%e+e)%e;function Gl(t,e){let n=Xi(t-e-2,65);return n<63?n:n+1}function Ol(t,e){return Xi(t-e-2,mh)}function Yi(t,e,n,r){return nE[sE(Xi(e+r,mh))][oE(Xi(t+n,rE))]}function iE(t){return Math.round(t*255/31)}function io(t,e){let n=Math.floor((31*t+e)/255);return iE(n<0?0:n>31?31:n)}function aE(t,e,n){return n===t?16777216|n>>2<<8|e>>2:n|e<<8|t<<16}function $i(t,e,n){if(e<=0||n<=0)return "replicate";let r=e*n;if(r<=2304)return "replicate";let o=b=>aE(t[b*3],t[b*3+1],t[b*3+2]),s=new Set;if(r>16384){for(let b=0;b<n;b+=6){for(let h=0;h<e;h++)s.add(o(b*e+h));if(s.size>=20)return "filter"}return "replicate"}let i=Math.floor(2304/e)+1;if(n<i)return "replicate";let a=n===i,u=a?289+Math.floor((i*e-2304)/8):145+Math.floor((i*e-2304)/16),l=0,c=0,f=0,m=false;for(let b=0;b<n;b++){let h=0;for(let p=0;p<e;p++){let d=o(b*e+p);s.has(d)||(s.add(d),h++);}if(l+=h,!m&&l>=u||(h===0?c++:f+=e,l>=20&&f>2304&&!(a&&m)))return "filter";(a?l+c*e>=u-1:l+(c+1)*e>=r-2305+u)&&(m=true);}return "replicate"}var Nl=1,fh=2;var gr=4;function Ko(t,e,n){let r=Math.floor((2*t+1)*e/(2*n));return Math.max(0,Math.min(e-1,r))}function bh(t,e,n,r,o){let s=[],i=u=>r?t+e-1-u:t+u;if(n<=0||e<=0)return s;let a=-1;for(let u=0;u<n;u++){let l=Ko(u,e,n),c=[],f=o&&n<e?a+1:l;for(let m=f;m<=l;m++)c.push(i(m));s.push(c),a=l;}return s}function xh(t,e,n,r,o,s,i,a){let u=Math.max(0,Math.round(Math.abs(s))),l=Math.max(0,Math.round(Math.abs(i))),c=s<0!=r<0,f=i<0!=o<0,m=a===Nl||a===fh,b=bh(Math.round(Math.min(e,e+r)),Math.round(Math.abs(r)),u,c,m),h=bh(Math.round(Math.min(n,n+o)),Math.round(Math.abs(o)),l,f,m),p=new Uint8ClampedArray(u*l*4),d=t.data,x=(y,g)=>{if(y<0||g<0||y>=t.width||g>=t.height)return 0;let M=(g*t.width+y)*4;return d[M]<<16|d[M+1]<<8|d[M+2]};for(let y=0;y<l;y++){Fe();let g=h[y]??[];for(let M=0;M<u;M++){let P=b[M]??[],E=a===Nl?16777215:0,R=true;for(let A of g)for(let w of P){let I=x(w,A);a===Nl?E&=I:a===fh?E|=I:R&&(E=I),R=false;}let T=(y*u+M)*4;p[T]=E>>16&255,p[T+1]=E>>8&255,p[T+2]=E&255,p[T+3]=255;}}return {width:u,height:l,data:p}}var ao=65536;function Hl(t,e,n){let r=(2*t+1)*e,o=2*n,s=Math.floor(r/o);return s*o===r&&s--,Math.max(0,Math.min(e-1,s))}function yh(t,e,n,r){let o=[];if(n<=0||e<=0)return o;let s=a=>t+a;if(n>=e){for(let a=0;a<n;a++)o.push([[s(Hl(a,e,n)),1]]);return r&&o.reverse(),o}let i=Math.ceil(e*ao/n);for(let a=0;a<n;a++){let u=a*i,l=(a+1)*i,c=[];for(let f=Math.floor(u/ao);f*ao<l&&f<e;f++){let m=Math.min(l,(f+1)*ao)-Math.max(u,f*ao);m>0&&c.push([s(f),m]);}o.push(c);}return r&&o.reverse(),o}var uE=13;function Jo(t,e,n){if(e>=t)return yh(0,t,e,n);let r=2**uE,o=ao/r,s=[];for(let i=0;i<e;i++){let a=i*t,u=(i+1)*t,l=[];for(let c=Math.floor(a/e);c*e<u;c++){let f=Math.max(a,c*e)-a,m=Math.min(u,(c+1)*e)-a;m<=f||l.push([c,(Math.floor(m*r/t)-Math.floor(f*r/t))*o]);}s.push(l);}return n&&s.reverse(),s}function lE(t){if(t>=1)return 0;let e=1-t;return Math.abs(t-.5)<1e-9?e:Math.pow(e,t<.5?Math.SQRT1_2:Math.SQRT2)}function gh(t,e){return cE(t,e).map(n=>{let r=0;return n.map(([o,s],i)=>{let a=i===n.length-1?8192:Math.ceil(s-1e-7),u=a-r;return r=a,[o,u/8192]})})}function cE(t,e){let n=e/t,r=Math.ceil(n)-1,o=[],s=0;for(let u=0;u<=r;u++){let l=lE(u/n);o.push(l),s+=u===0?l:2*l;}let i=[];for(let u=0;u<e;u++){let l=u/n,c=(u+1)/n,f=[];for(let m=Math.max(0,Math.floor(l));m<Math.min(t,c);m++){let b=Math.min(c,m+1)-Math.max(l,m);b>0&&f.push([m,b*n]);}i.push(f);}let a=[];for(let u=0;u<e;u++){let l=new Map;for(let m=-r;m<=r;m++){let b=o[Math.abs(m)]/s;if(b!==0)for(let[h,p]of i[Math.max(0,Math.min(e-1,u+m))])l.set(h,(l.get(h)??0)+b*p);}let c=[...l.entries()].sort((m,b)=>m[0]-b[0]),f=0;a.push(c.map(([m,b])=>(f+=b*8192,[m,f])));}return a}function yr(t,e,n,r,o,s,i,a){for(let u=0;u<n;u++){let l=a?a[u]:u;for(let c=0;c<e;c++){let f=i?i[c]:c,m=Yi(r.startX,r.startY,f,l),b=(u*e+c)*3;t[b]=io(t[b],m),t[b+1]=io(t[b+1],m),t[b+2]=io(t[b+2],m);}}}function hh(t,e,n){if(e<2||n<2)return;let r=t.slice(),o=(l,c)=>{let f=l<0?-l:l>=e?2*(e-1)-l:l,m=c<0?-c:c>=n?2*(n-1)-c:c;return (Math.max(0,Math.min(n-1,m))*e+Math.max(0,Math.min(e-1,f)))*3},s=(l,c)=>r[l]===r[c]&&r[l+1]===r[c+1]&&r[l+2]===r[c+2],i=e+1,a=new Uint8Array(i*(n+1));for(let l=-1;l<n;l++)for(let c=-1;c<e;c++){let f=o(c,l),m=o(c+1,l),b=o(c,l+1),h=o(c+1,l+1);a[(l+1)*i+c+1]=s(f,h)&&s(m,b)&&!s(f,m)?1:0;}let u=(l,c)=>a[(c+1)*i+l+1]===1;for(let l=0;l<n-1;l++)for(let c=0;c<e-1;c++){if(!u(c,l))continue;let f=o(c,l),m=o(c+1,l),b=[[c,l,1,1,true],[c+1,l+1,-1,-1,true],[c+1,l,-1,1,false],[c,l+1,1,-1,false]];if(u(c-1,l)&&u(c+1,l)||u(c,l-1)&&u(c,l+1)){for(let[p,d]of b){let x=(d*e+p)*3;for(let y=0;y<3;y++)t[x+y]=r[f+y]+r[m+y]+1>>1;}continue}let h=4*(r[f]-r[m])+8*(r[f+1]-r[m+1])+(r[f+2]-r[m+2]);for(let[p,d,x,y,g]of b){if(g?h<0:h>=0)continue;let M=(d*e+p)*3,P=o(p+x,d),E=o(p,d+y),R=o(p+2*x,d),T=o(p,d+2*y);for(let A=0;A<3;A++)t[M+A]=12*t[M+A]+r[P+A]+r[E+A]+r[R+A]+r[T+A]+8>>4;}}}function mE(t,e,n){let r=t.slice(),o=(s,i,a)=>r[(Math.max(0,Math.min(n-1,i))*e+Math.max(0,Math.min(e-1,s)))*3+a];for(let s=0;s<n;s++){Fe();for(let i=0;i<e;i++)for(let a=0;a<3;a++){let u=o(i,s,a),l=o(i-1,s,a)+o(i+1,s,a)+o(i,s-1,a)+o(i,s+1,a),c=u+Math.floor((4*u-l)/8);t[(s*e+i)*3+a]=c<0?0:c>255?255:c;}}}function fE(t,e,n,r){let o=r?e:n,s=(l,c)=>(r?c*e+l:l*e+c)*3,i=(l,c)=>t[l]===t[c]&&t[l+1]===t[c+1]&&t[l+2]===t[c+2],a=l=>l>=0&&l+1<o&&i(s(l,0),s(l+1,1))&&i(s(l,1),s(l+1,0))&&!i(s(l,0),s(l,1)),u=Array.from({length:o},(l,c)=>a(c-1)||a(c));for(let l=0;l<o;l++){if(!u[l])continue;let c=s(l,0),f=s(l,1);for(let m=0;m<3;m++)t[c+m]=t[f+m]=t[c+m]+t[f+m]+1>>1;}}function ph(t,e,n,r){let o=r?e:n,s=new Int32Array(o*3);for(let i=0;i<o;i++){let a=(r?e+i:i*e+1)*3;for(let u=0;u<3;u++)s[i*3+u]=t[a+u];}return s}function bE(t,e,n,r,o,s,i){let a=Jo(e,r,s),u=Jo(n,o,i),l=new Int32Array(r*n*3);for(let b=0;b<n;b++){Fe();for(let h=0;h<r;h++){let p=0;for(let[,d]of a[h])p+=d;for(let d=0;d<3;d++){let x=0;for(let[y,g]of a[h])x+=t[(b*e+y)*3+d]*g;l[(b*r+h)*3+d]=Math.floor((2*x+p)/(2*p));}}}let c=new Float64Array(r*o*3);for(let b=0;b<o;b++){let h=0;for(let[,p]of u[b])h+=p;for(let p=0;p<r;p++)for(let d=0;d<3;d++){let x=0;for(let[y,g]of u[b])x+=l[(y*r+p)*3+d]*g;c[(b*r+p)*3+d]=x/h;}}let f=(b,h,p)=>c[(Math.max(0,Math.min(o-1,h))*r+Math.max(0,Math.min(r-1,b)))*3+p],m=new Int32Array(r*o*3);for(let b=0;b<o;b++)for(let h=0;h<r;h++)for(let p=0;p<3;p++){let d=f(h,b,p),x=f(h-1,b,p)+f(h+1,b,p)+f(h,b-1,p)+f(h,b+1,p);m[(b*r+h)*3+p]=Math.max(0,Math.min(255,Math.floor(d+(4*d-x)/8)));}return m}function hE(t,e,n,r,o,s,i){let a=o<n,u=a?Jo(n,o,i):Jo(e,r,s),l=new Float64Array(r*o*3);for(let m=0;m<o;m++)for(let b=0;b<r;b++){let h=a?u[m]:u[b],p=a?s?r-1-b:b:i?o-1-m:m,d=0;for(let[,x]of h)d+=x;for(let x=0;x<3;x++){let y=0;for(let[g,M]of h)y+=t[((a?g:p)*e+(a?p:g))*3+x]*M;l[(m*r+b)*3+x]=y/d;}}let c=new Int32Array(r*o*3),f=(m,b,h)=>l[(Math.max(0,Math.min(o-1,b))*r+Math.max(0,Math.min(r-1,m)))*3+h];for(let m=0;m<o;m++)for(let b=0;b<r;b++)for(let h=0;h<3;h++){let p=f(b,m,h),d=a?f(b,m-1,h)+f(b,m+1,h):f(b-1,m,h)+f(b+1,m,h);c[(m*r+b)*3+h]=Math.max(0,Math.min(255,Math.floor(p+(2*p-d)/4)));}return c}var Mh={1:[[5,22,5,32]],2:[[4,12,0,16],[0,12,4,16]],3:[[6,10,0,16],[1,14,1,16],[0,10,6,16]],4:[[6,10,0,16],[3,12,1,16],[1,12,3,16],[0,10,6,16]],5:[[13,19,0,32],[6,25,1,32],[3,26,3,32],[1,25,6,32],[0,19,13,32]]};function Wl(t,e){if(e/t===2){let r=Mh[2].map(([o,s,i])=>[o*512,s*512,i*512]);return Array.from({length:e},(o,s)=>{let i=Math.floor(s/2),[a,u,l]=r[s%2];return [[Math.max(0,i-1),a],[i,u],[Math.min(t-1,i+1),l]]})}return gh(t,e).map(r=>r.map(([o,s])=>[o,Math.round(s*8192)]))}function pE(t,e,n,r,o,s){let i=r>e,a=i?e:n,u=new Int32Array(t.length),l=(m,b,h)=>b>=n&&s?s[Math.max(0,Math.min(e-1,m))*3+h]:t[(Math.max(0,Math.min(n-1,b))*e+Math.max(0,Math.min(e-1,m)))*3+h];for(let m=0;m<n;m++){Fe();for(let b=0;b<e;b++)for(let h=0;h<3;h++){let p=l(b,m,h),d=i?l(b-1,m,h)+l(b+1,m,h):l(b,m-1,h)+l(b,m+1,h),x=p+Math.floor((2*p-d)/4);u[(m*e+b)*3+h]=x<0?0:x>255?255:x;}}let c=Wl(a,i?r:o),f=new Int32Array(r*o*3);for(let m=0;m<o;m++)for(let b=0;b<r;b++)for(let h=0;h<3;h++){let p=0;if(i)for(let[d,x]of c[b])p+=x*u[(m*e+d)*3+h];else for(let[d,x]of c[m])p+=x*u[(d*e+b)*3+h];f[(m*r+b)*3+h]=Math.floor((p+4096)/8192);}return f}function dh(t,e){let n=Array.from({length:e},(s,i)=>Hl(i,t,e)),r=new Map;for(let s of n)r.set(s,(r.get(s)??0)+1);let o=new Map;return n.map(s=>{let i=o.get(s)??0;return o.set(s,i+1),{k:s,weights:Mh[r.get(s)][i]}})}function dE(t,e,n,r){return t>0&&e>0&&n>=t&&r>=e&&(n>t||r>e)}function xE(t,e,n,r,o,s,i){if(r>5*e||o>5*n){let u=new Int32Array((n+1)*e*3);return u.set(t),u.set(t.subarray((n-1)*e*3),n*e*3),yr(u,e,n+1,s,false,false,void 0,Int32Array.from({length:n+1},(l,c)=>i?o-1-c:c)),u}let a=new Int32Array((n+4)*e*3);return a.set(t.subarray(0,e*3),0),a.set(t.subarray(0,e*3),e*3),a.set(t,2*e*3),a.set(t.subarray((n-1)*e*3),(n+2)*e*3),a.set(t.subarray((n-1)*e*3),(n+3)*e*3),yr(a,e,n+4,{startX:s.startX,startY:(s.startY+(i?63:2))%65},false,false,void 0,Int32Array.from({length:n+4},(u,l)=>i?o-l+1:l-2)),a}function yE(t,e,n,r,o,s){if(r===e||o===n)return pE(t,e,n,r,o,s&&s.length===(n+1)*e*3?s.subarray(n*e*3):void 0);let i=x=>x<0?0:x>255?255:x,a=r>5*e||o>5*n,u=new Int32Array(r*o*3);if(a){let x=t.slice();if(s){let P=(E,R,T)=>s[(Math.max(0,Math.min(n,R))*e+Math.max(0,Math.min(e-1,E)))*3+T];for(let E=0;E<n;E++)for(let R=0;R<e;R++)for(let T=0;T<3;T++){let A=P(R,E,T),w=P(R-1,E,T)+P(R+1,E,T)+P(R,E-1,T)+P(R,E+1,T);x[(E*e+R)*3+T]=i(A+Math.floor((4*A-w)/8));}}else mE(x,e,n);let y=Wl(e,r),g=Wl(n,o),M=new Int32Array(r*n*3);for(let P=0;P<n;P++)for(let E=0;E<r;E++)for(let R=0;R<3;R++){let T=0;for(let[A,w]of y[E])T+=w*x[(P*e+A)*3+R];M[(P*r+E)*3+R]=Math.floor((T+4096)/8192);}for(let P=0;P<o;P++)for(let E=0;E<r;E++)for(let R=0;R<3;R++){let T=0;for(let[A,w]of g[P])T+=w*M[(A*r+E)*3+R];u[(P*r+E)*3+R]=i(Math.floor((T+4096)/8192));}return u}let l=n+2,c=new Int32Array(e*l*3),f;s&&s.length===(n+4)*e*3?f=s:(f=new Int32Array(e*(n+4)*3),s&&s.length===l*e*3?(f.set(s.subarray(e*3,2*e*3),0),f.set(s,e*3),f.set(s.subarray(n*e*3,(n+1)*e*3),(n+3)*e*3)):(f.set(t.subarray(0,e*3),0),f.set(t.subarray(0,e*3),e*3),f.set(t,2*e*3),f.set(t.subarray((n-1)*e*3),(n+2)*e*3),f.set(t.subarray((n-1)*e*3),(n+3)*e*3)));let m=f,b=(x,y,g)=>m[((y+1)*e+Math.max(0,Math.min(e-1,x)))*3+g];for(let x=0;x<l;x++)for(let y=0;y<e;y++)for(let g=0;g<3;g++){let M=b(y,x,g),P=b(y-1,x,g)+b(y+1,x,g)+b(y,x-1,g)+b(y,x+1,g);c[(x*e+y)*3+g]=i(M+Math.floor((4*M-P)/8));}let h=dh(e,r),p=dh(n,o),d=new Int32Array(e*3);for(let x=0;x<o;x++){let y=p[x].k+1,[g,M,P,E]=p[x].weights,R=(y-1)*e*3,T=y*e*3,A=(y+1)*e*3;for(let w=0;w<e*3;w++)d[w]=Math.floor((g*c[R+w]+M*c[T+w]+P*c[A+w]+E/2)/E);for(let w=0;w<r;w++){let I=h[w].k,[S,v,C,U]=h[w].weights,D=Math.max(0,I-1),L=Math.min(e-1,I+1);for(let F=0;F<3;F++)u[(x*r+w)*3+F]=Math.floor((S*d[D*3+F]+v*d[I*3+F]+C*d[L*3+F]+U/2)/U);}}return u}function gE(t,e,n,r,o){let s=r>e&&o*2<=n||o>n&&r*2<=e,i=o<n&&3*o+2<=2*n||r<e&&3*r+2<=2*e;if(s||i)return "reduced";let a=e*n<=2304;return !a&&$i(t,e,n)==="filter"?"reduced":r*o<e*n?a?"despeckled":"reduced":"nearest"}function Eh(t,e,n,r,o,s,i,a,u=false,l=false,c,f){let m=Math.max(0,Math.round(Math.abs(s))),b=Math.max(0,Math.round(Math.abs(i))),h=Math.round(Math.abs(r)),p=Math.round(Math.abs(o)),d=Math.round(Math.min(e,e+r)),x=Math.round(Math.min(n,n+o)),y=s<0!=r<0,g=i<0!=o<0,M=new Uint8ClampedArray(m*b*4);if(m===0||b===0||h===0||p===0)return {width:m,height:b,data:M};let P=new Int32Array(h*p*3);for(let H=0;H<p;H++){let Y=x+H;for(let N=0;N<h;N++){let G=d+N;if(Y<0||Y>=t.height||G<0||G>=t.width)continue;let j=(Y*t.width+G)*4,tt=(H*h+N)*3;P[tt]=t.data[j],P[tt+1]=t.data[j+1],P[tt+2]=t.data[j+2];}}let E=p===2&&b===1&&m>h&&(!a||u||!!c),R=h===2&&m===1&&b>p&&(!a||u||!!c);(E||R)&&(l||fE(P,h,p,E),E&&m>=2*h?(P=ph(P,h,p,true),p=1):R&&b>=2*p&&(P=ph(P,h,p,false),h=1));let T=m>=h&&b>=p&&(m>h||b>p),A=m<h&&b<p,w=m>h&&b<p||m<h&&b>p,I=!!c&&!!a&&!u,S=w&&(!a||u||I),v=S?gE(P,h,p,m,b):"nearest",C=S&&v==="nearest"&&(m<h&&m*2>h||b<p&&b*2>p),U=S&&v!=="nearest",D=h*p<=2304||h*p>16384,L=m<h&&b===p||b<p&&m===h,F=(A||L)&&D&&!l&&!(m<h&&3*m+2<=2*h)&&!(b<p&&3*b+2<=2*p)&&(h*p<=2304||$i(P,h,p)==="replicate");if(L&&(!a||u||I)){F&&hh(P,h,p);let H=hE(P,h,p,m,b,y,g);I?(yr(H,m,b,c),a(H),f&&f(H)):a&&a(H);for(let Y=0,N=0;Y<m*b;Y++,N+=3)M[Y*4]=H[N],M[Y*4+1]=H[N+1],M[Y*4+2]=H[N+2],M[Y*4+3]=255;return {width:m,height:b,data:M}}if(T&&dE(h,p,m,b)&&(!a||u||I)&&$i(P,h,p)==="filter"){let H,Y=P;I&&(m===h||b===p?b>p?(H=new Int32Array((p+1)*h*3),H.set(P),H.set(P.subarray((p-1)*h*3),p*h*3),yr(H,h,p+1,c,false,false,void 0,Int32Array.from({length:p+1},(G,j)=>g?b-1-j:j)),a(H),Y=H.subarray(0,h*p*3)):(Y=P.slice(),yr(Y,h,p,c,false,false,void 0,Int32Array.from({length:p},(G,j)=>g?b-1-j:j)),a(Y)):(H=xE(P,h,p,m,b,c,g),a(H)));let N=yE(Y,h,p,m,b,H);if(y||g){let G=N.slice();for(let j=0;j<b;j++)for(let tt=0;tt<m;tt++){let lt=((g?b-1-j:j)*m+(y?m-1-tt:tt))*3;N.set(G.subarray(lt,lt+3),(j*m+tt)*3);}}a&&u&&a(N),f&&I&&f(N);for(let G=0,j=0;G<m*b;G++,j+=3)M[G*4]=N[j],M[G*4+1]=N[j+1],M[G*4+2]=N[j+2],M[G*4+3]=255;return {width:m,height:b,data:M}}((T||C||v==="despeckled")&&D||A&&F)&&!l&&!E&&!R&&hh(P,h,p);let B=I&&(m>=h&&b>=p||U&&m*b>=h*p),X=B&&U&&m<h&&b>p;if(X){let H=new Int32Array((p+1)*h*3);H.set(P),H.copyWithin(p*h*3,(p-1)*h*3,p*h*3),P=H;}B&&yr(P,h,X?p+1:p,c,false,false,void 0,g?Int32Array.from({length:X?p+1:p},(H,Y)=>b-1-Y):void 0),a&&!u&&(!I||B)&&a(P);let k=U?Math.min(h,m):m,W=U?Math.min(p,b):b,O=U?(H,Y,N)=>Jo(H,Y,N):(H,Y,N)=>yh(0,H,Y,N),q=U&&m>h,Q=U&&b>p,K=O(h,k,y&&!q),V=O(p,W,g&&!Q);if(C){let H=(Y,N,G,j)=>{for(let tt=0;tt<G;tt++){let lt=j?G-1-tt:tt,ct=G<N?Math.floor(((lt+1)*2*N-G)/(2*G)):Hl(lt,N,G);Y[tt]=[[Math.max(0,Math.min(N-1,ct)),1]];}};H(K,h,m,y),H(V,p,b,g);}else if(w&&!U){let H=(Y,N,G,j)=>{if(!(G<=N))for(let tt=0;tt<G;tt++){let lt=Math.max(0,Math.min(N-1,(tt+.5)*N/G-.5)),ct=Math.floor(lt),ht=lt-ct,ft=at=>j?N-1-at:at;Y[tt]=[[ft(ct),1-ht],[ft(Math.min(N-1,ct+1)),ht]];}};H(K,h,m,y),H(V,p,b,g);}let rt=U?new Float64Array(k*W*3):new Int32Array(m*b*3);A&&(rt=bE(P,h,p,m,b,y,g));for(let H=0;!A&&H<W;H++){let Y=V[H];for(let N=0;N<k;N++){let G=K[N],j=0,tt=0,lt=0,ct=0;for(let[at,mt]of Y)for(let[Rt,Ae]of G){let Kt=Ae*mt;ct+=Kt;let Wt=(at*h+Rt)*3;j+=P[Wt]*Kt,tt+=P[Wt+1]*Kt,lt+=P[Wt+2]*Kt;}let ht=(H*k+N)*3,ft=at=>U?at/ct:w?Math.ceil(at/ct-.5):Math.floor((2*at+ct)/(2*ct));rt[ht]=ft(j),rt[ht+1]=ft(tt),rt[ht+2]=ft(lt);}}if(U){let H=m<h,Y;if(X){let lt=new Float64Array(k*3);for(let ct=0;ct<k;ct++){let ht=0,ft=[0,0,0];for(let[at,mt]of K[ct]){ht+=mt;for(let Rt=0;Rt<3;Rt++)ft[Rt]+=P[(p*h+at)*3+Rt]*mt;}for(let at=0;at<3;at++)lt[ct*3+at]=ft[at]/ht;}Y=lt;}for(let lt of [H,!H]){let ct=rt;rt=new Int32Array(ct.length);let ht=Y,ft=(at,mt,Rt)=>mt>=W&&ht?ht[Math.max(0,Math.min(k-1,at))*3+Rt]:ct[(Math.max(0,Math.min(W-1,mt))*k+Math.max(0,Math.min(k-1,at)))*3+Rt];if(lt&&ht){let at=new Int32Array(k*3);for(let mt=0;mt<k;mt++)for(let Rt=0;Rt<3;Rt++){let Ae=ht[mt*3+Rt],Kt=ft(mt-1,W,Rt)+ft(mt+1,W,Rt);at[mt*3+Rt]=Math.max(0,Math.min(255,Math.floor(Ae+(2*Ae-Kt)/4)));}Y=at;}for(let at=0;at<W;at++)for(let mt=0;mt<k;mt++)for(let Rt=0;Rt<3;Rt++){let Ae=ft(mt,at,Rt),Kt=lt?ft(mt-1,at,Rt)+ft(mt+1,at,Rt):ft(mt,at-1,Rt)+ft(mt,at+1,Rt);rt[(at*k+mt)*3+Rt]=Math.max(0,Math.min(255,Math.floor(Ae+(2*Ae-Kt)/4)));}}let N=rt;rt=new Int32Array(m*b*3);let G=(lt,ct)=>lt===ct?Array.from({length:ct},(ht,ft)=>[[ft,1]]):ct===2*lt?Array.from({length:ct},(ht,ft)=>{let at=Math.max(0,Math.min(lt-1,(ft+.5)*lt/ct-.5)),mt=Math.floor(at);return [[mt,1-(at-mt)],[Math.min(lt-1,mt+1),at-mt]]}):gh(lt,ct),j=G(k,m),tt=G(W,b);q&&y&&j.reverse(),Q&&g&&tt.reverse();for(let lt=0;lt<b;lt++)for(let ct=0;ct<m;ct++)for(let ht=0;ht<3;ht++){let ft=0;for(let[at,mt]of tt[lt])for(let[Rt,Ae]of j[ct])ft+=N[(at*k+Rt)*3+ht]*mt*Ae;rt[(lt*m+ct)*3+ht]=Math.max(0,Math.min(255,Math.floor(ft+.5+1e-7)));}}if(w&&!U&&!C){let H=rt.slice(),Y=(N,G,j)=>H[(Math.max(0,Math.min(b-1,G))*m+Math.max(0,Math.min(m-1,N)))*3+j];for(let N=0;N<b;N++)for(let G=0;G<m;G++)for(let j=0;j<3;j++){let tt=Y(G,N,j),lt=m<h?Y(G-1,N,j)+Y(G+1,N,j):Y(G,N-1,j)+Y(G,N+1,j);rt[(N*m+G)*3+j]=Math.max(0,Math.min(255,tt+Math.floor((2*tt-lt)/4)));}}if(I&&!B){let H=(j,tt,lt,ct)=>Int32Array.from({length:j},(ht,ft)=>lt>tt?Math.max(0,Math.ceil((2*ft+1)*tt/(2*lt))-1):ct?Math.max(0,Math.min(tt-1,Math.floor(((ft+1)*2*tt-lt)/(2*lt)))):ft),Y=C&&m*b>h*p,N=Y?H(m,h,m,true):void 0,G=Y?H(b,p,b,false):void 0;N&&y&&(N=N.slice().reverse()),G&&g&&b>p&&(G=G.slice().reverse().map(j=>b-1-j)),yr(rt,m,b,c,false,false,N,G),a(rt);}a&&u&&a(rt),f&&I&&f(rt);for(let H=0,Y=0;H<m*b;H++,Y+=3)M[H*4]=rt[Y],M[H*4+1]=rt[Y+1],M[H*4+2]=rt[Y+2],M[H*4+3]=255;return {width:m,height:b,data:M}}function ji(t,e){if(e.kind==="solid")return e.rgb;if(e.kind==="none")return 0;let{state:n,bounds:r}=t,o=t.sx||1,s=t.sy||1;return (i,a)=>qn(e,Math.floor(r.left+(i+.5)/o),Math.floor(r.top+(a+.5)/s),n.brushOrgX,n.brushOrgY)}function wh(t,e,n,r,o,s,i,a){let u=Math.min(n.dx,n.dx+n.dw)-r,l=Math.min(n.dy,n.dy+n.dh)-o,c=s===gr?Eh(e.pixels,n.sx,n.sy,n.sw,n.sh,n.dw,n.dh,e.adjust,e.adjustAfterSampling,n.dibOrigin==="bottom-left",e.adjust&&!e.adjustAfterSampling?{startX:Gl(Math.min(n.dx,n.dx+n.dw),i),startY:Ol(Math.min(n.dy,n.dy+n.dh),a)}:void 0,e.curves):xh(e.pixels,n.sx,n.sy,n.sw,n.sh,n.dw,n.dh,s);if(c.width===0||c.height===0)return;let f=It(c.width,c.height);f&&(Ct(f.ctx,Et(c.data,c.width,c.height),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",le(t,f.canvas,Math.round(u),Math.round(l),c.width,c.height),t.restore());}function zl(t,e,n=false){if(!e.source)return null;let r=Ue(t.view,e.source.bmi,e.source.bits,e.source.cbBits,e.source.palColors?Ve(t.state):null);if(!r)return null;let o=t.state.colorAdjustment;e.stretch&&t.state.stretchBltMode===gr&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=!n&&!!o);let s=e.stretch&&t.state.stretchBltMode===gr&&o,i=ah(o),a=s&&!i?ch(o):void 0,u=s?(f=>Bl(f,a?.palette??o)):void 0,l=a?.curves,{sy:c}=e;return e.dibOrigin==="bottom-left"&&t.view.getInt32(e.source.bmi+8,true)>0&&(c=r.height-c-e.sh),{decoded:{pixels:r,adjust:u,adjustAfterSampling:i,curves:l?f=>Bl(f,l):void 0},req:{...e,sy:c}}}function Xl(t,e,n,r){let o=t.globalCompositeOperation,s=t.fillStyle;t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation=n,t.fillStyle=e,t.fillRect(r.dx,r.dy,r.dw,r.dh),t.restore(),t.globalCompositeOperation=o,t.fillStyle=s;}function ME(t,e,n,r,o){let{ctx:s}=t,i=Tb(e.dx,e.dy,e.dw,e.dh,t.canvasW,t.canvasH);if(!i)return;if(typeof s.getImageData!="function"){return}let a="source-over";let u=Qt(t.state);if(r&&u.kind==="none")return;let l=It(i.w,i.h);if(!l)return;let c=null;if(o){let p=zl(t,e);if(!p)return;wh(l.ctx,p.decoded,p.req,i.x,i.y,t.state.stretchBltMode,t.state.brushOrgX,t.state.brushOrgY),c=Tt(l.ctx,0,0,i.w,i.h);}let f=Tt(s,i.x,i.y,i.w,i.h),m=ji(t,u);Rb(f,c,m,n,i.x,i.y);an(n).usesD?Ii():null;Ct(l.ctx,f,0,0),s.save(),s.setTransform(1,0,0,1,0,0),s.globalCompositeOperation=a,s.globalAlpha=1,le(s,l.canvas,i.x,i.y,i.w,i.h),s.restore();}function Yl(t,e,n){return Math.sign(t!==0?t:e!==0?e:n)}function Rh(t,e,n,r){return Yl(t,n,r)>=0&&Yl(t-e,n,r)<0}function Th(t,e,n,r){let o=Math.floor(t/e);return t===o*e&&Yl(0,n,r)<0?o-1:o}function Ih(t,e,n,r,o,s,i,a,u,l,c,f,m){let{ctx:b}=t,h=sl(s);if(h===170)return;let p=an(h);if(typeof b.getImageData!="function"){return}if(r===0||o===0)return;let d=Qt(t.state);if(p.usesP&&d.kind==="none")return;let x=ji(t,d),y=null,g=a,M=u,P;if(p.usesS){let R=zl(t,{plan:{kind:"ternary",index:h,operands:p},dx:0,dy:0,dw:r,dh:o,source:i,sx:a,sy:u,sw:l,sh:c,dibOrigin:f,stretch:m},true);if(!R)return;if(y=R.decoded.pixels,R.decoded.adjust&&t.halftoneRotatedAdjusts){let{adjust:T,adjustAfterSampling:A,curves:w}=R.decoded,I=Gl(0,t.state.brushOrgX),S=Ol(0,t.state.brushOrgY),v=new Int32Array(3);P=(C,U,D)=>{if(v[0]=C>>16&255,v[1]=C>>8&255,v[2]=C&255,!A){let L=Yi(I,S,U,D);for(let F=0;F<3;F++)v[F]=io(v[F],L);}return T(v),w?.(v),v[0]<<16|v[1]<<8|v[2]};}g=R.req.sx,M=R.req.sy;}let E=(R,T)=>{if(!y)return 0;let A=l<0?g-1-R:g+R,w=c<0?M-1-T:M+T;A=Math.max(0,Math.min(y.width-1,A)),w=Math.max(0,Math.min(y.height-1,w));let I=(w*y.width+A)*4;return y.data[I]<<16|y.data[I+1]<<8|y.data[I+2]};ql(t,dt(t,e,n),dt(t,e+r,n),dt(t,e,n+o),l,c,(R,T,A,w,I)=>{let S=p.usesS?E(R,T):0;P&&p.usesS&&(S=P(S,A,w));let v=typeof x=="function"?x(A,w):x;return Vt(h,v,S,I)});}function ql(t,e,n,r,o,s,i){let[a,u]=e,l=n[0]-a,c=n[1]-u,f=r[0]-a,m=r[1]-u,b=l*m-c*f;if(b===0)return;let h=b<0?-1:1;b*=h;let p=[a,n[0],r[0],n[0]+f],d=[u,n[1],r[1],n[1]+m],x=Math.max(0,Math.floor(Math.min(...p)/16)-1),y=Math.max(0,Math.floor(Math.min(...d)/16)-1),g=Math.min(t.canvasW,Math.ceil(Math.max(...p)/16)+2),M=Math.min(t.canvasH,Math.ceil(Math.max(...d)/16)+2);if(g<=x||M<=y)return;let P=Math.abs(o)||1,E=Math.abs(s)||1,R=h*m,T=-h*f,A=-h*c,w=h*l;Qr(t.ctx,{x,y,w:g-x,h:M-y},(I,S,v)=>{let C=I*16-a,U=S*16-u,D=h*(C*m-U*f),L=h*(l*U-c*C);if(!Rh(D,b,R,T)||!Rh(L,b,A,w))return -1;let F=Math.min(P-1,Th(D*P,b,R,T)),B=Math.min(E-1,Th(L*E,b,A,w));return i(F,B,I,S,v)});}function EE(t,e){let n=Pn(t),r=Rn(t);return {...e,dx:e.dw<0?e.dx+n:e.dx,dy:e.dh<0?e.dy+r:e.dy}}function Sh(t,e,n,r,o,s,i){Jl(t,{plan:wi(13369376),dx:e,dy:n,dw:r,dh:o,source:s,...i,dibOrigin:"top-left",stretch:true});}function Jl(t,e){let{ctx:n}=t,r=EE(t,e),o=r.plan;switch(o.kind){case "noop":return;case "solid":Xl(n,o.color==="black"?"#000000":"#ffffff","source-over",r);return;case "invert-dest":Xl(n,"#ffffff","difference",r);return;case "copy":{let s=zl(t,r);s&&wh(n,s.decoded,s.req,0,0,t.state.stretchBltMode,t.state.brushOrgX,t.state.brushOrgY);return}case "ternary":{let s=Qt(t.state);if(o.index===240&&s.kind!=="tile"){s.kind==="solid"&&Xl(n,t.state.brushColor,"source-over",r);return}ME(t,r,o.index,o.operands.usesP,o.operands.usesS);}}}function Vi(t,e,n,r,o,s=0){return e>0&&n>0&&r>0&&o>0?{bmi:t+e,bits:t+r,cbBits:o,...s===1?{palColors:true}:{}}:null}function Ah(t,e,n,r,o){let{view:s}=t;if(r<(o?108:96))return true;let i=s.getInt32(n+16,true),a=s.getInt32(n+20,true),u=s.getInt32(n+24,true),l=s.getInt32(n+28,true),c=s.getUint32(n+32,true),f=s.getInt32(n+36,true),m=s.getInt32(n+40,true),b=s.getFloat32(n+44,true),h=s.getFloat32(n+48,true),p=s.getFloat32(n+52,true),d=s.getFloat32(n+56,true),x=s.getFloat32(n+60,true),y=s.getFloat32(n+64,true),g=o?s.getInt32(n+92,true):u,M=o?s.getInt32(n+96,true):l,P=r>=100?Vi(e,s.getUint32(n+76,true),s.getUint32(n+80,true),s.getUint32(n+84,true),s.getUint32(n+88,true),s.getUint32(n+72,true)):null,E=b===0&&d===0&&h===0&&p===0,R=E?1:b,T=E?1:d,A={sx:R*f+(E?0:p*m+x),sy:T*m+(E?0:h*f+y),sw:R*g,sh:T*M};return jt(t)?(Ih(t,i,a,u,l,c,P,A.sx,A.sy,A.sw,A.sh,"top-left",o),true):(Jl(t,{plan:wi(c),dx:Gt(t,i),dy:Ot(t,a),dw:qt(t,u),dh:oe(t,l),source:P,...A,dibOrigin:"top-left",stretch:o}),true)}function PE(t,e,n,r){let{view:o}=t;if(r<80)return true;let s=o.getInt32(n+16,true),i=o.getInt32(n+20,true),a=o.getInt32(n+64,true),u=o.getInt32(n+68,true),l=o.getUint32(n+60,true),c=Vi(e,o.getUint32(n+40,true),o.getUint32(n+44,true),o.getUint32(n+48,true),o.getUint32(n+52,true),o.getUint32(n+56,true)),f=o.getInt32(n+24,true),m=o.getInt32(n+28,true),b=o.getInt32(n+32,true),h=o.getInt32(n+36,true);return jt(t)?(Ih(t,s,i,a,u,l,c,f,m,b,h,"bottom-left",true),true):(Jl(t,{plan:wi(l),dx:Gt(t,s),dy:Ot(t,i),dw:qt(t,a),dh:oe(t,u),source:c,sx:f,sy:m,sw:b,sh:h,dibOrigin:"bottom-left",stretch:true}),true)}function vh(t,e,n,r,o){switch(e){case 76:return Ah(t,n,r,o,false);case 77:return Ah(t,n,r,o,true);case 81:return PE(t,n,r,o);default:return false}}function zi(t,e,n,r,o,s,i,a=false){return !n||!r||!o||!s?null:Ue(t.view,e+n,e+o,s,i===1?Ve(t.state):null,a)}function Ch(t,e,n,r,o,s){let{view:i}=t;if(!n||!r||!o||!s)return null;let a=e+n;if(a+16>i.byteLength)return null;let u=i.getInt32(a+4,true),l=i.getInt32(a+8,true),c=Math.abs(l);if(i.getUint16(a+14,true)!==1||u<=0||c===0||u>16384||c>16384)return null;let f=(u+31>>5)*4,m=e+o;if(m+f*c>i.byteLength)return null;let b=new Uint8Array(u*c);for(let h=0;h<c;h++){let p=l>0?c-1-h:h,d=m+h*f;for(let x=0;x<u;x++)b[p*u+x]=i.getUint8(d+(x>>3))>>7-(x&7)&1;}return {width:u,height:c,bits:b}}function qi(t,e,n,r,o,s){let i=t.getFloat32(e,true),a=t.getFloat32(e+4,true),u=t.getFloat32(e+8,true),l=t.getFloat32(e+12,true),c=t.getFloat32(e+16,true),f=t.getFloat32(e+20,true),m=i===0&&l===0&&a===0&&u===0,b=m?1:i,h=m?1:l;return {sx:Math.round(b*n+(m?0:u*r+c)),sy:Math.round(h*r+(m?0:a*n+f)),sw:Math.round(b*o),sh:Math.round(h*s)}}function uo(t,e,n){let r=e<0?0:e>=t.width?t.width-1:e,s=((n<0?0:n>=t.height?t.height-1:n)*t.width+r)*4;return (t.data[s+3]<<24|t.data[s]<<16|t.data[s+1]<<8|t.data[s+2])>>>0}function Ji(t,e,n,r,o,s,i,a,u){let l=Gt(t,e),c=Ot(t,n),f=qt(t,r),m=oe(t,o);f<0&&(l+=Pn(t)),m<0&&(c+=Rn(t));let b=Math.round(Math.abs(f)),h=Math.round(Math.abs(m)),p=Math.abs(a),d=Math.abs(u);if(b===0||h===0||p===0||d===0)return null;let x=Math.round(Math.min(l,l+f)),y=Math.round(Math.min(c,c+m)),g=Math.max(0,x),M=Math.max(0,y),P=Math.min(t.canvasW,x+b),E=Math.min(t.canvasH,y+h);if(P<=g||E<=M)return null;let R=Math.min(s,s+a),T=Math.min(i,i+u),A=new Int32Array(P-g),w=new Int32Array(E-M),I=f<0||m<0,S=(v,C,U)=>I?Math.min(C-1,Math.floor(v*C/U)):Ko(v,C,U);for(let v=g;v<P;v++){let C=S(v-x,p,b);A[v-g]=a<0!=f<0?R+p-1-C:R+C;}for(let v=M;v<E;v++){let C=S(v-y,d,h);w[v-M]=u<0!=m<0?T+d-1-C:T+C;}return {box:{x:g,y:M,w:P-g,h:E-M},col:A,row:w}}function Zo(t,e,n){let{ctx:r}=t;if(typeof r.getImageData=="function"&&Qr(r,e,n))return;let o=ze(e.w,e.h);if(!o)return;let s=new Uint8ClampedArray(e.w*e.h*4);for(let i=0;i<e.h;i++)for(let a=0;a<e.w;a++){let u=n(e.x+a,e.y+i,0);if(u<0)continue;let l=(i*e.w+a)*4;s[l]=u>>16&255,s[l+1]=u>>8&255,s[l+2]=u&255,s[l+3]=255;}qe(r,e,o,Et(s,e.w,e.h));}function Mr(t){return Math.round(t/255)}function SE(t,e,n,r){let o=t>>>24;if(n===0)return -1;let s=t>>16&255,i=t>>8&255,a=t&255,u=e>>16&255,l=e>>8&255,c=e&255;if(!r||o===255&&n!==255)return u+Math.round((s-u)*n/255)<<16|l+Math.round((i-l)*n/255)<<8|c+Math.round((a-c)*n/255);if(o===0)return -1;let f=s,m=i,b=a,h=o;n!==255&&(f=Mr(s*n),m=Mr(i*n),b=Mr(a*n),h=Mr(o*n));let p=255-h,d=b+Mr(c*p),x=m+Mr(l*p)+(d>>8);return (f+Mr(u*p)+(x>>8)&255)<<16|(x&255)<<8|d&255}function vE(t,e,n,r){let{view:o}=t;if(r<108)return;let s=o.getUint32(n+32,true),i=s>>>16&255,a=(s>>>24&1)!==0,u=zi(t,e,o.getUint32(n+76,true),o.getUint32(n+80,true),o.getUint32(n+84,true),o.getUint32(n+88,true),o.getUint32(n+72,true),true);if(!u||i===0)return;let l=qi(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),c=Ji(t,o.getInt32(n+16,true),o.getInt32(n+20,true),o.getInt32(n+24,true),o.getInt32(n+28,true),l.sx,l.sy,l.sw,l.sh);if(!c)return;let{box:f,col:m,row:b}=c;if(!Pe(t.ctx));Zo(t,f,(h,p,d)=>SE(uo(u,m[h-f.x],b[p-f.y]),d,i,a));}function UE(t,e,n,r){let{view:o}=t;if(r<108)return;let s=Wo(o.getUint32(n+32,true),Ve(t.state)),i=zi(t,e,o.getUint32(n+76,true),o.getUint32(n+80,true),o.getUint32(n+84,true),o.getUint32(n+88,true),o.getUint32(n+72,true));if(!i)return;let a=qi(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),u=Ji(t,o.getInt32(n+16,true),o.getInt32(n+20,true),o.getInt32(n+24,true),o.getInt32(n+28,true),a.sx,a.sy,a.sw,a.sh);if(!u)return;let{box:l,col:c,row:f}=u;Zo(t,l,(m,b)=>{let h=uo(i,c[m-l.x],f[b-l.y])&16777215;return h===s?-1:h});}function _E(t,e,n,r){let{view:o}=t;if(r<128)return;let s=o.getUint32(n+32,true),i=s>>>16&255,a=s>>>24&255,u=o.getInt32(n+24,true),l=o.getInt32(n+28,true),c=zi(t,e,o.getUint32(n+76,true),o.getUint32(n+80,true),o.getUint32(n+84,true),o.getUint32(n+88,true),o.getUint32(n+72,true)),f=Ch(t,e,o.getUint32(n+104,true),o.getUint32(n+108,true),o.getUint32(n+112,true),o.getUint32(n+116,true)),m=o.getInt32(n+92,true),b=o.getInt32(n+96,true),h=qi(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),u,l),p=Ji(t,o.getInt32(n+16,true),o.getInt32(n+20,true),u,l,h.sx,h.sy,h.sw,h.sh);if(!p)return;let{box:d,col:x,row:y}=p;if((an(i).usesD||f!==null&&an(a).usesD)&&!Pe(t.ctx)){return}let M=ji(t,Qt(t.state)),P=Math.min(h.sx,h.sx+h.sw),E=Math.min(h.sy,h.sy+h.sh);Zo(t,d,(R,T,A)=>{let w=x[R-d.x],I=y[T-d.y],S=i;if(f){let U=m+w-P,D=b+I-E;S=(U>=0&&D>=0&&U<f.width&&D<f.height?f.bits[D*f.width+U]:0)?i:a;}let v=c?uo(c,w,I)&16777215:0,C=typeof M=="function"?M(R,T):M;return Vt(S,C,v,A)});}function LE(t,e,n,r){let{view:o}=t;if(r<140)return;let s=[0,1,2].map(x=>dt(t,o.getInt32(n+16+x*8,true),o.getInt32(n+20+x*8,true))),i=o.getInt32(n+48,true),a=o.getInt32(n+52,true),u=zi(t,e,o.getUint32(n+88,true),o.getUint32(n+92,true),o.getUint32(n+96,true),o.getUint32(n+100,true),o.getUint32(n+84,true));if(!u)return;let l=Ch(t,e,o.getUint32(n+116,true),o.getUint32(n+120,true),o.getUint32(n+124,true),o.getUint32(n+128,true)),c=o.getInt32(n+104,true),f=o.getInt32(n+108,true),m=qi(o,n+56,o.getInt32(n+40,true),o.getInt32(n+44,true),i,a),b=(x,y,g=x,M=y)=>{if(l){let R=c+g,T=f+M;if(R<0||T<0||R>=l.width||T>=l.height||!l.bits[T*l.width+R])return -1}let P=m.sw<0?m.sx-1-x:m.sx+x,E=m.sh<0?m.sy-1-y:m.sy+y;return uo(u,P,E)&16777215},[h,p,d]=s;if(p[1]===h[1]&&d[0]===h[0]){let x=Math.round(Math.abs(p[0]-h[0])/16),y=Math.round(Math.abs(d[1]-h[1])/16);if(!l&&t.state.stretchBltMode===gr&&x>0&&y>0){Sh(t,Math.round(h[0]/16),Math.round(h[1]/16),p[0]<h[0]?-x:x,d[1]<h[1]?-y:y,Vi(e,o.getUint32(n+88,true),o.getUint32(n+92,true),o.getUint32(n+96,true),o.getUint32(n+100,true),o.getUint32(n+84,true)),m);return}let g=Math.round(h[0]/16)+(p[0]<h[0]?1-x:0),M=Math.round(h[1]/16)+(d[1]<h[1]?1-y:0),P=Math.abs(m.sw),E=Math.abs(m.sh),R=Math.max(0,g),T=Math.max(0,M),A=Math.min(t.canvasW,g+x),w=Math.min(t.canvasH,M+y);if(A<=R||w<=T||P===0||E===0)return;let I=p[0]<h[0],S=d[1]<h[1];Zo(t,{x:R,y:T,w:A-R,h:w-T},(v,C)=>{let U=Ko(v-g,P,x),D=Ko(C-M,E,y);return b(I?P-1-U:U,S?E-1-D:D,U,D)});return}t.state.stretchBltMode===gr&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=false),ql(t,h,p,d,m.sw,m.sh,(x,y)=>b(x,y));}function DE(t,e,n,r,o,s,i,a){let{view:u}=t;if(!n||!r||!o||!s||e+n+r>u.byteLength||e+o+s>u.byteLength)return null;let l=new Uint8Array(r+s);l.set(new Uint8Array(u.buffer,u.byteOffset+e+n,r),0),l.set(new Uint8Array(u.buffer,u.byteOffset+e+o,s),r);let c=new DataView(l.buffer),f=c.getInt32(8,true);return c.setInt32(8,f<0?-a:a,true),Ue(c,0,r,s,i===1?Ve(t.state):null)}function FE(t,e,n,r){let{view:o}=t;if(r<76)return;let s=o.getInt32(n+24,true),i=o.getInt32(n+28,true),a=o.getInt32(n+32,true),u=o.getInt32(n+36,true),l=o.getUint32(n+40,true),c=o.getUint32(n+44,true),f=o.getUint32(n+60,true),m=o.getUint32(n+64,true);if(m===0||!l||e+l+12>o.byteLength)return;let b=o.getInt32(e+l+8,true),h=b<0,p=Math.abs(b),d=DE(t,e,l,c,o.getUint32(n+48,true),o.getUint32(n+52,true),o.getUint32(n+56,true),m);if(!d)return;let x=Ji(t,o.getInt32(n+16,true),o.getInt32(n+20,true),a,u,0,0,a,u);if(!x)return;let{box:y,col:g,row:M}=x;Zo(t,y,(P,E)=>{let R=g[P-y.x],T=M[E-y.y],A=i+u-1-T,w=h?p-1-A-f:m-1-(A-f);if(w<0||w>=d.height)return -1;let I=s+R;return I<0||I>=d.width?-1:uo(d,I,w)&16777215});}function Uh(t,e,n,r,o){switch(e){case 114:return vE(t,n,r,o),true;case 116:return UE(t,n,r,o),true;case 78:return _E(t,n,r,o),true;case 79:return LE(t,n,r,o),true;case 80:return FE(t,n,r,o),true;default:return false}}var _h="\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",Lh={737:"\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E\u038F\xB1\u2265\u2264\u03AA\u03AB\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",775:"\u0106\xFC\xE9\u0101\xE4\u0123\xE5\u0107\u0142\u0113\u0156\u0157\u012B\u0179\xC4\xC5\xC9\xE6\xC6\u014D\xF6\u0122\xA2\u015A\u015B\xD6\xDC\xF8\xA3\xD8\xD7\xA4\u0100\u012A\xF3\u017B\u017C\u017A\u201D\xA6\xA9\xAE\xAC\xBD\xBC\u0141\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u0104\u010C\u0118\u0116\u2563\u2551\u2557\u255D\u012E\u0160\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0172\u016A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u017D\u0105\u010D\u0119\u0117\u012F\u0161\u0173\u016B\u017E\u2518\u250C\u2588\u2584\u258C\u2590\u2580\xD3\xDF\u014C\u0143\xF5\xD5\xB5\u0144\u0136\u0137\u013B\u013C\u0146\u0112\u0145\u2019\xAD\xB1\u201C\xBE\xB6\xA7\xF7\u201E\xB0\u2219\xB7\xB9\xB3\xB2\u25A0\xA0",850:"\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\xD7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xAE\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\xC0\xA9\u2563\u2551\u2557\u255D\xA2\xA5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\xE3\xC3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\xF0\xD0\xCA\xCB\xC8\u0131\xCD\xCE\xCF\u2518\u250C\u2588\u2584\xA6\xCC\u2580\xD3\xDF\xD4\xD2\xF5\xD5\xB5\xFE\xDE\xDA\xDB\xD9\xFD\xDD\xAF\xB4\xAD\xB1\u2017\xBE\xB6\xA7\xF7\xB8\xB0\xA8\xB7\xB9\xB3\xB2\u25A0\xA0",852:"\xC7\xFC\xE9\xE2\xE4\u016F\u0107\xE7\u0142\xEB\u0150\u0151\xEE\u0179\xC4\u0106\xC9\u0139\u013A\xF4\xF6\u013D\u013E\u015A\u015B\xD6\xDC\u0164\u0165\u0141\xD7\u010D\xE1\xED\xF3\xFA\u0104\u0105\u017D\u017E\u0118\u0119\xAC\u017A\u010C\u015F\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\u011A\u015E\u2563\u2551\u2557\u255D\u017B\u017C\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0102\u0103\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\u0111\u0110\u010E\xCB\u010F\u0147\xCD\xCE\u011B\u2518\u250C\u2588\u2584\u0162\u016E\u2580\xD3\xDF\xD4\u0143\u0144\u0148\u0160\u0161\u0154\xDA\u0155\u0170\xFD\xDD\u0163\xB4\xAD\u02DD\u02DB\u02C7\u02D8\xA7\xF7\xB8\xB0\xA8\u02D9\u0171\u0158\u0159\u25A0\xA0",855:"\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408\u0459\u0409\u045A\u040A\u045B\u040B\u045C\u040C\u045E\u040E\u045F\u040F\u044E\u042E\u044A\u042A\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414\u0435\u0415\u0444\u0424\u0433\u0413\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438\u0418\u2563\u2551\u2557\u255D\u0439\u0419\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u043A\u041A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\u043B\u041B\u043C\u041C\u043D\u041D\u043E\u041E\u043F\u2518\u250C\u2588\u2584\u041F\u044F\u2580\u042F\u0440\u0420\u0441\u0421\u0442\u0422\u0443\u0423\u0436\u0416\u0432\u0412\u044C\u042C\u2116\xAD\u044B\u042B\u0437\u0417\u0448\u0428\u044D\u042D\u0449\u0429\u0447\u0427\xA7\u25A0\xA0",858:"\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\xD7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xAE\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\xC0\xA9\u2563\u2551\u2557\u255D\xA2\xA5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\xE3\xC3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\xF0\xD0\xCA\xCB\xC8\u20AC\xCD\xCE\xCF\u2518\u250C\u2588\u2584\xA6\xCC\u2580\xD3\xDF\xD4\xD2\xF5\xD5\xB5\xFE\xDE\xDA\xDB\xD9\xFD\xDD\xAF\xB4\xAD\xB1\u2017\xBE\xB6\xA7\xF7\xB8\xB0\xA8\xB7\xB9\xB3\xB2\u25A0\xA0",860:"\xC7\xFC\xE9\xE2\xE3\xE0\xC1\xE7\xEA\xCA\xE8\xCD\xD4\xEC\xC3\xC2\xC9\xC0\xC8\xF4\xF5\xF2\xDA\xF9\xCC\xD5\xDC\xA2\xA3\xD9\u20A7\xD3\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xD2\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",861:"\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xD0\xF0\xDE\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xFE\xFB\xDD\xFD\xD6\xDC\xF8\xA3\xD8\u20A7\u0192\xE1\xED\xF3\xFA\xC1\xCD\xD3\xDA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",862:"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",863:"\xC7\xFC\xE9\xE2\xC2\xE0\xB6\xE7\xEA\xEB\xE8\xEF\xEE\u2017\xC0\xA7\xC9\xC8\xCA\xF4\xCB\xCF\xFB\xF9\xA4\xD4\xDC\xA2\xA3\xD9\xDB\u0192\xA6\xB4\xF3\xFA\xA8\xB8\xB3\xAF\xCE\u2310\xAC\xBD\xBC\xBE\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",865:"\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xA4\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",866:"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\xB0\u2219\xB7\u221A\u2116\xA4\u25A0\xA0"};var Dh={};var kE=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376];function Kl(t,e){return e===2?t:t>=128&&t<=159?kE[t-128]:t}var BE={0:"windows-1252",1:"windows-1252",77:"macintosh",128:"shift_jis",129:"euc-kr",130:"johab",134:"gbk",136:"big5",161:"windows-1253",162:"windows-1254",163:"windows-1258",177:"windows-1255",178:"windows-1256",186:"windows-1257",204:"windows-1251",222:"windows-874",238:"windows-1250",255:"ibm437"},GE={874:"windows-874",932:"shift_jis",936:"gbk",949:"euc-kr",950:"big5",1250:"windows-1250",1251:"windows-1251",1252:"windows-1252",1253:"windows-1253",1254:"windows-1254",1255:"windows-1255",1256:"windows-1256",1257:"windows-1257",1258:"windows-1258",54936:"gb18030",65001:"utf-8"},Fh={874:"windows-874",932:"shift_jis",936:"gbk",949:"euc-kr",950:"big5"};function OE(t,e){return {codes:t.map(n=>n<128?n:e.charCodeAt(n-128)),byteLengths:t.map(()=>1)}}function lo(t,e,n){if(e===2)return {codes:[...t],byteLengths:t.map(()=>1)};let r=n?.oem;if(e===255&&(r===void 0||!(r in Fh)))return OE(t,(r!==void 0?Lh[r]:void 0)??_h);if(e===130){let i=[],a=[];for(let u=0;u<t.length;u++){let l=t[u],c=Dh[l],f=c&&u+1<t.length?c.charCodeAt(t[u+1]):65533,m=l<128||f===65533?1:2;i.push(l<128?l:f),a.push(m),u+=m-1;}return {codes:i,byteLengths:a}}let o=n?.ansi,s=e===255&&r!==void 0?Fh[r]:(e===0||e===1)&&o!==void 0?GE[o]??"windows-1252":BE[e]??"windows-1252";if(s==="windows-1252")return {codes:t.map(i=>Kl(i,e)),byteLengths:t.map(()=>1)};try{let i=new TextDecoder(s,{fatal:!0,ignoreBOM:!0}),a=new TextDecoder(s,{ignoreBOM:!0}),u=new Uint8Array(t),l=[],c=[],f=0;for(;f<t.length;){let m=null,b=1;for(let h=1;h<=Math.min(4,t.length-f);h++)try{let p=i.decode(u.subarray(f,f+h));if(p.length>0){m=p,b=h;break}}catch{}m===null&&(m=a.decode(u.subarray(f,f+1)));for(let h=0;h<m.length;h++)l.push(m.charCodeAt(h)),c.push(h===m.length-1?b:0);f+=b;}return {codes:l,byteLengths:c}}catch{return {codes:t.map(i=>Kl(i,e)),byteLengths:t.map(()=>1)}}}var NE=[0,0,.4096065,.4875311,.5515784,.6070649,.656426,.7013281,.7426686,.7811829,.8173296,.8514569,.8838279,.9147507,.9443338,.9726402],WE=[0,0,.0556662,.0852493,.1161453,.1485431,.1826704,.2188171,.2572957,.2986719,.343574,.3929351,.4483443,.5124689,.5903349,.6957428],kh=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,8,8,8,8,9,9,9,10,10,11,11,11,12,12,13,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,23,23,24,24,25,26,26,27,28,28,29,30,30,31,32,32,33,34,35,35,36,37,38,38,39,40,41,42,42,43,44,45,46,47,48,49,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,68,69,70,71,72,73,74,75,77,78,79,80,81,83,84,85,86,88,89,90,92,93,94,96,97,98,100,101,102,104,105,107,108,109,111,112,114,115,117,118,120,121,123,124,126,128,129,131,132,134,136,137,139,141,142,144,146,147,149,151,153,154,156,158,160,161,163,165,167,169,171,173,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,213,215,217,219,221,223,225,228,230,232,234,237,239,241,243,246,248,250,253,255],HE=[0,24,32,39,44,48,52,55,59,62,64,67,70,72,74,77,79,81,83,85,86,88,90,92,93,95,97,98,100,101,103,104,106,107,108,110,111,112,114,115,116,117,118,120,121,122,123,124,125,127,128,129,130,131,132,133,134,135,136,137,138,139,140,140,142,143,144,145,145,146,147,148,149,150,151,152,152,153,154,154,156,157,157,158,159,160,161,161,162,163,164,165,165,166,167,167,168,169,170,171,171,172,173,173,174,175,176,176,177,178,178,178,180,180,181,182,182,183,184,184,185,186,186,187,188,188,189,189,190,191,192,192,193,193,194,195,195,196,196,197,198,198,199,199,200,201,201,202,202,203,204,204,205,205,206,206,207,208,208,208,209,210,210,211,211,212,212,213,214,214,215,215,216,216,217,217,218,218,219,219,220,220,221,221,222,222,223,224,224,225,225,225,226,227,227,228,228,229,229,229,230,230,231,231,232,232,233,233,234,234,235,235,236,236,237,237,238,238,239,239,239,240,240,240,241,242,242,243,243,244,244,245,245,245,246,246,247,247,248,248,249,249,249,250,250,251,251,252,252,252,253,253,254,254,255,255];function Qo(t,e,n,r){return n<=1?e:n>=16?t:r?HE[Math.floor((n*kh[t]+(16-n)*kh[e])/16)]:e+Math.floor((t-e)*(t>e?NE[n]:WE[n]))}var co=2,mo=4,Wh=16,Qi=4096,ts=8192,XE=[255,255,240,233,225,217,208,199,189,178,167,154,140,124,104,77,0];function Hh(t){let e=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!e)return [0,0,0];let n=parseInt(e[1],16);return [n>>16&255,n>>8&255,n&255]}function Xh(t,e,n,r){let o=[0,0,0],s=0,i=255;for(let a=0;a<3;a++)o[a]=r(n[a],255,a),s+=1-(o[a]-r(n[a],0,a))/255,i=Math.min(i,o[a]);if(s=Math.min(1,Math.max(s/3,1-i/255)),!(s<=0)){for(let a=0;a<3;a++)t[e+a]=Math.round((o[a]-255*(1-s))/s);t[e+3]=Math.round(s*255);}}function Zl(t,e,n,r){let{left:o,top:s,right:i,bottom:a}=e;r&&(o=Math.max(o,r.left),s=Math.max(s,r.top),i=Math.min(i,r.right),a=Math.min(a,r.bottom)),!(i<=o||a<=s)&&(t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.fillStyle=n,t.fillRect(o,s,i-o,a-s),t.restore());}function Bh(t,e,n,r){t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,r&&(t.beginPath(),t.rect(r.left,r.top,r.right-r.left,r.bottom-r.top),t.clip()),t.fillStyle=n,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let o=1;o<e.length;o++)t.lineTo(e[o].x,e[o].y);t.closePath(),t.fill(),t.restore();}function Yh(t){return t>=128&&t<=159}function Gh(t,e){return !t.glyphIndices&&!(t.options&Qi)&&Yh(t.codes[e])}function $h(t,e){let n=e.codes.length,r=e.codes.map(D=>e.glyphIndices?D:t.glyphIndex(D)),o=!!e.matrix&&Math.abs(e.matrix[0])>1e-9&&Math.abs(e.matrix[1])>1e-9&&!!t.rotatedLinearAdvance,s=[];for(let D=0;D<n;D++)s.push(Gh(e,D)&&!e.dx?0:e.dx&&D<e.dx.length?e.dx[D]:e.matrix?o?t.rotatedLinearAdvance(r[D]):t.rotatedAdvance(r[D],!!e.matrix&&e.matrix[0]<0):t.advance(r[D]));!e.dx&&e.textJustification&&!e.glyphIndices&&(s=hs(s,e.codes,e.textJustification.extra,e.textJustification.count));let i=[];for(let D=0;D<n;D++)i.push(e.dy&&D<e.dy.length?e.dy[D]:0);let a=0,u=0;for(let D=0;D<n;D++)a+=s[D],u+=i[D];let l=e.matrix,c=l?l[0]:1,f=l?l[1]:0,m=l?l[2]:0,b=l?l[3]:1,h=o?D=>Math.round(D*16)/16:D=>D,p=0,d=0,x=0,y=e.textAlign&6;if(y===6?p=o?-a/2:-Math.ceil(a/2):y===2&&(p=-a),o&&y){let D=L=>{let F=Math.round(L*a*16);return (y===6?-Math.trunc(F/2):-F)/16};d=D(c),x=D(f);}let g=(D,L)=>o?{x:e.x+d+h(c*(D-p))+h(m*L),y:e.y+x+h(f*(D-p))+h(b*L)}:{x:e.x+c*D+m*L,y:e.y+f*D+b*L},M=e.textAlign&24,P=!!l&&Math.abs(l[0])>1e-9&&Math.abs(l[1])>1e-9,E=l?t.rotatedMetrics?.(l[0],l[1]):void 0,R=E?E.ascent:P?t.rotatedAscent??t.ascent:t.ascent,T=E?E.descent:P?t.rotatedDescent??t.descent:t.descent,A=M===24?0:M===8?-T:R,w=[],I=[],S=e.glyphMatrix??l,v=S?[S[0],S[1],S[2],S[3]]:void 0,C=p,U=A;for(let D=0;D<n;D++){let L=g(C,U),F=!!t.fractionalOrigins,B=F?Math.floor(L.x):Math.round(L.x),X=F?t.fractionalOrigins==="xy"?Math.round((L.x-B)*4)*16:t.fractionalOrigins==="x"?Math.round((L.x-B)*6)*(64/6):Math.round((L.x-B)*64):0,k=t.fractionalOrigins==="xy"?Math.floor(L.y):Math.round(L.y),W=t.fractionalOrigins==="xy"?Math.round((L.y-k)*4)*16:0;if(I.push({x:B+X/64,y:k+W/64,along:C,down:U}),!Gh(e,D)){let O=t.glyph(r[D],v,X,W);O.bitmap&&w.push({x:B+O.bitmap.left,y:k-O.bitmap.top,bitmap:O.bitmap});}C+=s[D],U+=i[D];}return {glyphs:r,total:a,totalY:u,startAlong:p,baseDown:A,hAlign:y,at:g,placed:w,origins:I}}function tc(t,e,n,r){let{total:s,totalY:i,startAlong:a,baseDown:u,at:l,placed:c,hAlign:m}=$h(e,n),b=n.matrix,h=b?b[0]:1,p=b?b[1]:0,d=b?b[2]:0,x=b?b[3]:1,y=n.options&mo&&n.rect?n.rect:null;if(n.options&co&&n.rect&&Zl(t,n.rect,n.bkColor,null),n.bkMode===2&&s!==0)if(b){let E=[l(a,u-e.ascent),l(a+s,u-e.ascent),l(a+s,u+e.descent),l(a,u+e.descent)];Bh(t,E,n.bkColor,y);}else {let E=Math.round(n.x+a),R=Math.round(n.y+u),T=Math.min(E,E+Math.round(s)),A=Math.max(E,E+Math.round(s));Zl(t,{left:T,top:R-e.ascent,right:A,bottom:R+e.descent},n.bkColor,y);}let g=n.bkMode===2;if(!g&&n.options&co&&n.rect&&c.length>0){let E,R,T,A;if(b){let w=[l(a,u-e.ascent),l(a+s,u-e.ascent),l(a+s,u+e.descent),l(a,u+e.descent)];E=Math.min(...w.map(I=>I.x)),T=Math.max(...w.map(I=>I.x)),R=Math.min(...w.map(I=>I.y)),A=Math.max(...w.map(I=>I.y));}else {let w=Math.round(n.x+a),I=Math.round(n.y+u);E=Math.min(w,w+Math.round(s)),T=Math.max(w,w+Math.round(s)),R=I-e.ascent,A=I+e.descent;}for(let w of c)E=Math.min(E,w.x),R=Math.min(R,w.y),T=Math.max(T,w.x+w.bitmap.width),A=Math.max(A,w.y+w.bitmap.height);g=n.rect.left<=E&&n.rect.top<=R&&n.rect.right>=T&&n.rect.bottom>=A;}if(Oh(t,c,n.textColor,e.mode!=="mono",y,g),(n.underline||n.strikeOut)&&s!==0){let E=[];n.underline&&E.push([e.underlinePosition,Math.max(1,e.underlineThickness),0]),n.strikeOut&&E.push([e.strikeoutPosition,Math.max(1,e.strikeoutThickness),e.strikeoutShift??0]);let R=!b&&n.plusBars==="snapped"&&e.exactDecorations?Ql(e.exactDecorations,n,n.x+a,n.y+u,s):null,T=0;for(let[A,w,I]of E){let S=R?.[T++];if(b){let v=[l(a,u-A),l(a+s,u-A),l(a+s,u-A+w),l(a,u-A+w)];Bh(t,v,n.textColor,y);}else {let v=Math.round(n.x+a)+I,C=Math.round(n.y+u)-A,U=S?Math.round(S.left):Math.min(v,v+Math.round(s)),D=S?Math.round(S.right):Math.max(v,v+Math.round(s));Zl(t,{left:U,top:C,right:D,bottom:C+w},n.textColor,y);}}}let M=m===6?0:m===2?-s:s,P=m===6?0:i;return {dx:h*M+d*P,dy:p*M+x*P}}function Oh(t,e,n,r,o,s=false){if(e.length===0)return;let i=1/0,a=1/0,u=-1/0,l=-1/0;for(let P of e)i=Math.min(i,P.x),a=Math.min(a,P.y),u=Math.max(u,P.x+P.bitmap.width),l=Math.max(l,P.y+P.bitmap.height);let c=t.canvas;typeof c?.width=="number"&&typeof c?.height=="number"&&(i=Math.max(i,0),a=Math.max(a,0),u=Math.min(u,c.width),l=Math.min(l,c.height)),o&&(i=Math.max(i,o.left),a=Math.max(a,o.top),u=Math.min(u,o.right),l=Math.min(l,o.bottom));let f=u-i,m=l-a;if(f<=0||m<=0||f*m>64*1024*1024)return;if(e.some(P=>P.bitmap.channels===3)){VE(t,e,n,i,a,f,m);return}let b=new Uint8Array(f*m),h=r?16:1;for(let P of e){let E=P.bitmap;for(let R=0;R<E.height;R++){let T=P.y+R-a;if(!(T<0||T>=m))for(let A=0;A<E.width;A++){let w=E.data[R*E.width+A];if(!w)continue;let I=P.x+A-i;if(I<0||I>=f)continue;let S=T*f+I;r&&b[S]?b[S]=((b[S]-1|w-1)&15)+1:w>b[S]&&(b[S]=w);}}}let p=It(f,m);if(!p)return;let[d,x,y]=Hh(n),g=new Uint8ClampedArray(f*m*4),M=null;if(r&&typeof t.getImageData=="function")try{M=Tt(t,i,a,f,m).data;}catch{M=null;}for(let P=0;P<f*m;P++){let E=b[P];if(E<=(r?1:0))continue;let R=P*4;!r||E>=h?(g[R]=d,g[R+1]=x,g[R+2]=y,g[R+3]=255):M&&M[R+3]===255?(g[R]=Qo(d,M[R],E,s),g[R+1]=Qo(x,M[R+1],E,s),g[R+2]=Qo(y,M[R+2],E,s),g[R+3]=255):M?Xh(g,R,[d,x,y],(T,A)=>Qo(T,A,E,s)):(g[R]=d,g[R+1]=x,g[R+2]=y,g[R+3]=255-XE[E]);}Ct(p.ctx,Et(g,f,m),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,le(t,p.canvas,i,a,f,m),t.restore();}function ec(t,e,n){let r=t.fontDetails,o=t.fontHeight*e;return {face:t.fontFamily,height:o<0?-Math.round(-o):Math.round(o),width:r&&r.width?Math.round(Math.abs(r.width*n)):0,weight:t.fontWeight,italic:t.fontItalic,charSet:r?r.charSet:1,pitchAndFamily:r?r.pitchAndFamily:0,quality:r?r.quality:0}}function ta(t,e,n,r){let[o,s,i,a,u,l]=r.matrix,c=Math.hypot(o,s),f=Math.hypot(i,a);if(!(c>0)||!(f>0)||r.codes.length===0)return null;let m=s===0&&i===0&&n.fontEscapementTenthDeg%3600===0,b=ec(n,f,c);m&&r.playbackStretch&&r.playbackStretch!==1&&(b.playbackStretch=r.playbackStretch);let h=e.realize(b,n.fontFamilyMap);if(!h)return null;let d=s!==0||i!==0?[o/c,s/c,i/f,a/f]:null,x=d,y=n.fontEscapementTenthDeg%3600;if(y!==0){let S=(U,D)=>{let L=[D,-U,U,D];return d?[d[0]*L[0]+d[2]*L[1],d[1]*L[0]+d[3]*L[1],d[0]*L[2]+d[2]*L[3],d[1]*L[2]+d[3]*L[3]]:L},v=bm(y),C=y/10*(Math.PI/180);x=S(v.sin,v.cos),d=S(Math.sin(C),Math.cos(C));}if(x&&r.playbackStretch&&r.playbackStretch!==1){let S=r.playbackStretch;x=[x[0]*S,x[1]*S,x[2],x[3]];}let g=(n.textAlign&1)!==0,M=g?n.curX:r.x,P=g?n.curY:r.y,E=(S,v)=>({x:o*S+i*v+u,y:s*S+a*v+l}),R=E(M,P),T=null;if(r.rect&&r.options&(co|mo)){let S=E(r.rect.left,r.rect.top),v=E(r.rect.right,r.rect.bottom);T={left:Math.round(Math.min(S.x,v.x)),top:Math.round(Math.min(S.y,v.y)),right:Math.round(Math.max(S.x,v.x)),bottom:Math.round(Math.max(S.y,v.y))};}let A={codes:r.codes,glyphIndices:r.glyphIndices,x:R.x,y:R.y,dx:r.dx?r.dx.map(S=>S*c):null,dy:r.dy?r.dy.map(S=>-S*f):null,textJustification:r.textJustification?{...r.textJustification,extra:r.textJustification.extra*c}:void 0,textAlign:n.textAlign,textColor:n.textColor,bkColor:n.bkColor,bkMode:n.bkMode,options:r.options,rect:T,matrix:d,glyphMatrix:x,underline:n.fontUnderline,strikeOut:n.fontStrikeOut},w=tc(t,h,A,n.fontFamilyMap),I=o*a-s*i;return I===0?{dx:0,dy:0}:{dx:(a*w.dx-i*w.dy)/I,dy:(-s*w.dx+o*w.dy)/I}}var jh=1.2,Nh=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,jh)+.5)),$E=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,1/jh)+.5));function Ki(t,e,n){return $E[Math.floor((Nh[t]*n+Nh[e]*(6-n)+3)/6)]}function Zi(t){return Math.round(t*6/255)}function jE(t,e,n){return Ki(t,e,Zi(n*255))}function VE(t,e,n,r,o,s,i){let a=new Uint8Array(s*i*3);for(let m of e){let b=m.bitmap,h=b.channels===3?3:1;for(let p=0;p<b.height;p++){let d=m.y+p-o;if(!(d<0||d>=i))for(let x=0;x<b.width;x++){let y=m.x+x-r;if(!(y<0||y>=s))for(let g=0;g<3;g++){let M=h===3?b.data[(p*b.width+x)*3+g]:b.data[p*b.width+x]*255,P=(d*s+y)*3+g;M>a[P]&&(a[P]=M);}}}}let u=It(s,i);if(!u)return;let l;try{l=Tt(t,r,o,s,i).data;}catch{return}let c=Hh(n),f=new Uint8ClampedArray(s*i*4);for(let m=0;m<s*i;m++){let b=a[m*3],h=a[m*3+1],p=a[m*3+2];if(!b&&!h&&!p)continue;let d=m*4;if(l[d+3]!==255){let M=[b/255,h/255,p/255];Xh(f,d,c,(P,E,R)=>jE(P,E,M[R]));continue}let x=Zi(b),y=Zi(h),g=Zi(p);x===6&&y===6&&g===6?(f[d]=c[0],f[d+1]=c[1],f[d+2]=c[2]):x||y||g?(f[d]=Ki(c[0],l[d],x),f[d+1]=Ki(c[1],l[d+1],y),f[d+2]=Ki(c[2],l[d+2],g)):(f[d]=l[d],f[d+1]=l[d+1],f[d+2]=l[d+2]),f[d+3]=255;}Ct(u.ctx,Et(f,s,i),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,le(t,u.canvas,r,o,s,i),t.restore();}function Ql(t,e,n,r,o){let s=c=>Math.ceil(Math.floor(c*512+1e-7)/512*4-1e-9)/4,i=c=>Math.ceil(c*8-1e-9)/8,a=n+o,u=(c,f)=>{let m=Math.max(1,Math.round(f)),b=s(c-(m-1)/2);return m===1?{left:n+.3,right:a+.8,top:b,bottom:b+1}:{left:i(n+.5),right:i(a+.5),top:b,bottom:b+m}},l=[];return e.underline&&l.push(u(r-t.underlinePosition,t.underlineThickness)),e.strikeOut&&l.push(u(r-t.strikeoutPosition,t.strikeoutThickness)),l}function Vh(t,e,n={}){let{placed:r,total:o,startAlong:s,baseDown:i}=$h(t,e),a=[],u=[];if(n.decorations&&e.plusBars==="fractional"&&t.exactDecorations&&!e.matrix&&o!==0&&t.mode==="gray")u.push(...Ql(t.exactDecorations,e,e.x+s,e.y+i,o));else if(n.decorations&&!e.matrix&&o!==0){let g=Math.round(e.x+s),M=g+Math.round(o),P=e.plusBars==="snapped"&&t.exactDecorations?Ql(t.exactDecorations,e,e.x+s,e.y+i,o):null,E=0,R=(T,A)=>{let w=Math.round(e.y+i)-T,I=P?.[E++],S=I?Math.round(I.left):g,v=I?Math.round(I.right):M;a.push({left:Math.min(S,v),right:Math.max(S,v),top:w,bottom:w+Math.max(1,A)});};e.underline&&R(t.underlinePosition,t.underlineThickness),e.strikeOut&&R(t.strikeoutPosition,t.strikeoutThickness);}if(r.length===0&&a.length===0&&u.length===0)return null;let l=1/0,c=1/0,f=-1/0,m=-1/0;for(let g of r)l=Math.min(l,g.x),c=Math.min(c,g.y),f=Math.max(f,g.x+g.bitmap.width),m=Math.max(m,g.y+g.bitmap.height);for(let g of a)l=Math.min(l,g.left),c=Math.min(c,g.top),f=Math.max(f,g.right),m=Math.max(m,g.bottom);for(let g of u)l=Math.min(l,Math.floor(g.left)),c=Math.min(c,Math.floor(g.top)),f=Math.max(f,Math.ceil(g.right)),m=Math.max(m,Math.ceil(g.bottom));let b=f-l,h=m-c;if(b<=0||h<=0||b*h>64*1024*1024)return null;let p=r.some(g=>g.bitmap.channels===3)?3:1,d=new Uint8ClampedArray(b*h*p),x=t.mode==="mono"?1:n.grayLevels??16;for(let g of r){let M=g.bitmap,P=M.channels===3?3:1;for(let E=0;E<M.height;E++)for(let R=0;R<M.width;R++)for(let T=0;T<p;T++){let A=P===3?M.data[(E*M.width+R)*3+T]:Math.round(M.data[E*M.width+R]*255/x),w=((g.y+E-c)*b+(g.x+R-l))*p+T;A>d[w]&&(d[w]=A);}}for(let g of a)for(let M=g.top;M<g.bottom;M++)d.fill(255,((M-c)*b+g.left-l)*p,((M-c)*b+g.right-l)*p);let y=u.length>0?new Uint8ClampedArray(b*h):void 0;for(let g of u)for(let M=Math.floor(g.top);M<Math.ceil(g.bottom);M++){let P=Math.min(M+1,g.bottom)-Math.max(M,g.top);for(let E=Math.floor(g.left);E<Math.ceil(g.right);E++){let R=Math.round(P*4)*Math.round((Math.min(E+1,g.right)-Math.max(E,g.left))*8),T=Math.round(R*255/32),A=(M-c)*b+E-l;T>y[A]&&(y[A]=T);}}return {x:l,y:c,width:b,height:h,channels:p,data:d,bars:y}}function Jh(t,e,n,r,o){let s=t.getUint32(n+64,true);if(s===0)return null;let i=e+s,a=i+r*4;if(i<0||a>o)return null;let u=[];for(let l=0;l<r;l++)u.push(t.getInt32(i+l*4,true));return u}function qE(t,e,n,r,o,s){let{ctx:i,view:a,state:u}=t,l=t.fonts;if(!l)return false;let c=a.getUint32(n+44,true),f=[];for(let M=0;M<r;M++)f.push(a.getUint16(e+o+M*2,true));let m=(c&ts)!==0,b=Jh(a,e,n,m?r*2:r,s),h=b,p=null;if(b&&m){h=[],p=[];for(let M=0;M<r;M++)h.push(b[M*2]|0),p.push(b[M*2+1]|0);}let d=a.getFloat32(n+20,true),x=a.getFloat32(n+24,true),y=a.getUint32(n+16,true)===1&&d>0&&x>0?x/d:void 0,g=ta(i,l,u,{playbackStretch:y,codes:f,glyphIndices:(c&Wh)!==0,x:a.getInt32(n+28,true),y:a.getInt32(n+32,true),options:c,rect:{left:a.getInt32(n+48,true),top:a.getInt32(n+52,true),right:a.getInt32(n+56,true),bottom:a.getInt32(n+60,true)},dx:h,dy:p,matrix:yt(t),textJustification:u.textJustification});return g?(u.textAlign&1&&(u.curX+=g.dx,u.curY+=g.dy),true):false}function JE(t){return (t&6)===6?"center":t&2?"right":"left"}function KE(t){let e=t&24;return e===24?"alphabetic":e===8?"bottom":"top"}function rc(t,e,n,r,o,s,i,a,u=null){let l=r?bs(r):t.measureText(n).width,c=r?o+fm(l,i):o;if(e.bkMode===2){let f=Ss(e,a),m=t.fillStyle;t.fillStyle=e.bkColor,t.fillRect(c,s-f,l,f),t.fillStyle=m;}if(t.fillStyle=e.textColor,r){let f=Sa(r),m=u?Sa(u):null,b=t.textAlign;t.textAlign="left";for(let h=0;h<n.length&&h<f.length;h++)t.fillText(n[h],c+f[h],s+(m?.[h]??0));t.textAlign=b;}else t.fillText(n,o,s);(e.fontUnderline||e.fontStrikeOut)&&Dm(t,e,c,s,l,a);}function Kh(t,e,n,r){let{ctx:o,view:s,state:i}=t;if(r<76)return true;let a=(i.textAlign&1)!==0,u=a?i.curX:s.getInt32(n+28,true),l=a?i.curY:s.getInt32(n+32,true),c=s.getUint32(n+36,true),f=s.getUint32(n+40,true),m=Math.min(s.byteLength,e+r);if(c===0||f===0||c>Math.floor((m-e-f)/2)||qE(t,e,n,c,f,m))return true;let b=Dn(s,e+f,c);if(b.length===0)return true;let p=jt(t)?yt(t):null,d=p?Math.hypot(p[2],p[3]):Math.abs(oe(t,1)),x=p?Math.hypot(p[0],p[1]):null;Lm(o,i,d);let y=JE(i.textAlign);o.textBaseline=KE(i.textAlign),o.textAlign=y==="center"?"center":y==="right"?"right":"left";let g=(s.getUint32(n+44,true)&ts)!==0,M=Jh(s,e,n,g?c*2:c,m),P=M&&g?M.filter((I,S)=>S%2===0):M,E=M&&g?M.filter((I,S)=>S%2===1):null,R=E?E.map(I=>p?I*d:oe(t,I)):null,T=P?P.map(I=>x!==null?I*x:qt(t,I)):null;if(!T&&i.textJustification&&!g){let I=b.split(""),S=I.map(C=>o.measureText(C).width),v=x??qt(t,1);T=hs(S,I.map(C=>C.charCodeAt(0)),i.textJustification.extra*v,i.textJustification.count);}T&&(o.textAlign="left");let A=p?Lt(t,u,l):{x:Gt(t,u),y:Ot(t,l)},w=hm(i.fontEscapementTenthDeg);if(p&&d>0&&x?(o.save(),o.translate(A.x,A.y),o.transform(p[0]/x,p[1]/x,p[2]/d,p[3]/d,0,0),w!==0&&o.rotate(w),rc(o,i,b,T,0,0,y,d,R),o.restore()):w!==0?(o.save(),o.translate(A.x,A.y),o.rotate(w),rc(o,i,b,T,0,0,y,d,R),o.restore()):rc(o,i,b,T,A.x,A.y,y,d,R),a){let I=x??qt(t,1),S=T&&I?bs(T)/I:I?o.measureText(b).width/I:0,v=y==="center"?0:y==="right"?-S:S,C=y!=="center"&&E?bs(E):0;i.curX+=v*Math.cos(w)-C*Math.sin(w),i.curY+=v*Math.sin(w)+C*Math.cos(w);}return true}function sc(t,e,n,r,o,s,i){let a=r.length,u=76,l=u+a*2+3&-4,c=i?i.length:0,f=l+c*4,m=new DataView(new ArrayBuffer(f));m.setUint32(44,a,true),m.setUint32(48,u,true),m.setUint32(52,o,true),m.setInt32(36,e,true),m.setInt32(40,n,true),m.setInt32(56,s[0],true),m.setInt32(60,s[1],true),m.setInt32(64,s[2],true),m.setInt32(68,s[3],true),m.setUint32(72,i?l:0,true);for(let h=0;h<a;h++)m.setUint16(u+h*2,r[h],true);if(i)for(let h=0;h<c;h++)m.setInt32(l+h*4,i[h],true);let b={...t,view:m};Kh(b,0,8,f);}function Zh(t,e,n,r){let{view:o}=t;return lo(Array.from({length:n},(s,i)=>o.getUint8(e+i)),r,t.codePages)}function Qh(t,e,n){if(!t)return null;let r=[],o=0;for(let s of e){let i=0,a=0;for(let u=0;u<s;u++)i+=t[o+u*(n?2:1)]??0,n&&(a+=t[o+u*2+1]??0);r.push(i),n&&r.push(a),o+=s*(n?2:1);}return r}function ZE(t,e,n,r,o){let{view:s,state:i}=t,a=Math.min(s.byteLength,e+r);if(r<40)return true;let u=s.getUint32(n+28,true),l=n+32;if(u>Math.floor((a-l)/40))return true;let c=i.fontDetails?.charSet??1;for(let f=0;f<u;f++){let m=l+f*40,b=s.getInt32(m,true),h=s.getInt32(m+4,true),p=s.getUint32(m+8,true),d=s.getUint32(m+12,true),x=s.getUint32(m+16,true),y=[s.getInt32(m+20,true),s.getInt32(m+24,true),s.getInt32(m+28,true),s.getInt32(m+32,true)],g=s.getUint32(m+36,true),M=o?2:1;if(!d||d>a-e||p>Math.floor((a-(e+d))/M))continue;let P=o?null:Zh(t,e+d,p,c),E=o?Array.from({length:p},(w,I)=>s.getUint16(e+d+I*2,true)):P.codes,R=null,T=(x&ts)!==0,A=p*(T?2:1);g&&g<=a-e&&A<=Math.floor((a-(e+g))/4)&&(R=Array.from({length:A},(w,I)=>s.getInt32(e+g+I*4,true)),o||(R=Qh(R,P.byteLengths,T))),sc(t,b,h,E,x|Qi,y,R);}return true}function QE(t,e,n,r){let{view:o}=t,s=Math.min(o.byteLength,e+r);if(r<36)return true;let i=o.getInt32(n,true),a=o.getInt32(n+4,true),u=o.getUint32(n+8,true),l=o.getUint32(n+12,true),c=(l&512)!==0,f=(l&256)!==0,m=n+28+(f?0:16);if(m>s||u>Math.floor((s-m)/(c?1:2)))return true;let b=f?[0,0,0,0]:[o.getInt32(n+28,true),o.getInt32(n+32,true),o.getInt32(n+36,true),o.getInt32(n+40,true)],h=c?Array.from({length:u},(p,d)=>o.getUint8(m+d)):Array.from({length:u},(p,d)=>o.getUint16(m+d*2,true));return sc(t,i,a,h,l,b,null),true}function tp(t,e,n,r,o){if(e===84)return Kh(t,n,r,o);if(e===83||e===96||e===97||e===108){if(e===96||e===97)return ZE(t,n,r,o,e===97);if(e===108)return QE(t,n,r,o);let{view:s,state:i}=t,a=Math.min(s.byteLength,n+o);if(o<76)return true;let u=s.getInt32(r+28,true),l=s.getInt32(r+32,true),c=s.getUint32(r+36,true),f=s.getUint32(r+40,true),m=s.getUint32(r+44,true);if(!f||f>a-n||c>a-(n+f))return true;let b=Zh(t,n+f,c,i.fontDetails?.charSet??1),h=[s.getInt32(r+48,true),s.getInt32(r+52,true),s.getInt32(r+56,true),s.getInt32(r+60,true)],p=s.getUint32(r+64,true),d=null,x=(m&ts)!==0,y=c*(x?2:1);return p&&p<=a-n&&y<=Math.floor((a-(n+p))/4)&&(d=Array.from({length:y},(g,M)=>s.getInt32(n+p+M*4,true)),d=Qh(d,b.byteLengths,x)),sc(t,u,l,b.codes,m,h,d),true}return false}function Er(t,e,n){let r=Xu(n==="replace"?null:t.clipRegion??null,e,n,{x:0,y:0,w:t.canvasW,h:t.canvasH});r.exact||$(`gdiCombineClip: '${n}' approximated (region exceeds the scanline domain)`),t.clipRegion=r.region,We(t,r.region);}function ep(t,e){let{view:n}=t,r=n.getInt32(e,true),o=n.getInt32(e+4,true),s=n.getInt32(e+8,true),i=n.getInt32(e+12,true);return j0(Gt(t,r),Ot(t,o),qt(t,s-r),oe(t,i-o))}function o3(t,e,n){return n>=24&&Er(t,ep(t,e),"intersect"),true}function s3(t,e,n){return n>=24&&Er(t,ep(t,e),"exclude"),true}var ic={1:"intersect",2:"union",3:"xor",4:"exclude",5:"replace"};function i3(t,e,n){let{view:r}=t;if(n<16)return true;let o=r.getUint32(e,true),s=r.getUint32(e+4,true),i=ic[s];if(!i)return true;if(o===0)return i==="replace"&&(t.clipRegion=null,We(t,null),$("EMR_EXTSELECTCLIPRGN: RGN_COPY with empty region: clip reset")),true;let a=e+8;if(o<32)return true;let u=r.getUint32(a+8,true);if(u===0)return true;let l=[],c=a+32;for(let f=0;f<u;f++){let m=c+f*16;if(m+16>e+8+o)break;let b=r.getInt32(m,true),h=r.getInt32(m+4,true),p=r.getInt32(m+8,true),d=r.getInt32(m+12,true),x=rl(t,b),y=ol(t,h);l.push({x,y,w:rl(t,p)-x,h:ol(t,d)-y});}return l.length===0||(Er(t,sn(l),i),$(`EMR_EXTSELECTCLIPRGN: mode=${s} (${i}) with ${l.length} rect(s)`)),true}function a3(t,e,n){if(n>=16){let r=t.view.getInt32(e,true),o=t.view.getInt32(e+4,true);if(t.clipRegion){let s=Pn(t),i=Rn(t),a=Math.round(qt(t,r)/s)*s,u=Math.round(oe(t,o)/i)*i;t.clipRegion=ir(t.clipRegion,a,u),We(t,t.clipRegion);}}return true}function np(t,e,n,r){switch(e){case 30:return o3(t,n,r);case 75:return i3(t,n,r);case 29:return s3(t,n,r);case 26:return a3(t,n,r);default:return false}}var l3=1;function c3(t,e,n){let r=new Uint8Array(e*n);if(!t.clipRegion)return r.fill(1),r;for(let o of Qn(t.clipRegion,null,"intersect",{x:0,y:0,w:e,h:n}))for(let s=Math.max(0,o.y);s<Math.min(n,o.y+o.h);s++)r.fill(1,s*e+Math.max(0,o.x),s*e+Math.min(e,o.x+o.w));return r}function m3(t,e,n,r,o,s,i){let a=new zt,u=(m,b)=>{let h=b*e+m;return i[h]===1&&s(t[h*4]<<16|t[h*4+1]<<8|t[h*4+2])};if(r<0||o<0||r>=e||o>=n||!u(r,o))return a;let l=new Uint8Array(e*n),c=[r,o],f=[];for(;c.length>0;){let m=c.pop(),b=c.pop();if(l[m*e+b]||!u(b,m))continue;let h=b;for(;h>0&&!l[m*e+h-1]&&u(h-1,m);)h--;let p=b+1;for(;p<e&&!l[m*e+p]&&u(p,m);)p++;l.fill(1,m*e+h,m*e+p),f.push([m,h,p]);for(let d of [m-1,m+1]){if(d<0||d>=n)continue;let x=false;for(let y=h;y<p;y++){let g=!l[d*e+y]&&u(y,d);g&&!x&&c.push(y,d),x=g;}}}f.sort((m,b)=>m[0]-b[0]||m[1]-b[1]);for(let[m,b,h]of f)a.add(m,b,h);return a}function rp(t,e,n,r){if(e!==53)return false;if(r<24)return true;let{ctx:o,view:s,state:i}=t;if(typeof o.getImageData!="function")return true;let a=Je(t);if(!a)return true;let u=t.canvasW,l=t.canvasH,[c,f]=dt(t,s.getInt32(n,true),s.getInt32(n+4,true)),m=Wo(s.getUint32(n+8,true),Ve(i)),b=s.getUint32(n+12,true)===l3,h;try{h=Tt(o,0,0,u,l).data;}catch{return true}let p=m3(h,u,l,Math.round(c/16),Math.round(f/16),b?d=>d===m:d=>d!==m,c3(t,u,l));return se(t,p,a,i.rop2),true}var b3=0,op=1,ap=2;function h3(t,e,n,r){let o=Math.floor((e-t)*65536/r);return Math.floor((t*65536+o*n)/65536)>>8}function p3(t,e){let n=Kn([t.flatMap(m=>[m.x,m.y])],false);if(n.length===0)return;let[r,o,s]=t.map(m=>({x:m.x/16,y:m.y/16,c:m.c.map(b=>Math.min(b,65280))})),i=(o.x-r.x)*(s.y-r.y)-(s.x-r.x)*(o.y-r.y);if(i===0)return;let a=[0,1,2].map(m=>((o.c[m]-r.c[m])*(s.y-r.y)-(s.c[m]-r.c[m])*(o.y-r.y))/i),u=[0,1,2].map(m=>((s.c[m]-r.c[m])*(o.x-r.x)-(o.c[m]-r.c[m])*(s.x-r.x))/i),l=a.map(m=>Math.floor(m*65536)),c=n.data,f=c[0];for(let m=0;m<n.length*3;m+=3){let b=c[m],h=c[m+1],p=c[m+2];if(b<e.y||b>=e.y+e.h)continue;let d=[0,1,2].map(x=>r.c[x]+a[x]*(h-r.x)+u[x]*(b-r.y)+(b===f?0:.5));for(let x=Math.max(h,e.x);x<Math.min(p,e.x+e.w);x++){let y=0;for(let g=0;g<3;g++){let M=Math.floor(d[g]+l[g]*(x-h)/65536+1e-9)>>8;y=y<<8|Math.max(0,Math.min(255,M));}e.rgb[(b-e.y)*e.w+(x-e.x)]=y;}}}function d3(t,e,n){let{view:r}=t;if(n<36)return null;let o=r.getUint32(e+16,true),s=r.getUint32(e+20,true),i=r.getUint32(e+24,true),a=i===ap?3:2,u=e+28,l=u+o*16;if(o>1e6||s>1e6||l+s*a*4>e-8+n)return null;let c=[];for(let m=0;m<o;m++){let b=u+m*16,[h,p]=dt(t,r.getInt32(b,true),r.getInt32(b+4,true));c.push({x:h,y:p,c:[r.getUint16(b+8,true),r.getUint16(b+10,true),r.getUint16(b+12,true)]});}let f=[];for(let m=0;m<s;m++){let b=[];for(let h=0;h<a;h++)b.push(r.getUint32(l+(m*a+h)*4,true));b.every(h=>h<o)&&f.push(b);}return {mode:i,vertices:c,mesh:f}}function sp(t,e){let n=Math.max(0,e.x),r=Math.max(0,e.y),o=Math.min(t.canvasW,e.x+e.w),s=Math.min(t.canvasH,e.y+e.h);if(o<=n||s<=r)return;let i=o-n,a=s-r,u=new Uint8ClampedArray(i*a*4),l=false;for(let f=0;f<a;f++)for(let m=0;m<i;m++){let b=e.rgb[(f+r-e.y)*e.w+(m+n-e.x)];if(b<0)continue;let h=(f*i+m)*4;u[h]=b>>16&255,u[h+1]=b>>8&255,u[h+2]=b&255,u[h+3]=255,l=true;}let c=l?ze(i,a):null;c&&qe(t.ctx,{x:n,y:r,w:i,h:a},c,Et(u,i,a));}function x3(t,e,n){let r=Math.round(t.x/16),o=Math.round(t.y/16),s=Math.round(e.x/16),i=Math.round(e.y/16),a=(n?o<=i:r<=s)?t:e;return {l:Math.min(r,s),t:Math.min(o,i),r:Math.max(r,s),b:Math.max(o,i),first:a,second:a===t?e:t}}function up(t,e,n,r){if(e!==118)return false;let o=d3(t,n,r);if(!o)return true;let{ctx:s}=t;if(o.mode===b3||o.mode===op){let i=o.mode===op;for(let[u,l]of o.mesh){let c=x3(o.vertices[u],o.vertices[l],i),f=c.r-c.l,m=c.b-c.t;if(f<=0||m<=0)continue;let b=Math.max(c.l,0),h=Math.max(c.t,0),p=Math.min(c.r,t.canvasW),d=Math.min(c.b,t.canvasH);if(p<=b||d<=h)continue;let x={x:b,y:h,w:p-b,h:d-h,rgb:new Int32Array((p-b)*(d-h))},y=i?m:f,g=[];for(let M=i?h-c.t:b-c.l;M<(i?d-c.t:p-c.l);M++){let P=0;for(let E=0;E<3;E++)P=P<<8|Math.max(0,Math.min(255,h3(c.first.c[E],c.second.c[E],M,y)));g.push(P);}for(let M=0;M<x.h;M++)for(let P=0;P<x.w;P++)x.rgb[M*x.w+P]=g[i?M:P];sp(t,x);}return true}if(o.mode===ap)for(let i of o.mesh){let a=i.map(p=>o.vertices[p]),u=a.map(p=>p.x/16),l=a.map(p=>p.y/16),c=Math.max(0,Math.floor(Math.min(...u))-1),f=Math.max(0,Math.floor(Math.min(...l))-1),m=Math.min(t.canvasW,Math.ceil(Math.max(...u))+1),b=Math.min(t.canvasH,Math.ceil(Math.max(...l))+1);if(m<=c||b<=f)continue;let h={x:c,y:f,w:m-c,h:b-f,rgb:new Int32Array((m-c)*(b-f)).fill(-1)};p3(a,h),sp(t,h);}return true}var E3=6;function ac(t,e,n){let r=[];if(n<32||e+32>t.byteLength)return r;let o=t.getUint32(e+8,true),s=Math.min(t.byteLength,e+n);for(let i=0;i<o;i++){let a=e+32+i*16;if(a+16>s)break;r.push([t.getInt32(a,true),t.getInt32(a+4,true),t.getInt32(a+8,true),t.getInt32(a+12,true)]);}return r}function uc(t,e){let n=new zt;if(jt(t)){let r=e.map(([o,s,i,a])=>[...dt(t,o,s),...dt(t,i,s),...dt(t,i,a),...dt(t,o,a)]);return Kn(r,true,n)}for(let[r,o,s,i]of e){let a=Math.round(Gt(t,r)),u=Math.round(Gt(t,s)),l=Math.round(Ot(t,o)),c=Math.round(Ot(t,i)),f=Math.min(a,u),m=Math.max(a,u);for(let b=Math.min(l,c);b<Math.max(l,c);b++)n.add(b,f,m);}return n}function P3(t,e,n){let r=new zt,o=t.bounds();if(!o)return r;let s=o.x1-o.x0,i=o.y1-o.y0,a=new Uint8Array(s*i),u=t.data;for(let f=0;f<t.length*3;f+=3)a.fill(1,(u[f]-o.y0)*s+u[f+1]-o.x0,(u[f]-o.y0)*s+u[f+2]-o.x0);let l=new Uint8Array(s*i);for(let f=0;f<i;f++)for(let m=0;m<s;m++){let b=1;for(let h=-e;h<=e&&b;h++){let p=m+h;b=p>=0&&p<s?a[f*s+p]:0;}l[f*s+m]=b;}let c=(f,m)=>{for(let b=-n;b<=n;b++){let h=m+b;if(h<0||h>=i||!l[h*s+f])return false}return true};for(let f=0;f<i;f++){let m=-1;for(let b=0;b<=s;b++){let h=b<s&&a[f*s+b]===1&&!c(b,f);h&&m<0?m=b:!h&&m>=0&&(r.add(f+o.y0,m+o.x0,b+o.x0),m=-1);}}return r}function cp(t,e){let n=e>=2147483648?vs(e-2147483648):t.objectTable.get(e)??null;return n&&n.kind==="brush"?n:null}function lc(t,e,n){let{state:r}=t,o={style:r.brushStyle,color:r.brushColor,pattern:r.brushPattern};n&&(r.brushStyle=n.style,r.brushColor=n.colorRef!==void 0?de(r,n.colorRef):n.color,r.brushPattern=n.pattern??null);try{let s=Je(t);s&&se(t,e,s,r.rop2);}finally{r.brushStyle=o.style,r.brushColor=o.color,r.brushPattern=o.pattern;}}function mp(t,e,n,r){let{view:o}=t;switch(e){case 71:{if(r>=32){let s=o.getUint32(n+16,true),i=cp(t,o.getUint32(n+20,true));i&&lc(t,uc(t,ac(o,n+24,s)),i);}return true}case 72:{if(r>=40){let s=o.getUint32(n+16,true),i=cp(t,o.getUint32(n+20,true)),a=Math.round(Math.abs(qt(t,o.getInt32(n+24,true)))),u=Math.round(Math.abs(oe(t,o.getInt32(n+28,true))));if(i){let l=uc(t,ac(o,n+32,s));lc(t,P3(l,a,u),i);}}return true}case 73:case 74:{if(r>=24){let s=o.getUint32(n+16,true),i=uc(t,ac(o,n+20,s));e===73?se(t,i,{kind:"solid",rgb:0},E3):lc(t,i,null);}return true}default:return false}}function fp(t,e,n,r,o){return tp(t,e,n,r,o)||vh(t,e,n,r,o)||Uh(t,e,n,r,o)||np(t,e,r,o)||mp(t,e,r,o)||rp(t,e,r,o)||up(t,e,r,o)}function ea(t,e,n,r,o){return zb(t,e,r,o)||fp(t,e,n,r,o)}function R3(t,e,n,r,o,s,i){let{view:a}=e,u=0;for(let l=0;l<o;l++){let c=a.getUint32(r+l*4,true);for(let f=0;f<c&&u<s;f++){let m=n(u);f===0?t.moveTo(m.x,m.y):t.lineTo(m.x,m.y),u++;}i&&t.closePath();}}function bp(t,e,n,r,o,s,i){let{view:a}=e,u=0;for(let l=0;l<o;l++){let c=a.getUint32(r+l*4,true);for(let f=0;f<c&&u<s;f++){let[m,b]=n(u),[h,p]=dt(e,m,b);f===0?t.moveTo(h,p):t.lineTo(h,p),u++;}i&&c>0&&t.closeFigure();}}function na(t,e,n,r,o,s){let{view:i,state:a,inPath:u}=t,l=i.getUint32(n+16,true),c=i.getUint32(n+20,true);if(l===0||l>=1e4||c>=1e5)return;let f=n+24,m=f+l*4;if(m+c*o>e+r)return;let b=d=>o===8?[i.getInt32(m+d*8,true),i.getInt32(m+d*8+4,true)]:[i.getInt16(m+d*4,true),i.getInt16(m+d*4+2,true)],h=d=>{let[x,y]=b(d);return Lt(t,x,y)},p=d=>{R3(d,t,h,f,l,c,s);};if(u){p(ke(t)),t.rasterPath??(t.rasterPath=new St),bp(t.rasterPath,t,b,f,l,c,s);return}t.lineStyle={pos:0},Jt(t,{build:d=>{d.beginPath(),p(d);},raster:()=>{let d=new St;return bp(d,t,b,f,l,c,s),d},fill:s,stroke:true,fillRule:a.polyFillMode===2?"nonzero":"evenodd"});}function hp(t,e,n,r){na(t,e,n,r,8,true);}function pp(t,e,n,r){na(t,e,n,r,8,false);}function dp(t,e,n,r){na(t,e,n,r,4,false);}function xp(t,e,n,r){na(t,e,n,r,4,true);}function Ap(t,e,n,r,o){let{state:s,inPath:i}=t,{polygon:a,bezier:u,to:l}=o,c=h=>{let[p,d]=r(h);return Lt(t,p,d)},f=h=>{if(!l){let d=c(0);h.moveTo(d.x,d.y);}let p=l?0:1;if(u)for(;p+2<n;){let d=c(p),x=c(p+1),y=c(p+2);h.bezierCurveTo(d.x,d.y,x.x,x.y,y.x,y.y),p+=3;}else for(;p<n;p++){let d=c(p);h.lineTo(d.x,d.y);}a&&h.closePath();},m=h=>{let[p,d]=r(h);return dt(t,p,d)},b=(h,p)=>{let d=0;if(l)p&&h.moveTo(p[0],p[1]);else {let x=m(0);h.moveTo(x[0],x[1]),d=1;}if(u)for(;d+2<n;d+=3){let x=m(d),y=m(d+1),g=m(d+2);h.bezierTo(x[0],x[1],y[0],y[1],g[0],g[1]);}else for(;d<n;d++){let x=m(d);h.lineTo(x[0],x[1]);}a&&h.closeFigure();};if(i)l&&oo(t),f(ke(t)),t.rasterPath??(t.rasterPath=new St),b(t.rasterPath,null);else {let h=l?In(t):null,p=l?Lt(t,s.curX,s.curY):null;t.lineStyle={pos:0},Jt(t,{build:d=>{d.beginPath(),p&&d.moveTo(p.x,p.y),f(d);},raster:()=>{let d=new St;return b(d,h),d},fill:a,stroke:true,fillRule:s.polyFillMode===2?"nonzero":"evenodd"});}if(l&&n>0){let[h,p]=r(n-1);s.curX=h,s.curY=p,t.curFix=void 0;}}function N3(t,e,n,r,o){let{view:s}=t;if(o<28)return true;let i=s.getUint32(r+16,true),a=r+20;return i===0||a+i*8>n+o||Ap(t,e,i,u=>[s.getInt32(a+u*8,true),s.getInt32(a+u*8+4,true)],{polygon:e===3,bezier:e===2||e===5,to:e===5||e===6}),true}function W3(t,e,n,r,o){let{view:s}=t;if(o<28)return true;let i=s.getUint32(r+16,true),a=r+20;return i===0||a+i*4>n+o||Ap(t,e,i,u=>[s.getInt16(a+u*4,true),s.getInt16(a+u*4+2,true)],{polygon:e===86,bezier:e===85||e===88,to:e===88||e===89}),true}var cc=1,H3=2,X3=4,yp=6;function gp(t,e,n,r,o){let{view:s,state:i,inPath:a}=t;if(r<28)return;let u=s.getUint32(n+16,true),l=n+20,c=l+u*o;if(u===0||u>1e6||c+u>e+r)return;let f=x=>o===8?[s.getInt32(l+x*8,true),s.getInt32(l+x*8+4,true)]:[s.getInt16(l+x*4,true),s.getInt16(l+x*4+2,true)],m=x=>s.getUint8(c+x),b=(x,y,g,M)=>{let P=false,E=()=>{P||(M&&x?.moveTo(M.x,M.y),g&&y?.moveTo(g[0],g[1]),P=true);};for(let R=0;R<u;R++){let A=m(R)&~cc;if(A===yp){let[w,I]=f(R),S=Lt(t,w,I),v=dt(t,w,I);x?.moveTo(S.x,S.y),y?.moveTo(v[0],v[1]),P=true;continue}if(A===H3){E();let[w,I]=f(R),S=Lt(t,w,I),v=dt(t,w,I);x?.lineTo(S.x,S.y),y?.lineTo(v[0],v[1]);}else if(A===X3&&R+2<u){E();let w=[0,1,2].map(v=>f(R+v)),I=w.map(([v,C])=>Lt(t,v,C)),S=w.map(([v,C])=>dt(t,v,C));x?.bezierCurveTo(I[0].x,I[0].y,I[1].x,I[1].y,I[2].x,I[2].y),y?.bezierTo(S[0][0],S[0][1],S[1][0],S[1][1],S[2][0],S[2][1]),R+=2;}else continue;m(R)&cc&&(x?.closePath(),y?.closeFigure());}},h=(m(0)&~cc)===yp;if(a)h||oo(t),t.rasterPath??(t.rasterPath=new St),b(ke(t),t.rasterPath,null,null);else {let x=h?null:In(t),y=h?null:Lt(t,i.curX,i.curY);t.lineStyle={pos:0},Jt(t,{build:g=>{g.beginPath(),b(g,null,null,y);},raster:()=>{let g=new St;return b(null,g,x,null),g},fill:false,stroke:true});}let[p,d]=f(u-1);i.curX=p,i.curY=d,t.curFix=void 0;}function Y3(t){let e=[];for(let n of t)n.op==="moveTo"&&e.length>0&&e.push({op:"closePath"}),e.push(n);return e.length>0&&e.push({op:"closePath"}),e}function mc(t,e,n){let{state:r}=t,o=e&&n,s=o?Y3(t.pathCmds):t.pathCmds,i=u=>{u.beginPath(),Pb(u,s);},a=t.rasterPath??new St;if(o){let u=new St;u.append(a);for(let l of u.figures)l.closed=true;a=u;}Jt(t,{build:i,raster:()=>a,fill:e,stroke:n,fillRule:r.polyFillMode===2?"nonzero":"evenodd"});}function es(t){t.pathCmds=[],t.rasterPath=new St;}function wp(t){let e=[];for(let n of t.rasterPath?.figures??[]){for(let r=0;r+1<n.pts.length;r+=2)e.push({op:r===0?"moveTo":"lineTo",x:n.pts[r]/16,y:n.pts[r+1]/16});n.closed&&e.push({op:"closePath"});}t.pathCmds=e;}function $3(t){if(!(t.inPath||!t.rasterPath)){for(let e of t.rasterPath.figures)delete e.tangents,delete e.curveSegs,delete e.roundWiden;wp(t);}}function j3(t){let{state:e}=t;if(t.inPath||!t.rasterPath||(e.penStyle&15)===5)return;let n=xe(t)?{width:16,cap:"round",join:"round",miterLimit:e.miterLimit??10}:yl(t),r=Ho(t.rasterPath,n),o=new St;for(let s of r)if(!(s.length<4)){o.moveTo(s[0],s[1]);for(let i=2;i+1<s.length;i+=2)o.lineTo(s[i],s[i+1]);o.closeFigure();}t.rasterPath=o,wp(t);}function oa(t,e,n,r,o){let{ctx:s,state:i}=t;switch(e){case 4:case 3:case 2:case 5:case 6:return N3(t,e,n,r,o);case 87:case 86:case 85:case 88:case 89:return W3(t,e,n,r,o);case 7:return o>=28&&pp(t,n,r,o),true;case 8:return o>=28&&hp(t,n,r,o),true;case 91:return o>=28&&xp(t,n,r,o),true;case 56:return gp(t,n,r,o,8),true;case 92:return gp(t,n,r,o,4),true;case 90:return o>=28&&dp(t,n,r,o),true;case 59:return t.inPath=true,t.pathCmds=[],t.rasterPath=new St,s.beginPath(),true;case 60:return t.inPath=false,true;case 61:return s.closePath(),t.inPath&&(t.pathCmds.push({op:"closePath"}),t.rasterPath?.closeFigure()),true;case 62:return mc(t,true,false),es(t),true;case 63:return mc(t,true,true),es(t),true;case 64:return mc(t,false,true),es(t),true;case 65:return $3(t),true;case 66:return j3(t),true;case 68:return t.inPath=false,es(t),s.beginPath(),true;case 67:{let a=o>=12?t.view.getUint32(r,true):5,u=ic[a];if(t.inPath||!t.rasterPath||t.rasterPath.figures.length===0)return true;if(!u)return true;let l=cl(Ir(t.rasterPath,i.polyFillMode===2)),c=l.length>0?sn(l):Le();return Er(t,c,u),es(t),true}default:return false}}var fP=new Set([16,99,100,101,102,103,104,105,106,109,110,111,112,113,119,121,122]);function Ip(t,e,n,r){let{view:o,state:s}=t;switch(e){case 120:{if(r>=16){let i=o.getInt32(n,true),a=o.getInt32(n+4,true);s.textJustification=i!==0&&a>0?{extra:i,count:a}:void 0;}return true}case 23:{let i=r>=8+oh?uh(o,n):null;return i?s.colorAdjustment=i:$("EMR_SETCOLORADJUSTMENT: invalid COLORADJUSTMENT ignored"),true}default:return fP.has(e)?(true):false}}function vp(t,e,n,r){let{view:o,state:s}=t;switch(e){case 38:{if(r>=28){let i=o.getUint32(n,true),a=o.getUint32(n+4,true),u=o.getInt32(n+8,true),l=Xn(o,n+16),c=de(s,l);t.objectTable.set(i,{kind:"pen",style:a&255,widthX:u,color:c,flags:a,...No(l)?{colorRef:l}:{}});}return true}case 95:{if(r>=52){let i=o.getUint32(n,true),a=o.getUint32(n+20,true),u=o.getInt32(n+24,true),l=Xn(o,n+32),c=de(s,l),f=o.getUint32(n+40,true),m=[];if((a&15)===7)for(let b=0;b<f&&b<16&&52+b*4+4<=r;b++)m.push(o.getUint32(n+44+b*4,true));t.objectTable.set(i,{kind:"pen",style:a&15,widthX:u,color:c,flags:a,extended:true,...No(l)?{colorRef:l}:{},...m.length>0?{userStyle:m}:{}});}return true}case 39:{if(r>=24){let i=o.getUint32(n,true),a=o.getUint32(n+4,true),u=Xn(o,n+8),l=de(s,u),c=o.getUint32(n+12,true);t.objectTable.set(i,{kind:"brush",style:a,color:l,...No(u)?{colorRef:u}:{},...a===2&&c<=5?{pattern:{kind:"hatch",hatch:c}}:{}});}return true}case 93:case 94:{if(r>=32){let i=o.getUint32(n,true),a=e===93,u=o.getUint32(n+4,true),l=mm(o,n-8,n,a,u===1?Ve(s):null);t.objectTable.set(i,{kind:"brush",style:l?a?3:6:0,color:"#808080",...l?{pattern:l}:{}});}return true}case 82:{if(r>=332){let i=o.getUint32(n,true),a=o.getInt32(n+4,true),u=o.getInt32(n+8,true),l=o.getInt32(n+12,true),c=o.getInt32(n+16,true),f=o.getInt32(n+20,true),m=o.getUint8(n+24),b=o.getUint8(n+25),h=o.getUint8(n+26),p=o.getUint8(n+27),d=o.getUint8(n+30),x=o.getUint8(n+31),y=Dn(o,n+32,32)||"sans-serif";t.objectTable.set(i,{kind:"font",height:a,weight:f,italic:m!==0,underline:b!==0,strikeOut:h!==0,family:y,escapementTenthDeg:l,details:{width:u,orientationTenthDeg:c,charSet:p,quality:d,pitchAndFamily:x}});}return true}case 37:{if(r>=12){let i=o.getUint32(n,true),a=i>=2147483648?vs(i-2147483648):t.objectTable.get(i)??null;if(a)switch(a.kind){case "pen":s.penStyle=a.style,s.penWidth=a.widthX,s.penColor=a.colorRef!==void 0?de(s,a.colorRef):a.color,Jr(s,"pen",a.colorRef),s.penFlags=a.flags??a.style,s.penUserStyle=a.userStyle,s.penExtended=a.extended===true;break;case "brush":s.brushStyle=a.style,s.brushColor=a.colorRef!==void 0?de(s,a.colorRef):a.color,Jr(s,"brush",a.colorRef),s.brushPattern=a.pattern??null;break;case "font":s.fontHeight=a.height,s.fontWeight=a.weight,s.fontItalic=a.italic,s.fontUnderline=a.underline,s.fontStrikeOut=a.strikeOut,s.fontFamily=a.family,s.fontEscapementTenthDeg=a.escapementTenthDeg??0,s.fontDetails=a.details;break}}return true}case 40:return r>=12&&t.objectTable.delete(o.getUint32(n,true)),true;default:return false}}function dc(t){return {...t.dpi?{dpi:{...t.dpi}}:{},mode:t.mode,winOrg:{...t.winOrg},winExt:{...t.winExt},vpOrg:{...t.vpOrg},vpExt:{...t.vpExt}}}var MP={2:254,3:2540,4:100,5:1e3,6:1440};function fo(t){if(t.mode!==7||!t.winExt.cx||!t.winExt.cy)return;let e=Math.abs(t.vpExt.cx/t.winExt.cx)/(t.dpi?.x??96),n=Math.abs(t.vpExt.cy/t.winExt.cy)/(t.dpi?.y??96);if(e>n){let r=t.vpExt.cx>=0?1:-1;t.vpExt.cx=Math.floor(t.vpExt.cx*n/e+.5)||r;}else if(n>e){let r=t.vpExt.cy>=0?1:-1;t.vpExt.cy=Math.floor(t.vpExt.cy*e/n+.5)||r;}}function ia(t,e){if(e<1||e>8)return;let n=MP[e===7?2:e];e===1?(t.winExt={cx:1,cy:1},t.vpExt={cx:1,cy:1}):n!==void 0&&(e!==7||t.mode!==7)&&(t.winExt={cx:n,cy:n},t.vpExt={cx:t.dpi?.x??96,cy:-(t.dpi?.y??96)}),t.mode=e;}function Pr(t){return t.mode===7||t.mode===8}function Cp(t,e,n){!Pr(t)||e===0||n===0||(t.winExt={cx:e,cy:n},fo(t));}function Up(t,e,n){!Pr(t)||e===0||n===0||(t.vpExt={cx:e,cy:n},fo(t));}function sa(t,e,n){let r=Math.imul(t,e);return r===-2147483648&&n===-1?0:Math.trunc(r/n)}function aa(t,e,n,r,o){if(!Pr(t)||!n||!o)return;let s=sa(t.winExt.cx,e,n),i=sa(t.winExt.cy,r,o);s===0||i===0||(t.winExt={cx:s,cy:i},fo(t));}function ua(t,e,n,r,o){if(!Pr(t)||!n||!o)return;let s=sa(t.vpExt.cx,e,n),i=sa(t.vpExt.cy,r,o);s===0||i===0||(t.vpExt={cx:s,cy:i},fo(t));}function xc(t,e,n,r,o=0){t.wmfLayoutRtl=o>0,t.useMappingMode=true,t.windowOrg={x:e.winOrg.x,y:e.winOrg.y},t.windowExt={cx:e.winExt.cx||1,cy:e.winExt.cy||1},t.viewportOrg={x:e.vpOrg.x*n,y:e.vpOrg.y*r},t.viewportExt={cx:(e.vpExt.cx||1)*n,cy:(e.vpExt.cy||1)*r},o>0&&(t.viewportOrg.x=o*n-t.viewportOrg.x,t.viewportExt.cx=-t.viewportExt.cx);}function EP(t,e){let n={mode:null,winExt:null,vpExt:null},r=e,o=0;for(;r+6<=t.byteLength&&o++<1e6;){let s=t.getUint32(r,true)*2,i=t.getUint16(r+4,true);if(s<6||r+s>t.byteLength||i===0)break;let a=r+6;i===259&&s>=8&&n.mode===null?n.mode=t.getUint16(a,true):i===524&&s>=10&&!n.winExt?n.winExt={cy:t.getInt16(a,true),cx:t.getInt16(a+2,true)}:i===526&&s>=10&&!n.vpExt&&(n.vpExt={cy:t.getInt16(a,true),cx:t.getInt16(a+2,true)}),r+=s;}return n}function la(t,e,n){let r=p=>typeof p=="number"&&Number.isFinite(p)&&p>0?p:96,o={x:r(typeof n=="number"?n:n?.x),y:r(typeof n=="number"?n:n?.y)},s=n===void 0?{}:{dpi:o},i=e.boundsRight-e.boundsLeft,a=e.boundsBottom-e.boundsTop;if(e.placeable!==false){let p=e.unitsPerInch>0?e.unitsPerInch:96,d=Math.max(1,Math.round(Math.abs(i)*o.x/p)),x=Math.max(1,Math.round(Math.abs(a)*o.y/p));return {width:d,height:x,mapping:{...s,mode:8,winOrg:{x:e.boundsLeft,y:e.boundsTop},winExt:{cx:i||1,cy:a||1},vpOrg:{x:0,y:0},vpExt:{cx:d,cy:x}}}}let u=EP(t,e.headerSize),c=(u.mode===7||u.mode===8)&&u.vpExt?u.vpExt:u.winExt,f=Math.abs(c?c.cx:i),m=Math.abs(c?c.cy:a),b=Math.max(1,f||1),h=Math.max(1,m||1);return {width:b,height:h,mapping:{...s,mode:8,winOrg:{x:0,y:0},winExt:{cx:b,cy:h},vpOrg:{x:0,y:0},vpExt:{cx:b,cy:h}}}}function UP(t){if(t.byteLength<88||t.getUint32(0,true)!==1)return;let e=t.getInt32(72,true),n=t.getInt32(76,true),r=t.getInt32(80,true),o=t.getInt32(84,true);if(!(e<=0||n<=0||r<=0||o<=0))return {x:e*25.4/r,y:n*25.4/o}}function yc(t){let e=UP(t.view);return {...e?{dpi:e}:{},mode:t.mapMode??1,winOrg:t.windowOrg,winExt:{...t.windowExt},vpOrg:t.viewportOrg,vpExt:{...t.viewportExt}}}function gc(t,e){t.mapMode=e.mode,t.windowExt=e.winExt,t.viewportExt=e.vpExt;}function Lp(t,e,n,r){let o=yc(t);!Pr(o)||n===0||r===0||(e?o.vpExt={cx:n,cy:r}:o.winExt={cx:n,cy:r},fo(o),gc(t,o),Kr(t));}function _P(t,e,n,r,o,s){let i=yc(t);!Pr(i)||!r||!s||((e?ua:aa)(i,n,r,o,s),!(t.windowExt.cx===i.winExt.cx&&t.windowExt.cy===i.winExt.cy&&t.viewportExt.cx===i.vpExt.cx&&t.viewportExt.cy===i.vpExt.cy)&&(gc(t,i),Kr(t)));}function LP(t,e,n,r){let{view:o}=t;switch(e){case 9:return r>=16&&Lp(t,false,o.getInt32(n,true),o.getInt32(n+4,true)),true;case 10:return r>=16&&(t.windowOrg.x=o.getInt32(n,true),t.windowOrg.y=o.getInt32(n+4,true),Kr(t)),true;case 11:return r>=16&&Lp(t,true,o.getInt32(n,true),o.getInt32(n+4,true)),true;case 12:return r>=16&&(t.viewportOrg.x=o.getInt32(n,true),t.viewportOrg.y=o.getInt32(n+4,true),Kr(t)),true;case 17:{if(r>=12){let s=o.getUint32(n,true);if(s>=1&&s<=8){let i=yc(t);ia(i,s),gc(t,i),Kr(t);}}return true}case 31:case 32:return r>=24&&_P(t,e===31,o.getInt32(n,true),o.getInt32(n+4,true),o.getInt32(n+8,true),o.getInt32(n+12,true)),true;default:return false}}function DP(t,e,n,r){let{view:o,state:s}=t;switch(e){case 35:return r>=32&&(s.worldTransform=[o.getFloat32(n,true),o.getFloat32(n+4,true),o.getFloat32(n+8,true),o.getFloat32(n+12,true),o.getFloat32(n+16,true),o.getFloat32(n+20,true)]),true;case 36:{if(r>=36){let i=o.getUint32(n+24,true);if(i===1)s.worldTransform=[1,0,0,1,0,0];else if(i===2||i===3){let a=[o.getFloat32(n,true),o.getFloat32(n+4,true),o.getFloat32(n+8,true),o.getFloat32(n+12,true),o.getFloat32(n+16,true),o.getFloat32(n+20,true)],[u,l,c,f,m,b]=s.worldTransform;i===2?s.worldTransform=[a[0]*u+a[1]*c,a[0]*l+a[1]*f,a[2]*u+a[3]*c,a[2]*l+a[3]*f,a[4]*u+a[5]*c+m,a[4]*l+a[5]*f+b]:s.worldTransform=[u*a[0]+l*a[2],u*a[1]+l*a[3],c*a[0]+f*a[2],c*a[1]+f*a[3],m*a[0]+b*a[2]+a[4],m*a[1]+b*a[3]+a[5]];}}return true}default:return false}}function Fp(t,e,n,r){return LP(t,e,n,r)||DP(t,e,n,r)}function ca(){return {penColor:"#000000",penWidth:1,penStyle:0,brushColor:"#ffffff",brushStyle:0,brushPattern:null,brushOrgX:0,brushOrgY:0,stretchBltMode:1,textColor:"#000000",bkColor:"#ffffff",bkMode:2,fontHeight:-12,fontWeight:400,fontItalic:false,fontFamily:"sans-serif",fontUnderline:false,fontStrikeOut:false,fontEscapementTenthDeg:0,rop2:13,curX:0,curY:0,polyFillMode:1,textAlign:0,worldTransform:[1,0,0,1,0,0]}}function ma(t){return {...t,worldTransform:[...t.worldTransform]}}function fa(){return {objectTable:new Map,worldTransform:[1,0,0,1,0,0],saveStack:[],saveIdMap:new Map,clipRegion:null,clipSaveDepth:0}}function os(t,e,n,r,o){if(Fp(t,e,r,o)||vp(t,e,r,o)||Eb(t,e,r,o)||Ip(t,e,r,o))return true;let{ctx:s,view:i,state:a}=t;switch(e){case 33:{for(;t.clipSaveDepth>0;)s.restore(),t.clipSaveDepth--;return t.clipStack??(t.clipStack=[]),t.clipStack.push({region:t.clipRegion??null}),t.mappingStack??(t.mappingStack=[]),t.mappingStack.push({mapMode:t.mapMode,windowOrg:{...t.windowOrg},windowExt:{...t.windowExt},viewportOrg:{...t.viewportOrg},viewportExt:{...t.viewportExt},useMappingMode:t.useMappingMode}),t.stateStack.push(ma(a)),s.save(),t.clipRegion&&We(t,t.clipRegion),true}case 34:{if(o>=12){let u=i.getInt32(r,true);if(u<0&&(u=t.stateStack.length+u+1),u<1||u>t.stateStack.length)return true;for(;t.clipSaveDepth>0;)s.restore(),t.clipSaveDepth--;for(;t.stateStack.length>u;)t.stateStack.pop(),t.clipStack?.pop(),t.mappingStack?.pop(),s.restore();let l=t.stateStack.pop();if(l){let c=t.clipStack?.pop(),f=t.mappingStack?.pop();Object.assign(a,l),f&&Object.assign(t,f),s.restore(),t.clipRegion=c?.region??null,t.clipRegion&&We(t,t.clipRegion);}}return true}case 24:{if(o>=12){let u=Xn(i,r);a.textColor=de(a,u),Jr(a,"text",u);}return true}case 25:{if(o>=12){let u=Xn(i,r);a.bkColor=de(a,u),Jr(a,"bk",u);}return true}case 18:return o>=12&&(a.bkMode=i.getUint32(r,true)),true;case 19:return o>=12&&(a.polyFillMode=i.getUint32(r,true)),true;case 20:return o>=12&&(a.rop2=i.getUint32(r,true)),true;case 21:return o>=12&&(a.stretchBltMode=i.getUint32(r,true)),true;case 13:return o>=16&&(a.brushOrgX=i.getInt32(r,true),a.brushOrgY=i.getInt32(r+4,true)),true;case 58:{if(o>=12){let u=i.getFloat32(r,true);a.miterLimit=Number.isFinite(u)&&u>=1?u:Math.max(1,i.getUint32(r,true));}return true}case 57:return o>=12&&(a.arcDirection=i.getUint32(r,true)===2?2:1),true;case 22:return o>=12&&(a.textAlign=i.getUint32(r,true)),true;default:return false}}function Ac(t,e,n){return n?{x:t.getInt16(e,true),y:t.getInt16(e+2,true),w:t.getInt16(e+4,true),h:t.getInt16(e+6,true)}:{x:t.getFloat32(e,true),y:t.getFloat32(e+4,true),w:t.getFloat32(e+8,true),h:t.getFloat32(e+12,true)}}function wc(t,e,n){return n?{x:t.getInt16(e,true),y:t.getInt16(e+2,true)}:{x:t.getFloat32(e,true),y:t.getFloat32(e+4,true)}}var NP=16384,Ic=2048;function kp(t,e,n){if(e>=n)return null;let r=t.getUint8(e);if(r&128){let s=r&127;return {value:s&64?s-128:s,size:1}}if(e+2>n)return null;let o=r<<8|t.getUint8(e+1);return {value:o&16384?o-32768:o,size:2}}function vn(t,e,n,r,o){if(!(r>=0)||r>1e6)return null;let s=[];if(o&Ic){let u=e,l=0,c=0;for(let f=0;f<r;f++){let m=kp(t,u,n);if(!m)return null;u+=m.size;let b=kp(t,u,n);if(!b)return null;u+=b.size,l+=m.value,c+=b.value,s.push({x:l,y:c});}return s}let i=(o&NP)!==0,a=i?4:8;if(e+r*a>n)return null;for(let u=0;u<r;u++)s.push(wc(t,e+u*a,i));return s}var WP=64;function HP(t){return Math.floor(t*16+.5-1e-4)}function Bp(t,e,n,r,o){let s;try{s=yn(t,e).map(u=>u.pts.map(HP));}catch{return null}let i=ne(s.filter(u=>u.length>=6),n,false,o,r),a=new Uint8Array(r.w*r.h);for(let u=0;u<a.length;u++)a[u]=i[u]?1:0;return a}function ba(t,e,n,r,o=0){if(o>WP)return null;switch(t.type){case "infinite":return new Uint8Array(n.w*n.h).fill(1);case "empty":return new Uint8Array(n.w*n.h);case "rect":{let{x:s,y:i,width:a,height:u}=t;return Bp(l=>l.rect(s,i,a,u),e,false,n,r)}case "path":{let s=t.path;return Bp(i=>Or(i,s),e,s.fillRule==="evenodd",n,r)}case "combine":{let s=ba(t.left,e,n,r,o+1),i=s?ba(t.right,e,n,r,o+1):null;if(!s||!i)return null;let a=t.combineMode;for(let u=0;u<s.length;u++){let l=s[u],c=i[u];s[u]=a===2?l|c:a===3?l^c:a===4?l&(c^1):a===5?c&(l^1):l&c;}return s}}}function Gp(t,e){let n=1/0,r=1/0,o=-1,s=-1;for(let i=0;i<e.h;i++)for(let a=0;a<e.w;a++)t[i*e.w+a]&&(n=Math.min(n,a),o=Math.max(o,a),r=Math.min(r,i),s=Math.max(s,i));return o<0?null:{x:e.x+n,y:e.y+r,w:o-n+1,h:s-r+1}}function ha(t,e,n,r=0,o){let s=t.length;if(s<(n?3:2))return [];let i=(Number.isFinite(e)?e:0)/3,a=m=>{let b,h;return n?(b=t[(m-1+s)%s],h=t[(m+1)%s]):(b=t[Math.max(0,m-1)],h=t[Math.min(s-1,m+1)]),{x:i*(h.x-b.x),y:i*(h.y-b.y)}},u=n?s:s-1,l=n?0:Math.max(0,Math.floor(r)),c=n?u:Math.min(u-l,o===void 0?u:Math.floor(o));if(!(c>0))return [];let f=[{x:t[l].x,y:t[l].y}];for(let m=l;m<l+c;m++){let b=t[m],h=t[(m+1)%s],p=a(m),d=a((m+1)%s);f.push({x:b.x+p.x,y:b.y+p.y},{x:h.x-d.x,y:h.y-d.y},{x:h.x,y:h.y});}return f}function Op(t,e,n,r,o,s=false,i=[]){let a=ne(e,s,false,r,o),u=t.map(c=>{let f=ne(c,false,false,r,o);for(let m=0;m<f.length;m++)a[m]===0&&(f[m]=0);return f}),l=r?i.map(c=>c.map(f=>f-8)):i;return ne([...u.flatMap(c=>XP(c,o.w,o.h,o.x,o.y)),...l],false,n,false,o)}function XP(t,e,n,r,o){return VP(t,e,n).filter(s=>s.length>=3).map(s=>{let i=[];for(let a of s)i.push((a.x+r)*16,(a.y+o)*16);return i})}function YP(t,e,n){let r=[],o=[],s=null;for(let i=0;i<n;i++){let a=[],u=false;for(let c=0;c<e;c++){let f=t[i*e+c]!==0;f!==u&&(a.push(c),u=f);}u&&a.push(e);let l=r[r.length-1];if(a.length===0){s=null;continue}s&&l&&l.y1===i&&s.length===a.length&&s.every((c,f)=>c===a[f])?l.y1=i+1:(r.push({y0:i,y1:i+1,s:o.length,n:a.length}),o.push(...a)),s=a;}return {bands:r,X:o}}function $P(t,e){let n=t.length,r=new Uint8Array(e.length+2),o=[];for(let s=0;s<n;s++){let i=t[s];for(let a=0;a<i.n;a++){if(r[i.s+a])continue;let u=[{x:e[i.s+a],y:i.y0}];r[i.s+a]=1;let l=a&1,c=1,f=s,m=a,b=false;for(let h=0;h<16*(e.length+8)&&!b;h++){for(;;){let d=t[f],x=f+1<n?t[f+1]:null;if(!x||x.y0!==d.y1)break;let y=d.s+m,g=e[y],M=x.s,P=x.n-l-1,E,R=false;if(e[M+l]>g)E=l;else {if(e[M+P]<=g)break;{let A=l,w=P,I=w+A>>1;for(;I!==A;)e[M+I]<=g?A=I:w=I,I=A+w>>1;E=w;}}if((E&1)===l?e[M+E]>=e[y+1]&&(R=true):m<=0?E-=1:e[M+E-1]<e[y-1]?(c=-1,R=true):E-=1,R)break;let T=e[M+E];g!==T&&u.push({x:g,y:d.y1},{x:T,y:d.y1}),r[M+E]=1,f+=1,m=E;}{let d=t[f];u.push({x:e[d.s+m],y:d.y1},{x:e[d.s+m+c],y:d.y1}),m+=c,r[d.s+m]=1,c=-1;}for(;;){let d=t[f],x=f-1;if(x<s)break;let y=t[x];if(y.y1!==d.y0)break;let g=d.s+m,M=e[g],P=y.s,E=y.n-l-1,R;if(e[P+E]<M)R=E;else {if(e[P+l]>=M)break;{let A=l,w=E,I=w+A>>1;for(;I!==A;)e[P+I]<M?A=I:w=I,I=A+w>>1;R=A;}}if((R&1)===l){if(m<d.n-1&&e[P+R+1]>e[g+1]){c=1;break}R+=1;}else if(e[P+R]<=e[g-1])break;let T=e[P+R];M!==T&&u.push({x:M,y:d.y0},{x:T,y:d.y0}),r[P+R]=1,f=x,m=R;}let p=t[f];f===s&&a===m-1?(u.push({x:e[p.s+m],y:p.y0}),b=true):(u.push({x:e[p.s+m],y:p.y0},{x:e[p.s+m+c],y:p.y0}),m+=c,r[p.s+m]=1,c=1);}b&&o.push(u);}}return o}function jP(t){let e=t.map(o=>{let s=1/0,i=1/0,a=-1/0,u=-1/0;for(let l of o)s=Math.min(s,l.x),i=Math.min(i,l.y),a=Math.max(a,l.x),u=Math.max(u,l.y);return {x0:s,y0:i,x1:a,y1:u}}),n=(o,s)=>s.x0>=o.x0&&s.y0>=o.y0&&o.x1>=s.x1&&o.y1>=s.y1,r=t.map(()=>false);for(let o=1;o<t.length;o++)for(let s=o-1;s>=0;s--)n(e[o],e[s])?r[s]=!r[s]:n(e[s],e[o])&&(r[o]=!r[o]);return t.map((o,s)=>{let i=0;for(let a=0;a<t.length;a++)a!==s&&!r[a]&&n(e[a],e[s])&&i++;return i%2===1})}function VP(t,e,n){let{bands:r,X:o}=YP(t,e,n);if(r.length===0)return [];if(r.length===1&&r[0].n===2){let a=r[0];return [[{x:o[a.s],y:a.y0},{x:o[a.s+1],y:a.y0},{x:o[a.s+1],y:a.y1},{x:o[a.s],y:a.y1}]]}let s=$P(r,o).map(zP),i=jP(s);return s.map((a,u)=>i[u]?a.slice().reverse():a)}function zP(t){let e=t.length,n=[t[0],t[0],t[0]],r=[false,false,false],o=0,s=0,i=()=>{let M=o;o=(o+1)%3,s<e?(n[M]=t[s],r[M]=s===e-1,s++):(n[M]=t[0],r[M]=false);},a=[t[0]],u=0,l=t[0],c=t[0],f=0,m=0,b=M=>{if(u===0)l=M,u=1;else if(u===1)c=M,f=M.x-l.x,m=M.y-l.y,u=2;else {let P=M.x-c.x,E=M.y-c.y;P===f&&E===m||(a.push(l),l=c,f=P,m=E),c=M;}},h=()=>(a.push(l,c),a);i(),i(),i();let p=0,d=1,x=2,y,g;n[x].y===n[d].y?(y=n[d].y-n[p].y,g=1):(y=n[d].x-n[p].x,g=0);for(let M=0;M<8*e+16;M++){if(r[p])return h();let P,E;if(g===0?(E=n[x].y-n[d].y,P=E<0&&(y===1||E===-1)):(E=n[x].x-n[d].x,P=y>0&&(y===1||E===-1)),!P){i(),g^=1,y=E;let w=p;p=d,d=x,x=w,b(n[p]);continue}if(r[d])return h();i(),i();let R=p,T=x,A=d;p=T,d=R,x=A,y=g===0?n[d].x-n[p].x:n[d].y-n[p].y,b(n[p]);}return h()}var qP=1.5,Wp={1:[3,1],2:[1,1],3:[3,1,1,1],4:[3,1,1,1,1,1]};function JP(t){switch(t){case 1:case 17:return "square";case 2:case 18:case 3:case 19:return "round";default:return "butt"}}function KP(t){return t===1?"bevel":t===2?"round":"miter"}function Sc(t){let e=t.width||1,n=t.dashStyle===5?t.dashPattern:Wp[t.dashStyle];return !n||n.length===0||n.some(r=>!(r>=0))?[]:n.map(r=>r*e)}function Np(t,e,n=1){t.lineWidth=(e.width||1)*n;let r=Sc(e);t.lineCap=JP(r.length>0?e.dashCap??0:e.startCap??e.endCap),t.lineJoin=KP(e.lineJoin),t.miterLimit=e.miterLimit&&e.miterLimit>=1?e.miterLimit:10,typeof t.setLineDash=="function"&&t.setLineDash(r),t.lineDashOffset=r.length>0?(e.dashOffset??0)*(e.width||1):0;}function Qe(t,e,n,r,o=false,s=false){if(e){let m=QP(t,e);if(!m)return;e=m;}let{ctx:i}=t,a=tR(e);e=a.pen;let u=a.nib,l=!!e&&e.alignment===1&&o,c=l?2:1,f=m=>{(l||u)&&m.save(),l&&(m.beginPath(),n(m),m.clip()),m.beginPath(),n(m),u&&m.transform(u[0],u[1],u[2],u[3],0,0),m.stroke(),(l||u)&&m.restore();};if(e){let m=!!u&&Sc(e).length>0,b=[e.startCap,e.endCap].some(x=>x!==void 0&&x>=17&&x<=20);Np(i,e,c);let h=Vo(t),p=e.brush&&true?Al(t,e.brush):null;if(!p&&h!=="canvas"){let x=ro(e.color);p=x===null?null:eo(x);}if(p){let x=aR(i),y=_t(t),g=Hp(u?Xt(y,u):y);if(h!=="canvas"&&x&&eR(t,e,u,p,n,y,x,h,o,s))return;let M=pa(e)||b||m?jp(t,e,u,n,o):null,P=null;if(x&&M)P=pr(M.flat(),y,x,2);else if(x){let T=Math.max(1,i.miterLimit||10),A=e.width*g*T/2+2;P=pr(r,y,x,A);}if(x&&!P||P&&jo(t,p,P,M?T=>{Vp(T,M),T.fill("nonzero");}:T=>{Np(T,e,c),f(T),T.beginPath(),n(T),u&&T.transform(u[0],u[1],u[2],u[3],0,0);},h,M?(T,A,w)=>T.isPointInPath(A,w,"nonzero"):(T,A,w)=>T.isPointInStroke(A,w)&&(!l||T.isPointInPath(A,w))))return}let d=e.brush?ju(t,e.brush):e.color;if((pa(e)||b||m||u&&typeof d!="string")&&oR(t,e,u,d,n,o))return;i.strokeStyle=d;}pe(t),f(i);}var ZP=2;function QP(t,e){let n=e.unit??0;if(n>=3&&n<=6)return null;if(n!==ZP)return e;let r=xi(t),o=Ke([r[0],r[1],r[2],r[3],0,0]);return o?{...e,transform:Xt(o,e.transform??[1,0,0,1,0,0])}:e}function tR(t){if(!t?.transform)return {pen:t,nib:null};let[e,n,r,o]=t.transform,s=Math.hypot(e,n),i=Math.hypot(r,o),a=e*r+n*o,u=e*o-n*r,l={...t,transform:null};if(t.width===0||iR(t.transform)||!Number.isFinite(s+i+a+u)||Math.abs(u)<1e-12)return {pen:{...l,width:t.width===0?1:t.width},nib:null};if(Math.abs(s-i)<=1e-6*s&&Math.abs(a)<=1e-6*s*i){let c=t.dashStyle===5?t.dashPattern:Wp[t.dashStyle],f=c&&c.length>0?{dashStyle:5,dashPattern:c.map(m=>m/s),dashOffset:(t.dashOffset??0)/s}:{};return {pen:{...l,...f,width:t.width*s},nib:null}}return {pen:l,nib:[e,n,r,o,0,0]}}function Hp(t){let e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3],n=t[0]*t[3]-t[1]*t[2];return Math.sqrt((e+Math.sqrt(Math.max(0,e*e-4*n*n)))/2)}function Xp(t,e){if(!e)return {record:t,unit:Math.hypot(t[0],t[1]),toDevice:sR};let n=Xt(t,e),r=Hp(n),o=Ke(e);return !o||!(r>0)||!Number.isFinite(r)?null:{record:[o[0]*r,o[1]*r,o[2]*r,o[3]*r,0,0],unit:r,toDevice:Xt(n,[1/r,0,0,1/r,0,0])}}function Yp(t,e,n=null){let r=Sc(t).map(o=>o*e);return {half:(t.width||1)*e/2,join:t.lineJoin??0,miterLimit:t.miterLimit&&t.miterLimit>=1?t.miterLimit:10,startCap:t.startCap??0,endCap:t.endCap??0,dashCap:t.dashCap??0,dash:r.length>0?r:null,dashOffset:(t.dashOffset??0)*(t.width||1)*e,dashMetric:n?[n[0],n[1],n[2],n[3]]:void 0,compound:t.compound??null,inset:t.alignment===1}}function eR(t,e,n,r,o,s,i,a,u,l=false){if(!n){let R=Math.hypot(s[0],s[1]),T=Math.hypot(s[2],s[3]),A=s[0]*s[2]+s[1]*s[3];if(!(R>0)||Math.abs(R-T)>1e-6*R||Math.abs(A)>1e-6*R*T)return false}let c=Xp(s,n);if(!c)return false;let f;try{f=yn(o,c.record);}catch{return false}u&&(f=f.map(R=>({...R,closed:true})));let m=(e.width||1)*c.unit,b=Yp(e,c.unit,n),h=a==="gdiplus-aa",p=R=>{let T=c.toDevice;return R.flatMap(A=>[Ft(T[0]*A.x+T[2]*A.y+T[4]),Ft(T[1]*A.x+T[3]*A.y+T[5])])},d,x=[],y=null,g=[];if(pa(e))d=$p(f,m,b,e).map(p);else {if(m<=qP&&!b.dash&&!(((e.startCap??0)|(e.endCap??0)|(e.dashCap??0))&240))return rR(t,e,r,o,s,i,h,u);({fix:d,groups:x,insetFigures:y,open:g}=nR(f,b,p));}let M=So(d,i);if(!M)return true;if(M.w*M.h>16e6)return false;let P=Ee(t.pixelOffsetMode??0),E=y?Op(x,y,h,P,M,l,g):ne(d,false,h,P,M);return jn(t,r,M,E,1,true)}function nR(t,e,n){let r=t.filter(u=>u.closed);if(!e.inset||e.compound||r.length===0){let u=Wn(t,e).map(n);return {fix:u,groups:[u],insetFigures:null,open:[]}}let o={...e,inset:false,half:e.half*2,dashOffset:e.dashOffset*2,dashCapWidth:e.half*2,doubleRoundCap:true},s=r.map(u=>Wn([u],o).map(n)),i=Wn(t.filter(u=>!u.closed),{...e,inset:false}).map(n).map(u=>{let l=[];for(let c=u.length/2-1;c>=0;c--)l.push(u[2*c],u[2*c+1]);return l}),a=t.map(u=>n(Array.from({length:u.pts.length>>1},(l,c)=>({x:u.pts[2*c],y:u.pts[2*c+1]}))));return {fix:[...s.flat(),...i],groups:s,insetFigures:a,open:i}}function rR(t,e,n,r,o,s,i,a){let u;try{u=Of(r,o);}catch{return false}a&&(u=u.map(h=>({...h,closed:true})));let l=So(u.map(h=>h.pts),s);if(!l)return true;if(l.w*l.h>16e6)return false;let c=ro(e.color),m=(!e.brush||!e.brush.gradient&&!e.brush.texture&&!e.brush.hatch)&&c!==null&&c>>>24===255&&t.ext?.compositingMode!==1,b=Nf(u,{antialias:i,half:Ee(t.pixelOffsetMode??0),opaqueSolid:m,clip:{x:0,y:0,w:s.w,h:s.h}},l);return jn(t,n,l,b,1,true)}function pa(t){return !!(t.customStartCap||t.customEndCap)}function $p(t,e,n,r){let o=r0(t,e,r.customStartCap??null,r.customEndCap??null),s=[];return o.figures.forEach((i,a)=>{let u=o.capped[a],l={...n,half:Math.max(e,1)/2,join:n.join===0?3:n.join,startCap:u.start?0:n.startCap,endCap:u.end?0:n.endCap};for(let c of Wn([i],l))s.push(c.slice().reverse());}),s.push(...o.polygons),s}function jp(t,e,n,r,o){let s=_t(t),i=Xp(s,n),a=Ke(s);if(!i||!a||!(i.unit>0))return null;let u;try{u=yn(r,i.record);}catch{return null}o&&(u=u.map(b=>({...b,closed:true})));let l=(e.width||1)*i.unit,c=Yp(e,i.unit,n),f=pa(e)?$p(u,l,c,e):Wn(u,c),m=Xt(a,i.toDevice);return f.map(b=>b.map(h=>({x:m[0]*h.x+m[2]*h.y+m[4],y:m[1]*h.x+m[3]*h.y+m[5]})))}function Vp(t,e){t.beginPath();for(let n of e)n.forEach((r,o)=>{o===0?t.moveTo(r.x,r.y):t.lineTo(r.x,r.y);}),t.closePath();}function oR(t,e,n,r,o,s){let i=jp(t,e,n,o,s);if(!i)return false;let{ctx:a}=t;a.save();try{a.fillStyle=r,pe(t),Vp(a,i),a.fill("nonzero");}finally{a.restore();}return true}var sR=[1,0,0,1,0,0];function iR(t){return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1&&t[4]===0&&t[5]===0}function aR(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}var uR=/^(?:\p{Script=Latin}|\p{Script=Common}|\p{Co})$/u,lR=/[\p{M}\p{Cf}\p{Emoji_Presentation}]/u;function zp(t,e,n,r,o,s,i){let a=n.alignment,u=n.lineAlignment;if(!a&&!u||a<0||a>2||u<0||u>2||t.gridFit||t.mode!=="gray"||!t.designAdvance||t.ttf.winDescent===void 0||t.syntheticBold||t.syntheticItalic||n.flags&3||![r,o,s,i].every(Number.isFinite)||s<=0||i<=0||e.some(x=>!Number.isInteger(x)||x<32||x>1114111||x>=127&&x<=159||x===8232||x===8233)||e.some(x=>{let y=String.fromCodePoint(x);return !uR.test(y)||lR.test(y)||t.glyphIndex(x)===0}))return null;let l=t.ppem,c=n.tracking??1.03,f=l*(n.leadingMargin??1/6),m=l*(n.trailingMargin??1/6);if(![c,f,m].every(x=>Number.isFinite(x)&&x>=0)||!(n.flags&4)&&(t.ttf.fsSelection&1||t.ttf.macStyle&2)&&a!==0)return null;let b=e.map(x=>t.designAdvance(t.glyphIndex(x),c)),h=e.length;if(!(n.flags&2048))for(;h>0&&e[h-1]===32;)h--;let p=b.slice(0,h).reduce((x,y)=>x+y,0)+f+m,d=l*(t.ttf.winAscent+t.ttf.winDescent)/t.ttf.unitsPerEm+(n.flags&4?0:l/8);return p>s||d>i?null:{x:Math.fround(r+a/2*(s-p)+f),y:Math.fround(o+u/2*(i-d))+Math.round(l*t.ttf.winAscent/t.ttf.unitsPerEm),dx:b}}function xR(t,e){let n=e<=255?t.objectTable.get(e):void 0;return !n||n.kind!=="plus-imageattributes"||!n.wrapMode?{}:{wrap:n.wrapMode,clampArgb:n.clampArgb}}var yR=2;function MR(t,e,n,r,o,s,i,a){let{view:u}=t,l=N0(t.interpolationMode??0);if(n||u.getUint32(e+4,true)!==yR)return;let c=u.getFloat32(e+8,true),f=u.getFloat32(e+12,true),m=u.getFloat32(e+16,true),b=u.getFloat32(e+20,true);if(!(!(m>0&&b>0)||!Number.isFinite(c+f+m+b)))return {srcX:c,srcY:f,srcW:m,srcH:b,toDevice:Xt(_t(t),r(c,f,m,b)),kernel:l,halfPixelOffset:Ee(t.pixelOffsetMode??0),...o?{pointsForm:true}:{},...o&&i?{worldPoints:i,worldMatrix:_t(t)}:{},...!o&&a?{worldRect:a,worldMatrix:_t(t)}:{},...s?{nominalScale:s(m,b)}:{},...xR(t,u.getUint32(e,true))}}function Jp(t,e,n,r,o,s,i,a,u=null,l=false,c,f,m){if(!e.data)return;let b=e.type===2,h={imageData:e.data,dx:r,dy:o,dw:s,dh:i,transform:_t(t),isMetafile:b,resample:MR(t,n,b,a,l,c,f,m)},{view:p}=t,d={unit:p.getUint32(n+4,true),srcX:p.getFloat32(n+8,true),srcY:p.getFloat32(n+12,true),srcW:p.getFloat32(n+16,true),srcH:p.getFloat32(n+20,true),toWorld:a};if(fb(t,e,h,d,u)){return}if(h.effect=u,h.effectSource=d,At(t.ctx));t.deferredImages.push(h),$(`DrawImage: queued deferred image (total=${t.deferredImages.length})`);}function Uc(t,e,n,r){let{ctx:o}=t,s=r.fillRule??"nonzero";An(t,e,n,a=>Or(a,r),r.points,s)||(o.fillStyle=De(t,e,n),pe(t),Or(o,r),o.fill(s));}function _c(t,e,n){Qe(t,e,r=>Or(r,n),n.points,RR(n.types),n.fillRule==="evenodd");}function ER(t){return 1+(t===void 0||!Number.isFinite(t)?4:Math.min(12,Math.max(0,t)))/10}function PR(t,e){if(e===1)return;let n=1/e;for(let r=0;r<t.length;r++){let o=t[r]/255;t[r]=Math.round((1-Math.pow(1-o,n))*255);}}function RR(t){if(t.length===0)return false;for(let e=1;e<=t.length;e++)if((e===t.length||(t[e]&15)===0)&&!(t[e-1]&128))return false;return true}function Cc(t,e,n,r,o,s,i){let{ctx:a}=t,u=no(t,e,n),l=a.canvas;if(u&&l&&typeof l.width=="number"&&typeof l.height=="number"){let c=typeof a.measureText=="function"?a.measureText(r).width:r.length*i,f=Math.abs(i)||1,m=[{x:o-c-f,y:s-2*f},{x:o+c+f,y:s-2*f},{x:o-c-f,y:s+2*f},{x:o+c+f,y:s+2*f}],b=pr(m,_t(t),{w:l.width,h:l.height});if(!b)return;let{font:h,textAlign:p,textBaseline:d}=a;if(jo(t,u,b,x=>{x.font=h,x.textAlign=p,x.textBaseline=d,x.fillText(r,o,s);},"canvas",void 0,false))return}a.fillStyle=De(t,e,n),pe(t,false),a.fillText(r,o,s);}var TR=[3,3,3,4,4,6],vc=1/6,AR=1.03;function wR(t){let e=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/.exec(t.trim());return e?e[4]!==void 0&&Number(e[4])<1?null:"#"+[e[1],e[2],e[3]].map(n=>Number(n).toString(16).padStart(2,"0")).join(""):/^#[0-9a-f]{6}$/i.test(t)?t:null}function Kp(t,e){if(!e||e.kind!=="plus-font")return e;let n=e.unit??0;if(n<3||n>6)return n===0?e:{...e,unit:0};let r=t.dpiY??ur,o=lr(t.pageUnit,t.pageScale,r,t.videoDisplay??true),s=e.emSize*lr(n,1,r)/(o||1);return Number.isFinite(s)&&s>0?{...e,emSize:s,unit:0}:e}function IR(t,e){return t!==0?t:e==="mono"?1:e==="gray"?3:5}function Qp(t,e,n,r){let o=t.fonts,s=typeof n=="string"?wR(n):null,i=IR(t.textRenderingHint??0,o?.defaultSmoothing),u=!!s&&(i===3||i===4||i===5)&&!At(t.ctx),l=At(t.ctx)?null:u?eo(ro(n)??4278190080):s?null:r,c=e.unit??0;if(!o||!s&&!l||c!==0&&c!==2)return null;let f=_t(t);if(f[1]!==0||f[2]!==0||f[0]<=0||f[3]<=0)return null;let m=e.emSize*f[3],b={face:e.family,height:-Math.round(m),width:0,weight:e.flags&1?700:400,italic:(e.flags&2)!==0,charSet:1,pitchAndFamily:0,quality:TR[i]??3,unhinted:i===2||i===4,ignoreGasp:i===4,gdiPlus:true,unscaledText:f[0]===1&&f[3]===1},h=o.realize(b,t.fontFamilyMap);return h?{realized:h,emPx:m,m:f,unhinted:b.unhinted===true,color:s,sampler:l,solidViaCoverage:u,underline:(e.flags&4)!==0,strikeOut:(e.flags&8)!==0,plusBars:i===4?"fractional":"snapped"}:null}function xa(t,e,n,r){let o={...n,textAlign:24,bkColor:"#ffffff",bkMode:1,options:r?mo:0,rect:r??null,matrix:null};if((!e.color||e.solidViaCoverage)&&e.sampler){let s=Vh(e.realized,{...o,underline:e.underline,strikeOut:e.strikeOut,plusBars:e.plusBars},{decorations:true,grayLevels:15});if(!s)return true;if(r)for(let a=0;a<s.height;a++){let u=s.y+a;for(let l=0;l<s.width;l++){let c=s.x+l;if(c<r.left||c>=r.right||u<r.top||u>=r.bottom){let f=a*s.width+l;s.data.fill(0,f*s.channels,(f+1)*s.channels),s.bars&&(s.bars[f]=0);}}}let i=ER(t.ext?.textContrast);if(s.channels===1&&PR(s.data,i),s.bars){let a=s.width*s.height;for(let u=0;u<a;u++){let l=s.bars[u];if(l!==0)for(let c=0;c<s.channels;c++){let f=s.data[u*s.channels+c];s.data[u*s.channels+c]=255-Math.round((255-f)*(255-l)/255);}}}return jn(t,e.sampler,{x:s.x,y:s.y,w:s.width,h:s.height},s.data,s.channels,false,s.channels===3?i:1)}return tc(t.ctx,e.realized,{...o,textColor:e.color,underline:e.underline,strikeOut:e.strikeOut,plusBars:e.plusBars},t.fontFamilyMap),true}function SR(t,e,n,r,o,s,i,a,u,l,c=null){let f=Qp(t,e,a,c);if(!f)return false;let{realized:m,emPx:b,m:h,unhinted:p}=f,d=Array.from(n,K=>K.codePointAt(0));if(l&&(u!==0||l.lineAlignment!==0)&&p&&h[0]===h[3]&&Math.fround(b)===m.ppem){let K=zp(m,d,l,h[0]*r+h[4],h[3]*o+h[5],h[0]*s,h[3]*i);if(K)return xa(t,f,{codes:d,glyphIndices:false,...K,dy:null})}if(u!==0)return false;let x=m.ttf,y=b*x.winAscent/x.unitsPerEm,g=!m.syntheticBold&&!m.syntheticItalic&&b===m.ppem&&h[0]===1&&h[3]===1&&Number.isInteger(o+h[5])&&(l?.lineAlignment??0)===0,M=p?Math.round(y):g?Math.max(Math.round(y),m.ascent):Math.ceil(y),P=h[0]*r+h[4]+b*(l?.leadingMargin??vc);p||(P=Math.round(P));let E=h[3]*o+h[5]+M,R=l?.tracking??AR,T=!p&&m.mode==="cleartype"&&!!m.ctGridAdvance&&!m.syntheticItalic&&R>1,A=!!m.designAdvance&&h[0]===1&&h[3]===1,w=K=>{let V=m.glyphIndex(K);return p?A?m.designAdvance(V,R):m.advance(V)*R:T?m.ctGridAdvance(V):m.advance(V)},I=p||T?d.map(w):null,S=l?.flags??0,v=h[0]*r+h[4],C=h[3]*o+h[5],U=h[0]*s,D=h[3]*i,L=U>0&&D>0&&!(S&UR)?{left:Math.round(v),top:Math.round(C),right:Math.round(v+U),bottom:Math.round(C+D)}:void 0,F,B=U>0&&!(S&vR)?U-b*((l?.leadingMargin??vc)+(l?.trailingMargin??vc)):1/0,X=(m.designAdvance?d.map(K=>m.designAdvance(m.glyphIndex(K),R)):d.map(w)).map((K,V)=>V+1<d.length&&x.kerning?K+x.kerning(m.glyphIndex(d[V]),m.glyphIndex(d[V+1]))*b/x.unitsPerEm:K),k=_R(d,X,B),W=k.length>1;W&&(F=L);let O=x.winDescent??0,q=x.hheaAscender!==void 0&&x.hheaDescender!==void 0?x.hheaAscender-x.hheaDescender+(x.hheaLineGap??0):x.winAscent+O,Q=q*b/x.unitsPerEm;if(L){let K=S&CR?Math.floor((D-(x.winAscent+O)*b/x.unitsPerEm)/Q)+1:Math.floor(D/Q-.25)+1;if(k.length>K){F=L;let V=k.slice(0,Math.max(0,K));if(V.length>0&&(l?.trimming??1)===1){let rt=V[V.length-1],H=rt.start;for(;H<d.length&&d[H]!==10&&d[H]!==13;){let Y=0;for(let N=rt.start;N<=H;N++)Y+=X[N];if(Y>B&&H>rt.start)break;H++;}for(;H>rt.start&&d[H-1]===32;)H--;V[V.length-1]={start:rt.start,end:H};}k=V;}}if(k.length===0)return true;if(!W)return xa(t,f,{codes:d.slice(0,k[0].end===Zp(d)?d.length:k[0].end),glyphIndices:false,x:P,y:E,dx:I?I.slice(0,k[0].end===Zp(d)?d.length:k[0].end):null,dy:null},F);for(let[K,V]of k.entries()){let rt=C+(x.winAscent+K*q)*b/x.unitsPerEm,H=d.slice(V.start,V.end);if(H.length===0)continue;let Y=G=>{let j=G+1<V.end&&x.kerning?x.kerning(m.glyphIndex(d[G]),m.glyphIndex(d[G+1]))*b/x.unitsPerEm:0;return p?j:Math.round(j)},N=Array.from({length:V.end-V.start},(G,j)=>w(d[V.start+j])+Y(V.start+j));xa(t,f,{codes:H,glyphIndices:false,x:P,y:p?C+Math.round(y)+K*Q:Math.round(rt),dx:N.some((G,j)=>G!==w(d[V.start+j]))||I?N:null,dy:null},F);}return true}function Zp(t){let e=t.length;for(;e>0&&t[e-1]===32;)e--;return e}var vR=4096,CR=8192,UR=16384;function _R(t,e,n){let r=[],o=(a,u)=>{for(;u>a&&t[u-1]===32;)u--;return u},s=(a,u)=>{let l=0;for(let c=a;c<u;c++)l+=e[c];return l},i=0;for(;i<=t.length;){let a=i;for(;a<t.length&&t[a]!==10&&t[a]!==13;)a++;let u=i;do{let l=o(u,a);if(Number.isFinite(n)&&s(u,l)>n){let c=-1;for(let f=u+1;f<a;f++)t[f-1]===32&&t[f]!==32&&s(u,o(u,f))<=n&&(c=f);if(c>u)l=c;else for(l=u+1;l<a&&t[l]!==32&&s(u,l+1)<=n;)l++;}for(r.push({start:u,end:o(u,l)}),u=l;u<a&&t[u]===32&&u>i;)u++;}while(u<a);i=a+(t[a]===13&&t[a+1]===10?2:1);}return r}var LR=1,DR=2,FR=4;function kR(t,e,n,r,o,s,i){let a=(i&LR)!==0,u=(i&FR)!==0;if(!(i&DR)){let h=De(t,e,n),p=Qp(t,r,h,t.fonts?no(t,e,n):null);if(p){let{m:d}=p,x=s.map(g=>({x:d[0]*g.x+d[4],y:d[3]*g.y+d[5]})),y=g=>x.map((M,P)=>P+1<x.length?x[P+1][g]-M[g]:0);xa(t,p,{codes:o,glyphIndices:!a,x:x[0].x,y:x[0].y,dx:u?null:y("x"),dy:u?null:y("y")});return}}if(!a){return}let{ctx:l}=t,c=r.flags&1?"bold ":"",f=r.flags&2?"italic ":"",m=_r(r.family,t.fontFamilyMap),b=()=>{l.font=`${f}${c}${r.emSize}px ${m}`,l.textBaseline="alphabetic",l.textAlign="left";};if(u){b(),Cc(t,e,n,String.fromCharCode(...o),s[0].x,s[0].y,r.emSize);return}for(let h=0;h<o.length;h++)b(),Cc(t,e,n,String.fromCharCode(o[h]),s[h].x,s[h].y,r.emSize);}function td(t,e,n,r,o){let{ctx:s,view:i,objectTable:a}=t;switch(e){case 16404:{if(o>=4){let u=a.get(n&255);u&&u.kind==="plus-path"&&Uc(t,n,i.getUint32(r,true),u);}return true}case 16405:{if(o>=4){let u=a.get(n&255),l=a.get(i.getUint32(r,true)&255);u&&u.kind==="plus-path"&&_c(t,l&&l.kind==="plus-pen"?l:null,u);}return true}case 16412:{if(o>=28){let u=i.getUint32(r,true),l=i.getUint32(r+4,true),c=i.getUint32(r+8,true),f=i.getFloat32(r+12,true),m=i.getFloat32(r+16,true),b=i.getFloat32(r+20,true),h=i.getFloat32(r+24,true),p=n&255,d=Kp(t,a.get(p));if(c>0&&r+28+c*2<=r+o){let x=Dn(i,r+28,c);if(x.length>0&&d&&d.kind==="plus-font"){let y=a.get(l),g=De(t,n,u),M=y&&y.kind==="plus-stringformat"?y.alignment:0,P=y&&y.kind==="plus-stringformat"?y:void 0;if(SR(t,d,x,f,m,b,h,g,M,P,t.fonts?no(t,n,u):null))return true;let E=d.flags&1?"bold ":"",R=d.flags&2?"italic ":"",T=_r(d.family,t.fontFamilyMap);if(s.font=`${R}${E}${d.emSize}px ${T}`,s.textBaseline="top",y&&y.kind==="plus-stringformat")switch(y.alignment){case 1:s.textAlign="center";break;case 2:s.textAlign="right";break;default:s.textAlign="left";}else s.textAlign="left";Cc(t,n,u,x,f,m,d.emSize);}}}return true}case 16438:{if(o>=16){let u=i.getUint32(r,true),l=i.getUint32(r+4,true),c=i.getUint32(r+8,true)!==0,f=i.getUint32(r+12,true),m=Kp(t,a.get(n&255)),b=r+16,h=b+f*2,p=h+f*8;if(f>0&&f<1e5&&p+(c?24:0)<=r+o&&m&&m.kind==="plus-font"){let d=[],x=[];for(let g=0;g<f;g++)d.push(i.getUint16(b+g*2,true)),x.push({x:i.getFloat32(h+g*8,true),y:i.getFloat32(h+g*8+4,true)});let y=t.worldTransform;if(c){let g=[0,4,8,12,16,20].map(M=>i.getFloat32(p+M,true));g.every(Number.isFinite)&&(t.worldTransform=Xt(y,g));}try{kR(t,n,u,m,d,x,l);}finally{t.worldTransform=y;}}}return true}case 16410:{if(o>=24){let u=n&255,l=a.get(u),c=(n&16384)!==0,f=r+24,m,b,h,p;if(c&&f+8<=r+o)m=i.getInt16(f,true),b=i.getInt16(f+2,true),h=i.getInt16(f+4,true),p=i.getInt16(f+6,true);else if(!c&&f+16<=r+o)m=i.getFloat32(f,true),b=i.getFloat32(f+4,true),h=i.getFloat32(f+8,true),p=i.getFloat32(f+12,true);else return true;t.totalDrawImageCalls++;let d=l&&l.kind==="plus-image"&&l.data;$(`DrawImage: imgId=${u}, dest=(${m},${b},${h},${p}), compressed=${c}, hasObj=${!!l}, objKind=${l?.kind}, hasData=${!!d}, dataLen=${d?l.data.byteLength:0}, isMetafile=${l?.kind==="plus-image"?l.type===2:"N/A"}`),$(`DrawImage: worldTransform=[${t.worldTransform.map(x=>x.toFixed(3)).join(", ")}]`),l&&l.kind==="plus-image"&&l.data?Jp(t,l,r,m,b,h,p,(x,y,g,M)=>[_(h/g),0,0,_(p/M),m-x*h/g,b-y*p/M],null,false,(x,y)=>[Math.fround(h/x),Math.fround(p/y)],void 0,[m,b,h,p]):z(`DrawImage: SKIPPED, no valid image data for id=${u}`);}return true}case 16411:{if(o>=28){let u=n&255,l=a.get(u),c=i.getUint32(r+24,true),f=r+28,m=(n&af)!==0?t.ext?.pendingEffect??null:null;if(t.ext&&(t.ext.pendingEffect=null),c>=3&&l&&l.kind==="plus-image"&&l.data){let b=vn(i,f,r+o,3,n);if(!b)return true;let[{x:h,y:p},{x:d,y:x},{x:y,y:g}]=b,M=h,P=p,E=Math.sqrt((d-h)**2+(x-p)**2),R=Math.sqrt((y-h)**2+(g-p)**2);t.totalDrawImageCalls++,$(`DrawImagePoints: imgId=${u}, points=[(${h},${p}),(${d},${x}),(${y},${g})], dest=(${M.toFixed(1)},${P.toFixed(1)},${E.toFixed(1)},${R.toFixed(1)})`),$(`DrawImagePoints: worldTransform=[${t.worldTransform.map(T=>T.toFixed(3)).join(", ")}]`),Jp(t,l,r,M,P,E,R,(T,A,w,I)=>{let S=_((d-h)/w),v=_((x-p)/w),C=_((y-h)/I),U=_((g-p)/I);return [S,v,C,U,h-S*T-C*A,p-v*T-U*A]},m,true,x===p&&y===h?(T,A)=>[Math.fround((d-h)/T),Math.fround((g-p)/A)]:void 0,[h,p,d,x,y,g]);}else {l&&l.kind==="plus-image"&&l.data;}}return true}default:return false}}var XR=8192;function Lc(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function ya(t,e){return n=>{n.moveTo(t[0].x,t[0].y);for(let r=1;r+2<t.length;r+=3)n.bezierCurveTo(t[r].x,t[r].y,t[r+1].x,t[r+1].y,t[r+2].x,t[r+2].y);e&&n.closePath();}}function ed(t,e,n,r,o){let{view:s}=t,i=r+o;switch(e){case 16409:{if(o<4)return true;let a=s.getUint32(r,true),u=vn(s,r+4,i,a,n);return !u||u.length<4||(u.length-1)%3!==0||Qe(t,Lc(t,n),ya(u,false),u,false),true}case 16408:{if(o<16)return true;let a=s.getFloat32(r,true),u=s.getUint32(r+4,true),l=s.getUint32(r+8,true),c=s.getUint32(r+12,true),f=vn(s,r+16,i,c,n&16384);if(!f)return true;let m=ha(f,a,false,u,l);return m.length>=4&&Qe(t,Lc(t,n),ya(m,false),m,false),true}case 16407:{if(o<8)return true;let a=s.getFloat32(r,true),u=s.getUint32(r+4,true),l=vn(s,r+8,i,u,n),c=l?ha(l,a,true):[];return c.length>=4&&Qe(t,Lc(t,n),ya(c,true),c,true),true}case 16406:{if(o<12)return true;let a=s.getUint32(r,true),u=s.getFloat32(r+4,true),l=s.getUint32(r+8,true),c=vn(s,r+12,i,l,n),f=c?ha(c,u,true):[];if(f.length<4)return true;let m=n&XR?"nonzero":"evenodd",b=ya(f,true);if(!An(t,n,a,b,f,m)){let{ctx:h}=t;h.fillStyle=De(t,n,a),pe(t),h.beginPath(),b(h),h.fill(m);}return true}case 16439:return YR(t,n,r,o),true;case 16403:return o<4||jR(t,n,s.getUint32(r,true)),true;default:return false}}function YR(t,e,n,r){if(r<12)return;let{view:o,objectTable:s}=t,i=s.get(e&255),a=o.getUint32(n,true),u=o.getUint32(n+4,true);if(t.ext&&(t.ext.pendingEffect=null),!i||i.kind!=="plus-path")return;let l=u<=255?s.get(u):void 0;l&&l.kind==="plus-brush"&&Uc(t,0,u,i);let c=a<=255?s.get(a):void 0;c&&c.kind==="plus-pen"&&_c(t,c,i);}function $R(t){let e=t.canvas,n=e?.width,r=e?.height;return typeof n=="number"&&typeof r=="number"&&n>0&&r>0?{w:n,h:r}:null}function jR(t,e,n){let r=t.objectTable.get(e&255);if(!r||r.kind!=="plus-region"||r.nodes.length===0)return;let o=r.nodes[0],s=_t(t),{ctx:i}=t,a=$R(i);if(Vo(t)!=="canvas"&&a){let m={x:0,y:0,w:a.w,h:a.h},b=ba(o,s,m,Ee(t.pixelOffsetMode??0)),h=b?wl(t,e,n):null;if(b&&h){let p=Gp(b,m);if(!p)return;let d=new Uint8ClampedArray(p.w*p.h);for(let x=0;x<p.h;x++)for(let y=0;y<p.w;y++)d[x*p.w+y]=b[(p.y+x)*m.w+p.x+y]?255:0;if(jn(t,h,p,d,1,true))return}}let u=ko(o,s,0,a?{x:0,y:0,w:a.w,h:a.h}:void 0);u.exact||z("FillRegion: region approximated (no canvas domain for an unbounded result)");let l=u.region,c=Ke(s);if(l&&l.length===0||!c)return;let f=a??{w:1e6,h:1e6};i.save();try{i.setTransform(1,0,0,1,0,0);for(let b of l??[])i.beginPath(),Fo(i,b.cmds),i.clip(b.fillRule);i.fillStyle=De(t,e,n),pe(t);let m=[[0,0],[f.w,0],[f.w,f.h],[0,f.h]].map(([b,h])=>({x:c[0]*b+c[2]*h+c[4],y:c[1]*b+c[3]*h+c[5]}));i.beginPath(),i.moveTo(m[0].x,m[0].y);for(let b=1;b<4;b++)i.lineTo(m[b].x,m[b].y);i.closePath(),i.fill();}finally{i.restore();}}function tT(t,e,n,r){let o=u=>{let l=u*Math.PI/180;return n>0&&r>0?Math.atan2(n*Math.sin(l),r*Math.cos(l)):l},s=Math.max(-360,Math.min(360,e)),i=o(t);if(Math.abs(s)>=360)return {start:i,sweep:Math.sign(s)*2*Math.PI};let a=o(t+s)-i;return s>0&&a<0?a+=2*Math.PI:s<0&&a>0?a-=2*Math.PI:s===0&&(a=0),{start:i,sweep:a}}function od(t,e,n,r,o){if(o&Ic)return vn(t,e,n,r,o);let s=(o&16384)!==0,i=s?4:8,a=[];for(let u=0,l=e;u<r&&l+i<=n;u++,l+=i)a.push(wc(t,l,s));return a}function Dc(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function sd(t,e,n,r,o){let{ctx:s,view:i,objectTable:a}=t;switch(e){case 16394:{if(o>=8){let u=i.getUint32(r,true),l=i.getUint32(r+4,true),c=(n&16384)!==0,f=c?8:16,m=[],b=r+8;for(let p=0;p<l&&b+f<=r+o;p++)m.push(Ac(i,b,c)),b+=f;if(!An(t,n,u,p=>{for(let d of m)p.rect(d.x,d.y,d.w,d.h);},m.flatMap(p=>[{x:p.x,y:p.y},{x:p.x+p.w,y:p.y},{x:p.x,y:p.y+p.h},{x:p.x+p.w,y:p.y+p.h}]))){s.fillStyle=De(t,n,u),pe(t);for(let p of m)s.fillRect(p.x,p.y,p.w,p.h);}}return true}case 16395:{if(o>=4){let u=i.getUint32(r,true),l=(n&16384)!==0,c=l?8:16,f=[],m=r+4;for(let b=0;b<u&&m+c<=r+o;b++)f.push(Ac(i,m,l)),m+=c;Qe(t,Dc(t,n),b=>{for(let h of f)b.rect(h.x,h.y,h.w,h.h);},f.flatMap(b=>[{x:b.x,y:b.y},{x:b.x+b.w,y:b.y+b.h}]),true);}return true}case 16398:{if(o>=12){let u=i.getUint32(r,true),l=(n&16384)!==0,c,f,m,b;if(l)c=i.getInt16(r+4,true),f=i.getInt16(r+6,true),m=i.getInt16(r+8,true),b=i.getInt16(r+10,true);else {if(o<20)return true;c=i.getFloat32(r+4,true),f=i.getFloat32(r+8,true),m=i.getFloat32(r+12,true),b=i.getFloat32(r+16,true);}let h=d=>{d.ellipse(c+m/2,f+b/2,Math.abs(m)/2,Math.abs(b)/2,0,0,Math.PI*2);},p=[{x:c,y:f},{x:c+m,y:f},{x:c,y:f+b},{x:c+m,y:f+b}];An(t,n,u,h,p)||(s.fillStyle=De(t,n,u),pe(t),s.beginPath(),h(s),s.fill());}return true}case 16399:{let u=n&255,l=a.get(u),c=(n&16384)!==0,f,m,b,h;if(c&&o>=8)f=i.getInt16(r,true),m=i.getInt16(r+2,true),b=i.getInt16(r+4,true),h=i.getInt16(r+6,true);else if(!c&&o>=16)f=i.getFloat32(r,true),m=i.getFloat32(r+4,true),b=i.getFloat32(r+8,true),h=i.getFloat32(r+12,true);else return true;return Qe(t,l&&l.kind==="plus-pen"?l:null,p=>p.ellipse(f+b/2,m+h/2,Math.abs(b)/2,Math.abs(h)/2,0,0,Math.PI*2),[{x:f,y:m},{x:f+b,y:m+h}],true),true}case 16400:case 16401:case 16402:{let u=e===16400;if(o<(u?12:8))return true;let c=r,f=u?i.getUint32(c,true):0;u&&(c+=4);let m=i.getFloat32(c,true),b=i.getFloat32(c+4,true);c+=8;let h=(n&16384)!==0,p,d,x,y;if(h&&c+8<=r+o)p=i.getInt16(c,true),d=i.getInt16(c+2,true),x=i.getInt16(c+4,true),y=i.getInt16(c+6,true);else if(!h&&c+16<=r+o)p=i.getFloat32(c,true),d=i.getFloat32(c+4,true),x=i.getFloat32(c+8,true),y=i.getFloat32(c+12,true);else return true;let g=p+x/2,M=d+y/2,P=Math.abs(x)/2,E=Math.abs(y)/2,{start:R,sweep:T}=tT(m,b,P,E);if(u){let w=S=>{S.moveTo(g,M),S.ellipse(g,M,P,E,0,R,R+T,T<0),S.closePath();},I=[{x:p,y:d},{x:p+x,y:d},{x:p,y:d+y},{x:p+x,y:d+y}];return An(t,n,f,w,I)||(s.fillStyle=De(t,n,f),pe(t),s.beginPath(),w(s),s.fill()),true}let A=e===16401;return Qe(t,Dc(t,n),w=>{A&&w.moveTo(g,M),w.ellipse(g,M,P,E,0,R,R+T,T<0),A&&w.closePath();},[{x:p,y:d},{x:p+x,y:d+y}],A),true}case 16397:{if(o>=4){let u=i.getUint32(r,true),l=od(i,r+4,r+o,u,n);if(!l)return true;let c=(n&8192)!==0;Qe(t,Dc(t,n),f=>{l.forEach((m,b)=>b===0?f.moveTo(m.x,m.y):f.lineTo(m.x,m.y)),c&&f.closePath();},l,c);}return true}case 16396:{if(o>=8){let u=i.getUint32(r,true),l=i.getUint32(r+4,true),c=od(i,r+8,r+o,l,n);if(!c)return true;let f=m=>{c.forEach((b,h)=>h===0?m.moveTo(b.x,b.y):m.lineTo(b.x,b.y)),m.closePath();};An(t,n,u,f,c)||(s.fillStyle=De(t,n,u),pe(t),s.beginPath(),f(s),s.fill());}return true}default:return false}}function ad(t,e,n,r,o=n){let{view:s,objectTable:i}=t,a=e&255,u=e>>8&127;switch(u){case 1:{let l=Ks(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 2:{let l=p0(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 3:{let l=tr(s,n,r);l&&i.set(a,l);break}case 6:{let l=x0(s,n,r);l&&i.set(a,l);break}case 7:{if(r>=16){let l=s.getUint32(n+4,true),c=s.getUint32(n+12,true),f=s.getUint32(n+16,true),m=r>=48;i.set(a,{kind:"plus-stringformat",flags:l,alignment:c??0,lineAlignment:f??0,leadingMargin:m?s.getFloat32(n+36,true):void 0,trailingMargin:m?s.getFloat32(n+40,true):void 0,tracking:m?s.getFloat32(n+44,true):void 0,trimming:r>=52?s.getUint32(n+48,true):void 0});}break}case 5:{if(r<8)break;let l=ei(s,n,r);i.set(a,{kind:"plus-image",data:l.data,type:l.type,cacheKey:o}),t.totalImageObjects++;break}case 8:{if(r>=16){let l=s.getUint32(n+8,true),c=["tile","tile-flip-x","tile-flip-y","tile-flip-xy","clamp"];i.set(a,{kind:"plus-imageattributes",wrapMode:c[l]??"clamp",clampArgb:s.getUint32(n+12,true)});}else i.set(a,{kind:"plus-imageattributes"});break}case 4:{let l=iT(s,n,r);l&&(i.set(a,l),$(`replayEmfPlusRecords: Stored Region object id=${a}`));break}}}var id=64;function Fc(t,e,n,r=0){if(e+4>n)return null;if(r>id)return null;let o=t.getUint32(e,true),s=e+4;if(o<=5){let i=Fc(t,s,n,r+1);if(!i)return null;s+=i.bytesRead;let a=Fc(t,s,n,r+1);return a?(s+=a.bytesRead,{node:{type:"combine",combineMode:o,left:i.node,right:a.node},bytesRead:s-e}):null}if(o===268435456){if(s+16>n)return null;let i=t.getFloat32(s,true),a=t.getFloat32(s+4,true),u=t.getFloat32(s+8,true),l=t.getFloat32(s+12,true);return {node:{type:"rect",x:i,y:a,width:u,height:l},bytesRead:s+16-e}}if(o===268435457){if(s+4>n)return null;let i=t.getInt32(s,true);if(s+=4,i<=0||s+i>n)return null;let a=tr(t,s,i);return {node:a?{type:"path",path:a}:{type:"empty"},bytesRead:s+i-e}}return o===268435458?{node:{type:"empty"},bytesRead:4}:o===268435459?{node:{type:"infinite"},bytesRead:4}:(z(`parseRegionNode: unknown node type 0x${o.toString(16)}`),{node:{type:"empty"},bytesRead:4})}function iT(t,e,n){if(n<8)return null;t.getUint32(e,true);let o=t.getUint32(e+4,true);if(o>1e5)return null;let s=e+n,i=Fc(t,e+8,s);return i?{kind:"plus-region",nodes:[i.node]}:(null)}var bT={16385:"Header",16389:"MultiFormatStart",16390:"MultiFormatSection",16391:"MultiFormatEnd",16386:"EndOfFile",16388:"GetDC",16392:"Object",16393:"Clear",16394:"FillRects",16395:"DrawRects",16396:"FillPolygon",16397:"DrawLines",16398:"FillEllipse",16399:"DrawEllipse",16400:"FillPie",16401:"DrawPie",16402:"DrawArc",16403:"FillRegion",16406:"FillClosedCurve",16407:"DrawClosedCurve",16408:"DrawCurve",16409:"DrawBeziers",16404:"FillPath",16405:"DrawPath",16410:"DrawImage",16411:"DrawImagePoints",16412:"DrawString",16438:"DrawDriverString",16413:"SetRenderingOrigin",16414:"SetAntiAliasMode",16415:"SetTextRenderingHint",16416:"SetTextContrast",16417:"SetInterpolationMode",16418:"SetPixelOffsetMode",16419:"SetCompositingMode",16420:"SetCompositingQuality",16423:"BeginContainer",16429:"TranslateWorldTransform",16430:"ScaleWorldTransform",16431:"RotateWorldTransform",16439:"StrokeFillPath",16440:"SerializableObject",16441:"SetTSGraphics",16442:"SetTSClip",16426:"SetWorldTransform",16427:"ResetWorldTransform",16428:"MultiplyWorldTransform",16432:"SetPageTransform",16433:"ResetClip",16434:"SetClipRect",16435:"SetClipPath",16436:"SetClipRegion",16437:"OffsetClip",16421:"Save",16422:"Restore",16424:"BeginContainerNoParams",16425:"EndContainer"};function hT(t,e,n){if(n<8)return;let r=t.view.getUint32(e,true);n<4+4*r||((t.ext??(t.ext={})).multiFormatSkip=true,$("MultiFormatStart: GDI+ plays no further EMF+ record"));}function cd(t){return t>0&&t<=1e5?t:void 0}function*md(t,e,n,r,o,s,i,a=1,u=5e5,l,c,f){let m=i??fa(),b={ctx:r,view:t,objectTable:m.objectTable,worldTransform:m.worldTransform,deferredImages:[],saveStack:m.saveStack,saveIdMap:m.saveIdMap,totalImageObjects:0,totalDrawImageCalls:0,clipSaveDepth:m.clipSaveDepth,clipRegion:m.clipRegion,pageUnit:m.pageUnit??di,pageScale:m.pageScale??1,dpiX:m.dpiX,dpiY:m.dpiY,videoDisplay:m.videoDisplay,...m.continuation??ni(),dpiScale:a,canvasW:o,canvasH:s,fontFamilyMap:l,textureCache:c,interpolationMode:m.interpolationMode,pixelOffsetMode:m.pixelOffsetMode,textRenderingHint:m.textRenderingHint,fonts:f,baseTransform:m.baseTransform,imageCache:m.imageCache,nestingDepth:m.nestingDepth,gdiAntialias:m.gdiAntialias,codePages:m.codePages,antiAlias:m.antiAlias,ext:m.ext??(m.ext={})},h=e+n,p=0,d=new Map;for($(`replayEmfPlusRecords: offset=0x${e.toString(16)}, length=${n}`);e+12<=h&&p<u;){Fe(),qr()&&(yield);let y=t.getUint16(e,true),g=t.getUint16(e+2,true),M=t.getUint32(e+4,true),P=t.getUint32(e+8,true);if(M<12||e+M>h)break;p++,d.set(y,(d.get(y)??0)+1);let E=e+12;if(m.gdiPassthrough=y===16388,b.ext?.multiFormatSkip&&y!==16386){e+=M;continue}switch(y){case 16385:{if(m.dualMode=(g&1)!==0,P>=16){let R=t.getUint32(E+4,true),T=t.getUint32(E+8,true),A=t.getUint32(E+12,true);b.dpiX=m.dpiX=cd(T),b.dpiY=m.dpiY=cd(A),b.videoDisplay=m.videoDisplay=(R&1)!==0,$(`replayEmfPlusRecords: HEADER dpiX=${T}, dpiY=${A}, flags=0x${R.toString(16)}`);}break}case 16386:e=h;continue;case 16388:break;case 16389:hT(b,E,P);break;case 16390:case 16391:break;case 16440:(b.ext??(b.ext={})).pendingEffect=P<=M-12?uf(t,E,P):null;break;case 16393:{if(P>=4){let R=t.getUint32(E,true);r.save(),r.setTransform(1,0,0,1,0,0),r.globalAlpha=1,r.globalCompositeOperation="source-over",R>>>24!==255&&r.clearRect(0,0,o,s),r.fillStyle=ue(R),r.fillRect(0,0,o,s),r.restore();}break}case 16392:{let R=ri(b,t,g,E,P);R&&ad(R.view===t?b:{...b,view:R.view},R.flags,R.dataOff,R.dataSize,R.cacheKey);break}default:{sd(b,y,g,E,P)||ed(b,y,g,E,P)||td(b,y,g,E,P)||ab(b,y,g,E,P)||console.warn(`[emf-converter] Unhandled EMF+ record type: 0x${y.toString(16)}`);break}}e+=M;}p>=u&&console.warn(`[emf-converter] EMF+ record limit reached (${u}). Output may be incomplete.`);let x=[];for(let[y,g]of d)x.push(`${bT[y]??`0x${y.toString(16)}`}:${g}`);return $(`replayEmfPlusRecords: totalImageObjects=${b.totalImageObjects}, totalDrawImageCalls=${b.totalDrawImageCalls}, deferredImages=${b.deferredImages.length}`),$(`replayEmfPlusRecords: object table has ${b.objectTable.size} entries: [${Array.from(b.objectTable.entries()).map(([y,g])=>`${y}:${g.kind}`).join(", ")}]`),i&&(i.worldTransform=b.worldTransform,i.saveIdMap=b.saveIdMap,i.clipRegion=b.clipRegion??null,i.clipSaveDepth=b.clipSaveDepth,i.continuation={continuationBuffer:b.continuationBuffer,continuationObjectId:b.continuationObjectId,continuationObjectType:b.continuationObjectType,continuationTotalSize:b.continuationTotalSize,continuationOffset:b.continuationOffset,continuationKey:b.continuationKey},i.interpolationMode=b.interpolationMode,i.pixelOffsetMode=b.pixelOffsetMode,i.textRenderingHint=b.textRenderingHint,i.pageUnit=b.pageUnit,i.pageScale=b.pageScale,i.dpiX=b.dpiX,i.dpiY=b.dpiY,i.videoDisplay=b.videoDisplay,i.antiAlias=b.antiAlias),r.setTransform(1,0,0,1,0,0),b.deferredImages}var gT={1:"EMR_HEADER",2:"EMR_POLYBEZIER",3:"EMR_POLYGON",4:"EMR_POLYLINE",5:"EMR_POLYBEZIERTO",6:"EMR_POLYLINETO",14:"EMR_EOF",27:"EMR_MOVETOEX",37:"EMR_SELECTOBJECT",38:"EMR_CREATEPEN",39:"EMR_CREATEBRUSHINDIRECT",40:"EMR_DELETEOBJECT",42:"EMR_ELLIPSE",43:"EMR_RECTANGLE",54:"EMR_LINETO",59:"EMR_BEGINPATH",60:"EMR_ENDPATH",62:"EMR_FILLPATH",63:"EMR_STROKEANDFILLPATH",64:"EMR_STROKEPATH",70:"EMR_COMMENT",76:"EMR_BITBLT",81:"EMR_STRETCHDIBITS",84:"EMR_EXTTEXTOUTW",85:"EMR_POLYBEZIER16",86:"EMR_POLYGON16",87:"EMR_POLYLINE16",88:"EMR_POLYBEZIERTO16",91:"EMR_POLYPOLYGON16"};function fd(t,e,n,r,o,s=1,i={}){return Ei(Gc(t,e,n,r,o,s,i))}function*Gc(t,e,n,r,o,s=1,i={}){$(`replayEmfRecords: bounds=(${n.left},${n.top})\u2192(${n.right},${n.bottom}), canvas=${r}\xD7${o}`);let a=[],u=fa(),l=i.maxRecords??2e5,c=i.maxRecordsEmfPlus??5e5,f=n.right-n.left||1,m=n.bottom-n.top||1,b=r/f,h=o/m,p=s>0?s:1;u.imageCache=i.imageCache,u.gdiAntialias=i.gdiAntialias,u.codePages=i.codePages,u.baseTransform=i.plusBaseTransform??[b/p,0,0,h/p,-n.left*b,-n.top*h],u.nestingDepth=i.nestingDepth,$(`replayEmfRecords: logical=${f}\xD7${m}, scale=(${b.toFixed(4)},${h.toFixed(4)})`);let d={ctx:e,view:t,objectTable:new Map,state:{...ca(),fontFamilyMap:i.fontFamilyMap},stateStack:[],inPath:false,windowOrg:{x:0,y:0},windowExt:{cx:1,cy:1},viewportOrg:{x:0,y:0},viewportExt:{cx:1,cy:1},mapMode:1,useMappingMode:false,deviceToCanvas:true,clipSaveDepth:0,bounds:n,canvasW:r,canvasH:o,sx:b,sy:h,pathCmds:[],gdiAntialias:i.gdiAntialias,fonts:i.fonts,codePages:i.codePages},x=0,y=t.byteLength,g=0,M=0,P=new Map;for(;x+8<=y&&g<l;){Fe(),qr()&&(yield);let E=t.getUint32(x,true),R=t.getUint32(x+4,true);if(R<8||x+R>y)break;g++;let T=x+8;if(P.set(E,(P.get(E)??0)+1),E===70){if(R>=16){let w=t.getUint32(T,true),I=t.getUint32(T+4,true);if(I===726027589&&w>4){Nt(d),M++,$(`replayEmfRecords: EMF+ comment #${M} at offset 0x${x.toString(16)}, dataSize=${w}`);let S=yield*md(t,T+8,w-4,e,r,o,u,s,c,i.fontFamilyMap,i.textureCache,i.fonts);$(`replayEmfRecords: EMF+ comment #${M} returned ${S.length} deferred images`),a.push(...S);}else I===1128875079?$(`replayEmfRecords: EMR_COMMENT_PUBLIC at offset 0x${x.toString(16)}, size=${w}`):$(`replayEmfRecords: EMR_COMMENT (sig=0x${I.toString(16).padStart(8,"0")}) at offset 0x${x.toString(16)}, size=${w}`);}x+=R;continue}if(E===14){let w=[];for(let[I,S]of P)w.push(`${gT[I]??`0x${I.toString(16)}`}:${S}`);$(`replayEmfRecords: total deferred images = ${a.length}, EMF+ object table size = ${u.objectTable.size}`);break}if(E===28||E===98||E===115||E===1){x+=R;continue}if(Ci(E)||Nt(d),i.gdiDrawing===false){x+=R;continue}if(u.dualMode&&!u.gdiPassthrough){E===33?MT(d):E===34?R>=12&&ET(d,t.getInt32(T,true)):os(d,E,x,T,R),x+=R;continue}os(d,E,x,T,R)||ea(d,E,x,T,R)||oa(d,E,x,T,R)||console.warn(`[emf-converter] Unhandled EMR record type: ${E}`),x+=R;}if(Nt(d),g>=l&&console.warn(`[emf-converter] EMF record limit reached (${l}). Output may be incomplete.`),i.nestingDepth){let E=u.clipSaveDepth+d.clipSaveDepth+d.stateStack.length;for(;E-- >0;)e.restore();}return a}function MT(t){t.skippedDcStack??(t.skippedDcStack=[]),t.skippedDcStack.push({state:ma(t.state),mapping:{mapMode:t.mapMode,windowOrg:{...t.windowOrg},windowExt:{...t.windowExt},viewportOrg:{...t.viewportOrg},viewportExt:{...t.viewportExt},useMappingMode:t.useMappingMode}});}function ET(t,e){let n=t.skippedDcStack??[],r=e<0?n.length+e:e-1;if(r<0||r>=n.length)return;let o=n[r];n.length=r,Object.assign(t.state,o.state),Object.assign(t,o.mapping);}function PT(t,e,n,r,o,s){let i=new DataView(t);if(!Oo(i))return null;let[u,l,c,f,m,b]=o;if(l===0&&c===0&&u>0&&f>0){let p=-m/u,d=-b/f,x={left:p,top:d,right:p+n/u,bottom:d+r/f};return fd(i,e,x,n,r,1,s)}return fd(i,e,{left:0,top:0,right:n,bottom:r},n,r,1,{...s,plusBaseTransform:o,gdiDrawing:false})}mb(PT);function bd(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F￾￿]/g,"").replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"\uFFFD").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function hd(t,e){e.push("<",t.tag);for(let n of Object.keys(t.attrs))e.push(" ",n,'="',bd(String(t.attrs[n])),'"');if(t.text!==void 0){e.push(">",bd(t.text),"</",t.tag,">");return}if(!t.children||t.children.length===0){e.push("/>");return}e.push(">");for(let n of t.children)hd(n,e);e.push("</",t.tag,">");}function Oc(t){let e=[];return hd(t,e),e.join("")}var Rr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Nc(t){let e=[];for(let r=0;r<t.length;r+=12288){let o=Math.min(t.length,r+12288),s="",i=r;for(;i+2<o;i+=3){let a=t[i]<<16|t[i+1]<<8|t[i+2];s+=Rr[a>>18]+Rr[a>>12&63]+Rr[a>>6&63]+Rr[a&63];}if(i<o){let a=t[i]<<16|(i+1<o?t[i+1]:0)<<8;s+=Rr[a>>18]+Rr[a>>12&63]+(i+1<o?Rr[a>>6&63]:"=")+"=";}e.push(s);}return e.join("")}function RT(t){if(typeof TextEncoder<"u")return new TextEncoder().encode(t);let e=[];for(let n of t){let r=n.codePointAt(0);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):r<65536?e.push(224|r>>12,128|r>>6&63,128|r&63):e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63);}return Uint8Array.from(e)}function pd(t){return `data:image/svg+xml;base64,${Nc(RT(t))}`}function dd(t){return pd(Oc(t))}var xd=256*1024*1024;async function Wc(t){let e;if(t instanceof ArrayBuffer)e=t;else if(ArrayBuffer.isView(t))e=t.byteOffset===0&&t.byteLength===t.buffer.byteLength&&t.buffer instanceof ArrayBuffer?t.buffer:TT(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));else if(typeof Blob<"u"&&t instanceof Blob)e=await t.arrayBuffer();else return null;return AT(e)?wT(e):e}function TT(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}function AT(t){if(t.byteLength<18)return false;let e=new Uint8Array(t,0,3);return e[0]===31&&e[1]===139&&e[2]===8}async function wT(t){if(typeof DecompressionStream>"u")return null;try{let e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip")).getReader(),n=[],r=0;for(;;){let{done:i,value:a}=await e.read();if(i)break;if(r+=a.byteLength,r>xd)return await e.cancel(),z(`readMetafileInput: gzip input inflates past ${xd} bytes; refused`),null;n.push(a);}let o=new Uint8Array(r),s=0;for(let i of n)o.set(i,s),s+=i.byteLength;return o.buffer}catch(e){return z("readMetafileInput: gzip input is corrupt:",e instanceof Error?e.message:e),null}}var IT=15,ST=1128680791;function yd(t,e){let n=e,r=null,o=0,s=0,i=0,a=0,u=0;for(;n+6<=t.byteLength&&u++<1e6;){let c=t.getUint32(n,true)*2,f=t.getUint16(n+4,true);if(c<6||n+c>t.byteLength||f===0)break;if(f===1574&&c>=44){let m=n+6,b=t.getUint16(m,true),h=t.getUint16(m+2,true),p=m+4;if(b===IT&&h>=34&&t.getUint32(p,true)===ST&&t.getUint32(p+4,true)===1){let d=t.getUint32(p+18,true),x=t.getUint32(p+22,true),y=t.getUint32(p+26,true),g=t.getUint32(p+30,true),M=p+34;if(x>h-34||M+x>n+c)return null;if(!r){if(g===0||g>256*1024*1024)return null;r=new Uint8Array(g),s=g,i=d;}if(g!==s||o+x>s||y!==s-o-x)return null;r.set(new Uint8Array(t.buffer,t.byteOffset+M,x),o),o+=x,a++;}}n+=c;}if(!r||o!==s||a!==i)return null;let l=new DataView(r.buffer);return s<88||l.getUint32(0,true)!==1?null:r.buffer}var Te=class{constructor(e,n=64){this.type=e;this.len=8;this.bytes=new Uint8Array(Math.max(16,n)),this.view=new DataView(this.bytes.buffer);}ensure(e){if(this.len+e<=this.bytes.length)return;let n=new Uint8Array(Math.max(this.bytes.length*2,this.len+e));n.set(this.bytes),this.bytes=n,this.view=new DataView(n.buffer);}get offset(){return this.len}i32(e){return this.ensure(4),this.view.setInt32(this.len,e|0,true),this.len+=4,this}u32(e){return this.ensure(4),this.view.setUint32(this.len,e>>>0,true),this.len+=4,this}i16(e){return this.ensure(2),this.view.setInt16(this.len,e,true),this.len+=2,this}u16(e){return this.ensure(2),this.view.setUint16(this.len,e&65535,true),this.len+=2,this}f32(e){return this.ensure(4),this.view.setFloat32(this.len,e,true),this.len+=4,this}raw(e){return this.ensure(e.length),this.bytes.set(e,this.len),this.len+=e.length,this}align(){for(;this.len%4!==0;)this.ensure(1),this.bytes[this.len++]=0;return this}patchU32(e,n){return this.view.setUint32(e,n>>>0,true),this}finish(){return this.align(),this.view.setUint32(0,this.type,true),this.view.setUint32(4,this.len,true),new DataView(this.bytes.buffer,0,this.len)}};function Be(t,e){let n=e.getUint32(0,true),r=e.getUint32(4,true);Ci(n)||Nt(t);let o=t.view;t.view=e;try{!os(t,n,0,8,r)&&!ea(t,n,0,8,r)&&oa(t,n,0,8,r);}finally{t.view=o;}}var gd=[0,8388608,32768,8421376,128,8388736,32896,12632256,12639424,10930928,16776176,10526884,8421504,16711680,65280,16776960,255,16711935,65535,16777215];function Ed(){return {kind:"pen",style:0,width:0,color:0}}function Pd(){return {kind:"brush",style:0,color:16777215,hatch:0}}function Md(t,e,n){return t<<16|e<<8|n}function Vn(t,e){let n=t&255,r=t>>>8&255,o=t>>>16&255;if(t>>>24===1){let s=t&65535;if(e){let i=e.entries[s<e.entries.length?s:0];return i===void 0?0:Md(i&255,i>>>8&255,i>>>16&255)}return gd[s<gd.length?s:0]}return Md(n,r,o)}function Tr(t,e){let n=Vn(e,t.palette);return ms(n>>16&255,n>>8&255,n&255)}function zn(t,e){return t.getUint32(e,true)}function Rd(t,e){t.pen=e;let n=t.rCtx.state;n.penStyle=e.style&15,n.penFlags=e.style&15,n.penWidth=e.width,n.penColor=Tr(t,e.color),n.penUserStyle=void 0,n.penExtended=false;}function ss(t,e){t.brush=e;let n=t.rCtx.state;n.brushStyle=e.pattern?e.pattern.kind==="mono"?3:6:e.style,n.brushColor=Tr(t,e.color),n.brushPattern=e.pattern??(e.style===2&&e.hatch>=0&&e.hatch<=5?{kind:"hatch",hatch:e.hatch}:null);}function bo(t){Rd(t,t.pen),ss(t,t.brush),t.rCtx.state.textColor=Tr(t,t.textColor),t.rCtx.state.bkColor=Tr(t,t.bkColor);}function Ge(t,e){let n=0;for(;t.objects[n]!==void 0;)n++;t.objects[n]=e;}function Td(t,e,n){let{view:r}=t;if(n<16){Ge(t,{kind:"other"});return}Ge(t,{kind:"pen",style:r.getUint16(e,true),width:r.getInt16(e+2,true),color:zn(r,e+6)});}function Ad(t,e,n){let{view:r}=t;if(n<14){Ge(t,{kind:"other"});return}Ge(t,{kind:"brush",style:r.getUint16(e,true),color:zn(r,e+2),hatch:r.getUint16(e+6,true)});}function wd(t,e,n,r){let{view:o}=t;if(n<24){Ge(t,{kind:"other"});return}let s=[];for(let u=0;u<32&&e+18+u<r;u++){let l=o.getUint8(e+18+u);if(l===0)break;s.push(l);}let i=String.fromCharCode(...lo(s,1,{ansi:t.ansiCodePage}).codes),a={kind:"font",height:o.getInt16(e,true),weight:o.getInt16(e+8,true),italic:o.getUint8(e+10)!==0,underline:o.getUint8(e+11)!==0,strikeOut:o.getUint8(e+12)!==0,family:i||"sans-serif",escapementTenthDeg:o.getInt16(e+4,true),details:{width:o.getInt16(e+2,true),orientationTenthDeg:o.getInt16(e+6,true),charSet:o.getUint8(e+13),quality:o.getUint8(e+16),pitchAndFamily:o.getUint8(e+17)}};Ge(t,{kind:"font",font:a});}function Xc(t,e,n,r){if(n+40>r)return null;let o=e.getUint32(n,true),s=e.getUint16(n+14,true),i=e.getUint32(n+32,true);if(o<40||s>8)return null;let a=i||1<<s,u=n+o+a*2;if(u>r)return null;let l=r-u,c=new Uint8Array(o+a*4+l),f=new Uint8Array(e.buffer,e.byteOffset+n,r-n);c.set(f.subarray(0,o),0);for(let m=0;m<a;m++){let b=Vn(16777216|e.getUint16(n+o+m*2,true),t.palette);c[o+m*4]=b&255,c[o+m*4+1]=b>>8&255,c[o+m*4+2]=b>>16&255,c[o+m*4+3]=0;}return c.set(f.subarray(u-n),o+a*4),c}function Yc(t,e,n){let r=t.getUint32(e,true),o=t.getUint16(e+14,true),s=t.getUint32(e+16,true),a=t.getUint32(e+32,true);a===0&&o<=8&&(a=1<<o);let l=r+a*(4);return s===3&&r===40&&(l+=12),l}function vT(t,e,n,r,o){let s=t.view,i=e,a=n;if(r===1){let f=Xc(t,t.view,e,n);if(!f)return null;s=new DataView(f.buffer),i=0,a=f.length;}if(i+40>a)return null;let u=i+Yc(s,i);if(o&&s.getUint16(i+14,true)===1){let f=wa(s,i,u);if(f)return {kind:"mono",...f}}let l=Ue(s,i,u,Math.max(0,a-u));if(!l)return null;let c=new Uint32Array(l.width*l.height);for(let f=0;f<c.length;f++)c[f]=l.data[f*4]<<16|l.data[f*4+1]<<8|l.data[f*4+2];return {kind:"bitmap",width:l.width,height:l.height,rgb:c}}function Id(t,e,n){let{view:r}=t;if(e+4+40>n){Ge(t,{kind:"other"});return}let o=r.getUint16(e,true),s=r.getUint16(e+2,true),i=vT(t,e+4,n,s,o===3);Ge(t,{kind:"brush",style:i?6:0,color:8421504,hatch:0,...i?{pattern:i}:{}});}function Sd(t,e,n){let r=t.getUint16(e,true),o=t.getUint16(e+2,true),s=[];for(let i=0;i<o&&e+4+i*4+4<=n;i++)s.push(t.getUint32(e+4+i*4,true));return {start:r,entries:s}}function vd(t,e,n){if(e+4>n){Ge(t,{kind:"other"});return}Ge(t,{kind:"palette",entries:Sd(t.view,e,n).entries});}function $c(t,e,n,r){let o=t.palette;if(!o||e+4>n)return;let{start:s,entries:i}=Sd(t.view,e,n);for(let a=0;a<i.length&&s+a<o.entries.length;a++)r&&(o.entries[s+a]>>>24&1)===0||(o.entries[s+a]=i[a]);bo(t);}function Cd(t,e){let n=t.palette;if(n){if(e<n.entries.length)n.entries.length=e;else for(;n.entries.length<e;)n.entries.push(0);bo(t);}}function Ud(t,e){let n=t.objects[e];n?.kind==="palette"&&(t.palette=n,bo(t));}function _d(t,e,n){let{view:r}=t,o={kind:"region",rects:[]};if(e+22<=n){let s=r.getUint16(e+10,true),i=e+22;for(let a=0;a<s&&i+6<=n;a++){let u=r.getUint16(i,true),l=r.getInt16(i+2,true),c=r.getInt16(i+4,true),f=i+6;for(let m=0;m+1<u&&f+4<=n;m+=2,f+=4){let b=r.getInt16(f,true),h=r.getInt16(f+2,true);h>b&&c>l&&o.rects.push([b,l,h,c]);}i=f+2;}if(s===0){let a=r.getInt16(e+14,true),u=r.getInt16(e+16,true),l=r.getInt16(e+18,true),c=r.getInt16(e+20,true);l>a&&c>u&&o.rects.push([a,u,l,c]);}}Ge(t,o);}function Ld(t,e){let n=t.objects[e];if(!n)return;let r=t.rCtx.state;switch(n.kind){case "pen":Rd(t,n);break;case "brush":ss(t,n);break;case "font":{let o=n.font;r.fontHeight=o.height,r.fontWeight=o.weight,r.fontItalic=o.italic,r.fontUnderline=o.underline,r.fontStrikeOut=o.strikeOut,r.fontFamily=o.family,r.fontEscapementTenthDeg=o.escapementTenthDeg??0,r.fontDetails=o.details;break}}return n}function Dd(t,e){e>=0&&e<t.objects.length&&(t.objects[e]=void 0);}function jc(t,e,n,r,o){let s=yt(t.rCtx),i=(l,c)=>[Math.floor((s[0]*l+s[2]*c+s[4])/t.kx+.5),Math.floor((s[1]*l+s[3]*c+s[5])/t.ky+.5)],a=i(e,n),u=i(e+r,n+o);return [a[0],a[1],u[0]-a[0],u[1]-a[1]]}function Fd(t,e){let{rCtx:n}=t,r={windowOrg:n.windowOrg,windowExt:n.windowExt,viewportOrg:n.viewportOrg,viewportExt:n.viewportExt};n.windowOrg={x:0,y:0},n.windowExt={cx:1,cy:1},n.viewportOrg={x:0,y:0},n.viewportExt={cx:t.kx,cy:t.ky};try{e();}finally{Object.assign(n,r);}}function CT(t,e){if(!e||e.bmi.length<48)return e;let n=new DataView(e.bmi.buffer,e.bmi.byteOffset,e.bmi.byteLength);if(n.getUint16(14,true)!==1)return e;let r=e.bmi.slice(),o=n.getUint32(0,true),s=(i,a)=>{r[o+i*4]=a&255,r[o+i*4+1]=a>>8&255,r[o+i*4+2]=a>>16&255,r[o+i*4+3]=0;};return s(0,Vn(t.textColor,t.palette)),s(1,Vn(t.bkColor,t.palette)),{bmi:r,bits:e.bits}}function Vc(t,e,n,r){let{view:o}=t;if(e+40>n)return null;let s=new Uint8Array(o.buffer,o.byteOffset+e,n-e),i=new DataView(s.buffer,s.byteOffset,s.byteLength);if(r===1){let u=Xc(t,o,e,n);if(!u)return null;s=u,i=new DataView(u.buffer);}if(i.getUint32(0,true)<40)return null;let a=Yc(i,0);return a>s.length?null:{bmi:s.subarray(0,a),bits:s.subarray(a)}}function zc(t,e,n,r,o,s,i,a,u,l,c,f){[r,o,s,i]=jc(t,r,o,s,i);let m=e?108:100,b=new Te(e?77:76,m+(f?f.bmi.length+f.bits.length+8:0));b.i32(0).i32(0).i32(-1).i32(-1),b.i32(r).i32(o).i32(s).i32(i),b.u32(n),b.i32(a).i32(u),b.f32(1).f32(0).f32(0).f32(1).f32(0).f32(0),b.u32(0),b.u32(0);let h=b.offset;if(b.u32(0).u32(0).u32(0).u32(0),e&&b.i32(l).i32(c),f){let d=b.offset;b.raw(f.bmi).align();let x=b.offset;b.raw(f.bits),b.patchU32(h,d).patchU32(h+4,f.bmi.length).patchU32(h+8,x).patchU32(h+12,f.bits.length);}let p=b.finish();Fd(t,()=>Be(t.rCtx,p));}function kd(t,e,n,r,o,s,i,a,u,l,c,f=false){f||([n,r,o,s]=jc(t,n,r,o,s));let m=new Te(81,80+c.bmi.length+c.bits.length+8);m.i32(0).i32(0).i32(-1).i32(-1),m.i32(n).i32(r),m.i32(i).i32(a).i32(u).i32(l);let b=m.offset;m.u32(0).u32(0).u32(0).u32(0),m.u32(0),m.u32(e),m.i32(o).i32(s);let h=m.offset;m.raw(c.bmi).align();let p=m.offset;m.raw(c.bits),m.patchU32(b,h).patchU32(b+4,c.bmi.length).patchU32(b+8,p).patchU32(b+12,c.bits.length);let d=m.finish();Fd(t,()=>Be(t.rCtx,d));}function Bd(t,e,n){let{view:r}=t;if(e+12>n)return;let o=r.getUint32(e,true),s=r.getInt16(e+4,true),i=r.getInt16(e+6,true),a=r.getInt16(e+8,true),u=r.getInt16(e+10,true);zc(t,false,o,u,a,i,s,0,0,i,s,null);}function Gd(t,e){return e/2===(t>>8)+3}function Od(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true);if(!Gd(s,r))return;let i=n+6,a=i+4+(e?4:0)+6;if(a+8>n+r)return;let u=o.getUint32(i,true),l=o.getInt16(a,true),c=o.getInt16(a+2,true),f=o.getInt16(a+4,true),m=o.getInt16(a+6,true);zc(t,false,u,m,f,c,l,0,0,c,l,null);}function Nd(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true),i=n+6,a=n+r,u=Gd(s,r),l=i+4,c=()=>{let P=o.getInt16(l,true);return l+=2,P};if(i+4+(e?16:12)>a)return;let f=o.getUint32(i,true),m=e?c():0,b=e?c():0,h=c(),p=c();u&&(l+=2);let d=c(),x=c(),y=c(),g=c(),M=u?null:CT(t,Vc(t,l,a,0));zc(t,e,f,g,y,x,d,p,h,e?b:x,e?m:d,M);}function Wd(t,e,n){let{view:r}=t;if(e+22>n)return;let o=r.getUint32(e,true),s=r.getUint16(e+4,true),i=r.getInt16(e+6,true),a=r.getInt16(e+8,true),u=r.getInt16(e+10,true),l=r.getInt16(e+12,true),c=r.getInt16(e+14,true),f=r.getInt16(e+16,true),m=r.getInt16(e+18,true),b=r.getInt16(e+20,true),h=Vc(t,e+22,n,s);h&&kd(t,o,b,m,f,c,l,u,a,i,h);}function Hd(t,e,n){let{view:r}=t;if(e+18>n)return;let o=r.getUint16(e,true),s=r.getUint16(e+2,true),i=r.getUint16(e+4,true),a=r.getInt16(e+6,true),u=r.getInt16(e+8,true),l=r.getInt16(e+10,true),c=r.getInt16(e+12,true),f=r.getInt16(e+14,true),m=r.getInt16(e+16,true),b=Vc(t,e+18,n,o);if(!b||s===0)return;let h=Math.abs(new DataView(b.bmi.buffer,b.bmi.byteOffset,b.bmi.byteLength).getInt32(8,true));if(i!==0||s<h)return;let p=Math.max(a,i),d=Math.min(a+l,i+s);if(d<=p||c<=0)return;let x=b.bmi.slice(),y=new DataView(x.buffer),g=y.getInt32(8,true);y.setInt32(8,g<0?-s:s,true);let[M,P]=jc(t,m,f,0,0),E=t.layout&1?M-c:M;kd(t,13369376,E,P+(a+l-d),c,d-p,u,p-i,c,d-p,{bmi:x,bits:b.bits},true);}function Xd(t,e,n){let r=yt(t.rCtx),o=Math.round((r[0]*e+r[2]*n)*16)+Math.round(r[4]*16),s=Math.round((r[1]*e+r[3]*n)*16)+Math.round(r[5]*16);return [Math.floor((o/t.kx+8)/16),Math.floor((s/t.ky+8)/16)]}function ho(t,e,n,r,o){let s=Xd(t,e,n),i=Xd(t,r,o);return [Math.min(s[0],i[0]),Math.min(s[1],i[1]),Math.max(s[0],i[0]),Math.max(s[1],i[1])]}function UT(t,e){return e.map(([n,r,o,s])=>({x:n*t.kx,y:r*t.ky,w:(o-n)*t.kx,h:(s-r)*t.ky}))}function qc(t,e,n){Nt(t.rCtx);let r=e.length>0?sn(UT(t,e)):Le();Er(t.rCtx,r,n);}function Yd(t,e,n,r,o){qc(t,[ho(t,e,n,r,o)],"intersect");}function $d(t,e,n,r,o){qc(t,[ho(t,e,n,r,o)],"exclude");}function jd(t,e,n){let{rCtx:r}=t;if(!r.clipRegion)return;Nt(r);let o=yt(r),s=Math.round(o[0]*e/t.kx)*t.kx,i=Math.round(o[3]*n/t.ky)*t.ky;r.clipRegion=ir(r.clipRegion,s,i),We(r,r.clipRegion);}function Jc(t,e){let n=t.objects[e];if(n?.kind!=="region"){Nt(t.rCtx),t.rCtx.clipRegion=null,We(t.rCtx,null);return}qc(t,n.rects,"replace");}function ga(t,e){return e.rects.map(([n,r,o,s])=>ho(t,n,r,o,s)).filter(([n,r,o,s])=>o>n&&s>r)}function Vd(t,e){let n=new zt,r=new Map;for(let[o,s,i,a]of e){let u=Math.round(o*t.kx),l=Math.round(i*t.kx);for(let c=Math.round(s*t.ky);c<Math.round(a*t.ky);c++){let f=r.get(c);f||(f=[],r.set(c,f)),f.push([u,l]);}}for(let o of [...r.keys()].sort((s,i)=>s-i)){let s=r.get(o).sort((u,l)=>u[0]-l[0]),[i,a]=s[0];for(let u=1;u<s.length;u++)s[u][0]<=a?a=Math.max(a,s[u][1]):(n.add(o,i,a),[i,a]=s[u]);n.add(o,i,a);}return n}function Kc(t,e,n){let r=t.brush;if(n!==null){let s=t.objects[n];if(s?.kind!=="brush")return;ss(t,s);}let o=Je(t.rCtx);o&&se(t.rCtx,Vd(t,e),o,t.rCtx.state.rop2),n!==null&&ss(t,r);}function Ma(t,e){let n=t.objects[e];return n?.kind==="region"?n:null}function zd(t,e,n){let r=Ma(t,e);r&&Kc(t,ga(t,r),n);}function qd(t,e){let n=Ma(t,e);n&&Kc(t,ga(t,n),null);}function Jd(t,e){let n=Ma(t,e);n&&se(t.rCtx,Vd(t,ga(t,n)),{kind:"solid",rgb:0},6);}function _T(t){if(t.length===0)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let[u,l,c,f]of t)e=Math.min(e,u),n=Math.min(n,l),r=Math.max(r,c),o=Math.max(o,f);let s=r-e,i=o-n;if(s<=0||i<=0||s*i>64*1024*1024)return null;let a=new Uint8Array(s*i);for(let[u,l,c,f]of t)for(let m=l;m<f;m++)a.fill(1,(m-n)*s+(u-e),(m-n)*s+(c-e));return {x0:e,y0:n,w:s,h:i,m:a}}function Kd(t,e,n,r,o){let s=Ma(t,e);if(!s)return;let i=yt(t.rCtx),a=Math.abs(Math.round(i[0]*o/t.kx)),u=Math.abs(Math.round(i[3]*r/t.ky)),l=_T(ga(t,s));if(!l)return;let{x0:c,y0:f,w:m,h:b}=l,h=(d,x)=>d>=0&&x>=0&&d<m&&x<b?l.m[x*m+d]:0,p=[];for(let d=0;d<b;d++){let x=-1;for(let y=0;y<=m;y++){let g=y<m&&h(y,d)===1,M=g&&h(y-a,d)===1&&h(y+a,d)===1&&h(y,d-u)===1&&h(y,d+u)===1&&h(y-a,d-u)===1&&h(y+a,d-u)===1&&h(y-a,d+u)===1&&h(y+a,d+u)===1,P=g&&!M;P&&x<0?x=y:!P&&x>=0&&(p.push([c+x,f+d,c+y,f+d+1]),x=-1);}}Kc(t,p,n);}function LT(t,e,n){let r=new zt,o=Math.round(e*t.kx),s=Math.max(o+1,Math.round((e+1)*t.kx)),i=Math.round(n*t.ky),a=Math.max(i+1,Math.round((n+1)*t.ky));for(let u=i;u<a;u++)r.add(u,o,s);return r}function Zd(t,e,n,r){let[o,s]=ho(t,e,n,e,n);se(t.rCtx,LT(t,o,s),{kind:"solid",rgb:Vn(r,t.palette)},13);}function Zc(t,e,n,r,o){let{rCtx:s}=t,{ctx:i}=s,a=Tn(i);if(!a||false||typeof i.getImageData!="function")return;let u=Je(s);if(!u)return;Nt(s);let[l,c]=ho(t,e,n,e,n),f=Math.floor((l+.5)*t.kx),m=Math.floor((c+.5)*t.ky),{w:b,h}=a;if(f<0||m<0||f>=b||m>=h)return;let p=Tt(i,0,0,b,h).data,d=Vn(r,t.palette),x=T=>p[T*4+3]===0?16777215:p[T*4]<<16|p[T*4+1]<<8|p[T*4+2],y=o===1,g=T=>y?x(T)===d:x(T)!==d,M=m*b+f;if(!g(M))return;let P=new Uint8Array(b*h),E=[M];for(P[M]=1;E.length>0;){let T=E.pop(),A=T%b,w=(T-A)/b,I=S=>{!P[S]&&g(S)&&(P[S]=1,E.push(S));};A>0&&I(T-1),A+1<b&&I(T+1),w>0&&I(T-b),w+1<h&&I(T+b);}let R=new zt;for(let T=0;T<h;T++){let A=-1;for(let w=0;w<=b;w++){let I=w<b&&P[T*b+w]===1;I&&A<0?A=w:!I&&A>=0&&(R.add(T,A,w),A=-1);}}se(s,R,u,s.state.rop2);}var Qd=5,t1=6;function Ea(t,e,n,r,o,s={}){let i=s.exclusive!==false,a=dt(t.rCtx,e,n),u=dt(t.rCtx,r,o),l=16*t.kx,c=16*t.ky,f={x0:Math.min(a[0],u[0]),y0:Math.min(a[1],u[1]),x1:Math.max(a[0],u[0])-(i?Math.round(l):0),y1:Math.max(a[1],u[1])-(i?Math.round(c):0)};if(!i)return f;if(s.curved&&tm(t)&&(f.x0-=Math.round(l/4),f.y0-=Math.round(c/4),f.x1-=Math.round(l*3/4),f.y1-=Math.round(c*3/4)),(t.rCtx.state.penStyle&15)===t1&&Math.round(Bi(t.rCtx)/t.kx)>1){let b={...f},h=yt(t.rCtx),p=Math.round(Math.abs(t.rCtx.state.penWidth*h[0])/t.kx*16),d=Math.round(Math.abs(t.rCtx.state.penWidth*h[3])/t.ky*16);f.x1+=Math.round(l),f.y1+=Math.round(c),f.x0+=Math.round((s.curved||s.roundFrame?Math.floor(p/2):Math.ceil(p/2))*l/16),f.y0+=Math.round(Math.ceil(d/2)*c/16);let x=!!s.half&&p%2===1;if(f.x1-=Math.round((x?Math.ceil(p/2):Math.floor(p/2))*l/16),f.y1-=Math.round(Math.ceil(d/2)*c/16),x&&(f.halfX=true),s.clampEmpty&&(f.x1<f.x0||f.y1<f.y0))return {x0:b.x0,y0:b.y0,x1:b.x1+Math.round(l),y1:b.y1+Math.round(c)}}return f}function Pa(t,e,n=false){let r=n?Jn(t.x0,t.y0,t.x1,t.y1):Jn(t.x0,t.y0,Math.max(t.x0,t.x1),Math.max(t.y0,t.y1));return t.halfX&&(r.halfX=true,r.halfXCompat=true),e&&(r.cornerExact=e),r}function is(t){return {x:t.x0/16,y:t.y0/16,w:Math.max(0,t.x1-t.x0)/16,h:Math.max(0,t.y1-t.y0)/16}}function DT(t,e){let{state:n}=t.rCtx,r=$n(t.rCtx);if(hr(n,r)===0||br(n,r)!==1)return;let o=is(e);if(!(o.w<=1||o.h<=1))return s=>{s.beginPath(),s.rect(o.x+1,o.y+1,o.w-1,o.h-1);}}function e1(t,e,n,r,o){let s=Ea(t,e,n,r,o);if(s.x1<s.x0||s.y1<s.y0)return;let i=is(s),{rCtx:a}=t,{state:u}=a,l=u.penStyle===Qd||(u.penStyle===0||u.penStyle===6)&&xe(a);if(a.gdiAntialias!==false&&l&&Qt(u).kind!=="tile"&&(he(u.rop2).exact||!Yn(u.rop2))){let{ctx:c}=a;Nt(a),Ur(c,u),c.fillRect(i.x,i.y,i.w,i.h),Cr(c,u),c.lineWidth=1;let f=hr(u,$n(a));c.strokeRect(i.x+f,i.y+f,i.w,i.h);return}Jt(t.rCtx,{build:c=>{c.beginPath(),c.rect(i.x,i.y,i.w,i.h);},raster:()=>fr(Pa(s),Qc(t)),rectangle:true,fill:true,stroke:true,axisRect:{interior:DT(t,s)}});}function FT(t,e,n,r,o){let s=yt(t.rCtx);Math.round(Math.abs(e*s[0])*16);Math.round(Math.abs(n*s[3])*16);let u=16*t.kx,l=16*t.ky;if((t.rCtx.state.penStyle&15)===t1&&!xe(t.rCtx)){let p=r.x1-r.x0,d=r.y1-r.y0,x=Math.abs((o[2]-o[0])*s[0])*16||p,y=Math.abs((o[3]-o[1])*s[3])*16||d,g=Math.min(Math.abs(e*s[0])*16,x)*p/x;return [Math.floor(g),Math.floor(Math.min(Math.abs(n*s[3])*16,y)*d/y),[g,Math.min(Math.abs(n*s[3])*16,y)*d/y]]}let c=r.x1-r.x0,f=r.y1-r.y0,m=Math.abs((o[2]-o[0])*s[0])*16||c+u,b=Math.abs((o[3]-o[1])*s[3])*16||f+l,h=[Math.min(Math.abs(e*s[0])*16,m)*c/m,Math.min(Math.abs(n*s[3])*16,b)*f/b];return xe(t.rCtx)&&!tm(t)?h:[Math.floor(h[0]),Math.floor(h[1])]}function n1(t,e,n,r,o,s,i){let a=Ea(t,e,n,r,o,{curved:true,half:true,clampEmpty:true});if(a.x1<a.x0||a.y1<a.y0)return;let[u,l,c]=FT(t,s,i,a,[e,n,r,o]),f=is(a);Jt(t.rCtx,{build:m=>{m.beginPath();let b=Math.min(u/32,f.w/2),h=Math.min(l/32,f.h/2);if(b<=0||h<=0){m.rect(f.x,f.y,f.w,f.h);return}let p=Math.PI/2,d=f.x+f.w,x=f.y+f.h;m.moveTo(f.x+b,f.y),m.lineTo(d-b,f.y),m.ellipse(d-b,f.y+h,b,h,0,-p,0),m.lineTo(d,x-h),m.ellipse(d-b,x-h,b,h,0,0,p),m.lineTo(f.x+b,x),m.ellipse(f.x+b,x-h,b,h,0,p,2*p),m.lineTo(f.x,f.y+h),m.ellipse(f.x+b,f.y+h,b,h,0,2*p,3*p),m.closePath();},raster:()=>ki(Pa(a,c),u,l,Qc(t),s===0||i===0,!tm(t)&&xe(t.rCtx)),roundPen:true,fill:true,stroke:true});}function r1(t,e,n,r,o){let s=Ea(t,e,n,r,o,{curved:true,half:true,clampEmpty:true});if(s.x1<s.x0||s.y1<s.y0)return;let i=is(s);Jt(t.rCtx,{build:a=>{a.beginPath(),a.ellipse(i.x+i.w/2,i.y+i.h/2,i.w/2,i.h/2,0,0,Math.PI*2);},raster:()=>Yo(Pa(s),Qc(t)),roundPen:true,fill:true,stroke:true});}function kT(t,e,n,r,o,s,i,a,u,l,c=false){let f=Ea(t,n,r,o,s,{curved:e==="chord"||e==="pie",roundFrame:true,half:true});if(f.y1<f.y0||!c&&f.x1<f.x0)return null;let m=yt(t.rCtx),b=(P,E)=>[(m[0]*P+m[2]*E+m[4])*16,(m[1]*P+m[3]*E+m[5])*16],[h,p]=b(n,r),[d,x]=b(o,s),y={x0:Math.min(h,d),x1:Math.max(h,d),y0:Math.min(p,x),y1:Math.max(p,x)},g=(P,E,R,T,A)=>(T+A)/2+(R!==E?(P-(E+R)/2)*(A-T)/(R-E):P-(E+R)/2),M=(P,E)=>{let[R,T]=b(P,E);return [g(R,y.x0,y.x1,f.x0,f.x1),g(T,y.y0,y.y1,f.y0,f.y1)]};return {box:f,s:M(i,a),e:M(u,l)}}function o1(t,e,n,r,o,s,i,a,u,l){let c=kT(t,e,n,r,o,s,i,a,u,l);if(!c)return;let{box:f,s:m,e:b}=c,h=t.rCtx.state.arcDirection===2,p=is(f),d=p.x+p.w/2,x=p.y+p.h/2,y=p.w/2||1,g=p.h/2||1,M=Math.atan2((m[1]/16-x)/g,(m[0]/16-d)/y),P=Math.atan2((b[1]/16-x)/g,(b[0]/16-d)/y),E=e==="chord"||e==="pie";Jt(t.rCtx,{build:R=>{R.beginPath(),e==="pie"&&R.moveTo(d,x),R.ellipse(d,x,p.w/2,p.h/2,0,M,P,!h),E&&R.closePath();},raster:()=>to(Pa(f),m,b,h,e).path,fill:E,stroke:true});}function Qc(t){return t.rCtx.state.arcDirection===2}function tm(t){return (t.rCtx.state.penStyle&15)===Qd}function BT(t,e){let n=t.rCtx.fonts;if(!n)return null;let r=yt(t.rCtx),o=n.realize(ec(t.rCtx.state,Math.hypot(r[2],r[3]),Math.hypot(r[0],r[1])),t.rCtx.state.fontFamilyMap);return o?e.map(s=>o.advance(o.glyphIndex(s))):null}function GT(t,e){if(t.charExtra===0&&(t.justifyExtra===0||t.justifyCount===0))return null;let n=BT(t,e);if(!n)return null;let r=yt(t.rCtx),o=Math.hypot(r[0],r[1])||1,s=Math.round(t.charExtra*o),i=32,a=t.justifyCount,u=a>0?Math.round(t.justifyExtra*o):0,l=f=>Math.round((f+1)*u/a)-Math.round(f*u/a),c=0;return n.map((f,m)=>{let b=f+s;return e[m]===i&&a>0&&(b+=l(c++)),b/o})}function OT(t,e,n,r){let{rCtx:o}=t;if(!o.fonts)return false;Nt(o);let s=e.rect,i=ta(o.ctx,o.fonts,o.state,{codes:n,glyphIndices:false,x:e.x,y:e.y,options:e.options,rect:s?{left:s[0],top:s[1],right:s[2],bottom:s[3]}:null,dx:r,dy:null,matrix:yt(o)});return i?(o.state.textAlign&1&&(o.state.curX+=i.dx,o.state.curY+=i.dy),true):false}function em(t,e){let n=t.rCtx.state.fontDetails?.charSet??1,{codes:r,byteLengths:o}=lo(e.bytes,n,{ansi:t.ansiCodePage,oem:t.oemCodePage}),s=r.length;if(s===0)return;let i=0,a=e.dx?o.map(m=>{let b=0;for(let h=0;h<m;h++)b+=e.dx[i++]??0;return b}):GT(t,r);if(OT(t,e,r,a))return;let u=new Te(84,76+s*6+8);u.i32(0).i32(0).i32(-1).i32(-1),u.u32(1),u.f32(1).f32(1),u.i32(e.x).i32(e.y),u.u32(s);let l=u.offset;u.u32(0),u.u32(e.options);let c=e.rect??[0,0,0,0];u.i32(c[0]).i32(c[1]).i32(c[2]).i32(c[3]);let f=u.offset;u.u32(0),u.patchU32(l,u.offset);for(let m of r)u.u16(m);if(u.align(),a){u.patchU32(f,u.offset);for(let m of a)u.u32(Math.round(m)>>>0);}Be(t.rCtx,u.finish());}function s1(t,e,n){let{view:r}=t;if(e+2>n)return;let o=r.getInt16(e,true),s=e+2,i=s+o+(o&1);if(o<=0||i+4>n)return;let a=[];for(let u=0;u<o;u++)a.push(r.getUint8(s+u));em(t,{y:r.getInt16(i,true),x:r.getInt16(i+2,true),bytes:a,options:0,rect:null,dx:null});}function i1(t,e,n){let{view:r}=t;if(e+8>n)return;let o=r.getInt16(e,true),s=r.getInt16(e+2,true),i=r.getInt16(e+4,true),a=r.getUint16(e+6,true),u=(a&(co|mo))!==0,l=e+8+(u?8:0),c=u&&e+16<=n?[r.getInt16(e+8,true),r.getInt16(e+10,true),r.getInt16(e+12,true),r.getInt16(e+14,true)]:null,f=Math.max(0,i);if(l+f>n)return;let m=[];for(let p=0;p<f;p++)m.push(r.getUint8(l+p));let b=l+f+(f&1),h=null;if(f>0&&b+f*2<=n){h=[];for(let p=0;p<f;p++)h.push(r.getInt16(b+p*2,true));}if(f===0){c&&a&co&&em(t,{x:s,y:o,bytes:[32],options:a,rect:c,dx:[0]});return}em(t,{x:s,y:o,bytes:m,options:a,rect:c,dx:h});}function Q4(t,e,n,r,o,s={}){let i=la(t,n,s.wmfReferenceDpi),a=r/i.width,u=o/i.height,l={...ca(),fontFamilyMap:s.fontFamilyMap},c={ctx:e,view:t,objectTable:new Map,state:l,stateStack:[],inPath:false,windowOrg:{x:0,y:0},windowExt:{cx:1,cy:1},viewportOrg:{x:0,y:0},viewportExt:{cx:1,cy:1},useMappingMode:true,clipSaveDepth:0,bounds:{left:0,top:0,right:i.width,bottom:i.height},canvasW:r,canvasH:o,sx:a,sy:u,pathCmds:[],gdiAntialias:s.gdiAntialias,fonts:s.fonts,wholeDevicePixels:[a,u]},f={rCtx:c,ansiCodePage:s.wmfAnsiCodePage??s.codePages?.ansi,oemCodePage:s.codePages?.oem,view:t,kx:a,ky:u,devW:i.width,devH:i.height,objects:[],stack:[],mapping:i.mapping,pen:Ed(),brush:Pd(),palette:null,textColor:0,bkColor:16777215,charExtra:0,justifyExtra:0,justifyCount:0,layout:0};return xc(c,f.mapping,a,u),bo(f),f}function tn(t){xc(t.rCtx,t.mapping,t.kx,t.ky,t.layout&1?t.devW:0);}function tA(t){return {mapping:dc(t.mapping),pen:t.pen,brush:t.brush,palette:t.palette,textColor:t.textColor,bkColor:t.bkColor,charExtra:t.charExtra,justifyExtra:t.justifyExtra,justifyCount:t.justifyCount,layout:t.layout}}function as(t,e,n){Be(t.rCtx,new Te(e,16).u32(n).finish());}function eA(t,e,n,r){let o=new Te(e,28+n*4);o.i32(0).i32(0).i32(-1).i32(-1).u32(n);for(let s=0;s<n;s++)o.i16(t.view.getInt16(r+s*4,true)).i16(t.view.getInt16(r+s*4+2,true));Be(t.rCtx,o.finish());}function nA(t,e,n,r){let{view:o,rCtx:s}=t,i=n+6,a=n+r,u=f=>i+f<=a,l=f=>o.getInt16(i+f*2,true),c=f=>o.getUint16(i+f*2,true);switch(e){case 259:u(2)&&(ia(t.mapping,c(0)),tn(t));return;case 523:u(4)&&(t.mapping.winOrg={y:l(0),x:l(1)},tn(t));return;case 524:u(4)&&(Cp(t.mapping,l(1),l(0)),tn(t));return;case 525:u(4)&&(t.mapping.vpOrg={y:l(0),x:l(1)},tn(t));return;case 526:u(4)&&(Up(t.mapping,l(1),l(0)),tn(t));return;case 527:u(4)&&(t.mapping.winOrg={x:t.mapping.winOrg.x+l(1),y:t.mapping.winOrg.y+l(0)},tn(t));return;case 529:u(4)&&(t.mapping.vpOrg={x:t.mapping.vpOrg.x+l(1),y:t.mapping.vpOrg.y+l(0)},tn(t));return;case 1040:u(8)&&(aa(t.mapping,l(3),l(2),l(1),l(0)),tn(t));return;case 1042:u(8)&&(ua(t.mapping,l(3),l(2),l(1),l(0)),tn(t));return;case 30:t.stack.push(tA(t)),Be(s,new Te(33,8).finish());return;case 295:{let f=u(2)?l(0):-1,m=t.stack.length;if(f<0&&(f=m+f+1),f<1||f>m)return;let b=t.stack[f-1];t.stack.length=f-1,Be(s,new Te(34,12).i32(f).finish()),Object.assign(t,{...b,mapping:dc(b.mapping)}),tn(t),bo(t);return}case 521:u(4)&&(t.textColor=zn(o,i),s.state.textColor=Tr(t,t.textColor));return;case 513:u(4)&&(t.bkColor=zn(o,i),s.state.bkColor=Tr(t,t.bkColor));return;case 258:u(2)&&as(t,18,c(0));return;case 260:u(2)&&as(t,20,c(0));return;case 262:u(2)&&as(t,19,c(0));return;case 263:u(2)&&as(t,21,c(0));return;case 302:u(2)&&as(t,22,c(0));return;case 264:u(2)&&(t.charExtra=l(0));return;case 522:u(4)&&(t.justifyCount=l(0),t.justifyExtra=l(1));return;case 329:u(4)&&(t.layout=o.getUint32(i,true),tn(t));return;case 261:case 561:case 1574:case 53:return;case 762:Td(t,i,r);return;case 764:Ad(t,i,r);return;case 763:wd(t,i,r,a);return;case 322:Id(t,i,a);return;case 505:return;case 247:vd(t,i,a);return;case 1791:_d(t,i,a);return;case 248:case 1790:case 765:Ge(t,{kind:"other"});return;case 301:u(2)&&(t.objects[c(0)]?.kind==="region"?Jc(t,c(0)):Ld(t,c(0)));return;case 564:u(2)&&Ud(t,c(0));return;case 55:$c(t,i,a,false);return;case 1078:$c(t,i,a,true);return;case 313:u(2)&&Cd(t,c(0));return;case 496:u(2)&&Dd(t,c(0));return;case 532:u(4)&&Be(s,new Te(27,16).i32(l(1)).i32(l(0)).finish());return;case 531:u(4)&&Be(s,new Te(54,16).i32(l(1)).i32(l(0)).finish());return;case 1051:u(8)&&e1(t,l(3),l(2),l(1),l(0));return;case 1564:u(12)&&n1(t,l(5),l(4),l(3),l(2),l(1),l(0));return;case 1048:u(8)&&r1(t,l(3),l(2),l(1),l(0));return;case 2071:case 2096:case 2074:u(16)&&o1(t,e===2071?"arc":e===2096?"chord":"pie",l(7),l(6),l(5),l(4),l(3),l(2),l(1),l(0));return;case 804:case 805:if(u(2)){let f=l(0);f>0&&u(2+f*4)&&eA(t,e===804?86:87,f,i+2);}return;case 1336:if(u(2)){let f=c(0);if(f===0||!u(2+f*2))return;let m=[],b=0;for(let d=0;d<f;d++){let x=o.getUint16(i+2+d*2,true);m.push(x),b+=x;}let h=i+2+f*2;if(!u(2+f*2+b*4))return;let p=new Te(91,32+f*4+b*4);p.i32(0).i32(0).i32(-1).i32(-1).u32(f).u32(b);for(let d of m)p.u32(d);for(let d=0;d<b;d++)p.i16(o.getInt16(h+d*4,true)).i16(o.getInt16(h+d*4+2,true));Be(s,p.finish());}return;case 1313:s1(t,i,a);return;case 2610:i1(t,i,a);return;case 1565:Bd(t,i,a);return;case 2338:case 2851:Od(t,e===2851,n,r);return;case 2368:case 2881:Nd(t,e===2881,n,r);return;case 3907:Wd(t,i,a);return;case 3379:Hd(t,i,a);return;case 1046:u(8)&&Yd(t,l(3),l(2),l(1),l(0));return;case 1045:u(8)&&$d(t,l(3),l(2),l(1),l(0));return;case 544:u(4)&&jd(t,l(1),l(0));return;case 300:u(2)&&Jc(t,c(0));return;case 552:u(4)&&zd(t,c(0),c(1));return;case 299:u(2)&&qd(t,c(0));return;case 298:u(2)&&Jd(t,c(0));return;case 1065:u(8)&&Kd(t,c(0),c(1),l(2),l(3));return;case 1055:u(8)&&Zd(t,l(3),l(2),zn(o,i));return;case 1049:u(8)&&Zc(t,l(3),l(2),zn(o,i),0);return;case 1352:u(10)&&Zc(t,l(4),l(3),zn(o,i+2),c(0));return;default:return}}function*f1(t,e,n,r,o,s={}){let i=Q4(t,e,n,r,o,s),a=n.headerSize,u=t.byteLength,l=s.maxRecords??2e5,c=0;for(;a+6<=u&&c<l;){let m=t.getUint32(a,true)*2,b=t.getUint16(a+4,true);if(m<6||a+m>u||b===0)break;c++,Fe(),qr()&&(yield),nA(i,b,a,m),a+=m;}Nt(i.rCtx);let f=i.rCtx.clipSaveDepth+i.rCtx.stateStack.length;for(;f-- >0;)e.restore();c>=l&&console.warn(`[emf-converter] WMF record limit reached (${l}). Output may be incomplete.`);}function Ra(t,e){return e?{...t,[Mi]:e}:t}var ls=3;async function p1(t,e,n){if($(`replayMetafile: input buffer ${t.byteLength} bytes`),t.byteLength>=16){let u=new Uint8Array(t,0,16);$(`replayMetafile: first 16 bytes: [${Array.from(u).map(l=>l.toString(16).padStart(2,"0")).join(" ")}]`);}let r=e??{},o=zr(r),s=r.dpiScale??Zn,i=new DataView(t),a=null;try{a=Oo(i);}catch(u){z("replayMetafile: parseEmfHeader threw during detection:",u instanceof Error?u.message:u);}if(!a)try{let u=el(i),l=u?yd(i,u.headerSize):null;if(l){let c=new DataView(l);a=Oo(c),a&&($("replayMetafile: WMF carries an embedded EMF; playing the EMF"),i=c);}}catch(u){z("replayMetafile: embedded-EMF probe threw:",u instanceof Error?u.message:u);}if(a){try{let u=await si(i),l=await Cu(i);o?.check();let c=db(a);if(!c)return $("replayMetafile: getRenderableEmfBounds returned null"),null;let f=n(c.right-c.left,c.bottom-c.top);if(!f)return $("replayMetafile: surface creation failed"),null;f.ctx.save();let m=await Qu(o,Gc(i,f.ctx,c,f.width,f.height,s,{maxRecords:r.maxRecords,maxRecordsEmfPlus:r.maxRecords,fontFamilyMap:r.fontFamilyMap,codePages:{ansi:r.ansiCodePage,oem:r.oemCodePage},textureCache:u,imageCache:l,gdiAntialias:r.gdiAntialias,fonts:b1(r)}));return f.ctx.restore(),$(`replayMetafile: EMF replay done, ${m.length} deferred images`),{surface:f,deferredImages:m}}catch(u){return o?.throwIfTripped(),z("replayMetafile: EMF EXCEPTION:",u instanceof Error?u.message:u),console.warn("[emf-converter] EMF conversion failed:",u instanceof Error?u.message:u),null}}try{let u=el(i);if(!u)return $("replayMetafile: parseWmfHeader returned null"),null;if(u.boundsRight-u.boundsLeft<=0||u.boundsBottom-u.boundsTop<=0)return $("replayMetafile: invalid WMF dimensions"),null;let l=la(i,u,r.wmfReferenceDpi),c=n(l.width,l.height);return c?(c.ctx.save(),await Qu(o,f1(i,c.ctx,u,c.width,c.height,{wmfReferenceDpi:r.wmfReferenceDpi,wmfAnsiCodePage:r.wmfAnsiCodePage,codePages:{ansi:r.ansiCodePage,oem:r.oemCodePage},maxRecords:r.maxRecords,fontFamilyMap:r.fontFamilyMap,gdiAntialias:r.gdiAntialias,fonts:b1(r)})),c.ctx.restore(),{surface:c,deferredImages:[]}):null}catch(u){return o?.throwIfTripped(),z("replayMetafile: WMF EXCEPTION:",u instanceof Error?u.message:u),console.warn("[emf-converter] WMF conversion failed:",u instanceof Error?u.message:u),null}}function b1(t){if(!t.fonts||t.fonts.length===0)return;let e=Ti.for(t.fonts,t.fontSmoothing??"cleartype");return e.size>0?e:void 0}function us(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}function rA(t,e,n){let r=t.canvas,o=r?.width,s=r?.height;if(typeof o!="number"||typeof s!="number")return false;let{width:i,height:a}=e,u=It(i,a);if(!u)return false;le(u.ctx,e.drawable,0,0,i,a);let l=Tt(u.ctx,0,0,i,a),c=on(l.data,i,a,n,{w:o,h:s});if(!c)return false;let f=It(c.w,c.h);return f?(Ct(f.ctx,Et(c.rgba,c.w,c.h),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.imageSmoothingEnabled=false,le(t,f.canvas,c.x,c.y,c.w,c.h),t.restore(),true):false}async function oA(t,e,n,r){$(`processDeferredImages: ${e.length} deferred images (recursionDepth=${n})`);let o=true;for(let s=0;s<e.length;s++){let i=e[s];r?.check();try{let a=us(i.imageData);t.setTransform(...i.transform);let u=a,l;if(i.isMetafile){if(n>=ls){z(` Deferred image [${s}]: skipping embedded metafile, recursion depth ${n}`);continue}let f=await d1(a,Ra({format:"png"},r),n+1);if(!f){z(` Deferred image [${s}]: metafile conversion returned null`),o=!1;continue}l=f.mimeType,u=us(f.data.buffer);}if(i.effect&&!i.isMetafile){let f=await om(u);if(f){let m=gi({kind:"plus-image",type:1,data:i.imageData},{kind:"bitmap",rgba:f.data,width:f.width,height:f.height},i.effect,i,i.effectSource);m&&(u=us((await Ri(m.bitmap.rgba,m.bitmap.width,m.bitmap.height)).buffer),i=m.draw,t.setTransform(...i.transform)),l="image/png";}}let c=await Lr(u,l);c?(i.resample&&rA(t,c,i.resample)||le(t,c.drawable,i.dx,i.dy,i.dw,i.dh),c.close()):(z(` Deferred image [${s}]: no image decoder available`),o=!1);}catch(a){r?.throwIfTripped(),o=false;let u=a instanceof Error?a.message:String(a);console.warn("[emf-converter] Deferred image draw failed:",u,`(isMetafile=${i.isMetafile}, dataLen=${i.imageData.byteLength})`);}}return t.setTransform(1,0,0,1,0,0),o}var h1={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml"};async function d1(t,e,n=0){let r=e?.format??"png",o=zr(e);if(o?.check(),e=Ra(e,o),r==="svg"){let i=await y1(t,e,n);if(!i)return null;o?.check();let a=Oc(await i.toTree({includeSize:e.includeSize}));return o?.check(),{format:r,mimeType:h1.svg,data:new TextEncoder().encode(a),width:i.canvas.width,height:i.canvas.height}}let s=await rm(t,e,n);if(!s)return null;try{let{data:i,width:a,height:u}=s,l;if(r==="jpeg"){let c=e;l=Bo(o,()=>hb(i,a,u,{quality:c.quality,background:iA(c.background),chromaSubsampling:c.chromaSubsampling}));}else if(r==="webp"){let c=e;l=Bo(o,()=>pb(i,a,u,{lossy:c.lossless===!1,quality:c.quality}));}else l=await Bo(o,()=>Ri(i,a,u));return o?.check(),{format:r,mimeType:h1[r],data:l,width:a,height:u}}catch(i){return o?.throwIfTripped(),z("convertMetafile: EXCEPTION:",i instanceof Error?i.message:i),console.warn("[emf-converter] Conversion failed:",i instanceof Error?i.message:i),null}}async function rm(t,e,n=0){let r=zr(e);r?.check();let o=await Wc(t);r?.check();let s=o?await aA(o,Ra(e,r),n,"convertMetafileToImageData"):null;if(!s)return null;try{let{canvas:i,ctx:a}=s;return {data:i instanceof dn?new Uint8ClampedArray(i.pixels):Tt(a,0,0,i.width,i.height).data,width:i.width,height:i.height}}catch(i){return r?.throwIfTripped(),z("convertMetafileToImageData: EXCEPTION:",i instanceof Error?i.message:i),console.warn("[emf-converter] Conversion failed:",i instanceof Error?i.message:i),null}}async function x1(t,e){return sA(await d1(t,{...e,format:"png"}))}function sA(t){return t?`data:${t.mimeType};base64,${Nc(t.data)}`:null}function iA(t){if(t===void 0)return [255,255,255];let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim())?.[1];if(!e)return [255,255,255];let n=e.length===3?[...e].map(r=>r+r).join(""):e;return [0,2,4].map(r=>parseInt(n.slice(r,r+2),16))}async function aA(t,e,n,r){let o=zr(e);if(await Va(),n>ls)return null;let s={...e,gdiAntialias:e?.gdiAntialias??false};o?.check();let i=null,a=await p1(t,s,(u,l)=>{let c=Is(u,l,s.maxWidth,s.maxHeight,s.dpiScale??Zn,s.maxCanvasDimension);return c?(i=c.canvas,{ctx:c.ctx,width:c.canvas.width,height:c.canvas.height}):null});if(!a||!i)return null;try{let u=await oA(a.surface.ctx,a.deferredImages,n,o),l=i instanceof dn?i:null;return l&&(l.textDraws>0||!u)?(z(`${r}: no canvas backend and the drawing ${l.textDraws>0?`contains text (${l.textDraws} runs)`:"contains an image only a canvas can decode"}; install @napi-rs/canvas for raster output, or use SVG output`),null):{canvas:i,ctx:a.surface.ctx}}catch(u){return o?.throwIfTripped(),z(`${r}: EXCEPTION:`,u instanceof Error?u.message:u),console.warn("[emf-converter] Conversion failed:",u instanceof Error?u.message:u),null}}var nm=0;async function om(t){let e=await As(new Uint8Array(t));if(e||ws())return e;let n=await Lr(t);if(!n)return null;try{let r=It(n.width,n.height);return r?(le(r.ctx,n.drawable,0,0,n.width,n.height),{data:Tt(r.ctx,0,0,n.width,n.height).data,width:n.width,height:n.height}):null}finally{n.close();}}async function uA(t,e,n){let r=await om(t);return r?on(r.data,r.width,r.height,e,{w:n.width,h:n.height}):null}async function lA(t,e,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];o?.check();try{let a=us(i.imageData);if(i.effect&&!i.isMetafile){let f=await om(a);if(f){let m=gi({kind:"plus-image",type:1,data:i.imageData},{kind:"bitmap",rgba:f.data,width:f.width,height:f.height},i.effect,i,i.effectSource);m&&(a=us((await Ri(m.bitmap.rgba,m.bitmap.width,m.bitmap.height)).buffer),i=m.draw);}}let u=null;if(i.isMetafile){if(r>=ls){z(` Deferred image [${s}]: skipping embedded metafile, recursion depth ${r}`);continue}let f=await cA(a,{...n,includeSize:!0,idPrefix:void 0},r+1);f&&(u={kind:"url",url:dd(f)});}else {let f=new Uint8Array(a),m=Us(f);if(m)u={kind:"encoded",bytes:f,mime:m};else if(u=go(a),!u){let b=await Lr(a);if(b){let h=Is(b.width,b.height,void 0,void 0,1);h&&(le(h.ctx,b.drawable,0,0,b.width,b.height),u={kind:"rgba",data:h.ctx.getImageData(0,0,b.width,b.height).data,width:b.width,height:b.height}),b.close();}}}if(!u){z(` Deferred image [${s}]: unsupported image data for SVG output`);continue}let l=i.svgSlot??t.reserveSlot();if(i.resample&&n.imageResampling==="exact"&&!i.isMetafile){let f=await uA(a,i.resample,t.canvas);if(f){t.fillSlot(l,{kind:"rgba",data:f.rgba,width:f.w,height:f.h},[1,0,0,1,0,0],f.x,f.y,f.w,f.h);continue}z(` Deferred image [${s}]: exact resampling unavailable (image not decodable here); renderer scaling used`);}let c=i.resample?_s(u):null;if(i.resample&&c){let f=i.resample;t.fillSlotCropped(l,u,f.toDevice,c,f.srcX,f.srcY,f.srcW,f.srcH);}else t.fillSlot(l,u,i.transform,i.dx,i.dy,i.dw,i.dh);}catch(a){o?.throwIfTripped(),z(` Deferred image [${s}]: SVG embed failed: ${a instanceof Error?a.message:a}`);}}}async function cA(t,e,n=0){let r=await y1(t,e,n);return r?r.toTree({includeSize:e?.includeSize}):null}async function y1(t,e,n=0){let r=zr(e);if(r?.check(),await Va(),n>ls)return null;let o=await Wc(t);if(r?.check(),!o)return null;let s=Ra(e??{},r),i=s.dpiScale??Zn,a=s.idPrefix===void 0?++nm:0,u=s.idPrefix??`emf${a}-`,l=null;try{let c=await p1(o,s,(m,b)=>{let h=za(m,b,s.maxWidth,s.maxHeight,i,s.maxCanvasDimension),p=s.exactRasterOps===!1?null:Is(m,b,s.maxWidth,s.maxHeight,i,s.maxCanvasDimension)?.ctx??null;return l=new bi(h.w,h.h,{shadow:p,idPrefix:u,imageResampling:s.imageResampling}),{ctx:l,width:h.w,height:h.h}});if(!c||!l)return null;let f=l;return await lA(f,c.deferredImages,s,n,r),f}catch(c){throw a!==0&&nm===a&&nm--,c}}function G_(t,e){return x1(t,e)}function O_(t,e){return rm(t,e)}export{Zn as DEFAULT_DPI_SCALE,G_ as convertMetafileToDataUrl,O_ as convertMetafileToImageData};