emf-converter 4.29.0 → 5.0.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/README.md +7 -1
- package/dist/browser-chunks/chunk-32ASPP2J.js +1 -0
- package/dist/browser-chunks/chunk-5OO5QZBQ.js +1 -0
- package/dist/browser-chunks/chunk-6M4YGIQZ.mjs +1 -0
- package/dist/browser-chunks/chunk-7JVB7NLG.js +2 -0
- package/dist/browser-chunks/chunk-AKFBI6HO.mjs +1 -0
- package/dist/browser-chunks/chunk-BZ5EU3GQ.mjs +1 -0
- package/dist/browser-chunks/chunk-C3KBKW2L.js +1 -0
- package/dist/browser-chunks/chunk-DO2CGP4P.js +1 -0
- package/dist/browser-chunks/chunk-DOQZZ5LA.mjs +1 -0
- package/dist/browser-chunks/chunk-GB3YMP7Z.mjs +1 -0
- package/dist/browser-chunks/chunk-H4QX7Q4T.mjs +2 -0
- package/dist/browser-chunks/chunk-J6UKX2SY.js +1 -0
- package/dist/browser-chunks/chunk-LKJUWXHV.js +1 -0
- package/dist/browser-chunks/chunk-OB5ODU4B.js +1 -0
- package/dist/browser-chunks/chunk-PO4H7QFT.mjs +1 -0
- package/dist/browser-chunks/chunk-QX63UNWK.js +1 -0
- package/dist/browser-chunks/chunk-VQRM3TC4.mjs +1 -0
- package/dist/browser-chunks/chunk-VSFHXEGM.mjs +1 -0
- package/dist/browser-chunks/emf-ansi-johab-BGUOAP6H.mjs +1 -0
- package/dist/browser-chunks/emf-ansi-johab-KHT3RJ3R.js +1 -0
- package/dist/browser-chunks/emf-gdi-chroma-tie-data-QPKNQFSO.mjs +1 -0
- package/dist/browser-chunks/emf-gdi-chroma-tie-data-YFCUXKFP.js +1 -0
- package/dist/browser-chunks/emf-gdi-illuminant-data-FESCLWQ7.mjs +2 -0
- package/dist/browser-chunks/emf-gdi-illuminant-data-YYCDAVZT.js +2 -0
- package/dist/browser-chunks/emf-plus-image-curves-OLOBXBF7.js +2 -0
- package/dist/browser-chunks/emf-plus-image-curves-U46ENPYQ.mjs +2 -0
- package/dist/browser-chunks/gdi-font-engine-JSQROG7F.mjs +1 -0
- package/dist/browser-chunks/gdi-font-engine-VF73ZSE3.js +1 -0
- package/dist/browser-chunks/gif-decoder-HCVZWAHL.mjs +1 -0
- package/dist/browser-chunks/gif-decoder-ZZ27IQG6.js +1 -0
- package/dist/browser-chunks/jpeg-cmyk-POM57I3O.mjs +2 -0
- package/dist/browser-chunks/jpeg-cmyk-QL44AOOZ.js +2 -0
- package/dist/browser-chunks/jpeg-decoder-CMP7ASL4.mjs +1 -0
- package/dist/browser-chunks/jpeg-decoder-GGVNSSPW.js +1 -0
- package/dist/browser-chunks/jpeg-decoder-legacy-4LSDXMCV.mjs +1 -0
- package/dist/browser-chunks/jpeg-decoder-legacy-V73WBA5Z.js +1 -0
- package/dist/browser-chunks/jpeg-encoder-5DE4U2SQ.js +1 -0
- package/dist/browser-chunks/jpeg-encoder-5DFCLIMU.mjs +1 -0
- package/dist/browser-chunks/png-encoder-BUYFBWDO.js +1 -0
- package/dist/browser-chunks/png-encoder-J4262WS7.mjs +1 -0
- package/dist/browser-chunks/svg-context-CVI7XPTM.js +2 -0
- package/dist/browser-chunks/svg-context-KC7L6NV3.mjs +2 -0
- package/dist/browser-chunks/tiff-decoder-6LKFU47D.mjs +1 -0
- package/dist/browser-chunks/tiff-decoder-Q6MTIHDV.js +1 -0
- package/dist/browser-chunks/tiff-jpeg-MBC3UGMN.js +1 -0
- package/dist/browser-chunks/tiff-jpeg-TOIEUWZF.mjs +1 -0
- package/dist/browser-chunks/webp-decoder-FY74YL2U.js +1 -0
- package/dist/browser-chunks/webp-decoder-WYHITGE2.mjs +1 -0
- package/dist/browser-chunks/webp-encoder-4JPXFFZZ.js +1 -0
- package/dist/browser-chunks/webp-encoder-JQ4I7ABR.mjs +1 -0
- package/dist/browser.js +37 -61232
- package/dist/browser.mjs +37 -61214
- package/dist/index.js +37 -61315
- package/dist/index.mjs +37 -61297
- package/dist/lite.js +5 -5
- package/dist/lite.mjs +5 -5
- package/dist/node-chunks/chunk-2WUBHBGZ.js +1 -0
- package/dist/node-chunks/chunk-3AWDT4IN.mjs +2 -0
- package/dist/node-chunks/chunk-6TAYDPWF.mjs +1 -0
- package/dist/node-chunks/chunk-75GGL2QB.mjs +1 -0
- package/dist/node-chunks/chunk-AAYRADLK.js +1 -0
- package/dist/node-chunks/chunk-CWULLVCX.js +2 -0
- package/dist/node-chunks/chunk-DKUII3EV.js +1 -0
- package/dist/node-chunks/chunk-EA6JK7TD.mjs +1 -0
- package/dist/node-chunks/chunk-EBIZSO4S.js +1 -0
- package/dist/node-chunks/chunk-GD73XQBZ.js +1 -0
- package/dist/node-chunks/chunk-GNJ2QHWI.mjs +1 -0
- package/dist/node-chunks/chunk-L2UW73US.mjs +1 -0
- package/dist/node-chunks/chunk-RCUX23RT.js +1 -0
- package/dist/node-chunks/chunk-SXBOBAYR.js +1 -0
- package/dist/node-chunks/chunk-T4UGEB7S.mjs +1 -0
- package/dist/node-chunks/chunk-T6E6K636.mjs +1 -0
- package/dist/node-chunks/chunk-YXNQU7W4.mjs +1 -0
- package/dist/node-chunks/chunk-ZF3VWEU6.js +1 -0
- package/dist/node-chunks/gdi-font-engine-WCHWF444.js +1 -0
- package/dist/node-chunks/gdi-font-engine-YGRNO7OF.mjs +1 -0
- package/dist/node-chunks/gif-decoder-I2CNJCRR.mjs +1 -0
- package/dist/node-chunks/gif-decoder-UOU3U2ZO.js +1 -0
- package/dist/node-chunks/jpeg-cmyk-AXLREJRN.js +2 -0
- package/dist/node-chunks/jpeg-cmyk-WFBY5BFQ.mjs +2 -0
- package/dist/node-chunks/jpeg-decoder-TQ6AAYSY.mjs +1 -0
- package/dist/node-chunks/jpeg-decoder-VQUHLPAJ.js +1 -0
- package/dist/node-chunks/jpeg-decoder-legacy-5AQKLBQX.mjs +1 -0
- package/dist/node-chunks/jpeg-decoder-legacy-KIJBM2X4.js +1 -0
- package/dist/node-chunks/jpeg-encoder-EYPZTDIT.js +1 -0
- package/dist/node-chunks/jpeg-encoder-JZWC5RLN.mjs +1 -0
- package/dist/node-chunks/png-encoder-Q6PONWA7.mjs +1 -0
- package/dist/node-chunks/png-encoder-R2HLCKBA.js +1 -0
- package/dist/node-chunks/svg-context-WDRM2YC3.mjs +2 -0
- package/dist/node-chunks/svg-context-X65E7QBQ.js +2 -0
- package/dist/node-chunks/tiff-decoder-PUQ7YZGC.js +1 -0
- package/dist/node-chunks/tiff-decoder-VCS2FIXG.mjs +1 -0
- package/dist/node-chunks/tiff-jpeg-7CMHUYH4.js +1 -0
- package/dist/node-chunks/tiff-jpeg-XTNEMUKO.mjs +1 -0
- package/dist/node-chunks/webp-decoder-DBVS75GU.mjs +1 -0
- package/dist/node-chunks/webp-decoder-MDSDJDEH.js +1 -0
- package/dist/node-chunks/webp-encoder-DSA7O3HC.mjs +1 -0
- package/dist/node-chunks/webp-encoder-SGJY4K6D.js +1 -0
- package/package.json +1 -1
package/dist/lite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function vs(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 ja(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 Om(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 Bm(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 T=0;T<2&&y<d;T++){let E=T===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 Va(t){if(t===0)return 0;let e=0,n=t;for(;(n&1)===0;)n>>>=1,e++;return e}var tx=3;function Nm(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===tx){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=Va(s),l=Va(i),c=Va(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 Gm(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 T=o?M:r-1-M,E=e+T*c;if(!(E+c>t.byteLength))for(let R=0;R<n;R++){let P=(M*n+R)*4;if(s===1){let A=E+(R>>3),I=t.getUint8(A)>>7-(R&7)&1;I<i.length&&(u[P]=i[I][0],u[P+1]=i[I][1],u[P+2]=i[I][2]),u[P+3]=255;}else if(s===4){let A=E+(R>>1),I=(R&1)===0?t.getUint8(A)>>4&15:t.getUint8(A)&15;I<i.length&&(u[P]=i[I][0],u[P+1]=i[I][1],u[P+2]=i[I][2]),u[P+3]=255;}else if(s===8){let A=t.getUint8(E+R);A<i.length&&(u[P]=i[A][0],u[P+1]=i[A][1],u[P+2]=i[A][2]),u[P+3]=255;}else if(s===16){let A=t.getUint16(E+R*2,true);u[P]=Math.round(((A&f)>>>h)*255/x),u[P+1]=Math.round(((A&m)>>>p)*255/y),u[P+2]=Math.round(((A&b)>>>d)*255/g),u[P+3]=255;}else if(s===24){let A=E+R*3;u[P]=t.getUint8(A+2),u[P+1]=t.getUint8(A+1),u[P+2]=t.getUint8(A),u[P+3]=255;}else {let A=E+R*4,I=t.getUint8(A),S=t.getUint8(A+1),w=t.getUint8(A+2),C=t.getUint8(A+3);u[P]=w,u[P+1]=S,u[P+2]=I,u[P+3]=C===0&&!l?255:C;}}}}function Le(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 T=1<<c,E=t.getUint32(e+32,true)||T,R=Math.min(E,T),P=e+i,A=!!o&&o.length>0;if(P+R*(A?2:4)>t.byteLength)return null;for(let I=0;I<R;I++){if(A){let v=t.getUint16(P+I*2,true),L=o[v<o.length?v:0];y.push([L>>16&255,L>>8&255,L&255]);continue}let S=t.getUint8(P+I*4),w=t.getUint8(P+I*4+1),C=t.getUint8(P+I*4+2);y.push([C,w,S]);}}let g=Nm(t,e,i,f,c);if(!g)return null;let M=new Uint8ClampedArray(a*d*4);return f===b||f===h?Bm(t,n,r,a,d,x,f===h,y,M,(E,R,P,A,I,S)=>{let w=(R*a+E)*4;M[w]=P,M[w+1]=A,M[w+2]=I,M[w+3]=S;}):(Gm(t,n,a,d,x,c,y,g,M,s),Et(M,a,d))}var Wm=[[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 vr(t,e,n){return ((Wm[t]??Wm[0])[n&7]>>7-(e&7)&1)===1}function Ls(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 za(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 Hm(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=za(t,u,l);if(h&&r)return {kind:"mono",...h}}let f=Le(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:Ls(t.brushColor)};if(e.kind==="bitmap")return {kind:"tile",width:e.width,height:e.height,rgb:e.rgb};let n=Ls(t.bkColor);if(e.kind==="hatch"){let s=Ls(t.brushColor),i=new Uint32Array(64);for(let a=0;a<8;a++)for(let u=0;u<8;u++)i[a*8+u]=vr(e.hatch,u,a)?s:n;return {kind:"tile",width:8,height:8,rgb:i}}let r=Ls(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 Jn(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 Ja(t){let e=[],n=0;for(let r=0;r<t.length;r++)e.push(n),n+=t[r];return e}function Ds(t){let e=0;for(let n of t)e+=n;return e}function Us(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 Xm(t,e){return e==="center"?-t/2:e==="right"?-t:0}var ex=Math.PI/180;function Ym(t){let n=(t%3600+3600)%3600*qa/3600,r=Math.floor(n),o=n-r,s=r*2*Math.PI/qa,i=(r+1)*2*Math.PI/qa;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 qa=128;function $m(t){return -(t/10)*ex}var nx=1.15;function jm(t){return t===0?0:t<0?-t:t/nx}var $=(...t)=>{},z=(...t)=>{};var rx=[137,80,78,71,13,10,26,10];function Ka(t){return t.length>=8&&rx.every((e,n)=>t[n]===e)}async function ox(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 Za(t)}var sx=[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],ix=[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],ax=[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],ux=[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],lx=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function To(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 Za(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=To(p,288),c=To(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 T=0;T<x;T++)y[lx[T]]=a(3);let g=To(y,19),M=new Uint8Array(p+d);for(let T=0;T<p+d;){let E=u(g);if(E<16)M[T++]=E;else if(E===16){let R=M[T-1];for(let P=3+a(2);P>0;P--)M[T++]=R;}else E===17?T+=3+a(3):T+=11+a(7);}b=To(M.subarray(0,p),p),h=To(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=sx[d]+a(ix[d]),y=u(h),g=ax[y]+a(ux[y]);i(x);for(let M=0;M<x;M++)o[s]=o[s-g],s++;}}}}return o.subarray(0,s)}var cx=[[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 mx(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 fx(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+=mx(c,f,m);break}t[u+l]=b&255;}s=u,e=u+n;}return e}async function Vm(t){if(!Ka(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 S=8;S+12<=t.length;){let w=e.getUint32(S),C=String.fromCharCode(t[S+4],t[S+5],t[S+6],t[S+7]),v=t.subarray(S+8,Math.min(t.length,S+8+w));if(C==="IHDR"&&v.length>=13)n=e.getUint32(S+8),r=e.getUint32(S+12),o=v[8],s=v[9],i=v[12];else if(C==="PLTE")a=v;else if(C==="tRNS")u=v;else if(C==="IDAT")l.push(v),c+=v.length;else if(C==="IEND")break;S+=12+w;}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 S of l)b.set(S,h),h+=S.length;let p;try{p=await ox(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,T=u&&s===2&&u.length>=6?[u[0]<<8|u[1],u[2]<<8|u[3],u[4]<<8|u[5]]:null,E=(S,w)=>{if(o===8)return p[S+w];if(o===16)return p[S+w*2]<<8|p[S+w*2+1];let C=w*o;return p[S+(C>>3)]>>8-o-(C&7)&g},R=S=>o===16?S>>8:o===8?S:Math.round(S*255/g),P=(S,w,C,v,L)=>{for(let _=0;_<w;_++){let U=(C*n+v+_*L)*4;if(s===3){let F=E(S,_);y[U]=a[F*3]??0,y[U+1]=a[F*3+1]??0,y[U+2]=a[F*3+2]??0,y[U+3]=u&&F<u.length?u[F]:255;}else if(s===0||s===4){let F=E(S,_*f),O=R(F);y[U]=O,y[U+1]=O,y[U+2]=O,y[U+3]=s===4?R(E(S,_*f+1)):F===M?0:255;}else {let F=E(S,_*f),O=E(S,_*f+1),X=E(S,_*f+2);y[U]=R(F),y[U+1]=R(O),y[U+2]=R(X),y[U+3]=s===6?R(E(S,_*f+3)):T&&F===T[0]&&O===T[1]&&X===T[2]?0:255;}}},A=0,I=i===1?cx:[[0,0,1,1]];for(let[S,w,C,v]of I){let L=Math.ceil((n-S)/C),_=Math.ceil((r-w)/v);if(L<=0||_<=0)continue;let U=Math.ceil(L*d/8);if(A+_*(U+1)>p.length)return null;let F=A;A=fx(p,A,U,_,x);for(let O=0;O<_;O++)P(F+O*(U+1)+1,L,w+O*v,S,C);}return {width:n,height:r,data:y}}function zm(t){return null}function _s(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 qm(){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 Jm(t,e){return Math.floor(t/e)}function Ro(t,e){return -Math.floor(-t/e)}function Zn(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],T=h[x*2+1];if(g===T)continue;let E=T>g?1:-1,R=E>0?y:M,P=E>0?g:T,A=E>0?M:y,I=E>0?T:g,S=Ro(P,16),w=Ro(I,16);w<=S||(s.push([S,w,R,P,A-R,I-P,E]),S<i&&(i=S),w>a&&(a=w));}}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(Ro(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 bx(t,e){return Math.abs(t)!==Math.abs(e)?10:e>0?2:t>0?136:68}function Km(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 Bs(t,e,n,r,o){let s=n-t,i=r-e;if(s===0&&i===0)return;let a=bx(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,P)=>u?Km(E,R,P,a):Km(R,E,P,a),M=b>0?Jm(x,16)-1:Ro(y,16)+1,T=b>0?Ro(y,16)+1:Jm(x,16)-1;for(let E=M;b>0?E<=T:E>=T;E+=b){let R=E*16,P=c*h+(R-l)*p,A=P/h/16,I=Math.round(A);for(let S=I-1;S<=I+1;S++){let w=S*16,C=P-w*h,v=x-R,L=y-R,_;if(d){let U=p/h,F=C/h,O=Math.max(v,Math.min(0,L)),X=Math.max(v,Math.min(-F/U,L));_=g(2*O,2*(F+U*O),2)||g(2*X,2*(F+U*X),2)||g(O+X,2*F+U*(O+X),2);}else {let U=Math.max(v,Math.min(0,L));_=g(U*h,C+U*p,h);}_&&(g(f-R,m-w,1)||(u?o(E,S):o(S,E)));}}}var Zm=10,Qa=3,tf=6*10912,hx=tf*8;function pn(t,e){return Math.floor(t/2**e)}var Ns=class{constructor(e,n,r,o){let s=2**Zm;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=pn(this.e2+this.e3,1),this.e1=pn(this.e1-pn(this.e2,e),1);}steadyState(e){let n=2**Qa;this.e0*=n,this.e1*=n;let r=e-Qa;r<0?(this.e2*=2**-r,this.e3*=2**-r):(this.e2=pn(this.e2,r),this.e3=pn(this.e3,r));}halve(){this.e2=pn(this.e2+this.e3,3),this.e1=pn(this.e1-this.e2,1),this.e3=pn(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=Zm+Qa;return pn(this.e0+2**(e-1),e)}};function ef(t,e,n,r,o,s,i,a,u,l=1){let c=tf*l,f=hx*l,m=new Ns(t,n,o,i),b=new Ns(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 Se=.5522847498307936;function Kn(t,e,n,r){return {ax:t,ay:e,exx:n-t,exy:0,eyx:0,eyy:r-e}}function dn(t,e=false){if(!e)return rf(t,false);let{halfX:n,...r}=t,o=nf(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 nf(t){return rf(t,true)}function rf(t,e){let n=(I,S)=>S?Math.ceil(I/2):Math.floor(I/2),r=I=>n(I,false),o=I=>n(I,true),s=I=>Math.floor(I/2)+Math.ceil(Se*Math.ceil(I/2)),i=I=>Math.ceil(I/2)-Math.ceil(Se*Math.ceil(I/2)),a=I=>n(I,false),u=I=>n(I,true),l=I=>Math.floor(I/2)-Math.floor(Se*Math.floor(I/2)),c=I=>I-l(I),f=I=>I%2===0?Math.ceil(Se*Math.floor(I/2)):Math.floor(Se*Math.ceil(I/2)),m=e?I=>a(I)-f(I):l,b=e?I=>a(I)-f(I):l,h=e?I=>u(I)+f(I):c,p=e?I=>u(I)+f(I):c,d=()=>0,x=I=>I,{ax:y,ay:g,exx:M,exy:T,eyx:E,eyy:R}=t,P=[],A=(I,S)=>{P.push(y+I(M)+S(E),g+I(T)+S(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 I of [0,1,2,3,4,5,12])P[2*I]++;return P}function nu(t,e,n,r){return dn(Kn(t,e,n,r))}function ru(t){let e=[t[0],t[1]];for(let n=2;n+5<t.length;n+=6)ef(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 of(t,e,n,r,o,s,i=false,a=false,u=false,l){let c=n-t,f=r-e;if(l){let E=(P,A)=>Math.floor(Math.fround(P*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(Se*h):Math.floor(Se*h),y=u?Math.floor(Se*d):Math.ceil(Se*d),g=[n,e+h,n,e+h-x,n-d+y,e,p,e],M=E=>t+n-E,T=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]),T(g[1]),M(g[2]),T(g[3]),M(g[4]),T(g[5]),M(g[6]),T(g[7]),g[6],T(g[7]),g[4],T(g[5]),g[2],T(g[3]),g[0],T(g[1])]}var eu=2*Math.PI/128,Fs=t=>_n(t)[0],ks=t=>_n(t)[1];function ou(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 sf(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*Fs(i),c=e-r*ks(i),f=t+n*Fs(a),m=e-r*ks(a);return [l-u*n*ks(i),c-u*r*Fs(i),f+u*n*ks(a),m+u*r*Fs(a),f,m]}function af(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=nu(r,o,r+s,o+i),c=nf(Kn(r,o,r+s,o+i)),f=e*Math.PI/180,m=Math.abs(n)<=3?[Math.cos(f),Math.sin(f)]:_n(f),b=[Math.round(a+s/2*m[0]),Math.round(u-i/2*m[1])];for(let h of ou(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=uf(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 px=3*Math.PI/180,Os=(()=>{let t=[],e=[];for(let n=0;n<=129;n++)t.push(Math.fround(Math.cos(n*eu))),e.push(Math.fround(Math.sin(n*eu)));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 _n(t){let e=t%(2*Math.PI);e<0&&(e+=2*Math.PI);let n=Math.fround(e/eu),r=Math.min(127,Math.floor(n)),o=n-r;return [Os.cos[r]*(1-o)+Os.cos[r+1]*o,Os.sin[r]*(1-o)+Os.sin[r+1]*o]}var tu=Array.from({length:33},(t,e)=>Math.atan(e/32));function Qm(t){let e=t*32,n=Math.min(31,Math.floor(e));return tu[n]+(tu[n+1]-tu[n])*(e-n)}function dx(t,e){let n=Math.abs(t),r=Math.abs(e);if(n===0&&r===0)return 0;let o=r<=n?Qm(Math.fround(r/n)):Math.PI/2-Qm(Math.fround(n/r));return t>=0?e>=0?o:2*Math.PI-o:e>=0?Math.PI-o:Math.PI+o}function uf(t,e,n,r=1/0){let o=n?l=>[Math.cos(l),Math.sin(l)]:_n,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(_n(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=_n(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 lf(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,T=(k,W)=>dx((k-g)/(m/2||1),-(W-M)/(b/2||1)),E=T(o,s),R=T(i,a),P=k=>u?(2*Math.PI-k)%(2*Math.PI):k,A=R!==E&&Math.abs(P(R)-P(E))<=px,I=u?-1:1;if(I>0)for(;R<=E;)R+=2*Math.PI;else for(;R>=E;)R-=2*Math.PI;let S=(k,W)=>Math.fround(k*Math.fround(W)),w=(k,W)=>f?Math.round(x-S(Math.floor(m/2),k)):u&&l?Math.ceil(x+S(p,k)+.5-W):Math.round(x+S(p,k)+(l?1+W:0)),C=k=>Math.round(y-S(d,k)),v=f?Kn(n,e,t,r):Kn(t,e,n,r);l&&(v.halfX=true);let L=dn(v);if(u){let k=dn(v,true);for(let W=0;W<k.length;W+=2)L[k.length-2-W]=k[W],L[k.length-1-W]=k[W+1];}let _=A?[Math.cos(E),Math.sin(E)]:_n(E),U=[w(_[0],_[1]),C(_[1])],F=k=>Math.abs(k/h-Math.round(k/h))<1e-9,O=k=>(Math.round(k/h)%4+4)%4;c&&F(E)&&(I>0?O(E)===1||O(E)===2:O(E)===2||O(E)===3)&&U.push(U[0],U[1],U[0],U[1],U[0],U[1]);let X=E;for(let k=0;k<8&&(I>0?X<R-1e-12:X>R+1e-12);k++){let W=I>0?Math.floor(X/h+1e-9)*h+h:Math.ceil(X/h-1e-9)*h-h,N=Math.abs(X/h-Math.round(X/h))<1e-9,q=I>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&&(I>0?Q===0||Q===3:Q===0||Q===1)||q&&(I>0?K===1||K===2:K===2||K===3))&&N&&(I>0?W<=R+1e-12:W>=R-1e-12)){let Y=(Math.round(Math.min(X,W)/h)%4+4)%4*6;I>0?U.push(L[Y+2],L[Y+3],L[Y+4],L[Y+5],L[Y+6],L[Y+7]):U.push(L[Y+4],L[Y+5],L[Y+2],L[Y+3],L[Y],L[Y+1]),X=W;continue}let rt=I>0?Math.min(W,R):Math.max(W,R),H=uf(X,rt,A,Math.max(p,d));for(let Y=0;Y<6;Y+=2)U.push(w(H.ctrl[Y],H.ctrl[Y+1]),C(H.ctrl[Y+1]));X=rt;}if(c&&F(R)&&(I>0?O(R)===3||O(R)===0:O(R)===1||O(R)===0)){let k=_n(R),W=w(k[0],k[1]),N=C(k[1]);U.push(W,N,W,N,W,N);}return U}var wt=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;ef(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,T,E)=>x!==p||y!==d?[x-p,y-d]:g!==p||M!==d?[g-p,M-d]:T!==p||E!==d?[T-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 Lr(t,e,n){return Zn(t.figures.map(r=>r.pts),e,n)}function Dr(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 Po(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 Gs(t){let e=t&15;return e>=1&&e<=4}function Ws(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)Bs(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])&&Bs(c[f-2],c[f-1],c[0],c[1],a);}});}var xn=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 pu(){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 qm();}catch{te=null;}return te}var cf=false;function $s(){return typeof OffscreenCanvas>"u"&&typeof document>"u"&&!te}var Qn=1;function Ur(t,e,n,r,o=Qn,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 Xs={willReadFrequently:true};function js(t,e,n,r,o=Qn,s=8192){let{w:i,h:a,scaleX:u,scaleY:l}=Ur(t,e,n,r,o,s);try{if($s()){$(`createCanvas: using the software rasteriser ${i}\xD7${a}`);let c=new xn(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",Xs);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",Xs);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 St(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)),cf);if(typeof OffscreenCanvas<"u"){let r=new OffscreenCanvas(t,e),o=r.getContext("2d",Xs);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",Xs);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 xn(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 _r(t,e){switch(e){case "invert":return Om(t);case "black":return "#000000";case "white":return "#ffffff";case "skip":return "rgba(0,0,0,0)";default:return t}}function Fr(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=_r(e.penColor,n.colorTransform),t.lineWidth=Math.max(e.penWidth,1),t.setLineDash(e.penWidth<=1?Dr(e.penStyle,e.penUserStyle)??[]:[]);}function kr(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=_r(e.brushColor,n.colorTransform);}function Rx(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 Or(t,e){let n=e?.[t.toLowerCase().trim()]??t;return /[\s,]/.test(n)&&!/^["']/.test(n)?`"${n}"`:n}function Vs(t,e=1){return Math.max(jm(t.fontHeight)*Math.abs(e||1),8)}function mf(t,e,n=1){let r=e.fontItalic?"italic ":"",o=Rx(e.fontWeight),s=o?`${o} `:"",i=Vs(e,n),a=Or(e.fontFamily,e.fontFamilyMap);t.font=`${r}${s}${i}px ${a}`;}function ff(t,e,n,r,o,s=1){if(!e.fontUnderline&&!e.fontStrikeOut)return;let i=Vs(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 $e(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 zs(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 Br(t,e){let n=_s(new Uint8Array(t));if(n==="unsupported")return null;if($s()){let s=await Ys(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 Ys(new Uint8Array(t)),o=r&&St(r.width,r.height);return !r||!o?null:(vt(o.ctx,Et(r.data,r.width,r.height),0,0),{drawable:o.canvas,width:r.width,height:r.height,close:()=>{}})}async function Ys(t){if(Ka(t))return Vm(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=Le(e,14,n,e.byteLength-n);return r?{data:r.data,width:r.width,height:r.height}:null}return zm()}function le(t,e,n,r,o,s){t.drawImage.call(t,e,n,r,o,s);}function Pt(t,e,n,r,o){return t.getImageData.call(t,e,n,r,o)}function vt(t,e,n,r){t.putImageData.call(t,e,n,r);}function qs(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 Nr(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?_s(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 Js(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 Ao(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=Le(e,14,n,e.byteLength-n);return r?{kind:"rgba",data:r.data,width:r.width,height:r.height}:null}var Ks=new Float32Array(1),bf=new Uint32Array(Ks.buffer);function D(t){let e=Math.fround(t);return e<=t||Number.isNaN(e)?e:e===0?(bf[0]=2147483649,Ks[0]):(Ks[0]=e,bf[0]+=e>0?-1:1,Ks[0])}var Lt=Math.fround,Fn=D,xu=new Float32Array(1),du=new Uint32Array(xu.buffer);function hf(t){return xu[0]=t,t>0?du[0]-=1:t<0?du[0]+=1:du[0]=2147483649,xu[0]}var ut=(t,e)=>Fn(t+e),et=(t,e)=>Fn(t-e),Z=(t,e)=>Fn(t*e);function Tt(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=hf(r)),r}function Io(t){let e=Math.sqrt(t);if(!Number.isFinite(e))return e;let n=Fn(e);return n*n>t&&(n=hf(n)),n}function kn(t){let e=Math.floor(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function Zs(t){let e=Math.ceil(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function On(t,e,n){return e=Lt(e),n=Lt(n),[ut(ut(Z(e,Lt(t[0])),Z(n,Lt(t[2]))),Lt(t[4])),ut(ut(Z(e,Lt(t[1])),Z(n,Lt(t[3]))),Lt(t[5]))]}var ee=(t,e)=>t>e,Bn=(t,e)=>t>=e,Ne=(t,e)=>!(t>=e),pf=(t,e)=>!(t>e);var So=11920929e-14,Qs=2**30;function yn(t){let e=t>>>24;if(e<So)return [0,0,0,0];let n=t>>>16&255,r=t>>>8&255,o=t&255;if(Math.abs(e-255)<So)return [e,n,r,o];let s=Tt(e,255);return [e,Z(s,n),Z(s,r),Z(s,o)]}function Nn(t){let e=ut(Z(Z(t,16),16),.5);return Math.floor(e)+15>>4}function Px(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 T=-s;if(T<i)h=-1,p=i-T;else {h=-Math.trunc(T/i);let E=T%i;E>0?(h--,p=i-E):p=0;}}let d=-1,x=f&15;if(x!==0)for(let T=16-x;T>0;T--){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 T=0;T<M.length;T++){M[T]=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 ti=class{constructor(e,n,r={}){this.shading=r;this.edges=[];this.rows=new Map;this.colors=n;let o=[Nn(e[0]),Nn(e[2]),Nn(e[4]),Nn(e[0])],s=[Nn(e[1]),Nn(e[3]),Nn(e[5]),Nn(e[1])],i=1/0,a=-1/0;for(let u=0;u<3;u++){let l=Px(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=-Qs,r=Qs){if(e<this.yMin||e>=this.yMax)return null;let o=n===-Qs&&r===Qs?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 v of this.edges)e>=v.yStart&&e<v.yEnd&&o.push(v);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)>So){let v=Tt(y,p);d=ut(Z(et(f,l),v),l),x=ut(Z(et(m,c),v),c);}let g=et(u,h);if(Math.abs(g)>So){let v=Tt(g,p);f=et(f,Z(et(f,l),v)),m=et(m,Z(et(m,c),v));}let M=h-b,T=Tt(et(f,d),M),E=Tt(et(m,x),M),[R,P,A]=this.colors,I=new Uint8Array(M*4),S=[0,0,0,0],{preset:w,adjust:C}=this.shading;for(let v=0;v<M;v++){if(w)w(et(et(1,d),x),S);else {let L=d,_=x;if(C){let U=C(et(et(1,d),x)),F=ut(x,d);if(F!==0){let O=Tt(et(1,U),F);L=Z(d,O),_=Z(x,O);}}for(let U=0;U<4;U++){let F=R[U],O=ut(Z(et(P[U],F),L),F);S[U]=ut(O,Z(et(A[U],F),_));}}d=ut(d,T),x=ut(x,E),yu(S,I,v*4);}return {xl:b,n:M,argb:I}}weights(e,n){let r=e.xMajor?e.xs[n-e.yStart]:n,o=Tt(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 yu(t,e,n){let r=t[0];if(!(Math.abs(r)>=So)){e[n]=e[n+1]=e[n+2]=e[n+3]=0;return}0>r&&(r=0),r>255&&(r=255),e[n]=df(r);for(let o=1;o<4;o++){let s=t[o];0>s&&(s=0),s>r&&(s=r),e[n+o]=df(s);}}function df(t){let e=Math.floor(ut(t,.5));return Number.isFinite(e)?e&255:0}function wo(t,e,n,r,o=false){if(t===0)return 0;let s=o?Tt(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 gu=t=>Fn(1-Lt(t));function ei(t){if(!t||t.factors.length===0)return null;let e=t.factors.length;if(e===1){let o=Lt(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(gu).reverse(),r=t.positions.map(gu).reverse();return o=>{if(Ne(o,0)||Ne(1,o))return o;let s=1;if(ee(et(o,r[1]),xf))for(;;){if(s++,s>=e)return o;if(!ee(et(o,r[s]),xf))break}let i=et(r[s],r[s-1]);return ee(i,0)?ut(Z(Tt(et(o,r[s-1]),i),et(n[s],n[s-1])),n[s-1]):Z(ut(n[s],n[s-1]),.5)}}var xf=11920929e-14;function ni(t){if(!t||t.argb.length<2)return null;let e=t.argb.length,n=t.argb.map(o=>yn(o)).reverse(),r=t.positions.map(gu).reverse();return (o,s)=>{let i;if(Ne(o,0)||Ne(1,o)){i=Bn(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=Tt(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 ri=2**30,yf=Lt(-0.02),gf=Lt(1.02),Wr=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]=Tt(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]=Tt(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(Bn(o,ut(this.minY,this.height)))return [];let s=n,i=r;if(ee(this.minX,i))return [];if(Bn(s,ut(this.minX,this.width)))return [];if(ee(this.yMin,o))return [];if(Bn(o,this.yMax))return [];let a=[];for(let c=0;c<4;c++)this.flags[c]&&(Ne(o,this.yTop[c])||pf(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(Bn(f,i)||Bn(s,m))continue;f<s&&(f=s),m>i&&(m=i);let b=Zs(f),h=Zs(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=Io(y),T=ut(u,u),E=Ne(a,0)?et(M,a):et(-a,M),R=Tt(T,E),P=Tt(E,g);(ee(0,R)||ee(R,1))&&(Ne(P,0)||Ne(1,P)||([R,P]=[P,R])),c=R,f=P;}else y===0&&(l=1,c=Tt(-a,g));}else {if(a===0)return false;l=1,c=Tt(-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(yf,y)||ee(y,gf)),p=y=>!(Ne(y,yf)||Ne(gf,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))?[Tt(-ut(Z(e,this.e2x),n),o),true]:ee(Math.abs(s),0)?[Tt(-ut(Z(e,this.e2y),r),s),true]:[0,false]}},Mu=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=-ri,o=ri){let s=r===-ri&&o===ri?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=Lt(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 Eu(t,e){if(t.length===0)return 0;let n=Lt(t[0].x),r=Lt(t[0].y),o=n,s=r;for(let p of t){let d=Lt(p.x),x=Lt(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,Lt(e[2])),Z(p,Lt(e[0]))),ut(Z(d,Lt(e[3])),Z(p,Lt(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 Io(ut(Z(x,x),Z(y,y)))},h=ut(b(c,m),b(l,f));return Math.max(1,Zs(h))}function Gr(t){return Z(kn(ut(Z(t,16),.5)),.0625)}function Mf(t,e){let n=t.boundary.length;if(n<2)return null;let r=Eu(t.boundary,e),o=yn(t.centerArgb),s=yn(t.boundaryArgb[0]??4278190080),i=new Uint32Array(r+2),a=Tt(1,r),u=ei(t.blend),l=ni(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 I=u?u(c):c;for(let S=0;S<4;S++)f[S]=ut(Z(et(s[S],o[S]),I),o[S]);}yu(f,m,0),i[A]=(m[0]<<24|m[1]<<16|m[2]<<8|m[3])>>>0,c=ut(c,a);}let b=On(e,t.center.x,t.center.y),h=Gr(b[0]),p=Gr(b[1]),d=Lt(t.focus?.x??0),x=Lt(t.focus?.y??0),y=d!==0||x!==0,g=[],M=[],T=h,E=h;for(let A=0;A<n;A++){let I=A+1<n?A+1:0,S=t.boundary[A],w=t.boundary[I];if(S.x===w.x&&S.y===w.y){g.push(new Wr(null,-1)),y&&M.push(new Wr(null,-1));continue}let C=On(e,S.x,S.y),v=On(e,w.x,w.y),L=Gr(C[0]),_=Gr(C[1]),U=Gr(v[0]),F=Gr(v[1]);T=Math.min(T,L,U),E=Math.max(E,L,U);let O=h,X=p,k=h,W=p;y&&(O=ut(Z(et(L,h),d),h),k=ut(Z(et(U,h),d),h),X=ut(Z(et(_,p),x),p),W=ut(Z(et(F,p),x),p),M.push(new Wr([[h,p],[O,X],[h,p],[k,W]],0))),g.push(new Wr([[O,X],[L,_],[k,W],[U,F]],-1));}let R=Math.floor(T)-2,P=Math.ceil(E)+3-R;return new Mu(y?[...g,...M]:g,i,r,R,P)}var Pf=2.2;function Ax(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 Ix(t){return t.preset?t.preset.positions.length:t.blend?t.blend.positions.length:2}function Sx(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 Hr(t,e){let n=t>>>24&255,r=n/255,o=s=>{let i=t>>>s&255;return (e?255*Math.pow(i/255,Pf):i)*r*(n<255?1-2**-40:1)};return [o(16),o(8),o(0),n]}function Ef(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 Tu=new Float32Array(1),wx=new Int32Array(Tu.buffer);function ot(t){let e=Math.fround(t);return Math.abs(e)>Math.abs(t)?(Tu[0]=e,wx[0]-=1,Tu[0]):e}function Cx(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 vx(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 Lx(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 Hr(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 Ef(Hr(i[u-1],n),Hr(i[u],n),c)}return Hr(i[a-1],n)}let r=Hr(t.startArgb,n),o=Hr(t.endArgb,n);return t.blend&&!n?vx(r,o,Cx(t.blend.positions,t.blend.factors,e)):Ef(r,o,t.blend?Sx(t.blend.positions,t.blend.factors,e):e)}function Dx(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/Pf)*n}function Ru(t,e){let n=Ax(Ix(t),e),r=new Uint8Array((n+1)*4);for(let o=0;o<=n;o++){let s=Lx(t,o/n),i=o*4;for(let a=0;a<3;a++){let u=t.gammaCorrected?Dx(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 Pu(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 Ux(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 Af(t){let e=[];for(let n=0;n<=t.intervals;n++){let r=Ux(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 oi=65536;function Tf(t,e,n){let r=(n==="tile-flip-x"||n==="tile-flip-xy"?2:1)*e*oi;return (t%r+r)%r}function Au(t,e){return Math.min(255,Math.floor(t*Math.floor(255*65536/e)/65536))}function _x(t,e,n,r,o=false){let s=t.intervals,i=Math.floor(e/oi),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?Au(p,b):Math.round(p*255/b);}n[r+3]=b;}}function Fx(t,e,n,r){let o=t.intervals,s=Math.floor(e/oi),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 Rf(t,e){return [D(D(t[0]*e[0])+D(t[1]*e[2])),D(D(t[0]*e[1])+D(t[1]*e[3])),D(D(t[2]*e[0])+D(t[3]*e[2])),D(D(t[2]*e[1])+D(t[3]*e[3])),D(D(D(t[4]*e[0])+D(t[5]*e[2]))+e[4]),D(D(D(t[4]*e[1])+D(t[5]*e[3]))+e[5])]}function kx(t){let e=D(D(t[0]*t[3])-D(t[1]*t[2]));if(e===0)return null;let n=D(1/e),r=[D(t[3]*n),D(-t[1]*n),D(-t[2]*n),D(t[0]*n),D(D(D(t[5]*t[2])-D(t[4]*t[3]))*n),D(D(D(t[4]*t[1])-D(t[5]*t[0]))*n)];return r.every(Number.isFinite)?r:null}function Ox(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=[D(e+r),n],a=[e,D(n+o)],u=D(D(D(D(r+e)*D(n+o))-D(n*e))+D(D(-o*e)-D(n*r)));if(Math.abs(u)<11920929e-14)return [1,0,0,1,0,0];let l=D(1/u),c=D(D(D(e+r)*D(n+o))-D(e*n)),f=D(-e*o),m=D(-n*r);return [D(D(D(o*i[0])+D(-o*s[0]))*l),D(D(D(o*i[1])+D(-o*s[1]))*l),D(D(D(r*a[0])+D(-r*s[0]))*l),D(D(D(r*a[1])+D(-r*s[1]))*l),D(D(D(D(f*i[0])+D(c*s[0]))+D(m*a[0]))*l),D(D(D(D(f*i[1])+D(c*s[1]))+D(m*a[1]))*l)]}function Bx(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*oi,l=D(o+i),c=D(s+a),f=D(D(l-o)/u),m=D(D(c-s)/u),b=[f,0,0,m,D(l-D(f*u)),D(c-D(m*u))],h=Rf(e.map(p=>Math.fround(p)),n.map(p=>Math.fround(p)));return kx(Rf(b,h))}function If(t,e,n,r=false,o={x:0,y:0}){let s=t.rect,i=Pu(t);if(!s||!i||!(Math.abs(s.w)>1e-9))return null;let a=Ru(i,s),u=a.intervals,l=Bx(s,t.transform??Ox(s),e,u);if(!l)return null;let c=n?.5:0,f=Math.floor(D(l[0]+.5)),m=Math.floor(D(l[2]+.5)),b=Math.floor(D(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 T=b+p*f+(d+M)*m;for(let E=0;E<x;E++,T+=f)_x(a,Tf(T,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 T=b+p*f+(d+M)*m;for(let E=0;E<x;E++,T+=f)Fx(a,Tf(T,u,t.wrapMode),g,(M*x+E)*4);}}),h}var vo=[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 Cf(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 Co(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 Nx(t,e,n){let r=t>>>24&255,o=e>>>24&255;if(r===o)return Co(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 vf(t,e=vo){return Eu(t,e)}function Gx(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 Sf(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 Co(o.argb,r.argb,s>0?(e-o.offset)/s:1)}}return t[t.length-1].argb}function si(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 P=0;P<u;P++){let A=i[P],I=i[(P+1)%u],S=A.x-s.x,w=A.y-s.y,C=I.x-A.x,v=I.y-A.y,L=S*v-w*C;if(Math.abs(L)<1e-12)continue;let _=(l*v-c*C)/L,U=(S*c-w*l)/L;if(_<-d||U<-d||U>_+d||_>1+d)continue;b=P;let F=(f*v-m*C)/L,O=(S*m-w*f)/L;h=Math.max(0,F),p=F>0?Math.min(1,Math.max(0,O/F)):0;}let x=b<0?1/0:h;if(t.focus){let P=Math.min(1,Math.max(0,t.focus.x)),A=Math.min(1,Math.max(0,t.focus.y));if(P===A)x=x<=P?0:(x-P)/(1-P);else if(x>0){let I=1-P,S=1-A,w=1/0,C=false;for(let v=0;v<u;v++){let L=i[v],_=i[(v+1)%u],U=L.x-s.x,F=L.y-s.y,O=_.x-L.x,X=_.y-L.y,k=U*X-F*O;if(Math.abs(k)<1e-12)continue;if(P===0&&A>0&&Math.abs((r?.x??e)-s.x)<d&&O>0&&Math.max(U,U+O)>0&&Math.abs(X)>d){let Y=(((r?.y??n)-s.y)/A-F)/X;Y>=-d&&Y<=1+d&&(C=true);}if((P>0||Math.abs(l)<d)&&(A>0||Math.abs(c)<d)){let Y=P>0?l/P:0,G=A>0?c/A:0,B=(Y*X-G*O)/k,j=(U*G-F*Y)/k;B>=-d&&B<=1+d&&j>=-d&&j<=B+d&&(C=true,b<0&&(b=v));}let W=k*I*S,N=k*(P*S+A*I)-l*X*S+c*O*I,q=k*P*A-l*X*A+c*O*P,Q=N*N-4*W*q,K=Math.abs(W)<1e-12?Math.abs(N)>1e-12?[-q/N]:[]:Q>=0?[(-N-Math.sqrt(Q))/(2*W),(-N+Math.sqrt(Q))/(2*W)]:[],V=0,rt=0,H=0;for(let Y of K){if(Y<-d||Y>1+d)continue;let G=P+I*Y,B=A+S*Y;if(B===0&&G>0&&Math.abs(c)<d&&X>0&&Math.max(F,F+X)>0&&Math.abs(O)>d){let tt=(l/G-U)/O;if(tt>=-d&&tt<=1+d){V=1,rt=0,H=Math.min(1,Math.max(0,tt));break}}if(G<=0||B<=0)continue;let j=Math.abs(O)>Math.abs(X)?(l/G-U)/O:(c/B-F)/X;j>=-d&&j<=1+d&&(V++,rt=Math.max(0,Y),H=Math.min(1,Math.max(0,j)));}V===1&&(w=rt,b=v,p=H);}x=C?0:Number.isFinite(w)?w: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:P,argb:A}=t.preset;if(y<=P[0])return A[0];for(let I=1;I<P.length;I++)if(y<=P[I]){let S=P[I]-P[I-1];return Co(A[I-1],A[I],S>0?(y-P[I-1])/S:1)}return A[P.length-1]}let g=a[b]??t.centerArgb,M=a[(b+1)%u]??g,T=Co(g,M,p),E=t.blend?Gx(t.blend.positions,t.blend.factors,y):y,R=Math.min(1,Math.max(0,E));return T>>>24!==t.centerArgb>>>24&&a.every(P=>P===a[0])?Nx(T,t.centerArgb,R):Co(T,t.centerArgb,R)}var Wx=2048;function Lf(t){return {x:t==="tile-flip-x"||t==="tile-flip-xy",y:t==="tile-flip-y"||t==="tile-flip-xy"}}function ii(t,e,n,r,o,s,i,a,u){if(typeof t.createPattern!="function")return null;let l=o==="clamp"?{x:false,y:false}:Lf(o),c=n*(l.x?2:1),f=r*(l.y?2:1),m=St(c,f);if(!m)return null;let b=e.w/n,h=e.h/r,p=T=>{let E=T%n*b+(.5+a.phaseX)*b;return T<n?E:e.w-a.lagX-(E-(.5+a.phaseX)*b)-.5*b},d=T=>{let E=(T%r+.5)*h;return T<r?E:e.h-a.lagY-E},x=new Uint8ClampedArray(c*f*4);for(let T=0;T<f;T++){let E=e.y+d(T);for(let R=0;R<c;R++){let P=u(e.x+p(R),E);if(P===null)continue;let A=(T*c+R)*4;x[A]=P>>>16&255,x[A+1]=P>>>8&255,x[A+2]=P&255,x[A+3]=P>>>24&255;}}vt(m.ctx,Et(x,c,f),0,0);let y=qs(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 Lo(t){let e=Cf(t);return e?{x:e[0]*.5+e[2]*.5,y:e[1]*.5+e[3]*.5}:{x:0,y:0}}var Hx=4;function Iu(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(Wx,Math.ceil(Math.abs(n)*r*Hx)))}function Df(t,e){let n=e??vo,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 Xx(t,e){if(typeof t.createLinearGradient!="function")return null;let n=e.rect?Df(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 wf=1e-5,Yx=2048;function $x(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 jx(t,e,n,r){let o=$x(t),s=Cf(r);if(!o||!s||typeof t.createLinearGradient!="function")return null;let i=Df(n,e.transform),a=Lo(r),u=i.x2-i.x1,l=i.y2-i.y1,c=i.x1+a.x+u*wf,f=i.y1+a.y+l*wf,m=u*u+l*l;if(!(m>1e-12))return null;let b=1/0,h=-1/0;for(let[T,E]of [[0,0],[o.w,0],[0,o.h],[o.w,o.h]]){let R=T-r[4],P=E-r[5],A=s[0]*R+s[2]*P,I=s[1]*R+s[3]*P,S=((A-c)*u+(I-f)*l)/m;b=Math.min(b,S),h=Math.max(h,S);}let p=Math.floor(b),d=Math.max(p+1,Math.ceil(h));if(d-p>Yx)return null;let x=t.createLinearGradient(c+u*p,f+l*p,c+u*d,f+l*d),y=d-p,g=Lf(e.wrapMode).x,M=[...e.stops].reverse();for(let T=p;T<d;T++){let E=g&&(T%2+2)%2===1;for(let R of E?M:e.stops){let P=E?1-R.offset:R.offset;x.addColorStop(Math.min(1,Math.max(0,(T-p+P)/y)),R.color);}}return x}function Vx(t){let e=t.rect?Pu(t):null;return e&&t.rect?Af(Ru(e,t.rect)):t.stops}function zx(t,e,n){let r={...e,stops:Vx(e)},o=r.rect;if(r.wrapMode!=="clamp"&&o&&o.w!==0){let s=jx(t,r,o,n);if(s)return s;if(Sf(r.stops,0)!==null){let i=r.transform??vo,a=Iu(Xt(n,i),"x",o.w),u=ii(t,o,a,1,r.wrapMode,i,Lo(n),{phaseX:.5,lagX:0,lagY:0},l=>Sf(r.stops,(l-o.x)/o.w));if(u)return u}}return Xx(t,r)}function qx(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 Jx(t,e,n,r){let o=qx(e.boundary);if(!o)return null;let s=e.transform??vo,i=Xt(r,s),a=Math.hypot(i[0],i[1]),u=Math.hypot(i[2],i[3]);return ii(t,o,Iu(i,"x",o.w),Iu(i,"y",o.h),n,s,Lo(r),{phaseX:0,lagX:a>0?1/a:0,lagY:u>0?1/u:0},(l,c)=>si(e,l,c))}function Kx(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 Uf(t,e,n=vo){try{if(e.type==="linear")return zx(t,e,n);if(e.shape){let r=Jx(t,e.shape,e.wrapMode,n);if(r)return r;$("createBrushGradient: path gradient pattern unavailable, using the radial approximation");}return Kx(t,e)}catch{return null}}var Zx=Uint8Array.from({length:256},(t,e)=>e);function _f(t,e){return Zx}var Qx={"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"},Bf=8192;var Xr={All:0,Red:1,Green:2,Blue:3},ai=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0");function ty(t,e){let n=[];for(let r=0;r<8;r++)n.push(ai(t.getUint8(e+8+r),2));return [ai(t.getUint32(e,true),8),ai(t.getUint16(e+4,true),4),ai(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,ey=12;function Nf(t,e,n){if(n<20||e<0||e+n>t.byteLength)return null;let r=Qx[ty(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(ey))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 Gf=t=>Math.ceil(t-.5);function vu(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 Ff(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 ny(t,e){let n=e>=100?1e6:e>=0?100/(100-e):(100+e)/100,r=t/2;return vu(o=>(o+r-127.5)*n+127.5+r)}function Su(t){return vu(e=>e*(Math.floor((1+t/100)*65536)/65536))}function ry(t,e){if(!Number.isInteger(t)||t<0||t>7)return null;return _f().slice()}function oy(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=Ff(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=Ff(e);return vu(i=>{let a=kt((i-r)/o,0,1);return 255*(t>=n?a**s:1-(1-a)**s)},Gf)}function Do(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 sy(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 je=43,ui=255;function iy(t,e,n){let r=Math.max(t,e,n),o=r-Math.min(t,e,n),s=u=>Math.floor(u*je/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 ay(t,e,n,r){let o=new Uint8ClampedArray(t),s=Math.round(e*ui/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=((iy(l,c,f)+s)%ui+ui)%ui,T=M+Math.floor((M+41)/85),E=Math.min(5,Math.floor(T/je)),R=T-E*je,P=y+Math.floor((g-y)*R/je),A=y+Math.floor((g-y)*(je-R)/je),[I,S,w]=[[g,P,y],[A,g,y],[y,g,P],[y,A,g],[P,y,g],[g,y,A]][E];o[u]=I,o[u+1]=S,o[u+2]=w;}return o}function uy(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/je)),i=o-s*je,a=Math.floor(Gn*i/je),u=Math.floor(Gn*(je-i)/je),[l,c,f]=[[Gn,a,0],[u,Gn,0],[0,Gn,a],[0,u,Gn],[a,0,Gn],[Gn,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,T=b*x+c*g,E=b*y+f*g,R=54*d+183*x+19*y-(54*(M>>8)+183*(T>>8)+19*(E>>8));h[p]=R+M>>8,h[p+1]=R+T>>8,h[p+2]=R+E>>8;}return h}var Gn=254;function ly(t,e,n,r){let o=new Uint8ClampedArray(t),s={x:0,y:0,set:false};for(let i of r)gy(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 li=60,cy=15,my=2/9,fy=1;function by(t,e){return Math.floor((9*t+2*e+5)/11)}var wu=5/16,kf=[25,40,80],hy=[.25,.5,.66,.75],py=40,dy=.33,xy=5;function yy(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 gy(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],G=Q*a+K;f[G]=H+my*Y;let B=by(H,Y);m[G]=B;let j=rt-Math.max(H,Y);if(j>0){c[G]=j;let tt=ot(B>=1?j/B:fy);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}=yy(m,a,u));let g=n+d,M=r+x,T=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(T,M-.5):Math.min(E,g-.5);if(!(R>0))return;let P=Int32Array.from(m).sort(),A=P[Math.floor(.7*l)],I=A-P[Math.floor(.3*l)],S=P[l-1],w=l>1?P[l-2]:-1,C=-1;S>w&&S-A>=py&&(C=m.indexOf(S));let v=0;for(;v<kf.length&&I>kf[v];)v++;let L=hy[v],_=new Uint8Array(l),U=new Float64Array(l),F=new Float64Array(li),O=new Float64Array(li),X=new Float64Array(li),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));U[H]=ot(Math.sqrt(Y));let G=Math.atan2(rt,V)*k;G<0&&(G+=360);let B=V===0&&rt===0?cy:rt===0?0:Math.min(li-1,Math.floor(G/6));_[H]=B,Y<W&&(F[B]+=c[H],O[B]+=f[H],X[B]++);}C>=0&&!(U[C]<R)&&(C=-1);let N=ot,q=N(L);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||U[V]>=R)continue;let H=_[V],Y=N(F[H]/X[H]),G=N(O[H]/X[H]),B=G>0?N(f[V]/G):1,j=N(1-N(U[V]/R)),tt=B<2?N(.5*N(N(1-B)*N(1-B))):0,lt=Math.max(N(q*N(j*j)),tt,y?N(dy*j):0),ct=N(N(1-lt)*Y);if(C>=0){let at=K-C%a,mt=Q-Math.floor(C/a);ct=Math.min(ct,xy*(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-wu)*ht),t[ft+1]=Math.round(t[ft+1]+wu*ht),t[ft+2]=Math.round(t[ft+2]+wu*ht);}}function Wf(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 Cu(t,e){if(e===1)return 0;for(;t<0||t>=e;)t=t<0?-t:2*(e-1)-t;return t}function Hf(t,e,n,r,o=0,s=false,i=Math.ceil(n/e)){let a=Wf(r),u=(a.length-1)/2,l=(u|1)>=e?m=>Math.max(0,Math.min(e-1,m)):m=>Cu(m,e),c=(u|1)>=n?m=>Math.max(0,Math.min(n-1,m)):m=>Cu(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 T=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[T]),d+=R*Math.round(E*t[T+1]),x+=R*Math.round(E*t[T+2]),y+=R*Math.round(E*t[T+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 T=0;T<e*4;T++)p[T]+=M*Math.round(g*m[y+T])/256;}f.set(p,h*e*4);}}return f}function Xf(t){return t<20?1:t<40?2:t<=80?4:t<160?8:16}function Of(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=>Cu(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 T=a.start+(M-a.pad)*n,E=Math.min(a.start+a.size,T+n),R=0;for(let P=T;P<E;P++)R+=s(P,d,x);m[M]=Math.floor(R/(E-T));}for(let M=0;M<l;M++){let T=0;if(M>=c&&M+c<l)for(let E=0;E<h.length;E++)T+=Math.round(h[E]*m[M-c+E]);else for(let E=0;E<h.length;E++){let R=M-c+E;T+=Math.round(h[E]*(a.zeroOutside&&(R<0||R>=l)?0:m[f(R)]));}T+=2*Math.round(p*m[M]),b[M]=Math.floor((T+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 T=(M-a.start+.5)/n-.5;if(y){let P=Math.abs(M-a.start-(Math.min(a.size,n/2)-.5))/n;i(M,d,x,kt(Math.floor((1+P)*b[a.pad]+1e-9),0,255));continue}let E=kt(Math.floor(T),0,Math.max(0,u-2)),R=T-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 Lu(t,e,n,r,o,s=false){let i=Xf(r);if(i===1)return Hf(t,e,n,r);let a=Wf(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);Of(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 Of(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 My(t,e,n,r){return Uint8ClampedArray.from(Lu(t,e,n,r),Math.round)}function Ey(t,e){return Gf(64*e/(250-2*e))/64}function Ty(t,e,n,r,o){let s=Lu(t,e,n,r),i=Ey(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 Ry(t,e,n,r){if(e<=0||n<=0||t.length!==e*n*4)return null;switch(r.kind){case "blur":return My(t,e,n,r.radius);case "sharpen":return Ty(t,e,n,r.radius,r.amount);case "brightnessContrast":{let o=ny(r.brightness,r.contrast);return Do(t,o,o,o)}case "colorBalance":return Do(t,Su(r.cyanRed),Su(r.magentaGreen),Su(r.yellowBlue));case "colorCurve":{let o=ry(r.adjustment,r.intensity),s=r.channel;if(!o||s<Xr.All||s>Xr.Blue)return null;let i=a=>s===Xr.All||s===a?o:null;return Do(t,i(Xr.Red),i(Xr.Green),i(Xr.Blue))}case "colorLookupTable":return Do(t,r.r,r.g,r.b,r.a);case "colorMatrix":return sy(t,r.matrix);case "hueSaturationLightness":return ay(t,r.hue,r.saturation,r.lightness);case "levels":{let o=oy(r.highlight,r.midtone,r.shadow);return Do(t,o,o,o)}case "redEyeCorrection":return ly(t,e,n,r.areas);case "tint":return uy(t,r.hue,r.amount)}}function ci(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 Py(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)ci(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);ci(t,e,x,y,g-x,M-y,m,c,x-(o-l),y-(s-l));}let b=Xf(r)>1?Lu(m,c,f,r,u?{x:l,y:l,w:i-o,h:a-s}:void 0,true):Hf(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 Yf(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 $f(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 ci(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}=Py(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),ci(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=Ry(h,l,c,p);return d?b(d):null}function jf(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),T=t.getUint8(x+3);s===925707&&T>0&&T<255&&(M=Math.min(255,Math.round(M*255/T)),g=Math.min(255,Math.round(g*255/T)),y=Math.min(255,Math.round(y*255/T)));let E=p+d*4;f[E]=y,f[E+1]=g,f[E+2]=M,f[E+3]=T;}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 Ay(f,l,n,r,c)}function Vf(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 Ay(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 zf=Math.fround;function on(t){return Math.floor(zf(zf(t)*256+.5))+15>>4}function Ge(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 P of [b,h])P[2]=m(P[2]+P[3],1),P[1]=m(P[1]-m(P[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,T=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(T),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--,T+=M,g(b),g(h);}}function Iy(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 qf(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 Jf(t,e){let n=t%e;return n<0?n+e:n}function Yr(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=Iy(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,T=h/x,E=p/x,R=Math.max(-1,Math.min(1,g*T+M*E)),P=Math.acos(R)/2,A=l.radius/Math.tan(P),I=l.x1+g*A,S=l.y1+M*A,w=l.x1+T*A,C=l.y1+E*A,v=g+T,L=M+E,_=Math.hypot(v,L),U=l.radius/Math.sin(P),F=l.x1+v/_*U,O=l.y1+L/_*U,X=Math.atan2(S-O,I-F),k=Math.atan2(C-O,w-F)-X;k>Math.PI?k-=2*Math.PI:k<-Math.PI&&(k+=2*Math.PI),u(I,S);let W=qf(l.radius,k);for(let N=1;N<=W;N++){let q=X+k*N/W;u(F+l.radius*Math.cos(q),O+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:Jf(y,c));}else {let y=l.endAngle-l.startAngle;f=y>=c?c:Jf(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=qf(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 Sy(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 Zf(...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 Yr(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 wy(t,e,n){let r=[];for(let o of Yr(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 Cy(t,e){let n=[],r=wy(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 Qf(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 Kf(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=Cy(o,e);r=r.map((i,a)=>i.length===0?i:Qf(i,s[a],t0));}return r}var t0=(t,e)=>t&&e,vy={replace:(t,e)=>e,intersect:t0,union:(t,e)=>t||e,xor:(t,e)=>t!==e,exclude:(t,e)=>t&&!e,complement:(t,e)=>e&&!t};function Ly(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 Dy(t,e){let n=[],r=0;for(let o=1;o<=t.length;o++){if(o<t.length&&Ly(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 tr(t,e,n,r){let o=Sy(r);if(o.x1<=o.x0||o.y1<=o.y0)return [];let s=Kf(t,o),i=Kf(e,o),a=vy[n],u=s.map((l,c)=>Qf(l,i[c],a));return Dy(u,o.y0)}function e0(t){return t.w>32768||t.h>32768}var Uy=8192;function er(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&Uy?"nonzero":"evenodd"}}function _y(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 Fy=512;function ky(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 Oy(t){let e=Yr(t);if(e.length!==1)return false;let n=e[0],r=n.length/2;if(r<3)return true;if(r>Fy)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&&ky(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 Du(t,e){let n=_y(t,e);return {cmds:n,fillRule:t.fillRule??"nonzero",simple:Oy(n)}}function $r(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 Hy=1,hi=2,r0=4,o0=8,Xy=64,Yy=128,mi=4096;function jr(t){return t>>>12===900097}function _u(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 fi(t,e,n){return {x:t[0]*e+t[2]*n+t[4],y:t[1]*e+t[3]*n+t[5]}}function $y(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function Fu(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 s0(t){return t.map(e=>({...e,offset:$y(e.offset)})).sort((e,n)=>e.offset-n.offset)}function i0(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>mi)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 a0(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>mi)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 jy(t,e,n){if(e+40>n)return null;let r=t.getUint32(e,true),o=Fu(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&hi&&f+24<=n&&(m=_u(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&Yy)!==0};if(r&r0){let x=i0(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&o0){let x=a0(t,f,n);x&&(b=x.entries.map(y=>({offset:y.pos,color:ja(l,c,y.factor),argb:ku(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=fi(m,p.x,p.y),d=fi(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:s0(b),wrapMode:o,rect:{x:s,y:i,w:a,h:u},transform:m,ramp:h}}}function u0(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=Vf(t,u,o,s,i,a);return c?{width:o,height:s,rgba:c}:null}function l0(t,e,n){if(e+28>n||t.getUint32(e+4,true)!==1||u0(t,e,n))return null;let r=e+28;return r<n?{start:r,end:n}:null}function c0(t,e,n){if(e+8>n)return null;let r=t.getUint32(e,true),o=e+8;return r&hi&&o+24<=n&&(o+=24),o}function Vy(t,e,n,r){if(e+8>n)return null;let o=t.getUint32(e,true),s=Fu(t.getUint32(e+4,true)),i=e+8,a=null;o&hi&&i+24<=n&&(a=_u(t,i),i+=24);let u=u0(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 zy(t,e,n){if(e+24>n)return null;let r=t.getUint32(e,true),o=Fu(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>mi)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&Hy){if(c+4<=n){let A=t.getInt32(c,true);if(c+=4,A>0&&c+A<=n){let I=er(t,c,A);if(I){let S=Ky(I.points,I.types,h);f=S.points,m=S.argb;let w=I.points.length;for(let C=0;C<I.points.length;C++){if(C>0&&(I.types[C]&7)===0){w=C;break}if(I.types[C]&128){w=C+1;break}}I.types.slice(0,w).some(C=>(C&7)===3)&&(b={points:I.points.slice(0,w),types:I.types.slice(0,w)});}c+=A;}}}else if(c+4<=n){let A=t.getUint32(c,true);if(c+=4,A>0&&A<=mi&&c+A*8<=n){for(let I=0;I<A;I++)f.push({x:t.getFloat32(c+I*8,true),y:t.getFloat32(c+I*8+4,true)}),m.push(h(I));c+=A*8;}}let p=null;r&hi&&c+24<=n&&(p=_u(t,c),c+=24);let d={x:i,y:a},x=p,y=x?f.map(A=>fi(x,A.x,A.y)):f;x&&({x:i,y:a}=fi(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}],T=null,E=null;if(r&r0){let A=i0(t,c,n);A&&(M=A.stops.map(I=>({...I,offset:1-I.offset})),E={positions:A.stops.map(I=>I.offset),argb:A.stops.map(I=>I.argb??0)},c=A.next);}else if(r&o0){let A=a0(t,c,n);A&&(M=A.entries.map(I=>({offset:1-I.pos,color:ja(g,s,I.factor),argb:ku(g,s,I.factor)})),T={positions:A.entries.map(I=>I.pos),factors:A.entries.map(I=>I.factor)},c=A.next);}let R=null;r&Xy&&c+12<=n&&t.getUint32(c,true)===2&&(R={x:t.getFloat32(c+4,true),y:t.getFloat32(c+8,true)});let P=0;for(let A of y){let I=Math.hypot(A.x-i,A.y-a);I>P&&(P=I);}return P>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:P,stops:s0(M),wrapMode:o,shape:{center:d,centerArgb:s,boundary:f,source:b,boundaryArgb:m,blend:T,preset:E,focus:R,transform:p}}}):{kind:"plus-brush",color:ue(s)}}function ku(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 qy=.25,Jy=10;function n0(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 bi(t,e,n,r,o,s=0,i=1,a=0){if(Math.max(n0(e,t,r),n0(n,t,r))<=qy||a>=Jy){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;bi(t,c,b,p,o,s,d,a+1),bi(p,h,m,r,o,d,i,a+1);}function Ky(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=>[on(b.x),on(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=[];Ge(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(ku(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 pi(t,e,n,r,o=e){if(n<8)return null;let s=e+n,i=jr(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 Vy(t,l,s,c)??{kind:"plus-brush",color:"rgba(0,0,0,1)"}}case 4:return jy(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};case 3:return zy(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};default:return {kind:"plus-brush",color:"rgba(0,0,0,1)"}}}function Zy(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 Uo(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 nr(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 m0(t,e){let n=Zy(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=[];bi(Uo(e,l),Uo(e,c),Uo(e,f),Uo(e,m),b);for(let h=0;h<b.length-1;h++){let p=Uo(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},T=nr(l,c,f,m,h,x).map(R=>R.map(M));if(T.length===0)return;let E=T[0][0];r?i(E):s(E);for(let[R,P,A,I]of T)a(R,P,A,I);}};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 d0(t,e,n){let r=e.map(m=>xt(m)),o=(m,b)=>on(xt(xt(xt(r[0]*xt(m))+xt(r[2]*xt(b)))+r[4])),s=(m,b)=>on(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;Ge([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 T=Math.cos(d),E=Math.sin(d),R=I=>d===0?I:{x:m+(I.x-m)*T-(I.y-b)*E,y:b+(I.x-m)*E+(I.y-b)*T},P=nr(m,b,h,p,x,M);if(P.length===0)return;let A=R(P[0][0]);a?c(A.x,A.y):l(A.x,A.y);for(let I of P){let[,S,w,C]=I.map(R);f.bezierCurveTo(S.x,S.y,w.x,w.y,C.x,C.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 f0(t){let e=t.pts;return !t.closed||e.length<4?e:[...e,e[0],e[1]]}var b0=32;function Qy(t){let e=t.length/2,n=[];for(let r=0;r<e-1;r+=b0-1)n.push(t.slice(2*r,2*Math.min(e,r+b0)));return n}function t2(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,T=0,E=0,R=0;if(i){let G=y===0?0:xt(1/y),B=(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<B||p>j){if(h>j||p<B)return;if(h<B){let at=xt(xt((B-h)*y)+d),mt=Math.floor(at);d=mt,h=B,T=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?T:E)))*G));ct?(h+=at,d=tt):(p+=at,x=tt);}if(ft>lt){let at=Math.floor(xt(xt(lt-xt(ft+(ct?E:T)))*G));ct?(p+=at,x=lt):(h+=at,d=lt),o=true;}}E!==0&&(x&15)===8&&x++,T!==0&&(R=Math.floor(xt(xt(2*g*b)*T)));}let P=f&&g===M,A=P&&b===1,I=A?8:7,S=(G,B)=>{let j=Math.abs(G)+Math.abs(B);return j<8?true:j!==8?false:B===0&&G===(A?-8:8)||G===0&&B===8?true:P&&(A?G<0:G>0)&&B>0},w=h+I&-16,C=p+I&-16,v=S(h-w,d-(d+7&-16)),L=S(p-C,x-(x+7&-16)),_=h&15,U=p&15;m&&!o?(v||_<=8)&&(w+=16):_<=8&&!v&&(w+=16),!m&&!o?(U>8||L)&&(C-=16):!L&&U>8&&(C-=16);let F=w>>4,O=C>>4;if(O<F)return;let X=Math.floor((w-h)*y+d+T),k=X+7&-16,W=k>>4,N=R-((k-X)*b+8)*2*g>>4;if(!i){for(let G=F;G<=O;G++)f?s(G,W):s(W,G),N+=2*M,N>0&&(W+=b,N-=2*g);return}let Q=Math.floor((C-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 G=F;G<=O&&Y>=0;G++)G>=K&&G<=V&&W>=rt&&W<=H&&(f?s(G,W):s(W,G)),N+=2*M,N>0&&(W+=b,N-=2*g,Y--);}var h0=[0,-8,-8,0,0,8,8,0];function p0(t,e){return Math.abs(e)>Math.abs(t)?e<0?1:3:t<0?2:0}function e2(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=p0(o(1)-o(0),s(1)-s(0)),a=m=>h0[2*(m&3)],u=m=>h0[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=p0(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 x0(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&&!n2(t,e.clip,o)?e.clip:void 0;for(let u of t){let l=f0(u);for(let c=0;c+3<l.length;c+=2)t2(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 Qy(f0(o))){let i=e2(s);i.length>=6&&r.push(i);}return ne(r,false,e.antialias,e.half,n)}function n2(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 y0(t){return Math.floor(t*16+.5-1e-4)}function r2(t){let e=t.map(y0);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 gn(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=(S,w)=>Math.abs(S-y.pts[g-2])<.001&&Math.abs(w-y.pts[g-1])<.001,T=M(s(m,b),i(m,b))&&M(s(h,p),i(h,p))&&M(s(d,x),i(d,x)),E=S=>Ft(S),R=E(y.pts[g-2]),P=E(y.pts[g-1]);y.pts[g-2]=R/16,y.pts[g-1]=P/16,T&&(y.splits??(y.splits=[])).push({x:R/16,y:P/16});let A=[],I=[R,P,E(s(m,b)),E(i(m,b)),E(s(h,p)),E(i(h,p)),E(s(d,x)),E(i(d,x))];Ge(I,A);for(let S of A)y.pts.push(S/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 T=Math.cos(d),E=Math.sin(d),R=I=>d===0?I:{x:m+(I.x-m)*T-(I.y-b)*E,y:b+(I.x-m)*E+(I.y-b)*T},P=nr(m,b,h,p,x,M);if(P.length===0)return;let A=R(P[0][0]);r?u(A.x,A.y):a(A.x,A.y);for(let I of P){let[,S,w,C]=I.map(R);l(S.x,S.y,w.x,w.y,C.x,C.y);}}}),n.filter(m=>m.pts.length>=4)}function g0(t,e,n=false){return gn(t,e).map(r=>(n&&!r.curved?r2(r.pts):null)??r.pts.map(Ft)).filter(r=>r.length>=6)}function o2(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 _o(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 T=(M+1)%g,E=y[2*M],R=y[2*M+1],P=y[2*T],A=y[2*T+1];R!==A&&b.push({ax:E,ay:R,bx:P,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 T=f+u*(y*i+M);x.length=0;for(let P of b){if(T<P.top||T>=P.bottom)continue;let A=P.by-P.ay,I=P.ax*A+(P.bx-P.ax)*(T-P.ay);A<0&&(A=-A,I=-I);let S=o2(I-c*A,a*A);x.push({k:Math.min(Math.max(S,0),m),w:P.w});}if(x.length<2)continue;x.sort((P,A)=>P.k-A.k),d.fill(0);let E=0;for(let P=0;P+1<x.length;P++)E+=x[P].w,(e?(E&1)!==0:E!==0)&&x[P+1].k>x[P].k&&(d[x[P].k]++,d[x[P+1].k]--);let R=0;for(let P=0;P<m;P++)R+=d[P],R>0&&p[P/s|0]++;}let g=s*i;for(let M=0;M<o.w;M++){let T=p[M];h[y*o.w+M]=T===0?0:T>=g?255:Math.round(T*255/g);}}return h}function M0(t,e,n){let r=[1,0,0,1,0,0],o=null;for(let a of t){let u;try{u=gn(a.build,r).map(c=>c.pts.map(y0));}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 Vr=Math.fround,De=(t,e)=>D(t+e),ce=(t,e)=>D(t-e),Yt=(t,e)=>D(t*e),Ou=(t,e)=>D(t/e),Bu=11920928955078125e-23;function xi(t,e){let n=ce(Vr(e.x),Vr(t.x)),r=ce(Vr(e.y),Vr(t.y)),o=De(Yt(r,r),Yt(n,n)),s=0;return o>0&&(s=D(Math.sqrt(o)),n=Ou(n,s),r=Ou(r,s)),{gx:n,gy:r,len:s}}function s2(t,e){let n=Math.sqrt(t*t+e*e);return n<Bu?0:D(n)}var di=Vr(.552284777),i2=[[1,0],[1,di],[di,1],[0,1],[-di,1],[-1,di],[-1,0]];function a2(t,e,n,r,o){let s=o?-e.gx:e.gx,i=o?-e.gy:e.gy,a=De(n,r),u=Yt(ce(n,r),.5),l=De(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:De(ce(Yt(b,f),Yt(h,m)),l),y:De(De(Yt(h,f),Yt(b,m)),c)})}function E0(t,e,n,r,o){let s=a2(t,e,n,r,o),i=[];for(let a of [.5,-0.5])for(let[u,l]of i2)i.push(s(De(Yt(u,.5),a),Yt(l,.5)));return i}function T0(t,e,n){return n<0?{x:De(t.x,Yt(-n,e.gy)),y:De(t.y,Yt(-n,-e.gx))}:{x:ce(t.x,Yt(n,e.gy)),y:ce(t.y,Yt(n,-e.gx))}}function R0(t,e,n,r){let o=t.length;if(o<2||n.length===0)return [];let s=0;for(let y of n)s=De(s,y);if(!(s>0))return [];let i=Vr(r%s);i<0&&(i=De(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(xi(t[y-1],t[y]).len);let f,m,b;(f=t[o-1],m=0,b=s2(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))<Bu&&Math.abs(ce(y.y,g.y))<Bu;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=Ou(h,b),T={x:De(Yt(ce(g.x,f.x),M),f.x),y:De(Yt(ce(g.y,f.y),M),f.y)};b=ce(b,h),u&&(x(f,T)?d&&d.length>1&&p.push(d):(d??(d=[f]),d.push(T),p.push(d)),d=null),f=T,h=n[l%n.length],l++,u=!u;}}return u&&d&&d.length>1&&p.push(d),p}function Fo(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(...nr(t.x,t.y,e,e,n+r*a/s,r/s));for(let[a,u,l,c]of i){let f=[];Ge([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 P0(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 u2=.99;function qr(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 v0(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>u2)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,...Fo(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,T=d.y-t.y,E=y*y+g*g,R=M*y+T*g,P=M*M+T*T-h*h,A=Math.max(0,R*R-E*P),I=E===0?0:(-R+Math.sqrt(A))/E;return {x:d.x+y*I,y:d.y+g*I}};return [p(i,m),p(a,m)]}return [i,a]}function A0(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),...Fo(a(y,0),p,d,-Math.PI),a(x,0),...Fo(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),...Fo(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 yi(t,e,n,r){let o=t.length,s=[],i=e?o:o-1,a=Array.from({length:i},(u,l)=>qr(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(...v0(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 l2(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,m2*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 T=g.x-l[M].x,E=g.y-l[M].y;return d?Math.hypot(d[0]*T+d[2]*E,d[1]*T+d[3]*E):Math.hypot(T,E)}),y=g=>x.slice(g+1).reduce((M,T)=>M+T,0);for(let g=0;g+1<l.length;g++){let M=l[g],T=l[g+1],E=x[g],R=0;for(;E-R>m+1e-9;){R+=m;let P={x:M.x+(T.x-M.x)*R/E,y:M.y+(T.y-M.y)*R/E};b&&h?(h.push(P),u.push({pts:h,first:p,last:!e&&s>0&&E-R+y(g)<=n.half+1e-9}),h=null):(h=[P],p=!e&&s>0&&u.length===0&&x.slice(0,g).reduce((A,I)=>A+I,0)+R<=n.half+1e-9),b=!b,f=(f+1)%i.length,m=i[f];}m-=E-R,b&&h&&(h.push(T),r&&g+2<l.length&&r.some(P=>Math.abs(P.x-T.x)<1e-6&&Math.abs(P.y-T.y)<1e-6)&&(u.push({pts:h,first:p,last:false}),h=[T],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 c2(t,e){let n=D(e.dashCapWidth??2*e.half),r=D(Math.fround(.001)*n),o=e.dash.map((i,a)=>{let u=D(i);if(a%2===1)return D(u+n);let l=D(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(),R0(s,true,o,D(D(e.dashOffset)-n)).map(i=>({pts:i,first:false,last:false}))}function I0(t,e,n,r,o){let s=E0({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=[];Ge([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 S0=20;function w0(t,e,n,r){let o=e?t[t.length-1]:t[0],s=e?t[t.length-2]:t[1],i=qr(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 Fo(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 C0(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 m2=.001;function zr(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 f2(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 b2(t,e){let n=zr(t)>0?1:-1,r=t.length,o=Array.from({length:r},(i,a)=>qr(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(zr(s))!==n||s.some(i=>!f2(t,i))}function h2(t,e,n){let r=zr(t)>0?1:-1,o=t.length,s=Array.from({length:o},(a,u)=>qr(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(...v0(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=P0(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()),b2(s,2*r)||n.push(h2(s,2*r,e).reverse());continue}e.inset&&i&&(zr(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?c2(o.pts,e):e.dash?l2(s,i,f,o.splits):[{pts:s,first:true,last:true}],h=!e.dash&&i;for(let p of b){let d=P0(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(w0(d,false,r,e.startCap)),y=0),p.last&&e.endCap>=17&&e.endCap<=19&&(x.push(w0(d,true,r,e.endCap)),g=0),p.first&&e.startCap===S0&&(x.push(C0(d,false,r)),y=0),p.last&&e.endCap===S0&&(x.push(C0(d,true,r)),g=0));for(let[M,T]of l){if(h){n.push(yi(d,true,T,e)),n.push(yi(d,true,M,e).reverse());continue}let E=yi(d,false,T,e),R=yi(d,false,M,e).reverse(),P=qr(d[d.length-2],d[d.length-1]),A=qr(d[1],d[0]),I=g??(p.last&&!(e.dash&&i)?e.endCap:e.dashCap),S=y??(p.first&&!(e.dash&&i)?e.startCap:e.dashCap),w=m?xi(d[d.length-2],d[d.length-1]):null,C=m?xi(d[0],d[1]):null,v=w?I0(d[d.length-1],w,M,T,false):A0(d[d.length-1],P,M,T,I,r,e.doubleRoundCap),L=C?I0(d[0],C,M,T,true):A0(d[0],A,-T,-M,S,r,e.doubleRoundCap);if(C&&(E[0]=T0(d[0],C,T)),I===0&&v.length===2&&E.length>2&&R.length>2){let F=(k,W)=>(k.x-W.x)*P.ux+(k.y-W.y)*P.uy<-1e-9,O=E[E.length-2],X=R[1];F(v[0],O)&&(v[0]={x:O.x,y:O.y}),F(v[1],X)&&(v[1]={x:X.x,y:X.y});}let _=[...E.slice(S===1?1:0,-1),...v,...R.slice(1,-1),...L];n.push(_);let U=Math.sign(zr(_));for(let F of x)n.push(Math.sign(zr(F))===U?F:F.slice().reverse());}}}return n}var p2=1,d2=2,Ve=11920928955078125e-23,it=Math.fround;function Nu(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)>=Ve){let l=it(-a.x/u);if(!(l<-Ve)&&!(it(l-1)>Ve)){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 x2(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 U0(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=x2(b,h,p,d),y=Nu(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=er(t,l,b);return l+=b,h},f=u&p2?c():null,m=u&d2?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?Nu(f.points,f.types):0,strokeLength:m?Nu(m.points,m.types):0}}function y2(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<Ve)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<Ve&&m>=e)return null;let h=e-m+b*b;if(h<Ve)return null;let p=Math.sqrt(h),d=null;if(m>=e){let y=b-p;y>Ve&&y>=0&&(d=y);}if(d===null){let y=p+b;y>Ve&&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 g2(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),T=it(g.y-a.y);if(it(it(M*M)+it(T*T))>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=y2(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>Ve?(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 L0(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 D0(t,e){let n=gn(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 _0(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),T,E;y?(T=d.fillLength,E=Math.max(M,1)):(T=Math.abs(d.strokeLength)<Ve?1:d.strokeLength,E=M);let R=y&&Math.abs(T)<Ve?0:it(d.baseInset/T),P=it(T*E),A=g2(c,f,x,it(P*P),R),I={x:-A.x,y:-A.y},S=x?b:m;if(y){let w=L0(g,S,I,Math.max(E,u));for(let C of D0(w,true)){let v=[];for(let L=0;L+1<C.pts.length;L+=2)v.push({x:C.pts[L],y:C.pts[L+1]});a.push(v);}}else {let w=L0(g,S,I,E),C={half:Math.max(M,1)/2,join:(o.widenJoin??(v=>v))(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)(D0(w,false),C).map(v=>v.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 F0=1,k0=2,O0=4,B0=8,N0=16,Gu=32,G0=64,W0=128,H0=256,X0=512,Y0=1024,Wu=2048,$0=4096,ko=1024;function j0(t,e,n,r,o=e){if(n<20)return null;let s=e+n,i=jr(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&F0&&(l+24<=s&&(m.transform=[0,4,8,12,16,20].map(b=>t.getFloat32(l+b,true))),l+=24),a&k0&&(m.startCap=c()),a&O0&&(m.endCap=c()),a&B0&&(m.lineJoin=c()),a&N0&&(m.miterLimit=f()),a&Gu&&(m.dashStyle=c()??0),a&G0&&(m.dashCap=c()),a&W0&&(m.dashOffset=f()),a&H0){let b=c()??0;b>0&&b<=ko&&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,ko)*4;}if(a&X0&&(m.alignment=c()),a&Y0){let b=c()??0;b>=2&&b<=ko&&l+b*4<=s&&(m.compound=Array.from({length:b},(h,p)=>t.getFloat32(l+p*4,true))),l+=Math.min(b,ko)*4;}for(let b of [Wu,$0])if(a&b){let h=c()??0,p=l+h<=s?U0(t,l,h):null;b===Wu?m.customStartCap=p:m.customEndCap=p,l+=h;}if(l+8<=s){let b=pi(t,l,s-l,r,o);b&&(m.color=b.color,m.brush=b);}return m}function V0(t,e,n){if(n<20)return null;let r=e+n,o=jr(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,ko)*4;};s&F0&&(i+=24);for(let u of [k0,O0,B0,N0,Gu,G0,W0])s&u&&(i+=4);s&H0&&a(),s&X0&&(i+=4),s&Y0&&a();for(let u of [Wu,$0])if(s&u){let l=i+4<=r?t.getUint32(i,true):0;i+=4+l;}return i+8<=r?i:null}function gi(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=jf(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 z0(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=$e(t,e+24,i)||"sans-serif"),{kind:"plus-font",emSize:r||12,flags:s,family:a,unit:o}}var M2=64*1024*1024;function Mi(){return {continuationBuffer:null,continuationObjectId:-1,continuationObjectType:0,continuationTotalSize:0,continuationOffset:0,continuationKey:void 0}}function q0(t){t.continuationBuffer=null,t.continuationObjectId=-1,t.continuationObjectType=0,t.continuationTotalSize=0,t.continuationOffset=0,t.continuationKey=void 0;}function E2(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 T2(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 q0(t),r}function Ei(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`),q0(t),o<4)return null;let u=e.getUint32(r,true),l=e.byteLength-r;if(u<=0||u>M2||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 E2(t,e,r,o),!s||t.continuationOffset>=t.continuationTotalSize?T2(t,i):null}function R2(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=V0(r,t.dataOff,t.dataSize);if(c===null)return;s=c;}let i=jr(r.getUint32(s,true)),a=s+(i?4:0);if(a+8>o||r.getUint32(a,true)!==2)return;let u=c0(r,a+4,o);if(u===null)return;let l=l0(r,u,o);l&&e.push({key:t.cacheKey,view:r,byteStart:l.start,byteEnd:l.end});}function P2(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=Ei(r,t,c,i+12,m);b&&o(b);}i+=f;}}function Go(t,e){let n=Mi(),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&&P2(t,l+8,c-4,n,e);}else if(a===14)break;r+=u;}}function A2(t){let e=[];return Go(t,n=>R2(n,e)),e}async function Yu(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 Br(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=St(a,u);if(!l)return i.close(),null;le(l.ctx,i.drawable,0,0,a,u),i.close();let c=Pt(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 Ri(t){let e=new Map,n;try{n=A2(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 Yu(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 $u=3;async function ju(t,e=0){let n=new Map,r=[];try{Go(t,o=>{if((o.flags>>8&127)!==5||o.dataSize<8)return;let i=gi(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>=$u)continue;n.set(o.key,{kind:"metafile",caches:await I2(s,e+1)});continue}let i=await Yu(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 I2(t,e=0){return {textures:await Ri(t),images:await ju(t,e)}}function J0(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 S2(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),T=l+(g>>1),E=(g&1?c:1-c)*(g>>1?f:1-f);if(E<=0)continue;let R,P;if(m){if(M<0||T<0||M>=n||T>=r)continue;R=M,P=T;}else R=J0(M,n,b),P=J0(T,r,h);let A=(P*n+R)*4,I=o[A+3];p+=E*Math.round(o[A]*I/255),d+=E*Math.round(o[A+1]*I/255),x+=E*Math.round(o[A+2]*I/255),y+=E*I;}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 Pi(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?D(D(D(D(.5*n)+D(.5*o))+i)-.5):i,l=e?D(D(D(D(.5*r)+D(.5*s))+a)-.5):a,c=D(D(n*s)-D(r*o));if(!Number.isFinite(c)||c===0)return null;let f=D(1/c);return [D(s*f),D(-r*f),D(-o*f),D(n*f),D(D(D(o*l)-D(s*u))*f),D(D(D(r*u)-D(n*l))*f)]}function Z0(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);w2(t,s+h,i+b,x,y,d);for(let g=0;g<d;g++)S2(x[g],y[g],e,n,r,o,l,(b*a+h+g)*4);h=p;}}}function w2(t,e,n,r,o,s=r.length){if(s<=0)return;let[i,a,u,l,c,f]=t,m=T=>[D(D(D(i*T)+D(u*n))+c),D(D(D(a*T)+D(l*n))+f)],[b,h]=m(e),[p,d]=m(e+s),x=D(D(p-b)/s),y=D(D(d-h)/s),g=b,M=h;for(let T=0;T<s;T++)r[T]=g,o[T]=M,g=D(g+x),M=D(M+y);}var K0=[1,0,0,1,0,0];function C2(t,e){return (t[e+3]<<24|t[e]<<16|t[e+1]<<8|t[e+2])>>>0}function Q0(t,e,n=K0){let{width:r,height:o,rgba:s}=e;if(r<=0||o<=0)return null;try{let i=e.transform??K0,a=(u,l)=>{let c=Math.floor(u),f=Math.floor(l);return c<0||f<0||c>=r||f>=o?null:C2(s,(f*r+c)*4)};return ii(t,{x:0,y:0,w:r,h:o},r,o,e.wrapMode,i,Lo(n),{phaseX:0,lagX:0,lagY:0},a)}catch{return null}}var zu=new Float32Array(1),Vu=new Uint32Array(zu.buffer);function tb(t){return zu[0]=t,t>0?Vu[0]-=1:t<0?Vu[0]+=1:Vu[0]=2147483649,zu[0]}function st(t,e){let n=t+e,r=n-t,o=t-(n-r)+(e-r),s=D(n);return Math.fround(n)===n&&o<0?tb(n):s}var $t=(t,e)=>st(t,-e),J=(t,e)=>D(t*e);function rr(t,e){let n=D(t/e);return (e>0?n*e>t:n*e<t)&&(n=tb(n)),n}var Ai=.000596046448;function qu(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=D(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 Ho(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=rr(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),T=J(-u,f),E=J(-l,c),R=$t(J(st(u,c),st(l,f)),J(u,l)),P=J(st(st(J(T,o),J(R,n)),J(E,i)),d),A=J(st(st(J(T,s),J(R,r)),J(E,a)),d);return [x,y,g,M,P,A]}function Xo(t,e){let n=qu(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 v2(t,e){let n=Ho(t,e);if(!n)return null;let[r,o,s,i]=e;return Xo(n,[r,o,st(r,s),o,r,st(o,i)])}function Ii(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 Ju(t,e,n){let r=v2(t,e);if(!r)return null;let o=Ho(r,e);return o?Ii(o,n):null}function Ku(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=rr(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 eb(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=qu(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=rr($t(d,h),r),g=rr($t(x,p),r),M=h,T=p;for(let E=0;E<r;E++)o[E]=M,s[E]=T,M=st(M,y),T=st(T,g);}function nb(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=qu(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 I=Math.floor(st(J(A,65536),.5));return I>=-2147483648&&I<=2147483647?I:-2147483648},g=(A,I)=>M(rr(J($t(I,A),65536),r)),M=A=>{let I=Math.floor(st(A,.5));return I>=-2147483648&&I<=2147483647?I:-2147483648},T=y(h),E=y(p),R=g(h,d),P=g(p,x);for(let A=0;A<r;A++)o[A]=T,s[A]=E,T=T+R|0,E=E+P|0;}function L2(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=rr($t(m,i),$t(c,n)),p=rr($t(b,a),$t(f,r)),d=$t(m,J(h,c)),x=$t(b,J(p,f));return Xo([h,0,0,p,d,x],[n,r,c,r,n,f])}function rb(t,e){let[n,r,o,s]=e.map(Math.fround),i=Xo(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 ob(t,e,n){let r=L2(t,e);if(!r)return null;let o=Ho(r,t);return o?Ii(o,n):null}var sb=[[-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 Zu(t){return t<64?{first:-2,weights:sb[t]}:{first:-1,weights:sb[127-t].slice().reverse()}}var D2=(()=>{let t=new Int32Array(512).fill(Number.NaN);for(let e=0;e<128;e++){let{first:n,weights:r}=Zu(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 Si(t){return t<-256?-32768:t>255?32768:D2[t+256]}var Qu=1/65536;function U2(t){return t<=-128?0:t>=128?65536:32768+(t<0?-(512*-t-2*t*t):512*t-2*t*t)}function _2(t){return t<-256?0:t>255?65536:32768+Si(t)}var Ot=t=>t|0,ab=(t,e)=>Math.floor(t*e/65536);function F2(t){return t>=-32768&&t<=32767}function ub(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(F2))return null;let l=t.kernel==="cubic"?2:1,c=t.kernel==="cubic"?131072:65536,f=.5,m=B=>kn(ut(Z(B,65536),f)),b=m(Tt(r,a));m(Tt(a,r));let p=m(Tt(o,u));m(Tt(u,o));if(b===0||p===0)return null;let x=B=>kn(ut(Z(B,16),f)),y=x(s),g=x(ut(Z(r,Tt(a,r)),s)),M=x(i),T=x(ut(Z(o,Tt(u,o)),i)),E=Math.min(y,g),R=Math.max(y,g),P=Math.min(M,T),A=Math.max(M,T),I=E+15>>4,S=Ot(E<<12),w=Ot(R<<12),C=Ot(P<<12),v=Ot(A<<12),L=B=>D(B),_=L(b),U,F;b<0?(U=L(w+65535>>16),F=ut(s,a)):(U=L(S>>16),F=s);let O=et(F,U);O=Z(O,_),O=Z(O,Qu),O=ut(O,e);let X=m(O),k=(B,j)=>{let tt=m(Tt(Z(l,B),j));return tt<0&&(tt=-tt),tt<c?c:tt},W=k(r,a),N=kn(ut(Z(Tt(65536,L(W)),65536),f)),q=L(p),Q;if(p<0){let B=L(v+65535>>16);B=et(B,ut(u,i)),B=Z(B,q),B=Z(B,Qu),Q=m(et(n,B));}else {let B=L(C>>16);B=et(B,i),B=Z(B,q),B=Z(B,Qu),Q=m(ut(B,n));}let K=k(o,u),V=kn(ut(Z(Tt(65536,L(K)),65536),f)),rt=C>>16,H=(w+65535>>16)-(S>>16)+1,Y=2*(K+65535>>16)+1,G=(B,j)=>{let tt=j-32768;return tt>=-2147483648&&tt<=2147483647&&tt-B>=-2147483648&&tt+B<=2147483647};return !G(W,X)||!G(K,Q)?null:{request:t,firstColumn:I,columns:H,firstRow:rt,xStart:X,xStep:b,xStretch:W,xRecip:N,yStart:Q,yStep:p,yStretch:K,yRecip:V,kernelRows:Y,table:t.kernel==="cubic"?_2:U2,shift:t.kernel==="cubic"?8:9,rows:new Map}}function tl(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 k2(t){return [t>>>16&255,t>>>8&255,t&255,t>>>24]}function lb(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=k2(m),d=f===1||f===3,x=Ot(o-32768),y=[0,0,0,0];for(let g=0;g<r;g++){let M=Ot(i+65535+x),T=M>>16,E=Ot(M-2*i)>>16;y[0]=y[1]=y[2]=y[3]=0;let R=0,P=(_,U,F)=>{let O=u(Ot(_)>>l),X=O-R;R=O,y[0]+=U[F]*X,y[1]+=U[F+1]*X,y[2]+=U[F+2]*X,y[3]+=U[F+3]*X;},A=_=>ab(Ot(Ot(_<<16)-x),a),I=E<0?0:E,S=T<c-1?T:c-1,w=A(E);for(let _=E;_<Math.min(I,T+1);_++)f===4||!e?P(w,p,0):P(w,e,tl(_,c,d)*4),w=Ot(w+a);if(I<=S){w=A(I);for(let _=I;_<=S;_++)e?P(w,e,_*4):P(w,p,0),w=Ot(w+a);}let C=Math.max(S+1,E);if(C<=T){w=A(C);for(let _=C;_<=T;_++)f===4||!e?P(w,p,0):P(w,e,tl(_,c,d)*4),w=Ot(w+a);}let v=g*4,L=Math.max(0,Math.min(255,y[3]+32768>>16));h[v+3]=L;for(let _=0;_<3;_++){let U=y[_]+32768>>16;h[v+_]=b?Math.max(0,Math.min(L,U)):Math.min(255,U);}x=Ot(x+s);}return h}function ib(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=tl(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=lb(t,u),t.rows.set(i,a);}return a}function O2(t){let e=t.rows.get(Number.NaN);return e||(e=lb(t,null),t.rows.set(Number.NaN,e)),e}function cb(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=Ot(a-32768+Ot((x-i)*u)),g=Ot(y+l+65535)>>16,M=Ot(y-l+65535)>>16;if(g<M)return null;let T=ab(Ot(Ot(M<<16)-y),c),E=0,R=[],P=[];for(let S=0;S<f;S++){let w=M+S;if(w>g){P.push(0),R.push(null);continue}let C=m(Ot(T)>>b);P.push(C-E),E=C,T=Ot(T+c),R.push(w>=0&&w<t.request.height?ib(t,w):t.request.wrap===4||t.request.wrap===void 0?O2(t):ib(t,w));}let A=t.request.kernel==="cubic",I=new Uint8Array(d*4);for(let S=0;S<d;S++){let w=(h-o+S)*4,C=0,v=0,L=0,_=0;for(let O=0;O<f;O++){let X=R[O];if(!X)continue;let k=P[O];C+=X[w]*k,v+=X[w+1]*k,L+=X[w+2]*k,_+=X[w+3]*k;}let U=S*4,F=Math.max(0,Math.min(255,_+32768>>16));I[U+3]=F;for(let[O,X]of [[0,C],[1,v],[2,L]]){let k=X+32768>>16;I[U+O]=A?Math.max(0,Math.min(F,k)):Math.min(255,k);}}return {x:h,pixels:I}}var B2={0:"bilinear",1:"bilinear",2:"hq-bicubic",3:"bilinear",4:"bicubic",5:"nearest",6:"hq-bilinear",7:"hq-bicubic"},N2=new Set([2,4]),rl=16*1024*1024;function xb(t){return B2[t]??"bilinear"}function Ee(t){return N2.has(t)}function yb(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 Jr=1e-6,Kr=1e-9,G2=1+2**-21,mb=5e-4,we=16;function W2(t){let e=t.toDevice,n=(l,c)=>[Math.round((e[0]*l+e[2]*c+e[4])*we)/we,Math.round((e[1]*l+e[3]*c+e[5])*we)/we],[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 H2(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*we)/we,i=Math.round(o*we)/we,[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 X2(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 Y2(t){let e=Math.min(1,Math.abs(t));return Math.sign(t)*(e-e*e/2)}function $2(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 nl(t){return Math.ceil(t*(1-15e-8))}function bb(t,e){let n=nl(t)-e;return n>=-1&&n<=1}function hb(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||!Ci(n.srcW)||!Ci(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 j2=-0.5,V2=-1;function wi(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)=>X2(r-o,j2)};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=>$2(a,V2):Y2;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 z2(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,T=0,E=0,R=0;for(let P=0;P<b.length;P++){let A=b[P],I=m+P;if(A===0)continue;let S=Yo(I,d,x,a?u.mirrorX:u.mirrorY,u);if(S===Zr)continue;let w=0,C=0,v=0,L=0;for(let U=0;U<p.length;U++){let F=p[U],O=h+U;if(F===0)continue;let X=Yo(O,y,g,a?u.mirrorY:u.mirrorX,u);if(X===Zr)continue;let k,W=0;X===sr||S===sr?k=u.clamp??[0,0,0,0]:(k=t,W=(a?X*e+S:S*e+X)*4);let N=k[W+3],q=F*N/255,Q=!!u.literal&&k===u.clamp;w+=c||Q?F*k[W]:l||f?F*Math.round(N*k[W]/255):q*k[W],C+=c||Q?F*k[W+1]:l||f?F*Math.round(N*k[W+1]/255):q*k[W+1],v+=c||Q?F*k[W+2]:l||f?F*Math.round(N*k[W+2]/255):q*k[W+2],L+=F*N;}l&&(w=Math.trunc(w),C=Math.trunc(C),v=Math.trunc(v),L=Math.trunc(L)),L=Math.min(255,Math.max(0,L));let _=u.literal&&f?1/0:L;M+=A*Math.min(_,Math.max(0,w)),T+=A*Math.min(_,Math.max(0,C)),E+=A*Math.min(_,Math.max(0,v)),R+=A*L;}return [M,T,E,R]}var Zr=-1,sr=-2;function gb(t,e){let n=e>>>24;return t==="clamp"&&n>0&&n<255}function Yo(t,e,n,r,o){if(t>=e&&t<n)return t;if(!o.wrap)return Zr;if(o.wrap==="clamp")return sr;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 q2(t){let e=t-Math.floor(t);return e===0?t:Math.floor(t)+1-e}function sn(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 sn(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 sn(t,e,n,{...r,wrap:void 0,clampArgb:void 0},o,s);if(r.kernel==="nearest"&&!r.wrap)return sg(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:W2(r),p=r.kernel,d=p==="hq-bilinear"||p==="hq-bicubic";d&&(h[1]!==0||h[2]!==0)&&Math.abs(h[1])<=mb*Math.abs(h[0])&&Math.abs(h[2])<=mb*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=H2(r));let g=p==="bicubic"&&x&&!r.halfPixelOffset&&h[0]===1&&h[3]===1&&hb(h[4],h[5],r)&&hb(h[5],h[4],r),T=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=bb(nt,r.srcW)||bb(bt,r.srcH);return og(t,e,n,r,o,h,p,Mt)}let R=p==="bicubic";if(d&&x&&!u){let nt=eg(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]+q2(nt)-nt,h[5]];}let P=yb(h);if(!P)return null;let A=Math.max(0,Math.floor(r.srcX)),I=Math.max(0,Math.floor(r.srcY)),S=Math.min(e,Math.ceil(r.srcX+r.srcW)),w=Math.min(n,Math.ceil(r.srcY+r.srcH));if(S<=A||w<=I)return null;let C=1/0,v=1/0,L=-1/0,_=-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];C=Math.min(C,Mt),v=Math.min(v,Ht),L=Math.max(L,Mt),_=Math.max(_,Ht);}let U=Math.max(0,Math.floor(C)-1),F=Math.max(0,Math.floor(v)-1),O=Math.min(o.w,Math.ceil(L)+1),X=Math.min(o.h,Math.ceil(_)+1),k=O-U,W=X-F;if(!(k>0&&W>0)||k*W>rl)return null;let N=c?ne([c],false,false,f,{x:U,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:U,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=wi(p,q,H),G=wi(p,Q,H),B=new Uint8ClampedArray(k*W*4),j=r.halfPixelOffset?.5:0,tt=r.srcX+r.srcW,lt=r.srcY+r.srcH,ct=[],ht=[];Math.hypot(P[0],P[2]);Math.hypot(P[1],P[3]);let mt=r.clampArgb??0,Rt={wrap:r.wrap,clamp:[mt>>>16&255,mt>>>8&255,mt&255,mt>>>24&255],literal:gb(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(P[0]*re),Kt=Math.round(P[1]*re),Wt=!i&&(p==="bilinear"||p==="bicubic"&&!x)?Pi(h):null,Ce=null;if((Wt||i)&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&(p==="bilinear"||p==="bicubic")&&!r.halfPixelOffset&&!r.chainHalf&&!r.wrap){let nt=Ju(r.worldPoints,r.chainSrc??[r.srcX,r.srcY,r.srcW,r.srcH],r.worldMatrix);Ce=nt&&Ku(nt);}else if(i&&r.chainHalf&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&r.chainSrc&&(p==="bilinear"||p==="bicubic")){let nt=r.worldMatrix,bt=Ju(r.worldPoints,r.chainSrc,[nt[0],nt[1],nt[2],nt[3],D(nt[4]-.5),D(nt[5]-.5)]);Ce=bt&&Ku(bt);}let me=new Float64Array(k),Cr=new Float64Array(k),Ln=new Int32Array(k),He=new Int32Array(k),Xe=0,Ct=(nt,bt)=>{let Mt=nt+Jr,Ht=bt+Kr,ye=P[0]*Mt+P[2]*Ht+P[4],ie=P[1]*Mt+P[3]*Ht+P[5];return !(ye<r.srcX||ie<r.srcY||ye>=tt||ie>=lt)};Wt&&!Ce&&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=U+pt+j,It=P[0]*(fe-T)+P[2]*(bt-E)+P[4],gt=P[1]*(fe-T)+P[3]*(bt-E)+P[5],Zt=fe+Jr,Ie=bt+Kr,_t=P[0]*Zt+P[2]*Ie+P[4],Ye=P[1]*Zt+P[3]*Ie+P[5];if(N?!N[nt*k+pt]:_t<r.srcX||Ye<r.srcY||_t>=tt||Ye>=lt)continue;if(Ce){if(Mt<0){Mt=pt,Xe=pt;let be=pt+1;for(;be<k&&(N?N[nt*k+be]!==0:Ct(U+be+j,bt));)be++;R?nb(Ce,U+pt,F+nt,be-pt,Ln,He):eb(Ce,U+pt,F+nt,be-pt,me,Cr);}R?(It=(Ln[pt-Xe]+m*re)/re,gt=(He[pt-Xe]+m*re)/re):(It=me[pt-Xe]+m,gt=Cr[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]),fn=Math.fround(r.toDevice[1]*r.srcX+r.toDevice[3]*r.srcY+r.toDevice[5]),Un=D(fe-be),bn=D(bt-fn);ie=D(D(D(Wt[0]*Un)+D(Wt[2]*bn))+Math.fround(r.srcX)),ae=D(D(D(Wt[1]*Un)+D(Wt[3]*bn))+Math.fround(r.srcY));}for(;ge<pt;ge++)ie=D(ie+Wt[0]),ae=D(ae+Wt[1]);It=ie,gt=ae,r.pointsForm&&p==="bilinear"&&x&&(gt=r.srcY+(ae-r.srcY)*G2);}R&&(Ce||Wt?(It=Math.floor(It*64)/64,gt=Math.floor(gt*64)/64):(Mt<0&&(Mt=pt,Ht=Math.round(It*re),ye=Math.round(gt*re)),It=Math.floor((Ht+(pt-Mt)*Ae)/(re/64))/64,gt=Math.floor((ye+(pt-Mt)*Kt)/(re/64))/64),g&&(It=Math.round(It),gt=Math.round(gt)));let nn={x0:0,y0:0,x1:e,y1:n},rn=(be,fn)=>{let Un=Math.ceil(be-Y.radius),bn=Math.floor(be+Y.radius),km=Math.ceil(fn-G.radius),Q1=Math.floor(fn+G.radius);ct.length=0,ht.length=0;for(let hn=Un;hn<=bn;hn++)ct.push(R?Math.round(Y.weight(hn,be)*65536)/65536:Y.weight(hn,be));for(let hn=km;hn<=Q1;hn++)ht.push(R?Math.round(G.weight(hn,fn)*65536)/65536:G.weight(hn,fn));return z2(t,e,nn,Un,ct,km,ht,p==="bicubic",Rt,R,u,p==="bilinear")};p==="bilinear"&&(It=Math.floor(It)+Math.round((It-Math.floor(It))*2048)/2048,gt=Math.floor(gt)+Math.round((gt-Math.floor(gt))*2048)/2048);let[Dn,cn,ve,Me]=rn(It,gt);if(Me<=0)continue;if(R){if(Dn=Math.trunc(Dn),cn=Math.trunc(cn),ve=Math.trunc(ve),Me=Math.trunc(Me),Me<=0)continue}else if((u||p==="bilinear")&&(Dn=Math.round(Dn),cn=Math.round(cn),ve=Math.round(ve),Me=Math.round(Me),Me<=0))continue;let mn=Math.min(255,Me),Cs=(nt*k+pt)*4;B[Cs]=Math.min(Math.max(0,Dn),mn)*255/mn,B[Cs+1]=Math.min(Math.max(0,cn),mn)*255/mn,B[Cs+2]=Math.min(Math.max(0,ve),mn)*255/mn,B[Cs+3]=mn;}}return {x:U,y:F,w:k,h:W,rgba:B}}var or=128;function Ci(t){return Number.isInteger(t)&&t>0&&(t&t-1)===0}function Mb(t){return !t.pointsForm||Ci(t.srcW)&&Ci(t.srcH)}function J2(t,e,n){return Mb(t)?e===1?-(n?2:1)*65536+(t.kernel==="hq-bicubic"?1:0):0:e<=1?1:0}function pb(t){return t<1?Eb(65536/t):Math.round(65536/t)}var K2=.027;function Eb(t){return Math.floor(t+.5+K2)}function db(t){return t>512?0:t>256?2:t>64?1:0}var Z2=.9375-1e-9;function Q2(t){return t<=-128?-32768:t>=128?32768:t<0?-(512*-t-2*t*t):512*t-2*t*t}function tg(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?Si(g):Q2(g);x>b&&p.push((M-d)/65536),d=M;}a.push({first:b,weights:p});}return a}function eg(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=Ct=>Math.abs(Ct-Math.round(Ct))<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:D(D(Math.fround(r.toDevice[0])*r.srcX)+D(r.toDevice[4]))-b,y=u?Math.round(d*we)/we:Math.min(h,p),g=s[3]*r.srcY+s[5]-b,M=u?y+l*r.srcW:Math.max(h,p),T=g+s[3]*r.srcH,E=u?.5:Math.ceil(x*we-.5)/we,R=!u&&Number.isInteger(E)&&x-E>1e-5,P=!u&&Number.isInteger(E)&&E-x>1e-5,A=Math.ceil(R?x-Jr:y-Jr),I=Math.ceil(R?x+l*r.srcW-Jr:M-Jr)-1,S=D(D(Math.fround(r.toDevice[3])*r.srcY)+D(r.toDevice[5]))-b,w=Math.ceil(S*we-.5)/we,C=Number.isInteger(w)&&S-w>1e-5,v=Math.ceil(C?S-Kr:g-Kr),L=Math.ceil(C?S+s[3]*r.srcH-Kr:T-Kr)-1,_=Math.max(0,A),U=Math.max(0,v),F=Math.min(o.w-1,I),O=Math.min(o.h-1,L);if(F<_||O<U)return null;let X=F-_+1,k=O-U+1;if(X*k>rl)return null;let W=ng(t,e,n,r,_,U,X,k,i);if(W)return W;let N=a==="hq-bicubic",q=N?.5:1,Q=pb(l),K=pb(c),V=r.nominalScale;if(V&&!u&&Math.abs(V[0]/l-1)<1e-5&&Math.abs(V[1]/c-1)<1e-5){let Ct=Math.fround,nt=Ct(1/Ct(V[0]*V[1])),bt=(Mt,Ht)=>Ht<1?Eb(Mt):Math.round(Mt);Q=bt(65536*Ct(V[1]*nt),l),K=bt(65536*Ct(V[0]*nt),c);}let rt=A-x,H=rt<1e-5?0:rt,Y=Math.max(0,v-S);if(u&&(r.halfPixelOffset||!f(r.srcX)||!f(r.srcW)))return;let G=I-A+1+H,B=x-Math.floor(x),j=u?0:R?Math.round((1+B)*Q):P?Math.round((B-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>=Z2?0:-db(x),ht=db(S),ft=wi(a,l,false),at=wi(a,c,false),mt=(Ct,nt,bt,Mt,Ht,ye,ie,ae,ge=false)=>{let pt=[],fe=((nt&nt-1)===0?0:Math.round(r.srcW/170))+(ge?J2(r,ie,H>1e-9):0),It=_t=>ge?Math.round((G-_t)*nt)+fe:_t*nt+bt;if(ge&&m&&H<=1e-9&&Mb(r)){for(let _t=Ht;_t<=ye;_t++)pt.push({first:Math.round(Mt+It(_t)/65536),weights:[1]});return pt}let gt=Mt*or,Zt=Math.abs(gt-Math.round(gt))<1e-6;if(ie<1&&Zt)return tg(N,ie,nt,_t=>It(_t)+ae,Mt,Ht,ye);let Ie=N&&Zt;for(let _t=Ht;_t<=ye;_t++){let Ye=Math.floor((It(_t)-1)/(65536/or));if(Ie){let ve=Math.round(gt)+Ye,Me=Zu((ve%or+or)%or);pt.push({first:Math.floor(ve/or)+Me.first,weights:Me.weights.map(mn=>mn/65536)});continue}let nn=Mt+(Ye+q)/or,rn=Math.ceil(nn-Ct.radius),Dn=Math.floor(nn+Ct.radius),cn=[];for(let ve=rn;ve<=Dn;ve++)cn.push(Ct.weight(ve,nn));pt.push({first:rn,weights:cn});}return pt},Rt=mt(ft,Q,j,r.srcX,_-A,F-A,l,ct,u),Ae=mt(at,K,tt,r.srcY,U-v,O-v,c,ht),Kt=1/0,Wt=-1/0;for(let Ct of Ae)Kt=Math.min(Kt,Ct.first),Wt=Math.max(Wt,Ct.first+Ct.weights.length-1);let Ce=r.clampArgb??0,me=r.wrap?{wrap:r.wrap,clamp:[Ce>>>16&255,Ce>>>8&255,Ce&255,Ce>>>24&255],literal:gb(r.wrap,Ce),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 Cr=Math.max(0,Wt-Kt+1),Ln=Math.abs(c-1)<1e-9?1/0:Math.ceil((N?2:1)/Math.min(1,c)),He=new Uint8Array(Cr*X*4);for(let Ct=0;Ct<Cr;Ct++){let nt=Kt+Ct;if(me&&(Number.isFinite(Ln)&&(nt=Yo(nt,Math.max(0,r.srcY-Ln),Math.min(n,r.srcY+r.srcH+Ln),me.mirrorY,me)),nt!==Zr&&nt!==sr&&(nt=Yo(nt,0,n,me.mirrorY,me))),nt===Zr||nt!==sr&&(nt<r.srcY-Ln||nt>r.srcY+r.srcH+Ln-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,Ie=t,_t=0;if(me){if(Zt=Yo(Zt,0,e,me.mirrorX,me),Zt===Zr)continue}else if(Zt<0||Zt>=e)continue;Zt===sr||nt===sr?Ie=me?.clamp??[0,0,0,0]:_t=(bt+Zt)*4;let Ye=Ie[_t+3];if(Ye===0)continue;let nn=Ht.weights[gt],rn=!!me?.literal&&Ie===me.clamp;ye+=nn*(rn?Ie[_t]:Math.round(Ie[_t]*Ye/255)),ie+=nn*(rn?Ie[_t+1]:Math.round(Ie[_t+1]*Ye/255)),ae+=nn*(rn?Ie[_t+2]:Math.round(Ie[_t+2]*Ye/255)),ge+=nn*Ye;}let pt=Math.min(255,Math.max(0,Math.round(ge))),fe=(Ct*X+Mt)*4,It=me?.literal?255:pt;He[fe]=Math.min(It,Math.max(0,Math.round(ye))),He[fe+1]=Math.min(It,Math.max(0,Math.round(ie))),He[fe+2]=Math.min(It,Math.max(0,Math.round(ae))),He[fe+3]=pt;}}let Xe=new Uint8ClampedArray(X*k*4);for(let Ct=0;Ct<k;Ct++){let nt=Ae[Ct];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 It=nt.first+fe-Kt;if(It<0||It>=Cr)continue;let gt=(It*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=(Ct*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:_,y:U,w:X,h:k,rgba:Xe,premultiplied:i}}function ng(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?Ho(r.worldPoints,c):null,m=r.worldRect?ob(c,r.worldRect,l):f?Ii(f,l):null;if(!m||!(m[0]>0&&m[3]>0))return;let b=rb(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=ub({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=cb(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),T=M[3];if(T===0)continue;let E=(x*i+y.x-o+g)*4,R=u?1:255/T;d[E]=M[0]*R,d[E+1]=M[1]*R,d[E+2]=M[2]*R,d[E+3]=T;}}return {x:o,y:s,w:i,h:a,rgba:d,premultiplied:u}}function rg(t,e){let n=Xo(e,t),r=(o,s)=>Math.ceil(Io(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 og(t,e,n,r,o,s,i,a){let u=!!(r.pointsForm&&r.worldPoints&&r.worldMatrix&&!r.wrap),l=u?rg(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,T=r.halfPixelOffset,E=0,R=0;if(c){b=e+2*f,h=n+2*f,m=new Uint8ClampedArray(b*h*4);for(let S=0;S<n;S++)for(let w=0;w<e;w++){let C=(S*e+w)*4,v=t[C+3],L=((S+f)*b+w+f)*4;m[L]=Math.round(t[C]*v/255),m[L+1]=Math.round(t[C+1]*v/255),m[L+2]=Math.round(t[C+2]*v/255),m[L+3]=v;}[p,d,x,y]=s,g=s[4]-(T?.5:0),M=s[5]-(T?.5:0);}else {let S=l?l[0]:nl(Math.hypot(s[0],s[1])*r.srcW),w=l?l[1]:nl(Math.hypot(s[2],s[3])*r.srcH);E=S,R=w;let C=S/r.srcW,v=w/r.srcH,L=sn(t,e,n,{srcX:r.srcX,srcY:r.srcY,srcW:r.srcW,srcH:r.srcH,toDevice:[C,0,0,v,-r.srcX*C,-r.srcY*v],kernel:i,halfPixelOffset:false,wrap:r.wrap,clampArgb:r.clampArgb},{w:S,h:w},{premultOut:true});if(!L)return null;if(!L.premultiplied)for(let F=0;F<L.rgba.length;F+=4){let O=L.rgba[F+3];L.rgba[F]=Math.round(L.rgba[F]*O/255),L.rgba[F+1]=Math.round(L.rgba[F+1]*O/255),L.rgba[F+2]=Math.round(L.rgba[F+2]*O/255);}b=S+2*f,h=w+2*f,m=new Uint8ClampedArray(b*h*4);for(let F=0;F<L.h;F++)for(let O=0;O<L.w;O++){let X=O+L.x,k=F+L.y;X<S&&k<w&&m.set(L.rgba.subarray((F*L.w+O)*4,(F*L.w+O)*4+4),((k+f)*b+X+f)*4);}p=s[0]/C,d=s[1]/C,x=s[2]/v,y=s[3]/v;let _=s[0]*r.srcX+s[2]*r.srcY+s[4],U=s[1]*r.srcX+s[3]*r.srcY+s[5];g=T?_-.5+.5*(p+x):_,M=T?U-.5+.5*(d+y):U;}let P=[[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(([S,w])=>[Ft(s[0]*S+s[2]*w+s[4]),Ft(s[1]*S+s[3]*w+s[5])]),A=sn(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]:[T?-0.5:0,T?-0.5:0,E,R],...T?{chainHalf:true}:{}}:{}},o,{plainRotated:true,keepOrigin:true,premultSource:true,...u?{rasterQuad:P,rasterHalf:T,chainPad:f}:{}});if(!A)return A;let I=ne([P],false,false,T,{x:A.x,y:A.y,w:A.w,h:A.h});for(let S=0;S<A.w*A.h;S++)I[S]||A.rgba.fill(0,S*4,S*4+4);return A}var re=65536;function sg(t,e,n,r,o){let s=r.toDevice,i=yb(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(([v,L])=>[s[0]*v+s[2]*L+s[4],s[1]*v+s[3]*L+s[5]]),m=1/0,b=1/0,h=-1/0,p=-1/0;for(let[v,L]of f)m=Math.min(m,v),b=Math.min(b,L),h=Math.max(h,v),p=Math.max(p,L);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,T=g-x;if(!(M>0&&T>0)||M*T>rl)return null;let E={x:d,y:x,w:M,h:T},R=ne([f.flatMap(([v,L])=>[Ft(v),Ft(L)])],false,false,r.halfPixelOffset,E),P=Math.max(0,Math.floor(u)),A=Math.min(n,Math.ceil(u+c)),I=r.halfPixelOffset?.5:0,S=Math.round(i[0]*re),w=Math.round(i[1]*re),C=new Uint8ClampedArray(M*T*4);for(let v=0;v<T;v++){let L=x+v+I,_=-1,U=0,F=0;for(let O=0;O<M;O++){if(!R[v*M+O])continue;if(_<0){let Q=d+O+I;_=O,U=Math.round((i[0]*Q+i[2]*L+i[4])*re),F=Math.round((i[1]*Q+i[3]*L+i[5])*re);}let X=O-_,k=Math.floor((U+X*S+re/2)/re),W=Math.floor((F+X*w+re/2)/re);if(k<0||k>=e||W<P||W>=A)continue;let N=(W*e+k)*4,q=(v*M+O)*4;C[q]=t[N],C[q+1]=t[N+1],C[q+2]=t[N+2],C[q+3]=t[N+3];}}return {x:d,y:x,w:M,h:T,rgba:C}}var vi=1<<24;function Rb(t,e,n,r){return {cmds:[{op:"rect",x:t,y:e,w:n,h:r}],fillRule:"nonzero",simple:true}}function an(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 Ue(){return {cmds:[{op:"rect",x:0,y:0,w:0,h:0}],fillRule:"nonzero",simple:true}}function ig(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 ar(t,e,n){return t?t.map(r=>ig(r,e,n)):null}function ol(t){return t.simple&&t.fillRule==="nonzero"}function ir(t){return t.fillRule==="evenodd"||ol(t)}function Tb(t){let e=0;for(let n of Yr(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 ag(t,e){if(!ol(t)||!ol(e))return false;let n=Tb(t),r=Tb(e);return !Number.isNaN(n)&&!Number.isNaN(r)&&(n===0||r===0||n===r)}function $o(t){return {cmds:[{op:"rect",x:-vi,y:-vi,w:2*vi,h:2*vi},...t.cmds],fillRule:"evenodd",simple:false}}var ug={x:1<<23,y:1<<23,w:1,h:1};function Mn(t,e,n,r){let o=r??Zf(t,e),s=tr(t,e,n,o),i=!e0(o);return !r&&tr(t,e,n,ug).length>0&&(i=false),{region:[s.length>0?an(s):Ue()],exact:i}}function sl(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(ir(e)){let o=$o(e);return {region:t?[...t,o]:[o],exact:true}}return Mn(t,[e],n,r)}case "union":return t?t.length===1&&ag(t[0],e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"nonzero",simple:false}],exact:true}:Mn(t,[e],n,r):{region:null,exact:true};case "xor":return t?t.length===1&&ir(t[0])&&ir(e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"evenodd",simple:false}],exact:true}:Mn(t,[e],n,r):ir(e)?{region:[$o(e)],exact:true}:Mn(t,[e],n,r);case "complement":return t?t.length===1&&ir(t[0])?{region:[e,$o(t[0])],exact:true}:Mn(t,[e],n,r):{region:[Ue()],exact:true}}}function il(t,e,n,r){if(n==="replace")return {region:e,exact:true};if(e&&e.length===1)return sl(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:[Ue()],exact:true};case "xor":case "complement":return t?t.length===1&&ir(t[0])?{region:[$o(t[0])],exact:true}:Mn(t,e,n,r):{region:[Ue()],exact:true}}switch(n){case "intersect":return {region:t?[...t,...e]:e,exact:true};case "union":return t?Mn(t,e,n,r):{region:null,exact:true};case "complement":return t?t.length===1&&ir(t[0])?{region:[...e,$o(t[0])],exact:true}:Mn(t,e,n,r):{region:[Ue()],exact:true};case "xor":case "exclude":return Mn(t,e,n,r)}}function jo(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 lg(t,e){for(let n of e){t.beginPath(),jo(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),lg(r,e));}var cg=[[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]],Pb=234,Ab=64;function mg(t,e,n){let r=()=>{let s=((e-n)%8+8)%8;return s===0?Pb:s===1||s===7?Ab:0},o=()=>{let s=((e+n-7)%8+8)%8;return s===0?Pb:s===1||s===7?Ab:0};switch(t){case 2:return r();case 3:return o();case 5:return Math.max(r(),o());default:{let s=cg[t];return s&&s[n]&128>>e?256:0}}}function fg(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 Ib(t){let e=new Uint8ClampedArray(256);for(let n=0;n<8;n++)for(let r=0;r<8;r++){let o=fg(t.fore,t.back,mg(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 Sb(t,e,n){let r=Ib(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 wb(t,e,n,r,o){if(typeof t.createPattern!="function")return null;let s=St(8,8);if(!s)return null;vt(s.ctx,Et(Ib(e),8,8),0,0);let i=qs(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 Li=class{constructor(){throw new Error("SVG output is not part of the emf-converter lite build")}};function At(t){return false}function Te(t){return true}function Gg(t,e,n){let r=D,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 En(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 _e(t,e,n){if(e&32768)return ue(n);let r=t.objectTable.get(n&255);return r&&r.kind==="plus-brush"?ul(t,r):"rgba(0,0,0,1)"}function ul(t,e){if(e.gradient){let n=Uf(t.ctx,e.gradient,Dt(t));if(n)return n}if(e.texture){let n=Q0(t.ctx,e.texture,Dt(t));if(n)return n}if(e.hatch){let n=wb(t.ctx,e.hatch,t.ext?.renderingOrigin??{x:0,y:0},Dt(t),ki(t));if(n)return n}return e.color}var al=0,_i=1,Wg=6,lr=96;function cr(t,e,n=lr,r=true){let o;switch(t){case _i: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 Hg(t){let e=t.videoDisplay??true;return [cr(t.pageUnit,t.pageScale,t.dpiX??lr,e),cr(t.pageUnit,t.pageScale,t.dpiY??lr,e)]}function Dt(t){let e=Fi(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 Tn(t){return t.ext||(t.ext={}),t.ext}function Fi(t){let e=t.ext;if(e?.tsDevice)return e.tsDevice;let n=t.worldTransform,[r,o]=Hg(t),s=[n[0]*r,n[1]*o,n[2]*r,n[3]*o,n[4]*r,n[5]*o];return e?.containerTransform?En(s,e.containerTransform):s}function ki(t){let e=t.dpiScale,n=[e,0,0,e,0,0];return t.baseTransform?En(n,t.baseTransform):n}function pe(t,e=true){let n=Dt(t),r=e?ll(t):0;t.ctx.setTransform(n[0],n[1],n[2],n[3],n[4]+r,n[5]+r);}function ll(t){return At(t.ctx)?0:t.antiAlias&&!Ee(t.pixelOffsetMode??0)?.5:0}function Ub(t,e){let n=Tn(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 Cb(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=Tn(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&&Qr(t);}}function vb(t,e,n){let r=Fi(t),o=Ui(t.ext?.containerClip,t.clipRegion);Ub(t,e);let s=Tn(t);s.containerTransform=n?En(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=_i,t.pageScale=1,t.antiAlias=false,t.interpolationMode=void 0,t.pixelOffsetMode=void 0,t.textRenderingHint=void 0,Qr(t);}function Xg(t,e,n,r=lr,o=lr,s=true){let i=n===al?r/100:cr(n,1,r,s),a=n===al?o/100:cr(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 Ui(t,e){let n=[...t??[],...e??[]];return t||e?n:null}function Di(t){return Dt(t)}function _b(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 Yg(t,e){return Du(t.path,e)}var $g={0:"intersect",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"},Lb=64;function Vo(t,e,n=0,r){if(n>Lb)return {region:[Ue()],exact:false};switch(t.type){case "rect":return {region:[_b(t.x,t.y,t.width,t.height,e)],exact:true};case "path":return {region:[Yg(t,e)],exact:true};case "infinite":return {region:null,exact:true};case "empty":return {region:[Ue()],exact:true};case "combine":{let o=Vo(t.left,e,n+1,r),s=Vo(t.right,e,n+1,r),i=$g[t.combineMode]??"intersect",a=il(o.region,s.region,i,r);return {region:a.region,exact:a.exact&&o.exact&&s.exact}}}}var jg={0:"replace",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"};function cl(t){if(!(t.canvasW===void 0||t.canvasH===void 0))return {x:0,y:0,w:t.canvasW,h:t.canvasH}}function Fb(t){let e=t.ext;return Ui(Ui(e?.containerClip,t.clipRegion??void 0)??void 0,e?.tsClip??void 0)}function Qr(t){We(t,Fb(t),true);}function kb(t,e){let n=cl(t);if(t.gdiAntialias===true||!e||!n||At(t.ctx))return e;let r=Ee(t.pixelOffsetMode??0),o=M0(e.map(a=>({build:u=>jo(u,a.cmds),evenOdd:a.fillRule==="evenodd"})),n,r);if(o)return [an(o)];let s=(r?0:.5)-1/32,i=ar(e,s,s);return [an(tr(i,null,"intersect",n))]}function Ob(t,e,n,r){let o=kb(t,e),s=jg[n];let i=il(t.clipRegion??null,o,s??"intersect",cl(t));i.exact||z(`${r}: CombineMode ${n} approximated (no canvas domain for an unbounded result)`),t.clipRegion=i.region,Qr(t);}function Db(t,e,n,r){Ob(t,[e],n,r);}function ur(t){t.ext?.tsDevice&&(t.ext.tsDevice=null);}function Vg(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=Tn(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 zg(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 qg(t,e,n,r){let o=zg(t.view,n,r,e);if(!o)return;let s=ki(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}:Ue(),c=Tn(t);c.tsClip=Ui(Fb(t)??void 0,kb(t,[l])??void 0),Qr(t);}function Bb(t,e,n,r,o){let{view:s}=t;switch(e){case 16426:return ur(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 ur(t),t.worldTransform=[1,0,0,1,0,0],true;case 16428:{if(ur(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=En(t.worldTransform,i):t.worldTransform=En(i,t.worldTransform);}return true}case 16429:{if(ur(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=En(t.worldTransform,u):t.worldTransform=En(u,t.worldTransform);}return true}case 16430:{if(ur(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=En(t.worldTransform,u):t.worldTransform=En(u,t.worldTransform);}return true}case 16431:return ur(t),o>=4&&(t.worldTransform=Gg(t.worldTransform,s.getFloat32(r,true),(n&8192)!==0)),true;case 16421:return o>=4&&Ub(t,s.getUint32(r,true)),true;case 16422:return o>=4&&Cb(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=_b(a,u,l,c,Di(t));Db(t,f,i,"SetClipRect");}return true}case 16433:return t.clipRegion=null,Qr(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=Vo(u.nodes[0],Di(t),0,cl(t));l.exact||z("SetClipRegion: region tree approximated (no canvas domain for an unbounded result)"),Ob(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=Du(u,Di(t));Db(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=Di(t),l=u[0]*i+u[2]*a,c=u[1]*i+u[3]*a;t.clipRegion=ar(t.clipRegion,l,c),Qr(t);}}return true}case 16424:return o>=4&&vb(t,s.getUint32(r,true),null),true;case 16423:{if(o>=36){let i=u=>s.getFloat32(r+u,true),a=Xg({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);vb(t,s.getUint32(r+32,true),a??[1,0,0,1,0,0]);}return true}case 16425:return o>=4&&Cb(t,s.getUint32(r,true)),true;case 16432:{ur(t);let i=n&255,a=o>=4?s.getFloat32(r,true):1;return i===al||i>Wg||!(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 Tn(t).compositingQuality=n&255,true;case 16419:return Tn(t).compositingMode=n&255,true;case 16413:return o>=8&&(Tn(t).renderingOrigin={x:s.getInt32(r,true),y:s.getInt32(r+4,true)}),true;case 16416:return Tn(t).textContrast=n&4095,true;case 16441:return Vg(t,r,o),true;case 16442:return qg(t,n,r,o),true;default:return false}}function Wb(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 Nb(t,e,n){let r=St(e,n);return r?(vt(r.ctx,Et(t,e,n),0,0),r):null}function ml(t,e,n){let r=Wb(t);if(n.resample&&r){let s=sn(e.rgba,e.width,e.height,n.resample,r);if(s){let i=Nb(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=Nb(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 Jg(t,e){if(!t.data)return null;let n=new Uint8Array(t.data.slice(0)),r=Nr(n);return r?{kind:"encoded",bytes:n,mime:r}:e?{kind:"rgba",data:e.rgba,width:e.width,height:e.height}:Ao(n.buffer)}function Gb(t,e,n,r,o=false){let s=o&&n?{kind:"rgba",data:n.rgba,width:n.width,height:n.height}:Jg(e,n);if(!s)return false;let i=t.reserveSlot(),a=t.imageResampling==="exact"&&n&&r.resample?sn(n.rgba,n.width,n.height,r.resample,{w:t.canvas.width,h:t.canvas.height}):null,u=r.resample?Js(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&&ml(t.shadow,n,r),true}var fl=2,bl=null;function Hb(t){bl=t;}function Kg(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 Zg(t,e,n,r){let o=t.nestingDepth??0;if(!bl||!r||!e.data||r.unit!==fl||o>=$u)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=Wb(t.ctx);if(!l)return false;let c=Kg(Xt(Dt(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=bl(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 Oi(t,e,n,r,o){if(o&&o.unit!==fl)return null;let s=e;if(!s&&t.data){let p=Ao(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===fl&&o.srcW>0&&o.srcH>0&&[o.srcX,o.srcY,o.srcW,o.srcH].every(Number.isFinite)?o:null,a=$f(Yf(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 Xb(t,e,n,r,o=null){let s=e.cacheKey!==void 0?t.imageCache?.get(e.cacheKey):void 0;if(e.type===2)return Zg(t,e,s,r);let i=s&&s.kind==="bitmap"?s:null,a=o?Oi(e,i,o,n,r):null;return a?At(t.ctx)?Gb(t.ctx,e,a.bitmap,a.draw,true):ml(t.ctx,a.bitmap,a.draw):o&&!i?false:At(t.ctx)?Gb(t.ctx,e,i,n):i?ml(t.ctx,i,n):false}var hl=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:Qg()};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 Qg(){return new DOMException("The operation was aborted due to timeout","TimeoutError")}var Bi=Symbol("emf-converter.budget");function to(t){return t?t[Bi]?t[Bi]:t.signal===void 0&&t.timeoutMs===void 0?null:new hl(t):null}var Hn=null;function Fe(){Hn&&Hn.check();}function eo(){return Hn!==null&&Hn.yields&&performance.now()-Hn.sliceStart>16}function tM(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 zo(t,e){return t?tM(t,e):e()}function eM(){return new Promise(t=>setTimeout(t,0))}async function pl(t,e){for(;;){let n=zo(t,()=>e.next());if(n.done)return n.value;await eM(),t?.check();}}function Ni(t){for(;;){let e=t.next();if(e.done)return e.value}}var Gi=null;function nM(t,e,n){if(!Gi){Gi=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;Gi[o]=s>>>0;}}let r=4294967295;for(let o=e;o<n;o++)r=Gi[(r^t[o])&255]^r>>>8;return (r^4294967295)>>>0}function rM(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 oM(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=rM(t);return n[r++]=o>>>24,n[r++]=o>>>16&255,n[r++]=o>>>8&255,n[r++]=o&255,n}async function sM(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 oM(t)}function iM(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 Yb(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 aM(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 T=f>>2,E=m>>2,R=true;for(let P=0;P<e;P++)if(s[T+P]!==s[E+P]){R=false;break}if(R){i[b]=2;continue}}let h=r.subarray(f,f+o),p=Yb(h,o);if(p===0){i.set(h,b+1);continue}let d=0,x=0;for(let T=0;T<4&&T<o;T++){let E=r[f+T];a[T]=E,d+=E<128?E:256-E;}for(let T=4;T<o;T++){let E=r[f+T]-r[f+T-4]&255;a[T]=E,d+=E<128?E:256-E;}if(c>0)for(let T=0;T<o;T++){let E=r[f+T]-r[m+T]&255;u[T]=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,P=r[m+E],A=E>=4?r[m+E-4]:0;l[E]=r[f+E]-iM(R,P,A)&255;}Yb(l,o)<M&&(y=l,g=4);}i[b]=g,i.set(y,b+1);}return i}function dl(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,nM(n,4,8+e.length)),n}async function Wi(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 sM(aM(t,e,n)),i=[Uint8Array.of(137,80,78,71,13,10,26,10),dl("IHDR",r),dl("IDAT",s),dl("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 $b(){throw new Error("JPEG output is not part of the emf-converter lite build")}function jb(){throw new Error("WebP output is not part of the emf-converter lite build")}var Hi=class t{constructor(){this.size=0;}static for(e,n){return new t}};function mr(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 Xi(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 Jo(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 hM=[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 Ko(t){return t>>>24!==0}function ze(t){return t.palette?.entries??hM}function Zo(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=Zo(e,ze(t));return vs(n>>16&255,n>>8&255,n&255)}function qb(t,e,n){return de(t,Xn(e,n))}function no(t,e,n){let r={...t.colorRefs};n!==void 0&&Ko(n)?r[e]=n:delete r[e],t.colorRefs=r;}function Jb(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 Vb(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 xl(t,e){let n=t.objectTable.get(e);return n&&n.kind==="palette"?n:null}function zb(t,e){t.state.palette===e&&Jb(t.state);}function Kb(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:Vb(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=xl(t,i);if(!a)return true;s.palette=a;}Jb(s);}return true}case 50:{if(r>=20){let i=xl(t,o.getUint32(n,true)),a=o.getUint32(n+4,true),u=o.getUint32(n+8,true);if(i){let l=Vb(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];zb(t,i);}}return true}case 51:{if(r>=16){let i=xl(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);zb(t,i);}}return true}case 52:return true;default:return false}}function Bt(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 Nt(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 Rn(t){return !t.useMappingMode||t.deviceToCanvas?t.sx:1}function Pn(t){return !t.useMappingMode||t.deviceToCanvas?t.sy:1}function yl(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.left)*t.sx:e}function gl(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.top)*t.sy:e}function ro(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 Ut(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 Yi(t,e,n,r,o){let s=yt(t),i=Ut(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 Zb(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 Ml(t){return t>>>16&255}function un(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 $i(t){let e=Ml(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:un(e)}}}function Qb(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 th(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 pM={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 pM}function oo(t){if(!Number.isInteger(t)||t<1||t>16)return;let e=t-1;return (e>>2)*80+(e&3)*5}function El(t,e,n){return t<<16|e<<8|n}function Tl(t,e){switch(e){case "invert":return ~t&16777215;case "black":return 0;case "white":return 16777215;default:return t}}function An(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 Rl(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,T=0)=>{r=Math.min(r,g+a-T),o=Math.min(o,M+u-T),s=Math.max(s,g+a+T),i=Math.max(i,M+u+T);},f=()=>{l=true;},m={moveTo:(g,M)=>c(g,M),lineTo:(g,M)=>c(g,M),rect:(g,M,T,E)=>{c(g,M),c(g+T,M+E);},fillRect:(g,M,T,E)=>{c(g,M),c(g+T,M+E);},strokeRect:(g,M,T,E)=>{c(g,M),c(g+T,M+E);},bezierCurveTo:(g,M,T,E,R,P)=>{c(g,M),c(T,E),c(R,P);},quadraticCurveTo:(g,M,T,E)=>{c(g,M),c(T,E);},arcTo:(g,M,T,E)=>{c(g,M),c(T,E);},arc:(g,M,T)=>c(g,M,Math.abs(T)),ellipse:(g,M,T,E)=>c(g,M,Math.max(Math.abs(T),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 dM=1024*1024,br=null;function qe(t,e){let n=br&&br.w>=t&&br.h>=e?br:null;if(!n){let o=Math.max(t,br?.w??0),s=Math.max(e,br?.h??0),i=o*s<=dM,a=i?St(o,s):St(t,e);if(!a)return null;n={canvas:a.canvas,ctx:a.ctx,w:i?o:t,h:i?s:e},i&&(br=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 Je(t,e,n,r){vt(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 ji(t,e){return null}function Vi(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 zi(t,e,n){}function so(t,e,n,r){try{let o=Pt(t,e.x,e.y,e.w,e.h),s=o.data,i=qe(e.w,e.h),a=i?Pt(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,El(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 vt(t,o,e.x,e.y),!0;let l=ji(t,e),c=l?Vi(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 Je(t,e,i,a),zi(t,e,c),!0}catch{return false}}function Pl(t,e,n,r,o=2,s){let i=oo(e);if(i===void 0||false)return false;if(i===170)return true;let a=An(t);if(!a)return false;try{let u=Rl(r,o,a);if(!u)return !0;let l=qe(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=Pt(c,0,0,u.w,u.h),p=h.data,d=i===240?null:Pt(t,u.x,u.y,u.w,u.h).data,x=d?ji(t,u):null,y=x?new Int32Array(u.w*u.h):null;for(let M=0;M<p.length;M+=4){let T=p[M+3],E;if(T===0)E=!1;else if(T===255)E=!0;else if(f){let A=(M>>2)%u.w,I=((M>>2)-A)/u.w;E=c.isPointInPath(A+.5,I+.5,s);}else E=T>=128;if(!E){p[M]=0,p[M+1]=0,p[M+2]=0,p[M+3]=0;continue}let R=b>=0?b:El(p[M],p[M+1],p[M+2]);y&&(y[M>>2]=R);let P=R;if(d){let A=El(d[M],d[M+1],d[M+2]);P=Vt(i,R,A,A);}p[M]=P>>16&255,p[M+1]=P>>8&255,p[M+2]=P&255,p[M+3]=255;}let g=[];if(x&&y);return Je(t,u,l,h),zi(t,u,g),!0}catch{return false}}var xM=16*1024*1024;function eh(t){if(t.gdiAntialias!==false)return null;if(t.rasterLayer!==void 0)return t.rasterLayer;let e=An(t.ctx);return !e||At(t.ctx)||e.w*e.h>xM?(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 Gt(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=qe(n.w,n.h);if(o){Je(t.ctx,n,o,Et(r,n.w,n.h));return}let s=Pt(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);vt(t.ctx,s,n.x,n.y);}var yM=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 qi(t){return yM.has(t)}function oh(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 nh(t){return `#${(t&16777215).toString(16).padStart(6,"0")}`}function sh(t){for(let e of [0,16777215])if(Vt(t,e,0,0)!==Vt(t,e,0,16777215))return true;return false}function ih(t,e){t.beginPath();for(let n of Al(e))t.rect(n.x,n.y,n.w,n.h);}function Al(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 rh(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,ih(t,e),t.fill("nonzero");}finally{t.restore();}}function se(t,e,n,r){if(e.length===0)return;let o=oo(r)??240;if(o===170)return;let s=sh(o)?null:eh(t);if(!s){Gt(t),gM(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(oh(n,d,m))continue;let x=c;if(n.kind==="tile"){let[y,g]=n.toDevice(d,m);x=Vt(o,Jn(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 gM(t,e,n,r){if(e.length===0)return;let o=oo(r)??240;if(o===170)return;let s=sh(o);if(n.kind==="solid"&&!s){rh(t,e,nh(Vt(o,n.rgb,0,0)));return}if(n.kind==="tile"&&At());let i=e.bounds(),a=An(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=qe(m.w,m.h);if(!b)return;let h=Pt(t,m.x,m.y,m.w,m.h).data,p=Pt(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]),T=Math.min(c,x[y+2]);for(let E=M;E<T;E++){if(oh(n,E,g))continue;let R=((g-l)*m.w+(E-u))*4,P;if(n.kind==="solid")P=n.rgb;else {let[I,S]=n.toDevice(E,g);P=Jn(n.tile,I,S,n.orgX,n.orgY);}let A=P;if(s){let I=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,P,I,I);}else A=Vt(o,P,0,0);d[R]=A>>16&255,d[R+1]=A>>8&255,d[R+2]=A&255,d[R+3]=255;}}Je(t,m,b,p);}var MM=[[[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]]],wl=104;function EM(t,e){return t?e?.5:-0.5:0}function TM(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 ah=new Map;function Cl(t,e=t){let n=`${t},${e}`,r=ah.get(n);if(r)return r;let o;if(t===e&&t<wl){let s=Math.min(6,Math.max(1,Math.floor(t/16+.5)));o=MM[s-1];}else {let s=Math.ceil(t/2),i=Math.ceil(e/2),a=ru(nu(-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 ah.set(n,o),o}var Il=new Map;function Ji(t){return Math.sign(t)*Math.floor(Math.abs(t)+.75)}function RM(t,e){let n=`${t},${e.join(",")}`,r=Il.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<wl){let b=Cl(Math.round(t*o));return Il.set(n,b),b}let s=t/2,i=e[0]*e[3]-e[1]*e[2]<0?-1:1,a=[Ji(e[0]*s),Ji(e[1]*s)],u=[i*Ji(e[2]*s),i*Ji(e[3]*s)],l=dn({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=ru(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 Il.set(n,m),m}function PM(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 Ki(t){return Math.sign(t)*8*Math.floor((Math.abs(t)+4)/8)}function AM(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??Cl(t,r),l=u.length,c=-i,f=s,m=0,b=-1/0;for(let U=0;U<l;U++){let F=c*u[U][0]+f*u[U][1];F>b&&(b=F,m=U);}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,T]=x>=y?[h,x,y]:[p,y,x],E=2*(b-M+(b-T)),R=E===0?0:(M-T)/E,P=d[0]+(g[0]-d[0])*R,A=d[1]+(g[1]-d[1])*R,I=M-T,S=U=>Math.sign(E===0?d[U]:d[U]*E+(g[U]-d[U])*I),w=o?[S(0)!==0?-S(0):s===0?0:Math.sign(i),S(1)!==0?S(1):Math.sign(s)]:[s===0?0:Math.sign(i),Math.sign(s)],C=o?m<l/2:m===0&&x>=y,v=[0,1].map(U=>{let F=w[U]+2*EM(Math.abs(g[U]-d[U])%2===1,C);if(E===0)return 8*(U===1&&i<0?Math.ceil((d[U]+F/2+4)/8)-1:Math.floor((d[U]+F/2+4)/8));let O=d[U]*E+(g[U]-d[U])*I;return 8*TM(2*O+E*(F+8)-(U===1&&i<0?1:0),16*E)}),L=v[0],_=v[1];return {v:a?[-L,-_]:[L,_],ray:a?[-P,-A]:[P,A]}}function ln(t,e){return Math.sqrt(t*t+e*e)}function uh(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=ln(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?T=>Math.sign(T)*Math.floor(Math.abs(T)+.5):T=>Math.floor(T+.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=ln(y(p),y(d));return g===0?[0,0]:[b(p/g*m),b(d*f/c/g*m)]}let h=t===o?ln(e,n):ln(e,n*t/o);return [b(e/h*m),b(n/h*m)]}function Zi(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 Sl=class{constructor(e,n){this.opts=e;this.out=n;this.pts=[];this.pen=e.matrix&&e.deviceNib?RM(e.width,e.matrix):Cl(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]=PM(this.pen,u[0],u[1],this.opts.width,this.opts.height,l),m=s&&o?o:[i,a],b=AM(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:uh(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 [Ki(r[0]),Ki(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 [Ki(r[0]),Ki(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=ln(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 uh(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=wM(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=Zi(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=Zi(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=Zi(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=Zi(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<wl;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 Qi(t){return Math.sign(t)*Math.floor((Math.abs(t)+8)/16)*16}function lh(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 IM(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,T=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]):ln(g[0],g[1]),E=i?ln(Qi(g[0]/i[0]),Qi(g[1]/i[1])):a?ln(Qi((a[3]*g[0]-a[2]*g[1])/M),Qi((-a[1]*g[0]+a[0]*g[1])/M)):s?ln(Math.floor(g[0]/16),Math.floor(g[1]/16))*16:ln(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 P=[lh(p,g[0],R,E),lh(d,g[1],R,E)];m&&b?(b.pts.push(P),b.dirs.push(g),b.draws.push(e[h]),b.curves.push(n[h]),b.endScale=b.pts[0]===t[0]&&P[0]===t[0][0]&&P[1]===t[0][1]?1:T/E,u.push(b),b=null):b={pts:[P],dirs:[],draws:[],curves:[],startScale:T/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=T/E);}return m&&b&&b.dirs.length>0&&(b.endScale=1,u.push(b)),u}function SM(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 wt;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 Qo(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 Qo(t,e){if(e.matrix&&!e.deviceNib)return SM(t,e,e.matrix);let n=[],r=!!e.dashes&&e.dashes.length>0;for(let o of t.figures){let s=new Sl(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 IM(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 wM(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,T=(-u[1]*p+u[0]*d)/g;return Math.hypot(Math.round(M/16),Math.round(T/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 vl(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 ts(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 CM(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 vM(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 hr(t,e=false){let n=CM(e?vM(t):t);t.halfXRect&&(n[4]--,n[6]--);let r=new wt;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 es(t,e=false){let n=new wt;return n.addBeziers(dn(t,e),true),n.closeFigure(),n.figures[0].roundWiden=true,n}function ch(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 mh(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 Ll(t,e,n,r=false,o=false){let s=mh(t),i=Re(t)&&t.exx<0,a=Re(t)&&t.eyy<0,u=r!==a,l=of(s.l,s.t,s.r,s.b,e,n,o,u,i,Re(t)?t.cornerRatio:void 0),c=ch(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(Se*h):Math.ceil(Se*h),x=u?Math.ceil(Se*p):Math.floor(Se*p),y=(M,T,E)=>{T!==null&&(f[2*M]=T),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 ea(t,e,n,r=false,o=false,s=false){if(o)return hr(t,r);let i=Ll(t,e,n,r,s),a=new wt;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 io(t,e,n,r,o,s,i=new wt,a){let u=mh(t),l=ch(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,T)=>{let E=M-t.ax,R=T-t.ay,P=(E*t.eyy-R*t.eyx)/y,A=(t.exx*R-t.exy*E)/y;return [u.l+P*(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=lf(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,T]=l(u.l+Math.ceil(y/2)+(t.halfX&&!p?1:0),u.t+Math.ceil(g/2));i.lineTo(M,T);}return (o==="pie"||o==="chord")&&i.closeFigure(),{path:i,end:[x[x.length-2],x[x.length-1]]}}var fh=5,LM=65536;function na(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)&LM)===0&&t.state.penExtended?true:Math.round(na(t)/(t.wholeDevicePixels?.[0]??1))<=1}function Dl(t){return (t.state.penStyle&15)!==fh}function Ul(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])):na(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?Po(r,n.penWidth,n.penUserStyle,1):Po(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 DM(t){let e=new Uint8Array(64);for(let n=0;n<8;n++)for(let r=0;r<8;r++)e[n*8+r]=vr(t,r,n)?0:1;return e}function Ke(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:DM(s.brushPattern.hatch)}:{}}}function UM(t){if(!t.figures.some(n=>n.tangents))return t;let e=new wt;return e.figures=t.figures.map(n=>({pts:n.pts,closed:n.closed,roundWiden:n.roundWiden})),e}function ta(t,e,n=false){if(!t.wmfLayoutRtl||n)return e;let r=Math.round(16*(t.wholeDevicePixels?.[0]??1)),o=new wt;return o.figures=e.figures.map(s=>({...s,pts:s.pts.map((i,a)=>a%2===0?i-r:i)})),o}function bh(t,e,n){e=ta(t,e,n.rectangle||n.roundPen);let{ctx:r,state:o}=t,s=!!n.filled;if(n.fill){let c=Ke(t);if(c){s=true;let f=n.fillPath?ta(t,n.fillPath,n.rectangle||n.roundPen):e,m=Lr(f,!!n.winding);se(t,m,c,o.rop2);}}if(!n.stroke||o.penStyle===fh)return true;if(!xe(t)){if(!Dl(t))return false;let c=Qo(s?UM(e):e,Ul(t,n));return se(t,Zn(c,true),{kind:"solid",rgb:vl(o.penColor)},o.rop2),true}let i=Dr(o.penFlags??o.penStyle,o.penUserStyle),a=new zt,l=i!==null&&o.bkMode===2&&Gs(o.penFlags??o.penStyle)?new zt:null;return Ws(e,a,l,i,n.style??{pos:0}),l&&se(t,l,{kind:"solid",rgb:vl(o.bkColor)},o.rop2),se(t,a,{kind:"solid",rgb:vl(o.penColor)},o.rop2),true}var _l=.5-1/32;function Fl(t,e){return e===0?t:n=>{n.save(),n.translate(e,e),t(n),n.restore();}}function kl(t){return t.gdiAntialias===false}function _M(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=oo(s.rop2)??240,c=s.bkMode===1&&s.brushPattern?.kind==="hatch"?s.brushPattern.hatch:-1,f=(x,y)=>c>=0&&!vr(c,((x-s.brushOrgX)%8+8)%8,((y-s.brushOrgY)%8+8)%8);let m=An(r);if(!m||typeof r.isPointInPath!="function")return false;if(l===170)return true;let b=n?Rl(n,1,m):{x:0,y:0,w:m.w,h:m.h};if(!b)return true;let h=.5-_l,p=(x,y)=>Jn(i,Math.floor(o.left+(x+.5)/a),Math.floor(o.top+(y+.5)/u),s.brushOrgX,s.brushOrgY),d=he(s.rop2);return so(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:Tl(p(x,y),d.colorTransform),mode:d.gco}))}function FM(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=_M(t,n,i);if(r&&e(o),l)return}else {let l=he(s.rop2);if((kl(t)||!l.exact&&Yn(s.rop2))&&Pl(o,s.rop2,s.brushColor,f=>{Fl(i,_l)(f),f.fill(n);},1,n))return}let a=jt(t)?_l:0,u=a!==0||r!==void 0;u&&Fl(i,a)(o),kr(o,s),o.fill(n),u&&e(o);}var ns=5;function pr(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 dr(t,e=1){if(t.penStyle===ns)return 0;let n=pr(t,e);return Number.isInteger(n)&&n%2===1?.5:0}function hh(t,e){let{state:n}=e,r=$n(e),o=pr(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(Po(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 kM(t){let{state:e}=t;return e.penStyle===ns||!xe(t)?null:Dr(e.penFlags??e.penStyle,e.penUserStyle)}function OM(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&&Gs(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;Bs(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=_r(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 BM(t,e){let{ctx:n,state:r}=t,o=$n(t),s=dr(r,o),i=Fl(e,s),a=he(r.rop2);r.penStyle!==ns&&(kl(t)||!a.exact&&Yn(r.rop2))&&Pl(n,r.rop2,r.penColor,l=>{hh(l,t),i(l),l.stroke();},pr(r,o)/2+2)||(s!==0&&i(n),Fr(n,r),r.penStyle!==ns&&hh(n,t),n.stroke());}function Jt(t,e){let{ctx:n,state:r}=t,o=kl(t),s=!he(r.rop2).exact&&Yn(r.rop2),i=r.penStyle===ns,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=Ke(t);if(p){let d=ta(t,l(),e.rectangle||e.roundPen),x=Lr(d,m==="nonzero");e.axisRect&&e.stroke&&a&&(x=NM(x,l())),se(t,x,p,r.rop2);}}else {f();let p=e.axisRect&&e.stroke&&!i?e.axisRect.interior:void 0;FM(t,e.build,m,p);}}if(!e.stroke||i)return;if((a||Dl(t))&&(o||s)){bh(t,l(),{fill:false,stroke:true,style:e.style,rectangle:e.rectangle,roundPen:e.roundPen,filled:!!e.fill&&r.brushStyle!==1});return}let b=kM(t);if(b&&!o&&!s){OM(t,l(),b,e.style??{pos:0});return}Gt(t),f(),BM(t,e.build);}function NM(t,e){let n=new zt;Ws(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 ph(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=On(e,t.center.x,t.center.y),o=yn(t.centerArgb),s=t.boundary.map(l=>On(e,l.x,l.y)),i=ni(t.preset),a=i?{preset:i}:{adjust:ei(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 ti([r[0],r[1],s[l][0],s[l][1],s[c][0],s[c][1]],[o,yn(t.boundaryArgb[l]),yn(t.boundaryArgb[c])],a));}return {triangles:u}}function dh(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=wo(u.argb[l],u.argb[l+1],u.argb[l+2],u.argb[l+3],s);}return i}var Bl=[1,0,0,1,0,0],Nl=16*1024*1024,GM=1e-4;function Ze(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 WM(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 HM(t,e,n=false){let{width:r,height:o,rgba:s,wrapMode:i}=t;if(r<=0||o<=0)return null;let a=Pi(Xt(e,t.transform??Bl),n);return a?(u,l,c,f,m,b)=>{Z0(a,r,o,s,i,u,l,c,f,m,b);}:null}function XM(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 xh(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 YM(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 Ol(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 ra=2048;function oa(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 $M(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=>[on(l.x),on(l.y)]);o[o.length-1]={x:a[0]/16,y:a[1]/16};let u=[];Ge(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 jM(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=gh({...t,boundary:t.source?$M(t.source,m,n):t.boundary.map(m),source:void 0,center:m(t.center),transform:null},"clamp",Bl,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,T,E)=>{let R=x();for(let P=0;P<T;P++){let A=f*(g+P-o),I=Math.floor(A),S=Math.floor((A-I)*ra+.5)/ra,w=oa(I,l,p)*u,C=oa(I+1,l,p)*u;for(let v=0;v<M;v++){let L=c*(y+v-r),_=Math.floor(L),U=Math.floor((L-_)*ra+.5)/ra,F=oa(_,u,h),O=oa(_+1,u,h),X=(P*M+v)*4,k=q=>(1-U)*(1-S)*R[(w+F)*4+q]+U*(1-S)*R[(w+O)*4+q]+(1-U)*S*R[(C+F)*4+q]+U*S*R[(C+O)*4+q],W=k(3),N=Math.floor(W+.5);if(N<=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/N+.5));}E[X+3]=N;}}}}function gh(t,e,n,r=true,o=false){let s=XM(t.boundary),i=Xt(n,t.transform??Bl),a=Ze(i);if(!s||!a)return null;if(e!=="clamp"&&!Ol(t.boundary,i)){let T=jM(t,e,i);if(T)return T}let c=!t.boundaryArgb.every(T=>T===t.boundaryArgb[0])||e!=="clamp"&&!Ol(t.boundary,i)?0:vf(t.boundary,i),f=e==="clamp"||Ol(t.boundary,i)?ph(t,i):null,m=c>0?Mf(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"?GM:0,M=e==="clamp"?null:YM(s,i);return (T,E,R,P,A,I)=>{let S=M!==null&&T>=M[0]&&T+R<=M[2]&&E>=M[1]&&E+P<=M[3],w=M&&!S?M[0]:T,C=M&&!S?M[2]:T+R,v=o||M!==null&&!S,L=I!==void 0&&!(M&&!S);for(let _=0;_<P;_++){let U=E+_,F=-1;for(let O=0;O<R;O++){if(L&&I[_*R+O]&&O>=F){let V=O;for(;V>0&&I[_*R+V-1];)V--;for(F=O;F<R&&I[_*R+F];)F++;w=T+V,C=T+F;}let X=T+O+g,k=a[0]*X+a[2]*U+a[4],W=a[1]*X+a[3]*U+a[5];if(e!=="clamp"&&(k=xh(k,s.x,s.w,x,p),W=xh(W,s.y,s.h,y,d)),e==="clamp"&&W>=s.y+s.h&&!f&&!m)continue;let N=g?{x:k-a[0]*g,y:W-a[1]*g}:void 0,q=null,Q=false;if(f||m){let V=e==="clamp"?T+O:i[0]*k+i[2]*W+i[4],rt=e==="clamp"?U: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=dh(f,H,Y,w,C,v),q===null&&r&&(Q=true);else if(m){let G=m.colorAt(H,Y,w,C);G!==null?q=wo(G>>>24,G>>>16&255,G>>>8&255,G&255,v):r&&(Q=true);}}}if(q===null&&!Q)if(m){let V={s:NaN};if(si(t,k,W,N,V)!==null){let rt=m.colorForPosition(V.s);q=wo(rt>>>24,rt>>>16&255,rt>>>8&255,rt&255,v);}}else q=si(t,k,W,N);if(q===null)continue;let K=(_*R+O)*4;A[K]=q>>>16&255,A[K+1]=q>>>8&255,A[K+2]=q&255,A[K+3]=q>>>24&255;}}}}function uo(t,e,n){if(e&32768)return null;let r=t.objectTable.get(n&255);return !r||r.kind!=="plus-brush"?null:Gl(t,r)}function Gl(t,e){let n=Dt(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=Ze(ki(t));if(s)return Sb(e.hatch,t.ext?.renderingOrigin??{x:0,y:0},s)}return e.texture?HM(e.texture,n,Ee(t.pixelOffsetMode??0)):e.gradient&&e.gradient.type==="radial"&&e.gradient.shape?gh(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]),If(e.gradient,n,Ee(t.pixelOffsetMode??0),t.ext?.compositingMode===1,o)):null}function xr(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 In(t,e,n,r,o,s="nonzero"){let{ctx:i}=t,a=WM(i);if(!a||typeof i.clip!="function"||typeof i.drawImage!="function")return false;let u=os(t);if(u!=="canvas"){let b=Wl(t,e,n);if(b&&zM(t,b,r,o,s,a,u))return true}let l=uo(t,e,n);if(!l)return false;let c=xr(o,Dt(t),a);if(!c)return true;if(c.w*c.h>Nl)return false;let f=St(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),vt(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 rs(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>Nl)return false;let f=St(n.w,n.h),m=St(n.w,n.h);if(!f||!m||typeof f.ctx.getImageData!="function")return false;let b=Dt(t),h=f.ctx,p=u?VM(t):i?ll(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"?m0(h,b):h);let d=Pt(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,T=M%n.w,E=Math.floor(M/n.w),R=0;for(let P=0;P<4;P++)for(let A=0;A<8;A++)s(h,T+A/8+yh,E+P/4+yh)&&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 T=(g-3)/4,E=T%n.w+.5,R=Math.floor(T/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;vt(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 VM(t){return (Ee(t.pixelOffsetMode??0)?0:.5)-1/32}var yh=1/1024;function os(t){return t.gdiAntialias===true||At(t.ctx)?"canvas":t.antiAlias?"gdiplus-aa":"aliased"}function ao(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 lo(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 ao(n>>>0);let r=uo(t,e,n);if(r)return r;let o=t.objectTable.get(n&255),s=o&&o.kind==="plus-brush"?lo(o.color):null;return s===null?null:ao(s)}function zM(t,e,n,r,o,s,i){let a=Dt(t),u=null;try{u=g0(n,a,i==="aliased");}catch{u=null;}if(u){let c=_o(u,s);if(!c)return true;if(c.w*c.h<=Nl){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=xr(r,a,s);return l?rs(t,e,l,c=>{c.beginPath(),n(c),c.fill(o);},i,(c,f,m)=>c.isPointInPath(f,m,o)):true}function qM(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 JM(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]=Au(Math.round(f*a/32),l);}t[s+3]=l;}}return t}function KM(t,e,n,r){let{ctx:o}=t,s=St(e.w,e.h),i=St(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;vt(s.ctx,Et(a,e.w,e.h),0,0),vt(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 ZM(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 QM(t){let e=Math.round(t*6/255);return Math.abs(t-255*e/6)<=.51?e/6:t/255}function tE(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)*QM(e)*o)))]}function jn(t,e,n,r,o=1,s=false,i=1){let{ctx:a}=t,u=St(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=Pt(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)),KM(t,n,JM(l,c,r,f),r)}if(o===1&&s&&typeof a.getImageData=="function"){let c=Pt(a,n.x,n.y,n.w,n.h).data;qM(l,c,r),vt(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=Pt(a,n.x,n.y,n.w,n.h).data,f=ZM(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]=tE(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;vt(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 aE(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 Sn(t){return t.rasterPath??(t.rasterPath=new wt),t.rasterPath}function $l(t,e,n){let r=hr(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(),Sn(t).append(r);}function Th(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 co(t){let e=Sn(t),[n,r]=wn(t),o=e.figures.length;e.continueAt(n,r),e.figures.length!==o&&ke(t).moveTo(n/16,r/16);}function uE(t){return t.lineStyle??(t.lineStyle={pos:0}),t.lineStyle}function mo(t){t.lineStyle={pos:0};}function wn(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 sa(t,e,n,r,o){return ts(t,Math.min(e,r),Math.min(n,o),Math.max(e,r),Math.max(n,o))}function Mh(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 Rh=6;function ia(t,e,n=false,r=false){if((t.state.penStyle&15)!==Rh||!Re(e)||jt(t))return null;let o=yt(t),s=Rn(t),i=Pn(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 lE(t,e){if((t.state.penStyle&15)!==Rh||!Re(e)||jt(t))return false;let n=yt(t),r=Rn(t),o=Pn(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 aa(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 cE(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 mE(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=qb(t.state,o,e+8),u=jt(t)?Ut(t,s,i):{x:Bt(t,s),y:Nt(t,i)};r.fillStyle=a,r.fillRect(u.x,u.y,1,1);}return true}function fE(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),mo(t),t.curFix=void 0,s)){let i=jt(t)?Ut(t,o.curX,o.curY):{x:Bt(t,o.curX),y:Nt(t,o.curY)};ke(t).moveTo(i.x,i.y);let a=dt(t,o.curX,o.curY);Sn(t).moveTo(a[0],a[1]);}return true}function bE(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?Ut(t,i,a):{x:Bt(t,i),y:Nt(t,a)},c=dt(t,i,a);if(s)co(t),ke(t).lineTo(l.x,l.y),Sn(t).lineTo(c[0],c[1]);else {let f=u?Ut(t,o.curX,o.curY):{x:Bt(t,o.curX),y:Nt(t,o.curY)},m=wn(t);Jt(t,{build:b=>{b.beginPath(),b.moveTo(f.x,f.y),b.lineTo(l.x,l.y);},raster:()=>{let b=new wt;return b.moveTo(m[0],m[1]),b.lineTo(c[0],c[1]),b},fill:false,stroke:true,style:uE(t)});}o.curX=i,o.curY=a;}return true}function hE(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 pE(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 dE(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=hE(t,sa(t,a,u,l,c)),m=ia(t,f,true,t.state.arcDirection===2),b=m?aa(f,m):f,h=t.state.arcDirection===2;if(i||mo(t),jt(t)){let M=Ut(t,a,u),T=Ut(t,l,u),E=Ut(t,l,c),R=Ut(t,a,c),P=A=>{A.moveTo(M.x,M.y),A.lineTo(T.x,T.y),A.lineTo(E.x,E.y),A.lineTo(R.x,R.y),A.closePath();};return i?$l(t,b,h):Jt(t,{build:A=>{A.beginPath(),P(A);},raster:()=>hr(b,h),rectangle:true,fill:true,stroke:true,axisRect:Re(b)?{}:void 0}),true}let d=Bt(t,a),x=Nt(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)$l(t,b,h);else if(aE(t))Jt(t,{build:M=>{M.beginPath(),M.rect(d,x,y,g);},raster:()=>hr(xe(t)?pE(b):b,h),rectangle:true,fill:true,stroke:true,axisRect:{interior:xE(s,d,x,y,g,$n(t))}});else {kr(r,s),r.fillRect(d,x,y,g),Fr(r,s),r.lineWidth=1;let M=dr(s,$n(t));r.strokeRect(d+M,x+M,y,g);}}return true}function xE(t,e,n,r,o,s=1){if(dr(t,s)===0||pr(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 Eh=.5522847498307936;function Hl(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 T=a(g,M);t.moveTo(T.x,T.y);},p=(g,M)=>{let T=a(g,M);t.lineTo(T.x,T.y);},d=(g,M,T,E,R,P)=>{let A=a(g,M),I=a(T,E),S=a(R,P);t.bezierCurveTo(A.x,A.y,I.x,I.y,S.x,S.y);};if(m<=0||b<=0){h(u,c),p(l,c),p(l,f),p(u,f),t.closePath();return}let x=m*Eh,y=b*Eh;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 yE(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=sa(t,s,i,a,u),b=ia(t,m,false,f),h=b?aa(m,b):m,p=yt(t),d=b?Math.abs(l*p[0])*16:Mh(t,l,0),x=b?Math.abs(c*p[3])*16:Mh(t,c,1),y=(P,A,I)=>b&&A!==0?Math.floor(Math.min(P,A)*I/A):P,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)),T=b?h:zl(t,s,i,a,u,true);!b&&T.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(T.exx)/Math.abs(m.exx)),M=Math.floor(Math.min(x,Math.abs(m.eyy))*Math.abs(T.eyy)/Math.abs(m.eyy))),!b&&T.exx===m.exx&&T.eyy===m.eyy&&l!==0&&c!==0&&a!==s&&u!==i&&!jt(t)&&(T.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?P=>Hl(P,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)?P=>Hl(P,s,i,a,u,l/2,c/2,(A,I)=>Ut(t,A,I)):P=>Hl(P,Bt(t,s),Nt(t,i),Bt(t,a),Nt(t,u),qt(t,l)/2,oe(t,c)/2,null);if(b){let P=Math.abs((a-s)*p[0])*16,A=Math.abs((u-i)*p[3])*16;P>0&&A>0&&(h.cornerExact=[Math.min(d,P)*Math.abs(h.exx)/P,Math.min(x,A)*Math.abs(h.eyy)/A]);}let R=(P=h)=>ea(P,g,M,f,l===0||c===0);if(o){let P=T;l===0||c===0?$l(t,P,f):(Th(t,Ll(P,g,M,f),8),Sn(t).append(R(P)));}else mo(t),Jt(t,{build:P=>{P.beginPath(),E(P);},raster:()=>R(T),roundPen:true,fill:true,stroke:true});}return true}function zl(t,e,n,r,o,s=false){let i=s?sa(t,e,n,r,o):ts(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 gE(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=sa(t,s,i,a,u),f=ia(t,c,false,t.state.arcDirection===2),m=f?aa(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)?Yi(t,(s+a)/2,(i+u)/2,Math.abs(a-s)/2,Math.abs(u-i)/2):{cx:Bt(t,(s+a)/2),cy:Nt(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;Th(t,dn(h,l),6),Sn(t).append(es(h,l));}else mo(t),Jt(t,{build:h=>{h.beginPath(),h.ellipse(b.cx,b.cy,b.rx,b.ry,b.rotation,0,Math.PI*2);},raster:()=>es(f?m:zl(t,s,i,a,u,true),l),roundPen:true,fill:true,stroke:true});}return true}function ME(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)),T=i.arcDirection===2,E=e!==47&&y>0&&g>0&&cE(u,l,c,f,m,b,h,p),R=E?M+(T?2:-2)*Math.PI:Math.atan2((p-x)/(g||1),(h-d)/(y||1)),P=jt(t),A=ts(t,u,l,c,f);if(e!==55&&lE(t,A))return true;let I=ia(t,A,false,t.state.arcDirection===2),S=I?aa(A,I):A,w=I?{cx:(S.ax+S.exx/2)/16,cy:(S.ay+S.eyy/2)/16,rx:Math.abs(S.exx)/32,ry:Math.abs(S.eyy)/32,rotation:0}:P?Yi(t,d,x,y,g):{cx:Bt(t,d),cy:Nt(t,x),rx:Math.abs(qt(t,y)),ry:Math.abs(oe(t,g)),rotation:0},C=e===55,v=e===47||e===46,L=P?Ut(t,d+y*Math.cos(M),x+g*Math.sin(M)):{x:w.cx+w.rx*Math.cos(M),y:w.cy+w.ry*Math.sin(M)},_=N=>{if(e===47?N.moveTo(w.cx,w.cy):!C&&a&&N.moveTo(L.x,L.y),C){if(!a){let q=wn(t);N.moveTo(q[0]/16,q[1]/16);}N.lineTo(L.x,L.y);}N.ellipse(w.cx,w.cy,w.rx,w.ry,w.rotation,M,R,!T),v&&N.closePath();},U=C?"arcto":e===47?"pie":e===46?"chord":"arc",F=(N,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 [N.ax+N.exx*rt+N.eyx*H,N.ay+N.exy*rt+N.eyy*H]},O=yt(t),X=O[0]*O[3]-O[1]*O[2]<0,k=O[1]===0&&O[2]===0,W=(N=false)=>{let q=I?S:N&&v?zl(t,u,l,c,f):A,Q=q.exx*q.eyy-q.exy*q.eyx<0,K=k&&Re(q)?{x:O[0]<0,y:O[3]<0}:void 0;return {box:q,mirror:K,clockwise:K?T:T!==(X!==Q),s:F(q,m,b),e:E?F(q,m,b):F(q,h,p),from:wn(t)}};if(a){C&&co(t),_(ke(t));let N=W();io(N.box,N.s,N.e,N.clockwise,U,N.from,Sn(t),N.mirror),v&&Sn(t).closeFigure();}else mo(t),o.beginPath(),Jt(t,{build:N=>{N.beginPath(),_(N);},raster:()=>{let N=W(true);return io(N.box,N.s,N.e,N.clockwise,U,N.from,void 0,N.mirror).path},fill:v,stroke:true});if(C){let N=W(),q=io(N.box,N.s,N.e,N.clockwise,"arc",void 0,void 0,N.mirror).end,Q=Math.floor(q[0]/16),K=Math.floor(q[1]/16),V=Ze(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 EE(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=ts(t,i-u,a-u,i+u,a+u),M;if(Re(g))M=af(g,l,c);else {M=[...dt(t,i+u*Math.cos(f),a-u*Math.sin(f))];for(let C of ou(l,c)){let v=sf(i,a,u,u,C.from,C.to);for(let L=0;L<6;L+=2)M.push(...dt(t,v[L],v[L+1]));}}let T=[M[M.length-2],M[M.length-1]],E=(C,v)=>{C.continueAt(v[0],v[1]),C.addBeziers(M,false);},R=Yi(t,i,a,u,u),P=Ut(t,b,h),A=C=>{if(C.lineTo(P.x,P.y),u===0)return;let v=Math.min(Math.abs(m-f),Math.PI*2*(y+1));C.ellipse(R.cx,R.cy,R.rx,R.ry,R.rotation,-f,x?-f+v:-f-v,!x);};if(s)co(t),A(ke(t)),E(Sn(t),wn(t));else {mo(t);let C=wn(t),v=Ut(t,o.curX,o.curY);Jt(t,{build:L=>{L.beginPath(),L.moveTo(v.x,v.y),A(L);},raster:()=>{let L=new wt;return E(L,C),L},fill:false,stroke:true});}let I=Math.floor(T[0]/16),S=Math.floor(T[1]/16),w=Ze(yt(t));return o.curX=Math.round(w?w[0]*I+w[2]*S+w[4]:p),o.curY=Math.round(w?w[1]*I+w[3]*S+w[5]:d),t.curFix=s?{x:T[0],y:T[1],lx:o.curX,ly:o.curY}:{x:I*16,y:S*16,lx:o.curX,ly:o.curY},true}function Ph(t,e,n,r){switch(e){case 15:return mE(t,n,r);case 27:return fE(t,n,r);case 54:return bE(t,n,r);case 43:return dE(t,n,r);case 44:return yE(t,n,r);case 42:return gE(t,n,r);case 41:return EE(t,n,r);case 45:case 55:case 46:case 47:return ME(t,e,n,r);default:return false}}var Ah={};var Ih={};var Dh=1,Uh=2,_h=24,TE={flags:0,illuminant:0,redGamma:1e4,greenGamma:1e4,blueGamma:1e4,referenceBlack:0,referenceWhite:1e4,contrast:0,brightness:0,colorfulness:0,redGreenTint:0},Sh=new Map;function Fh(t){let e=Sh.get(t);if(e===void 0){let n=Ih[t];if(e=null,n){let r=Uint8Array.from(atob(n),s=>s.charCodeAt(0)),o=Za(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;}}Sh.set(t,e);}return e}var RE={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 kh(t){return Fh(t.illuminant)!==null}var yr=Array.from({length:32},(t,e)=>Math.round(e*255/31));function PE(t){let e=Math.round(t*31/255);return yr[e]===t?255*e/31:t}function ql(t){let e=LE(t)*255,n=Math.min(30,Math.floor(e*31/255));for(;n<30&&e>=yr[n+1];)n++;for(;n>0&&e<yr[n];)n--;return n+Math.min(1,Math.max(0,(e-yr[n])/(yr[n+1]-yr[n])))}function AE(t,e,n,r){let o=ql(e),s=ql(n),i=ql(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 Oh(t){return !!t&&!kh(t)&&t.colorfulness===0&&t.redGreenTint===0}function Bh(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&&!kh(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 IE=.0148885,SE=.95625,wE=1/100,CE=-Math.PI/3,Qe=[[.4123908,.3575843,.1804808],[.212639,.7151687,.0721923],[.0193308,.1191948,.9505322]],Cn=vE(Qe),is=Qe.map(t=>t[0]+t[1]+t[2]),Nh=is[0]+15*is[1]+3*is[2],wh=4*is[0]/Nh,Ch=9*is[1]/Nh;function vE(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 LE=t=>t<0?0:t>1?1:t,gr=t=>t<0?0:t>255?255:t,vh=t=>Math.floor(t+.5+1e-7);function DE(t,e,n,r,o){let s=Qe[0][0]*t+Qe[0][1]*e+Qe[0][2]*n,i=Qe[1][0]*t+Qe[1][1]*e+Qe[1][2]*n,a=Qe[2][0]*t+Qe[2][1]*e+Qe[2][2]*n,u=s+15*i+3*a;if(u<=1e-9||i<=1e-9)return [gr(t),gr(e),gr(n)];let l=4*s/u-wh,c=9*i/u-Ch,f=Math.cos(o)*r,m=Math.sin(o)*r,b=Math.max(0,wh+l*f-c*m),h=Math.max(1e-6,Ch+l*m+c*f),p=i*9*b/(4*h),d=i*(12-3*b-20*h)/(4*h),x=[Cn[0][0]*p+Cn[0][1]*i+Cn[0][2]*d,Cn[1][0]*p+Cn[1][1]*i+Cn[1][2]*d,Cn[2][0]*p+Cn[2][1]*i+Cn[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 Lh=new Map;function UE(t){if(t.illuminant!==0&&t.illuminant!==6)return null;let e=`${t.colorfulness},${t.redGreenTint}`,n=Lh.get(e);if(n===void 0){let r=Ah[e];if(n=null,r){n=new Int8Array(32768*3);for(let o of r)n[o>>1]=o&1?1:-1;}Lh.set(e,n);}return n}function Jl(t){let e=Math.round(t*31/255);return yr[e]===t?e:-1}function _E(t){let e=Jl(t[0]),n=Jl(t[1]),r=Jl(t[2]);return e<0||n<0||r<0?-1:(e*32+n)*32+r}function FE(t,e){let n=Fh(t.illuminant),r=RE[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(IE*t.contrast),u=SE*t.brightness,l=t.colorfulness!==0||t.redGreenTint!==0,c=1+wE*t.colorfulness,f=CE*t.redGreenTint/100,m=(t.flags&Uh)!==0,b=(t.flags&Dh)!==0,h=l&&e?.chromaTies!==false?UE(t):null,p=(d,x)=>{let y=255*(gr(d)/255)**o[x];return y=(y-s)/i*255,y=y*a+u,m&&(y=255*Math.log2(1+7*gr(y)/255)/3),b&&(y=255-gr(y)),vh(gr(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?_E(x):-1;if(x=x.map(PE),r){let[g,M,T]=x;x=r.map(E=>E[0]*g+E[1]*M+E[2]*T);}x=DE(x[0],x[1],x[2],c,f),x=x.map(vh),h&&y>=0&&(x=x.map((g,M)=>g+h[y*3+M]));}else if(n){let y=AE(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 Gh(t){let n={...TE,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 Zl(t,e){if(!e||Kl(e))return;let n=FE(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 kE=[[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]],OE=66,Wh=65;function BE(t){return t<63?t%16:t<=64?14:15}function NE(t){return t<63?t%16:t===63?14:15}var ua=(t,e)=>(t%e+e)%e;function Ql(t,e){let n=ua(t-e-2,65);return n<63?n:n+1}function tc(t,e){return ua(t-e-2,Wh)}function la(t,e,n,r){return kE[NE(ua(e+r,Wh))][BE(ua(t+n,OE))]}function GE(t){return Math.round(t*255/31)}function fo(t,e){let n=Math.floor((31*t+e)/255);return GE(n<0?0:n>31?31:n)}function WE(t,e,n){return n===t?16777216|n>>2<<8|e>>2:n|e<<8|t<<16}function ca(t,e,n){if(e<=0||n<=0)return "replicate";let r=e*n;if(r<=2304)return "replicate";let o=b=>WE(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 ec=1,Hh=2;var Er=4;function us(t,e,n){let r=Math.floor((2*t+1)*e/(2*n));return Math.max(0,Math.min(e-1,r))}function Xh(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=us(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 Vh(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===ec||a===Hh,b=Xh(Math.round(Math.min(e,e+r)),Math.round(Math.abs(r)),u,c,m),h=Xh(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 T=b[M]??[],E=a===ec?16777215:0,R=true;for(let A of g)for(let I of T){let S=x(I,A);a===ec?E&=S:a===Hh?E|=S:R&&(E=S),R=false;}let P=(y*u+M)*4;p[P]=E>>16&255,p[P+1]=E>>8&255,p[P+2]=E&255,p[P+3]=255;}}return {width:u,height:l,data:p}}var bo=65536;function rc(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 zh(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(rc(a,e,n)),1]]);return r&&o.reverse(),o}let i=Math.ceil(e*bo/n);for(let a=0;a<n;a++){let u=a*i,l=(a+1)*i,c=[];for(let f=Math.floor(u/bo);f*bo<l&&f<e;f++){let m=Math.min(l,(f+1)*bo)-Math.max(u,f*bo);m>0&&c.push([s(f),m]);}o.push(c);}return r&&o.reverse(),o}var HE=13;function as(t,e,n){if(e>=t)return zh(0,t,e,n);let r=2**HE,o=bo/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 XE(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 qh(t,e){return YE(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 YE(t,e){let n=e/t,r=Math.ceil(n)-1,o=[],s=0;for(let u=0;u<=r;u++){let l=XE(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 Mr(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=la(r.startX,r.startY,f,l),b=(u*e+c)*3;t[b]=fo(t[b],m),t[b+1]=fo(t[b+1],m),t[b+2]=fo(t[b+2],m);}}}function Yh(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,T=o(p+x,d),E=o(p,d+y),R=o(p+2*x,d),P=o(p,d+2*y);for(let A=0;A<3;A++)t[M+A]=12*t[M+A]+r[T+A]+r[E+A]+r[R+A]+r[P+A]+8>>4;}}}function $E(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 jE(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 $h(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 VE(t,e,n,r,o,s,i){let a=as(e,r,s),u=as(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 zE(t,e,n,r,o,s,i){let a=o<n,u=a?as(n,o,i):as(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 Jh={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 nc(t,e){if(e/t===2){let r=Jh[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 qh(t,e).map(r=>r.map(([o,s])=>[o,Math.round(s*8192)]))}function qE(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=nc(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 jh(t,e){let n=Array.from({length:e},(s,i)=>rc(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:Jh[r.get(s)][i]}})}function JE(t,e,n,r){return t>0&&e>0&&n>=t&&r>=e&&(n>t||r>e)}function KE(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),Mr(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),Mr(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 ZE(t,e,n,r,o,s){if(r===e||o===n)return qE(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 T=(E,R,P)=>s[(Math.max(0,Math.min(n,R))*e+Math.max(0,Math.min(e-1,E)))*3+P];for(let E=0;E<n;E++)for(let R=0;R<e;R++)for(let P=0;P<3;P++){let A=T(R,E,P),I=T(R-1,E,P)+T(R+1,E,P)+T(R,E-1,P)+T(R,E+1,P);x[(E*e+R)*3+P]=i(A+Math.floor((4*A-I)/8));}}else $E(x,e,n);let y=nc(e,r),g=nc(n,o),M=new Int32Array(r*n*3);for(let T=0;T<n;T++)for(let E=0;E<r;E++)for(let R=0;R<3;R++){let P=0;for(let[A,I]of y[E])P+=I*x[(T*e+A)*3+R];M[(T*r+E)*3+R]=Math.floor((P+4096)/8192);}for(let T=0;T<o;T++)for(let E=0;E<r;E++)for(let R=0;R<3;R++){let P=0;for(let[A,I]of g[T])P+=I*M[(A*r+E)*3+R];u[(T*r+E)*3+R]=i(Math.floor((P+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),T=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-T)/8));}let h=jh(e,r),p=jh(n,o),d=new Int32Array(e*3);for(let x=0;x<o;x++){let y=p[x].k+1,[g,M,T,E]=p[x].weights,R=(y-1)*e*3,P=y*e*3,A=(y+1)*e*3;for(let I=0;I<e*3;I++)d[I]=Math.floor((g*c[R+I]+M*c[P+I]+T*c[A+I]+E/2)/E);for(let I=0;I<r;I++){let S=h[I].k,[w,C,v,L]=h[I].weights,_=Math.max(0,S-1),U=Math.min(e-1,S+1);for(let F=0;F<3;F++)u[(x*r+I)*3+F]=Math.floor((w*d[_*3+F]+C*d[S*3+F]+v*d[U*3+F]+L/2)/L);}}return u}function QE(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&&ca(t,e,n)==="filter"?"reduced":r*o<e*n?a?"despeckled":"reduced":"nearest"}function Kh(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 T=new Int32Array(h*p*3);for(let H=0;H<p;H++){let Y=x+H;for(let G=0;G<h;G++){let B=d+G;if(Y<0||Y>=t.height||B<0||B>=t.width)continue;let j=(Y*t.width+B)*4,tt=(H*h+G)*3;T[tt]=t.data[j],T[tt+1]=t.data[j+1],T[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||jE(T,h,p,E),E&&m>=2*h?(T=$h(T,h,p,true),p=1):R&&b>=2*p&&(T=$h(T,h,p,false),h=1));let P=m>=h&&b>=p&&(m>h||b>p),A=m<h&&b<p,I=m>h&&b<p||m<h&&b>p,S=!!c&&!!a&&!u,w=I&&(!a||u||S),C=w?QE(T,h,p,m,b):"nearest",v=w&&C==="nearest"&&(m<h&&m*2>h||b<p&&b*2>p),L=w&&C!=="nearest",_=h*p<=2304||h*p>16384,U=m<h&&b===p||b<p&&m===h,F=(A||U)&&_&&!l&&!(m<h&&3*m+2<=2*h)&&!(b<p&&3*b+2<=2*p)&&(h*p<=2304||ca(T,h,p)==="replicate");if(U&&(!a||u||S)){F&&Yh(T,h,p);let H=zE(T,h,p,m,b,y,g);S?(Mr(H,m,b,c),a(H),f&&f(H)):a&&a(H);for(let Y=0,G=0;Y<m*b;Y++,G+=3)M[Y*4]=H[G],M[Y*4+1]=H[G+1],M[Y*4+2]=H[G+2],M[Y*4+3]=255;return {width:m,height:b,data:M}}if(P&&JE(h,p,m,b)&&(!a||u||S)&&ca(T,h,p)==="filter"){let H,Y=T;S&&(m===h||b===p?b>p?(H=new Int32Array((p+1)*h*3),H.set(T),H.set(T.subarray((p-1)*h*3),p*h*3),Mr(H,h,p+1,c,false,false,void 0,Int32Array.from({length:p+1},(B,j)=>g?b-1-j:j)),a(H),Y=H.subarray(0,h*p*3)):(Y=T.slice(),Mr(Y,h,p,c,false,false,void 0,Int32Array.from({length:p},(B,j)=>g?b-1-j:j)),a(Y)):(H=KE(T,h,p,m,b,c,g),a(H)));let G=ZE(Y,h,p,m,b,H);if(y||g){let B=G.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;G.set(B.subarray(lt,lt+3),(j*m+tt)*3);}}a&&u&&a(G),f&&S&&f(G);for(let B=0,j=0;B<m*b;B++,j+=3)M[B*4]=G[j],M[B*4+1]=G[j+1],M[B*4+2]=G[j+2],M[B*4+3]=255;return {width:m,height:b,data:M}}((P||v||C==="despeckled")&&_||A&&F)&&!l&&!E&&!R&&Yh(T,h,p);let O=S&&(m>=h&&b>=p||L&&m*b>=h*p),X=O&&L&&m<h&&b>p;if(X){let H=new Int32Array((p+1)*h*3);H.set(T),H.copyWithin(p*h*3,(p-1)*h*3,p*h*3),T=H;}O&&Mr(T,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&&(!S||O)&&a(T);let k=L?Math.min(h,m):m,W=L?Math.min(p,b):b,N=L?(H,Y,G)=>as(H,Y,G):(H,Y,G)=>zh(0,H,Y,G),q=L&&m>h,Q=L&&b>p,K=N(h,k,y&&!q),V=N(p,W,g&&!Q);if(v){let H=(Y,G,B,j)=>{for(let tt=0;tt<B;tt++){let lt=j?B-1-tt:tt,ct=B<G?Math.floor(((lt+1)*2*G-B)/(2*B)):rc(lt,G,B);Y[tt]=[[Math.max(0,Math.min(G-1,ct)),1]];}};H(K,h,m,y),H(V,p,b,g);}else if(I&&!L){let H=(Y,G,B,j)=>{if(!(B<=G))for(let tt=0;tt<B;tt++){let lt=Math.max(0,Math.min(G-1,(tt+.5)*G/B-.5)),ct=Math.floor(lt),ht=lt-ct,ft=at=>j?G-1-at:at;Y[tt]=[[ft(ct),1-ht],[ft(Math.min(G-1,ct+1)),ht]];}};H(K,h,m,y),H(V,p,b,g);}let rt=L?new Float64Array(k*W*3):new Int32Array(m*b*3);A&&(rt=VE(T,h,p,m,b,y,g));for(let H=0;!A&&H<W;H++){let Y=V[H];for(let G=0;G<k;G++){let B=K[G],j=0,tt=0,lt=0,ct=0;for(let[at,mt]of Y)for(let[Rt,Ae]of B){let Kt=Ae*mt;ct+=Kt;let Wt=(at*h+Rt)*3;j+=T[Wt]*Kt,tt+=T[Wt+1]*Kt,lt+=T[Wt+2]*Kt;}let ht=(H*k+G)*3,ft=at=>L?at/ct:I?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(L){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]+=T[(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 G=rt;rt=new Int32Array(m*b*3);let B=(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]]}):qh(lt,ct),j=B(k,m),tt=B(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+=G[(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(I&&!L&&!v){let H=rt.slice(),Y=(G,B,j)=>H[(Math.max(0,Math.min(b-1,B))*m+Math.max(0,Math.min(m-1,G)))*3+j];for(let G=0;G<b;G++)for(let B=0;B<m;B++)for(let j=0;j<3;j++){let tt=Y(B,G,j),lt=m<h?Y(B-1,G,j)+Y(B+1,G,j):Y(B,G-1,j)+Y(B,G+1,j);rt[(G*m+B)*3+j]=Math.max(0,Math.min(255,tt+Math.floor((2*tt-lt)/4)));}}if(S&&!O){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=v&&m*b>h*p,G=Y?H(m,h,m,true):void 0,B=Y?H(b,p,b,false):void 0;G&&y&&(G=G.slice().reverse()),B&&g&&b>p&&(B=B.slice().reverse().map(j=>b-1-j)),Mr(rt,m,b,c,false,false,G,B),a(rt);}a&&u&&a(rt),f&&S&&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 ma(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)=>Jn(e,Math.floor(r.left+(i+.5)/o),Math.floor(r.top+(a+.5)/s),n.brushOrgX,n.brushOrgY)}function np(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===Er?Kh(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:Ql(Math.min(n.dx,n.dx+n.dw),i),startY:tc(Math.min(n.dy,n.dy+n.dh),a)}:void 0,e.curves):Vh(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=St(c.width,c.height);f&&(vt(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 ic(t,e,n=false){if(!e.source)return null;let r=Le(t.view,e.source.bmi,e.source.bits,e.source.cbBits,e.source.palColors?ze(t.state):null);if(!r)return null;let o=t.state.colorAdjustment;e.stretch&&t.state.stretchBltMode===Er&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=!n&&!!o);let s=e.stretch&&t.state.stretchBltMode===Er&&o,i=Oh(o),a=s&&!i?Gh(o):void 0,u=s?(f=>Zl(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=>Zl(f,l):void 0},req:{...e,sy:c}}}function oc(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 tT(t,e,n,r,o){let{ctx:s}=t,i=th(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=St(i.w,i.h);if(!l)return;let c=null;if(o){let p=ic(t,e);if(!p)return;np(l.ctx,p.decoded,p.req,i.x,i.y,t.state.stretchBltMode,t.state.brushOrgX,t.state.brushOrgY),c=Pt(l.ctx,0,0,i.w,i.h);}let f=Pt(s,i.x,i.y,i.w,i.h),m=ma(t,u);Qb(f,c,m,n,i.x,i.y);un(n).usesD?ji():null;vt(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 sc(t,e,n){return Math.sign(t!==0?t:e!==0?e:n)}function Qh(t,e,n,r){return sc(t,n,r)>=0&&sc(t-e,n,r)<0}function tp(t,e,n,r){let o=Math.floor(t/e);return t===o*e&&sc(0,n,r)<0?o-1:o}function rp(t,e,n,r,o,s,i,a,u,l,c,f,m){let{ctx:b}=t,h=Ml(s);if(h===170)return;let p=un(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=ma(t,d),y=null,g=a,M=u,T;if(p.usesS){let R=ic(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:P,adjustAfterSampling:A,curves:I}=R.decoded,S=Ql(0,t.state.brushOrgX),w=tc(0,t.state.brushOrgY),C=new Int32Array(3);T=(v,L,_)=>{if(C[0]=v>>16&255,C[1]=v>>8&255,C[2]=v&255,!A){let U=la(S,w,L,_);for(let F=0;F<3;F++)C[F]=fo(C[F],U);}return P(C),I?.(C),C[0]<<16|C[1]<<8|C[2]};}g=R.req.sx,M=R.req.sy;}let E=(R,P)=>{if(!y)return 0;let A=l<0?g-1-R:g+R,I=c<0?M-1-P:M+P;A=Math.max(0,Math.min(y.width-1,A)),I=Math.max(0,Math.min(y.height-1,I));let S=(I*y.width+A)*4;return y.data[S]<<16|y.data[S+1]<<8|y.data[S+2]};ac(t,dt(t,e,n),dt(t,e+r,n),dt(t,e,n+o),l,c,(R,P,A,I,S)=>{let w=p.usesS?E(R,P):0;T&&p.usesS&&(w=T(w,A,I));let C=typeof x=="function"?x(A,I):x;return Vt(h,C,w,S)});}function ac(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 T=Math.abs(o)||1,E=Math.abs(s)||1,R=h*m,P=-h*f,A=-h*c,I=h*l;so(t.ctx,{x,y,w:g-x,h:M-y},(S,w,C)=>{let v=S*16-a,L=w*16-u,_=h*(v*m-L*f),U=h*(l*L-c*v);if(!Qh(_,b,R,P)||!Qh(U,b,A,I))return -1;let F=Math.min(T-1,tp(_*T,b,R,P)),O=Math.min(E-1,tp(U*E,b,A,I));return i(F,O,S,w,C)});}function eT(t,e){let n=Rn(t),r=Pn(t);return {...e,dx:e.dw<0?e.dx+n:e.dx,dy:e.dh<0?e.dy+r:e.dy}}function op(t,e,n,r,o,s,i){uc(t,{plan:$i(13369376),dx:e,dy:n,dw:r,dh:o,source:s,...i,dibOrigin:"top-left",stretch:true});}function uc(t,e){let{ctx:n}=t,r=eT(t,e),o=r.plan;switch(o.kind){case "noop":return;case "solid":oc(n,o.color==="black"?"#000000":"#ffffff","source-over",r);return;case "invert-dest":oc(n,"#ffffff","difference",r);return;case "copy":{let s=ic(t,r);s&&np(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"&&oc(n,t.state.brushColor,"source-over",r);return}tT(t,r,o.index,o.operands.usesP,o.operands.usesS);}}}function fa(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 ep(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,T=r>=100?fa(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,P=E?1:d,A={sx:R*f+(E?0:p*m+x),sy:P*m+(E?0:h*f+y),sw:R*g,sh:P*M};return jt(t)?(rp(t,i,a,u,l,c,T,A.sx,A.sy,A.sw,A.sh,"top-left",o),true):(uc(t,{plan:$i(c),dx:Bt(t,i),dy:Nt(t,a),dw:qt(t,u),dh:oe(t,l),source:T,...A,dibOrigin:"top-left",stretch:o}),true)}function nT(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=fa(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)?(rp(t,s,i,a,u,l,c,f,m,b,h,"bottom-left",true),true):(uc(t,{plan:$i(l),dx:Bt(t,s),dy:Nt(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 sp(t,e,n,r,o){switch(e){case 76:return ep(t,n,r,o,false);case 77:return ep(t,n,r,o,true);case 81:return nT(t,n,r,o);default:return false}}function ba(t,e,n,r,o,s,i,a=false){return !n||!r||!o||!s?null:Le(t.view,e+n,e+o,s,i===1?ze(t.state):null,a)}function ip(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 ha(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 ho(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 pa(t,e,n,r,o,s,i,a,u){let l=Bt(t,e),c=Nt(t,n),f=qt(t,r),m=oe(t,o);f<0&&(l+=Rn(t)),m<0&&(c+=Pn(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),T=Math.min(t.canvasW,x+b),E=Math.min(t.canvasH,y+h);if(T<=g||E<=M)return null;let R=Math.min(s,s+a),P=Math.min(i,i+u),A=new Int32Array(T-g),I=new Int32Array(E-M),S=f<0||m<0,w=(C,v,L)=>S?Math.min(v-1,Math.floor(C*v/L)):us(C,v,L);for(let C=g;C<T;C++){let v=w(C-x,p,b);A[C-g]=a<0!=f<0?R+p-1-v:R+v;}for(let C=M;C<E;C++){let v=w(C-y,d,h);I[C-M]=u<0!=m<0?P+d-1-v:P+v;}return {box:{x:g,y:M,w:T-g,h:E-M},col:A,row:I}}function fs(t,e,n){let{ctx:r}=t;if(typeof r.getImageData=="function"&&so(r,e,n))return;let o=qe(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;}Je(r,e,o,Et(s,e.w,e.h));}function Tr(t){return Math.round(t/255)}function rT(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=Tr(s*n),m=Tr(i*n),b=Tr(a*n),h=Tr(o*n));let p=255-h,d=b+Tr(c*p),x=m+Tr(l*p)+(d>>8);return (f+Tr(u*p)+(x>>8)&255)<<16|(x&255)<<8|d&255}function oT(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=ba(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=ha(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),c=pa(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(!Te(t.ctx));fs(t,f,(h,p,d)=>rT(ho(u,m[h-f.x],b[p-f.y]),d,i,a));}function iT(t,e,n,r){let{view:o}=t;if(r<108)return;let s=Zo(o.getUint32(n+32,true),ze(t.state)),i=ba(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=ha(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),u=pa(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;fs(t,l,(m,b)=>{let h=ho(i,c[m-l.x],f[b-l.y])&16777215;return h===s?-1:h});}function aT(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=ba(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=ip(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=ha(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),u,l),p=pa(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((un(i).usesD||f!==null&&un(a).usesD)&&!Te(t.ctx)){return}let M=ma(t,Qt(t.state)),T=Math.min(h.sx,h.sx+h.sw),E=Math.min(h.sy,h.sy+h.sh);fs(t,d,(R,P,A)=>{let I=x[R-d.x],S=y[P-d.y],w=i;if(f){let L=m+I-T,_=b+S-E;w=(L>=0&&_>=0&&L<f.width&&_<f.height?f.bits[_*f.width+L]:0)?i:a;}let C=c?ho(c,I,S)&16777215:0,v=typeof M=="function"?M(R,P):M;return Vt(w,v,C,A)});}function uT(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=ba(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=ip(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=ha(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,P=f+M;if(R<0||P<0||R>=l.width||P>=l.height||!l.bits[P*l.width+R])return -1}let T=m.sw<0?m.sx-1-x:m.sx+x,E=m.sh<0?m.sy-1-y:m.sy+y;return ho(u,T,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===Er&&x>0&&y>0){op(t,Math.round(h[0]/16),Math.round(h[1]/16),p[0]<h[0]?-x:x,d[1]<h[1]?-y:y,fa(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),T=Math.abs(m.sw),E=Math.abs(m.sh),R=Math.max(0,g),P=Math.max(0,M),A=Math.min(t.canvasW,g+x),I=Math.min(t.canvasH,M+y);if(A<=R||I<=P||T===0||E===0)return;let S=p[0]<h[0],w=d[1]<h[1];fs(t,{x:R,y:P,w:A-R,h:I-P},(C,v)=>{let L=us(C-g,T,x),_=us(v-M,E,y);return b(S?T-1-L:L,w?E-1-_:_,L,_)});return}t.state.stretchBltMode===Er&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=false),ac(t,h,p,d,m.sw,m.sh,(x,y)=>b(x,y));}function lT(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),Le(c,0,r,s,i===1?ze(t.state):null)}function cT(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=lT(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=pa(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;fs(t,y,(T,E)=>{let R=g[T-y.x],P=M[E-y.y],A=i+u-1-P,I=h?p-1-A-f:m-1-(A-f);if(I<0||I>=d.height)return -1;let S=s+R;return S<0||S>=d.width?-1:ho(d,S,I)&16777215});}function ap(t,e,n,r,o){switch(e){case 114:return oT(t,n,r,o),true;case 116:return iT(t,n,r,o),true;case 78:return aT(t,n,r,o),true;case 79:return uT(t,n,r,o),true;case 80:return cT(t,n,r,o),true;default:return false}}var up="\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",lp={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 cp={};var mT=[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 hc(t,e){return e===2?t:t>=128&&t<=159?mT[t-128]:t}var fT={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"},bT={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"},mp={874:"windows-874",932:"shift_jis",936:"gbk",949:"euc-kr",950:"big5"};function hT(t,e){return {codes:t.map(n=>n<128?n:e.charCodeAt(n-128)),byteLengths:t.map(()=>1)}}function Vn(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 mp)))return hT(t,(r!==void 0?lp[r]:void 0)??up);if(e===130){let i=[],a=[];for(let u=0;u<t.length;u++){let l=t[u],c=cp[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?mp[r]:(e===0||e===1)&&o!==void 0?bT[o]??"windows-1252":fT[e]??"windows-1252";if(s==="windows-1252")return {codes:t.map(i=>hc(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=>hc(i,e)),byteLengths:t.map(()=>1)}}}var pT=[0,0,.4096065,.4875311,.5515784,.6070649,.656426,.7013281,.7426686,.7811829,.8173296,.8514569,.8838279,.9147507,.9443338,.9726402],dT=[0,0,.0556662,.0852493,.1161453,.1485431,.1826704,.2188171,.2572957,.2986719,.343574,.3929351,.4483443,.5124689,.5903349,.6957428],fp=[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],xT=[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 bs(t,e,n,r){return n<=1?e:n>=16?t:r?xT[Math.floor((n*fp[t]+(16-n)*fp[e])/16)]:e+Math.floor((t-e)*(t>e?pT[n]:dT[n]))}var po=2,xo=4,xp=16,ya=4096,hs=8192,yT=[255,255,240,233,225,217,208,199,189,178,167,154,140,124,104,77,0];function yp(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 gp(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 pc(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 bp(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 Mp(t){return t>=128&&t<=159}function hp(t,e){return !t.glyphIndices&&!(t.options&ya)&&Mp(t.codes[e])}function Ep(t,e){let n=e.codes.length,r=e.codes.map(_=>e.glyphIndices?_:t.glyphIndex(_)),o=!!e.matrix&&Math.abs(e.matrix[0])>1e-9&&Math.abs(e.matrix[1])>1e-9&&!!t.rotatedLinearAdvance,s=[];for(let _=0;_<n;_++)s.push(hp(e,_)&&!e.dx?0:e.dx&&_<e.dx.length?e.dx[_]:e.matrix?o?t.rotatedLinearAdvance(r[_]):t.rotatedAdvance(r[_],!!e.matrix&&e.matrix[0]<0):t.advance(r[_]));!e.dx&&e.textJustification&&!e.glyphIndices&&(s=Us(s,e.codes,e.textJustification.extra,e.textJustification.count));let i=[];for(let _=0;_<n;_++)i.push(e.dy&&_<e.dy.length?e.dy[_]:0);let a=0,u=0;for(let _=0;_<n;_++)a+=s[_],u+=i[_];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?_=>Math.round(_*16)/16:_=>_,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 _=U=>{let F=Math.round(U*a*16);return (y===6?-Math.trunc(F/2):-F)/16};d=_(c),x=_(f);}let g=(_,U)=>o?{x:e.x+d+h(c*(_-p))+h(m*U),y:e.y+x+h(f*(_-p))+h(b*U)}:{x:e.x+c*_+m*U,y:e.y+f*_+b*U},M=e.textAlign&24,T=!!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:T?t.rotatedAscent??t.ascent:t.ascent,P=E?E.descent:T?t.rotatedDescent??t.descent:t.descent,A=M===24?0:M===8?-P:R,I=[],S=[],w=e.glyphMatrix??l,C=w?[w[0],w[1],w[2],w[3]]:void 0,v=p,L=A;for(let _=0;_<n;_++){let U=g(v,L),F=!!t.fractionalOrigins,O=F?Math.floor(U.x):Math.round(U.x),X=F?t.fractionalOrigins==="xy"?Math.round((U.x-O)*4)*16:t.fractionalOrigins==="x"?Math.round((U.x-O)*6)*(64/6):Math.round((U.x-O)*64):0,k=t.fractionalOrigins==="xy"?Math.floor(U.y):Math.round(U.y),W=t.fractionalOrigins==="xy"?Math.round((U.y-k)*4)*16:0;if(S.push({x:O+X/64,y:k+W/64,along:v,down:L}),!hp(e,_)){let N=t.glyph(r[_],C,X,W);N.bitmap&&I.push({x:O+N.bitmap.left,y:k-N.bitmap.top,bitmap:N.bitmap});}v+=s[_],L+=i[_];}return {glyphs:r,total:a,totalY:u,startAlong:p,baseDown:A,hAlign:y,at:g,placed:I,origins:S}}function xc(t,e,n,r){let{total:s,totalY:i,startAlong:a,baseDown:u,at:l,placed:c,hAlign:m}=Ep(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&xo&&n.rect?n.rect:null;if(n.options&po&&n.rect&&pc(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)];bp(t,E,n.bkColor,y);}else {let E=Math.round(n.x+a),R=Math.round(n.y+u),P=Math.min(E,E+Math.round(s)),A=Math.max(E,E+Math.round(s));pc(t,{left:P,top:R-e.ascent,right:A,bottom:R+e.descent},n.bkColor,y);}let g=n.bkMode===2;if(!g&&n.options&po&&n.rect&&c.length>0){let E,R,P,A;if(b){let I=[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(...I.map(S=>S.x)),P=Math.max(...I.map(S=>S.x)),R=Math.min(...I.map(S=>S.y)),A=Math.max(...I.map(S=>S.y));}else {let I=Math.round(n.x+a),S=Math.round(n.y+u);E=Math.min(I,I+Math.round(s)),P=Math.max(I,I+Math.round(s)),R=S-e.ascent,A=S+e.descent;}for(let I of c)E=Math.min(E,I.x),R=Math.min(R,I.y),P=Math.max(P,I.x+I.bitmap.width),A=Math.max(A,I.y+I.bitmap.height);g=n.rect.left<=E&&n.rect.top<=R&&n.rect.right>=P&&n.rect.bottom>=A;}if(pp(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?dc(e.exactDecorations,n,n.x+a,n.y+u,s):null,P=0;for(let[A,I,S]of E){let w=R?.[P++];if(b){let C=[l(a,u-A),l(a+s,u-A),l(a+s,u-A+I),l(a,u-A+I)];bp(t,C,n.textColor,y);}else {let C=Math.round(n.x+a)+S,v=Math.round(n.y+u)-A,L=w?Math.round(w.left):Math.min(C,C+Math.round(s)),_=w?Math.round(w.right):Math.max(C,C+Math.round(s));pc(t,{left:L,top:v,right:_,bottom:v+I},n.textColor,y);}}}let M=m===6?0:m===2?-s:s,T=m===6?0:i;return {dx:h*M+d*T,dy:p*M+x*T}}function pp(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 T of e)i=Math.min(i,T.x),a=Math.min(a,T.y),u=Math.max(u,T.x+T.bitmap.width),l=Math.max(l,T.y+T.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(T=>T.bitmap.channels===3)){TT(t,e,n,i,a,f,m);return}let b=new Uint8Array(f*m),h=r?16:1;for(let T of e){let E=T.bitmap;for(let R=0;R<E.height;R++){let P=T.y+R-a;if(!(P<0||P>=m))for(let A=0;A<E.width;A++){let I=E.data[R*E.width+A];if(!I)continue;let S=T.x+A-i;if(S<0||S>=f)continue;let w=P*f+S;r&&b[w]?b[w]=((b[w]-1|I-1)&15)+1:I>b[w]&&(b[w]=I);}}}let p=St(f,m);if(!p)return;let[d,x,y]=yp(n),g=new Uint8ClampedArray(f*m*4),M=null;if(r&&typeof t.getImageData=="function")try{M=Pt(t,i,a,f,m).data;}catch{M=null;}for(let T=0;T<f*m;T++){let E=b[T];if(E<=(r?1:0))continue;let R=T*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]=bs(d,M[R],E,s),g[R+1]=bs(x,M[R+1],E,s),g[R+2]=bs(y,M[R+2],E,s),g[R+3]=255):M?gp(g,R,[d,x,y],(P,A)=>bs(P,A,E,s)):(g[R]=d,g[R+1]=x,g[R+2]=y,g[R+3]=255-yT[E]);}vt(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 yc(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 ga(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=yc(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 w=(L,_)=>{let U=[_,-L,L,_];return d?[d[0]*U[0]+d[2]*U[1],d[1]*U[0]+d[3]*U[1],d[0]*U[2]+d[2]*U[3],d[1]*U[2]+d[3]*U[3]]:U},C=Ym(y),v=y/10*(Math.PI/180);x=w(C.sin,C.cos),d=w(Math.sin(v),Math.cos(v));}if(x&&r.playbackStretch&&r.playbackStretch!==1){let w=r.playbackStretch;x=[x[0]*w,x[1]*w,x[2],x[3]];}let g=(n.textAlign&1)!==0,M=g?n.curX:r.x,T=g?n.curY:r.y,E=(w,C)=>({x:o*w+i*C+u,y:s*w+a*C+l}),R=E(M,T),P=null;if(r.rect&&r.options&(po|xo)){let w=E(r.rect.left,r.rect.top),C=E(r.rect.right,r.rect.bottom);P={left:Math.round(Math.min(w.x,C.x)),top:Math.round(Math.min(w.y,C.y)),right:Math.round(Math.max(w.x,C.x)),bottom:Math.round(Math.max(w.y,C.y))};}let A={codes:r.codes,glyphIndices:r.glyphIndices,x:R.x,y:R.y,dx:r.dx?r.dx.map(w=>w*c):null,dy:r.dy?r.dy.map(w=>-w*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:P,matrix:d,glyphMatrix:x,underline:n.fontUnderline,strikeOut:n.fontStrikeOut},I=xc(t,h,A,n.fontFamilyMap),S=o*a-s*i;return S===0?{dx:0,dy:0}:{dx:(a*I.dx-i*I.dy)/S,dy:(-s*I.dx+o*I.dy)/S}}var Tp=1.2,dp=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,Tp)+.5)),MT=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,1/Tp)+.5));function da(t,e,n){return MT[Math.floor((dp[t]*n+dp[e]*(6-n)+3)/6)]}function xa(t){return Math.round(t*6/255)}function ET(t,e,n){return da(t,e,xa(n*255))}function TT(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,T=(d*s+y)*3+g;M>a[T]&&(a[T]=M);}}}}let u=St(s,i);if(!u)return;let l;try{l=Pt(t,r,o,s,i).data;}catch{return}let c=yp(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];gp(f,d,c,(T,E,R)=>ET(T,E,M[R]));continue}let x=xa(b),y=xa(h),g=xa(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]=da(c[0],l[d],x),f[d+1]=da(c[1],l[d+1],y),f[d+2]=da(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;}vt(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 dc(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 Rp(t,e,n={}){let{placed:r,total:o,startAlong:s,baseDown:i}=Ep(t,e),a=[],u=[];if(n.decorations&&e.plusBars==="fractional"&&t.exactDecorations&&!e.matrix&&o!==0&&t.mode==="gray")u.push(...dc(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),T=e.plusBars==="snapped"&&t.exactDecorations?dc(t.exactDecorations,e,e.x+s,e.y+i,o):null,E=0,R=(P,A)=>{let I=Math.round(e.y+i)-P,S=T?.[E++],w=S?Math.round(S.left):g,C=S?Math.round(S.right):M;a.push({left:Math.min(w,C),right:Math.max(w,C),top:I,bottom:I+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,T=M.channels===3?3:1;for(let E=0;E<M.height;E++)for(let R=0;R<M.width;R++)for(let P=0;P<p;P++){let A=T===3?M.data[(E*M.width+R)*3+P]:Math.round(M.data[E*M.width+R]*255/x),I=((g.y+E-c)*b+(g.x+R-l))*p+P;A>d[I]&&(d[I]=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 T=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(T*4)*Math.round((Math.min(E+1,g.right)-Math.max(E,g.left))*8),P=Math.round(R*255/32),A=(M-c)*b+E-l;P>y[A]&&(y[A]=P);}}return {x:l,y:c,width:b,height:h,channels:p,data:d,bars:y}}function Pp(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 RT(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&hs)!==0,b=Pp(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=ga(i,l,u,{playbackStretch:y,codes:f,glyphIndices:(c&xp)!==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 PT(t){return (t&6)===6?"center":t&2?"right":"left"}function AT(t){let e=t&24;return e===24?"alphabetic":e===8?"bottom":"top"}function gc(t,e,n,r,o,s,i,a,u=null){let l=r?Ds(r):t.measureText(n).width,c=r?o+Xm(l,i):o;if(e.bkMode===2){let f=Vs(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=Ja(r),m=u?Ja(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)&&ff(t,e,c,s,l,a);}function Ap(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)||RT(t,e,n,c,f,m))return true;let b=$e(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;mf(o,i,d);let y=PT(i.textAlign);o.textBaseline=AT(i.textAlign),o.textAlign=y==="center"?"center":y==="right"?"right":"left";let g=(s.getUint32(n+44,true)&hs)!==0,M=Pp(s,e,n,g?c*2:c,m),T=M&&g?M.filter((S,w)=>w%2===0):M,E=M&&g?M.filter((S,w)=>w%2===1):null,R=E?E.map(S=>p?S*d:oe(t,S)):null,P=T?T.map(S=>x!==null?S*x:qt(t,S)):null;if(!P&&i.textJustification&&!g){let S=b.split(""),w=S.map(v=>o.measureText(v).width),C=x??qt(t,1);P=Us(w,S.map(v=>v.charCodeAt(0)),i.textJustification.extra*C,i.textJustification.count);}P&&(o.textAlign="left");let A=p?Ut(t,u,l):{x:Bt(t,u),y:Nt(t,l)},I=$m(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),I!==0&&o.rotate(I),gc(o,i,b,P,0,0,y,d,R),o.restore()):I!==0?(o.save(),o.translate(A.x,A.y),o.rotate(I),gc(o,i,b,P,0,0,y,d,R),o.restore()):gc(o,i,b,P,A.x,A.y,y,d,R),a){let S=x??qt(t,1),w=P&&S?Ds(P)/S:S?o.measureText(b).width/S:0,C=y==="center"?0:y==="right"?-w:w,v=y!=="center"&&E?Ds(E):0;i.curX+=C*Math.cos(I)-v*Math.sin(I),i.curY+=C*Math.sin(I)+v*Math.cos(I);}return true}function Ec(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};Ap(b,0,8,f);}function Ip(t,e,n,r){let{view:o}=t;return Vn(Array.from({length:n},(s,i)=>o.getUint8(e+i)),r,t.codePages)}function Sp(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 IT(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 T=o?null:Ip(t,e+d,p,c),E=o?Array.from({length:p},(I,S)=>s.getUint16(e+d+S*2,true)):T.codes,R=null,P=(x&hs)!==0,A=p*(P?2:1);g&&g<=a-e&&A<=Math.floor((a-(e+g))/4)&&(R=Array.from({length:A},(I,S)=>s.getInt32(e+g+S*4,true)),o||(R=Sp(R,T.byteLengths,P))),Ec(t,b,h,E,x|ya,y,R);}return true}function ST(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 Ec(t,i,a,h,l,b,null),true}function wp(t,e,n,r,o){if(e===84)return Ap(t,n,r,o);if(e===83||e===96||e===97||e===108){if(e===96||e===97)return IT(t,n,r,o,e===97);if(e===108)return ST(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=Ip(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&hs)!==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=Sp(d,b.byteLengths,x)),Ec(t,u,l,b.codes,m,h,d),true}return false}function Rr(t,e,n){let r=sl(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 Cp(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 Rb(Bt(t,r),Nt(t,o),qt(t,s-r),oe(t,i-o))}function DT(t,e,n){return n>=24&&Rr(t,Cp(t,e),"intersect"),true}function UT(t,e,n){return n>=24&&Rr(t,Cp(t,e),"exclude"),true}var Tc={1:"intersect",2:"union",3:"xor",4:"exclude",5:"replace"};function _T(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=Tc[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=yl(t,b),y=gl(t,h);l.push({x,y,w:yl(t,p)-x,h:gl(t,d)-y});}return l.length===0||(Rr(t,an(l),i),$(`EMR_EXTSELECTCLIPRGN: mode=${s} (${i}) with ${l.length} rect(s)`)),true}function FT(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=Rn(t),i=Pn(t),a=Math.round(qt(t,r)/s)*s,u=Math.round(oe(t,o)/i)*i;t.clipRegion=ar(t.clipRegion,a,u),We(t,t.clipRegion);}}return true}function vp(t,e,n,r){switch(e){case 30:return DT(t,n,r);case 75:return _T(t,n,r);case 29:return UT(t,n,r);case 26:return FT(t,n,r);default:return false}}var OT=1;function BT(t,e,n){let r=new Uint8Array(e*n);if(!t.clipRegion)return r.fill(1),r;for(let o of tr(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 NT(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 Lp(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=Ke(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=Zo(s.getUint32(n+8,true),ze(i)),b=s.getUint32(n+12,true)===OT,h;try{h=Pt(o,0,0,u,l).data;}catch{return true}let p=NT(h,u,l,Math.round(c/16),Math.round(f/16),b?d=>d===m:d=>d!==m,BT(t,u,l));return se(t,p,a,i.rop2),true}var WT=0,Dp=1,Fp=2;function HT(t,e,n,r){let o=Math.floor((e-t)*65536/r);return Math.floor((t*65536+o*n)/65536)>>8}function XT(t,e){let n=Zn([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 YT(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===Fp?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 Up(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?qe(i,a):null;c&&Je(t.ctx,{x:n,y:r,w:i,h:a},c,Et(u,i,a));}function $T(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 kp(t,e,n,r){if(e!==118)return false;let o=YT(t,n,r);if(!o)return true;let{ctx:s}=t;if(o.mode===WT||o.mode===Dp){let i=o.mode===Dp;for(let[u,l]of o.mesh){let c=$T(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 T=0;for(let E=0;E<3;E++)T=T<<8|Math.max(0,Math.min(255,HT(c.first.c[E],c.second.c[E],M,y)));g.push(T);}for(let M=0;M<x.h;M++)for(let T=0;T<x.w;T++)x.rgb[M*x.w+T]=g[i?M:T];Up(t,x);}return true}if(o.mode===Fp)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)};XT(a,h),Up(t,h);}return true}var qT=6;function Rc(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 Pc(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 Zn(r,true,n)}for(let[r,o,s,i]of e){let a=Math.round(Bt(t,r)),u=Math.round(Bt(t,s)),l=Math.round(Nt(t,o)),c=Math.round(Nt(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 JT(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 Bp(t,e){let n=e>=2147483648?zs(e-2147483648):t.objectTable.get(e)??null;return n&&n.kind==="brush"?n:null}function Ac(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=Ke(t);s&&se(t,e,s,r.rop2);}finally{r.brushStyle=o.style,r.brushColor=o.color,r.brushPattern=o.pattern;}}function Np(t,e,n,r){let{view:o}=t;switch(e){case 71:{if(r>=32){let s=o.getUint32(n+16,true),i=Bp(t,o.getUint32(n+20,true));i&&Ac(t,Pc(t,Rc(o,n+24,s)),i);}return true}case 72:{if(r>=40){let s=o.getUint32(n+16,true),i=Bp(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=Pc(t,Rc(o,n+32,s));Ac(t,JT(l,a,u),i);}}return true}case 73:case 74:{if(r>=24){let s=o.getUint32(n+16,true),i=Pc(t,Rc(o,n+20,s));e===73?se(t,i,{kind:"solid",rgb:0},qT):Ac(t,i,null);}return true}default:return false}}function Gp(t,e,n,r,o){return wp(t,e,n,r,o)||sp(t,e,n,r,o)||ap(t,e,n,r,o)||vp(t,e,r,o)||Np(t,e,r,o)||Lp(t,e,r,o)||kp(t,e,r,o)}function Ta(t,e,n,r,o){return Ph(t,e,r,o)||Gp(t,e,n,r,o)}function KT(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 Wp(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 Ra(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 Ut(t,x,y)},p=d=>{KT(d,t,h,f,l,c,s);};if(u){p(ke(t)),t.rasterPath??(t.rasterPath=new wt),Wp(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 wt;return Wp(d,t,b,f,l,c,s),d},fill:s,stroke:true,fillRule:a.polyFillMode===2?"nonzero":"evenodd"});}function Hp(t,e,n,r){Ra(t,e,n,r,8,true);}function Xp(t,e,n,r){Ra(t,e,n,r,8,false);}function Yp(t,e,n,r){Ra(t,e,n,r,4,false);}function $p(t,e,n,r){Ra(t,e,n,r,4,true);}function Qp(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 Ut(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&&co(t),f(ke(t)),t.rasterPath??(t.rasterPath=new wt),b(t.rasterPath,null);else {let h=l?wn(t):null,p=l?Ut(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 wt;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 hR(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||Qp(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 pR(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||Qp(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 Ic=1,dR=2,xR=4,jp=6;function Vp(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 T=false,E=()=>{T||(M&&x?.moveTo(M.x,M.y),g&&y?.moveTo(g[0],g[1]),T=true);};for(let R=0;R<u;R++){let A=m(R)&~Ic;if(A===jp){let[I,S]=f(R),w=Ut(t,I,S),C=dt(t,I,S);x?.moveTo(w.x,w.y),y?.moveTo(C[0],C[1]),T=true;continue}if(A===dR){E();let[I,S]=f(R),w=Ut(t,I,S),C=dt(t,I,S);x?.lineTo(w.x,w.y),y?.lineTo(C[0],C[1]);}else if(A===xR&&R+2<u){E();let I=[0,1,2].map(C=>f(R+C)),S=I.map(([C,v])=>Ut(t,C,v)),w=I.map(([C,v])=>dt(t,C,v));x?.bezierCurveTo(S[0].x,S[0].y,S[1].x,S[1].y,S[2].x,S[2].y),y?.bezierTo(w[0][0],w[0][1],w[1][0],w[1][1],w[2][0],w[2][1]),R+=2;}else continue;m(R)&Ic&&(x?.closePath(),y?.closeFigure());}},h=(m(0)&~Ic)===jp;if(a)h||co(t),t.rasterPath??(t.rasterPath=new wt),b(ke(t),t.rasterPath,null,null);else {let x=h?null:wn(t),y=h?null:Ut(t,i.curX,i.curY);t.lineStyle={pos:0},Jt(t,{build:g=>{g.beginPath(),b(g,null,null,y);},raster:()=>{let g=new wt;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 yR(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 Sc(t,e,n){let{state:r}=t,o=e&&n,s=o?yR(t.pathCmds):t.pathCmds,i=u=>{u.beginPath(),Zb(u,s);},a=t.rasterPath??new wt;if(o){let u=new wt;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 xs(t){t.pathCmds=[],t.rasterPath=new wt;}function td(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 gR(t){if(!(t.inPath||!t.rasterPath)){for(let e of t.rasterPath.figures)delete e.tangents,delete e.curveSegs,delete e.roundWiden;td(t);}}function MR(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}:Ul(t),r=Qo(t.rasterPath,n),o=new wt;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,td(t);}function Aa(t,e,n,r,o){let{ctx:s,state:i}=t;switch(e){case 4:case 3:case 2:case 5:case 6:return hR(t,e,n,r,o);case 87:case 86:case 85:case 88:case 89:return pR(t,e,n,r,o);case 7:return o>=28&&Xp(t,n,r,o),true;case 8:return o>=28&&Hp(t,n,r,o),true;case 91:return o>=28&&$p(t,n,r,o),true;case 56:return Vp(t,n,r,o,8),true;case 92:return Vp(t,n,r,o,4),true;case 90:return o>=28&&Yp(t,n,r,o),true;case 59:return t.inPath=true,t.pathCmds=[],t.rasterPath=new wt,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 Sc(t,true,false),xs(t),true;case 63:return Sc(t,true,true),xs(t),true;case 64:return Sc(t,false,true),xs(t),true;case 65:return gR(t),true;case 66:return MR(t),true;case 68:return t.inPath=false,xs(t),s.beginPath(),true;case 67:{let a=o>=12?t.view.getUint32(r,true):5,u=Tc[a];if(t.inPath||!t.rasterPath||t.rasterPath.figures.length===0)return true;if(!u)return true;let l=Al(Lr(t.rasterPath,i.polyFillMode===2)),c=l.length>0?an(l):Ue();return Rr(t,c,u),xs(t),true}default:return false}}var GR=new Set([16,99,100,101,102,103,104,105,106,109,110,111,112,113,119,121,122]);function ed(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+_h?Bh(o,n):null;return i?s.colorAdjustment=i:$("EMR_SETCOLORADJUSTMENT: invalid COLORADJUSTMENT ignored"),true}default:return GR.has(e)?(true):false}}function rd(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,...Ko(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,...Ko(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,...Ko(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=Hm(o,n-8,n,a,u===1?ze(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=$e(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?zs(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,no(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,no(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 Uc(t){return {...t.dpi?{dpi:{...t.dpi}}:{},mode:t.mode,winOrg:{...t.winOrg},winExt:{...t.winExt},vpOrg:{...t.vpOrg},vpExt:{...t.vpExt}}}var VR={2:254,3:2540,4:100,5:1e3,6:1440};function yo(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 Sa(t,e){if(e<1||e>8)return;let n=VR[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 od(t,e,n){!Pr(t)||e===0||n===0||(t.winExt={cx:e,cy:n},yo(t));}function sd(t,e,n){!Pr(t)||e===0||n===0||(t.vpExt={cx:e,cy:n},yo(t));}function Ia(t,e,n){let r=Math.imul(t,e);return r===-2147483648&&n===-1?0:Math.trunc(r/n)}function wa(t,e,n,r,o){if(!Pr(t)||!n||!o)return;let s=Ia(t.winExt.cx,e,n),i=Ia(t.winExt.cy,r,o);s===0||i===0||(t.winExt={cx:s,cy:i},yo(t));}function Ca(t,e,n,r,o){if(!Pr(t)||!n||!o)return;let s=Ia(t.vpExt.cx,e,n),i=Ia(t.vpExt.cy,r,o);s===0||i===0||(t.vpExt={cx:s,cy:i},yo(t));}function _c(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 zR(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 go(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=zR(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 o3(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 Fc(t){let e=o3(t.view);return {...e?{dpi:e}:{},mode:t.mapMode??1,winOrg:t.windowOrg,winExt:{...t.windowExt},vpOrg:t.viewportOrg,vpExt:{...t.viewportExt}}}function kc(t,e){t.mapMode=e.mode,t.windowExt=e.winExt,t.viewportExt=e.vpExt;}function ad(t,e,n,r){let o=Fc(t);!Pr(o)||n===0||r===0||(e?o.vpExt={cx:n,cy:r}:o.winExt={cx:n,cy:r},yo(o),kc(t,o),ro(t));}function s3(t,e,n,r,o,s){let i=Fc(t);!Pr(i)||!r||!s||((e?Ca:wa)(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)&&(kc(t,i),ro(t)));}function i3(t,e,n,r){let{view:o}=t;switch(e){case 9:return r>=16&&ad(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),ro(t)),true;case 11:return r>=16&&ad(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),ro(t)),true;case 17:{if(r>=12){let s=o.getUint32(n,true);if(s>=1&&s<=8){let i=Fc(t);Sa(i,s),kc(t,i),ro(t);}}return true}case 31:case 32:return r>=24&&s3(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 a3(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 ld(t,e,n,r){return i3(t,e,n,r)||a3(t,e,n,r)}function va(){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 La(t){return {...t,worldTransform:[...t.worldTransform]}}function Da(){return {objectTable:new Map,worldTransform:[1,0,0,1,0,0],saveStack:[],saveIdMap:new Map,clipRegion:null,clipSaveDepth:0}}function Ms(t,e,n,r,o){if(ld(t,e,r,o)||rd(t,e,r,o)||Kb(t,e,r,o)||ed(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(La(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),no(a,"text",u);}return true}case 25:{if(o>=12){let u=Xn(i,r);a.bkColor=de(a,u),no(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 Hc(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 Xc(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 b3=16384,Yc=2048;function cd(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&Yc){let u=e,l=0,c=0;for(let f=0;f<r;f++){let m=cd(t,u,n);if(!m)return null;u+=m.size;let b=cd(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&b3)!==0,a=i?4:8;if(e+r*a>n)return null;for(let u=0;u<r;u++)s.push(Xc(t,e+u*a,i));return s}var h3=64;function p3(t){return Math.floor(t*16+.5-1e-4)}function md(t,e,n,r,o){let s;try{s=gn(t,e).map(u=>u.pts.map(p3));}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 Ua(t,e,n,r,o=0){if(o>h3)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 md(l=>l.rect(s,i,a,u),e,false,n,r)}case "path":{let s=t.path;return md(i=>$r(i,s),e,s.fillRule==="evenodd",n,r)}case "combine":{let s=Ua(t.left,e,n,r,o+1),i=s?Ua(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 fd(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 _a(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 bd(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=>d3(c,o.w,o.h,o.x,o.y)),...l],false,n,false,o)}function d3(t,e,n,r,o){return M3(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 x3(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 y3(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,T=x.n-l-1,E,R=false;if(e[M+l]>g)E=l;else {if(e[M+T]<=g)break;{let A=l,I=T,S=I+A>>1;for(;S!==A;)e[M+S]<=g?A=S:I=S,S=A+I>>1;E=I;}}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 P=e[M+E];g!==P&&u.push({x:g,y:d.y1},{x:P,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],T=y.s,E=y.n-l-1,R;if(e[T+E]<M)R=E;else {if(e[T+l]>=M)break;{let A=l,I=E,S=I+A>>1;for(;S!==A;)e[T+S]<M?A=S:I=S,S=A+I>>1;R=A;}}if((R&1)===l){if(m<d.n-1&&e[T+R+1]>e[g+1]){c=1;break}R+=1;}else if(e[T+R]<=e[g-1])break;let P=e[T+R];M!==P&&u.push({x:M,y:d.y0},{x:P,y:d.y0}),r[T+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 g3(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 M3(t,e,n){let{bands:r,X:o}=x3(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=y3(r,o).map(E3),i=g3(s);return s.map((a,u)=>i[u]?a.slice().reverse():a)}function E3(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 T=M.x-c.x,E=M.y-c.y;T===f&&E===m||(a.push(l),l=c,f=T,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 T,E;if(g===0?(E=n[x].y-n[d].y,T=E<0&&(y===1||E===-1)):(E=n[x].x-n[d].x,T=y>0&&(y===1||E===-1)),!T){i(),g^=1,y=E;let I=p;p=d,d=x,x=I,b(n[p]);continue}if(r[d])return h();i(),i();let R=p,P=x,A=d;p=P,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 T3=1.5,pd={1:[3,1],2:[1,1],3:[3,1,1,1],4:[3,1,1,1,1,1]};function R3(t){switch(t){case 1:case 17:return "square";case 2:case 18:case 3:case 19:return "round";default:return "butt"}}function P3(t){return t===1?"bevel":t===2?"round":"miter"}function $c(t){let e=t.width||1,n=t.dashStyle===5?t.dashPattern:pd[t.dashStyle];return !n||n.length===0||n.some(r=>!(r>=0))?[]:n.map(r=>r*e)}function hd(t,e,n=1){t.lineWidth=(e.width||1)*n;let r=$c(e);t.lineCap=R3(r.length>0?e.dashCap??0:e.startCap??e.endCap),t.lineJoin=P3(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 tn(t,e,n,r,o=false,s=false){if(e){let m=I3(t,e);if(!m)return;e=m;}let{ctx:i}=t,a=S3(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&&$c(e).length>0,b=[e.startCap,e.endCap].some(x=>x!==void 0&&x>=17&&x<=20);hd(i,e,c);let h=os(t),p=e.brush&&true?Gl(t,e.brush):null;if(!p&&h!=="canvas"){let x=lo(e.color);p=x===null?null:ao(x);}if(p){let x=_3(i),y=Dt(t),g=dd(u?Xt(y,u):y);if(h!=="canvas"&&x&&w3(t,e,u,p,n,y,x,h,o,s))return;let M=Fa(e)||b||m?Md(t,e,u,n,o):null,T=null;if(x&&M)T=xr(M.flat(),y,x,2);else if(x){let P=Math.max(1,i.miterLimit||10),A=e.width*g*P/2+2;T=xr(r,y,x,A);}if(x&&!T||T&&rs(t,p,T,M?P=>{Ed(P,M),P.fill("nonzero");}:P=>{hd(P,e,c),f(P),P.beginPath(),n(P),u&&P.transform(u[0],u[1],u[2],u[3],0,0);},h,M?(P,A,I)=>P.isPointInPath(A,I,"nonzero"):(P,A,I)=>P.isPointInStroke(A,I)&&(!l||P.isPointInPath(A,I))))return}let d=e.brush?ul(t,e.brush):e.color;if((Fa(e)||b||m||u&&typeof d!="string")&&L3(t,e,u,d,n,o))return;i.strokeStyle=d;}pe(t),f(i);}var A3=2;function I3(t,e){let n=e.unit??0;if(n>=3&&n<=6)return null;if(n!==A3)return e;let r=Fi(t),o=Ze([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 S3(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||U3(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:pd[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 dd(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 xd(t,e){if(!e)return {record:t,unit:Math.hypot(t[0],t[1]),toDevice:D3};let n=Xt(t,e),r=dd(n),o=Ze(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 yd(t,e,n=null){let r=$c(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 w3(t,e,n,r,o,s,i,a,u,l=false){if(!n){let R=Math.hypot(s[0],s[1]),P=Math.hypot(s[2],s[3]),A=s[0]*s[2]+s[1]*s[3];if(!(R>0)||Math.abs(R-P)>1e-6*R||Math.abs(A)>1e-6*R*P)return false}let c=xd(s,n);if(!c)return false;let f;try{f=gn(o,c.record);}catch{return false}u&&(f=f.map(R=>({...R,closed:true})));let m=(e.width||1)*c.unit,b=yd(e,c.unit,n),h=a==="gdiplus-aa",p=R=>{let P=c.toDevice;return R.flatMap(A=>[Ft(P[0]*A.x+P[2]*A.y+P[4]),Ft(P[1]*A.x+P[3]*A.y+P[5])])},d,x=[],y=null,g=[];if(Fa(e))d=gd(f,m,b,e).map(p);else {if(m<=T3&&!b.dash&&!(((e.startCap??0)|(e.endCap??0)|(e.dashCap??0))&240))return v3(t,e,r,o,s,i,h,u);({fix:d,groups:x,insetFigures:y,open:g}=C3(f,b,p));}let M=_o(d,i);if(!M)return true;if(M.w*M.h>16e6)return false;let T=Ee(t.pixelOffsetMode??0),E=y?bd(x,y,h,T,M,l,g):ne(d,false,h,T,M);return jn(t,r,M,E,1,true)}function C3(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 v3(t,e,n,r,o,s,i,a){let u;try{u=d0(r,o);}catch{return false}a&&(u=u.map(h=>({...h,closed:true})));let l=_o(u.map(h=>h.pts),s);if(!l)return true;if(l.w*l.h>16e6)return false;let c=lo(e.color),m=(!e.brush||!e.brush.gradient&&!e.brush.texture&&!e.brush.hatch)&&c!==null&&c>>>24===255&&t.ext?.compositingMode!==1,b=x0(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 Fa(t){return !!(t.customStartCap||t.customEndCap)}function gd(t,e,n,r){let o=_0(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 Md(t,e,n,r,o){let s=Dt(t),i=xd(s,n),a=Ze(s);if(!i||!a||!(i.unit>0))return null;let u;try{u=gn(r,i.record);}catch{return null}o&&(u=u.map(b=>({...b,closed:true})));let l=(e.width||1)*i.unit,c=yd(e,i.unit,n),f=Fa(e)?gd(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 Ed(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 L3(t,e,n,r,o,s){let i=Md(t,e,n,o,s);if(!i)return false;let{ctx:a}=t;a.save();try{a.fillStyle=r,pe(t),Ed(a,i),a.fill("nonzero");}finally{a.restore();}return true}var D3=[1,0,0,1,0,0];function U3(t){return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1&&t[4]===0&&t[5]===0}function _3(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 F3=/^(?:\p{Script=Latin}|\p{Script=Common}|\p{Co})$/u,k3=/[\p{M}\p{Cf}\p{Emoji_Presentation}]/u;function Td(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 !F3.test(y)||k3.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 H3(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 X3=2;function $3(t,e,n,r,o,s,i,a){let{view:u}=t,l=xb(t.interpolationMode??0);if(n||u.getUint32(e+4,true)!==X3)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(Dt(t),r(c,f,m,b)),kernel:l,halfPixelOffset:Ee(t.pixelOffsetMode??0),...o?{pointsForm:true}:{},...o&&i?{worldPoints:i,worldMatrix:Dt(t)}:{},...!o&&a?{worldRect:a,worldMatrix:Dt(t)}:{},...s?{nominalScale:s(m,b)}:{},...H3(t,u.getUint32(e,true))}}function Pd(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:Dt(t),isMetafile:b,resample:$3(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(Xb(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 Jc(t,e,n,r){let{ctx:o}=t,s=r.fillRule??"nonzero";In(t,e,n,a=>$r(a,r),r.points,s)||(o.fillStyle=_e(t,e,n),pe(t),$r(o,r),o.fill(s));}function Kc(t,e,n){tn(t,e,r=>$r(r,n),n.points,z3(n.types),n.fillRule==="evenodd");}function j3(t){return 1+(t===void 0||!Number.isFinite(t)?4:Math.min(12,Math.max(0,t)))/10}function V3(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 z3(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 Vc(t,e,n,r,o,s,i){let{ctx:a}=t,u=uo(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=xr(m,Dt(t),{w:l.width,h:l.height});if(!b)return;let{font:h,textAlign:p,textBaseline:d}=a;if(rs(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=_e(t,e,n),pe(t,false),a.fillText(r,o,s);}var q3=[3,3,3,4,4,6],jc=1/6,J3=1.03;function K3(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 Ad(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??lr,o=cr(t.pageUnit,t.pageScale,r,t.videoDisplay??true),s=e.emSize*cr(n,1,r)/(o||1);return Number.isFinite(s)&&s>0?{...e,emSize:s,unit:0}:e}function Z3(t,e){return t!==0?t:e==="mono"?1:e==="gray"?3:5}function Sd(t,e,n,r){let o=t.fonts,s=typeof n=="string"?K3(n):null,i=Z3(t.textRenderingHint??0,o?.defaultSmoothing),u=!!s&&(i===3||i===4||i===5)&&!At(t.ctx),l=At(t.ctx)?null:u?ao(lo(n)??4278190080):s?null:r,c=e.unit??0;if(!o||!s&&!l||c!==0&&c!==2)return null;let f=Dt(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:q3[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 Oa(t,e,n,r){let o={...n,textAlign:24,bkColor:"#ffffff",bkMode:1,options:r?xo:0,rect:r??null,matrix:null};if((!e.color||e.solidViaCoverage)&&e.sampler){let s=Rp(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=j3(t.ext?.textContrast);if(s.channels===1&&V3(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 xc(t.ctx,e.realized,{...o,textColor:e.color,underline:e.underline,strikeOut:e.strikeOut,plusBars:e.plusBars},t.fontFamilyMap),true}function Q3(t,e,n,r,o,s,i,a,u,l,c=null){let f=Sd(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=Td(m,d,l,h[0]*r+h[4],h[3]*o+h[5],h[0]*s,h[3]*i);if(K)return Oa(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),T=h[0]*r+h[4]+b*(l?.leadingMargin??jc);p||(T=Math.round(T));let E=h[3]*o+h[5]+M,R=l?.tracking??J3,P=!p&&m.mode==="cleartype"&&!!m.ctGridAdvance&&!m.syntheticItalic&&R>1,A=!!m.designAdvance&&h[0]===1&&h[3]===1,I=K=>{let V=m.glyphIndex(K);return p?A?m.designAdvance(V,R):m.advance(V)*R:P?m.ctGridAdvance(V):m.advance(V)},S=p||P?d.map(I):null,w=l?.flags??0,C=h[0]*r+h[4],v=h[3]*o+h[5],L=h[0]*s,_=h[3]*i,U=L>0&&_>0&&!(w&nP)?{left:Math.round(C),top:Math.round(v),right:Math.round(C+L),bottom:Math.round(v+_)}:void 0,F,O=L>0&&!(w&tP)?L-b*((l?.leadingMargin??jc)+(l?.trailingMargin??jc)):1/0,X=(m.designAdvance?d.map(K=>m.designAdvance(m.glyphIndex(K),R)):d.map(I)).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=rP(d,X,O),W=k.length>1;W&&(F=U);let N=x.winDescent??0,q=x.hheaAscender!==void 0&&x.hheaDescender!==void 0?x.hheaAscender-x.hheaDescender+(x.hheaLineGap??0):x.winAscent+N,Q=q*b/x.unitsPerEm;if(U){let K=w&eP?Math.floor((_-(x.winAscent+N)*b/x.unitsPerEm)/Q)+1:Math.floor(_/Q-.25)+1;if(k.length>K){F=U;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 G=rt.start;G<=H;G++)Y+=X[G];if(Y>O&&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 Oa(t,f,{codes:d.slice(0,k[0].end===Id(d)?d.length:k[0].end),glyphIndices:false,x:T,y:E,dx:S?S.slice(0,k[0].end===Id(d)?d.length:k[0].end):null,dy:null},F);for(let[K,V]of k.entries()){let rt=v+(x.winAscent+K*q)*b/x.unitsPerEm,H=d.slice(V.start,V.end);if(H.length===0)continue;let Y=B=>{let j=B+1<V.end&&x.kerning?x.kerning(m.glyphIndex(d[B]),m.glyphIndex(d[B+1]))*b/x.unitsPerEm:0;return p?j:Math.round(j)},G=Array.from({length:V.end-V.start},(B,j)=>I(d[V.start+j])+Y(V.start+j));Oa(t,f,{codes:H,glyphIndices:false,x:T,y:p?v+Math.round(y)+K*Q:Math.round(rt),dx:G.some((B,j)=>B!==I(d[V.start+j]))||S?G:null,dy:null},F);}return true}function Id(t){let e=t.length;for(;e>0&&t[e-1]===32;)e--;return e}var tP=4096,eP=8192,nP=16384;function rP(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 oP=1,sP=2,iP=4;function aP(t,e,n,r,o,s,i){let a=(i&oP)!==0,u=(i&iP)!==0;if(!(i&sP)){let h=_e(t,e,n),p=Sd(t,r,h,t.fonts?uo(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,T)=>T+1<x.length?x[T+1][g]-M[g]:0);Oa(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=Or(r.family,t.fontFamilyMap),b=()=>{l.font=`${f}${c}${r.emSize}px ${m}`,l.textBaseline="alphabetic",l.textAlign="left";};if(u){b(),Vc(t,e,n,String.fromCharCode(...o),s[0].x,s[0].y,r.emSize);return}for(let h=0;h<o.length;h++)b(),Vc(t,e,n,String.fromCharCode(o[h]),s[h].x,s[h].y,r.emSize);}function wd(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"&&Jc(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"&&Kc(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=Ad(t,a.get(p));if(c>0&&r+28+c*2<=r+o){let x=$e(i,r+28,c);if(x.length>0&&d&&d.kind==="plus-font"){let y=a.get(l),g=_e(t,n,u),M=y&&y.kind==="plus-stringformat"?y.alignment:0,T=y&&y.kind==="plus-stringformat"?y:void 0;if(Q3(t,d,x,f,m,b,h,g,M,T,t.fonts?uo(t,n,u):null))return true;let E=d.flags&1?"bold ":"",R=d.flags&2?"italic ":"",P=Or(d.family,t.fontFamilyMap);if(s.font=`${R}${E}${d.emSize}px ${P}`,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";Vc(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=Ad(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{aP(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?Pd(t,l,r,m,b,h,p,(x,y,g,M)=>[D(h/g),0,0,D(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&Bf)!==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,T=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)},${T.toFixed(1)},${E.toFixed(1)},${R.toFixed(1)})`),$(`DrawImagePoints: worldTransform=[${t.worldTransform.map(P=>P.toFixed(3)).join(", ")}]`),Pd(t,l,r,M,T,E,R,(P,A,I,S)=>{let w=D((d-h)/I),C=D((x-p)/I),v=D((y-h)/S),L=D((g-p)/S);return [w,C,v,L,h-w*P-v*A,p-C*P-L*A]},m,true,x===p&&y===h?(P,A)=>[Math.fround((d-h)/P),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 hP=8192;function Zc(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function Ba(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 Cd(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||tn(t,Zc(t,n),Ba(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=_a(f,a,false,u,l);return m.length>=4&&tn(t,Zc(t,n),Ba(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?_a(l,a,true):[];return c.length>=4&&tn(t,Zc(t,n),Ba(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?_a(c,u,true):[];if(f.length<4)return true;let m=n&hP?"nonzero":"evenodd",b=Ba(f,true);if(!In(t,n,a,b,f,m)){let{ctx:h}=t;h.fillStyle=_e(t,n,a),pe(t),h.beginPath(),b(h),h.fill(m);}return true}case 16439:return pP(t,n,r,o),true;case 16403:return o<4||xP(t,n,s.getUint32(r,true)),true;default:return false}}function pP(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"&&Jc(t,0,u,i);let c=a<=255?s.get(a):void 0;c&&c.kind==="plus-pen"&&Kc(t,c,i);}function dP(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 xP(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=Dt(t),{ctx:i}=t,a=dP(i);if(os(t)!=="canvas"&&a){let m={x:0,y:0,w:a.w,h:a.h},b=Ua(o,s,m,Ee(t.pixelOffsetMode??0)),h=b?Wl(t,e,n):null;if(b&&h){let p=fd(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=Vo(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=Ze(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(),jo(i,b.cmds),i.clip(b.fillRule);i.fillStyle=_e(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 AP(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 Dd(t,e,n,r,o){if(o&Yc)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(Xc(t,l,s));return a}function Qc(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function Ud(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(Hc(i,b,c)),b+=f;if(!In(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=_e(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(Hc(i,m,l)),m+=c;tn(t,Qc(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}];In(t,n,u,h,p)||(s.fillStyle=_e(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 tn(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,T=Math.abs(x)/2,E=Math.abs(y)/2,{start:R,sweep:P}=AP(m,b,T,E);if(u){let I=w=>{w.moveTo(g,M),w.ellipse(g,M,T,E,0,R,R+P,P<0),w.closePath();},S=[{x:p,y:d},{x:p+x,y:d},{x:p,y:d+y},{x:p+x,y:d+y}];return In(t,n,f,I,S)||(s.fillStyle=_e(t,n,f),pe(t),s.beginPath(),I(s),s.fill()),true}let A=e===16401;return tn(t,Qc(t,n),I=>{A&&I.moveTo(g,M),I.ellipse(g,M,T,E,0,R,R+P,P<0),A&&I.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=Dd(i,r+4,r+o,u,n);if(!l)return true;let c=(n&8192)!==0;tn(t,Qc(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=Dd(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();};In(t,n,u,f,c)||(s.fillStyle=_e(t,n,u),pe(t),s.beginPath(),f(s),s.fill());}return true}default:return false}}function Fd(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=pi(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 2:{let l=j0(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 3:{let l=er(s,n,r);l&&i.set(a,l);break}case 6:{let l=z0(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=gi(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=vP(s,n,r);l&&(i.set(a,l),$(`replayEmfPlusRecords: Stored Region object id=${a}`));break}}}var _d=64;function tm(t,e,n,r=0){if(e+4>n)return null;if(r>_d)return null;let o=t.getUint32(e,true),s=e+4;if(o<=5){let i=tm(t,s,n,r+1);if(!i)return null;s+=i.bytesRead;let a=tm(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=er(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 vP(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=tm(t,e+8,s);return i?{kind:"plus-region",nodes:[i.node]}:(null)}var kP={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 OP(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 Bd(t){return t>0&&t<=1e5?t:void 0}function*Nd(t,e,n,r,o,s,i,a=1,u=5e5,l,c,f){let m=i??Da(),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??_i,pageScale:m.pageScale??1,dpiX:m.dpiX,dpiY:m.dpiY,videoDisplay:m.videoDisplay,...m.continuation??Mi(),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(),eo()&&(yield);let y=t.getUint16(e,true),g=t.getUint16(e+2,true),M=t.getUint32(e+4,true),T=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,T>=16){let R=t.getUint32(E+4,true),P=t.getUint32(E+8,true),A=t.getUint32(E+12,true);b.dpiX=m.dpiX=Bd(P),b.dpiY=m.dpiY=Bd(A),b.videoDisplay=m.videoDisplay=(R&1)!==0,$(`replayEmfPlusRecords: HEADER dpiX=${P}, dpiY=${A}, flags=0x${R.toString(16)}`);}break}case 16386:e=h;continue;case 16388:break;case 16389:OP(b,E,T);break;case 16390:case 16391:break;case 16440:(b.ext??(b.ext={})).pendingEffect=T<=M-12?Nf(t,E,T):null;break;case 16393:{if(T>=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=Ei(b,t,g,E,T);R&&Fd(R.view===t?b:{...b,view:R.view},R.flags,R.dataOff,R.dataSize,R.cacheKey);break}default:{Ud(b,y,g,E,T)||Cd(b,y,g,E,T)||wd(b,y,g,E,T)||Bb(b,y,g,E,T)||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(`${kP[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 HP={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 Gd(t,e,n,r,o,s=1,i={}){return Ni(rm(t,e,n,r,o,s,i))}function*rm(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=Da(),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:{...va(),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,T=new Map;for(;x+8<=y&&g<l;){Fe(),eo()&&(yield);let E=t.getUint32(x,true),R=t.getUint32(x+4,true);if(R<8||x+R>y)break;g++;let P=x+8;if(T.set(E,(T.get(E)??0)+1),E===70){if(R>=16){let I=t.getUint32(P,true),S=t.getUint32(P+4,true);if(S===726027589&&I>4){Gt(d),M++,$(`replayEmfRecords: EMF+ comment #${M} at offset 0x${x.toString(16)}, dataSize=${I}`);let w=yield*Nd(t,P+8,I-4,e,r,o,u,s,c,i.fontFamilyMap,i.textureCache,i.fonts);$(`replayEmfRecords: EMF+ comment #${M} returned ${w.length} deferred images`),a.push(...w);}else S===1128875079?$(`replayEmfRecords: EMR_COMMENT_PUBLIC at offset 0x${x.toString(16)}, size=${I}`):$(`replayEmfRecords: EMR_COMMENT (sig=0x${S.toString(16).padStart(8,"0")}) at offset 0x${x.toString(16)}, size=${I}`);}x+=R;continue}if(E===14){let I=[];for(let[S,w]of T)I.push(`${HP[S]??`0x${S.toString(16)}`}:${w}`);$(`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(qi(E)||Gt(d),i.gdiDrawing===false){x+=R;continue}if(u.dualMode&&!u.gdiPassthrough){E===33?XP(d):E===34?R>=12&&YP(d,t.getInt32(P,true)):Ms(d,E,x,P,R),x+=R;continue}Ms(d,E,x,P,R)||Ta(d,E,x,P,R)||Aa(d,E,x,P,R)||console.warn(`[emf-converter] Unhandled EMR record type: ${E}`),x+=R;}if(Gt(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 XP(t){t.skippedDcStack??(t.skippedDcStack=[]),t.skippedDcStack.push({state:La(t.state),mapping:{mapMode:t.mapMode,windowOrg:{...t.windowOrg},windowExt:{...t.windowExt},viewportOrg:{...t.viewportOrg},viewportExt:{...t.viewportExt},useMappingMode:t.useMappingMode}});}function YP(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 $P(t,e,n,r,o,s){let i=new DataView(t);if(!mr(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 Gd(i,e,x,n,r,1,s)}return Gd(i,e,{left:0,top:0,right:n,bottom:r},n,r,1,{...s,plusBaseTransform:o,gdiDrawing:false})}Hb($P);function Wd(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"\uFFFD").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Hd(t,e){e.push("<",t.tag);for(let n of Object.keys(t.attrs))e.push(" ",n,'="',Wd(String(t.attrs[n])),'"');if(t.text!==void 0){e.push(">",Wd(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 om(t){let e=[];return Hd(t,e),e.join("")}var Ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function sm(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+=Ir[a>>18]+Ir[a>>12&63]+Ir[a>>6&63]+Ir[a&63];}if(i<o){let a=t[i]<<16|(i+1<o?t[i+1]:0)<<8;s+=Ir[a>>18]+Ir[a>>12&63]+(i+1<o?Ir[a>>6&63]:"=")+"=";}e.push(s);}return e.join("")}function jP(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 Xd(t){return `data:image/svg+xml;base64,${sm(jP(t))}`}function Yd(t){return Xd(om(t))}var $d=256*1024*1024;async function Ts(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:VP(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));else if(typeof Blob<"u"&&t instanceof Blob)e=await t.arrayBuffer();else return null;return zP(e)?qP(e):e}function VP(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}function zP(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 qP(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>$d)return await e.cancel(),z(`readMetafileInput: gzip input inflates past ${$d} 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 JP=15,KP=1128680791;function Na(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===JP&&h>=34&&t.getUint32(p,true)===KP&&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 Pe=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 Oe(t,e){let n=e.getUint32(0,true),r=e.getUint32(4,true);qi(n)||Gt(t);let o=t.view;t.view=e;try{!Ms(t,n,0,8,r)&&!Ta(t,n,0,8,r)&&Aa(t,n,0,8,r);}finally{t.view=o;}}var jd=[0,8388608,32768,8421376,128,8388736,32896,12632256,12639424,10930928,16776176,10526884,8421504,16711680,65280,16776960,255,16711935,65535,16777215];function zd(){return {kind:"pen",style:0,width:0,color:0}}function qd(){return {kind:"brush",style:0,color:16777215,hatch:0}}function Vd(t,e,n){return t<<16|e<<8|n}function zn(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:Vd(i&255,i>>>8&255,i>>>16&255)}return jd[s<jd.length?s:0]}return Vd(n,r,o)}function Sr(t,e){let n=zn(e,t.palette);return vs(n>>16&255,n>>8&255,n&255)}function qn(t,e){return t.getUint32(e,true)}function Jd(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=Sr(t,e.color),n.penUserStyle=void 0,n.penExtended=false;}function Rs(t,e){t.brush=e;let n=t.rCtx.state;n.brushStyle=e.pattern?e.pattern.kind==="mono"?3:6:e.style,n.brushColor=Sr(t,e.color),n.brushPattern=e.pattern??(e.style===2&&e.hatch>=0&&e.hatch<=5?{kind:"hatch",hatch:e.hatch}:null);}function Mo(t){Jd(t,t.pen),Rs(t,t.brush),t.rCtx.state.textColor=Sr(t,t.textColor),t.rCtx.state.bkColor=Sr(t,t.bkColor);}function Be(t,e){let n=0;for(;t.objects[n]!==void 0;)n++;t.objects[n]=e;}function Kd(t,e,n){let{view:r}=t;if(n<16){Be(t,{kind:"other"});return}Be(t,{kind:"pen",style:r.getUint16(e,true),width:r.getInt16(e+2,true),color:qn(r,e+6)});}function Zd(t,e,n){let{view:r}=t;if(n<14){Be(t,{kind:"other"});return}Be(t,{kind:"brush",style:r.getUint16(e,true),color:qn(r,e+2),hatch:r.getUint16(e+6,true)});}function Qd(t,e,n,r){let{view:o}=t;if(n<24){Be(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(...Vn(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)}};Be(t,{kind:"font",font:a});}function am(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=zn(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 um(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 ZP(t,e,n,r,o){let s=t.view,i=e,a=n;if(r===1){let f=am(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+um(s,i);if(o&&s.getUint16(i+14,true)===1){let f=za(s,i,u);if(f)return {kind:"mono",...f}}let l=Le(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 t1(t,e,n){let{view:r}=t;if(e+4+40>n){Be(t,{kind:"other"});return}let o=r.getUint16(e,true),s=r.getUint16(e+2,true),i=ZP(t,e+4,n,s,o===3);Be(t,{kind:"brush",style:i?6:0,color:8421504,hatch:0,...i?{pattern:i}:{}});}function e1(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 n1(t,e,n){if(e+4>n){Be(t,{kind:"other"});return}Be(t,{kind:"palette",entries:e1(t.view,e,n).entries});}function lm(t,e,n,r){let o=t.palette;if(!o||e+4>n)return;let{start:s,entries:i}=e1(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]);Mo(t);}function r1(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);Mo(t);}}function o1(t,e){let n=t.objects[e];n?.kind==="palette"&&(t.palette=n,Mo(t));}function s1(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]);}}Be(t,o);}function i1(t,e){let n=t.objects[e];if(!n)return;let r=t.rCtx.state;switch(n.kind){case "pen":Jd(t,n);break;case "brush":Rs(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 a1(t,e){e>=0&&e<t.objects.length&&(t.objects[e]=void 0);}function cm(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 u1(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 QP(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,zn(t.textColor,t.palette)),s(1,zn(t.bkColor,t.palette)),{bmi:r,bits:e.bits}}function mm(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=am(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=um(i,0);return a>s.length?null:{bmi:s.subarray(0,a),bits:s.subarray(a)}}function fm(t,e,n,r,o,s,i,a,u,l,c,f){[r,o,s,i]=cm(t,r,o,s,i);let m=e?108:100,b=new Pe(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();u1(t,()=>Oe(t.rCtx,p));}function l1(t,e,n,r,o,s,i,a,u,l,c,f=false){f||([n,r,o,s]=cm(t,n,r,o,s));let m=new Pe(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();u1(t,()=>Oe(t.rCtx,d));}function c1(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);fm(t,false,o,u,a,i,s,0,0,i,s,null);}function m1(t,e){return e/2===(t>>8)+3}function f1(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true);if(!m1(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);fm(t,false,u,m,f,c,l,0,0,c,l,null);}function b1(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true),i=n+6,a=n+r,u=m1(s,r),l=i+4,c=()=>{let T=o.getInt16(l,true);return l+=2,T};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:QP(t,mm(t,l,a,0));fm(t,e,f,g,y,x,d,p,h,e?b:x,e?m:d,M);}function h1(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=mm(t,e+22,n,s);h&&l1(t,o,b,m,f,c,l,u,a,i,h);}function p1(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=mm(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,T]=cm(t,m,f,0,0),E=t.layout&1?M-c:M;l1(t,13369376,E,T+(a+l-d),c,d-p,u,p-i,c,d-p,{bmi:x,bits:b.bits},true);}function d1(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 Eo(t,e,n,r,o){let s=d1(t,e,n),i=d1(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 t4(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 bm(t,e,n){Gt(t.rCtx);let r=e.length>0?an(t4(t,e)):Ue();Rr(t.rCtx,r,n);}function x1(t,e,n,r,o){bm(t,[Eo(t,e,n,r,o)],"intersect");}function y1(t,e,n,r,o){bm(t,[Eo(t,e,n,r,o)],"exclude");}function g1(t,e,n){let{rCtx:r}=t;if(!r.clipRegion)return;Gt(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=ar(r.clipRegion,s,i),We(r,r.clipRegion);}function hm(t,e){let n=t.objects[e];if(n?.kind!=="region"){Gt(t.rCtx),t.rCtx.clipRegion=null,We(t.rCtx,null);return}bm(t,n.rects,"replace");}function Ga(t,e){return e.rects.map(([n,r,o,s])=>Eo(t,n,r,o,s)).filter(([n,r,o,s])=>o>n&&s>r)}function M1(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 pm(t,e,n){let r=t.brush;if(n!==null){let s=t.objects[n];if(s?.kind!=="brush")return;Rs(t,s);}let o=Ke(t.rCtx);o&&se(t.rCtx,M1(t,e),o,t.rCtx.state.rop2),n!==null&&Rs(t,r);}function Wa(t,e){let n=t.objects[e];return n?.kind==="region"?n:null}function E1(t,e,n){let r=Wa(t,e);r&&pm(t,Ga(t,r),n);}function T1(t,e){let n=Wa(t,e);n&&pm(t,Ga(t,n),null);}function R1(t,e){let n=Wa(t,e);n&&se(t.rCtx,M1(t,Ga(t,n)),{kind:"solid",rgb:0},6);}function e4(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 P1(t,e,n,r,o){let s=Wa(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=e4(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,T=g&&!M;T&&x<0?x=y:!T&&x>=0&&(p.push([c+x,f+d,c+y,f+d+1]),x=-1);}}pm(t,p,n);}function n4(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 A1(t,e,n,r){let[o,s]=Eo(t,e,n,e,n);se(t.rCtx,n4(t,o,s),{kind:"solid",rgb:zn(r,t.palette)},13);}function dm(t,e,n,r,o){let{rCtx:s}=t,{ctx:i}=s,a=An(i);if(!a||false||typeof i.getImageData!="function")return;let u=Ke(s);if(!u)return;Gt(s);let[l,c]=Eo(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=Pt(i,0,0,b,h).data,d=zn(r,t.palette),x=P=>p[P*4+3]===0?16777215:p[P*4]<<16|p[P*4+1]<<8|p[P*4+2],y=o===1,g=P=>y?x(P)===d:x(P)!==d,M=m*b+f;if(!g(M))return;let T=new Uint8Array(b*h),E=[M];for(T[M]=1;E.length>0;){let P=E.pop(),A=P%b,I=(P-A)/b,S=w=>{!T[w]&&g(w)&&(T[w]=1,E.push(w));};A>0&&S(P-1),A+1<b&&S(P+1),I>0&&S(P-b),I+1<h&&S(P+b);}let R=new zt;for(let P=0;P<h;P++){let A=-1;for(let I=0;I<=b;I++){let S=I<b&&T[P*b+I]===1;S&&A<0?A=I:!S&&A>=0&&(R.add(P,A,I),A=-1);}}se(s,R,u,s.state.rop2);}var I1=5,S1=6;function Ha(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&&ym(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)===S1&&Math.round(na(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 Xa(t,e,n=false){let r=n?Kn(t.x0,t.y0,t.x1,t.y1):Kn(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 Ps(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 r4(t,e){let{state:n}=t.rCtx,r=$n(t.rCtx);if(dr(n,r)===0||pr(n,r)!==1)return;let o=Ps(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 w1(t,e,n,r,o){let s=Ha(t,e,n,r,o);if(s.x1<s.x0||s.y1<s.y0)return;let i=Ps(s),{rCtx:a}=t,{state:u}=a,l=u.penStyle===I1||(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;Gt(a),kr(c,u),c.fillRect(i.x,i.y,i.w,i.h),Fr(c,u),c.lineWidth=1;let f=dr(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:()=>hr(Xa(s),xm(t)),rectangle:true,fill:true,stroke:true,axisRect:{interior:r4(t,s)}});}function o4(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)===S1&&!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)&&!ym(t)?h:[Math.floor(h[0]),Math.floor(h[1])]}function C1(t,e,n,r,o,s,i){let a=Ha(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]=o4(t,s,i,a,[e,n,r,o]),f=Ps(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:()=>ea(Xa(a,c),u,l,xm(t),s===0||i===0,!ym(t)&&xe(t.rCtx)),roundPen:true,fill:true,stroke:true});}function v1(t,e,n,r,o){let s=Ha(t,e,n,r,o,{curved:true,half:true,clampEmpty:true});if(s.x1<s.x0||s.y1<s.y0)return;let i=Ps(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:()=>es(Xa(s),xm(t)),roundPen:true,fill:true,stroke:true});}function s4(t,e,n,r,o,s,i,a,u,l,c=false){let f=Ha(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=(T,E)=>[(m[0]*T+m[2]*E+m[4])*16,(m[1]*T+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=(T,E,R,P,A)=>(P+A)/2+(R!==E?(T-(E+R)/2)*(A-P)/(R-E):T-(E+R)/2),M=(T,E)=>{let[R,P]=b(T,E);return [g(R,y.x0,y.x1,f.x0,f.x1),g(P,y.y0,y.y1,f.y0,f.y1)]};return {box:f,s:M(i,a),e:M(u,l)}}function L1(t,e,n,r,o,s,i,a,u,l){let c=s4(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=Ps(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),T=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,T,!h),E&&R.closePath();},raster:()=>io(Xa(f),m,b,h,e).path,fill:E,stroke:true});}function xm(t){return t.rCtx.state.arcDirection===2}function ym(t){return (t.rCtx.state.penStyle&15)===I1}function i4(t,e){let n=t.rCtx.fonts;if(!n)return null;let r=yt(t.rCtx),o=n.realize(yc(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 a4(t,e){if(t.charExtra===0&&(t.justifyExtra===0||t.justifyCount===0))return null;let n=i4(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 u4(t,e,n,r){let{rCtx:o}=t;if(!o.fonts)return false;Gt(o);let s=e.rect,i=ga(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 gm(t,e){let n=t.rCtx.state.fontDetails?.charSet??1,{codes:r,byteLengths:o}=Vn(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}):a4(t,r);if(u4(t,e,r,a))return;let u=new Pe(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);}Oe(t.rCtx,u.finish());}function D1(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));gm(t,{y:r.getInt16(i,true),x:r.getInt16(i+2,true),bytes:a,options:0,rect:null,dx:null});}function U1(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&(po|xo))!==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&po&&gm(t,{x:s,y:o,bytes:[32],options:a,rect:c,dx:[0]});return}gm(t,{x:s,y:o,bytes:m,options:a,rect:c,dx:h});}function pA(t,e,n,r,o,s={}){let i=go(t,n,s.wmfReferenceDpi),a=r/i.width,u=o/i.height,l={...va(),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:zd(),brush:qd(),palette:null,textColor:0,bkColor:16777215,charExtra:0,justifyExtra:0,justifyCount:0,layout:0};return _c(c,f.mapping,a,u),Mo(f),f}function en(t){_c(t.rCtx,t.mapping,t.kx,t.ky,t.layout&1?t.devW:0);}function dA(t){return {mapping:Uc(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){Oe(t.rCtx,new Pe(e,16).u32(n).finish());}function xA(t,e,n,r){let o=new Pe(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));Oe(t.rCtx,o.finish());}function yA(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)&&(Sa(t.mapping,c(0)),en(t));return;case 523:u(4)&&(t.mapping.winOrg={y:l(0),x:l(1)},en(t));return;case 524:u(4)&&(od(t.mapping,l(1),l(0)),en(t));return;case 525:u(4)&&(t.mapping.vpOrg={y:l(0),x:l(1)},en(t));return;case 526:u(4)&&(sd(t.mapping,l(1),l(0)),en(t));return;case 527:u(4)&&(t.mapping.winOrg={x:t.mapping.winOrg.x+l(1),y:t.mapping.winOrg.y+l(0)},en(t));return;case 529:u(4)&&(t.mapping.vpOrg={x:t.mapping.vpOrg.x+l(1),y:t.mapping.vpOrg.y+l(0)},en(t));return;case 1040:u(8)&&(wa(t.mapping,l(3),l(2),l(1),l(0)),en(t));return;case 1042:u(8)&&(Ca(t.mapping,l(3),l(2),l(1),l(0)),en(t));return;case 30:t.stack.push(dA(t)),Oe(s,new Pe(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,Oe(s,new Pe(34,12).i32(f).finish()),Object.assign(t,{...b,mapping:Uc(b.mapping)}),en(t),Mo(t);return}case 521:u(4)&&(t.textColor=qn(o,i),s.state.textColor=Sr(t,t.textColor));return;case 513:u(4)&&(t.bkColor=qn(o,i),s.state.bkColor=Sr(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),en(t));return;case 261:case 561:case 1574:case 53:return;case 762:Kd(t,i,r);return;case 764:Zd(t,i,r);return;case 763:Qd(t,i,r,a);return;case 322:t1(t,i,a);return;case 505:return;case 247:n1(t,i,a);return;case 1791:s1(t,i,a);return;case 248:case 1790:case 765:Be(t,{kind:"other"});return;case 301:u(2)&&(t.objects[c(0)]?.kind==="region"?hm(t,c(0)):i1(t,c(0)));return;case 564:u(2)&&o1(t,c(0));return;case 55:lm(t,i,a,false);return;case 1078:lm(t,i,a,true);return;case 313:u(2)&&r1(t,c(0));return;case 496:u(2)&&a1(t,c(0));return;case 532:u(4)&&Oe(s,new Pe(27,16).i32(l(1)).i32(l(0)).finish());return;case 531:u(4)&&Oe(s,new Pe(54,16).i32(l(1)).i32(l(0)).finish());return;case 1051:u(8)&&w1(t,l(3),l(2),l(1),l(0));return;case 1564:u(12)&&C1(t,l(5),l(4),l(3),l(2),l(1),l(0));return;case 1048:u(8)&&v1(t,l(3),l(2),l(1),l(0));return;case 2071:case 2096:case 2074:u(16)&&L1(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)&&xA(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 Pe(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));Oe(s,p.finish());}return;case 1313:D1(t,i,a);return;case 2610:U1(t,i,a);return;case 1565:c1(t,i,a);return;case 2338:case 2851:f1(t,e===2851,n,r);return;case 2368:case 2881:b1(t,e===2881,n,r);return;case 3907:h1(t,i,a);return;case 3379:p1(t,i,a);return;case 1046:u(8)&&x1(t,l(3),l(2),l(1),l(0));return;case 1045:u(8)&&y1(t,l(3),l(2),l(1),l(0));return;case 544:u(4)&&g1(t,l(1),l(0));return;case 300:u(2)&&hm(t,c(0));return;case 552:u(4)&&E1(t,c(0),c(1));return;case 299:u(2)&&T1(t,c(0));return;case 298:u(2)&&R1(t,c(0));return;case 1065:u(8)&&P1(t,c(0),c(1),l(2),l(3));return;case 1055:u(8)&&A1(t,l(3),l(2),qn(o,i));return;case 1049:u(8)&&dm(t,l(3),l(2),qn(o,i),0);return;case 1352:u(10)&&dm(t,l(4),l(3),qn(o,i+2),c(0));return;default:return}}function*B1(t,e,n,r,o,s={}){let i=pA(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(),eo()&&(yield),yA(i,b,a,m),a+=m;}Gt(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 $a(t,e){return e?{...t,[Bi]:e}:t}var Ss=3;async function W1(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=to(r),s=r.dpiScale??Qn,i=new DataView(t),a=null;try{a=mr(i);}catch(u){z("replayMetafile: parseEmfHeader threw during detection:",u instanceof Error?u.message:u);}if(!a)try{let u=Jo(i),l=u?Na(i,u.headerSize):null;if(l){let c=new DataView(l);a=mr(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 Ri(i),l=await ju(i);o?.check();let c=Xi(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 pl(o,rm(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:N1(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=Jo(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=go(i,u,r.wmfReferenceDpi),c=n(l.width,l.height);return c?(c.ctx.save(),await pl(o,B1(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:N1(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 N1(t){if(!t.fonts||t.fonts.length===0)return;let e=Hi.for(t.fonts,t.fontSmoothing??"cleartype");return e.size>0?e:void 0}function Is(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}function gA(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=St(i,a);if(!u)return false;le(u.ctx,e.drawable,0,0,i,a);let l=Pt(u.ctx,0,0,i,a),c=sn(l.data,i,a,n,{w:o,h:s});if(!c)return false;let f=St(c.w,c.h);return f?(vt(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 MA(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=Is(i.imageData);t.setTransform(...i.transform);let u=a,l;if(i.isMetafile){if(n>=Ss){z(` Deferred image [${s}]: skipping embedded metafile, recursion depth ${n}`);continue}let f=await H1(a,$a({format:"png"},r),n+1);if(!f){z(` Deferred image [${s}]: metafile conversion returned null`),o=!1;continue}l=f.mimeType,u=Is(f.data.buffer);}if(i.effect&&!i.isMetafile){let f=await Cm(u);if(f){let m=Oi({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=Is((await Wi(m.bitmap.rgba,m.bitmap.width,m.bitmap.height)).buffer),i=m.draw,t.setTransform(...i.transform)),l="image/png";}}let c=await Br(u,l);c?(i.resample&&gA(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 G1={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml"};async function H1(t,e,n=0){let r=e?.format??"png",o=to(e);if(o?.check(),e=$a(e,o),r==="svg"){let i=await Y1(t,e,n);if(!i)return null;o?.check();let a=om(await i.toTree({includeSize:e.includeSize}));return o?.check(),{format:r,mimeType:G1.svg,data:new TextEncoder().encode(a),width:i.canvas.width,height:i.canvas.height}}let s=await wm(t,e,n);if(!s)return null;try{let{data:i,width:a,height:u}=s,l;if(r==="jpeg"){let c=e;l=zo(o,()=>$b(i,a,u,{quality:c.quality,background:TA(c.background),chromaSubsampling:c.chromaSubsampling}));}else if(r==="webp"){let c=e;l=zo(o,()=>jb(i,a,u,{lossy:c.lossless===!1,quality:c.quality}));}else l=await zo(o,()=>Wi(i,a,u));return o?.check(),{format:r,mimeType:G1[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 wm(t,e,n=0){let r=to(e);r?.check();let o=await Ts(t);r?.check();let s=o?await RA(o,$a(e,r),n,"convertMetafileToImageData"):null;if(!s)return null;try{let{canvas:i,ctx:a}=s;return {data:i instanceof xn?new Uint8ClampedArray(i.pixels):Pt(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 EA(await H1(t,{...e,format:"png"}))}function EA(t){return t?`data:${t.mimeType};base64,${sm(t.data)}`:null}function TA(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 RA(t,e,n,r){let o=to(e);if(await pu(),n>Ss)return null;let s={...e,gdiAntialias:e?.gdiAntialias??false};o?.check();let i=null,a=await W1(t,s,(u,l)=>{let c=js(u,l,s.maxWidth,s.maxHeight,s.dpiScale??Qn,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 MA(a.surface.ctx,a.deferredImages,n,o),l=i instanceof xn?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 Sm=0;async function Cm(t){let e=await Ys(new Uint8Array(t));if(e||$s())return e;let n=await Br(t);if(!n)return null;try{let r=St(n.width,n.height);return r?(le(r.ctx,n.drawable,0,0,n.width,n.height),{data:Pt(r.ctx,0,0,n.width,n.height).data,width:n.width,height:n.height}):null}finally{n.close();}}async function PA(t,e,n){let r=await Cm(t);return r?sn(r.data,r.width,r.height,e,{w:n.width,h:n.height}):null}async function AA(t,e,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];o?.check();try{let a=Is(i.imageData);if(i.effect&&!i.isMetafile){let f=await Cm(a);if(f){let m=Oi({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=Is((await Wi(m.bitmap.rgba,m.bitmap.width,m.bitmap.height)).buffer),i=m.draw);}}let u=null;if(i.isMetafile){if(r>=Ss){z(` Deferred image [${s}]: skipping embedded metafile, recursion depth ${r}`);continue}let f=await IA(a,{...n,includeSize:!0,idPrefix:void 0},r+1);f&&(u={kind:"url",url:Yd(f)});}else {let f=new Uint8Array(a),m=Nr(f);if(m)u={kind:"encoded",bytes:f,mime:m};else if(u=Ao(a),!u){let b=await Br(a);if(b){let h=js(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 PA(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?Js(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 IA(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=to(e);if(r?.check(),await pu(),n>Ss)return null;let o=await Ts(t);if(r?.check(),!o)return null;let s=$a(e??{},r),i=s.dpiScale??Qn,a=s.idPrefix===void 0?++Sm:0,u=s.idPrefix??`emf${a}-`,l=null;try{let c=await W1(o,s,(m,b)=>{let h=Ur(m,b,s.maxWidth,s.maxHeight,i,s.maxCanvasDimension),p=s.exactRasterOps===!1?null:js(m,b,s.maxWidth,s.maxHeight,i,s.maxCanvasDimension)?.ctx??null;return l=new Li(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 AA(f,c.deferredImages,s,n,r),f}catch(c){throw a!==0&&Sm===a&&Sm--,c}}var SA=`
|
|
1
|
+
var yx=Object.defineProperty;var Za=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var Qm=(t,e)=>{for(var n in e)yx(t,n,{get:e[n],enumerable:true});};function $2(){return new DOMException("The operation was aborted due to timeout","TimeoutError")}function $o(t){return t?t[Li]?t[Li]:t.signal===void 0&&t.timeoutMs===void 0?null:new tl(t):null}function Te(){$n&&$n.check();}function jn(){return $n!==null&&$n.yields&&performance.now()-$n.sliceStart>16}function j2(t,e){let n=$n;$n=t,t.sliceStart=performance.now();try{t.check();let r=e();return t.throwIfTripped(),r}finally{$n=n;}}function el(t,e){return t?j2(t,e):e()}function V2(){return new Promise(t=>setTimeout(t,0))}async function jo(t,e){for(;;){let n=el(t,()=>e.next());if(n.done)return n.value;await V2(),t?.check();}}function Di(t){for(;;){let e=t.next();if(e.done)return e.value}}var tl,Li,$n,Vn=Za(()=>{"use strict";tl=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:$2()};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())}}};Li=Symbol("emf-converter.budget");$n=null;});var nx={};Qm(nx,{GdiFontCollection:()=>Om});var Om,rx=Za(()=>{"use strict";Om=class t{constructor(){this.size=0;}static for(e,n){return new t}};});var Gm={};Qm(Gm,{encodePng:()=>_A,zlibDeflate:()=>sx});function wA(t,e,n){if(!qa){qa=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;qa[o]=s>>>0;}}let r=4294967295;for(let o=e;o<n;o++)r=qa[(r^t[o])&255]^r>>>8;return (r^4294967295)>>>0}function CA(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 vA(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=CA(t);return n[r++]=o>>>24,n[r++]=o>>>16&255,n[r++]=o>>>8&255,n[r++]=o&255,n}async function sx(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 vA(t)}function LA(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 DA(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 ox(t,e){return (t|Ja)-(e&~Ja)^(t^e^Ja)&Ja}function Bm(t){let e=t>>>7&16843009,n=(t^e*255)+e,r=(n&16711935)+(n>>>8&16711935);return (r&65535)+(r>>>16)}function UA(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 Uint32Array(a.buffer),c=new Uint32Array(u.buffer),f=new Uint8Array(o);for(let m=0;m<n;m++){(m&63)===0&&Te();let b=m*o,h=b-o,p=m*(o+1);if(s&&m>0){let P=b>>2,A=h>>2,I=true;for(let S=0;S<e;S++)if(s[P+S]!==s[A+S]){I=false;break}if(I){i[p]=2;continue}}let d=r.subarray(b,b+o),x=0,y=b>>2;if(s)for(let P=0;P<e;P++)x+=Bm(s[y+P]);else x=DA(d,o);if(x===0){i.set(d,p+1);continue}let g=0,M=0;if(s){let P=0;for(let A=0;A<e;A++){let I=s[y+A],S=ox(I,P);l[A]=S,g+=Bm(S),P=I;}if(m>0)for(let A=0;A<e;A++){let I=ox(s[y+A],s[y-e+A]);c[A]=I,M+=Bm(I);}else M=x;}else {for(let P=0;P<4&&P<o;P++){let A=r[b+P];a[P]=A,g+=A<128?A:256-A;}for(let P=4;P<o;P++){let A=r[b+P]-r[b+P-4]&255;a[P]=A,g+=A<128?A:256-A;}if(m>0)for(let P=0;P<o;P++){let A=r[b+P]-r[h+P]&255;u[P]=A,M+=A<128?A:256-A;}else M=x;}let E=d,T=0,R=x;if(g<R&&(R=g,E=a,T=1),M<R&&(R=M,E=u,T=2),m>0&&R>o>>3){f.set(u.subarray(0,4));let P=0;for(let A=0;A<4&&A<o;A++){let I=u[A];P+=I<128?I:256-I;}for(let A=4;A<o&&P<R;A++){let I=r[b+A-4],S=r[h+A],w=r[h+A-4],C=r[b+A]-LA(I,S,w)&255;f[A]=C,P+=C<128?C:256-C;}P<R&&(E=f,T=4);}i[p]=T,i.set(E,p+1);}return i}function Nm(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,wA(n,4,8+e.length)),n}async function _A(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 sx(UA(t,e,n)),i=[Uint8Array.of(137,80,78,71,13,10,26,10),Nm("IHDR",r),Nm("IDAT",s),Nm("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}var qa,Ja,Wm=Za(()=>{"use strict";Vn();qa=null;Ja=2155905152;});function Fs(t,e,n){let r=o=>o.toString(16).padStart(2,"0");return `#${r(t&255)}${r(e&255)}${r(n&255)}`}function le(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 Qa(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 tf(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 ef(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 E=0;E<2&&y<d;E++){let T=E===0?M>>4&15:M&15;T<a.length&&c<r&&l(c,o-1-f,a[T][0],a[T][1],a[T][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 Rt(new Uint8ClampedArray(u.buffer,u.byteOffset,u.byteLength),r,o)}function tu(t){if(t===0)return 0;let e=0,n=t;for(;(n&1)===0;)n>>>=1,e++;return e}var gx=3;function nf(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===gx){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=tu(s),l=tu(i),c=tu(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 rf(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 E=o?M:r-1-M,T=e+E*c;if(!(T+c>t.byteLength))for(let R=0;R<n;R++){let P=(M*n+R)*4;if(s===1){let A=T+(R>>3),I=t.getUint8(A)>>7-(R&7)&1;I<i.length&&(u[P]=i[I][0],u[P+1]=i[I][1],u[P+2]=i[I][2]),u[P+3]=255;}else if(s===4){let A=T+(R>>1),I=(R&1)===0?t.getUint8(A)>>4&15:t.getUint8(A)&15;I<i.length&&(u[P]=i[I][0],u[P+1]=i[I][1],u[P+2]=i[I][2]),u[P+3]=255;}else if(s===8){let A=t.getUint8(T+R);A<i.length&&(u[P]=i[A][0],u[P+1]=i[A][1],u[P+2]=i[A][2]),u[P+3]=255;}else if(s===16){let A=t.getUint16(T+R*2,true);u[P]=Math.round(((A&f)>>>h)*255/x),u[P+1]=Math.round(((A&m)>>>p)*255/y),u[P+2]=Math.round(((A&b)>>>d)*255/g),u[P+3]=255;}else if(s===24){let A=T+R*3;u[P]=t.getUint8(A+2),u[P+1]=t.getUint8(A+1),u[P+2]=t.getUint8(A),u[P+3]=255;}else {let A=T+R*4,I=t.getUint8(A),S=t.getUint8(A+1),w=t.getUint8(A+2),C=t.getUint8(A+3);u[P]=w,u[P+1]=S,u[P+2]=I,u[P+3]=C===0&&!l?255:C;}}}}function Oe(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 E=1<<c,T=t.getUint32(e+32,true)||E,R=Math.min(T,E),P=e+i,A=!!o&&o.length>0;if(P+R*(A?2:4)>t.byteLength)return null;for(let I=0;I<R;I++){if(A){let v=t.getUint16(P+I*2,true),D=o[v<o.length?v:0];y.push([D>>16&255,D>>8&255,D&255]);continue}let S=t.getUint8(P+I*4),w=t.getUint8(P+I*4+1),C=t.getUint8(P+I*4+2);y.push([C,w,S]);}}let g=nf(t,e,i,f,c);if(!g)return null;let M=new Uint8ClampedArray(a*d*4);return f===b||f===h?ef(t,n,r,a,d,x,f===h,y,M,(T,R,P,A,I,S)=>{let w=(R*a+T)*4;M[w]=P,M[w+1]=A,M[w+2]=I,M[w+3]=S;}):(rf(t,n,a,d,x,c,y,g,M,s),Rt(M,a,d))}var of=[[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 Fr(t,e,n){return ((of[t]??of[0])[n&7]>>7-(e&7)&1)===1}function ks(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 eu(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 sf(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=eu(t,u,l);if(h&&r)return {kind:"mono",...h}}let f=Oe(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 ne(t){if(t.brushStyle===1)return {kind:"none"};let e=t.brushPattern;if(!e)return {kind:"solid",rgb:ks(t.brushColor)};if(e.kind==="bitmap")return {kind:"tile",width:e.width,height:e.height,rgb:e.rgb};let n=ks(t.bkColor);if(e.kind==="hatch"){let s=ks(t.brushColor),i=new Uint32Array(64);for(let a=0;a<8;a++)for(let u=0;u<8;u++)i[a*8+u]=Fr(e.hatch,u,a)?s:n;return {kind:"tile",width:8,height:8,rgb:i}}let r=ks(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 nr(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 ru(t){let e=[],n=0;for(let r=0;r<t.length;r++)e.push(n),n+=t[r];return e}function Os(t){let e=0;for(let n of t)e+=n;return e}function Bs(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 af(t,e){return e==="center"?-t/2:e==="right"?-t:0}var Mx=Math.PI/180;function uf(t){let n=(t%3600+3600)%3600*nu/3600,r=Math.floor(n),o=n-r,s=r*2*Math.PI/nu,i=(r+1)*2*Math.PI/nu;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 nu=128;function lf(t){return -(t/10)*Mx}var Ex=1.15;function cf(t){return t===0?0:t<0?-t:t/Ex}var $=(...t)=>{},J=(...t)=>{};var Tx=[137,80,78,71,13,10,26,10];function ou(t){return t.length>=8&&Tx.every((e,n)=>t[n]===e)}async function Rx(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 su(t)}var Px=[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],Ax=[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],Ix=[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],Sx=[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],wx=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Ro(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 su(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=Ro(p,288),c=Ro(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 E=0;E<x;E++)y[wx[E]]=a(3);let g=Ro(y,19),M=new Uint8Array(p+d);for(let E=0;E<p+d;){let T=u(g);if(T<16)M[E++]=T;else if(T===16){let R=M[E-1];for(let P=3+a(2);P>0;P--)M[E++]=R;}else T===17?E+=3+a(3):E+=11+a(7);}b=Ro(M.subarray(0,p),p),h=Ro(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=Px[d]+a(Ax[d]),y=u(h),g=Ix[y]+a(Sx[y]);i(x);for(let M=0;M<x;M++)o[s]=o[s-g],s++;}}}}return o.subarray(0,s)}var Cx=[[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 vx(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 Lx(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+=vx(c,f,m);break}t[u+l]=b&255;}s=u,e=u+n;}return e}async function mf(t){if(!ou(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 S=8;S+12<=t.length;){let w=e.getUint32(S),C=String.fromCharCode(t[S+4],t[S+5],t[S+6],t[S+7]),v=t.subarray(S+8,Math.min(t.length,S+8+w));if(C==="IHDR"&&v.length>=13)n=e.getUint32(S+8),r=e.getUint32(S+12),o=v[8],s=v[9],i=v[12];else if(C==="PLTE")a=v;else if(C==="tRNS")u=v;else if(C==="IDAT")l.push(v),c+=v.length;else if(C==="IEND")break;S+=12+w;}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 S of l)b.set(S,h),h+=S.length;let p;try{p=await Rx(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,E=u&&s===2&&u.length>=6?[u[0]<<8|u[1],u[2]<<8|u[3],u[4]<<8|u[5]]:null,T=(S,w)=>{if(o===8)return p[S+w];if(o===16)return p[S+w*2]<<8|p[S+w*2+1];let C=w*o;return p[S+(C>>3)]>>8-o-(C&7)&g},R=S=>o===16?S>>8:o===8?S:Math.round(S*255/g),P=(S,w,C,v,D)=>{for(let _=0;_<w;_++){let U=(C*n+v+_*D)*4;if(s===3){let F=T(S,_);y[U]=a[F*3]??0,y[U+1]=a[F*3+1]??0,y[U+2]=a[F*3+2]??0,y[U+3]=u&&F<u.length?u[F]:255;}else if(s===0||s===4){let F=T(S,_*f),O=R(F);y[U]=O,y[U+1]=O,y[U+2]=O,y[U+3]=s===4?R(T(S,_*f+1)):F===M?0:255;}else {let F=T(S,_*f),O=T(S,_*f+1),H=T(S,_*f+2);y[U]=R(F),y[U+1]=R(O),y[U+2]=R(H),y[U+3]=s===6?R(T(S,_*f+3)):E&&F===E[0]&&O===E[1]&&H===E[2]?0:255;}}},A=0,I=i===1?Cx:[[0,0,1,1]];for(let[S,w,C,v]of I){let D=Math.ceil((n-S)/C),_=Math.ceil((r-w)/v);if(D<=0||_<=0)continue;let U=Math.ceil(D*d/8);if(A+_*(U+1)>p.length)return null;let F=A;A=Lx(p,A,U,_,x);for(let O=0;O<_;O++)P(F+O*(U+1)+1,D,w+O*v,S,C);}return {width:n,height:r,data:y}}async function ff(t){return null}function Ns(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 bf(){return null}var Jt=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 hf(t,e){return Math.floor(t/e)}function Po(t,e){return -Math.floor(-t/e)}function or(t,e,n=new Jt,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],E=h[x*2+1];if(g===E)continue;let T=E>g?1:-1,R=T>0?y:M,P=T>0?g:E,A=T>0?M:y,I=T>0?E:g,S=Po(P,16),w=Po(I,16);w<=S||(s.push([S,w,R,P,A-R,I-P,T]),S<i&&(i=S),w>a&&(a=w));}}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(Po(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 Dx(t,e){return Math.abs(t)!==Math.abs(e)?10:e>0?2:t>0?136:68}function pf(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 Xs(t,e,n,r,o){let s=n-t,i=r-e;if(s===0&&i===0)return;let a=Dx(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=(T,R,P)=>u?pf(T,R,P,a):pf(R,T,P,a),M=b>0?hf(x,16)-1:Po(y,16)+1,E=b>0?Po(y,16)+1:hf(x,16)-1;for(let T=M;b>0?T<=E:T>=E;T+=b){let R=T*16,P=c*h+(R-l)*p,A=P/h/16,I=Math.round(A);for(let S=I-1;S<=I+1;S++){let w=S*16,C=P-w*h,v=x-R,D=y-R,_;if(d){let U=p/h,F=C/h,O=Math.max(v,Math.min(0,D)),H=Math.max(v,Math.min(-F/U,D));_=g(2*O,2*(F+U*O),2)||g(2*H,2*(F+U*H),2)||g(O+H,2*F+U*(O+H),2);}else {let U=Math.max(v,Math.min(0,D));_=g(U*h,C+U*p,h);}_&&(g(f-R,m-w,1)||(u?o(T,S):o(S,T)));}}}var df=10,iu=3,yf=6*10912,Ux=yf*8;function dn(t,e){return Math.floor(t/2**e)}var Ys=class{constructor(e,n,r,o){let s=2**df;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=dn(this.e2+this.e3,1),this.e1=dn(this.e1-dn(this.e2,e),1);}steadyState(e){let n=2**iu;this.e0*=n,this.e1*=n;let r=e-iu;r<0?(this.e2*=2**-r,this.e3*=2**-r):(this.e2=dn(this.e2,r),this.e3=dn(this.e3,r));}halve(){this.e2=dn(this.e2+this.e3,3),this.e1=dn(this.e1-this.e2,1),this.e3=dn(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=df+iu;return dn(this.e0+2**(e-1),e)}};function gf(t,e,n,r,o,s,i,a,u,l=1){let c=yf*l,f=Ux*l,m=new Ys(t,n,o,i),b=new Ys(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 Le=.5522847498307936;function rr(t,e,n,r){return {ax:t,ay:e,exx:n-t,exy:0,eyx:0,eyy:r-e}}function xn(t,e=false){if(!e)return Ef(t,false);let{halfX:n,...r}=t,o=Mf(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 Mf(t){return Ef(t,true)}function Ef(t,e){let n=(I,S)=>S?Math.ceil(I/2):Math.floor(I/2),r=I=>n(I,false),o=I=>n(I,true),s=I=>Math.floor(I/2)+Math.ceil(Le*Math.ceil(I/2)),i=I=>Math.ceil(I/2)-Math.ceil(Le*Math.ceil(I/2)),a=I=>n(I,false),u=I=>n(I,true),l=I=>Math.floor(I/2)-Math.floor(Le*Math.floor(I/2)),c=I=>I-l(I),f=I=>I%2===0?Math.ceil(Le*Math.floor(I/2)):Math.floor(Le*Math.ceil(I/2)),m=e?I=>a(I)-f(I):l,b=e?I=>a(I)-f(I):l,h=e?I=>u(I)+f(I):c,p=e?I=>u(I)+f(I):c,d=()=>0,x=I=>I,{ax:y,ay:g,exx:M,exy:E,eyx:T,eyy:R}=t,P=[],A=(I,S)=>{P.push(y+I(M)+S(T),g+I(E)+S(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 I of [0,1,2,3,4,5,12])P[2*I]++;return P}function lu(t,e,n,r){return xn(rr(t,e,n,r))}function cu(t){let e=[t[0],t[1]];for(let n=2;n+5<t.length;n+=6)gf(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 Tf(t,e,n,r,o,s,i=false,a=false,u=false,l){let c=n-t,f=r-e;if(l){let T=(P,A)=>Math.floor(Math.fround(P*A)+.5),R=u?Math.floor(c/2):Math.ceil(c/2);o=2*Math.min(T(R,l[0]),R),s=2*Math.min(T(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(Le*h):Math.floor(Le*h),y=u?Math.floor(Le*d):Math.ceil(Le*d),g=[n,e+h,n,e+h-x,n-d+y,e,p,e],M=T=>t+n-T,E=T=>e+r-T;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]),E(g[1]),M(g[2]),E(g[3]),M(g[4]),E(g[5]),M(g[6]),E(g[7]),g[6],E(g[7]),g[4],E(g[5]),g[2],E(g[3]),g[0],E(g[1])]}var uu=2*Math.PI/128,Gs=t=>On(t)[0],Ws=t=>On(t)[1];function mu(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 Rf(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*Gs(i),c=e-r*Ws(i),f=t+n*Gs(a),m=e-r*Ws(a);return [l-u*n*Ws(i),c-u*r*Gs(i),f+u*n*Ws(a),m+u*r*Gs(a),f,m]}function Pf(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=lu(r,o,r+s,o+i),c=Mf(rr(r,o,r+s,o+i)),f=e*Math.PI/180,m=Math.abs(n)<=3?[Math.cos(f),Math.sin(f)]:On(f),b=[Math.round(a+s/2*m[0]),Math.round(u-i/2*m[1])];for(let h of mu(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=Af(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 _x=3*Math.PI/180,Hs=(()=>{let t=[],e=[];for(let n=0;n<=129;n++)t.push(Math.fround(Math.cos(n*uu))),e.push(Math.fround(Math.sin(n*uu)));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 On(t){let e=t%(2*Math.PI);e<0&&(e+=2*Math.PI);let n=Math.fround(e/uu),r=Math.min(127,Math.floor(n)),o=n-r;return [Hs.cos[r]*(1-o)+Hs.cos[r+1]*o,Hs.sin[r]*(1-o)+Hs.sin[r+1]*o]}var au=Array.from({length:33},(t,e)=>Math.atan(e/32));function xf(t){let e=t*32,n=Math.min(31,Math.floor(e));return au[n]+(au[n+1]-au[n])*(e-n)}function Fx(t,e){let n=Math.abs(t),r=Math.abs(e);if(n===0&&r===0)return 0;let o=r<=n?xf(Math.fround(r/n)):Math.PI/2-xf(Math.fround(n/r));return t>=0?e>=0?o:2*Math.PI-o:e>=0?Math.PI-o:Math.PI+o}function Af(t,e,n,r=1/0){let o=n?l=>[Math.cos(l),Math.sin(l)]:On,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(On(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=On(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 If(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,E=(k,G)=>Fx((k-g)/(m/2||1),-(G-M)/(b/2||1)),T=E(o,s),R=E(i,a),P=k=>u?(2*Math.PI-k)%(2*Math.PI):k,A=R!==T&&Math.abs(P(R)-P(T))<=_x,I=u?-1:1;if(I>0)for(;R<=T;)R+=2*Math.PI;else for(;R>=T;)R-=2*Math.PI;let S=(k,G)=>Math.fround(k*Math.fround(G)),w=(k,G)=>f?Math.round(x-S(Math.floor(m/2),k)):u&&l?Math.ceil(x+S(p,k)+.5-G):Math.round(x+S(p,k)+(l?1+G:0)),C=k=>Math.round(y-S(d,k)),v=f?rr(n,e,t,r):rr(t,e,n,r);l&&(v.halfX=true);let D=xn(v);if(u){let k=xn(v,true);for(let G=0;G<k.length;G+=2)D[k.length-2-G]=k[G],D[k.length-1-G]=k[G+1];}let _=A?[Math.cos(T),Math.sin(T)]:On(T),U=[w(_[0],_[1]),C(_[1])],F=k=>Math.abs(k/h-Math.round(k/h))<1e-9,O=k=>(Math.round(k/h)%4+4)%4;c&&F(T)&&(I>0?O(T)===1||O(T)===2:O(T)===2||O(T)===3)&&U.push(U[0],U[1],U[0],U[1],U[0],U[1]);let H=T;for(let k=0;k<8&&(I>0?H<R-1e-12:H>R+1e-12);k++){let G=I>0?Math.floor(H/h+1e-9)*h+h:Math.ceil(H/h-1e-9)*h-h,N=Math.abs(H/h-Math.round(H/h))<1e-9,K=I>0?G>=R-1e-12:G<=R+1e-12,V=(Math.round(H/h)%4+4)%4,z=(Math.round(G/h)%4+4)%4;if(!(k===0&&(I>0?V===0||V===3:V===0||V===1)||K&&(I>0?z===1||z===2:z===2||z===3))&&N&&(I>0?G<=R+1e-12:G>=R-1e-12)){let X=(Math.round(Math.min(H,G)/h)%4+4)%4*6;I>0?U.push(D[X+2],D[X+3],D[X+4],D[X+5],D[X+6],D[X+7]):U.push(D[X+4],D[X+5],D[X+2],D[X+3],D[X],D[X+1]),H=G;continue}let at=I>0?Math.min(G,R):Math.max(G,R),Y=Af(H,at,A,Math.max(p,d));for(let X=0;X<6;X+=2)U.push(w(Y.ctrl[X],Y.ctrl[X+1]),C(Y.ctrl[X+1]));H=at;}if(c&&F(R)&&(I>0?O(R)===3||O(R)===0:O(R)===1||O(R)===0)){let k=On(R),G=w(k[0],k[1]),N=C(k[1]);U.push(G,N,G,N,G,N);}return U}var vt=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;gf(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,E,T)=>x!==p||y!==d?[x-p,y-d]:g!==p||M!==d?[g-p,M-d]:E!==p||T!==d?[E-p,T-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 kr(t,e,n){return or(t.figures.map(r=>r.pts),e,n)}function Or(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 Ao(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 $s(t){let e=t&15;return e>=1&&e<=4}function js(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)Xs(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])&&Xs(c[f-2],c[f-1],c[0],c[1],a);}});}var yn=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 re;async function Sf(){if(re!==void 0)return re;if(typeof OffscreenCanvas<"u"||typeof document<"u"||typeof process>"u"||!process.versions?.node)return re=null,re;try{re=await bf();}catch{re=null;}return re}var wf=false;function Js(){return typeof OffscreenCanvas>"u"&&typeof document>"u"&&!re}var Br=1;function Io(t,e,n,r,o=Br,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 zs={willReadFrequently:true};function Cf(t,e,n,r,o=Br,s=8192){let{w:i,h:a,scaleX:u,scaleY:l}=Io(t,e,n,r,o,s);try{if(Js()){$(`createCanvas: using the software rasteriser ${i}\xD7${a}`);let c=new yn(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",zs);return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(J('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",zs);return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(J('createCanvas: HTMLCanvasElement.getContext("2d") returned null'),null)}if(re){$(`createCanvas: using @napi-rs/canvas ${i}\xD7${a}, scale=(${u.toFixed(3)},${l.toFixed(3)})`);let c=re.createCanvas(i,a),f=c.getContext("2d");return f?{canvas:c,ctx:f,scaleX:u,scaleY:l}:(J('createCanvas: @napi-rs/canvas getContext("2d") returned null'),null)}return J("createCanvas: no OffscreenCanvas, no document, and no @napi-rs/canvas, cannot create canvas"),null}catch(c){return null}}function wt(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)),wf);if(typeof OffscreenCanvas<"u"){let r=new OffscreenCanvas(t,e),o=r.getContext("2d",zs);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",zs);return o?{canvas:r,ctx:o}:null}if(re){let r=re.createCanvas(t,e),o=r.getContext("2d");return o?{canvas:r,ctx:o}:null}let n=new yn(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 Nr(t,e){switch(e){case "invert":return tf(t);case "black":return "#000000";case "white":return "#ffffff";case "skip":return "rgba(0,0,0,0)";default:return t}}function Gr(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=Nr(e.penColor,n.colorTransform),t.lineWidth=Math.max(e.penWidth,1),t.setLineDash(e.penWidth<=1?Or(e.penStyle,e.penUserStyle)??[]:[]);}function Wr(t,e){let n=he(e.rop2);if(t.globalCompositeOperation=n.gco,ne(e).kind==="none"){t.fillStyle="rgba(0,0,0,0)";return}t.fillStyle=Nr(e.brushColor,n.colorTransform);}function Hx(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 Hr(t,e){let n=e?.[t.toLowerCase().trim()]??t;return /[\s,]/.test(n)&&!/^["']/.test(n)?`"${n}"`:n}function Ks(t,e=1){return Math.max(cf(t.fontHeight)*Math.abs(e||1),8)}function vf(t,e,n=1){let r=e.fontItalic?"italic ":"",o=Hx(e.fontWeight),s=o?`${o} `:"",i=Ks(e,n),a=Hr(e.fontFamily,e.fontFamilyMap);t.font=`${r}${s}${i}px ${a}`;}function Lf(t,e,n,r,o,s=1){if(!e.fontUnderline&&!e.fontStrikeOut)return;let i=Ks(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 Ke(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 Zs(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 So(t,e){let n=Ns(new Uint8Array(t));if(n==="unsupported")return null;if(Js()){let s=await qs(new Uint8Array(t));return s?{drawable:s,width:s.width,height:s.height,close:()=>{}}:null}{if(re)try{let s=await re.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 qs(new Uint8Array(t)),o=r&&wt(r.width,r.height);return !r||!o?null:(Lt(o.ctx,Rt(r.data,r.width,r.height),0,0),{drawable:o.canvas,width:r.width,height:r.height,close:()=>{}})}async function qs(t){if(ou(t))return mf(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=Oe(e,14,n,e.byteLength-n);return r?{data:r.data,width:r.width,height:r.height}:null}return ff()}function pe(t,e,n,r,o,s){t.drawImage.call(t,e,n,r,o,s);}function At(t,e,n,r,o){return t.getImageData.call(t,e,n,r,o)}function Lt(t,e,n,r){t.putImageData.call(t,e,n,r);}function Qs(t,e,n){return t.createPattern.call(t,e,n)}function Rt(t,e,n){if(typeof ImageData<"u")return new ImageData(t,e,n);if(re){let r=re.ImageData;return new r(t,e,n)}return {data:t,width:e,height:n,colorSpace:"srgb"}}function wo(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?Ns(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 Tu(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 ti(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=Oe(e,14,n,e.byteLength-n);return r?{kind:"rgba",data:r.data,width:r.width,height:r.height}:null}var ei=new Float32Array(1),Df=new Uint32Array(ei.buffer);function L(t){let e=Math.fround(t);return e<=t||Number.isNaN(e)?e:e===0?(Df[0]=2147483649,ei[0]):(ei[0]=e,Df[0]+=e>0?-1:1,ei[0])}var Ut=Math.fround,Bn=L,Pu=new Float32Array(1),Ru=new Uint32Array(Pu.buffer);function Uf(t){return Pu[0]=t,t>0?Ru[0]-=1:t<0?Ru[0]+=1:Ru[0]=2147483649,Pu[0]}var mt=(t,e)=>Bn(t+e),et=(t,e)=>Bn(t-e),Q=(t,e)=>Bn(t*e);function Pt(t,e){let n=t/e;if(!Number.isFinite(n))return n;let r=Bn(n);return (e>0?r*e>t:r*e<t)&&(r=Uf(r)),r}function Co(t){let e=Math.sqrt(t);if(!Number.isFinite(e))return e;let n=Bn(e);return n*n>t&&(n=Uf(n)),n}function Nn(t){let e=Math.floor(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function ni(t){let e=Math.ceil(t);return e>=-2147483648&&e<=2147483647?e:-2147483648}function Gn(t,e,n){return e=Ut(e),n=Ut(n),[mt(mt(Q(e,Ut(t[0])),Q(n,Ut(t[2]))),Ut(t[4])),mt(mt(Q(e,Ut(t[1])),Q(n,Ut(t[3]))),Ut(t[5]))]}var oe=(t,e)=>t>e,Wn=(t,e)=>t>=e,Ye=(t,e)=>!(t>=e),_f=(t,e)=>!(t>e);var vo=11920929e-14,ri=2**30;function gn(t){let e=t>>>24;if(e<vo)return [0,0,0,0];let n=t>>>16&255,r=t>>>8&255,o=t&255;if(Math.abs(e-255)<vo)return [e,n,r,o];let s=Pt(e,255);return [e,Q(s,n),Q(s,r),Q(s,o)]}function Hn(t){let e=mt(Q(Q(t,16),16),.5);return Math.floor(e)+15>>4}function Xx(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 E=-s;if(E<i)h=-1,p=i-E;else {h=-Math.trunc(E/i);let T=E%i;T>0?(h--,p=i-T):p=0;}}let d=-1,x=f&15;if(x!==0)for(let E=16-x;E>0;E--){d+=p;let T=h+c;d>=0?(d-=i,c=T+1):c=T;}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 E=0;E<M.length;E++){M[E]=g,g+=h;let T=d+p;T>=0?(d=T-i,g+=1):d=T;}return {kind:t,yStart:m,yEnd:b,xs:M,xMajor:a,origin:u,steps:l}}var oi=class{constructor(e,n,r={}){this.shading=r;this.edges=[];this.rows=new Map;this.colors=n;let o=[Hn(e[0]),Hn(e[2]),Hn(e[4]),Hn(e[0])],s=[Hn(e[1]),Hn(e[3]),Hn(e[5]),Hn(e[1])],i=1/0,a=-1/0;for(let u=0;u<3;u++){let l=Xx(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=-ri,r=ri){if(e<this.yMin||e>=this.yMax)return null;let o=n===-ri&&r===ri?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 v of this.edges)e>=v.yStart&&e<v.yEnd&&o.push(v);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)>vo){let v=Pt(y,p);d=mt(Q(et(f,l),v),l),x=mt(Q(et(m,c),v),c);}let g=et(u,h);if(Math.abs(g)>vo){let v=Pt(g,p);f=et(f,Q(et(f,l),v)),m=et(m,Q(et(m,c),v));}let M=h-b,E=Pt(et(f,d),M),T=Pt(et(m,x),M),[R,P,A]=this.colors,I=new Uint8Array(M*4),S=[0,0,0,0],{preset:w,adjust:C}=this.shading;for(let v=0;v<M;v++){if(w)w(et(et(1,d),x),S);else {let D=d,_=x;if(C){let U=C(et(et(1,d),x)),F=mt(x,d);if(F!==0){let O=Pt(et(1,U),F);D=Q(d,O),_=Q(x,O);}}for(let U=0;U<4;U++){let F=R[U],O=mt(Q(et(P[U],F),D),F);S[U]=mt(O,Q(et(A[U],F),_));}}d=mt(d,E),x=mt(x,T),Au(S,I,v*4);}return {xl:b,n:M,argb:I}}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 Au(t,e,n){let r=t[0];if(!(Math.abs(r)>=vo)){e[n]=e[n+1]=e[n+2]=e[n+3]=0;return}0>r&&(r=0),r>255&&(r=255),e[n]=Ff(r);for(let o=1;o<4;o++){let s=t[o];0>s&&(s=0),s>r&&(s=r),e[n+o]=Ff(s);}}function Ff(t){let e=Math.floor(mt(t,.5));return Number.isFinite(e)?e&255:0}function Lo(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(Q(a,s)):Math.round(a*255/t));return (t<<24|i(e)<<16|i(n)<<8|i(r))>>>0}var Iu=t=>Bn(1-Ut(t));function si(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?Bn(Math.pow(s,o)):s}let n=t.factors.map(Iu).reverse(),r=t.positions.map(Iu).reverse();return o=>{if(Ye(o,0)||Ye(1,o))return o;let s=1;if(oe(et(o,r[1]),kf))for(;;){if(s++,s>=e)return o;if(!oe(et(o,r[s]),kf))break}let i=et(r[s],r[s-1]);return oe(i,0)?mt(Q(Pt(et(o,r[s-1]),i),et(n[s],n[s-1])),n[s-1]):Q(mt(n[s],n[s-1]),.5)}}var kf=11920929e-14;function ii(t){if(!t||t.argb.length<2)return null;let e=t.argb.length,n=t.argb.map(o=>gn(o)).reverse(),r=t.positions.map(Iu).reverse();return (o,s)=>{let i;if(Ye(o,0)||Ye(1,o)){i=Wn(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&&oe(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(oe(c,0)){let f=Pt(et(o,r[a-1]),c);for(let m=0;m<4;m++)s[m]=mt(Q(et(l[m],u[m]),f),u[m]);}else for(let f=0;f<4;f++)s[f]=Q(mt(l[f],u[f]),.5);}}var ai=2**30,Of=Ut(-0.02),Bf=Ut(1.02),Yr=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=mt(et(et(r[0],o[0]),s[0]),i[0]),this.e3y=mt(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(Q(this.e2y,this.e3x),Q(this.e2x,this.e3y)),this.det=et(Q(this.e1x,this.e2y),Q(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(oe(this.minY,o))return [];if(Wn(o,mt(this.minY,this.height)))return [];let s=n,i=r;if(oe(this.minX,i))return [];if(Wn(s,mt(this.minX,this.width)))return [];if(oe(this.yMin,o))return [];if(Wn(o,this.yMax))return [];let a=[];for(let c=0;c<4;c++)this.flags[c]&&(Ye(o,this.yTop[c])||_f(this.yBottom[c],o)||a.push(mt(Q(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(Wn(f,i)||Wn(s,m))continue;f<s&&(f=s),m>i&&(m=i);let b=ni(f),h=ni(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(mt(Q(this.e3x,s),this.det),Q(this.e3y,o)),u=et(Q(this.e1x,s),Q(this.e1y,o)),l=0,c=0,f=0;if(i!==0||i!==i){let y=et(Q(a,a),Q(Q(i,4),u)),g=mt(i,i);if(oe(y,0)){l=2;let M=Co(y),E=mt(u,u),T=Ye(a,0)?et(M,a):et(-a,M),R=Pt(E,T),P=Pt(T,g);(oe(0,R)||oe(R,1))&&(Ye(P,0)||Ye(1,P)||([R,P]=[P,R])),c=R,f=P;}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=>!(oe(Of,y)||oe(y,Bf)),p=y=>!(Ye(y,Of)||Ye(Bf,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=mt(Q(this.e3x,e),this.e1x),s=mt(Q(this.e3y,e),this.e1y);return oe(Math.abs(o),Math.abs(s))?[Pt(-mt(Q(e,this.e2x),n),o),true]:oe(Math.abs(s),0)?[Pt(-mt(Q(e,this.e2y),r),s),true]:[0,false]}},Su=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=-ai,o=ai){let s=r===-ai&&o===ai?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 oe(0,n)?n=0:n<1||(n=1),this.table[Nn(mt(Q(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 wu(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)=>[mt(Q(d,Ut(e[2])),Q(p,Ut(e[0]))),mt(Q(d,Ut(e[3])),Q(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 Co(mt(Q(x,x),Q(y,y)))},h=mt(b(c,m),b(l,f));return Math.max(1,ni(h))}function Xr(t){return Q(Nn(mt(Q(t,16),.5)),.0625)}function Nf(t,e){let n=t.boundary.length;if(n<2)return null;let r=wu(t.boundary,e),o=gn(t.centerArgb),s=gn(t.boundaryArgb[0]??4278190080),i=new Uint32Array(r+2),a=Pt(1,r),u=si(t.blend),l=ii(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 I=u?u(c):c;for(let S=0;S<4;S++)f[S]=mt(Q(et(s[S],o[S]),I),o[S]);}Au(f,m,0),i[A]=(m[0]<<24|m[1]<<16|m[2]<<8|m[3])>>>0,c=mt(c,a);}let b=Gn(e,t.center.x,t.center.y),h=Xr(b[0]),p=Xr(b[1]),d=Ut(t.focus?.x??0),x=Ut(t.focus?.y??0),y=d!==0||x!==0,g=[],M=[],E=h,T=h;for(let A=0;A<n;A++){let I=A+1<n?A+1:0,S=t.boundary[A],w=t.boundary[I];if(S.x===w.x&&S.y===w.y){g.push(new Yr(null,-1)),y&&M.push(new Yr(null,-1));continue}let C=Gn(e,S.x,S.y),v=Gn(e,w.x,w.y),D=Xr(C[0]),_=Xr(C[1]),U=Xr(v[0]),F=Xr(v[1]);E=Math.min(E,D,U),T=Math.max(T,D,U);let O=h,H=p,k=h,G=p;y&&(O=mt(Q(et(D,h),d),h),k=mt(Q(et(U,h),d),h),H=mt(Q(et(_,p),x),p),G=mt(Q(et(F,p),x),p),M.push(new Yr([[h,p],[O,H],[h,p],[k,G]],0))),g.push(new Yr([[O,H],[D,_],[k,G],[U,F]],-1));}let R=Math.floor(E)-2,P=Math.ceil(T)+3-R;return new Su(y?[...g,...M]:g,i,r,R,P)}var Xf=2.2;function Yx(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 $x(t){return t.preset?t.preset.positions.length:t.blend?t.blend.positions.length:2}function jx(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 $r(t,e){let n=t>>>24&255,r=n/255,o=s=>{let i=t>>>s&255;return (e?255*Math.pow(i/255,Xf):i)*r*(n<255?1-2**-40:1)};return [o(16),o(8),o(0),n]}function Gf(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 Cu=new Float32Array(1),Vx=new Int32Array(Cu.buffer);function nt(t){let e=Math.fround(t);return Math.abs(e)>Math.abs(t)?(Cu[0]=e,Vx[0]-=1,Cu[0]):e}function zx(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=nt(t[o]-t[o-1]),i=s>0?nt(nt(n-t[o-1])/s):1;return nt(e[o-1]+nt(nt(e[o]-e[o-1])*i))}return e[r-1]}function qx(t,e,n){let r=nt(1-n),o=(s,i)=>nt(nt(s*r)+nt(i*n));return [o(t[0],e[0]),o(t[1],e[1]),o(t[2],e[2]),o(t[3],e[3])]}function Jx(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 $r(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 Gf($r(i[u-1],n),$r(i[u],n),c)}return $r(i[a-1],n)}let r=$r(t.startArgb,n),o=$r(t.endArgb,n);return t.blend&&!n?qx(r,o,zx(t.blend.positions,t.blend.factors,e)):Gf(r,o,t.blend?jx(t.blend.positions,t.blend.factors,e):e)}function Kx(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/Xf)*n}function vu(t,e){let n=Yx($x(t),e),r=new Uint8Array((n+1)*4);for(let o=0;o<=n;o++){let s=Jx(t,o/n),i=o*4;for(let a=0;a<3;a++){let u=t.gammaCorrected?Kx(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 Lu(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 Zx(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 Yf(t){let e=[];for(let n=0;n<=t.intervals;n++){let r=Zx(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 ui=65536;function Wf(t,e,n){let r=(n==="tile-flip-x"||n==="tile-flip-xy"?2:1)*e*ui;return (t%r+r)%r}function Du(t,e){return Math.min(255,Math.floor(t*Math.floor(255*65536/e)/65536))}function Qx(t,e,n,r,o=false){let s=t.intervals,i=Math.floor(e/ui),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?Du(p,b):Math.round(p*255/b);}n[r+3]=b;}}function ty(t,e,n,r){let o=t.intervals,s=Math.floor(e/ui),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 Hf(t,e){return [L(L(t[0]*e[0])+L(t[1]*e[2])),L(L(t[0]*e[1])+L(t[1]*e[3])),L(L(t[2]*e[0])+L(t[3]*e[2])),L(L(t[2]*e[1])+L(t[3]*e[3])),L(L(L(t[4]*e[0])+L(t[5]*e[2]))+e[4]),L(L(L(t[4]*e[1])+L(t[5]*e[3]))+e[5])]}function ey(t){let e=L(L(t[0]*t[3])-L(t[1]*t[2]));if(e===0)return null;let n=L(1/e),r=[L(t[3]*n),L(-t[1]*n),L(-t[2]*n),L(t[0]*n),L(L(L(t[5]*t[2])-L(t[4]*t[3]))*n),L(L(L(t[4]*t[1])-L(t[5]*t[0]))*n)];return r.every(Number.isFinite)?r:null}function ny(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=[L(e+r),n],a=[e,L(n+o)],u=L(L(L(L(r+e)*L(n+o))-L(n*e))+L(L(-o*e)-L(n*r)));if(Math.abs(u)<11920929e-14)return [1,0,0,1,0,0];let l=L(1/u),c=L(L(L(e+r)*L(n+o))-L(e*n)),f=L(-e*o),m=L(-n*r);return [L(L(L(o*i[0])+L(-o*s[0]))*l),L(L(L(o*i[1])+L(-o*s[1]))*l),L(L(L(r*a[0])+L(-r*s[0]))*l),L(L(L(r*a[1])+L(-r*s[1]))*l),L(L(L(L(f*i[0])+L(c*s[0]))+L(m*a[0]))*l),L(L(L(L(f*i[1])+L(c*s[1]))+L(m*a[1]))*l)]}function ry(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*ui,l=L(o+i),c=L(s+a),f=L(L(l-o)/u),m=L(L(c-s)/u),b=[f,0,0,m,L(l-L(f*u)),L(c-L(m*u))],h=Hf(e.map(p=>Math.fround(p)),n.map(p=>Math.fround(p)));return ey(Hf(b,h))}function $f(t,e,n,r=false,o={x:0,y:0}){let s=t.rect,i=Lu(t);if(!s||!i||!(Math.abs(s.w)>1e-9))return null;let a=vu(i,s),u=a.intervals,l=ry(s,t.transform??ny(s),e,u);if(!l)return null;let c=n?.5:0,f=Math.floor(L(l[0]+.5)),m=Math.floor(L(l[2]+.5)),b=Math.floor(L(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 E=b+p*f+(d+M)*m;for(let T=0;T<x;T++,E+=f)Qx(a,Wf(E,u,t.wrapMode),g,(M*x+T)*4,r);}};return r&&(h.premultiplied=(p,d,x,y,g)=>{for(let M=0;M<y;M++){let E=b+p*f+(d+M)*m;for(let T=0;T<x;T++,E+=f)ty(a,Wf(E,u,t.wrapMode),g,(M*x+T)*4);}}),h}var Uo=[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 zf(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 Do(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 oy(t,e,n){let r=t>>>24&255,o=e>>>24&255;if(r===o)return Do(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 qf(t,e=Uo){return wu(t,e)}function sy(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 jf(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 Do(o.argb,r.argb,s>0?(e-o.offset)/s:1)}}return t[t.length-1].argb}function li(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 P=0;P<u;P++){let A=i[P],I=i[(P+1)%u],S=A.x-s.x,w=A.y-s.y,C=I.x-A.x,v=I.y-A.y,D=S*v-w*C;if(Math.abs(D)<1e-12)continue;let _=(l*v-c*C)/D,U=(S*c-w*l)/D;if(_<-d||U<-d||U>_+d||_>1+d)continue;b=P;let F=(f*v-m*C)/D,O=(S*m-w*f)/D;h=Math.max(0,F),p=F>0?Math.min(1,Math.max(0,O/F)):0;}let x=b<0?1/0:h;if(t.focus){let P=Math.min(1,Math.max(0,t.focus.x)),A=Math.min(1,Math.max(0,t.focus.y));if(P===A)x=x<=P?0:(x-P)/(1-P);else if(x>0){let I=1-P,S=1-A,w=1/0,C=false;for(let v=0;v<u;v++){let D=i[v],_=i[(v+1)%u],U=D.x-s.x,F=D.y-s.y,O=_.x-D.x,H=_.y-D.y,k=U*H-F*O;if(Math.abs(k)<1e-12)continue;if(P===0&&A>0&&Math.abs((r?.x??e)-s.x)<d&&O>0&&Math.max(U,U+O)>0&&Math.abs(H)>d){let X=(((r?.y??n)-s.y)/A-F)/H;X>=-d&&X<=1+d&&(C=true);}if((P>0||Math.abs(l)<d)&&(A>0||Math.abs(c)<d)){let X=P>0?l/P:0,B=A>0?c/A:0,W=(X*H-B*O)/k,j=(U*B-F*X)/k;W>=-d&&W<=1+d&&j>=-d&&j<=W+d&&(C=true,b<0&&(b=v));}let G=k*I*S,N=k*(P*S+A*I)-l*H*S+c*O*I,K=k*P*A-l*H*A+c*O*P,V=N*N-4*G*K,z=Math.abs(G)<1e-12?Math.abs(N)>1e-12?[-K/N]:[]:V>=0?[(-N-Math.sqrt(V))/(2*G),(-N+Math.sqrt(V))/(2*G)]:[],st=0,at=0,Y=0;for(let X of z){if(X<-d||X>1+d)continue;let B=P+I*X,W=A+S*X;if(W===0&&B>0&&Math.abs(c)<d&&H>0&&Math.max(F,F+H)>0&&Math.abs(O)>d){let Z=(l/B-U)/O;if(Z>=-d&&Z<=1+d){st=1,at=0,Y=Math.min(1,Math.max(0,Z));break}}if(B<=0||W<=0)continue;let j=Math.abs(O)>Math.abs(H)?(l/B-U)/O:(c/W-F)/H;j>=-d&&j<=1+d&&(st++,at=Math.max(0,X),Y=Math.min(1,Math.max(0,j)));}st===1&&(w=at,b=v,p=Y);}x=C?0:Number.isFinite(w)?w: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:P,argb:A}=t.preset;if(y<=P[0])return A[0];for(let I=1;I<P.length;I++)if(y<=P[I]){let S=P[I]-P[I-1];return Do(A[I-1],A[I],S>0?(y-P[I-1])/S:1)}return A[P.length-1]}let g=a[b]??t.centerArgb,M=a[(b+1)%u]??g,E=Do(g,M,p),T=t.blend?sy(t.blend.positions,t.blend.factors,y):y,R=Math.min(1,Math.max(0,T));return E>>>24!==t.centerArgb>>>24&&a.every(P=>P===a[0])?oy(E,t.centerArgb,R):Do(E,t.centerArgb,R)}var iy=2048;function Jf(t){return {x:t==="tile-flip-x"||t==="tile-flip-xy",y:t==="tile-flip-y"||t==="tile-flip-xy"}}function ci(t,e,n,r,o,s,i,a,u){if(typeof t.createPattern!="function")return null;let l=o==="clamp"?{x:false,y:false}:Jf(o),c=n*(l.x?2:1),f=r*(l.y?2:1),m=wt(c,f);if(!m)return null;let b=e.w/n,h=e.h/r,p=E=>{let T=E%n*b+(.5+a.phaseX)*b;return E<n?T:e.w-a.lagX-(T-(.5+a.phaseX)*b)-.5*b},d=E=>{let T=(E%r+.5)*h;return E<r?T:e.h-a.lagY-T},x=new Uint8ClampedArray(c*f*4);for(let E=0;E<f;E++){let T=e.y+d(E);for(let R=0;R<c;R++){let P=u(e.x+p(R),T);if(P===null)continue;let A=(E*c+R)*4;x[A]=P>>>16&255,x[A+1]=P>>>8&255,x[A+2]=P&255,x[A+3]=P>>>24&255;}}Lt(m.ctx,Rt(x,c,f),0,0);let y=Qs(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 _o(t){let e=zf(t);return e?{x:e[0]*.5+e[2]*.5,y:e[1]*.5+e[3]*.5}:{x:0,y:0}}var ay=4;function Uu(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(iy,Math.ceil(Math.abs(n)*r*ay)))}function Kf(t,e){let n=e??Uo,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 uy(t,e){if(typeof t.createLinearGradient!="function")return null;let n=e.rect?Kf(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 Vf=1e-5,ly=2048;function cy(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 my(t,e,n,r){let o=cy(t),s=zf(r);if(!o||!s||typeof t.createLinearGradient!="function")return null;let i=Kf(n,e.transform),a=_o(r),u=i.x2-i.x1,l=i.y2-i.y1,c=i.x1+a.x+u*Vf,f=i.y1+a.y+l*Vf,m=u*u+l*l;if(!(m>1e-12))return null;let b=1/0,h=-1/0;for(let[E,T]of [[0,0],[o.w,0],[0,o.h],[o.w,o.h]]){let R=E-r[4],P=T-r[5],A=s[0]*R+s[2]*P,I=s[1]*R+s[3]*P,S=((A-c)*u+(I-f)*l)/m;b=Math.min(b,S),h=Math.max(h,S);}let p=Math.floor(b),d=Math.max(p+1,Math.ceil(h));if(d-p>ly)return null;let x=t.createLinearGradient(c+u*p,f+l*p,c+u*d,f+l*d),y=d-p,g=Jf(e.wrapMode).x,M=[...e.stops].reverse();for(let E=p;E<d;E++){let T=g&&(E%2+2)%2===1;for(let R of T?M:e.stops){let P=T?1-R.offset:R.offset;x.addColorStop(Math.min(1,Math.max(0,(E-p+P)/y)),R.color);}}return x}function fy(t){let e=t.rect?Lu(t):null;return e&&t.rect?Yf(vu(e,t.rect)):t.stops}function by(t,e,n){let r={...e,stops:fy(e)},o=r.rect;if(r.wrapMode!=="clamp"&&o&&o.w!==0){let s=my(t,r,o,n);if(s)return s;if(jf(r.stops,0)!==null){let i=r.transform??Uo,a=Uu(Xt(n,i),"x",o.w),u=ci(t,o,a,1,r.wrapMode,i,_o(n),{phaseX:.5,lagX:0,lagY:0},l=>jf(r.stops,(l-o.x)/o.w));if(u)return u}}return uy(t,r)}function hy(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 py(t,e,n,r){let o=hy(e.boundary);if(!o)return null;let s=e.transform??Uo,i=Xt(r,s),a=Math.hypot(i[0],i[1]),u=Math.hypot(i[2],i[3]);return ci(t,o,Uu(i,"x",o.w),Uu(i,"y",o.h),n,s,_o(r),{phaseX:0,lagX:a>0?1/a:0,lagY:u>0?1/u:0},(l,c)=>li(e,l,c))}function dy(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 Zf(t,e,n=Uo){try{if(e.type==="linear")return by(t,e,n);if(e.shape){let r=py(t,e.shape,e.wrapMode,n);if(r)return r;$("createBrushGradient: path gradient pattern unavailable, using the radial approximation");}return dy(t,e)}catch{return null}}var Qf={};var t0={};var e0={};var xy=Uint8Array.from({length:256},(t,e)=>e);function _u(t,e){return xy}function n0(t){return Qf[t]}function r0(t){return e0[t]}function o0(t){return t0[t]}var yy={"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"},u0=8192;var jr={All:0,Red:1,Green:2,Blue:3},fi=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0");function gy(t,e){let n=[];for(let r=0;r<8;r++)n.push(fi(t.getUint8(e+8+r),2));return [fi(t.getUint32(e,true),8),fi(t.getUint16(e+4,true),4),fi(t.getUint16(e+6,true),4),n.slice(0,2).join(""),n.slice(2).join("")].join("-")}var Bt=(t,e,n)=>t<e?e:t>n?n:t,My=12;function di(t,e,n){if(n<20||e<0||e+n>t.byteLength)return null;let r=yy[gy(t,e)],o=t.getUint32(e+16,true);if(!r||20+o>n)return null;let s=e+20,i=(l,c,f)=>Bt(t.getInt32(s+4*l,true),c,f),a=(l,c,f)=>{let m=t.getFloat32(s+4*l,true);return Number.isFinite(m)?Bt(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(My))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 l0=t=>Math.ceil(t-.5);function Nu(t,e=Math.round){let n=new Uint8Array(256);for(let r=0;r<256;r++)n[r]=Bt(e(t(r)),0,255);return n}function s0(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,nt(e+nt(nt(Math.abs(t)-n)/nt(r-n)))),t<0?nt(e):nt(1/nt(e))}function Ey(t,e){let n=e>=100?1e6:e>=0?100/(100-e):(100+e)/100,r=t/2;return Nu(o=>(o+r-127.5)*n+127.5+r)}function ku(t){return Nu(e=>e*(Math.floor((1+t/100)*65536)/65536))}function Ty(t,e){if(!Number.isInteger(t)||t<0||t>7)return null;return _u().slice()}function Ry(t,e,n){if(t!==n){let i=t>n,a=nt((i?n:t)*255/100),u=nt((i?t:n)*255/100),l=nt(1/nt(u-a)),c=s0(e),f=new Uint8Array(256);for(let m=0;m<256;m++){let b=Bt(nt(nt(m-a)*l),0,1);e!==0&&(b=nt(b**c));let h=i?nt(255*b):nt(255-nt(255*b));f[m]=Bt(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=s0(e);return Nu(i=>{let a=Bt((i-r)/o,0,1);return 255*(t>=n?a**s:1-(1-a)**s)},l0)}function Fo(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 Py(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(Bt(l,0,1)*255);}}return n}var Ze=43,bi=255;function Ay(t,e,n){let r=Math.max(t,e,n),o=r-Math.min(t,e,n),s=u=>Math.floor(u*Ze/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 Iy(t,e,n,r){let o=new Uint8ClampedArray(t),s=Math.round(e*bi/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=Bt((m+b>>1)+a,0,255);if(m===b){o[u]=o[u+1]=o[u+2]=h;continue}let p=m+b,d=Bt(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=((Ay(l,c,f)+s)%bi+bi)%bi,E=M+Math.floor((M+41)/85),T=Math.min(5,Math.floor(E/Ze)),R=E-T*Ze,P=y+Math.floor((g-y)*R/Ze),A=y+Math.floor((g-y)*(Ze-R)/Ze),[I,S,w]=[[g,P,y],[A,g,y],[y,g,P],[y,A,g],[P,y,g],[g,y,A]][T];o[u]=I,o[u+1]=S,o[u+2]=w;}return o}function Sy(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/Ze)),i=o-s*Ze,a=Math.floor(Xn*i/Ze),u=Math.floor(Xn*(Ze-i)/Ze),[l,c,f]=[[Xn,a,0],[u,Xn,0],[0,Xn,a],[0,u,Xn],[a,0,Xn],[Xn,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,E=b*x+c*g,T=b*y+f*g,R=54*d+183*x+19*y-(54*(M>>8)+183*(E>>8)+19*(T>>8));h[p]=R+M>>8,h[p+1]=R+E>>8,h[p+2]=R+T>>8;}return h}var Xn=254;function wy(t,e,n,r){let o=new Uint8ClampedArray(t),s={x:0,y:0,set:false};for(let i of r)By(o,e,Bt(i.left,0,e),Bt(i.top,0,n),Bt(i.right,0,e),Bt(i.bottom,0,n),s);return o}var hi=60,Cy=15,vy=2/9,Ly=1;function Dy(t,e){return Math.floor((9*t+2*e+5)/11)}var Ou=5/16,i0=[25,40,80],Uy=[.25,.5,.66,.75],_y=40,Fy=.33,ky=5;function Oy(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=nt(r+nt(u*a)),o=nt(o+nt(u*i)),s=nt(s+u);}return {cx:nt(nt(r/s)+.5),cy:nt(nt(o/s)+.5)}}function By(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 V=0;V<u;V++)for(let z=0;z<a;z++){let st=((r+V)*e+n+z)*4,at=t[st],Y=t[st+1],X=t[st+2],B=V*a+z;f[B]=Y+vy*X;let W=Dy(Y,X);m[B]=W;let j=at-Math.max(Y,X);if(j>0){c[B]=j;let Z=nt(W>=1?j/W:Ly);b=nt(b+nt(Z*z)),h=nt(h+nt(Z*V)),p=nt(p+Z);}}if(p===0)return;i.set&&(b=nt(b+nt(i.x-.5)),h=nt(h+nt(i.y-.5)));let d=nt(nt(b/p)+.5),x=nt(nt(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}=Oy(m,a,u));let g=n+d,M=r+x,E=Math.round(d)>a/2?a-d+.5:d-.5,T=Math.round(x)>u/2?u-x+.5:x-.5,R=g>M?Math.min(E,M-.5):Math.min(T,g-.5);if(!(R>0))return;let P=Int32Array.from(m).sort(),A=P[Math.floor(.7*l)],I=A-P[Math.floor(.3*l)],S=P[l-1],w=l>1?P[l-2]:-1,C=-1;S>w&&S-A>=_y&&(C=m.indexOf(S));let v=0;for(;v<i0.length&&I>i0[v];)v++;let D=Uy[v],_=new Uint8Array(l),U=new Float64Array(l),F=new Float64Array(hi),O=new Float64Array(hi),H=new Float64Array(hi),k=180/Math.PI,G=nt(R*R);for(let V=0;V<u;V++)for(let z=0;z<a;z++){let st=z+.5-d,at=V+.5-x,Y=V*a+z,X=nt(nt(st*st)+nt(at*at));U[Y]=nt(Math.sqrt(X));let B=Math.atan2(at,st)*k;B<0&&(B+=360);let W=st===0&&at===0?Cy:at===0?0:Math.min(hi-1,Math.floor(B/6));_[Y]=W,X<G&&(F[W]+=c[Y],O[W]+=f[Y],H[W]++);}C>=0&&!(U[C]<R)&&(C=-1);let N=nt,K=N(D);for(let V=0;V<u;V++)for(let z=0;z<a;z++){let st=V*a+z,at=c[st];if(at<=0||U[st]>=R)continue;let Y=_[st],X=N(F[Y]/H[Y]),B=N(O[Y]/H[Y]),W=B>0?N(f[st]/B):1,j=N(1-N(U[st]/R)),Z=W<2?N(.5*N(N(1-W)*N(1-W))):0,ut=Math.max(N(K*N(j*j)),Z,y?N(Fy*j):0),it=N(N(1-ut)*X);if(C>=0){let tt=z-C%a,lt=V-Math.floor(C/a);it=Math.min(it,ky*(tt*tt+lt*lt));}if(it>=at)continue;let ht=at-it,ct=((r+V)*e+n+z)*4;t[ct]=Math.round(t[ct]-(1-Ou)*ht),t[ct+1]=Math.round(t[ct+1]+Ou*ht),t[ct+2]=Math.round(t[ct+2]+Ou*ht);}}function c0(t){let e=Math.ceil(t),n=new Float64Array(2*e+1);if(e===0)return n[0]=1,n;let r=nt(nt(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=nt(s+r),o[u]=nt(Math.exp(-nt(s*s))),i=nt(i+nt(2*o[u]));let a=nt(256/i);for(let u=0;u<=e;u++){let l=nt(o[u]*a)/256;n[e+u]=l,n[e-u]=l;}return n}function Bu(t,e){if(e===1)return 0;for(;t<0||t>=e;)t=t<0?-t:2*(e-1)-t;return t}function m0(t,e,n,r,o=0,s=false,i=Math.ceil(n/e)){let a=c0(r),u=(a.length-1)/2,l=(u|1)>=e?m=>Math.max(0,Math.min(e-1,m)):m=>Bu(m,e),c=(u|1)>=n?m=>Math.max(0,Math.min(n-1,m)):m=>Bu(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 E=b+l(h+M)*4,T=M===0?a[u]*128:a[M+u]*256,R=M===0?2:1;p+=R*Math.round(T*t[E]),d+=R*Math.round(T*t[E+1]),x+=R*Math.round(T*t[E+2]),y+=R*Math.round(T*t[E+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 E=0;E<e*4;E++)p[E]+=M*Math.round(g*m[y+E])/256;}f.set(p,h*e*4);}}return f}function f0(t){return t<20?1:t<40?2:t<=80?4:t<160?8:16}function a0(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=>Bt(d,0,l-1):d=>Bu(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 E=a.start+(M-a.pad)*n,T=Math.min(a.start+a.size,E+n),R=0;for(let P=E;P<T;P++)R+=s(P,d,x);m[M]=Math.floor(R/(T-E));}for(let M=0;M<l;M++){let E=0;if(M>=c&&M+c<l)for(let T=0;T<h.length;T++)E+=Math.round(h[T]*m[M-c+T]);else for(let T=0;T<h.length;T++){let R=M-c+T;E+=Math.round(h[T]*(a.zeroOutside&&(R<0||R>=l)?0:m[f(R)]));}E+=2*Math.round(p*m[M]),b[M]=Math.floor((E+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 E=(M-a.start+.5)/n-.5;if(y){let P=Math.abs(M-a.start-(Math.min(a.size,n/2)-.5))/n;i(M,d,x,Bt(Math.floor((1+P)*b[a.pad]+1e-9),0,255));continue}let T=Bt(Math.floor(E),0,Math.max(0,u-2)),R=E-T;i(M,d,x,Bt(Math.floor((1-R)*b[a.pad+T]+R*b[a.pad+Math.min(u-1,T+1)]+1e-9),0,255));}}}function Gu(t,e,n,r,o,s=false){let i=f0(r);if(i===1)return m0(t,e,n,r);let a=c0(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);a0(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 a0(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 Ny(t,e,n,r){return Uint8ClampedArray.from(Gu(t,e,n,r),Math.round)}function Gy(t,e){return l0(64*e/(250-2*e))/64}function Wy(t,e,n,r,o){let s=Gu(t,e,n,r),i=Gy(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 Hy(t,e,n,r){if(e<=0||n<=0||t.length!==e*n*4)return null;switch(r.kind){case "blur":return Ny(t,e,n,r.radius);case "sharpen":return Wy(t,e,n,r.radius,r.amount);case "brightnessContrast":{let o=Ey(r.brightness,r.contrast);return Fo(t,o,o,o)}case "colorBalance":return Fo(t,ku(r.cyanRed),ku(r.magentaGreen),ku(r.yellowBlue));case "colorCurve":{let o=Ty(r.adjustment,r.intensity),s=r.channel;if(!o||s<jr.All||s>jr.Blue)return null;let i=a=>s===jr.All||s===a?o:null;return Fo(t,i(jr.Red),i(jr.Green),i(jr.Blue))}case "colorLookupTable":return Fo(t,r.r,r.g,r.b,r.a);case "colorMatrix":return Py(t,r.matrix);case "hueSaturationLightness":return Iy(t,r.hue,r.saturation,r.lightness);case "levels":{let o=Ry(r.highlight,r.midtone,r.shadow);return Fo(t,o,o,o)}case "redEyeCorrection":return wy(t,e,n,r.areas);case "tint":return Sy(t,r.hue,r.amount)}}function pi(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 Xy(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)pi(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);pi(t,e,x,y,g-x,M-y,m,c,x-(o-l),y-(s-l));}let b=f0(r)>1?Gu(m,c,f,r,u?{x:l,y:l,w:i-o,h:a-s}:void 0,true):m0(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 b0(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 h0(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=Bt(Math.floor(o.x),0,e),i=Bt(Math.floor(o.y),0,n),a=Bt(Math.ceil(o.x+o.w)+1,0,e),u=Bt(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 pi(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}=Xy(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),pi(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=Hy(h,l,c,p);return d?b(d):null}function p0(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),E=t.getUint8(x+3);s===925707&&E>0&&E<255&&(M=Math.min(255,Math.round(M*255/E)),g=Math.min(255,Math.round(g*255/E)),y=Math.min(255,Math.round(y*255/E)));let T=p+d*4;f[T]=y,f[T+1]=g,f[T+2]=M,f[T+3]=E;}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 Yy(f,l,n,r,c)}function d0(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 Yy(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 x0=Math.fround;function De(t){return Math.floor(x0(x0(t)*256+.5))+15>>4}function $e(t,e,n,r){let o=1/0,s=1/0,i=-1/0,a=-1/0;for(let T=0;T<8;T+=2)o=Math.min(o,t[T]),i=Math.max(i,t[T]),s=Math.min(s,t[T+1]),a=Math.max(a,t[T+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=(T,R)=>Math.floor(T/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=(T,R)=>Math.abs(T)>Math.abs(R)?Math.abs(T):Math.abs(R);for(let T=0;T<40;T++){let R=24576*2**d;if(y(b[2],b[3])<=R&&y(h[2],h[3])<=R)break;d+=2;for(let P of [b,h])P[2]=m(P[2]+P[3],1),P[1]=m(P[1]-m(P[2],d),1);p*=2;}for(let T of [b,h]){T[0]*=8,T[1]*=8;let R=d-3;R>=0?(T[2]=m(T[2],R),T[3]=m(T[3],R)):(T[2]*=2**-R,T[3]*=2**-R);}let g=T=>{T[0]+=T[1];let R=T[2];T[1]+=R,T[2]=R+R-T[3],T[3]=R;},M=1/p,E=M;g(b),g(h),p--;for(let T=0;T<1<<22;T++){if(e.push(m(b[0]+4096,13)+u,m(h[0]+4096,13)+l),r?.push(E),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--,E+=M,g(b),g(h);}}function $y(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 y0(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 g0(t,e){let n=t%e;return n<0?n+e:n}function Vr(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=$y(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,E=h/x,T=p/x,R=Math.max(-1,Math.min(1,g*E+M*T)),P=Math.acos(R)/2,A=l.radius/Math.tan(P),I=l.x1+g*A,S=l.y1+M*A,w=l.x1+E*A,C=l.y1+T*A,v=g+E,D=M+T,_=Math.hypot(v,D),U=l.radius/Math.sin(P),F=l.x1+v/_*U,O=l.y1+D/_*U,H=Math.atan2(S-O,I-F),k=Math.atan2(C-O,w-F)-H;k>Math.PI?k-=2*Math.PI:k<-Math.PI&&(k+=2*Math.PI),u(I,S);let G=y0(l.radius,k);for(let N=1;N<=G;N++){let K=H+k*N/G;u(F+l.radius*Math.cos(K),O+l.radius*Math.sin(K));}break}case "ellipse":{let c=2*Math.PI,f;if(l.ccw){let y=l.startAngle-l.endAngle;f=-(y>=c?c:g0(y,c));}else {let y=l.endAngle-l.startAngle;f=y>=c?c:g0(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=y0(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 jy(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 E0(...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 Vr(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 Vy(t,e,n){let r=[];for(let o of Vr(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 zy(t,e){let n=[],r=Vy(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 T0(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 M0(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=zy(o,e);r=r.map((i,a)=>i.length===0?i:T0(i,s[a],R0));}return r}var R0=(t,e)=>t&&e,qy={replace:(t,e)=>e,intersect:R0,union:(t,e)=>t||e,xor:(t,e)=>t!==e,exclude:(t,e)=>t&&!e,complement:(t,e)=>e&&!t};function Jy(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 Ky(t,e){let n=[],r=0;for(let o=1;o<=t.length;o++){if(o<t.length&&Jy(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 sr(t,e,n,r){let o=jy(r);if(o.x1<=o.x0||o.y1<=o.y0)return [];let s=M0(t,o),i=M0(e,o),a=qy[n],u=s.map((l,c)=>T0(l,i[c],a));return Ky(u,o.y0)}function P0(t){return t.w>32768||t.h>32768}var Zy=8192;function ir(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&Zy?"nonzero":"evenodd"}}function Qy(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 t2=512;function e2(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 n2(t){let e=Vr(t);if(e.length!==1)return false;let n=e[0],r=n.length/2;if(r<3)return true;if(r>t2)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&&e2(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 Wu(t,e){let n=Qy(t,e);return {cmds:n,fillRule:t.fillRule??"nonzero",simple:n2(n)}}function zr(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 a2=1,Mi=2,I0=4,S0=8,u2=64,l2=128,xi=4096;function qr(t){return t>>>12===900097}function Xu(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 yi(t,e,n){return {x:t[0]*e+t[2]*n+t[4],y:t[1]*e+t[3]*n+t[5]}}function c2(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function Yu(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 w0(t){return t.map(e=>({...e,offset:c2(e.offset)})).sort((e,n)=>e.offset-n.offset)}function C0(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>xi)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:le(l),argb:l});}return {stops:a,next:i}}function v0(t,e,n){if(e+4>n)return null;let r=t.getUint32(e,true);if(r===0||r>xi)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 m2(t,e,n){if(e+40>n)return null;let r=t.getUint32(e,true),o=Yu(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&Mi&&f+24<=n&&(m=Xu(t,f),f+=24);let b=[{offset:0,color:le(l),argb:l},{offset:1,color:le(c),argb:c}],h={startArgb:l,endArgb:c,preset:null,blend:null,gammaCorrected:(r&l2)!==0};if(r&I0){let x=C0(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&S0){let x=v0(t,f,n);x&&(b=x.entries.map(y=>({offset:y.pos,color:Qa(l,c,y.factor),argb:$u(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=yi(m,p.x,p.y),d=yi(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:le(l),gradient:{type:"linear",x1:p.x,y1:p.y,x2:d.x,y2:d.y,stops:w0(b),wrapMode:o,rect:{x:s,y:i,w:a,h:u},transform:m,ramp:h}}}function L0(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=d0(t,u,o,s,i,a);return c?{width:o,height:s,rgba:c}:null}function D0(t,e,n){if(e+28>n||t.getUint32(e+4,true)!==1||L0(t,e,n))return null;let r=e+28;return r<n?{start:r,end:n}:null}function U0(t,e,n){if(e+8>n)return null;let r=t.getUint32(e,true),o=e+8;return r&Mi&&o+24<=n&&(o+=24),o}function f2(t,e,n,r){if(e+8>n)return null;let o=t.getUint32(e,true),s=Yu(t.getUint32(e+4,true)),i=e+8,a=null;o&Mi&&i+24<=n&&(a=Xu(t,i),i+=24);let u=L0(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 b2(t,e,n){if(e+24>n)return null;let r=t.getUint32(e,true),o=Yu(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>xi)return {kind:"plus-brush",color:le(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&a2){if(c+4<=n){let A=t.getInt32(c,true);if(c+=4,A>0&&c+A<=n){let I=ir(t,c,A);if(I){let S=d2(I.points,I.types,h);f=S.points,m=S.argb;let w=I.points.length;for(let C=0;C<I.points.length;C++){if(C>0&&(I.types[C]&7)===0){w=C;break}if(I.types[C]&128){w=C+1;break}}I.types.slice(0,w).some(C=>(C&7)===3)&&(b={points:I.points.slice(0,w),types:I.types.slice(0,w)});}c+=A;}}}else if(c+4<=n){let A=t.getUint32(c,true);if(c+=4,A>0&&A<=xi&&c+A*8<=n){for(let I=0;I<A;I++)f.push({x:t.getFloat32(c+I*8,true),y:t.getFloat32(c+I*8+4,true)}),m.push(h(I));c+=A*8;}}let p=null;r&Mi&&c+24<=n&&(p=Xu(t,c),c+=24);let d={x:i,y:a},x=p,y=x?f.map(A=>yi(x,A.x,A.y)):f;x&&({x:i,y:a}=yi(x,i,a));let g=l.length>0?l[0]:s,M=[{offset:0,color:le(s),argb:s},{offset:1,color:le(g),argb:g}],E=null,T=null;if(r&I0){let A=C0(t,c,n);A&&(M=A.stops.map(I=>({...I,offset:1-I.offset})),T={positions:A.stops.map(I=>I.offset),argb:A.stops.map(I=>I.argb??0)},c=A.next);}else if(r&S0){let A=v0(t,c,n);A&&(M=A.entries.map(I=>({offset:1-I.pos,color:Qa(g,s,I.factor),argb:$u(g,s,I.factor)})),E={positions:A.entries.map(I=>I.pos),factors:A.entries.map(I=>I.factor)},c=A.next);}let R=null;r&u2&&c+12<=n&&t.getUint32(c,true)===2&&(R={x:t.getFloat32(c+4,true),y:t.getFloat32(c+8,true)});let P=0;for(let A of y){let I=Math.hypot(A.x-i,A.y-a);I>P&&(P=I);}return P>0?($(`parseEmfPlusBrushObject: path gradient centre=(${i.toFixed(1)},${a.toFixed(1)}), ${f.length} boundary point(s)`),{kind:"plus-brush",color:le(s),gradient:{type:"radial",cx:i,cy:a,r:P,stops:w0(M),wrapMode:o,shape:{center:d,centerArgb:s,boundary:f,source:b,boundaryArgb:m,blend:E,preset:T,focus:R,transform:p}}}):{kind:"plus-brush",color:le(s)}}function $u(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 h2=.25,p2=10;function A0(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 gi(t,e,n,r,o,s=0,i=1,a=0){if(Math.max(A0(e,t,r),A0(n,t,r))<=h2||a>=p2){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;gi(t,c,b,p,o,s,d,a+1),gi(p,h,m,r,o,d,i,a+1);}function d2(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=>[De(b.x),De(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=[];$e(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($u(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 Ei(t,e,n,r,o=e){if(n<8)return null;let s=e+n,i=qr(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:le(t.getUint32(l,true))};case 1:if(l+12<=s){let c=t.getUint32(l+4,true);return {kind:"plus-brush",color:le(c),hatch:{style:t.getUint32(l,true),fore:c,back:t.getUint32(l+8,true)}}}return l+8<=s?{kind:"plus-brush",color:le(t.getUint32(l+4,true))}:{kind:"plus-brush",color:"rgba(0,0,0,1)"};case 2:{let c=r?.get(o);return f2(t,l,s,c)??{kind:"plus-brush",color:"rgba(0,0,0,1)"}}case 4:return m2(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};case 3:return b2(t,l,s)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};default:return {kind:"plus-brush",color:"rgba(0,0,0,1)"}}}function x2(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 ko(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 ar(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 _0(t,e){let n=x2(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=[];gi(ko(e,l),ko(e,c),ko(e,f),ko(e,m),b);for(let h=0;h<b.length-1;h++){let p=ko(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},E=ar(l,c,f,m,h,x).map(R=>R.map(M));if(E.length===0)return;let T=E[0][0];r?i(T):s(T);for(let[R,P,A,I]of E)a(R,P,A,I);}};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 yt=Math.fround;function N0(t,e,n){let r=e.map(m=>yt(m)),o=(m,b)=>De(yt(yt(yt(r[0]*yt(m))+yt(r[2]*yt(b)))+r[4])),s=(m,b)=>De(yt(yt(yt(r[1]*yt(m))+yt(r[3]*yt(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;$e([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 E=Math.cos(d),T=Math.sin(d),R=I=>d===0?I:{x:m+(I.x-m)*E-(I.y-b)*T,y:b+(I.x-m)*T+(I.y-b)*E},P=ar(m,b,h,p,x,M);if(P.length===0)return;let A=R(P[0][0]);a?c(A.x,A.y):l(A.x,A.y);for(let I of P){let[,S,w,C]=I.map(R);f.bezierCurveTo(S.x,S.y,w.x,w.y,C.x,C.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 F0(t){let e=t.pts;return !t.closed||e.length<4?e:[...e,e[0],e[1]]}var k0=32;function y2(t){let e=t.length/2,n=[];for(let r=0;r<e-1;r+=k0-1)n.push(t.slice(2*r,2*Math.min(e,r+k0)));return n}function g2(t,e,n,r,o,s,i){let a=yt(n/16-t/16),u=yt(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=yt(f?yt(b*c)/l:yt(b*l)/c),g=p-h,M=(x-d)*b,E=0,T=0,R=0;if(i){let B=y===0?0:yt(1/y),W=(f?i.x:i.y)*16-8,j=(f?i.x+i.w:i.y+i.h)*16-8,Z=(f?i.y:i.x)*16-8,ut=(f?i.y+i.h:i.x+i.w)*16-8;if(h<W||p>j){if(h>j||p<W)return;if(h<W){let tt=yt(yt((W-h)*y)+d),lt=Math.floor(tt);d=lt,h=W,E=yt(tt-lt);}if(p>j){let tt=yt(yt((j-p)*y)+x),lt=Math.floor(tt);o=true,x=lt,p=j,T=yt(tt-lt);}}let it=b===1,ht=it?d:x,ct=it?x:d;if(ht<Z||ct>ut){if(ht>ut||ct<Z)return;if(ht<Z){let tt=Math.floor(yt(yt(Z-yt(ht+(it?E:T)))*B));it?(h+=tt,d=Z):(p+=tt,x=Z);}if(ct>ut){let tt=Math.floor(yt(yt(ut-yt(ct+(it?T:E)))*B));it?(p+=tt,x=ut):(h+=tt,d=ut),o=true;}}T!==0&&(x&15)===8&&x++,E!==0&&(R=Math.floor(yt(yt(2*g*b)*E)));}let P=f&&g===M,A=P&&b===1,I=A?8:7,S=(B,W)=>{let j=Math.abs(B)+Math.abs(W);return j<8?true:j!==8?false:W===0&&B===(A?-8:8)||B===0&&W===8?true:P&&(A?B<0:B>0)&&W>0},w=h+I&-16,C=p+I&-16,v=S(h-w,d-(d+7&-16)),D=S(p-C,x-(x+7&-16)),_=h&15,U=p&15;m&&!o?(v||_<=8)&&(w+=16):_<=8&&!v&&(w+=16),!m&&!o?(U>8||D)&&(C-=16):!D&&U>8&&(C-=16);let F=w>>4,O=C>>4;if(O<F)return;let H=Math.floor((w-h)*y+d+E),k=H+7&-16,G=k>>4,N=R-((k-H)*b+8)*2*g>>4;if(!i){for(let B=F;B<=O;B++)f?s(B,G):s(G,B),N+=2*M,N>0&&(G+=b,N-=2*g);return}let V=Math.floor((C-p)*y+x+T)+7>>4,z=f?i.x:i.y,st=(f?i.x+i.w:i.y+i.h)-1,at=f?i.y:i.x,Y=(f?i.y+i.h:i.x+i.w)-1,X=(V-G)*b;for(let B=F;B<=O&&X>=0;B++)B>=z&&B<=st&&G>=at&&G<=Y&&(f?s(B,G):s(G,B)),N+=2*M,N>0&&(G+=b,N-=2*g,X--);}var O0=[0,-8,-8,0,0,8,8,0];function B0(t,e){return Math.abs(e)>Math.abs(t)?e<0?1:3:t<0?2:0}function M2(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=B0(o(1)-o(0),s(1)-s(0)),a=m=>O0[2*(m&3)],u=m=>O0[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=B0(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 Ti(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&&!E2(t,e.clip,o)?e.clip:void 0;for(let u of t){let l=F0(u);for(let c=0;c+3<l.length;c+=2)g2(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 y2(F0(o))){let i=M2(s);i.length>=6&&r.push(i);}return se(r,false,e.antialias,e.half,n)}function E2(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 kt(t){return Math.ceil(Math.round(t*256-1e-6)/16)}function G0(t){return Math.floor(t*16+.5-1e-4)}function T2(t){let e=t.map(G0);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 Mn(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=(S,w)=>Math.abs(S-y.pts[g-2])<.001&&Math.abs(w-y.pts[g-1])<.001,E=M(s(m,b),i(m,b))&&M(s(h,p),i(h,p))&&M(s(d,x),i(d,x)),T=S=>kt(S),R=T(y.pts[g-2]),P=T(y.pts[g-1]);y.pts[g-2]=R/16,y.pts[g-1]=P/16,E&&(y.splits??(y.splits=[])).push({x:R/16,y:P/16});let A=[],I=[R,P,T(s(m,b)),T(i(m,b)),T(s(h,p)),T(i(h,p)),T(s(d,x)),T(i(d,x))];$e(I,A);for(let S of A)y.pts.push(S/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 E=Math.cos(d),T=Math.sin(d),R=I=>d===0?I:{x:m+(I.x-m)*E-(I.y-b)*T,y:b+(I.x-m)*T+(I.y-b)*E},P=ar(m,b,h,p,x,M);if(P.length===0)return;let A=R(P[0][0]);r?u(A.x,A.y):a(A.x,A.y);for(let I of P){let[,S,w,C]=I.map(R);l(S.x,S.y,w.x,w.y,C.x,C.y);}}}),n.filter(m=>m.pts.length>=4)}function W0(t,e,n=false){return Mn(t,e).map(r=>(n&&!r.curved?T2(r.pts):null)??r.pts.map(kt)).filter(r=>r.length>=6)}function R2(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 Oo(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 se(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 E=(M+1)%g,T=y[2*M],R=y[2*M+1],P=y[2*E],A=y[2*E+1];R!==A&&b.push({ax:T,ay:R,bx:P,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 E=f+u*(y*i+M);x.length=0;for(let P of b){if(E<P.top||E>=P.bottom)continue;let A=P.by-P.ay,I=P.ax*A+(P.bx-P.ax)*(E-P.ay);A<0&&(A=-A,I=-I);let S=R2(I-c*A,a*A);x.push({k:Math.min(Math.max(S,0),m),w:P.w});}if(x.length<2)continue;x.sort((P,A)=>P.k-A.k),d.fill(0);let T=0;for(let P=0;P+1<x.length;P++)T+=x[P].w,(e?(T&1)!==0:T!==0)&&x[P+1].k>x[P].k&&(d[x[P].k]++,d[x[P+1].k]--);let R=0;for(let P=0;P<m;P++)R+=d[P],R>0&&p[P/s|0]++;}let g=s*i;for(let M=0;M<o.w;M++){let E=p[M];h[y*o.w+M]=E===0?0:E>=g?255:Math.round(E*255/g);}}return h}function H0(t,e,n){let r=[1,0,0,1,0,0],o=null;for(let a of t){let u;try{u=Mn(a.build,r).map(c=>c.pts.map(G0));}catch{return null}let l=se(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 Jr=Math.fround,Be=(t,e)=>L(t+e),ce=(t,e)=>L(t-e),Yt=(t,e)=>L(t*e),ju=(t,e)=>L(t/e),Vu=11920928955078125e-23;function Pi(t,e){let n=ce(Jr(e.x),Jr(t.x)),r=ce(Jr(e.y),Jr(t.y)),o=Be(Yt(r,r),Yt(n,n)),s=0;return o>0&&(s=L(Math.sqrt(o)),n=ju(n,s),r=ju(r,s)),{gx:n,gy:r,len:s}}function P2(t,e){let n=Math.sqrt(t*t+e*e);return n<Vu?0:L(n)}var Ri=Jr(.552284777),A2=[[1,0],[1,Ri],[Ri,1],[0,1],[-Ri,1],[-1,Ri],[-1,0]];function I2(t,e,n,r,o){let s=o?-e.gx:e.gx,i=o?-e.gy:e.gy,a=Be(n,r),u=Yt(ce(n,r),.5),l=Be(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:Be(ce(Yt(b,f),Yt(h,m)),l),y:Be(Be(Yt(h,f),Yt(b,m)),c)})}function X0(t,e,n,r,o){let s=I2(t,e,n,r,o),i=[];for(let a of [.5,-0.5])for(let[u,l]of A2)i.push(s(Be(Yt(u,.5),a),Yt(l,.5)));return i}function Y0(t,e,n){return n<0?{x:Be(t.x,Yt(-n,e.gy)),y:Be(t.y,Yt(-n,-e.gx))}:{x:ce(t.x,Yt(n,e.gy)),y:ce(t.y,Yt(n,-e.gx))}}function $0(t,e,n,r){let o=t.length;if(o<2||n.length===0)return [];let s=0;for(let y of n)s=Be(s,y);if(!(s>0))return [];let i=Jr(r%s);i<0&&(i=Be(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(Pi(t[y-1],t[y]).len);let f,m,b;(f=t[o-1],m=0,b=P2(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))<Vu&&Math.abs(ce(y.y,g.y))<Vu;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=ju(h,b),E={x:Be(Yt(ce(g.x,f.x),M),f.x),y:Be(Yt(ce(g.y,f.y),M),f.y)};b=ce(b,h),u&&(x(f,E)?d&&d.length>1&&p.push(d):(d??(d=[f]),d.push(E),p.push(d)),d=null),f=E,h=n[l%n.length],l++,u=!u;}}return u&&d&&d.length>1&&p.push(d),p}function Bo(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(...ar(t.x,t.y,e,e,n+r*a/s,r/s));for(let[a,u,l,c]of i){let f=[];$e([kt(a.x),kt(a.y),kt(u.x),kt(u.y),kt(l.x),kt(l.y),kt(c.x),kt(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 j0(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 S2=.99;function Zr(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 Z0(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>S2)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,...Bo(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,E=d.y-t.y,T=y*y+g*g,R=M*y+E*g,P=M*M+E*E-h*h,A=Math.max(0,R*R-T*P),I=T===0?0:(-R+Math.sqrt(A))/T;return {x:d.x+y*I,y:d.y+g*I}};return [p(i,m),p(a,m)]}return [i,a]}function V0(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),...Bo(a(y,0),p,d,-Math.PI),a(x,0),...Bo(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),...Bo(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 Ai(t,e,n,r){let o=t.length,s=[],i=e?o:o-1,a=Array.from({length:i},(u,l)=>Zr(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(...Z0(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 w2(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,v2*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 E=g.x-l[M].x,T=g.y-l[M].y;return d?Math.hypot(d[0]*E+d[2]*T,d[1]*E+d[3]*T):Math.hypot(E,T)}),y=g=>x.slice(g+1).reduce((M,E)=>M+E,0);for(let g=0;g+1<l.length;g++){let M=l[g],E=l[g+1],T=x[g],R=0;for(;T-R>m+1e-9;){R+=m;let P={x:M.x+(E.x-M.x)*R/T,y:M.y+(E.y-M.y)*R/T};b&&h?(h.push(P),u.push({pts:h,first:p,last:!e&&s>0&&T-R+y(g)<=n.half+1e-9}),h=null):(h=[P],p=!e&&s>0&&u.length===0&&x.slice(0,g).reduce((A,I)=>A+I,0)+R<=n.half+1e-9),b=!b,f=(f+1)%i.length,m=i[f];}m-=T-R,b&&h&&(h.push(E),r&&g+2<l.length&&r.some(P=>Math.abs(P.x-E.x)<1e-6&&Math.abs(P.y-E.y)<1e-6)&&(u.push({pts:h,first:p,last:false}),h=[E],p=false)),T=0;}return b&&h&&h.length>1&&u.push({pts:h,first:p,last:true}),u.filter(g=>g.pts.length>1)}function C2(t,e){let n=L(e.dashCapWidth??2*e.half),r=L(Math.fround(.001)*n),o=e.dash.map((i,a)=>{let u=L(i);if(a%2===1)return L(u+n);let l=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(),$0(s,true,o,L(L(e.dashOffset)-n)).map(i=>({pts:i,first:false,last:false}))}function z0(t,e,n,r,o){let s=X0({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=[];$e([a,u,l,c].flatMap(m=>[kt(s[m].x),kt(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 q0=20;function J0(t,e,n,r){let o=e?t[t.length-1]:t[0],s=e?t[t.length-2]:t[1],i=Zr(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 Bo(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 K0(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 v2=.001;function Kr(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 L2(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 D2(t,e){let n=Kr(t)>0?1:-1,r=t.length,o=Array.from({length:r},(i,a)=>Zr(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(Kr(s))!==n||s.some(i=>!L2(t,i))}function U2(t,e,n){let r=Kr(t)>0?1:-1,o=t.length,s=Array.from({length:o},(a,u)=>Zr(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(...Z0(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 Yn(t,e){let n=[],r=e.half;for(let o of t){let s=j0(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()),D2(s,2*r)||n.push(U2(s,2*r,e).reverse());continue}e.inset&&i&&(Kr(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?C2(o.pts,e):e.dash?w2(s,i,f,o.splits):[{pts:s,first:true,last:true}],h=!e.dash&&i;for(let p of b){let d=j0(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(J0(d,false,r,e.startCap)),y=0),p.last&&e.endCap>=17&&e.endCap<=19&&(x.push(J0(d,true,r,e.endCap)),g=0),p.first&&e.startCap===q0&&(x.push(K0(d,false,r)),y=0),p.last&&e.endCap===q0&&(x.push(K0(d,true,r)),g=0));for(let[M,E]of l){if(h){n.push(Ai(d,true,E,e)),n.push(Ai(d,true,M,e).reverse());continue}let T=Ai(d,false,E,e),R=Ai(d,false,M,e).reverse(),P=Zr(d[d.length-2],d[d.length-1]),A=Zr(d[1],d[0]),I=g??(p.last&&!(e.dash&&i)?e.endCap:e.dashCap),S=y??(p.first&&!(e.dash&&i)?e.startCap:e.dashCap),w=m?Pi(d[d.length-2],d[d.length-1]):null,C=m?Pi(d[0],d[1]):null,v=w?z0(d[d.length-1],w,M,E,false):V0(d[d.length-1],P,M,E,I,r,e.doubleRoundCap),D=C?z0(d[0],C,M,E,true):V0(d[0],A,-E,-M,S,r,e.doubleRoundCap);if(C&&(T[0]=Y0(d[0],C,E)),I===0&&v.length===2&&T.length>2&&R.length>2){let F=(k,G)=>(k.x-G.x)*P.ux+(k.y-G.y)*P.uy<-1e-9,O=T[T.length-2],H=R[1];F(v[0],O)&&(v[0]={x:O.x,y:O.y}),F(v[1],H)&&(v[1]={x:H.x,y:H.y});}let _=[...T.slice(S===1?1:0,-1),...v,...R.slice(1,-1),...D];n.push(_);let U=Math.sign(Kr(_));for(let F of x)n.push(Math.sign(Kr(F))===U?F:F.slice().reverse());}}}return n}var _2=1,F2=2,Qe=11920928955078125e-23,ot=Math.fround;function zu(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=ot(o.x-a.x);if(Math.abs(u)>=Qe){let l=ot(-a.x/u);if(!(l<-Qe)&&!(ot(l-1)>Qe)){let c=ot(ot(ot(o.y-a.y)*l)+a.y);s=Math.min(s,c);}}o=a;}return s<0?-s:0}function k2(t,e,n,r){let o=ot(e),s=ot(ot(t)*.5),i=[{x:s,y:-o},{x:0,y:0},{x:-s,y:-o}];r&&n!==0&&i.push({x:0,y:ot(ot(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 eb(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=k2(b,h,p,d),y=zu(x.points,x.types);return {kind:"plus-customlinecap",capType:1,baseCap:0,baseInset:b!==0?ot(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=ir(t,l,b);return l+=b,h},f=u&_2?c():null,m=u&F2?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?zu(f.points,f.types):0,strokeLength:m?zu(m.points,m.types):0}}function O2(t,e,n,r){let o=ot(r.x-n.x),s=ot(r.y-n.y),i=Math.sqrt(ot(ot(o*o)+ot(s*s)));if(i<Qe)return null;let a=ot(1/i),u=ot(o*a),l=ot(s*a),c=ot(t.x-n.x),f=ot(t.y-n.y),m=ot(ot(f*f)+ot(c*c)),b=ot(ot(f*l)+ot(c*u));if(b<Qe&&m>=e)return null;let h=e-m+b*b;if(h<Qe)return null;let p=Math.sqrt(h),d=null;if(m>=e){let y=b-p;y>Qe&&y>=0&&(d=y);}if(d===null){let y=p+b;y>Qe&&y>=0&&(d=y);}if(d===null)return null;let x=ot(d);return {x:ot(ot(x*u)+n.x),y:ot(ot(x*l)+n.y)}}function B2(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=ot(g.x-a.x),E=ot(g.y-a.y);if(ot(ot(M*M)+ot(E*E))>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=O2(a,r,t[f],b)??{x:b.x,y:b.y},p=ot(h.x-a.x),d=ot(h.y-a.y),x=Math.sqrt(p*p+d*d);x>Qe?(p=ot(p/x),d=ot(d/x)):(p=0,d=0);let y=ot(1-o);return t[m]={x:ot(ot(ot(a.x-h.x)*y)+h.x),y:ot(ot(ot(a.y-h.y)*y)+h.y)},{x:p,y:d}}function Q0(t,e,n,r){let o=ot(n.y*r),s=ot(-n.x*r),i=ot(n.x*r),a=ot(n.y*r),u=t.points.map(l=>({x:ot(ot(ot(o*l.x)+ot(i*l.y))+e.x),y:ot(ot(ot(s*l.x)+ot(a*l.y))+e.y)}));return {...t,points:u}}function tb(t,e){let n=Mn(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 nb(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=ot(d.widthScale*e),E,T;y?(E=d.fillLength,T=Math.max(M,1)):(E=Math.abs(d.strokeLength)<Qe?1:d.strokeLength,T=M);let R=y&&Math.abs(E)<Qe?0:ot(d.baseInset/E),P=ot(E*T),A=B2(c,f,x,ot(P*P),R),I={x:-A.x,y:-A.y},S=x?b:m;if(y){let w=Q0(g,S,I,Math.max(T,u));for(let C of tb(w,true)){let v=[];for(let D=0;D+1<C.pts.length;D+=2)v.push({x:C.pts[D],y:C.pts[D+1]});a.push(v);}}else {let w=Q0(g,S,I,T),C={half:Math.max(M,1)/2,join:(o.widenJoin??(v=>v))(d.strokeJoin),miterLimit:10,startCap:d.strokeStartCap,endCap:d.strokeEndCap,dashCap:0,dash:null,dashOffset:0,compound:null,inset:false};a.push(...(o.widen??Yn)(tb(w,false),C).map(v=>v.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 rb=1,ob=2,sb=4,ib=8,ab=16,qu=32,ub=64,lb=128,cb=256,mb=512,fb=1024,Ju=2048,bb=4096,No=1024;function hb(t,e,n,r,o=e){if(n<20)return null;let s=e+n,i=qr(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&rb&&(l+24<=s&&(m.transform=[0,4,8,12,16,20].map(b=>t.getFloat32(l+b,true))),l+=24),a&ob&&(m.startCap=c()),a&sb&&(m.endCap=c()),a&ib&&(m.lineJoin=c()),a&ab&&(m.miterLimit=f()),a&qu&&(m.dashStyle=c()??0),a&ub&&(m.dashCap=c()),a&lb&&(m.dashOffset=f()),a&cb){let b=c()??0;b>0&&b<=No&&l+b*4<=s&&(m.dashPattern=Array.from({length:b},(h,p)=>t.getFloat32(l+p*4,true)),a&qu||(m.dashStyle=5)),l+=Math.min(b,No)*4;}if(a&mb&&(m.alignment=c()),a&fb){let b=c()??0;b>=2&&b<=No&&l+b*4<=s&&(m.compound=Array.from({length:b},(h,p)=>t.getFloat32(l+p*4,true))),l+=Math.min(b,No)*4;}for(let b of [Ju,bb])if(a&b){let h=c()??0,p=l+h<=s?eb(t,l,h):null;b===Ju?m.customStartCap=p:m.customEndCap=p,l+=h;}if(l+8<=s){let b=Ei(t,l,s-l,r,o);b&&(m.color=b.color,m.brush=b);}return m}function pb(t,e,n){if(n<20)return null;let r=e+n,o=qr(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,No)*4;};s&rb&&(i+=24);for(let u of [ob,sb,ib,ab,qu,ub,lb])s&u&&(i+=4);s&cb&&a(),s&mb&&(i+=4),s&fb&&a();for(let u of [Ju,bb])if(s&u){let l=i+4<=r?t.getUint32(i,true):0;i+=4+l;}return i+8<=r?i:null}function Ii(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=p0(t,m,u,l,c,f);h?($(` Bitmap(Pixel): decoded successfully, size=${h.byteLength} bytes`),o=h):J(" 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 J(` Metafile: out of bounds or empty (mfStart=0x${c.toString(16)}, mfDataSize=${u}, viewLen=${t.byteLength})`);}return {data:o,type:s}}function db(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=Ke(t,e+24,i)||"sans-serif"),{kind:"plus-font",emSize:r||12,flags:s,family:a,unit:o}}var N2=64*1024*1024;function Si(){return {continuationBuffer:null,continuationObjectId:-1,continuationObjectType:0,continuationTotalSize:0,continuationOffset:0,continuationKey:void 0}}function xb(t){t.continuationBuffer=null,t.continuationObjectId=-1,t.continuationObjectType=0,t.continuationTotalSize=0,t.continuationOffset=0,t.continuationKey=void 0;}function G2(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 W2(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 xb(t),r}function wi(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&&J(`EMFPLUS_OBJECT continuation: object ${t.continuationObjectId} never completed, dropping it`),xb(t),o<4)return null;let u=e.getUint32(r,true),l=e.byteLength-r;if(u<=0||u>N2||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 G2(t,e,r,o),!s||t.continuationOffset>=t.continuationTotalSize?W2(t,i):null}var Xo=5e5;function H2(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=pb(r,t.dataOff,t.dataSize);if(c===null)return;s=c;}let i=qr(r.getUint32(s,true)),a=s+(i?4:0);if(a+8>o||r.getUint32(a,true)!==2)return;let u=U0(r,a+4,o);if(u===null)return;let l=D0(r,u,o);l&&e.push({key:t.cacheKey,view:r,byteStart:l.start,byteEnd:l.end});}function X2(t,e,n,r,o,s){let i=e+n,a=e,u=0;for(;a+12<=i&&u<Xo;){let l=t.getUint16(a,true),c=t.getUint16(a+2,true),f=t.getUint32(a+4,true),m=t.getUint32(a+8,true);if(f<12||a+f>i)break;if(u++,s&&m<=f-12&&s.plus(l,a+12,m),l===16392){let b=wi(r,t,c,a+12,m);b&&o(b);}a+=f;}}function Yo(t,e,n){let r=Si(),o=0,s=t.byteLength,i=0;for(;o+8<=s&&i<Xo;){let a=t.getUint32(o,true),u=t.getUint32(o+4,true);if(u<8||o+u>s)break;if(i++,n?.emf(a,o+8,u),a===70&&u>=16){let l=o+8,c=t.getUint32(l,true);t.getUint32(l+4,true)===726027589&&c>4&&X2(t,l+8,c-4,r,e,n);}else if(a===14)break;o+=u;}}function Y2(t){let e=[];return Yo(t,n=>H2(n,e)),e}async function Qu(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 So(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=wt(a,u);if(!l)return i.close(),null;pe(l.ctx,i.drawable,0,0,a,u),i.close();let c=At(l.ctx,0,0,a,u);return {width:a,height:u,rgba:new Uint8ClampedArray(c.data.buffer.slice(0))}}catch(i){return J("preDecodeEmfPlusTextures: failed to decode a compressed texture image:",i instanceof Error?i.message:i),null}}async function vi(t){let e=new Map,n;try{n=Y2(t);}catch(r){return J("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 Qu(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}Vn();var Rb=1,Pb=2,Ui=24,z2={flags:0,illuminant:0,redGamma:1e4,greenGamma:1e4,blueGamma:1e4,referenceBlack:0,referenceWhite:1e4,contrast:0,brightness:0,colorfulness:0,redGreenTint:0},yb=new Map;function Ab(t){let e=yb.get(t);if(e===void 0){let n=r0(t);if(e=null,n){let r=Uint8Array.from(atob(n),s=>s.charCodeAt(0)),o=su(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;}}yb.set(t,e);}return e}var q2={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 Ib(t){return Ab(t.illuminant)!==null}var ur=Array.from({length:32},(t,e)=>Math.round(e*255/31));function J2(t){let e=Math.round(t*31/255);return ur[e]===t?255*e/31:t}function nl(t){let e=rg(t)*255,n=Math.min(30,Math.floor(e*31/255));for(;n<30&&e>=ur[n+1];)n++;for(;n>0&&e<ur[n];)n--;return n+Math.min(1,Math.max(0,(e-ur[n])/(ur[n+1]-ur[n])))}function K2(t,e,n,r){let o=nl(e),s=nl(n),i=nl(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 Sb(t){return !!t&&!Ib(t)&&t.colorfulness===0&&t.redGreenTint===0}function _i(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 ol(t){return !t||t.flags===0&&!Ib(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 Z2=.0148885,Q2=.95625,tg=1/100,eg=-Math.PI/3,tn=[[.4123908,.3575843,.1804808],[.212639,.7151687,.0721923],[.0193308,.1191948,.9505322]],En=ng(tn),Vo=tn.map(t=>t[0]+t[1]+t[2]),wb=Vo[0]+15*Vo[1]+3*Vo[2],gb=4*Vo[0]/wb,Mb=9*Vo[1]/wb;function ng(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 rg=t=>t<0?0:t>1?1:t,lr=t=>t<0?0:t>255?255:t,Eb=t=>Math.floor(t+.5+1e-7);function og(t,e,n,r,o){let s=tn[0][0]*t+tn[0][1]*e+tn[0][2]*n,i=tn[1][0]*t+tn[1][1]*e+tn[1][2]*n,a=tn[2][0]*t+tn[2][1]*e+tn[2][2]*n,u=s+15*i+3*a;if(u<=1e-9||i<=1e-9)return [lr(t),lr(e),lr(n)];let l=4*s/u-gb,c=9*i/u-Mb,f=Math.cos(o)*r,m=Math.sin(o)*r,b=Math.max(0,gb+l*f-c*m),h=Math.max(1e-6,Mb+l*m+c*f),p=i*9*b/(4*h),d=i*(12-3*b-20*h)/(4*h),x=[En[0][0]*p+En[0][1]*i+En[0][2]*d,En[1][0]*p+En[1][1]*i+En[1][2]*d,En[2][0]*p+En[2][1]*i+En[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 Tb=new Map;function sg(t){if(t.illuminant!==0&&t.illuminant!==6)return null;let e=`${t.colorfulness},${t.redGreenTint}`,n=Tb.get(e);if(n===void 0){let r=o0(e);if(n=null,r){n=new Int8Array(32768*3);for(let o of r)n[o>>1]=o&1?1:-1;}Tb.set(e,n);}return n}function rl(t){let e=Math.round(t*31/255);return ur[e]===t?e:-1}function ig(t){let e=rl(t[0]),n=rl(t[1]),r=rl(t[2]);return e<0||n<0||r<0?-1:(e*32+n)*32+r}function ag(t,e){let n=Ab(t.illuminant),r=q2[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(Z2*t.contrast),u=Q2*t.brightness,l=t.colorfulness!==0||t.redGreenTint!==0,c=1+tg*t.colorfulness,f=eg*t.redGreenTint/100,m=(t.flags&Pb)!==0,b=(t.flags&Rb)!==0,h=l&&e?.chromaTies!==false?sg(t):null,p=(d,x)=>{let y=255*(lr(d)/255)**o[x];return y=(y-s)/i*255,y=y*a+u,m&&(y=255*Math.log2(1+7*lr(y)/255)/3),b&&(y=255-lr(y)),Eb(lr(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?ig(x):-1;if(x=x.map(J2),r){let[g,M,E]=x;x=r.map(T=>T[0]*g+T[1]*M+T[2]*E);}x=og(x[0],x[1],x[2],c,f),x=x.map(Eb),h&&y>=0&&(x=x.map((g,M)=>g+h[y*3+M]));}else if(n){let y=K2(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 Cb(t){let n={...z2,illuminant:t.illuminant,colorfulness:t.colorfulness,redGreenTint:t.redGreenTint},r={...t,illuminant:0,colorfulness:0,redGreenTint:0};return {palette:ol(n)?void 0:n,curves:ol(r)?void 0:r}}function sl(t,e){if(!e||ol(e))return;let n=ag(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;}}function vb(t,e){return null;}async function ul(t,e){}async function Lb(t,e,n){return;}var ll=3;async function cl(t,e=0,n){let r=new Map,o=[],s=vb();try{Yo(t,i=>{if((i.flags>>8&127)!==5||i.dataSize<8)return;let u=Ii(i.view,i.dataOff,i.dataSize,i.flags&255);u.data&&u.data.byteLength>0&&o.push({key:i.cacheKey,type:u.type,data:u.data});},s?.observer);}catch(i){return n?.budget?.throwIfTripped(),J("preDecodeEmfPlusImages: scan failed:",i instanceof Error?i.message:i),s&&await ul(),r}if(s){let i=(n?.maxRecords??0)>Xo&&t.byteLength>=Xo*8;await ul(i?null:s.needs);}for(let i of o){let a=new DataView(i.data,0,i.data.byteLength);if(i.type===2){if(e>=ll)continue;r.set(i.key,{kind:"metafile",caches:await cg(a,e+1,n?.budget)});continue}let u=await Qu(a,0,i.data.byteLength);u&&(r.set(i.key,{kind:"bitmap",...u}),$(`preDecodeEmfPlusImages: decoded image key=0x${i.key.toString(16)}: ${u.width}x${u.height}`));}return r}async function cg(t,e=0,n){return {textures:await vi(t),images:await cl(t,e,{budget:n})}}function Db(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 mg(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),E=l+(g>>1),T=(g&1?c:1-c)*(g>>1?f:1-f);if(T<=0)continue;let R,P;if(m){if(M<0||E<0||M>=n||E>=r)continue;R=M,P=E;}else R=Db(M,n,b),P=Db(E,r,h);let A=(P*n+R)*4,I=o[A+3];p+=T*Math.round(o[A]*I/255),d+=T*Math.round(o[A+1]*I/255),x+=T*Math.round(o[A+2]*I/255),y+=T*I;}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 Zo(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?L(L(L(L(.5*n)+L(.5*o))+i)-.5):i,l=e?L(L(L(L(.5*r)+L(.5*s))+a)-.5):a,c=L(L(n*s)-L(r*o));if(!Number.isFinite(c)||c===0)return null;let f=L(1/c);return [L(s*f),L(-r*f),L(-o*f),L(n*f),L(L(L(o*l)-L(s*u))*f),L(L(L(r*u)-L(n*l))*f)]}function _b(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);ml(t,s+h,i+b,x,y,d);for(let g=0;g<d;g++)mg(x[g],y[g],e,n,r,o,l,(b*a+h+g)*4);h=p;}}}function ml(t,e,n,r,o,s=r.length){if(s<=0)return;let[i,a,u,l,c,f]=t,m=E=>[L(L(L(i*E)+L(u*n))+c),L(L(L(a*E)+L(l*n))+f)],[b,h]=m(e),[p,d]=m(e+s),x=L(L(p-b)/s),y=L(L(d-h)/s),g=b,M=h;for(let E=0;E<s;E++)r[E]=g,o[E]=M,g=L(g+x),M=L(M+y);}var Ub=[1,0,0,1,0,0];function fg(t,e){return (t[e+3]<<24|t[e]<<16|t[e+1]<<8|t[e+2])>>>0}function Fb(t,e,n=Ub){let{width:r,height:o,rgba:s}=e;if(r<=0||o<=0)return null;try{let i=e.transform??Ub,a=(u,l)=>{let c=Math.floor(u),f=Math.floor(l);return c<0||f<0||c>=r||f>=o?null:fg(s,(f*r+c)*4)};return ci(t,{x:0,y:0,w:r,h:o},r,o,e.wrapMode,i,_o(n),{phaseX:0,lagX:0,lagY:0},a)}catch{return null}}var bl=new Float32Array(1),fl=new Uint32Array(bl.buffer);function kb(t){return bl[0]=t,t>0?fl[0]-=1:t<0?fl[0]+=1:fl[0]=2147483649,bl[0]}function rt(t,e){let n=t+e,r=n-t,o=t-(n-r)+(e-r),s=L(n);return Math.fround(n)===n&&o<0?kb(n):s}var $t=(t,e)=>rt(t,-e),q=(t,e)=>L(t*e);function cr(t,e){let n=L(t/e);return (e>0?n*e>t:n*e<t)&&(n=kb(n)),n}var Fi=.000596046448;function hl(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=L(Math.abs(b)*Fi),p=15;return h>l&&h>c?(p=3,Fi>Math.abs($t(e,1))&&Fi>Math.abs($t(o,1))&&(p=1)):h>Math.abs($t(e,o))&&h>Math.abs(rt(r,n))&&(p=Fi>Math.abs($t(rt(q(n,n),q(e,e)),1))?5:7),s===0&&i===0&&(p&=-2),p}function Qo(t,e){let[n,r,o,s,i,a]=t,[u,l,c,f]=e,m=-f,b=-c,h=$t(q(rt(c,u),rt(l,f)),q(l,u)),p=rt(h,$t(q(m,u),q(l,c)));if(!(Math.abs(p)>=11920929e-14))return null;let d=cr(1,p),x=q(rt(q(f,o),q(m,n)),d),y=q(rt(q(f,s),q(m,r)),d),g=q(rt(q(c,i),q(b,n)),d),M=q(rt(q(c,a),q(b,r)),d),E=q(-u,f),T=q(-l,c),R=$t(q(rt(u,c),rt(l,f)),q(u,l)),P=q(rt(rt(q(E,o),q(R,n)),q(T,i)),d),A=q(rt(rt(q(E,s),q(R,r)),q(T,a)),d);return [x,y,g,M,P,A]}function ts(t,e){let n=hl(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(rt(a,f),rt(u,m)):(n&-4)===0?l.push(rt(q(r,f),a),rt(q(i,m),u)):l.push(rt(rt(q(f,r),q(m,s)),a),rt(rt(q(f,o),q(m,i)),u));}return l}function bg(t,e){let n=Qo(t,e);if(!n)return null;let[r,o,s,i]=e;return ts(n,[r,o,rt(r,s),o,r,rt(o,i)])}function ki(t,e){let[n,r,o,s,i,a]=t,[u,l,c,f,m,b]=e;return [rt(q(n,u),q(r,c)),rt(q(n,l),q(r,f)),rt(q(o,u),q(s,c)),rt(q(o,l),q(s,f)),rt(rt(q(i,u),q(a,c)),m),rt(rt(q(i,l),q(a,f)),b)]}function pl(t,e,n){let r=bg(t,e);if(!r)return null;let o=Qo(r,e);return o?ki(o,n):null}function dl(t){let[e,n,r,o,s,i]=t,a=$t(q(e,o),q(n,r));if(!Number.isFinite(a)||a===0)return null;let u=cr(1,a);return [q(o,u),q(-n,u),q(-r,u),q(e,u),q($t(q(r,i),q(o,s)),u),q($t(q(n,s),q(e,i)),u)]}function Ob(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=hl(t),b=T=>m===0?[T,n]:(m&-2)===0?[rt(T,c),rt(n,f)]:(m&-4)===0?[rt(q(T,i),c),rt(q(n,l),f)]:[rt(rt(q(i,T),q(u,n)),c),rt(rt(q(a,T),q(l,n)),f)],[h,p]=b(e),[d,x]=b(e+r),y=cr($t(d,h),r),g=cr($t(x,p),r),M=h,E=p;for(let T=0;T<r;T++)o[T]=M,s[T]=E,M=rt(M,y),E=rt(E,g);}function Bb(t,e,n,r,o,s){let[i,a,u,l,c,f]=t,m=hl(t),b=A=>m===0?[A,n]:(m&-2)===0?[rt(A,c),rt(n,f)]:(m&-4)===0?[rt(q(A,i),c),rt(q(n,l),f)]:[rt(rt(q(i,A),q(u,n)),c),rt(rt(q(a,A),q(l,n)),f)],[h,p]=b(e),[d,x]=b(e+r),y=A=>{let I=Math.floor(rt(q(A,65536),.5));return I>=-2147483648&&I<=2147483647?I:-2147483648},g=(A,I)=>M(cr(q($t(I,A),65536),r)),M=A=>{let I=Math.floor(rt(A,.5));return I>=-2147483648&&I<=2147483647?I:-2147483648},E=y(h),T=y(p),R=g(h,d),P=g(p,x);for(let A=0;A<r;A++)o[A]=E,s[A]=T,E=E+R|0,T=T+P|0;}function hg(t,e){let[n,r,o,s]=t.map(Math.fround),[i,a,u,l]=e.map(Math.fround),c=rt(n,o),f=rt(r,s),m=rt(i,u),b=rt(a,l);if(n===c||r===f)return null;let h=cr($t(m,i),$t(c,n)),p=cr($t(b,a),$t(f,r)),d=$t(m,q(h,c)),x=$t(b,q(p,f));return ts([h,0,0,p,d,x],[n,r,c,r,n,f])}function xl(t,e){let[n,r,o,s]=e.map(Math.fround),i=ts(t,[n,r,rt(n,o),rt(r,s)]);return [i[0],i[1],$t(i[2],i[0]),$t(i[3],i[1])]}function yl(t,e,n){let r=hg(t,e);if(!r)return null;let o=Qo(r,t);return o?ki(o,n):null}var Nb=[[-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 gl(t){return t<64?{first:-2,weights:Nb[t]}:{first:-1,weights:Nb[127-t].slice().reverse()}}var pg=(()=>{let t=new Int32Array(512).fill(Number.NaN);for(let e=0;e<128;e++){let{first:n,weights:r}=gl(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 Oi(t){return t<-256?-32768:t>255?32768:pg[t+256]}var Wb=1/65536;function dg(t){return t<=-128?0:t>=128?65536:32768+(t<0?-(512*-t-2*t*t):512*t-2*t*t)}function xg(t){return t<-256?0:t>255?65536:32768+Oi(t)}var Nt=t=>t|0,Hb=(t,e)=>Math.floor(t*e/65536);function Xb(t){return t>=-32768&&t<=32767}var mr=t=>Nn(mt(Q(t,65536),.5)),Bi=t=>Nn(mt(Q(t,16),.5));function El(t,e,n,r){if(![t,e,n,r].every(Xb))return null;let o=mr(Pt(e,r));if(o===0)return null;let s=Bi(n),i=Bi(mt(Q(e,Pt(r,e)),n)),a=Nt(Math.min(s,i)<<12)>>16,u=Nt(Math.max(s,i)<<12)+65535>>16,l=L(o),c=o<0?et(L(u),mt(r,n)):et(L(a),n),f=Q(Q(c,l),Wb),m=mr(o<0?et(t,f):mt(f,t));return {firstRow:a,yStart:m,yStep:o}}function Yb(t){let[e,n,r,o]=t.src.map(Math.fround),[s,i,a,u]=t.dest.map(Math.fround);if(![e,r,s,a].every(Xb))return null;let l=t.kernel==="cubic"?2:1,c=t.kernel==="cubic"?131072:65536,f=.5,m=mr(Pt(r,a));mr(Pt(a,r));mr(Pt(u,o));let p=El(n,o,i,u);if(m===0||!p)return null;let{firstRow:d,yStart:x,yStep:y}=p,g=Bi(s),M=Bi(mt(Q(r,Pt(a,r)),s)),E=Math.min(g,M),T=Math.max(g,M),R=E+15>>4,P=Nt(E<<12),A=Nt(T<<12),I=K=>L(K),S=I(m),w,C;m<0?(w=I(A+65535>>16),C=mt(s,a)):(w=I(P>>16),C=s);let v=et(C,w);v=Q(v,S),v=Q(v,Wb),v=mt(v,e);let D=mr(v),_=(K,V)=>{let z=mr(Pt(Q(l,K),V));return z<0&&(z=-z),z<c?c:z},U=_(r,a),F=Nn(mt(Q(Pt(65536,I(U)),65536),f)),O=_(o,u),H=Nn(mt(Q(Pt(65536,I(O)),65536),f)),k=(A+65535>>16)-(P>>16)+1,G=2*(O+65535>>16)+1,N=(K,V)=>{let z=V-32768;return z>=-2147483648&&z<=2147483647&&z-K>=-2147483648&&z+K<=2147483647};return !N(U,D)||!N(O,x)?null:{request:t,firstColumn:R,columns:k,firstRow:d,xStart:D,xStep:m,xStretch:U,xRecip:F,yStart:x,yStep:y,yStretch:O,yRecip:H,kernelRows:G,table:t.kernel==="cubic"?xg:dg,shift:t.kernel==="cubic"?8:9,rows:new Map}}function Ml(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 yg(t){return [t>>>16&255,t>>>8&255,t&255,t>>>24]}function $b(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=yg(m),d=f===1||f===3,x=Nt(o-32768),y=[0,0,0,0];for(let g=0;g<r;g++){let M=Nt(i+65535+x),E=M>>16,T=Nt(M-2*i)>>16;y[0]=y[1]=y[2]=y[3]=0;let R=0,P=(_,U,F)=>{let O=u(Nt(_)>>l),H=O-R;R=O,y[0]+=U[F]*H,y[1]+=U[F+1]*H,y[2]+=U[F+2]*H,y[3]+=U[F+3]*H;},A=_=>Hb(Nt(Nt(_<<16)-x),a),I=T<0?0:T,S=E<c-1?E:c-1,w=A(T);for(let _=T;_<Math.min(I,E+1);_++)f===4||!e?P(w,p,0):P(w,e,Ml(_,c,d)*4),w=Nt(w+a);if(I<=S){w=A(I);for(let _=I;_<=S;_++)e?P(w,e,_*4):P(w,p,0),w=Nt(w+a);}let C=Math.max(S+1,T);if(C<=E){w=A(C);for(let _=C;_<=E;_++)f===4||!e?P(w,p,0):P(w,e,Ml(_,c,d)*4),w=Nt(w+a);}let v=g*4,D=Math.max(0,Math.min(255,y[3]+32768>>16));h[v+3]=D;for(let _=0;_<3;_++){let U=y[_]+32768>>16;h[v+_]=b?Math.max(0,Math.min(D,U)):Math.min(255,U);}x=Nt(x+s);}return h}function Gb(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=Ml(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=$b(t,u),t.rows.set(i,a);}return a}function gg(t){let e=t.rows.get(Number.NaN);return e||(e=$b(t,null),t.rows.set(Number.NaN,e)),e}function jb(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=Nt(a-32768+Nt((x-i)*u)),g=Nt(y+l+65535)>>16,M=Nt(y-l+65535)>>16;if(g<M)return null;let E=Hb(Nt(Nt(M<<16)-y),c),T=0,R=[],P=[];for(let S=0;S<f;S++){let w=M+S;if(w>g){P.push(0),R.push(null);continue}let C=m(Nt(E)>>b);P.push(C-T),T=C,E=Nt(E+c),R.push(w>=0&&w<t.request.height?Gb(t,w):t.request.wrap===4||t.request.wrap===void 0?gg(t):Gb(t,w));}let A=t.request.kernel==="cubic",I=new Uint8Array(d*4);for(let S=0;S<d;S++){let w=(h-o+S)*4,C=0,v=0,D=0,_=0;for(let O=0;O<f;O++){let H=R[O];if(!H)continue;let k=P[O];C+=H[w]*k,v+=H[w+1]*k,D+=H[w+2]*k,_+=H[w+3]*k;}let U=S*4,F=Math.max(0,Math.min(255,_+32768>>16));I[U+3]=F;for(let[O,H]of [[0,C],[1,v],[2,D]]){let k=H+32768>>16;I[U+O]=A?Math.max(0,Math.min(F,k)):Math.min(255,k);}}return {x:h,pixels:I}}var Mg={0:"bilinear",1:"bilinear",2:"hq-bicubic",3:"bilinear",4:"bicubic",5:"nearest",6:"hq-bilinear",7:"hq-bicubic"},Eg=new Set([2,4]),Pl=16*1024*1024;function Qb(t){return Mg[t]??"bilinear"}function Re(t){return Eg.has(t)}function th(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 Qr=1e-6,to=1e-9,Tg=1+2**-21,Vb=5e-4,Ue=16;function Rg(t){let e=t.toDevice,n=(l,c)=>[Math.round((e[0]*l+e[2]*c+e[4])*Ue)/Ue,Math.round((e[1]*l+e[3]*c+e[5])*Ue)/Ue],[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 Pg(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*Ue)/Ue,i=Math.round(o*Ue)/Ue,[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 Ag(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 Ig(t){let e=Math.min(1,Math.abs(t));return Math.sign(t)*(e-e*e/2)}function Sg(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 Rl(t){return Math.ceil(t*(1-15e-8))}function qb(t,e){let n=Rl(t)-e;return n>=-1&&n<=1}function Jb(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||!Gi(n.srcW)||!Gi(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 wg=-0.5,Cg=-1;function Ni(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)=>Ag(r-o,wg)};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=>Sg(a,Cg):Ig;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 vg(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,E=0,T=0,R=0;for(let P=0;P<b.length;P++){let A=b[P],I=m+P;if(A===0)continue;let S=es(I,d,x,a?u.mirrorX:u.mirrorY,u);if(S===eo)continue;let w=0,C=0,v=0,D=0;for(let U=0;U<p.length;U++){let F=p[U],O=h+U;if(F===0)continue;let H=es(O,y,g,a?u.mirrorY:u.mirrorX,u);if(H===eo)continue;let k,G=0;H===br||S===br?k=u.clamp??[0,0,0,0]:(k=t,G=(a?H*e+S:S*e+H)*4);let N=k[G+3],K=F*N/255,V=!!u.literal&&k===u.clamp;w+=c||V?F*k[G]:l||f?F*Math.round(N*k[G]/255):K*k[G],C+=c||V?F*k[G+1]:l||f?F*Math.round(N*k[G+1]/255):K*k[G+1],v+=c||V?F*k[G+2]:l||f?F*Math.round(N*k[G+2]/255):K*k[G+2],D+=F*N;}l&&(w=Math.trunc(w),C=Math.trunc(C),v=Math.trunc(v),D=Math.trunc(D)),D=Math.min(255,Math.max(0,D));let _=u.literal&&f?1/0:D;M+=A*Math.min(_,Math.max(0,w)),E+=A*Math.min(_,Math.max(0,C)),T+=A*Math.min(_,Math.max(0,v)),R+=A*D;}return [M,E,T,R]}var eo=-1,br=-2;function eh(t,e){let n=e>>>24;return t==="clamp"&&n>0&&n<255}function es(t,e,n,r,o){if(t>=e&&t<n)return t;if(!o.wrap)return eo;if(o.wrap==="clamp")return br;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 Lg(t){let e=t-Math.floor(t);return e===0?t:Math.floor(t)+1-e}function Rn(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 ft=new Uint8ClampedArray((e+1)*n*4);for(let Mt=0;Mt<n;Mt++)ft.set(t.subarray(Mt*e*4,(Mt+1)*e*4),Mt*(e+1)*4),ft.set(r.rightHalo.subarray(Mt*4,Mt*4+4),(Mt*(e+1)+e)*4);return Rn(ft,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 Rn(t,e,n,{...r,wrap:void 0,clampArgb:void 0},o,s);if(r.kernel==="nearest"&&!r.wrap)return Wg(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:Rg(r),p=r.kernel,d=p==="hq-bilinear"||p==="hq-bicubic";d&&(h[1]!==0||h[2]!==0)&&Math.abs(h[1])<=Vb*Math.abs(h[0])&&Math.abs(h[2])<=Vb*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=Pg(r));let g=p==="bicubic"&&x&&!r.halfPixelOffset&&h[0]===1&&h[3]===1&&Jb(h[4],h[5],r)&&Jb(h[5],h[4],r),E=0,T=0;if(d&&!x){let ft=Math.hypot(h[0],h[1])*r.srcW,Mt=Math.hypot(h[2],h[3])*r.srcH,bt=qb(ft,r.srcW)||qb(Mt,r.srcH);return Gg(t,e,n,r,o,h,p,bt)}let R=p==="bicubic";if(d&&x&&!u){let ft=Og(t,e,n,r,o,h,l);if(ft!==void 0)return ft}if(d&&x){let ft=h[0]*r.srcX+h[4];h=[h[0],0,0,h[3],h[4]+Lg(ft)-ft,h[5]];}let P=th(h);if(!P)return null;let A=Math.max(0,Math.floor(r.srcX)),I=Math.max(0,Math.floor(r.srcY)),S=Math.min(e,Math.ceil(r.srcX+r.srcW)),w=Math.min(n,Math.ceil(r.srcY+r.srcH));if(S<=A||w<=I)return null;let C=1/0,v=1/0,D=-1/0,_=-1/0;for(let[ft,Mt]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 bt=h[0]*ft+h[2]*Mt+h[4],pt=h[1]*ft+h[3]*Mt+h[5];C=Math.min(C,bt),v=Math.min(v,pt),D=Math.max(D,bt),_=Math.max(_,pt);}let U=Math.max(0,Math.floor(C)-1),F=Math.max(0,Math.floor(v)-1),O=Math.min(o.w,Math.ceil(D)+1),H=Math.min(o.h,Math.ceil(_)+1),k=O-U,G=H-F;if(!(k>0&&G>0)||k*G>Pl)return null;let N=c?se([c],false,false,f,{x:U,y:F,w:k,h:G}):b?se([[[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(([ft,Mt])=>[kt(h[0]*ft+h[2]*Mt+h[4]),kt(h[1]*ft+h[3]*Mt+h[5])])],false,false,!!r.halfPixelOffset,{x:U,y:F,w:k,h:G}):null,K=Math.hypot(h[0],h[1]),V=Math.hypot(h[2],h[3]),z=ft=>Math.abs(ft-Math.round(ft))<1e-9,st=x&&Math.abs(K-1)<1e-9&&z(h[4]),at=x&&Math.abs(V-1)<1e-9&&z(h[5]),Y=st&&at,X=Ni(p,K,Y),B=Ni(p,V,Y),W=new Uint8ClampedArray(k*G*4),j=r.halfPixelOffset?.5:0,Z=r.srcX+r.srcW,ut=r.srcY+r.srcH,it=[],ht=[];Math.hypot(P[0],P[2]);Math.hypot(P[1],P[3]);let lt=r.clampArgb??0,dt={wrap:r.wrap,clamp:[lt>>>16&255,lt>>>8&255,lt&255,lt>>>24&255],literal:eh(r.wrap,lt),mirrorX:r.wrap==="tile-flip-x"||r.wrap==="tile-flip-xy",mirrorY:r.wrap==="tile-flip-y"||r.wrap==="tile-flip-xy"},zt=Math.round(P[0]*ie),Se=Math.round(P[1]*ie),Qt=!i&&(p==="bilinear"||p==="bicubic"&&!x)?Zo(h):null,ge=null;if((Qt||i)&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&(p==="bilinear"||p==="bicubic")&&!r.halfPixelOffset&&!r.chainHalf&&!r.wrap){let ft=pl(r.worldPoints,r.chainSrc??[r.srcX,r.srcY,r.srcW,r.srcH],r.worldMatrix);ge=ft&&dl(ft);}else if(i&&r.chainHalf&&r.pointsForm&&r.worldPoints&&r.worldMatrix&&r.chainSrc&&(p==="bilinear"||p==="bicubic")){let ft=r.worldMatrix,Mt=pl(r.worldPoints,r.chainSrc,[ft[0],ft[1],ft[2],ft[3],L(ft[4]-.5),L(ft[5]-.5)]);ge=Mt&&dl(Mt);}let _n=new Float64Array(k),Fn=new Float64Array(k),me=new Int32Array(k),_r=new Int32Array(k),ze=0,Ka=(ft,Mt)=>{let bt=ft+Qr,pt=Mt+to,Ot=P[0]*bt+P[2]*pt+P[4],Ct=P[1]*bt+P[3]*pt+P[5];return !(Ot<r.srcX||Ct<r.srcY||Ot>=Z||Ct>=ut)};Qt&&!ge&&r.pointsForm&&p==="bilinear"&&x&&(Qt[0]=Math.fround(1/Math.fround(h[0])));for(let ft=0;ft<G;ft++){let Mt=F+ft+j,bt=-1,pt=0,Ot=0,Ct=0,te=0,_e=0;for(let Et=0;Et<k;Et++){let fe=U+Et+j,St=P[0]*(fe-E)+P[2]*(Mt-T)+P[4],Tt=P[1]*(fe-E)+P[3]*(Mt-T)+P[5],we=fe+Qr,Ce=Mt+to,be=P[0]*we+P[2]*Ce+P[4],ee=P[1]*we+P[3]*Ce+P[5];if(N?!N[ft*k+Et]:be<r.srcX||ee<r.srcY||be>=Z||ee>=ut)continue;if(ge){if(bt<0){bt=Et,ze=Et;let qt=Et+1;for(;qt<k&&(N?N[ft*k+qt]!==0:Ka(U+qt+j,Mt));)qt++;R?Bb(ge,U+Et,F+ft,qt-Et,me,_r):Ob(ge,U+Et,F+ft,qt-Et,_n,Fn);}R?(St=(me[Et-ze]+m*ie)/ie,Tt=(_r[Et-ze]+m*ie)/ie):(St=_n[Et-ze]+m,Tt=Fn[Et-ze]+m);}else if(Qt){if(bt<0){bt=Et,_e=Et;let qt=Math.fround(r.toDevice[0]*r.srcX+r.toDevice[2]*r.srcY+r.toDevice[4]),Je=Math.fround(r.toDevice[1]*r.srcX+r.toDevice[3]*r.srcY+r.toDevice[5]),kn=L(fe-qt),hn=L(Mt-Je);Ct=L(L(L(Qt[0]*kn)+L(Qt[2]*hn))+Math.fround(r.srcX)),te=L(L(L(Qt[1]*kn)+L(Qt[3]*hn))+Math.fround(r.srcY));}for(;_e<Et;_e++)Ct=L(Ct+Qt[0]),te=L(te+Qt[1]);St=Ct,Tt=te,r.pointsForm&&p==="bilinear"&&x&&(Tt=r.srcY+(te-r.srcY)*Tg);}R&&(ge||Qt?(St=Math.floor(St*64)/64,Tt=Math.floor(Tt*64)/64):(bt<0&&(bt=Et,pt=Math.round(St*ie),Ot=Math.round(Tt*ie)),St=Math.floor((pt+(Et-bt)*zt)/(ie/64))/64,Tt=Math.floor((Ot+(Et-bt)*Se)/(ie/64))/64),g&&(St=Math.round(St),Tt=Math.round(Tt)));let Fe={x0:0,y0:0,x1:e,y1:n},Dt=(qt,Je)=>{let kn=Math.ceil(qt-X.radius),hn=Math.floor(qt+X.radius),Zm=Math.ceil(Je-B.radius),xx=Math.floor(Je+B.radius);it.length=0,ht.length=0;for(let pn=kn;pn<=hn;pn++)it.push(R?Math.round(X.weight(pn,qt)*65536)/65536:X.weight(pn,qt));for(let pn=Zm;pn<=xx;pn++)ht.push(R?Math.round(B.weight(pn,Je)*65536)/65536:B.weight(pn,Je));return vg(t,e,Fe,kn,it,Zm,ht,p==="bicubic",dt,R,u,p==="bilinear")};p==="bilinear"&&(St=Math.floor(St)+Math.round((St-Math.floor(St))*2048)/2048,Tt=Math.floor(Tt)+Math.round((Tt-Math.floor(Tt))*2048)/2048);let[Me,Ee,ke,ve]=Dt(St,Tt);if(ve<=0)continue;if(R){if(Me=Math.trunc(Me),Ee=Math.trunc(Ee),ke=Math.trunc(ke),ve=Math.trunc(ve),ve<=0)continue}else if((u||p==="bilinear")&&(Me=Math.round(Me),Ee=Math.round(Ee),ke=Math.round(ke),ve=Math.round(ve),ve<=0))continue;let ln=Math.min(255,ve),qe=(ft*k+Et)*4;W[qe]=Math.min(Math.max(0,Me),ln)*255/ln,W[qe+1]=Math.min(Math.max(0,Ee),ln)*255/ln,W[qe+2]=Math.min(Math.max(0,ke),ln)*255/ln,W[qe+3]=ln;}}return {x:U,y:F,w:k,h:G,rgba:W}}var fr=128;function Gi(t){return Number.isInteger(t)&&t>0&&(t&t-1)===0}function nh(t){return !t.pointsForm||Gi(t.srcW)&&Gi(t.srcH)}function Dg(t,e,n){return nh(t)?e===1?-(n?2:1)*65536+(t.kernel==="hq-bicubic"?1:0):0:e<=1?1:0}function Kb(t){return t<1?rh(65536/t):Math.round(65536/t)}var Ug=.027;function rh(t){return Math.floor(t+.5+Ug)}function Zb(t){return t>512?0:t>256?2:t>64?1:0}var _g=.9375-1e-9;function Fg(t){return t<=-128?-32768:t>=128?32768:t<0?-(512*-t-2*t*t):512*t-2*t*t}function kg(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?Oi(g):Fg(g);x>b&&p.push((M-d)/65536),d=M;}a.push({first:b,weights:p});}return a}function Og(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=bt=>Math.abs(bt-Math.round(bt))<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:L(L(Math.fround(r.toDevice[0])*r.srcX)+L(r.toDevice[4]))-b,y=u?Math.round(d*Ue)/Ue:Math.min(h,p),g=s[3]*r.srcY+s[5]-b,M=u?y+l*r.srcW:Math.max(h,p),E=g+s[3]*r.srcH,T=u?.5:Math.ceil(x*Ue-.5)/Ue,R=!u&&Number.isInteger(T)&&x-T>1e-5,P=!u&&Number.isInteger(T)&&T-x>1e-5,A=Math.ceil(R?x-Qr:y-Qr),I=Math.ceil(R?x+l*r.srcW-Qr:M-Qr)-1,S=L(L(Math.fround(r.toDevice[3])*r.srcY)+L(r.toDevice[5]))-b,w=Math.ceil(S*Ue-.5)/Ue,C=Number.isInteger(w)&&S-w>1e-5,v=Math.ceil(C?S-to:g-to),D=Math.ceil(C?S+s[3]*r.srcH-to:E-to)-1,_=Math.max(0,A),U=Math.max(0,v),F=Math.min(o.w-1,I),O=Math.min(o.h-1,D);if(F<_||O<U)return null;let H=F-_+1,k=O-U+1;if(H*k>Pl)return null;let G=Bg(t,e,n,r,_,U,H,k,i);if(G)return G;let N=a==="hq-bicubic",K=N?.5:1,V=Kb(l),z=Kb(c),st=r.nominalScale;if(st&&!u&&Math.abs(st[0]/l-1)<1e-5&&Math.abs(st[1]/c-1)<1e-5){let bt=Math.fround,pt=bt(1/bt(st[0]*st[1])),Ot=(Ct,te)=>te<1?rh(Ct):Math.round(Ct);V=Ot(65536*bt(st[1]*pt),l),z=Ot(65536*bt(st[0]*pt),c);}let at=A-x,Y=at<1e-5?0:at,X=Math.max(0,v-S);if(u&&(r.halfPixelOffset||!f(r.srcX)||!f(r.srcW)))return;let B=I-A+1+Y,W=x-Math.floor(x),j=u?0:R?Math.round((1+W)*V):P?Math.round((W-1)*V):Y>1e-9?Math.round((1-Y)*V):0,Z=X>1e-9?Math.round(X*z):0,ut=r.srcY+r.srcH,it;if(c===1&&!N&&!u&&!r.wrap&&!r.halfPixelOffset&&ut+1<n&&f(r.srcY)&&f(r.srcH)&&r.worldMatrix&&r.worldRect){let bt=[r.srcX,r.srcY,r.srcW,r.srcH],pt=yl(bt,r.worldRect,r.worldMatrix),Ot=pt&&xl(pt,bt);if(Ot&&Ot[3]>=r.srcH){it=ut;let Ct=El(r.srcY,r.srcH,Ot[1],Ot[3]);Ct&&Ct.yStep===z&&(Z=Ct.yStart-r.srcY*65536+(v-Ct.firstRow)*z);}}let ht=x-Math.floor(x),ct=u||ht>=_g?0:-Zb(x),tt=Zb(S),lt=Ni(a,l,false),dt=Ni(a,c,false),zt=(bt,pt,Ot,Ct,te,_e,Et,fe,St=false)=>{let Tt=[],we=((pt&pt-1)===0?0:Math.round(r.srcW/170))+(St?Dg(r,Et,Y>1e-9):0),Ce=Dt=>St?Math.round((B-Dt)*pt)+we:Dt*pt+Ot;if(St&&m&&Y<=1e-9&&nh(r)){for(let Dt=te;Dt<=_e;Dt++)Tt.push({first:Math.round(Ct+Ce(Dt)/65536),weights:[1]});return Tt}let be=Ct*fr,ee=Math.abs(be-Math.round(be))<1e-6;if(Et<1&&ee)return kg(N,Et,pt,Dt=>Ce(Dt)+fe,Ct,te,_e);let Fe=N&ⅇfor(let Dt=te;Dt<=_e;Dt++){let Me=Math.floor((Ce(Dt)-1)/(65536/fr));if(Fe){let qe=Math.round(be)+Me,qt=gl((qe%fr+fr)%fr);Tt.push({first:Math.floor(qe/fr)+qt.first,weights:qt.weights.map(Je=>Je/65536)});continue}let Ee=Ct+(Me+K)/fr,ke=Math.ceil(Ee-bt.radius),ve=Math.floor(Ee+bt.radius),ln=[];for(let qe=ke;qe<=ve;qe++)ln.push(bt.weight(qe,Ee));Tt.push({first:ke,weights:ln});}return Tt},Se=zt(lt,V,j,r.srcX,_-A,F-A,l,ct,u),Qt=zt(dt,z,Z,r.srcY,U-v,O-v,c,tt),ge=1/0,_n=-1/0;for(let bt of Qt)ge=Math.min(ge,bt.first),_n=Math.max(_n,bt.first+bt.weights.length-1);let Fn=r.clampArgb??0,me=r.wrap?{wrap:r.wrap,clamp:[Fn>>>16&255,Fn>>>8&255,Fn&255,Fn>>>24&255],literal:eh(r.wrap,Fn),mirrorX:r.wrap==="tile-flip-x"||r.wrap==="tile-flip-xy",mirrorY:r.wrap==="tile-flip-y"||r.wrap==="tile-flip-xy"}:null;me||(ge=Math.max(0,ge),_n=Math.min(n-1,_n));let _r=Math.max(0,_n-ge+1),ze=Math.abs(c-1)<1e-9?1/0:Math.ceil((N?2:1)/Math.min(1,c)),Ka=it??ut+ze-1,ft=new Uint8Array(_r*H*4);for(let bt=0;bt<_r;bt++){let pt=ge+bt;if(me&&(Number.isFinite(ze)&&(pt=es(pt,Math.max(0,r.srcY-ze),Math.min(n,r.srcY+r.srcH+ze),me.mirrorY,me)),pt!==eo&&pt!==br&&(pt=es(pt,0,n,me.mirrorY,me))),pt===eo||pt!==br&&(pt<r.srcY-ze||pt>Ka))continue;let Ot=pt*e;for(let Ct=0;Ct<H;Ct++){let te=Se[Ct],_e=0,Et=0,fe=0,St=0;for(let be=0;be<te.weights.length;be++){let ee=te.first+be,Fe=t,Dt=0;if(me){if(ee=es(ee,0,e,me.mirrorX,me),ee===eo)continue}else if(ee<0||ee>=e)continue;ee===br||pt===br?Fe=me?.clamp??[0,0,0,0]:Dt=(Ot+ee)*4;let Me=Fe[Dt+3];if(Me===0)continue;let Ee=te.weights[be],ke=!!me?.literal&&Fe===me.clamp;_e+=Ee*(ke?Fe[Dt]:Math.round(Fe[Dt]*Me/255)),Et+=Ee*(ke?Fe[Dt+1]:Math.round(Fe[Dt+1]*Me/255)),fe+=Ee*(ke?Fe[Dt+2]:Math.round(Fe[Dt+2]*Me/255)),St+=Ee*Me;}let Tt=Math.min(255,Math.max(0,Math.round(St))),we=(bt*H+Ct)*4,Ce=me?.literal?255:Tt;ft[we]=Math.min(Ce,Math.max(0,Math.round(_e))),ft[we+1]=Math.min(Ce,Math.max(0,Math.round(Et))),ft[we+2]=Math.min(Ce,Math.max(0,Math.round(fe))),ft[we+3]=Tt;}}let Mt=new Uint8ClampedArray(H*k*4);for(let bt=0;bt<k;bt++){let pt=Qt[bt];for(let Ot=0;Ot<H;Ot++){let Ct=0,te=0,_e=0,Et=0;for(let we=0;we<pt.weights.length;we++){let Ce=pt.first+we-ge;if(Ce<0||Ce>=_r)continue;let be=(Ce*H+Ot)*4,ee=pt.weights[we];Ct+=ee*ft[be],te+=ee*ft[be+1],_e+=ee*ft[be+2],Et+=ee*ft[be+3];}let fe=Math.min(255,Math.max(0,Math.round(Et)));if(fe===0)continue;let St=(bt*H+Ot)*4,Tt=i?1:255/fe;Mt[St]=Math.min(fe,Math.max(0,Math.round(Ct)))*Tt,Mt[St+1]=Math.min(fe,Math.max(0,Math.round(te)))*Tt,Mt[St+2]=Math.min(fe,Math.max(0,Math.round(_e)))*Tt,Mt[St+3]=fe;}}return {x:_,y:U,w:H,h:k,rgba:Mt,premultiplied:i}}function Bg(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?Qo(r.worldPoints,c):null,m=r.worldRect?yl(c,r.worldRect,l):f?ki(f,l):null;if(!m||!(m[0]>0&&m[3]>0))return;let b=xl(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=Yb({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=jb(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),E=M[3];if(E===0)continue;let T=(x*i+y.x-o+g)*4,R=u?1:255/E;d[T]=M[0]*R,d[T+1]=M[1]*R,d[T+2]=M[2]*R,d[T+3]=E;}}return {x:o,y:s,w:i,h:a,rgba:d,premultiplied:u}}function Ng(t,e){let n=ts(e,t),r=(o,s)=>Math.ceil(Co(rt(Q(s,s),Q(o,o))));return [r(rt(n[2],-n[0]),rt(n[3],-n[1])),r(rt(n[4],-n[0]),rt(n[5],-n[1]))]}function Gg(t,e,n,r,o,s,i,a){let u=!!(r.pointsForm&&r.worldPoints&&r.worldMatrix&&!r.wrap),l=u?Ng(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,E=r.halfPixelOffset,T=0,R=0;if(c){b=e+2*f,h=n+2*f,m=new Uint8ClampedArray(b*h*4);for(let S=0;S<n;S++)for(let w=0;w<e;w++){let C=(S*e+w)*4,v=t[C+3],D=((S+f)*b+w+f)*4;m[D]=Math.round(t[C]*v/255),m[D+1]=Math.round(t[C+1]*v/255),m[D+2]=Math.round(t[C+2]*v/255),m[D+3]=v;}[p,d,x,y]=s,g=s[4]-(E?.5:0),M=s[5]-(E?.5:0);}else {let S=l?l[0]:Rl(Math.hypot(s[0],s[1])*r.srcW),w=l?l[1]:Rl(Math.hypot(s[2],s[3])*r.srcH);T=S,R=w;let C=S/r.srcW,v=w/r.srcH,D=Rn(t,e,n,{srcX:r.srcX,srcY:r.srcY,srcW:r.srcW,srcH:r.srcH,toDevice:[C,0,0,v,-r.srcX*C,-r.srcY*v],kernel:i,halfPixelOffset:false,wrap:r.wrap,clampArgb:r.clampArgb},{w:S,h:w},{premultOut:true});if(!D)return null;if(!D.premultiplied)for(let F=0;F<D.rgba.length;F+=4){let O=D.rgba[F+3];D.rgba[F]=Math.round(D.rgba[F]*O/255),D.rgba[F+1]=Math.round(D.rgba[F+1]*O/255),D.rgba[F+2]=Math.round(D.rgba[F+2]*O/255);}b=S+2*f,h=w+2*f,m=new Uint8ClampedArray(b*h*4);for(let F=0;F<D.h;F++)for(let O=0;O<D.w;O++){let H=O+D.x,k=F+D.y;H<S&&k<w&&m.set(D.rgba.subarray((F*D.w+O)*4,(F*D.w+O)*4+4),((k+f)*b+H+f)*4);}p=s[0]/C,d=s[1]/C,x=s[2]/v,y=s[3]/v;let _=s[0]*r.srcX+s[2]*r.srcY+s[4],U=s[1]*r.srcX+s[3]*r.srcY+s[5];g=E?_-.5+.5*(p+x):_,M=E?U-.5+.5*(d+y):U;}let P=[[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(([S,w])=>[kt(s[0]*S+s[2]*w+s[4]),kt(s[1]*S+s[3]*w+s[5])]),A=Rn(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]:[E?-0.5:0,E?-0.5:0,T,R],...E?{chainHalf:true}:{}}:{}},o,{plainRotated:true,keepOrigin:true,premultSource:true,...u?{rasterQuad:P,rasterHalf:E,chainPad:f}:{}});if(!A)return A;let I=se([P],false,false,E,{x:A.x,y:A.y,w:A.w,h:A.h});for(let S=0;S<A.w*A.h;S++)I[S]||A.rgba.fill(0,S*4,S*4+4);return A}var ie=65536;function Wg(t,e,n,r,o){let s=r.toDevice,i=th(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(([v,D])=>[s[0]*v+s[2]*D+s[4],s[1]*v+s[3]*D+s[5]]),m=1/0,b=1/0,h=-1/0,p=-1/0;for(let[v,D]of f)m=Math.min(m,v),b=Math.min(b,D),h=Math.max(h,v),p=Math.max(p,D);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,E=g-x;if(!(M>0&&E>0)||M*E>Pl)return null;let T={x:d,y:x,w:M,h:E},R=se([f.flatMap(([v,D])=>[kt(v),kt(D)])],false,false,r.halfPixelOffset,T),P=Math.max(0,Math.floor(u)),A=Math.min(n,Math.ceil(u+c)),I=r.halfPixelOffset?.5:0,S=Math.round(i[0]*ie),w=Math.round(i[1]*ie),C=new Uint8ClampedArray(M*E*4);for(let v=0;v<E;v++){let D=x+v+I,_=-1,U=0,F=0;for(let O=0;O<M;O++){if(!R[v*M+O])continue;if(_<0){let V=d+O+I;_=O,U=Math.round((i[0]*V+i[2]*D+i[4])*ie),F=Math.round((i[1]*V+i[3]*D+i[5])*ie);}let H=O-_,k=Math.floor((U+H*S+ie/2)/ie),G=Math.floor((F+H*w+ie/2)/ie);if(k<0||k>=e||G<P||G>=A)continue;let N=(G*e+k)*4,K=(v*M+O)*4;C[K]=t[N],C[K+1]=t[N+1],C[K+2]=t[N+2],C[K+3]=t[N+3];}}return {x:d,y:x,w:M,h:E,rgba:C}}var Wi=1<<24;function sh(t,e,n,r){return {cmds:[{op:"rect",x:t,y:e,w:n,h:r}],fillRule:"nonzero",simple:true}}function cn(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 Ne(){return {cmds:[{op:"rect",x:0,y:0,w:0,h:0}],fillRule:"nonzero",simple:true}}function Hg(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 pr(t,e,n){return t?t.map(r=>Hg(r,e,n)):null}function Al(t){return t.simple&&t.fillRule==="nonzero"}function hr(t){return t.fillRule==="evenodd"||Al(t)}function oh(t){let e=0;for(let n of Vr(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 Xg(t,e){if(!Al(t)||!Al(e))return false;let n=oh(t),r=oh(e);return !Number.isNaN(n)&&!Number.isNaN(r)&&(n===0||r===0||n===r)}function ns(t){return {cmds:[{op:"rect",x:-Wi,y:-Wi,w:2*Wi,h:2*Wi},...t.cmds],fillRule:"evenodd",simple:false}}var Yg={x:1<<23,y:1<<23,w:1,h:1};function Pn(t,e,n,r){let o=r??E0(t,e),s=sr(t,e,n,o),i=!P0(o);return !r&&sr(t,e,n,Yg).length>0&&(i=false),{region:[s.length>0?cn(s):Ne()],exact:i}}function Il(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(hr(e)){let o=ns(e);return {region:t?[...t,o]:[o],exact:true}}return Pn(t,[e],n,r)}case "union":return t?t.length===1&&Xg(t[0],e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"nonzero",simple:false}],exact:true}:Pn(t,[e],n,r):{region:null,exact:true};case "xor":return t?t.length===1&&hr(t[0])&&hr(e)?{region:[{cmds:[...t[0].cmds,...e.cmds],fillRule:"evenodd",simple:false}],exact:true}:Pn(t,[e],n,r):hr(e)?{region:[ns(e)],exact:true}:Pn(t,[e],n,r);case "complement":return t?t.length===1&&hr(t[0])?{region:[e,ns(t[0])],exact:true}:Pn(t,[e],n,r):{region:[Ne()],exact:true}}}function Sl(t,e,n,r){if(n==="replace")return {region:e,exact:true};if(e&&e.length===1)return Il(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:[Ne()],exact:true};case "xor":case "complement":return t?t.length===1&&hr(t[0])?{region:[ns(t[0])],exact:true}:Pn(t,e,n,r):{region:[Ne()],exact:true}}switch(n){case "intersect":return {region:t?[...t,...e]:e,exact:true};case "union":return t?Pn(t,e,n,r):{region:null,exact:true};case "complement":return t?t.length===1&&hr(t[0])?{region:[...e,ns(t[0])],exact:true}:Pn(t,e,n,r):{region:[Ne()],exact:true};case "xor":case "exclude":return Pn(t,e,n,r)}}function rs(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 $g(t,e){for(let n of e){t.beginPath(),rs(t,n.cmds);try{t.clip(n.fillRule);}catch{}}}function je(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),$g(r,e));}var jg=[[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]],ih=234,ah=64;function Vg(t,e,n){let r=()=>{let s=((e-n)%8+8)%8;return s===0?ih:s===1||s===7?ah:0},o=()=>{let s=((e+n-7)%8+8)%8;return s===0?ih:s===1||s===7?ah:0};switch(t){case 2:return r();case 3:return o();case 5:return Math.max(r(),o());default:{let s=jg[t];return s&&s[n]&128>>e?256:0}}}function zg(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 uh(t){let e=new Uint8ClampedArray(256);for(let n=0;n<8;n++)for(let r=0;r<8;r++){let o=zg(t.fore,t.back,Vg(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 lh(t,e,n){let r=uh(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 ch(t,e,n,r,o){if(typeof t.createPattern!="function")return null;let s=wt(8,8);if(!s)return null;Lt(s.ctx,Rt(uh(e),8,8),0,0);let i=Qs(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}function It(t){return false}function Pe(t){return true}function TM(t,e,n){let r=L,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 An(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 Ge(t,e,n){if(e&32768)return le(n);let r=t.objectTable.get(n&255);return r&&r.kind==="plus-brush"?Cl(t,r):"rgba(0,0,0,1)"}function Cl(t,e){if(e.gradient){let n=Zf(t.ctx,e.gradient,_t(t));if(n)return n}if(e.texture){let n=Fb(t.ctx,e.texture,_t(t));if(n)return n}if(e.hatch){let n=ch(t.ctx,e.hatch,t.ext?.renderingOrigin??{x:0,y:0},_t(t),ji(t));if(n)return n}return e.color}var wl=0,Yi=1,RM=6,xr=96;function yr(t,e,n=xr,r=true){let o;switch(t){case Yi: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 PM(t){let e=t.videoDisplay??true;return [yr(t.pageUnit,t.pageScale,t.dpiX??xr,e),yr(t.pageUnit,t.pageScale,t.dpiY??xr,e)]}function _t(t){let e=$i(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 In(t){return t.ext||(t.ext={}),t.ext}function $i(t){let e=t.ext;if(e?.tsDevice)return e.tsDevice;let n=t.worldTransform,[r,o]=PM(t),s=[n[0]*r,n[1]*o,n[2]*r,n[3]*o,n[4]*r,n[5]*o];return e?.containerTransform?An(s,e.containerTransform):s}function ji(t){let e=t.dpiScale,n=[e,0,0,e,0,0];return t.baseTransform?An(n,t.baseTransform):n}function de(t,e=true){let n=_t(t),r=e?vl(t):0;t.ctx.setTransform(n[0],n[1],n[2],n[3],n[4]+r,n[5]+r);}function vl(t){return It(t.ctx)?0:t.antiAlias&&!Re(t.pixelOffsetMode??0)?.5:0}function ph(t,e){let n=In(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 mh(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=In(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&&no(t);}}function fh(t,e,n){let r=$i(t),o=Xi(t.ext?.containerClip,t.clipRegion);ph(t,e);let s=In(t);s.containerTransform=n?An(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=Yi,t.pageScale=1,t.antiAlias=false,t.interpolationMode=void 0,t.pixelOffsetMode=void 0,t.textRenderingHint=void 0,no(t);}function AM(t,e,n,r=xr,o=xr,s=true){let i=n===wl?r/100:yr(n,1,r,s),a=n===wl?o/100:yr(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 Xi(t,e){let n=[...t??[],...e??[]];return t||e?n:null}function Hi(t){return _t(t)}function dh(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 IM(t,e){return Wu(t.path,e)}var SM={0:"intersect",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"},bh=64;function os(t,e,n=0,r){if(n>bh)return {region:[Ne()],exact:false};switch(t.type){case "rect":return {region:[dh(t.x,t.y,t.width,t.height,e)],exact:true};case "path":return {region:[IM(t,e)],exact:true};case "infinite":return {region:null,exact:true};case "empty":return {region:[Ne()],exact:true};case "combine":{let o=os(t.left,e,n+1,r),s=os(t.right,e,n+1,r),i=SM[t.combineMode]??"intersect",a=Sl(o.region,s.region,i,r);return {region:a.region,exact:a.exact&&o.exact&&s.exact}}}}var wM={0:"replace",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"};function Ll(t){if(!(t.canvasW===void 0||t.canvasH===void 0))return {x:0,y:0,w:t.canvasW,h:t.canvasH}}function xh(t){let e=t.ext;return Xi(Xi(e?.containerClip,t.clipRegion??void 0)??void 0,e?.tsClip??void 0)}function no(t){je(t,xh(t),true);}function yh(t,e){let n=Ll(t);if(t.gdiAntialias===true||!e||!n||It(t.ctx))return e;let r=Re(t.pixelOffsetMode??0),o=H0(e.map(a=>({build:u=>rs(u,a.cmds),evenOdd:a.fillRule==="evenodd"})),n,r);if(o)return [cn(o)];let s=(r?0:.5)-1/32,i=pr(e,s,s);return [cn(sr(i,null,"intersect",n))]}function gh(t,e,n,r){let o=yh(t,e),s=wM[n];let i=Sl(t.clipRegion??null,o,s??"intersect",Ll(t));i.exact||J(`${r}: CombineMode ${n} approximated (no canvas domain for an unbounded result)`),t.clipRegion=i.region,no(t);}function hh(t,e,n,r){gh(t,[e],n,r);}function dr(t){t.ext?.tsDevice&&(t.ext.tsDevice=null);}function CM(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=In(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 vM(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 LM(t,e,n,r){let o=vM(t.view,n,r,e);if(!o)return;let s=ji(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}:Ne(),c=In(t);c.tsClip=Xi(xh(t)??void 0,yh(t,[l])??void 0),no(t);}function Mh(t,e,n,r,o){let{view:s}=t;switch(e){case 16426:return dr(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 dr(t),t.worldTransform=[1,0,0,1,0,0],true;case 16428:{if(dr(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=An(t.worldTransform,i):t.worldTransform=An(i,t.worldTransform);}return true}case 16429:{if(dr(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=An(t.worldTransform,u):t.worldTransform=An(u,t.worldTransform);}return true}case 16430:{if(dr(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=An(t.worldTransform,u):t.worldTransform=An(u,t.worldTransform);}return true}case 16431:return dr(t),o>=4&&(t.worldTransform=TM(t.worldTransform,s.getFloat32(r,true),(n&8192)!==0)),true;case 16421:return o>=4&&ph(t,s.getUint32(r,true)),true;case 16422:return o>=4&&mh(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=dh(a,u,l,c,Hi(t));hh(t,f,i,"SetClipRect");}return true}case 16433:return t.clipRegion=null,no(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=os(u.nodes[0],Hi(t),0,Ll(t));l.exact||J("SetClipRegion: region tree approximated (no canvas domain for an unbounded result)"),gh(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=Wu(u,Hi(t));hh(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=pr(t.clipRegion,l,c),no(t);}}return true}case 16424:return o>=4&&fh(t,s.getUint32(r,true),null),true;case 16423:{if(o>=36){let i=u=>s.getFloat32(r+u,true),a=AM({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);fh(t,s.getUint32(r+32,true),a??[1,0,0,1,0,0]);}return true}case 16425:return o>=4&&mh(t,s.getUint32(r,true)),true;case 16432:{dr(t);let i=n&255,a=o>=4?s.getFloat32(r,true):1;return i===wl||i>RM||!(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 In(t).compositingQuality=n&255,true;case 16419:return In(t).compositingMode=n&255,true;case 16413:return o>=8&&(In(t).renderingOrigin={x:s.getInt32(r,true),y:s.getInt32(r+4,true)}),true;case 16416:return In(t).textContrast=n&4095,true;case 16441:return CM(t,r,o),true;case 16442:return LM(t,n,r,o),true;default:return false}}function Rh(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 Eh(t,e,n){let r=wt(e,n);return r?(Lt(r.ctx,Rt(t,e,n),0,0),r):null}function Dl(t,e,n){let r=Rh(t);if(n.resample&&r){let s=Rn(e.rgba,e.width,e.height,n.resample,r);if(s){let i=Eh(s.rgba,s.w,s.h);if(!i)return false;t.save();try{t.setTransform(1,0,0,1,0,0),t.imageSmoothingEnabled=!1,pe(t,i.canvas,s.x,s.y,s.w,s.h);}finally{t.restore();}return true}}let o=Eh(e.rgba,e.width,e.height);if(!o)return false;t.save();try{t.setTransform(...n.transform),pe(t,o.canvas,n.dx,n.dy,n.dw,n.dh);}finally{t.restore();}return true}function DM(t,e){if(!t.data)return null;let n=new Uint8Array(t.data.slice(0)),r=wo(n);return r?{kind:"encoded",bytes:n,mime:r}:e?{kind:"rgba",data:e.rgba,width:e.width,height:e.height}:ti(n.buffer)}function Th(t,e,n,r,o=false){let s=o&&n?{kind:"rgba",data:n.rgba,width:n.width,height:n.height}:DM(e,n);if(!s)return false;let i=t.reserveSlot(),a=t.imageResampling==="exact"&&n&&r.resample?Rn(n.rgba,n.width,n.height,r.resample,{w:t.canvas.width,h:t.canvas.height}):null,u=r.resample?Tu(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&&Dl(t.shadow,n,r),true}var Ul=2,_l=null;function Ph(t){_l=t;}function UM(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 _M(t,e,n,r){let o=t.nestingDepth??0;if(!_l||!r||!e.data||r.unit!==Ul||o>=ll)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=Rh(t.ctx);if(!l)return false;let c=UM(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=_l(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 Fl(t,e,n,r,o){if(o&&o.unit!==Ul)return null;let s=e;if(!s&&t.data){let p=ti(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===Ul&&o.srcW>0&&o.srcH>0&&[o.srcX,o.srcY,o.srcW,o.srcH].every(Number.isFinite)?o:null,a=h0(b0(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 Ah(t,e,n,r,o=null){let s=e.cacheKey!==void 0?t.imageCache?.get(e.cacheKey):void 0;if(e.type===2)return _M(t,e,s,r);let i=s&&s.kind==="bitmap"?s:null,a=o?Fl(e,i,o,n,r):null;return a?It(t.ctx)?Th(t.ctx,e,a.bitmap,a.draw,true):Dl(t.ctx,a.bitmap,a.draw):o&&!i?false:It(t.ctx)?Th(t.ctx,e,i,n):i?Dl(t.ctx,i,n):false}function gr(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 Vi(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 is(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 WM=[0,8388608,32768,8421376,128,8388736,32896,12632256,12639424,10930928,16776176,10526884,8421504,16711680,65280,16776960,255,16711935,65535,16777215];function zn(t,e){return t.getUint32(e,true)}function as(t){return t>>>24!==0}function en(t){return t.palette?.entries??WM}function us(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 xe(t,e){let n=us(e,en(t));return Fs(n>>16&255,n>>8&255,n&255)}function wh(t,e,n){return xe(t,zn(e,n))}function ro(t,e,n){let r={...t.colorRefs};n!==void 0&&as(n)?r[e]=n:delete r[e],t.colorRefs=r;}function Ch(t){let e=t.colorRefs;e&&(e.pen!==void 0&&(t.penColor=xe(t,e.pen)),e.brush!==void 0&&(t.brushColor=xe(t,e.brush)),e.text!==void 0&&(t.textColor=xe(t,e.text)),e.bk!==void 0&&(t.bkColor=xe(t,e.bk)));}function Ih(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 kl(t,e){let n=t.objectTable.get(e);return n&&n.kind==="palette"?n:null}function Sh(t,e){t.state.palette===e&&Ch(t.state);}function vh(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:Ih(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=kl(t,i);if(!a)return true;s.palette=a;}Ch(s);}return true}case 50:{if(r>=20){let i=kl(t,o.getUint32(n,true)),a=o.getUint32(n+4,true),u=o.getUint32(n+8,true);if(i){let l=Ih(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];Sh(t,i);}}return true}case 51:{if(r>=16){let i=kl(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);Sh(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 Wt(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 Kt(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 ae(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 Sn(t){return !t.useMappingMode||t.deviceToCanvas?t.sx:1}function wn(t){return !t.useMappingMode||t.deviceToCanvas?t.sy:1}function Ol(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.left)*t.sx:e}function Bl(t,e){return !t.useMappingMode||t.deviceToCanvas?(e-t.bounds.top)*t.sy:e}function oo(t){t.useMappingMode=true;}function jt(t){let e=t.state.worldTransform;return e[1]!==0||e[2]!==0}function gt(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 Ft(t,e,n){let r=gt(t);return {x:r[0]*e+r[2]*n+r[4],y:r[1]*e+r[3]*n+r[5]}}function zi(t,e,n,r,o){let s=gt(t),i=Ft(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 Lh(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 We(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 Nl(t){return t>>>16&255}function mn(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 qi(t){let e=Nl(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:mn(e)}}}function Dh(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 Uh(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 HM={9:160,15:250,7:90,10:165,5:80,14:245,3:10,12:175,8:95,2:5};function qn(t){return t in HM}function so(t){if(!Number.isInteger(t)||t<1||t>16)return;let e=t-1;return (e>>2)*80+(e&3)*5}function Gl(t,e,n){return t<<16|e<<8|n}function Wl(t,e){switch(e){case "invert":return ~t&16777215;case "black":return 0;case "white":return 16777215;default:return t}}function Cn(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 Hl(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,E=0)=>{r=Math.min(r,g+a-E),o=Math.min(o,M+u-E),s=Math.max(s,g+a+E),i=Math.max(i,M+u+E);},f=()=>{l=true;},m={moveTo:(g,M)=>c(g,M),lineTo:(g,M)=>c(g,M),rect:(g,M,E,T)=>{c(g,M),c(g+E,M+T);},fillRect:(g,M,E,T)=>{c(g,M),c(g+E,M+T);},strokeRect:(g,M,E,T)=>{c(g,M),c(g+E,M+T);},bezierCurveTo:(g,M,E,T,R,P)=>{c(g,M),c(E,T),c(R,P);},quadraticCurveTo:(g,M,E,T)=>{c(g,M),c(E,T);},arcTo:(g,M,E,T)=>{c(g,M),c(E,T);},arc:(g,M,E)=>c(g,M,Math.abs(E)),ellipse:(g,M,E,T)=>c(g,M,Math.max(Math.abs(E),Math.abs(T))),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 XM=1024*1024,Er=null;function nn(t,e){let n=Er&&Er.w>=t&&Er.h>=e?Er:null;if(!n){let o=Math.max(t,Er?.w??0),s=Math.max(e,Er?.h??0),i=o*s<=XM,a=i?wt(o,s):wt(t,e);if(!a)return null;n={canvas:a.canvas,ctx:a.ctx,w:i?o:t,h:i?s:e},i&&(Er=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 rn(t,e,n,r){Lt(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 Ji(t,e){return null}function Ki(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 Zi(t,e,n){}function io(t,e,n,r){try{let o=At(t,e.x,e.y,e.w,e.h),s=o.data,i=nn(e.w,e.h),a=i?At(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,Gl(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 Lt(t,o,e.x,e.y),!0;let l=Ji(t,e),c=l?Ki(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 rn(t,e,i,a),Zi(t,e,c),!0}catch{return false}}function Xl(t,e,n,r,o=2,s){let i=so(e);if(i===void 0||false)return false;if(i===170)return true;let a=Cn(t);if(!a)return false;try{let u=Hl(r,o,a);if(!u)return !0;let l=nn(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=At(c,0,0,u.w,u.h),p=h.data,d=i===240?null:At(t,u.x,u.y,u.w,u.h).data,x=d?Ji(t,u):null,y=x?new Int32Array(u.w*u.h):null;for(let M=0;M<p.length;M+=4){let E=p[M+3],T;if(E===0)T=!1;else if(E===255)T=!0;else if(f){let A=(M>>2)%u.w,I=((M>>2)-A)/u.w;T=c.isPointInPath(A+.5,I+.5,s);}else T=E>=128;if(!T){p[M]=0,p[M+1]=0,p[M+2]=0,p[M+3]=0;continue}let R=b>=0?b:Gl(p[M],p[M+1],p[M+2]);y&&(y[M>>2]=R);let P=R;if(d){let A=Gl(d[M],d[M+1],d[M+2]);P=Vt(i,R,A,A);}p[M]=P>>16&255,p[M+1]=P>>8&255,p[M+2]=P&255,p[M+3]=255;}let g=[];if(x&&y);return rn(t,u,l,h),Zi(t,u,g),!0}catch{return false}}var YM=16*1024*1024;function _h(t){if(t.gdiAntialias!==false)return null;if(t.rasterLayer!==void 0)return t.rasterLayer;let e=Cn(t.ctx);return !e||It(t.ctx)||e.w*e.h>YM?(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 Ht(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=nn(n.w,n.h);if(o){rn(t.ctx,n,o,Rt(r,n.w,n.h));return}let s=At(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);Lt(t.ctx,s,n.x,n.y);}var $M=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 Qi(t){return $M.has(t)}function Oh(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 Fh(t){return `#${(t&16777215).toString(16).padStart(6,"0")}`}function Bh(t){for(let e of [0,16777215])if(Vt(t,e,0,0)!==Vt(t,e,0,16777215))return true;return false}function Nh(t,e){t.beginPath();for(let n of Yl(e))t.rect(n.x,n.y,n.w,n.h);}function Yl(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 kh(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,Nh(t,e),t.fill("nonzero");}finally{t.restore();}}function ue(t,e,n,r){if(e.length===0)return;let o=so(r)??240;if(o===170)return;let s=Bh(o)?null:_h(t);if(!s){Ht(t),jM(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(Oh(n,d,m))continue;let x=c;if(n.kind==="tile"){let[y,g]=n.toDevice(d,m);x=Vt(o,nr(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 jM(t,e,n,r){if(e.length===0)return;let o=so(r)??240;if(o===170)return;let s=Bh(o);if(n.kind==="solid"&&!s){kh(t,e,Fh(Vt(o,n.rgb,0,0)));return}if(n.kind==="tile"&&It());let i=e.bounds(),a=Cn(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=nn(m.w,m.h);if(!b)return;let h=At(t,m.x,m.y,m.w,m.h).data,p=At(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]),E=Math.min(c,x[y+2]);for(let T=M;T<E;T++){if(Oh(n,T,g))continue;let R=((g-l)*m.w+(T-u))*4,P;if(n.kind==="solid")P=n.rgb;else {let[I,S]=n.toDevice(T,g);P=nr(n.tile,I,S,n.orgX,n.orgY);}let A=P;if(s){let I=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,P,I,I);}else A=Vt(o,P,0,0);d[R]=A>>16&255,d[R+1]=A>>8&255,d[R+2]=A&255,d[R+3]=255;}}rn(t,m,b,p);}var VM=[[[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]]],Vl=104;function zM(t,e){return t?e?.5:-0.5:0}function qM(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 Gh=new Map;function zl(t,e=t){let n=`${t},${e}`,r=Gh.get(n);if(r)return r;let o;if(t===e&&t<Vl){let s=Math.min(6,Math.max(1,Math.floor(t/16+.5)));o=VM[s-1];}else {let s=Math.ceil(t/2),i=Math.ceil(e/2),a=cu(lu(-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 Gh.set(n,o),o}var $l=new Map;function ta(t){return Math.sign(t)*Math.floor(Math.abs(t)+.75)}function JM(t,e){let n=`${t},${e.join(",")}`,r=$l.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<Vl){let b=zl(Math.round(t*o));return $l.set(n,b),b}let s=t/2,i=e[0]*e[3]-e[1]*e[2]<0?-1:1,a=[ta(e[0]*s),ta(e[1]*s)],u=[i*ta(e[2]*s),i*ta(e[3]*s)],l=xn({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=cu(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 $l.set(n,m),m}function KM(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 ea(t){return Math.sign(t)*8*Math.floor((Math.abs(t)+4)/8)}function ZM(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??zl(t,r),l=u.length,c=-i,f=s,m=0,b=-1/0;for(let U=0;U<l;U++){let F=c*u[U][0]+f*u[U][1];F>b&&(b=F,m=U);}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,E]=x>=y?[h,x,y]:[p,y,x],T=2*(b-M+(b-E)),R=T===0?0:(M-E)/T,P=d[0]+(g[0]-d[0])*R,A=d[1]+(g[1]-d[1])*R,I=M-E,S=U=>Math.sign(T===0?d[U]:d[U]*T+(g[U]-d[U])*I),w=o?[S(0)!==0?-S(0):s===0?0:Math.sign(i),S(1)!==0?S(1):Math.sign(s)]:[s===0?0:Math.sign(i),Math.sign(s)],C=o?m<l/2:m===0&&x>=y,v=[0,1].map(U=>{let F=w[U]+2*zM(Math.abs(g[U]-d[U])%2===1,C);if(T===0)return 8*(U===1&&i<0?Math.ceil((d[U]+F/2+4)/8)-1:Math.floor((d[U]+F/2+4)/8));let O=d[U]*T+(g[U]-d[U])*I;return 8*qM(2*O+T*(F+8)-(U===1&&i<0?1:0),16*T)}),D=v[0],_=v[1];return {v:a?[-D,-_]:[D,_],ray:a?[-P,-A]:[P,A]}}function fn(t,e){return Math.sqrt(t*t+e*e)}function Wh(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=fn(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?E=>Math.sign(E)*Math.floor(Math.abs(E)+.5):E=>Math.floor(E+.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=fn(y(p),y(d));return g===0?[0,0]:[b(p/g*m),b(d*f/c/g*m)]}let h=t===o?fn(e,n):fn(e,n*t/o);return [b(e/h*m),b(n/h*m)]}function na(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 jl=class{constructor(e,n){this.opts=e;this.out=n;this.pts=[];this.pen=e.matrix&&e.deviceNib?JM(e.width,e.matrix):zl(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]=KM(this.pen,u[0],u[1],this.opts.width,this.opts.height,l),m=s&&o?o:[i,a],b=ZM(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:Wh(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 [ea(r[0]),ea(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 [ea(r[0]),ea(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=fn(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 Wh(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=eE(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=na(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=na(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=na(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=na(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<Vl;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 ra(t){return Math.sign(t)*Math.floor((Math.abs(t)+8)/16)*16}function Hh(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 QM(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,E=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]):fn(g[0],g[1]),T=i?fn(ra(g[0]/i[0]),ra(g[1]/i[1])):a?fn(ra((a[3]*g[0]-a[2]*g[1])/M),ra((-a[1]*g[0]+a[0]*g[1])/M)):s?fn(Math.floor(g[0]/16),Math.floor(g[1]/16))*16:fn(g[0],g[1]);if(T===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(;T-R>f||f===0&&m;){R+=f;let P=[Hh(p,g[0],R,T),Hh(d,g[1],R,T)];m&&b?(b.pts.push(P),b.dirs.push(g),b.draws.push(e[h]),b.curves.push(n[h]),b.endScale=b.pts[0]===t[0]&&P[0]===t[0][0]&&P[1]===t[0][1]?1:E/T,u.push(b),b=null):b={pts:[P],dirs:[],draws:[],curves:[],startScale:E/T,endScale:1},m=!m,c=(c+1)%l.length,f=l[c];}f-=T-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=E/T);}return m&&b&&b.dirs.length>0&&(b.endScale=1,u.push(b)),u}function tE(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 vt;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 ls(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 ls(t,e){if(e.matrix&&!e.deviceNib)return tE(t,e,e.matrix);let n=[],r=!!e.dashes&&e.dashes.length>0;for(let o of t.figures){let s=new jl(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 QM(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 eE(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,E=(-u[1]*p+u[0]*d)/g;return Math.hypot(Math.round(M/16),Math.round(E/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 ql(t){let e=/^#?([0-9a-f]{6})$/i.exec(t.trim());return e?parseInt(e[1],16):0}function xt(t,e,n){let r=gt(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 cs(t,e,n,r,o){let[s,i]=xt(t,e,n),[a,u]=xt(t,r,n),[l,c]=xt(t,e,o);return {ax:s,ay:i,exx:a-s,exy:u-i,eyx:l-s,eyy:c-i}}function Ae(t){return t.exy===0&&t.eyx===0}function nE(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 rE(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 Tr(t,e=false){let n=nE(e?rE(t):t);t.halfXRect&&(n[4]--,n[6]--);let r=new vt;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 ms(t,e=false){let n=new vt;return n.addBeziers(xn(t,e),true),n.closeFigure(),n.figures[0].roundWiden=true,n}function Xh(t,e,n,r,o){return Ae(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 Yh(t){if(Ae(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 Jl(t,e,n,r=false,o=false){let s=Yh(t),i=Ae(t)&&t.exx<0,a=Ae(t)&&t.eyy<0,u=r!==a,l=Tf(s.l,s.t,s.r,s.b,e,n,o,u,i,Ae(t)?t.cornerRatio:void 0),c=Xh(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&&Ae(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(Le*h):Math.ceil(Le*h),x=u?Math.ceil(Le*p):Math.floor(Le*p),y=(M,E,T)=>{E!==null&&(f[2*M]=E),f[2*M+1]=u?s.t+s.b-T:T;},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 sa(t,e,n,r=false,o=false,s=false){if(o)return Tr(t,r);let i=Jl(t,e,n,r,s),a=new vt;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 ao(t,e,n,r,o,s,i=new vt,a){let u=Yh(t),l=Xh(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(Ae(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,E)=>{let T=M-t.ax,R=E-t.ay,P=(T*t.eyy-R*t.eyx)/y,A=(t.exx*R-t.exy*T)/y;return [u.l+P*(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&&Ae(t),d=If(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,E]=l(u.l+Math.ceil(y/2)+(t.halfX&&!p?1:0),u.t+Math.ceil(g/2));i.lineTo(M,E);}return (o==="pie"||o==="chord")&&i.closeFigure(),{path:i,end:[x[x.length-2],x[x.length-1]]}}var $h=5,oE=65536;function ia(t){let e=gt(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 ye(t){return ((t.state.penFlags??t.state.penStyle)&oE)===0&&t.state.penExtended?true:Math.round(ia(t)/(t.wholeDevicePixels?.[0]??1))<=1}function Kl(t){return (t.state.penStyle&15)!==$h}function Zl(t,e={}){let{state:n}=t,r=n.penFlags??n.penStyle,o=gt(t),s=t.wholeDevicePixels&&(r&15)===6?n.penWidth*Math.sqrt(Math.abs(o[0]*o[3]-o[1]*o[2])):ia(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?Ao(r,n.penWidth,n.penUserStyle,1):Ao(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 sE(t){let e=new Uint8Array(64);for(let n=0;n<8;n++)for(let r=0;r<8;r++)e[n*8+r]=Fr(t,r,n)?0:1;return e}function on(t){let e=ne(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:sE(s.brushPattern.hatch)}:{}}}function iE(t){if(!t.figures.some(n=>n.tangents))return t;let e=new vt;return e.figures=t.figures.map(n=>({pts:n.pts,closed:n.closed,roundWiden:n.roundWiden})),e}function oa(t,e,n=false){if(!t.wmfLayoutRtl||n)return e;let r=Math.round(16*(t.wholeDevicePixels?.[0]??1)),o=new vt;return o.figures=e.figures.map(s=>({...s,pts:s.pts.map((i,a)=>a%2===0?i-r:i)})),o}function jh(t,e,n){e=oa(t,e,n.rectangle||n.roundPen);let{ctx:r,state:o}=t,s=!!n.filled;if(n.fill){let c=on(t);if(c){s=true;let f=n.fillPath?oa(t,n.fillPath,n.rectangle||n.roundPen):e,m=kr(f,!!n.winding);ue(t,m,c,o.rop2);}}if(!n.stroke||o.penStyle===$h)return true;if(!ye(t)){if(!Kl(t))return false;let c=ls(s?iE(e):e,Zl(t,n));return ue(t,or(c,true),{kind:"solid",rgb:ql(o.penColor)},o.rop2),true}let i=Or(o.penFlags??o.penStyle,o.penUserStyle),a=new Jt,l=i!==null&&o.bkMode===2&&$s(o.penFlags??o.penStyle)?new Jt:null;return js(e,a,l,i,n.style??{pos:0}),l&&ue(t,l,{kind:"solid",rgb:ql(o.bkColor)},o.rop2),ue(t,a,{kind:"solid",rgb:ql(o.penColor)},o.rop2),true}var Ql=.5-1/32;function tc(t,e){return e===0?t:n=>{n.save(),n.translate(e,e),t(n),n.restore();}}function ec(t){return t.gdiAntialias===false}function aE(t,e,n){let{ctx:r,bounds:o,state:s}=t,i=ne(s);if(i.kind!=="tile")return false;let a=t.sx||1,u=t.sy||1,l=so(s.rop2)??240,c=s.bkMode===1&&s.brushPattern?.kind==="hatch"?s.brushPattern.hatch:-1,f=(x,y)=>c>=0&&!Fr(c,((x-s.brushOrgX)%8+8)%8,((y-s.brushOrgY)%8+8)%8);let m=Cn(r);if(!m||typeof r.isPointInPath!="function")return false;if(l===170)return true;let b=n?Hl(n,1,m):{x:0,y:0,w:m.w,h:m.h};if(!b)return true;let h=.5-Ql,p=(x,y)=>nr(i,Math.floor(o.left+(x+.5)/a),Math.floor(o.top+(y+.5)/u),s.brushOrgX,s.brushOrgY),d=he(s.rop2);return io(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:Wl(p(x,y),d.colorTransform),mode:d.gco}))}function uE(t,e,n="nonzero",r){let{ctx:o,state:s}=t;if(s.brushStyle===1)return;let i=r??e;if(ne(s).kind==="tile"){r&&r(o);let l=aE(t,n,i);if(r&&e(o),l)return}else {let l=he(s.rop2);if((ec(t)||!l.exact&&qn(s.rop2))&&Xl(o,s.rop2,s.brushColor,f=>{tc(i,Ql)(f),f.fill(n);},1,n))return}let a=jt(t)?Ql:0,u=a!==0||r!==void 0;u&&tc(i,a)(o),Wr(o,s),o.fill(n),u&&e(o);}var fs=5;function Rr(t,e=1){return Math.max(t.penWidth*e,1)}function Jn(t){let e=gt(t);return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))||1}function Pr(t,e=1){if(t.penStyle===fs)return 0;let n=Rr(t,e);return Number.isInteger(n)&&n%2===1?.5:0}function Vh(t,e){let{state:n}=e,r=Jn(e),o=Rr(n,r),s=n.penFlags??n.penStyle;t.lineWidth=o;let i=ye(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(Ao(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 lE(t){let{state:e}=t;return e.penStyle===fs||!ye(t)?null:Or(e.penFlags??e.penStyle,e.penUserStyle)}function cE(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&&$s(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;Xs(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=Nr(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 mE(t,e){let{ctx:n,state:r}=t,o=Jn(t),s=Pr(r,o),i=tc(e,s),a=he(r.rop2);r.penStyle!==fs&&(ec(t)||!a.exact&&qn(r.rop2))&&Xl(n,r.rop2,r.penColor,l=>{Vh(l,t),i(l),l.stroke();},Rr(r,o)/2+2)||(s!==0&&i(n),Gr(n,r),r.penStyle!==fs&&Vh(n,t),n.stroke());}function Zt(t,e){let{ctx:n,state:r}=t,o=ec(t),s=!he(r.rop2).exact&&qn(r.rop2),i=r.penStyle===fs,a=!i&&ye(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=ne(r).kind==="tile";if(o||h||s){let p=on(t);if(p){let d=oa(t,l(),e.rectangle||e.roundPen),x=kr(d,m==="nonzero");e.axisRect&&e.stroke&&a&&(x=fE(x,l())),ue(t,x,p,r.rop2);}}else {f();let p=e.axisRect&&e.stroke&&!i?e.axisRect.interior:void 0;uE(t,e.build,m,p);}}if(!e.stroke||i)return;if((a||Kl(t))&&(o||s)){jh(t,l(),{fill:false,stroke:true,style:e.style,rectangle:e.rectangle,roundPen:e.roundPen,filled:!!e.fill&&r.brushStyle!==1});return}let b=lE(t);if(b&&!o&&!s){cE(t,l(),b,e.style??{pos:0});return}Ht(t),f(),mE(t,e.build);}function fE(t,e){let n=new Jt;js(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 Jt,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 zh(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=Gn(e,t.center.x,t.center.y),o=gn(t.centerArgb),s=t.boundary.map(l=>Gn(e,l.x,l.y)),i=ii(t.preset),a=i?{preset:i}:{adjust:si(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 oi([r[0],r[1],s[l][0],s[l][1],s[c][0],s[c][1]],[o,gn(t.boundaryArgb[l]),gn(t.boundaryArgb[c])],a));}return {triangles:u}}function qh(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=Lo(u.argb[l],u.argb[l+1],u.argb[l+2],u.argb[l+3],s);}return i}var rc=[1,0,0,1,0,0],oc=16*1024*1024,bE=1e-4;function sn(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 hE(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 pE(t,e,n=false){let{width:r,height:o,rgba:s,wrapMode:i}=t;if(r<=0||o<=0)return null;let a=Zo(Xt(e,t.transform??rc),n);return a?(u,l,c,f,m,b)=>{_b(a,r,o,s,i,u,l,c,f,m,b);}:null}function dE(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 Jh(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 xE(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 nc(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 aa=2048;function ua(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 yE(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=>[De(l.x),De(l.y)]);o[o.length-1]={x:a[0]/16,y:a[1]/16};let u=[];$e(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 gE(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(g=>g===t.boundaryArgb[0]))return null;let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let g of t.source?t.source.points:t.boundary){let M=n[0]*g.x+n[4],E=n[3]*g.y+n[5];r=Math.min(r,M),o=Math.min(o,E),s=Math.max(s,M),i=Math.max(i,E);}let a=g=>Math.floor(g+.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=Zo([(s-r)/u,0,0,(i-o)/l,r,o]);if(!m)return null;let b=g=>({x:(n[0]*g.x+n[4]-r)*c,y:(n[3]*g.y+n[5]-o)*f}),h=Zh({...t,boundary:t.source?yE(t.source,b,n):t.boundary.map(b),source:void 0,center:b(t.center),transform:null},"clamp",rc,false,true);if(!h)return null;let p=e==="tile-flip-x"||e==="tile-flip-xy",d=e==="tile-flip-y"||e==="tile-flip-xy",x=null,y=()=>{if(x)return x;let g=new Uint8ClampedArray(u*l*4);h(0,0,u,l,g),x=new Float64Array(u*l*4);for(let M=0;M<u*l;M++){let E=g[M*4+3];x[M*4]=Math.floor(g[M*4]*E/255+.5),x[M*4+1]=Math.floor(g[M*4+1]*E/255+.5),x[M*4+2]=Math.floor(g[M*4+2]*E/255+.5),x[M*4+3]=E;}return x};return (g,M,E,T,R)=>{let P=y(),A=new Float64Array(E);ml(m,g,0,A,new Float64Array(E));for(let I=0;I<T;I++){let S=f*(M+I-o),w=Math.floor(S),C=Math.floor((S-w)*aa+.5)/aa,v=ua(w,l,d)*u,D=ua(w+1,l,d)*u;for(let _=0;_<E;_++){let U=A[_],F=Math.floor(U),O=Math.floor((U-F)*aa+.5)/aa,H=ua(F,u,p),k=ua(F+1,u,p),G=(I*E+_)*4,N=z=>(1-O)*(1-C)*P[(v+H)*4+z]+O*(1-C)*P[(v+k)*4+z]+(1-O)*C*P[(D+H)*4+z]+O*C*P[(D+k)*4+z],K=N(3),V=Math.floor(K+.5);if(V<=0){R[G]=R[G+1]=R[G+2]=R[G+3]=0;continue}for(let z=0;z<3;z++){let st=Math.floor(N(z)+.5);R[G+z]=Math.min(255,K>=255?st:Math.floor(st*255/V+.5));}R[G+3]=V;}}}}function Zh(t,e,n,r=true,o=false){let s=dE(t.boundary),i=Xt(n,t.transform??rc),a=sn(i);if(!s||!a)return null;if(e!=="clamp"&&!nc(t.boundary,i)){let E=gE(t,e,i);if(E)return E}let c=!t.boundaryArgb.every(E=>E===t.boundaryArgb[0])||e!=="clamp"&&!nc(t.boundary,i)?0:qf(t.boundary,i),f=e==="clamp"||nc(t.boundary,i)?zh(t,i):null,m=c>0?Nf(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"?bE:0,M=e==="clamp"?null:xE(s,i);return (E,T,R,P,A,I)=>{let S=M!==null&&E>=M[0]&&E+R<=M[2]&&T>=M[1]&&T+P<=M[3],w=M&&!S?M[0]:E,C=M&&!S?M[2]:E+R,v=o||M!==null&&!S,D=I!==void 0&&!(M&&!S);for(let _=0;_<P;_++){let U=T+_,F=-1;for(let O=0;O<R;O++){if(D&&I[_*R+O]&&O>=F){let st=O;for(;st>0&&I[_*R+st-1];)st--;for(F=O;F<R&&I[_*R+F];)F++;w=E+st,C=E+F;}let H=E+O+g,k=a[0]*H+a[2]*U+a[4],G=a[1]*H+a[3]*U+a[5];if(e!=="clamp"&&(k=Jh(k,s.x,s.w,x,p),G=Jh(G,s.y,s.h,y,d)),e==="clamp"&&G>=s.y+s.h&&!f&&!m)continue;let N=g?{x:k-a[0]*g,y:G-a[1]*g}:void 0,K=null,V=false;if(f||m){let st=e==="clamp"?E+O:i[0]*k+i[2]*G+i[4],at=e==="clamp"?U:i[1]*k+i[3]*G+i[5],Y=Math.round(st),X=Math.round(at);if(Math.abs(st-Y)<1e-6&&Math.abs(at-X)<1e-6){if(f)K=qh(f,Y,X,w,C,v),K===null&&r&&(V=true);else if(m){let B=m.colorAt(Y,X,w,C);B!==null?K=Lo(B>>>24,B>>>16&255,B>>>8&255,B&255,v):r&&(V=true);}}}if(K===null&&!V)if(m){let st={s:NaN};if(li(t,k,G,N,st)!==null){let at=m.colorForPosition(st.s);K=Lo(at>>>24,at>>>16&255,at>>>8&255,at&255,v);}}else K=li(t,k,G,N);if(K===null)continue;let z=(_*R+O)*4;A[z]=K>>>16&255,A[z+1]=K>>>8&255,A[z+2]=K&255,A[z+3]=K>>>24&255;}}}}function lo(t,e,n){if(e&32768)return null;let r=t.objectTable.get(n&255);return !r||r.kind!=="plus-brush"?null:sc(t,r)}function sc(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&&!It(t.ctx)){let s=sn(ji(t));if(s)return lh(e.hatch,t.ext?.renderingOrigin??{x:0,y:0},s)}return e.texture?pE(e.texture,n,Re(t.pixelOffsetMode??0)):e.gradient&&e.gradient.type==="radial"&&e.gradient.shape?Zh(e.gradient.shape,e.gradient.wrapMode,n):e.gradient&&e.gradient.type==="linear"&&!It(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]),$f(e.gradient,n,Re(t.pixelOffsetMode??0),t.ext?.compositingMode===1,o)):null}function Ar(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 vn(t,e,n,r,o,s="nonzero"){let{ctx:i}=t,a=hE(i);if(!a||typeof i.clip!="function"||typeof i.drawImage!="function")return false;let u=hs(t);if(u!=="canvas"){let b=ic(t,e,n);if(b&&EE(t,b,r,o,s,a,u))return true}let l=lo(t,e,n);if(!l)return false;let c=Ar(o,_t(t),a);if(!c)return true;if(c.w*c.h>oc)return false;let f=wt(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),Lt(f.ctx,Rt(m,c.w,c.h),0,0),i.save();try{de(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 bs(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>oc)return false;let f=wt(n.w,n.h),m=wt(n.w,n.h);if(!f||!m||typeof f.ctx.getImageData!="function")return false;let b=_t(t),h=f.ctx,p=u?ME(t):i?vl(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"?_0(h,b):h);let d=At(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,E=M%n.w,T=Math.floor(M/n.w),R=0;for(let P=0;P<4;P++)for(let A=0;A<8;A++)s(h,E+A/8+Kh,T+P/4+Kh)&&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 E=(g-3)/4,T=E%n.w+.5,R=Math.floor(E/n.w)+.5;d[g]=y(h,T,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;Lt(m.ctx,Rt(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 ME(t){return (Re(t.pixelOffsetMode??0)?0:.5)-1/32}var Kh=1/1024;function hs(t){return t.gdiAntialias===true||It(t.ctx)?"canvas":t.antiAlias?"gdiplus-aa":"aliased"}function uo(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 co(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 ic(t,e,n){if(e&32768)return uo(n>>>0);let r=lo(t,e,n);if(r)return r;let o=t.objectTable.get(n&255),s=o&&o.kind==="plus-brush"?co(o.color):null;return s===null?null:uo(s)}function EE(t,e,n,r,o,s,i){let a=_t(t),u=null;try{u=W0(n,a,i==="aliased");}catch{u=null;}if(u){let c=Oo(u,s);if(!c)return true;if(c.w*c.h<=oc){let f=Re(t.pixelOffsetMode??0),m=se(u,o==="evenodd",i==="gdiplus-aa",f,c);return Kn(t,e,c,m,1,true)}}let l=Ar(r,a,s);return l?bs(t,e,l,c=>{c.beginPath(),n(c),c.fill(o);},i,(c,f,m)=>c.isPointInPath(f,m,o)):true}function TE(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 RE(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]=Du(Math.round(f*a/32),l);}t[s+3]=l;}}return t}function PE(t,e,n,r){let{ctx:o}=t,s=wt(e.w,e.h),i=wt(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;Lt(s.ctx,Rt(a,e.w,e.h),0,0),Lt(i.ctx,Rt(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 AE(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 IE(t){let e=Math.round(t*6/255);return Math.abs(t-255*e/6)<=.51?e/6:t/255}function SE(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)*IE(e)*o)))]}function Kn(t,e,n,r,o=1,s=false,i=1){let{ctx:a}=t,u=wt(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=At(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)),PE(t,n,RE(l,c,r,f),r)}if(o===1&&s&&typeof a.getImageData=="function"){let c=At(a,n.x,n.y,n.w,n.h).data;TE(l,c,r),Lt(u.ctx,Rt(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=At(a,n.x,n.y,n.w,n.h).data,f=AE(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]=SE(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;Lt(u.ctx,Rt(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 _E(t){let{state:e}=t,r=!he(e.rop2).exact&&qn(e.rop2),o=e.penStyle===5||(e.penStyle===0||e.penStyle===6)&&ye(t);return r||t.gdiAntialias===false||ne(e).kind==="tile"||!o}function Ln(t){return t.rasterPath??(t.rasterPath=new vt),t.rasterPath}function cc(t,e,n){let r=Tr(e,n),o=r.figures[0].pts,s=We(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(),Ln(t).append(r);}function ep(t,e,n){let r=We(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 mo(t){let e=Ln(t),[n,r]=Dn(t),o=e.figures.length;e.continueAt(n,r),e.figures.length!==o&&We(t).moveTo(n/16,r/16);}function FE(t){return t.lineStyle??(t.lineStyle={pos:0}),t.lineStyle}function fo(t){t.lineStyle={pos:0};}function Dn(t){let e=t.curFix,{state:n}=t;return e&&e.lx===n.curX&&e.ly===n.curY?[e.x,e.y]:xt(t,n.curX,n.curY)}function la(t,e,n,r,o){return cs(t,Math.min(e,r),Math.min(n,o),Math.max(e,r),Math.max(n,o))}function Qh(t,e,n){let r=gt(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 np=6;function ca(t,e,n=false,r=false){if((t.state.penStyle&15)!==np||!Ae(e)||jt(t))return null;let o=gt(t),s=Sn(t),i=wn(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 kE(t,e){if((t.state.penStyle&15)!==np||!Ae(e)||jt(t))return false;let n=gt(t),r=Sn(t),o=wn(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 ma(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 OE(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 BE(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=wh(t.state,o,e+8),u=jt(t)?Ft(t,s,i):{x:Gt(t,s),y:Wt(t,i)};r.fillStyle=a,r.fillRect(u.x,u.y,1,1);}return true}function NE(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),fo(t),t.curFix=void 0,s)){let i=jt(t)?Ft(t,o.curX,o.curY):{x:Gt(t,o.curX),y:Wt(t,o.curY)};We(t).moveTo(i.x,i.y);let a=xt(t,o.curX,o.curY);Ln(t).moveTo(a[0],a[1]);}return true}function GE(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?Ft(t,i,a):{x:Gt(t,i),y:Wt(t,a)},c=xt(t,i,a);if(s)mo(t),We(t).lineTo(l.x,l.y),Ln(t).lineTo(c[0],c[1]);else {let f=u?Ft(t,o.curX,o.curY):{x:Gt(t,o.curX),y:Wt(t,o.curY)},m=Dn(t);Zt(t,{build:b=>{b.beginPath(),b.moveTo(f.x,f.y),b.lineTo(l.x,l.y);},raster:()=>{let b=new vt;return b.moveTo(m[0],m[1]),b.lineTo(c[0],c[1]),b},fill:false,stroke:true,style:FE(t)});}o.curX=i,o.curY=a;}return true}function WE(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||!ye(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 HE(t){if(!Ae(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 XE(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=WE(t,la(t,a,u,l,c)),m=ca(t,f,true,t.state.arcDirection===2),b=m?ma(f,m):f,h=t.state.arcDirection===2;if(i||fo(t),jt(t)){let M=Ft(t,a,u),E=Ft(t,l,u),T=Ft(t,l,c),R=Ft(t,a,c),P=A=>{A.moveTo(M.x,M.y),A.lineTo(E.x,E.y),A.lineTo(T.x,T.y),A.lineTo(R.x,R.y),A.closePath();};return i?cc(t,b,h):Zt(t,{build:A=>{A.beginPath(),P(A);},raster:()=>Tr(b,h),rectangle:true,fill:true,stroke:true,axisRect:Ae(b)?{}:void 0}),true}let d=Gt(t,a),x=Wt(t,u),y=Kt(t,l-a),g=ae(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)cc(t,b,h);else if(_E(t))Zt(t,{build:M=>{M.beginPath(),M.rect(d,x,y,g);},raster:()=>Tr(ye(t)?HE(b):b,h),rectangle:true,fill:true,stroke:true,axisRect:{interior:YE(s,d,x,y,g,Jn(t))}});else {Wr(r,s),r.fillRect(d,x,y,g),Gr(r,s),r.lineWidth=1;let M=Pr(s,Jn(t));r.strokeRect(d+M,x+M,y,g);}}return true}function YE(t,e,n,r,o,s=1){if(Pr(t,s)===0||Rr(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 tp=.5522847498307936;function ac(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 E=a(g,M);t.moveTo(E.x,E.y);},p=(g,M)=>{let E=a(g,M);t.lineTo(E.x,E.y);},d=(g,M,E,T,R,P)=>{let A=a(g,M),I=a(E,T),S=a(R,P);t.bezierCurveTo(A.x,A.y,I.x,I.y,S.x,S.y);};if(m<=0||b<=0){h(u,c),p(l,c),p(l,f),p(u,f),t.closePath();return}let x=m*tp,y=b*tp;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 $E(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=la(t,s,i,a,u),b=ca(t,m,false,f),h=b?ma(m,b):m,p=gt(t),d=b?Math.abs(l*p[0])*16:Qh(t,l,0),x=b?Math.abs(c*p[3])*16:Qh(t,c,1),y=(P,A,I)=>b&&A!==0?Math.floor(Math.min(P,A)*I/A):P,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)),E=b?h:bc(t,s,i,a,u,true);!b&&E.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(E.exx)/Math.abs(m.exx)),M=Math.floor(Math.min(x,Math.abs(m.eyy))*Math.abs(E.eyy)/Math.abs(m.eyy))),!b&&E.exx===m.exx&&E.eyy===m.eyy&&l!==0&&c!==0&&a!==s&&u!==i&&!jt(t)&&(E.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 T=b?P=>ac(P,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)?P=>ac(P,s,i,a,u,l/2,c/2,(A,I)=>Ft(t,A,I)):P=>ac(P,Gt(t,s),Wt(t,i),Gt(t,a),Wt(t,u),Kt(t,l)/2,ae(t,c)/2,null);if(b){let P=Math.abs((a-s)*p[0])*16,A=Math.abs((u-i)*p[3])*16;P>0&&A>0&&(h.cornerExact=[Math.min(d,P)*Math.abs(h.exx)/P,Math.min(x,A)*Math.abs(h.eyy)/A]);}let R=(P=h)=>sa(P,g,M,f,l===0||c===0);if(o){let P=E;l===0||c===0?cc(t,P,f):(ep(t,Jl(P,g,M,f),8),Ln(t).append(R(P)));}else fo(t),Zt(t,{build:P=>{P.beginPath(),T(P);},raster:()=>R(E),roundPen:true,fill:true,stroke:true});}return true}function bc(t,e,n,r,o,s=false){let i=s?la(t,e,n,r,o):cs(t,e,n,r,o);if(t.state.penStyle!==5)return i;let a=gt(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 jE(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=la(t,s,i,a,u),f=ca(t,c,false,t.state.arcDirection===2),m=f?ma(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)?zi(t,(s+a)/2,(i+u)/2,Math.abs(a-s)/2,Math.abs(u-i)/2):{cx:Gt(t,(s+a)/2),cy:Wt(t,(i+u)/2),rx:Math.abs(Kt(t,a-s))/2,ry:Math.abs(ae(t,u-i))/2,rotation:0};if(o){let h=m;ep(t,xn(h,l),6),Ln(t).append(ms(h,l));}else fo(t),Zt(t,{build:h=>{h.beginPath(),h.ellipse(b.cx,b.cy,b.rx,b.ry,b.rotation,0,Math.PI*2);},raster:()=>ms(f?m:bc(t,s,i,a,u,true),l),roundPen:true,fill:true,stroke:true});}return true}function VE(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)),E=i.arcDirection===2,T=e!==47&&y>0&&g>0&&OE(u,l,c,f,m,b,h,p),R=T?M+(E?2:-2)*Math.PI:Math.atan2((p-x)/(g||1),(h-d)/(y||1)),P=jt(t),A=cs(t,u,l,c,f);if(e!==55&&kE(t,A))return true;let I=ca(t,A,false,t.state.arcDirection===2),S=I?ma(A,I):A,w=I?{cx:(S.ax+S.exx/2)/16,cy:(S.ay+S.eyy/2)/16,rx:Math.abs(S.exx)/32,ry:Math.abs(S.eyy)/32,rotation:0}:P?zi(t,d,x,y,g):{cx:Gt(t,d),cy:Wt(t,x),rx:Math.abs(Kt(t,y)),ry:Math.abs(ae(t,g)),rotation:0},C=e===55,v=e===47||e===46,D=P?Ft(t,d+y*Math.cos(M),x+g*Math.sin(M)):{x:w.cx+w.rx*Math.cos(M),y:w.cy+w.ry*Math.sin(M)},_=N=>{if(e===47?N.moveTo(w.cx,w.cy):!C&&a&&N.moveTo(D.x,D.y),C){if(!a){let K=Dn(t);N.moveTo(K[0]/16,K[1]/16);}N.lineTo(D.x,D.y);}N.ellipse(w.cx,w.cy,w.rx,w.ry,w.rotation,M,R,!E),v&&N.closePath();},U=C?"arcto":e===47?"pie":e===46?"chord":"arc",F=(N,K,V)=>{let z=c-u,st=f-l;if(z===0||st===0)return xt(t,K,V);let at=(K-u)/z,Y=(V-l)/st;return [N.ax+N.exx*at+N.eyx*Y,N.ay+N.exy*at+N.eyy*Y]},O=gt(t),H=O[0]*O[3]-O[1]*O[2]<0,k=O[1]===0&&O[2]===0,G=(N=false)=>{let K=I?S:N&&v?bc(t,u,l,c,f):A,V=K.exx*K.eyy-K.exy*K.eyx<0,z=k&&Ae(K)?{x:O[0]<0,y:O[3]<0}:void 0;return {box:K,mirror:z,clockwise:z?E:E!==(H!==V),s:F(K,m,b),e:T?F(K,m,b):F(K,h,p),from:Dn(t)}};if(a){C&&mo(t),_(We(t));let N=G();ao(N.box,N.s,N.e,N.clockwise,U,N.from,Ln(t),N.mirror),v&&Ln(t).closeFigure();}else fo(t),o.beginPath(),Zt(t,{build:N=>{N.beginPath(),_(N);},raster:()=>{let N=G(true);return ao(N.box,N.s,N.e,N.clockwise,U,N.from,void 0,N.mirror).path},fill:v,stroke:true});if(C){let N=G(),K=ao(N.box,N.s,N.e,N.clockwise,"arc",void 0,void 0,N.mirror).end,V=Math.floor(K[0]/16),z=Math.floor(K[1]/16),st=sn(gt(t));st?(i.curX=Math.round(st[0]*V+st[2]*z+st[4]),i.curY=Math.round(st[1]*V+st[3]*z+st[5])):(i.curX=Math.round(d+y*Math.cos(R)),i.curY=Math.round(x+g*Math.sin(R))),t.curFix=a?{x:K[0],y:K[1],lx:i.curX,ly:i.curY}:{x:V*16,y:z*16,lx:i.curX,ly:i.curY};}}return true}function zE(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=cs(t,i-u,a-u,i+u,a+u),M;if(Ae(g))M=Pf(g,l,c);else {M=[...xt(t,i+u*Math.cos(f),a-u*Math.sin(f))];for(let C of mu(l,c)){let v=Rf(i,a,u,u,C.from,C.to);for(let D=0;D<6;D+=2)M.push(...xt(t,v[D],v[D+1]));}}let E=[M[M.length-2],M[M.length-1]],T=(C,v)=>{C.continueAt(v[0],v[1]),C.addBeziers(M,false);},R=zi(t,i,a,u,u),P=Ft(t,b,h),A=C=>{if(C.lineTo(P.x,P.y),u===0)return;let v=Math.min(Math.abs(m-f),Math.PI*2*(y+1));C.ellipse(R.cx,R.cy,R.rx,R.ry,R.rotation,-f,x?-f+v:-f-v,!x);};if(s)mo(t),A(We(t)),T(Ln(t),Dn(t));else {fo(t);let C=Dn(t),v=Ft(t,o.curX,o.curY);Zt(t,{build:D=>{D.beginPath(),D.moveTo(v.x,v.y),A(D);},raster:()=>{let D=new vt;return T(D,C),D},fill:false,stroke:true});}let I=Math.floor(E[0]/16),S=Math.floor(E[1]/16),w=sn(gt(t));return o.curX=Math.round(w?w[0]*I+w[2]*S+w[4]:p),o.curY=Math.round(w?w[1]*I+w[3]*S+w[5]:d),t.curFix=s?{x:E[0],y:E[1],lx:o.curX,ly:o.curY}:{x:I*16,y:S*16,lx:o.curX,ly:o.curY},true}function rp(t,e,n,r){switch(e){case 15:return BE(t,n,r);case 27:return NE(t,n,r);case 54:return GE(t,n,r);case 43:return XE(t,n,r);case 44:return $E(t,n,r);case 42:return jE(t,n,r);case 41:return zE(t,n,r);case 45:case 55:case 46:case 47:return VE(t,e,n,r);default:return false}}var qE=[[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]],JE=66,op=65;function KE(t){return t<63?t%16:t<=64?14:15}function ZE(t){return t<63?t%16:t===63?14:15}var fa=(t,e)=>(t%e+e)%e;function hc(t,e){let n=fa(t-e-2,65);return n<63?n:n+1}function pc(t,e){return fa(t-e-2,op)}function ba(t,e,n,r){return qE[ZE(fa(e+r,op))][KE(fa(t+n,JE))]}function QE(t){return Math.round(t*255/31)}function bo(t,e){let n=Math.floor((31*t+e)/255);return QE(n<0?0:n>31?31:n)}function tT(t,e,n){return n===t?16777216|n>>2<<8|e>>2:n|e<<8|t<<16}function ha(t,e,n){if(e<=0||n<=0)return "replicate";let r=e*n;if(r<=2304)return "replicate";let o=b=>tT(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"}Vn();var dc=1,sp=2;var Sr=4;function xs(t,e,n){let r=Math.floor((2*t+1)*e/(2*n));return Math.max(0,Math.min(e-1,r))}function ip(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=xs(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 cp(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===dc||a===sp,b=ip(Math.round(Math.min(e,e+r)),Math.round(Math.abs(r)),u,c,m),h=ip(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++){Te();let g=h[y]??[];for(let M=0;M<u;M++){let E=b[M]??[],T=a===dc?16777215:0,R=true;for(let A of g)for(let I of E){let S=x(I,A);a===dc?T&=S:a===sp?T|=S:R&&(T=S),R=false;}let P=(y*u+M)*4;p[P]=T>>16&255,p[P+1]=T>>8&255,p[P+2]=T&255,p[P+3]=255;}}return {width:u,height:l,data:p}}var ho=65536;function yc(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 mp(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(yc(a,e,n)),1]]);return r&&o.reverse(),o}let i=Math.ceil(e*ho/n);for(let a=0;a<n;a++){let u=a*i,l=(a+1)*i,c=[];for(let f=Math.floor(u/ho);f*ho<l&&f<e;f++){let m=Math.min(l,(f+1)*ho)-Math.max(u,f*ho);m>0&&c.push([s(f),m]);}o.push(c);}return r&&o.reverse(),o}var eT=13;function ds(t,e,n){if(e>=t)return mp(0,t,e,n);let r=2**eT,o=ho/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 nT(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 fp(t,e){return rT(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 rT(t,e){let n=e/t,r=Math.ceil(n)-1,o=[],s=0;for(let u=0;u<=r;u++){let l=nT(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 Ir(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=ba(r.startX,r.startY,f,l),b=(u*e+c)*3;t[b]=bo(t[b],m),t[b+1]=bo(t[b+1],m),t[b+2]=bo(t[b+2],m);}}}function ap(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,E=o(p+x,d),T=o(p,d+y),R=o(p+2*x,d),P=o(p,d+2*y);for(let A=0;A<3;A++)t[M+A]=12*t[M+A]+r[E+A]+r[T+A]+r[R+A]+r[P+A]+8>>4;}}}function oT(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++){Te();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 sT(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 up(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 iT(t,e,n,r,o,s,i){let a=ds(e,r,s),u=ds(n,o,i),l=new Int32Array(r*n*3);for(let b=0;b<n;b++){Te();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 aT(t,e,n,r,o,s,i){let a=o<n,u=a?ds(n,o,i):ds(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 bp={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 xc(t,e){if(e/t===2){let r=bp[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 fp(t,e).map(r=>r.map(([o,s])=>[o,Math.round(s*8192)]))}function uT(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++){Te();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=xc(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 lp(t,e){let n=Array.from({length:e},(s,i)=>yc(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:bp[r.get(s)][i]}})}function lT(t,e,n,r){return t>0&&e>0&&n>=t&&r>=e&&(n>t||r>e)}function cT(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),Ir(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),Ir(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 mT(t,e,n,r,o,s){if(r===e||o===n)return uT(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 E=(T,R,P)=>s[(Math.max(0,Math.min(n,R))*e+Math.max(0,Math.min(e-1,T)))*3+P];for(let T=0;T<n;T++)for(let R=0;R<e;R++)for(let P=0;P<3;P++){let A=E(R,T,P),I=E(R-1,T,P)+E(R+1,T,P)+E(R,T-1,P)+E(R,T+1,P);x[(T*e+R)*3+P]=i(A+Math.floor((4*A-I)/8));}}else oT(x,e,n);let y=xc(e,r),g=xc(n,o),M=new Int32Array(r*n*3);for(let E=0;E<n;E++)for(let T=0;T<r;T++)for(let R=0;R<3;R++){let P=0;for(let[A,I]of y[T])P+=I*x[(E*e+A)*3+R];M[(E*r+T)*3+R]=Math.floor((P+4096)/8192);}for(let E=0;E<o;E++)for(let T=0;T<r;T++)for(let R=0;R<3;R++){let P=0;for(let[A,I]of g[E])P+=I*M[(A*r+T)*3+R];u[(E*r+T)*3+R]=i(Math.floor((P+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),E=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-E)/8));}let h=lp(e,r),p=lp(n,o),d=new Int32Array(e*3);for(let x=0;x<o;x++){let y=p[x].k+1,[g,M,E,T]=p[x].weights,R=(y-1)*e*3,P=y*e*3,A=(y+1)*e*3;for(let I=0;I<e*3;I++)d[I]=Math.floor((g*c[R+I]+M*c[P+I]+E*c[A+I]+T/2)/T);for(let I=0;I<r;I++){let S=h[I].k,[w,C,v,D]=h[I].weights,_=Math.max(0,S-1),U=Math.min(e-1,S+1);for(let F=0;F<3;F++)u[(x*r+I)*3+F]=Math.floor((w*d[_*3+F]+C*d[S*3+F]+v*d[U*3+F]+D/2)/D);}}return u}function fT(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&&ha(t,e,n)==="filter"?"reduced":r*o<e*n?a?"despeckled":"reduced":"nearest"}function hp(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 E=new Int32Array(h*p*3);for(let Y=0;Y<p;Y++){let X=x+Y;for(let B=0;B<h;B++){let W=d+B;if(X<0||X>=t.height||W<0||W>=t.width)continue;let j=(X*t.width+W)*4,Z=(Y*h+B)*3;E[Z]=t.data[j],E[Z+1]=t.data[j+1],E[Z+2]=t.data[j+2];}}let T=p===2&&b===1&&m>h&&(!a||u||!!c),R=h===2&&m===1&&b>p&&(!a||u||!!c);(T||R)&&(l||sT(E,h,p,T),T&&m>=2*h?(E=up(E,h,p,true),p=1):R&&b>=2*p&&(E=up(E,h,p,false),h=1));let P=m>=h&&b>=p&&(m>h||b>p),A=m<h&&b<p,I=m>h&&b<p||m<h&&b>p,S=!!c&&!!a&&!u,w=I&&(!a||u||S),C=w?fT(E,h,p,m,b):"nearest",v=w&&C==="nearest"&&(m<h&&m*2>h||b<p&&b*2>p),D=w&&C!=="nearest",_=h*p<=2304||h*p>16384,U=m<h&&b===p||b<p&&m===h,F=(A||U)&&_&&!l&&!(m<h&&3*m+2<=2*h)&&!(b<p&&3*b+2<=2*p)&&(h*p<=2304||ha(E,h,p)==="replicate");if(U&&(!a||u||S)){F&&ap(E,h,p);let Y=aT(E,h,p,m,b,y,g);S?(Ir(Y,m,b,c),a(Y),f&&f(Y)):a&&a(Y);for(let X=0,B=0;X<m*b;X++,B+=3)M[X*4]=Y[B],M[X*4+1]=Y[B+1],M[X*4+2]=Y[B+2],M[X*4+3]=255;return {width:m,height:b,data:M}}if(P&&lT(h,p,m,b)&&(!a||u||S)&&ha(E,h,p)==="filter"){let Y,X=E;S&&(m===h||b===p?b>p?(Y=new Int32Array((p+1)*h*3),Y.set(E),Y.set(E.subarray((p-1)*h*3),p*h*3),Ir(Y,h,p+1,c,false,false,void 0,Int32Array.from({length:p+1},(W,j)=>g?b-1-j:j)),a(Y),X=Y.subarray(0,h*p*3)):(X=E.slice(),Ir(X,h,p,c,false,false,void 0,Int32Array.from({length:p},(W,j)=>g?b-1-j:j)),a(X)):(Y=cT(E,h,p,m,b,c,g),a(Y)));let B=mT(X,h,p,m,b,Y);if(y||g){let W=B.slice();for(let j=0;j<b;j++)for(let Z=0;Z<m;Z++){let ut=((g?b-1-j:j)*m+(y?m-1-Z:Z))*3;B.set(W.subarray(ut,ut+3),(j*m+Z)*3);}}a&&u&&a(B),f&&S&&f(B);for(let W=0,j=0;W<m*b;W++,j+=3)M[W*4]=B[j],M[W*4+1]=B[j+1],M[W*4+2]=B[j+2],M[W*4+3]=255;return {width:m,height:b,data:M}}((P||v||C==="despeckled")&&_||A&&F)&&!l&&!T&&!R&&ap(E,h,p);let O=S&&(m>=h&&b>=p||D&&m*b>=h*p),H=O&&D&&m<h&&b>p;if(H){let Y=new Int32Array((p+1)*h*3);Y.set(E),Y.copyWithin(p*h*3,(p-1)*h*3,p*h*3),E=Y;}O&&Ir(E,h,H?p+1:p,c,false,false,void 0,g?Int32Array.from({length:H?p+1:p},(Y,X)=>b-1-X):void 0),a&&!u&&(!S||O)&&a(E);let k=D?Math.min(h,m):m,G=D?Math.min(p,b):b,N=D?(Y,X,B)=>ds(Y,X,B):(Y,X,B)=>mp(0,Y,X,B),K=D&&m>h,V=D&&b>p,z=N(h,k,y&&!K),st=N(p,G,g&&!V);if(v){let Y=(X,B,W,j)=>{for(let Z=0;Z<W;Z++){let ut=j?W-1-Z:Z,it=W<B?Math.floor(((ut+1)*2*B-W)/(2*W)):yc(ut,B,W);X[Z]=[[Math.max(0,Math.min(B-1,it)),1]];}};Y(z,h,m,y),Y(st,p,b,g);}else if(I&&!D){let Y=(X,B,W,j)=>{if(!(W<=B))for(let Z=0;Z<W;Z++){let ut=Math.max(0,Math.min(B-1,(Z+.5)*B/W-.5)),it=Math.floor(ut),ht=ut-it,ct=tt=>j?B-1-tt:tt;X[Z]=[[ct(it),1-ht],[ct(Math.min(B-1,it+1)),ht]];}};Y(z,h,m,y),Y(st,p,b,g);}let at=D?new Float64Array(k*G*3):new Int32Array(m*b*3);A&&(at=iT(E,h,p,m,b,y,g));for(let Y=0;!A&&Y<G;Y++){let X=st[Y];for(let B=0;B<k;B++){let W=z[B],j=0,Z=0,ut=0,it=0;for(let[tt,lt]of X)for(let[dt,zt]of W){let Se=zt*lt;it+=Se;let Qt=(tt*h+dt)*3;j+=E[Qt]*Se,Z+=E[Qt+1]*Se,ut+=E[Qt+2]*Se;}let ht=(Y*k+B)*3,ct=tt=>D?tt/it:I?Math.ceil(tt/it-.5):Math.floor((2*tt+it)/(2*it));at[ht]=ct(j),at[ht+1]=ct(Z),at[ht+2]=ct(ut);}}if(D){let Y=m<h,X;if(H){let ut=new Float64Array(k*3);for(let it=0;it<k;it++){let ht=0,ct=[0,0,0];for(let[tt,lt]of z[it]){ht+=lt;for(let dt=0;dt<3;dt++)ct[dt]+=E[(p*h+tt)*3+dt]*lt;}for(let tt=0;tt<3;tt++)ut[it*3+tt]=ct[tt]/ht;}X=ut;}for(let ut of [Y,!Y]){let it=at;at=new Int32Array(it.length);let ht=X,ct=(tt,lt,dt)=>lt>=G&&ht?ht[Math.max(0,Math.min(k-1,tt))*3+dt]:it[(Math.max(0,Math.min(G-1,lt))*k+Math.max(0,Math.min(k-1,tt)))*3+dt];if(ut&&ht){let tt=new Int32Array(k*3);for(let lt=0;lt<k;lt++)for(let dt=0;dt<3;dt++){let zt=ht[lt*3+dt],Se=ct(lt-1,G,dt)+ct(lt+1,G,dt);tt[lt*3+dt]=Math.max(0,Math.min(255,Math.floor(zt+(2*zt-Se)/4)));}X=tt;}for(let tt=0;tt<G;tt++)for(let lt=0;lt<k;lt++)for(let dt=0;dt<3;dt++){let zt=ct(lt,tt,dt),Se=ut?ct(lt-1,tt,dt)+ct(lt+1,tt,dt):ct(lt,tt-1,dt)+ct(lt,tt+1,dt);at[(tt*k+lt)*3+dt]=Math.max(0,Math.min(255,Math.floor(zt+(2*zt-Se)/4)));}}let B=at;at=new Int32Array(m*b*3);let W=(ut,it)=>ut===it?Array.from({length:it},(ht,ct)=>[[ct,1]]):it===2*ut?Array.from({length:it},(ht,ct)=>{let tt=Math.max(0,Math.min(ut-1,(ct+.5)*ut/it-.5)),lt=Math.floor(tt);return [[lt,1-(tt-lt)],[Math.min(ut-1,lt+1),tt-lt]]}):fp(ut,it),j=W(k,m),Z=W(G,b);K&&y&&j.reverse(),V&&g&&Z.reverse();for(let ut=0;ut<b;ut++)for(let it=0;it<m;it++)for(let ht=0;ht<3;ht++){let ct=0;for(let[tt,lt]of Z[ut])for(let[dt,zt]of j[it])ct+=B[(tt*k+dt)*3+ht]*lt*zt;at[(ut*m+it)*3+ht]=Math.max(0,Math.min(255,Math.floor(ct+.5+1e-7)));}}if(I&&!D&&!v){let Y=at.slice(),X=(B,W,j)=>Y[(Math.max(0,Math.min(b-1,W))*m+Math.max(0,Math.min(m-1,B)))*3+j];for(let B=0;B<b;B++)for(let W=0;W<m;W++)for(let j=0;j<3;j++){let Z=X(W,B,j),ut=m<h?X(W-1,B,j)+X(W+1,B,j):X(W,B-1,j)+X(W,B+1,j);at[(B*m+W)*3+j]=Math.max(0,Math.min(255,Z+Math.floor((2*Z-ut)/4)));}}if(S&&!O){let Y=(j,Z,ut,it)=>Int32Array.from({length:j},(ht,ct)=>ut>Z?Math.max(0,Math.ceil((2*ct+1)*Z/(2*ut))-1):it?Math.max(0,Math.min(Z-1,Math.floor(((ct+1)*2*Z-ut)/(2*ut)))):ct),X=v&&m*b>h*p,B=X?Y(m,h,m,true):void 0,W=X?Y(b,p,b,false):void 0;B&&y&&(B=B.slice().reverse()),W&&g&&b>p&&(W=W.slice().reverse().map(j=>b-1-j)),Ir(at,m,b,c,false,false,B,W),a(at);}a&&u&&a(at),f&&S&&f(at);for(let Y=0,X=0;Y<m*b;Y++,X+=3)M[Y*4]=at[X],M[Y*4+1]=at[X+1],M[Y*4+2]=at[X+2],M[Y*4+3]=255;return {width:m,height:b,data:M}}function pa(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)=>nr(e,Math.floor(r.left+(i+.5)/o),Math.floor(r.top+(a+.5)/s),n.brushOrgX,n.brushOrgY)}function gp(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===Sr?hp(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:hc(Math.min(n.dx,n.dx+n.dw),i),startY:pc(Math.min(n.dy,n.dy+n.dh),a)}:void 0,e.curves):cp(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=wt(c.width,c.height);f&&(Lt(f.ctx,Rt(c.data,c.width,c.height),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",pe(t,f.canvas,Math.round(u),Math.round(l),c.width,c.height),t.restore());}function Ec(t,e,n=false){if(!e.source)return null;let r=Oe(t.view,e.source.bmi,e.source.bits,e.source.cbBits,e.source.palColors?en(t.state):null);if(!r)return null;let o=t.state.colorAdjustment;e.stretch&&t.state.stretchBltMode===Sr&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=!n&&!!o);let s=e.stretch&&t.state.stretchBltMode===Sr&&o,i=Sb(o),a=s&&!i?Cb(o):void 0,u=s?(f=>sl(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=>sl(f,l):void 0},req:{...e,sy:c}}}function gc(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 bT(t,e,n,r,o){let{ctx:s}=t,i=Uh(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=ne(t.state);if(r&&u.kind==="none")return;let l=wt(i.w,i.h);if(!l)return;let c=null;if(o){let p=Ec(t,e);if(!p)return;gp(l.ctx,p.decoded,p.req,i.x,i.y,t.state.stretchBltMode,t.state.brushOrgX,t.state.brushOrgY),c=At(l.ctx,0,0,i.w,i.h);}let f=At(s,i.x,i.y,i.w,i.h),m=pa(t,u);Dh(f,c,m,n,i.x,i.y);mn(n).usesD?Ji():null;Lt(l.ctx,f,0,0),s.save(),s.setTransform(1,0,0,1,0,0),s.globalCompositeOperation=a,s.globalAlpha=1,pe(s,l.canvas,i.x,i.y,i.w,i.h),s.restore();}function Mc(t,e,n){return Math.sign(t!==0?t:e!==0?e:n)}function dp(t,e,n,r){return Mc(t,n,r)>=0&&Mc(t-e,n,r)<0}function xp(t,e,n,r){let o=Math.floor(t/e);return t===o*e&&Mc(0,n,r)<0?o-1:o}function Mp(t,e,n,r,o,s,i,a,u,l,c,f,m){let{ctx:b}=t,h=Nl(s);if(h===170)return;let p=mn(h);if(typeof b.getImageData!="function"){return}if(r===0||o===0)return;let d=ne(t.state);if(p.usesP&&d.kind==="none")return;let x=pa(t,d),y=null,g=a,M=u,E;if(p.usesS){let R=Ec(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:P,adjustAfterSampling:A,curves:I}=R.decoded,S=hc(0,t.state.brushOrgX),w=pc(0,t.state.brushOrgY),C=new Int32Array(3);E=(v,D,_)=>{if(C[0]=v>>16&255,C[1]=v>>8&255,C[2]=v&255,!A){let U=ba(S,w,D,_);for(let F=0;F<3;F++)C[F]=bo(C[F],U);}return P(C),I?.(C),C[0]<<16|C[1]<<8|C[2]};}g=R.req.sx,M=R.req.sy;}let T=(R,P)=>{if(!y)return 0;let A=l<0?g-1-R:g+R,I=c<0?M-1-P:M+P;A=Math.max(0,Math.min(y.width-1,A)),I=Math.max(0,Math.min(y.height-1,I));let S=(I*y.width+A)*4;return y.data[S]<<16|y.data[S+1]<<8|y.data[S+2]};Tc(t,xt(t,e,n),xt(t,e+r,n),xt(t,e,n+o),l,c,(R,P,A,I,S)=>{let w=p.usesS?T(R,P):0;E&&p.usesS&&(w=E(w,A,I));let C=typeof x=="function"?x(A,I):x;return Vt(h,C,w,S)});}function Tc(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 E=Math.abs(o)||1,T=Math.abs(s)||1,R=h*m,P=-h*f,A=-h*c,I=h*l;io(t.ctx,{x,y,w:g-x,h:M-y},(S,w,C)=>{let v=S*16-a,D=w*16-u,_=h*(v*m-D*f),U=h*(l*D-c*v);if(!dp(_,b,R,P)||!dp(U,b,A,I))return -1;let F=Math.min(E-1,xp(_*E,b,R,P)),O=Math.min(T-1,xp(U*T,b,A,I));return i(F,O,S,w,C)});}function hT(t,e){let n=Sn(t),r=wn(t);return {...e,dx:e.dw<0?e.dx+n:e.dx,dy:e.dh<0?e.dy+r:e.dy}}function Ep(t,e,n,r,o,s,i){Rc(t,{plan:qi(13369376),dx:e,dy:n,dw:r,dh:o,source:s,...i,dibOrigin:"top-left",stretch:true});}function Rc(t,e){let{ctx:n}=t,r=hT(t,e),o=r.plan;switch(o.kind){case "noop":return;case "solid":gc(n,o.color==="black"?"#000000":"#ffffff","source-over",r);return;case "invert-dest":gc(n,"#ffffff","difference",r);return;case "copy":{let s=Ec(t,r);s&&gp(n,s.decoded,s.req,0,0,t.state.stretchBltMode,t.state.brushOrgX,t.state.brushOrgY);return}case "ternary":{let s=ne(t.state);if(o.index===240&&s.kind!=="tile"){s.kind==="solid"&&gc(n,t.state.brushColor,"source-over",r);return}bT(t,r,o.index,o.operands.usesP,o.operands.usesS);}}}function da(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 yp(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,E=r>=100?da(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,T=b===0&&d===0&&h===0&&p===0,R=T?1:b,P=T?1:d,A={sx:R*f+(T?0:p*m+x),sy:P*m+(T?0:h*f+y),sw:R*g,sh:P*M};return jt(t)?(Mp(t,i,a,u,l,c,E,A.sx,A.sy,A.sw,A.sh,"top-left",o),true):(Rc(t,{plan:qi(c),dx:Gt(t,i),dy:Wt(t,a),dw:Kt(t,u),dh:ae(t,l),source:E,...A,dibOrigin:"top-left",stretch:o}),true)}function pT(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=da(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)?(Mp(t,s,i,a,u,l,c,f,m,b,h,"bottom-left",true),true):(Rc(t,{plan:qi(l),dx:Gt(t,s),dy:Wt(t,i),dw:Kt(t,a),dh:ae(t,u),source:c,sx:f,sy:m,sw:b,sh:h,dibOrigin:"bottom-left",stretch:true}),true)}function Tp(t,e,n,r,o){switch(e){case 76:return yp(t,n,r,o,false);case 77:return yp(t,n,r,o,true);case 81:return pT(t,n,r,o);default:return false}}function xa(t,e,n,r,o,s,i,a=false){return !n||!r||!o||!s?null:Oe(t.view,e+n,e+o,s,i===1?en(t.state):null,a)}function Rp(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 ya(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 po(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 ga(t,e,n,r,o,s,i,a,u){let l=Gt(t,e),c=Wt(t,n),f=Kt(t,r),m=ae(t,o);f<0&&(l+=Sn(t)),m<0&&(c+=wn(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),E=Math.min(t.canvasW,x+b),T=Math.min(t.canvasH,y+h);if(E<=g||T<=M)return null;let R=Math.min(s,s+a),P=Math.min(i,i+u),A=new Int32Array(E-g),I=new Int32Array(T-M),S=f<0||m<0,w=(C,v,D)=>S?Math.min(v-1,Math.floor(C*v/D)):xs(C,v,D);for(let C=g;C<E;C++){let v=w(C-x,p,b);A[C-g]=a<0!=f<0?R+p-1-v:R+v;}for(let C=M;C<T;C++){let v=w(C-y,d,h);I[C-M]=u<0!=m<0?P+d-1-v:P+v;}return {box:{x:g,y:M,w:E-g,h:T-M},col:A,row:I}}function Es(t,e,n){let{ctx:r}=t;if(typeof r.getImageData=="function"&&io(r,e,n))return;let o=nn(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;}rn(r,e,o,Rt(s,e.w,e.h));}function wr(t){return Math.round(t/255)}function dT(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=wr(s*n),m=wr(i*n),b=wr(a*n),h=wr(o*n));let p=255-h,d=b+wr(c*p),x=m+wr(l*p)+(d>>8);return (f+wr(u*p)+(x>>8)&255)<<16|(x&255)<<8|d&255}function xT(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=xa(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=ya(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),c=ga(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));Es(t,f,(h,p,d)=>dT(po(u,m[h-f.x],b[p-f.y]),d,i,a));}function gT(t,e,n,r){let{view:o}=t;if(r<108)return;let s=us(o.getUint32(n+32,true),en(t.state)),i=xa(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=ya(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),o.getInt32(n+92,true),o.getInt32(n+96,true)),u=ga(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;Es(t,l,(m,b)=>{let h=po(i,c[m-l.x],f[b-l.y])&16777215;return h===s?-1:h});}function MT(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=xa(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=Rp(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=ya(o,n+44,o.getInt32(n+36,true),o.getInt32(n+40,true),u,l),p=ga(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((mn(i).usesD||f!==null&&mn(a).usesD)&&!Pe(t.ctx)){return}let M=pa(t,ne(t.state)),E=Math.min(h.sx,h.sx+h.sw),T=Math.min(h.sy,h.sy+h.sh);Es(t,d,(R,P,A)=>{let I=x[R-d.x],S=y[P-d.y],w=i;if(f){let D=m+I-E,_=b+S-T;w=(D>=0&&_>=0&&D<f.width&&_<f.height?f.bits[_*f.width+D]:0)?i:a;}let C=c?po(c,I,S)&16777215:0,v=typeof M=="function"?M(R,P):M;return Vt(w,v,C,A)});}function ET(t,e,n,r){let{view:o}=t;if(r<140)return;let s=[0,1,2].map(x=>xt(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=xa(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=Rp(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=ya(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,P=f+M;if(R<0||P<0||R>=l.width||P>=l.height||!l.bits[P*l.width+R])return -1}let E=m.sw<0?m.sx-1-x:m.sx+x,T=m.sh<0?m.sy-1-y:m.sy+y;return po(u,E,T)&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===Sr&&x>0&&y>0){Ep(t,Math.round(h[0]/16),Math.round(h[1]/16),p[0]<h[0]?-x:x,d[1]<h[1]?-y:y,da(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),E=Math.abs(m.sw),T=Math.abs(m.sh),R=Math.max(0,g),P=Math.max(0,M),A=Math.min(t.canvasW,g+x),I=Math.min(t.canvasH,M+y);if(A<=R||I<=P||E===0||T===0)return;let S=p[0]<h[0],w=d[1]<h[1];Es(t,{x:R,y:P,w:A-R,h:I-P},(C,v)=>{let D=xs(C-g,E,x),_=xs(v-M,T,y);return b(S?E-1-D:D,w?T-1-_:_,D,_)});return}t.state.stretchBltMode===Sr&&t.halftoneRotatedAdjusts===void 0&&(t.halftoneRotatedAdjusts=false),Tc(t,h,p,d,m.sw,m.sh,(x,y)=>b(x,y));}function TT(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),Oe(c,0,r,s,i===1?en(t.state):null)}function RT(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=TT(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=ga(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;Es(t,y,(E,T)=>{let R=g[E-y.x],P=M[T-y.y],A=i+u-1-P,I=h?p-1-A-f:m-1-(A-f);if(I<0||I>=d.height)return -1;let S=s+R;return S<0||S>=d.width?-1:po(d,S,I)&16777215});}function Pp(t,e,n,r,o){switch(e){case 114:return xT(t,n,r,o),true;case 116:return gT(t,n,r,o),true;case 78:return MT(t,n,r,o),true;case 79:return ET(t,n,r,o),true;case 80:return RT(t,n,r,o),true;default:return false}}var Ap="\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",Ip={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 PT=[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 Cc(t,e){return e===2?t:t>=128&&t<=159?PT[t-128]:t}var AT={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"},IT={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"},Sp={874:"windows-874",932:"shift_jis",936:"gbk",949:"euc-kr",950:"big5"};function ST(t,e){return {codes:t.map(n=>n<128?n:e.charCodeAt(n-128)),byteLengths:t.map(()=>1)}}function Zn(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 Sp)))return ST(t,(r!==void 0?Ip[r]:void 0)??Ap);if(e===130){let i=[],a=[];for(let u=0;u<t.length;u++){let l=t[u],c=n0(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?Sp[r]:(e===0||e===1)&&o!==void 0?IT[o]??"windows-1252":AT[e]??"windows-1252";if(s==="windows-1252")return {codes:t.map(i=>Cc(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=>Cc(i,e)),byteLengths:t.map(()=>1)}}}var wT=[0,0,.4096065,.4875311,.5515784,.6070649,.656426,.7013281,.7426686,.7811829,.8173296,.8514569,.8838279,.9147507,.9443338,.9726402],CT=[0,0,.0556662,.0852493,.1161453,.1485431,.1826704,.2188171,.2572957,.2986719,.343574,.3929351,.4483443,.5124689,.5903349,.6957428],wp=[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],vT=[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 Ts(t,e,n,r){return n<=1?e:n>=16?t:r?vT[Math.floor((n*wp[t]+(16-n)*wp[e])/16)]:e+Math.floor((t-e)*(t>e?wT[n]:CT[n]))}var Cp=[0,1,2,2,5,5,8,0,3,4,5,5,8,8,3,3,6,7,8,8,23,16,6,6,7,8,23,23,16,20,20,21,22,23,23,20,20,20,21,22,23,45,41,41,41,42,43,44,45,9,10,11,11,15,15,19,12,13,14,15,15,19,19,12,16,17,18,19,19,23,16,16,20,21,22,23,23,36,20,20,21,22,23,45,36,41,41,42,43,44,45,41,41,41,42,43,44,45,24,25,26,26,30,30,35,27,28,29,30,30,35,35,31,32,33,34,35,35,40,31,36,37,38,39,40,40,36,36,41,42,43,44,45,36,41,41,42,43,44,45,41,41,65,65,66,67,68,24,25,26,49,49,49,54,46,47,48,49,49,54,54,50,51,52,53,54,54,59,50,55,56,57,58,59,59,55,55,60,61,62,63,64,55,60,60,65,66,67,68,60,60,65,65,66,67,68,46,47,48,49,49,73,73,46,47,48,49,73,73,73,69,70,71,72,73,73,78,69,74,75,76,77,78,78,74,74,79,80,81,82,83,74,79,79,84,85,86,87,79,79,84,84,88,89,90,46,47,48,49,73,73,73,69,70,71,72,73,73,73,69,70,71,72,73,73,78,91,91,92,93,94,78,78,91,91,95,96,97,98,83,91,95,95,99,100,101,102,95,95,99,99,103,104,105,69,70,71,72,73,73,73,69,70,71,72,73,73,73,91,91,92,93,94,94,78,91,91,92,93,94,94,98,91,106,106,107,108,98,98,106,106,106,109,110,111,102,106,106,109,109,112,113,114],vp=new Map;for(let t=0;t<243;t++){let e=Math.floor(t/81)%3,n=Math.floor(t/27)%3,r=Math.floor(t/9)%3,o=Math.floor(t/3)%3,s=t%3,i=[e+n+r,n+r+o,r+o+s];vp.set(Cp[(i[0]*7+i[1])*7+i[2]],i);}function Lp(t,e,n){return vp.get(Cp[(t*7+e)*7+n])}var xo=2,yo=4,kp=16,Ea=4096,Rs=8192,LT=[255,255,240,233,225,217,208,199,189,178,167,154,140,124,104,77,0];function Op(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 Bp(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 vc(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 Dp(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 Np(t){return t>=128&&t<=159}function Up(t,e){return !t.glyphIndices&&!(t.options&Ea)&&Np(t.codes[e])}function Gp(t,e){let n=e.codes.length,r=e.codes.map(_=>e.glyphIndices?_:t.glyphIndex(_)),o=!!e.matrix&&Math.abs(e.matrix[0])>1e-9&&Math.abs(e.matrix[1])>1e-9&&!!t.rotatedLinearAdvance,s=[];for(let _=0;_<n;_++)s.push(Up(e,_)&&!e.dx?0:e.dx&&_<e.dx.length?e.dx[_]:e.matrix?o?t.rotatedLinearAdvance(r[_]):t.rotatedAdvance(r[_],!!e.matrix&&e.matrix[0]<0):t.advance(r[_]));!e.dx&&e.textJustification&&!e.glyphIndices&&(s=Bs(s,e.codes,e.textJustification.extra,e.textJustification.count));let i=[];for(let _=0;_<n;_++)i.push(e.dy&&_<e.dy.length?e.dy[_]:0);let a=0,u=0;for(let _=0;_<n;_++)a+=s[_],u+=i[_];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?_=>Math.round(_*16)/16:_=>_,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 _=U=>{let F=Math.round(U*a*16);return (y===6?-Math.trunc(F/2):-F)/16};d=_(c),x=_(f);}let g=(_,U)=>o?{x:e.x+d+h(c*(_-p))+h(m*U),y:e.y+x+h(f*(_-p))+h(b*U)}:{x:e.x+c*_+m*U,y:e.y+f*_+b*U},M=e.textAlign&24,E=!!l&&Math.abs(l[0])>1e-9&&Math.abs(l[1])>1e-9,T=l?t.rotatedMetrics?.(l[0],l[1]):void 0,R=T?T.ascent:E?t.rotatedAscent??t.ascent:t.ascent,P=T?T.descent:E?t.rotatedDescent??t.descent:t.descent,A=M===24?0:M===8?-P:R,I=[],S=[],w=e.glyphMatrix??l,C=w?[w[0],w[1],w[2],w[3]]:void 0,v=p,D=A;for(let _=0;_<n;_++){let U=g(v,D),F=!!t.fractionalOrigins,O=F?Math.floor(U.x):Math.round(U.x),H=F?t.fractionalOrigins==="xy"?Math.round((U.x-O)*4)*16:t.fractionalOrigins==="x"?Math.round((U.x-O)*6)*(64/6):Math.round((U.x-O)*64):0,k=t.fractionalOrigins==="xy"?Math.floor(U.y):Math.round(U.y),G=t.fractionalOrigins==="xy"?Math.round((U.y-k)*4)*16:0;if(S.push({x:O+H/64,y:k+G/64,along:v,down:D}),!Up(e,_)){let N=t.glyph(r[_],C,H,G);N.bitmap&&I.push({x:O+N.bitmap.left,y:k-N.bitmap.top,bitmap:N.bitmap});}v+=s[_],D+=i[_];}return {glyphs:r,total:a,totalY:u,startAlong:p,baseDown:A,hAlign:y,at:g,placed:I,origins:S}}function Dc(t,e,n,r){let{total:s,totalY:i,startAlong:a,baseDown:u,at:l,placed:c,hAlign:m}=Gp(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&yo&&n.rect?n.rect:null;if(n.options&xo&&n.rect&&vc(t,n.rect,n.bkColor,null),n.bkMode===2&&s!==0)if(b){let T=[l(a,u-e.ascent),l(a+s,u-e.ascent),l(a+s,u+e.descent),l(a,u+e.descent)];Dp(t,T,n.bkColor,y);}else {let T=Math.round(n.x+a),R=Math.round(n.y+u),P=Math.min(T,T+Math.round(s)),A=Math.max(T,T+Math.round(s));vc(t,{left:P,top:R-e.ascent,right:A,bottom:R+e.descent},n.bkColor,y);}let g=n.bkMode===2;if(!g&&n.options&xo&&n.rect&&c.length>0){let T,R,P,A;if(b){let I=[l(a,u-e.ascent),l(a+s,u-e.ascent),l(a+s,u+e.descent),l(a,u+e.descent)];T=Math.min(...I.map(S=>S.x)),P=Math.max(...I.map(S=>S.x)),R=Math.min(...I.map(S=>S.y)),A=Math.max(...I.map(S=>S.y));}else {let I=Math.round(n.x+a),S=Math.round(n.y+u);T=Math.min(I,I+Math.round(s)),P=Math.max(I,I+Math.round(s)),R=S-e.ascent,A=S+e.descent;}for(let I of c)T=Math.min(T,I.x),R=Math.min(R,I.y),P=Math.max(P,I.x+I.bitmap.width),A=Math.max(A,I.y+I.bitmap.height);g=n.rect.left<=T&&n.rect.top<=R&&n.rect.right>=P&&n.rect.bottom>=A;}if(_p(t,c,n.textColor,e.mode!=="mono",y,g),(n.underline||n.strikeOut)&&s!==0){let T=[];n.underline&&T.push([e.underlinePosition,Math.max(1,e.underlineThickness),0]),n.strikeOut&&T.push([e.strikeoutPosition,Math.max(1,e.strikeoutThickness),e.strikeoutShift??0]);let R=!b&&n.plusBars==="snapped"&&e.exactDecorations?Lc(e.exactDecorations,n,n.x+a,n.y+u,s):null,P=0;for(let[A,I,S]of T){let w=R?.[P++];if(b){let C=[l(a,u-A),l(a+s,u-A),l(a+s,u-A+I),l(a,u-A+I)];Dp(t,C,n.textColor,y);}else {let C=Math.round(n.x+a)+S,v=Math.round(n.y+u)-A,D=w?Math.round(w.left):Math.min(C,C+Math.round(s)),_=w?Math.round(w.right):Math.max(C,C+Math.round(s));vc(t,{left:D,top:v,right:_,bottom:v+I},n.textColor,y);}}}let M=m===6?0:m===2?-s:s,E=m===6?0:i;return {dx:h*M+d*E,dy:p*M+x*E}}function _p(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 E of e)i=Math.min(i,E.x),a=Math.min(a,E.y),u=Math.max(u,E.x+E.bitmap.width),l=Math.max(l,E.y+E.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(E=>E.bitmap.channels===3)){FT(t,e,n,i,a,f,m);return}let b=new Uint8Array(f*m),h=r?16:1;for(let E of e){let T=E.bitmap;for(let R=0;R<T.height;R++){let P=E.y+R-a;if(!(P<0||P>=m))for(let A=0;A<T.width;A++){let I=T.data[R*T.width+A];if(!I)continue;let S=E.x+A-i;if(S<0||S>=f)continue;let w=P*f+S;r&&b[w]?b[w]=((b[w]-1|I-1)&15)+1:I>b[w]&&(b[w]=I);}}}let p=wt(f,m);if(!p)return;let[d,x,y]=Op(n),g=new Uint8ClampedArray(f*m*4),M=null;if(r&&typeof t.getImageData=="function")try{M=At(t,i,a,f,m).data;}catch{M=null;}for(let E=0;E<f*m;E++){let T=b[E];if(T<=(r?1:0))continue;let R=E*4;!r||T>=h?(g[R]=d,g[R+1]=x,g[R+2]=y,g[R+3]=255):M&&M[R+3]===255?(g[R]=Ts(d,M[R],T,s),g[R+1]=Ts(x,M[R+1],T,s),g[R+2]=Ts(y,M[R+2],T,s),g[R+3]=255):M?Bp(g,R,[d,x,y],(P,A)=>Ts(P,A,T,s)):(g[R]=d,g[R+1]=x,g[R+2]=y,g[R+3]=255-LT[T]);}Lt(p.ctx,Rt(g,f,m),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,pe(t,p.canvas,i,a,f,m),t.restore();}function Uc(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=Uc(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 w=(D,_)=>{let U=[_,-D,D,_];return d?[d[0]*U[0]+d[2]*U[1],d[1]*U[0]+d[3]*U[1],d[0]*U[2]+d[2]*U[3],d[1]*U[2]+d[3]*U[3]]:U},C=uf(y),v=y/10*(Math.PI/180);x=w(C.sin,C.cos),d=w(Math.sin(v),Math.cos(v));}if(x&&r.playbackStretch&&r.playbackStretch!==1){let w=r.playbackStretch;x=[x[0]*w,x[1]*w,x[2],x[3]];}let g=(n.textAlign&1)!==0,M=g?n.curX:r.x,E=g?n.curY:r.y,T=(w,C)=>({x:o*w+i*C+u,y:s*w+a*C+l}),R=T(M,E),P=null;if(r.rect&&r.options&(xo|yo)){let w=T(r.rect.left,r.rect.top),C=T(r.rect.right,r.rect.bottom);P={left:Math.round(Math.min(w.x,C.x)),top:Math.round(Math.min(w.y,C.y)),right:Math.round(Math.max(w.x,C.x)),bottom:Math.round(Math.max(w.y,C.y))};}let A={codes:r.codes,glyphIndices:r.glyphIndices,x:R.x,y:R.y,dx:r.dx?r.dx.map(w=>w*c):null,dy:r.dy?r.dy.map(w=>-w*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:P,matrix:d,glyphMatrix:x,underline:n.fontUnderline,strikeOut:n.fontStrikeOut},I=Dc(t,h,A,n.fontFamilyMap),S=o*a-s*i;return S===0?{dx:0,dy:0}:{dx:(a*I.dx-i*I.dy)/S,dy:(-s*I.dx+o*I.dy)/S}}var Wp=1.2,Fp=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,Wp)+.5)),UT=Uint8Array.from({length:256},(t,e)=>Math.floor(255*Math.pow(e/255,1/Wp)+.5));function Ma(t,e,n){let r=Fp[t],o=Fp[e],s=n===1&&r<o||n===5&&r>o;return UT[Math.floor((r*n+o*(6-n)+(s?2:3))/6)]}function bn(t){return Math.round(t*6/255)}function Hp(t,e,n,r,o=Math.round){let s=n[r],i=n[r+1],a=n[r+2];if(!s&&!i&&!a)return;if(!t[e]&&!t[e+1]&&!t[e+2]){t[e]=s,t[e+1]=i,t[e+2]=a;return}let u=Lp(Math.min(6,bn(t[e])+bn(s)),Math.min(6,bn(t[e+1])+bn(i)),Math.min(6,bn(t[e+2])+bn(a)));for(let l=0;l<3;l++)t[e+l]=o(u[l]*255/6);}function _T(t,e,n){return Ma(t,e,bn(n*255))}function FT(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)continue;let g=(p*b.width+x)*h,M=(d*s+y)*3;if(b.additiveClearType){Hp(a,M,b.data,g);continue}for(let E=0;E<3;E++){let T=h===3?b.data[g+E]:b.data[g]*255;T>a[M+E]&&(a[M+E]=T);}}}}let u=wt(s,i);if(!u)return;let l;try{l=At(t,r,o,s,i).data;}catch{return}let c=Op(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];Bp(f,d,c,(E,T,R)=>_T(E,T,M[R]));continue}let x=bn(b),y=bn(h),g=bn(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]=Ma(c[0],l[d],x),f[d+1]=Ma(c[1],l[d+1],y),f[d+2]=Ma(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;}Lt(u.ctx,Rt(f,s,i),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,pe(t,u.canvas,r,o,s,i),t.restore();}function Lc(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);if(m===1){let h={left:n+.3,right:a+.8,top:b,bottom:b+1};if(a<n||Math.max(Math.abs(n),Math.abs(a),Math.abs(c))>=8388607)return h;let p=De(n),d=De(a),x=De(c),y=Math.floor(p/16),g=Math.floor(x/16);return {...h,nominal:{pts:[p,x,d,x],box:{x:y,y:g,w:Math.ceil(d/16+1)-y,h:Math.ceil(x/16+1)-g}}}}return {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 Xp(t,e,n={}){let{placed:r,total:o,startAlong:s,baseDown:i}=Gp(t,e),a=[],u=[];if(n.decorations&&e.plusBars==="fractional"&&t.exactDecorations&&!e.matrix&&o!==0&&t.mode==="gray")u.push(...Lc(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),E=e.plusBars==="snapped"&&t.exactDecorations?Lc(t.exactDecorations,e,e.x+s,e.y+i,o):null,T=0,R=(P,A)=>{let I=Math.round(e.y+i)-P,S=E?.[T++],w=S?Math.round(S.left):g,C=S?Math.round(S.right):M;a.push({left:Math.min(w,C),right:Math.max(w,C),top:I,bottom:I+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){let M=g.nominal?.box;l=Math.min(l,M?.x??Math.floor(g.left)),c=Math.min(c,M?.y??Math.floor(g.top)),f=Math.max(f,M?M.x+M.w:Math.ceil(g.right)),m=Math.max(m,M?M.y+M.h: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,E=M.channels===3?3:1;for(let T=0;T<M.height;T++)for(let R=0;R<M.width;R++){let P=T*M.width+R,A=(g.y+T-c)*b+(g.x+R-l);if(p===3&&E===3){Hp(d,A*3,M.data,P*3,M.additiveClearType?Math.round:Math.floor);continue}for(let I=0;I<p;I++){let S=Math.round(M.data[P]*255/x),w=A*p+I;S>d[w]&&(d[w]=S);}}}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){if(g.nominal){let{pts:M,box:E}=g.nominal,T=Ti([{pts:M,closed:false}],{antialias:true,half:false,opaqueSolid:true},E);for(let R=0;R<E.h;R++){let P=(E.y+R-c)*b+E.x-l;for(let A=0;A<E.w;A++)y[P+A]=Math.max(y[P+A],T[R*E.w+A]);}continue}for(let M=Math.floor(g.top);M<Math.ceil(g.bottom);M++){let E=Math.min(M+1,g.bottom)-Math.max(M,g.top);for(let T=Math.floor(g.left);T<Math.ceil(g.right);T++){let R=Math.round(E*4)*Math.round((Math.min(T+1,g.right)-Math.max(T,g.left))*8),P=Math.round(R*255/32),A=(M-c)*b+T-l;P>y[A]&&(y[A]=P);}}}return {x:l,y:c,width:b,height:h,channels:p,data:d,bars:y}}function Yp(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 kT(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&Rs)!==0,b=Yp(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&kp)!==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:gt(t),textJustification:u.textJustification});return g?(u.textAlign&1&&(u.curX+=g.dx,u.curY+=g.dy),true):false}function OT(t){return (t&6)===6?"center":t&2?"right":"left"}function BT(t){let e=t&24;return e===24?"alphabetic":e===8?"bottom":"top"}function _c(t,e,n,r,o,s,i,a,u=null){let l=r?Os(r):t.measureText(n).width,c=r?o+af(l,i):o;if(e.bkMode===2){let f=Ks(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=ru(r),m=u?ru(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)&&Lf(t,e,c,s,l,a);}function $p(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)||kT(t,e,n,c,f,m))return true;let b=Ke(s,e+f,c);if(b.length===0)return true;let p=jt(t)?gt(t):null,d=p?Math.hypot(p[2],p[3]):Math.abs(ae(t,1)),x=p?Math.hypot(p[0],p[1]):null;vf(o,i,d);let y=OT(i.textAlign);o.textBaseline=BT(i.textAlign),o.textAlign=y==="center"?"center":y==="right"?"right":"left";let g=(s.getUint32(n+44,true)&Rs)!==0,M=Yp(s,e,n,g?c*2:c,m),E=M&&g?M.filter((S,w)=>w%2===0):M,T=M&&g?M.filter((S,w)=>w%2===1):null,R=T?T.map(S=>p?S*d:ae(t,S)):null,P=E?E.map(S=>x!==null?S*x:Kt(t,S)):null;if(!P&&i.textJustification&&!g){let S=b.split(""),w=S.map(v=>o.measureText(v).width),C=x??Kt(t,1);P=Bs(w,S.map(v=>v.charCodeAt(0)),i.textJustification.extra*C,i.textJustification.count);}P&&(o.textAlign="left");let A=p?Ft(t,u,l):{x:Gt(t,u),y:Wt(t,l)},I=lf(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),I!==0&&o.rotate(I),_c(o,i,b,P,0,0,y,d,R),o.restore()):I!==0?(o.save(),o.translate(A.x,A.y),o.rotate(I),_c(o,i,b,P,0,0,y,d,R),o.restore()):_c(o,i,b,P,A.x,A.y,y,d,R),a){let S=x??Kt(t,1),w=P&&S?Os(P)/S:S?o.measureText(b).width/S:0,C=y==="center"?0:y==="right"?-w:w,v=y!=="center"&&T?Os(T):0;i.curX+=C*Math.cos(I)-v*Math.sin(I),i.curY+=C*Math.sin(I)+v*Math.cos(I);}return true}function kc(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};$p(b,0,8,f);}function jp(t,e,n,r){let{view:o}=t;return Zn(Array.from({length:n},(s,i)=>o.getUint8(e+i)),r,t.codePages)}function Vp(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 NT(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 E=o?null:jp(t,e+d,p,c),T=o?Array.from({length:p},(I,S)=>s.getUint16(e+d+S*2,true)):E.codes,R=null,P=(x&Rs)!==0,A=p*(P?2:1);g&&g<=a-e&&A<=Math.floor((a-(e+g))/4)&&(R=Array.from({length:A},(I,S)=>s.getInt32(e+g+S*4,true)),o||(R=Vp(R,E.byteLengths,P))),kc(t,b,h,T,x|Ea,y,R);}return true}function GT(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 kc(t,i,a,h,l,b,null),true}function zp(t,e,n,r,o){if(e===84)return $p(t,n,r,o);if(e===83||e===96||e===97||e===108){if(e===96||e===97)return NT(t,n,r,o,e===97);if(e===108)return GT(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=jp(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&Rs)!==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=Vp(d,b.byteLengths,x)),kc(t,u,l,b.codes,m,h,d),true}return false}function Cr(t,e,n){let r=Il(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,je(t,r.region);}function qp(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 sh(Gt(t,r),Wt(t,o),Kt(t,s-r),ae(t,i-o))}function $T(t,e,n){return n>=24&&Cr(t,qp(t,e),"intersect"),true}function jT(t,e,n){return n>=24&&Cr(t,qp(t,e),"exclude"),true}var Oc={1:"intersect",2:"union",3:"xor",4:"exclude",5:"replace"};function VT(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=Oc[s];if(!i)return true;if(o===0)return i==="replace"&&(t.clipRegion=null,je(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=Ol(t,b),y=Bl(t,h);l.push({x,y,w:Ol(t,p)-x,h:Bl(t,d)-y});}return l.length===0||(Cr(t,cn(l),i),$(`EMR_EXTSELECTCLIPRGN: mode=${s} (${i}) with ${l.length} rect(s)`)),true}function zT(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=Sn(t),i=wn(t),a=Math.round(Kt(t,r)/s)*s,u=Math.round(ae(t,o)/i)*i;t.clipRegion=pr(t.clipRegion,a,u),je(t,t.clipRegion);}}return true}function Jp(t,e,n,r){switch(e){case 30:return $T(t,n,r);case 75:return VT(t,n,r);case 29:return jT(t,n,r);case 26:return zT(t,n,r);default:return false}}var JT=1;function KT(t,e,n){let r=new Uint8Array(e*n);if(!t.clipRegion)return r.fill(1),r;for(let o of sr(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 ZT(t,e,n,r,o,s,i){let a=new Jt,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 Kp(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=on(t);if(!a)return true;let u=t.canvasW,l=t.canvasH,[c,f]=xt(t,s.getInt32(n,true),s.getInt32(n+4,true)),m=us(s.getUint32(n+8,true),en(i)),b=s.getUint32(n+12,true)===JT,h;try{h=At(o,0,0,u,l).data;}catch{return true}let p=ZT(h,u,l,Math.round(c/16),Math.round(f/16),b?d=>d===m:d=>d!==m,KT(t,u,l));return ue(t,p,a,i.rop2),true}var tR=0,Zp=1,ed=2;function eR(t,e,n,r){let o=Math.floor((e-t)*65536/r);return Math.floor((t*65536+o*n)/65536)>>8}function nR(t,e){let n=or([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 rR(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===ed?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]=xt(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 Qp(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?nn(i,a):null;c&&rn(t.ctx,{x:n,y:r,w:i,h:a},c,Rt(u,i,a));}function oR(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 nd(t,e,n,r){if(e!==118)return false;let o=rR(t,n,r);if(!o)return true;let{ctx:s}=t;if(o.mode===tR||o.mode===Zp){let i=o.mode===Zp;for(let[u,l]of o.mesh){let c=oR(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 E=0;for(let T=0;T<3;T++)E=E<<8|Math.max(0,Math.min(255,eR(c.first.c[T],c.second.c[T],M,y)));g.push(E);}for(let M=0;M<x.h;M++)for(let E=0;E<x.w;E++)x.rgb[M*x.w+E]=g[i?M:E];Qp(t,x);}return true}if(o.mode===ed)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)};nR(a,h),Qp(t,h);}return true}var uR=6;function Bc(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 Nc(t,e){let n=new Jt;if(jt(t)){let r=e.map(([o,s,i,a])=>[...xt(t,o,s),...xt(t,i,s),...xt(t,i,a),...xt(t,o,a)]);return or(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(Wt(t,o)),c=Math.round(Wt(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 lR(t,e,n){let r=new Jt,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 od(t,e){let n=e>=2147483648?Zs(e-2147483648):t.objectTable.get(e)??null;return n&&n.kind==="brush"?n:null}function Gc(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?xe(r,n.colorRef):n.color,r.brushPattern=n.pattern??null);try{let s=on(t);s&&ue(t,e,s,r.rop2);}finally{r.brushStyle=o.style,r.brushColor=o.color,r.brushPattern=o.pattern;}}function sd(t,e,n,r){let{view:o}=t;switch(e){case 71:{if(r>=32){let s=o.getUint32(n+16,true),i=od(t,o.getUint32(n+20,true));i&&Gc(t,Nc(t,Bc(o,n+24,s)),i);}return true}case 72:{if(r>=40){let s=o.getUint32(n+16,true),i=od(t,o.getUint32(n+20,true)),a=Math.round(Math.abs(Kt(t,o.getInt32(n+24,true)))),u=Math.round(Math.abs(ae(t,o.getInt32(n+28,true))));if(i){let l=Nc(t,Bc(o,n+32,s));Gc(t,lR(l,a,u),i);}}return true}case 73:case 74:{if(r>=24){let s=o.getUint32(n+16,true),i=Nc(t,Bc(o,n+20,s));e===73?ue(t,i,{kind:"solid",rgb:0},uR):Gc(t,i,null);}return true}default:return false}}function id(t,e,n,r,o){return zp(t,e,n,r,o)||Tp(t,e,n,r,o)||Pp(t,e,n,r,o)||Jp(t,e,r,o)||sd(t,e,r,o)||Kp(t,e,r,o)||nd(t,e,r,o)}function Aa(t,e,n,r,o){return rp(t,e,r,o)||id(t,e,n,r,o)}function cR(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 ad(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]=xt(e,m,b);f===0?t.moveTo(h,p):t.lineTo(h,p),u++;}i&&c>0&&t.closeFigure();}}function Ia(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 Ft(t,x,y)},p=d=>{cR(d,t,h,f,l,c,s);};if(u){p(We(t)),t.rasterPath??(t.rasterPath=new vt),ad(t.rasterPath,t,b,f,l,c,s);return}t.lineStyle={pos:0},Zt(t,{build:d=>{d.beginPath(),p(d);},raster:()=>{let d=new vt;return ad(d,t,b,f,l,c,s),d},fill:s,stroke:true,fillRule:a.polyFillMode===2?"nonzero":"evenodd"});}function ud(t,e,n,r){Ia(t,e,n,r,8,true);}function ld(t,e,n,r){Ia(t,e,n,r,8,false);}function cd(t,e,n,r){Ia(t,e,n,r,4,false);}function md(t,e,n,r){Ia(t,e,n,r,4,true);}function gd(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 Ft(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 xt(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&&mo(t),f(We(t)),t.rasterPath??(t.rasterPath=new vt),b(t.rasterPath,null);else {let h=l?Dn(t):null,p=l?Ft(t,s.curX,s.curY):null;t.lineStyle={pos:0},Zt(t,{build:d=>{d.beginPath(),p&&d.moveTo(p.x,p.y),f(d);},raster:()=>{let d=new vt;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 SR(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||gd(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 wR(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||gd(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 Wc=1,CR=2,vR=4,fd=6;function bd(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 E=false,T=()=>{E||(M&&x?.moveTo(M.x,M.y),g&&y?.moveTo(g[0],g[1]),E=true);};for(let R=0;R<u;R++){let A=m(R)&~Wc;if(A===fd){let[I,S]=f(R),w=Ft(t,I,S),C=xt(t,I,S);x?.moveTo(w.x,w.y),y?.moveTo(C[0],C[1]),E=true;continue}if(A===CR){T();let[I,S]=f(R),w=Ft(t,I,S),C=xt(t,I,S);x?.lineTo(w.x,w.y),y?.lineTo(C[0],C[1]);}else if(A===vR&&R+2<u){T();let I=[0,1,2].map(C=>f(R+C)),S=I.map(([C,v])=>Ft(t,C,v)),w=I.map(([C,v])=>xt(t,C,v));x?.bezierCurveTo(S[0].x,S[0].y,S[1].x,S[1].y,S[2].x,S[2].y),y?.bezierTo(w[0][0],w[0][1],w[1][0],w[1][1],w[2][0],w[2][1]),R+=2;}else continue;m(R)&Wc&&(x?.closePath(),y?.closeFigure());}},h=(m(0)&~Wc)===fd;if(a)h||mo(t),t.rasterPath??(t.rasterPath=new vt),b(We(t),t.rasterPath,null,null);else {let x=h?null:Dn(t),y=h?null:Ft(t,i.curX,i.curY);t.lineStyle={pos:0},Zt(t,{build:g=>{g.beginPath(),b(g,null,null,y);},raster:()=>{let g=new vt;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 LR(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 Hc(t,e,n){let{state:r}=t,o=e&&n,s=o?LR(t.pathCmds):t.pathCmds,i=u=>{u.beginPath(),Lh(u,s);},a=t.rasterPath??new vt;if(o){let u=new vt;u.append(a);for(let l of u.figures)l.closed=true;a=u;}Zt(t,{build:i,raster:()=>a,fill:e,stroke:n,fillRule:r.polyFillMode===2?"nonzero":"evenodd"});}function Is(t){t.pathCmds=[],t.rasterPath=new vt;}function Md(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 DR(t){if(!(t.inPath||!t.rasterPath)){for(let e of t.rasterPath.figures)delete e.tangents,delete e.curveSegs,delete e.roundWiden;Md(t);}}function UR(t){let{state:e}=t;if(t.inPath||!t.rasterPath||(e.penStyle&15)===5)return;let n=ye(t)?{width:16,cap:"round",join:"round",miterLimit:e.miterLimit??10}:Zl(t),r=ls(t.rasterPath,n),o=new vt;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,Md(t);}function wa(t,e,n,r,o){let{ctx:s,state:i}=t;switch(e){case 4:case 3:case 2:case 5:case 6:return SR(t,e,n,r,o);case 87:case 86:case 85:case 88:case 89:return wR(t,e,n,r,o);case 7:return o>=28&&ld(t,n,r,o),true;case 8:return o>=28&&ud(t,n,r,o),true;case 91:return o>=28&&md(t,n,r,o),true;case 56:return bd(t,n,r,o,8),true;case 92:return bd(t,n,r,o,4),true;case 90:return o>=28&&cd(t,n,r,o),true;case 59:return t.inPath=true,t.pathCmds=[],t.rasterPath=new vt,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 Hc(t,true,false),Is(t),true;case 63:return Hc(t,true,true),Is(t),true;case 64:return Hc(t,false,true),Is(t),true;case 65:return DR(t),true;case 66:return UR(t),true;case 68:return t.inPath=false,Is(t),s.beginPath(),true;case 67:{let a=o>=12?t.view.getUint32(r,true):5,u=Oc[a];if(t.inPath||!t.rasterPath||t.rasterPath.figures.length===0)return true;if(!u)return true;let l=Yl(kr(t.rasterPath,i.polyFillMode===2)),c=l.length>0?cn(l):Ne();return Cr(t,c,u),Is(t),true}default:return false}}var ZR=new Set([16,99,100,101,102,103,104,105,106,109,110,111,112,113,119,121,122]);function Ed(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+Ui?_i(o,n):null;return i?s.colorAdjustment=i:$("EMR_SETCOLORADJUSTMENT: invalid COLORADJUSTMENT ignored"),true}default:return ZR.has(e)?(true):false}}function Rd(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=zn(o,n+16),c=xe(s,l);t.objectTable.set(i,{kind:"pen",style:a&255,widthX:u,color:c,flags:a,...as(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=zn(o,n+32),c=xe(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,...as(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=zn(o,n+8),l=xe(s,u),c=o.getUint32(n+12,true);t.objectTable.set(i,{kind:"brush",style:a,color:l,...as(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=sf(o,n-8,n,a,u===1?en(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=Ke(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?Zs(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?xe(s,a.colorRef):a.color,ro(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?xe(s,a.colorRef):a.color,ro(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 Vc(t){return {...t.dpi?{dpi:{...t.dpi}}:{},mode:t.mode,winOrg:{...t.winOrg},winExt:{...t.winExt},vpOrg:{...t.vpOrg},vpExt:{...t.vpExt}}}var s3={2:254,3:2540,4:100,5:1e3,6:1440};function go(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 va(t,e){if(e<1||e>8)return;let n=s3[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 vr(t){return t.mode===7||t.mode===8}function Pd(t,e,n){!vr(t)||e===0||n===0||(t.winExt={cx:e,cy:n},go(t));}function Ad(t,e,n){!vr(t)||e===0||n===0||(t.vpExt={cx:e,cy:n},go(t));}function Ca(t,e,n){let r=Math.imul(t,e);return r===-2147483648&&n===-1?0:Math.trunc(r/n)}function La(t,e,n,r,o){if(!vr(t)||!n||!o)return;let s=Ca(t.winExt.cx,e,n),i=Ca(t.winExt.cy,r,o);s===0||i===0||(t.winExt={cx:s,cy:i},go(t));}function Da(t,e,n,r,o){if(!vr(t)||!n||!o)return;let s=Ca(t.vpExt.cx,e,n),i=Ca(t.vpExt.cy,r,o);s===0||i===0||(t.vpExt={cx:s,cy:i},go(t));}function zc(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 i3(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 Mo(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=i3(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 d3(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 qc(t){let e=d3(t.view);return {...e?{dpi:e}:{},mode:t.mapMode??1,winOrg:t.windowOrg,winExt:{...t.windowExt},vpOrg:t.viewportOrg,vpExt:{...t.viewportExt}}}function Jc(t,e){t.mapMode=e.mode,t.windowExt=e.winExt,t.viewportExt=e.vpExt;}function Sd(t,e,n,r){let o=qc(t);!vr(o)||n===0||r===0||(e?o.vpExt={cx:n,cy:r}:o.winExt={cx:n,cy:r},go(o),Jc(t,o),oo(t));}function x3(t,e,n,r,o,s){let i=qc(t);!vr(i)||!r||!s||((e?Da:La)(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)&&(Jc(t,i),oo(t)));}function y3(t,e,n,r){let{view:o}=t;switch(e){case 9:return r>=16&&Sd(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),oo(t)),true;case 11:return r>=16&&Sd(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),oo(t)),true;case 17:{if(r>=12){let s=o.getUint32(n,true);if(s>=1&&s<=8){let i=qc(t);va(i,s),Jc(t,i),oo(t);}}return true}case 31:case 32:return r>=24&&x3(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 g3(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 Cd(t,e,n,r){return y3(t,e,n,r)||g3(t,e,n,r)}function Ua(){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 _a(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 Cs(t,e,n,r,o){if(Cd(t,e,r,o)||Rd(t,e,r,o)||vh(t,e,r,o)||Ed(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(_a(a)),s.save(),t.clipRegion&&je(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&&je(t,t.clipRegion);}}return true}case 24:{if(o>=12){let u=zn(i,r);a.textColor=xe(a,u),ro(a,"text",u);}return true}case 25:{if(o>=12){let u=zn(i,r);a.bkColor=xe(a,u),ro(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 nm(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 rm(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 A3=16384,om=2048;function vd(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 Un(t,e,n,r,o){if(!(r>=0)||r>1e6)return null;let s=[];if(o&om){let u=e,l=0,c=0;for(let f=0;f<r;f++){let m=vd(t,u,n);if(!m)return null;u+=m.size;let b=vd(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&A3)!==0,a=i?4:8;if(e+r*a>n)return null;for(let u=0;u<r;u++)s.push(rm(t,e+u*a,i));return s}var I3=64;function S3(t){return Math.floor(t*16+.5-1e-4)}function Ld(t,e,n,r,o){let s;try{s=Mn(t,e).map(u=>u.pts.map(S3));}catch{return null}let i=se(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 ka(t,e,n,r,o=0){if(o>I3)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 Ld(l=>l.rect(s,i,a,u),e,false,n,r)}case "path":{let s=t.path;return Ld(i=>zr(i,s),e,s.fillRule==="evenodd",n,r)}case "combine":{let s=ka(t.left,e,n,r,o+1),i=s?ka(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 Dd(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 Oa(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 Ud(t,e,n,r,o,s=false,i=[]){let a=se(e,s,false,r,o),u=t.map(c=>{let f=se(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 se([...u.flatMap(c=>w3(c,o.w,o.h,o.x,o.y)),...l],false,n,false,o)}function w3(t,e,n,r,o){return D3(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 C3(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 v3(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,E=x.n-l-1,T,R=false;if(e[M+l]>g)T=l;else {if(e[M+E]<=g)break;{let A=l,I=E,S=I+A>>1;for(;S!==A;)e[M+S]<=g?A=S:I=S,S=A+I>>1;T=I;}}if((T&1)===l?e[M+T]>=e[y+1]&&(R=true):m<=0?T-=1:e[M+T-1]<e[y-1]?(c=-1,R=true):T-=1,R)break;let P=e[M+T];g!==P&&u.push({x:g,y:d.y1},{x:P,y:d.y1}),r[M+T]=1,f+=1,m=T;}{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],E=y.s,T=y.n-l-1,R;if(e[E+T]<M)R=T;else {if(e[E+l]>=M)break;{let A=l,I=T,S=I+A>>1;for(;S!==A;)e[E+S]<M?A=S:I=S,S=A+I>>1;R=A;}}if((R&1)===l){if(m<d.n-1&&e[E+R+1]>e[g+1]){c=1;break}R+=1;}else if(e[E+R]<=e[g-1])break;let P=e[E+R];M!==P&&u.push({x:M,y:d.y0},{x:P,y:d.y0}),r[E+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 L3(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 D3(t,e,n){let{bands:r,X:o}=C3(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=v3(r,o).map(U3),i=L3(s);return s.map((a,u)=>i[u]?a.slice().reverse():a)}function U3(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 E=M.x-c.x,T=M.y-c.y;E===f&&T===m||(a.push(l),l=c,f=E,m=T),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 E,T;if(g===0?(T=n[x].y-n[d].y,E=T<0&&(y===1||T===-1)):(T=n[x].x-n[d].x,E=y>0&&(y===1||T===-1)),!E){i(),g^=1,y=T;let I=p;p=d,d=x,x=I,b(n[p]);continue}if(r[d])return h();i(),i();let R=p,P=x,A=d;p=P,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 _3=1.5,Fd={1:[3,1],2:[1,1],3:[3,1,1,1],4:[3,1,1,1,1,1]};function F3(t){switch(t){case 1:case 17:return "square";case 2:case 18:case 3:case 19:return "round";default:return "butt"}}function k3(t){return t===1?"bevel":t===2?"round":"miter"}function sm(t){let e=t.width||1,n=t.dashStyle===5?t.dashPattern:Fd[t.dashStyle];return !n||n.length===0||n.some(r=>!(r>=0))?[]:n.map(r=>r*e)}function _d(t,e,n=1){t.lineWidth=(e.width||1)*n;let r=sm(e);t.lineCap=F3(r.length>0?e.dashCap??0:e.startCap??e.endCap),t.lineJoin=k3(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 an(t,e,n,r,o=false,s=false){if(e){let m=B3(t,e);if(!m)return;e=m;}let{ctx:i}=t,a=N3(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&&sm(e).length>0,b=[e.startCap,e.endCap].some(x=>x!==void 0&&x>=17&&x<=20);_d(i,e,c);let h=hs(t),p=e.brush&&true?sc(t,e.brush):null;if(!p&&h!=="canvas"){let x=co(e.color);p=x===null?null:uo(x);}if(p){let x=j3(i),y=_t(t),g=kd(u?Xt(y,u):y);if(h!=="canvas"&&x&&G3(t,e,u,p,n,y,x,h,o,s))return;let M=Ba(e)||b||m?Gd(t,e,u,n,o):null,E=null;if(x&&M)E=Ar(M.flat(),y,x,2);else if(x){let P=Math.max(1,i.miterLimit||10),A=e.width*g*P/2+2;E=Ar(r,y,x,A);}if(x&&!E||E&&bs(t,p,E,M?P=>{Wd(P,M),P.fill("nonzero");}:P=>{_d(P,e,c),f(P),P.beginPath(),n(P),u&&P.transform(u[0],u[1],u[2],u[3],0,0);},h,M?(P,A,I)=>P.isPointInPath(A,I,"nonzero"):(P,A,I)=>P.isPointInStroke(A,I)&&(!l||P.isPointInPath(A,I))))return}let d=e.brush?Cl(t,e.brush):e.color;if((Ba(e)||b||m||u&&typeof d!="string")&&X3(t,e,u,d,n,o))return;i.strokeStyle=d;}de(t),f(i);}var O3=2;function B3(t,e){let n=e.unit??0;if(n>=3&&n<=6)return null;if(n!==O3)return e;let r=$i(t),o=sn([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 N3(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||$3(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:Fd[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 kd(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 Od(t,e){if(!e)return {record:t,unit:Math.hypot(t[0],t[1]),toDevice:Y3};let n=Xt(t,e),r=kd(n),o=sn(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 Bd(t,e,n=null){let r=sm(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 G3(t,e,n,r,o,s,i,a,u,l=false){if(!n){let R=Math.hypot(s[0],s[1]),P=Math.hypot(s[2],s[3]),A=s[0]*s[2]+s[1]*s[3];if(!(R>0)||Math.abs(R-P)>1e-6*R||Math.abs(A)>1e-6*R*P)return false}let c=Od(s,n);if(!c)return false;let f;try{f=Mn(o,c.record);}catch{return false}u&&(f=f.map(R=>({...R,closed:true})));let m=(e.width||1)*c.unit,b=Bd(e,c.unit,n),h=a==="gdiplus-aa",p=R=>{let P=c.toDevice;return R.flatMap(A=>[kt(P[0]*A.x+P[2]*A.y+P[4]),kt(P[1]*A.x+P[3]*A.y+P[5])])},d,x=[],y=null,g=[];if(Ba(e))d=Nd(f,m,b,e).map(p);else {if(m<=_3&&!b.dash&&!(((e.startCap??0)|(e.endCap??0)|(e.dashCap??0))&240))return H3(t,e,r,o,s,i,h,u);({fix:d,groups:x,insetFigures:y,open:g}=W3(f,b,p));}let M=Oo(d,i);if(!M)return true;if(M.w*M.h>16e6)return false;let E=Re(t.pixelOffsetMode??0),T=y?Ud(x,y,h,E,M,l,g):se(d,false,h,E,M);return Kn(t,r,M,T,1,true)}function W3(t,e,n){let r=t.filter(u=>u.closed);if(!e.inset||e.compound||r.length===0){let u=Yn(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=>Yn([u],o).map(n)),i=Yn(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 H3(t,e,n,r,o,s,i,a){let u;try{u=N0(r,o);}catch{return false}a&&(u=u.map(h=>({...h,closed:true})));let l=Oo(u.map(h=>h.pts),s);if(!l)return true;if(l.w*l.h>16e6)return false;let c=co(e.color),m=(!e.brush||!e.brush.gradient&&!e.brush.texture&&!e.brush.hatch)&&c!==null&&c>>>24===255&&t.ext?.compositingMode!==1,b=Ti(u,{antialias:i,half:Re(t.pixelOffsetMode??0),opaqueSolid:m,clip:{x:0,y:0,w:s.w,h:s.h}},l);return Kn(t,n,l,b,1,true)}function Ba(t){return !!(t.customStartCap||t.customEndCap)}function Nd(t,e,n,r){let o=nb(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 Yn([i],l))s.push(c.slice().reverse());}),s.push(...o.polygons),s}function Gd(t,e,n,r,o){let s=_t(t),i=Od(s,n),a=sn(s);if(!i||!a||!(i.unit>0))return null;let u;try{u=Mn(r,i.record);}catch{return null}o&&(u=u.map(b=>({...b,closed:true})));let l=(e.width||1)*i.unit,c=Bd(e,i.unit,n),f=Ba(e)?Nd(u,l,c,e):Yn(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 Wd(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 X3(t,e,n,r,o,s){let i=Gd(t,e,n,o,s);if(!i)return false;let{ctx:a}=t;a.save();try{a.fillStyle=r,de(t),Wd(a,i),a.fill("nonzero");}finally{a.restore();}return true}var Y3=[1,0,0,1,0,0];function $3(t){return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1&&t[4]===0&&t[5]===0}function j3(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 V3=/^(?:\p{Script=Latin}|\p{Script=Common}|\p{Co})$/u,z3=/[\p{M}\p{Cf}\p{Emoji_Presentation}]/u;function Hd(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 !V3.test(y)||z3.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 tP(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 eP=2;function rP(t,e,n,r,o,s,i,a){let{view:u}=t,l=Qb(t.interpolationMode??0);if(n||u.getUint32(e+4,true)!==eP)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:Re(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)}:{},...tP(t,u.getUint32(e,true))}}function Yd(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:rP(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(Ah(t,e,h,d,u)){return}if(h.effect=u,h.effectSource=d,It(t.ctx));t.deferredImages.push(h),$(`DrawImage: queued deferred image (total=${t.deferredImages.length})`);}function cm(t,e,n,r){let{ctx:o}=t,s=r.fillRule??"nonzero";vn(t,e,n,a=>zr(a,r),r.points,s)||(o.fillStyle=Ge(t,e,n),de(t),zr(o,r),o.fill(s));}function mm(t,e,n){an(t,e,r=>zr(r,n),n.points,iP(n.types),n.fillRule==="evenodd");}function oP(t){return 1+(t===void 0||!Number.isFinite(t)?4:Math.min(12,Math.max(0,t)))/10}function sP(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 iP(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 am(t,e,n,r,o,s,i){let{ctx:a}=t,u=lo(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=Ar(m,_t(t),{w:l.width,h:l.height});if(!b)return;let{font:h,textAlign:p,textBaseline:d}=a;if(bs(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=Ge(t,e,n),de(t,false),a.fillText(r,o,s);}var aP=[3,3,3,4,4,6],Qn=1/6,im=1.03;function uP(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 $d(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??xr,o=yr(t.pageUnit,t.pageScale,r,t.videoDisplay??true),s=e.emSize*yr(n,1,r)/(o||1);return Number.isFinite(s)&&s>0?{...e,emSize:s,unit:0}:e}function lP(t,e){return t!==0?t:e==="mono"?1:e==="gray"?3:5}function Vd(t,e,n,r,o=false){let s=t.fonts,i=typeof n=="string"?uP(n):null,a=lP(t.textRenderingHint??0,s?.defaultSmoothing),l=!!i&&(a===3||a===4||a===5)&&!It(t.ctx),c=It(t.ctx)?null:l?uo(co(n)??4278190080):i?null:r,f=e.unit??0;if(!s||!i&&!c||f!==0&&f!==2)return null;let m=_t(t);if(m[1]!==0||m[2]!==0||m[0]<=0||m[3]<=0)return null;let b=e.emSize*m[3],h={face:e.family,height:-Math.round(b),width:0,weight:e.flags&1?700:400,italic:(e.flags&2)!==0,charSet:1,pitchAndFamily:0,quality:aP[a]??3,unhinted:a===2||a===4,ignoreGasp:a===4,gdiPlus:true,...a===1&&o?{defaultDrawStringFormat:true}:{},unscaledText:m[0]===1&&m[3]===1},p=s.realize(h,t.fontFamilyMap);return p?{realized:p,emPx:b,m,unhinted:h.unhinted===true,color:i,sampler:c,solidViaCoverage:l,underline:(e.flags&4)!==0,strikeOut:(e.flags&8)!==0,plusBars:a===4?"fractional":"snapped"}:null}function Ga(t,e,n,r){let o={...n,textAlign:24,bkColor:"#ffffff",bkMode:1,options:r?yo:0,rect:r??null,matrix:null};if((!e.color||e.solidViaCoverage)&&e.sampler){let s=Xp(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=oP(t.ext?.textContrast);if(s.channels===1&&sP(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 Kn(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 Dc(t.ctx,e.realized,{...o,textColor:e.color,underline:e.underline,strikeOut:e.strikeOut,plusBars:e.plusBars},t.fontFamilyMap),true}function cP(t,e,n,r,o,s,i,a,u,l,c=null){let f=!l||l.flags===0&&l.alignment===0&&l.lineAlignment===0&&(l.trimming??1)===1&&Math.fround(l.leadingMargin??Qn)===Math.fround(Qn)&&Math.fround(l.trailingMargin??Qn)===Math.fround(Qn)&&Math.fround(l.tracking??im)===Math.fround(im),m=Vd(t,e,a,c,f);if(!m)return false;let{realized:b,emPx:h,m:p,unhinted:d}=m,x=Array.from(n,B=>B.codePointAt(0));if(l&&(u!==0||l.lineAlignment!==0)&&d&&p[0]===p[3]&&Math.fround(h)===b.ppem){let B=Hd(b,x,l,p[0]*r+p[4],p[3]*o+p[5],p[0]*s,p[3]*i);if(B)return Ga(t,m,{codes:x,glyphIndices:false,...B,dy:null})}let y=b.ttf,g=h*y.winAscent/y.unitsPerEm,M=!b.syntheticBold&&!b.syntheticItalic&&h===b.ppem&&p[0]===1&&p[3]===1&&Number.isInteger(o+p[5])&&(l?.lineAlignment??0)===0,E=l?.flags??0;if(u!==0&&(u!==1&&u!==2||E!==0||b.mode!=="mono"||!b.gridFit||!M||!b.designAdvance||x.some(B=>B!==10&&B!==13&&(B<32||B>126))))return false;let T=d?Math.round(g):M?Math.max(Math.round(g),b.ascent):Math.ceil(g),R=h*(l?.leadingMargin??Qn),P=h*(l?.trailingMargin??Qn),A=p[0]*r+p[4]+R;d||(A=Math.round(A));let I=p[3]*o+p[5]+T,S=l?.tracking??im,w=!d&&b.mode==="cleartype"&&!!b.ctGridAdvance&&!b.syntheticItalic&&S>1,C=!!b.designAdvance&&p[0]===1&&p[3]===1,v=B=>{let W=b.glyphIndex(B);return d?C?b.designAdvance(W,S):b.advance(W)*S:w?b.ctGridAdvance(W):b.advance(W)},D=d||w?x.map(v):null,_=p[0]*r+p[4],U=p[3]*o+p[5],F=p[0]*s,O=p[3]*i,H=F>0&&O>0&&!(E&bP)?{left:Math.round(_),top:Math.round(U),right:Math.round(_+F),bottom:Math.round(U+O)}:void 0,k,G=F>0&&!(E&mP)?F-h*((l?.leadingMargin??Qn)+(l?.trailingMargin??Qn)):1/0,N=x.map(B=>b.designAdvance?.(b.glyphIndex(B),S)??v(B)),K=N.map((B,W)=>W+1<x.length&&y.kerning?B+y.kerning(b.glyphIndex(x[W]),b.glyphIndex(x[W+1]))*h/y.unitsPerEm:B),V=hP(x,K,G),z,st=V.length>1;if(u!==0&&(!st||!H))return false;st&&(k=H);let at=y.winDescent??0,Y=y.hheaAscender!==void 0&&y.hheaDescender!==void 0?y.hheaAscender-y.hheaDescender+(y.hheaLineGap??0):y.winAscent+at,X=Y*h/y.unitsPerEm;if(H){let B=E&fP?Math.floor((O-(y.winAscent+at)*h/y.unitsPerEm)/X)+1:Math.floor(O/X-.25)+1;if(V.length>B){if(u!==0)return false;k=H;let W=V.slice(0,Math.max(0,B));if(W.length>0&&(l?.trimming??1)===1){let j=W[W.length-1],Z=j.start;for(;Z<x.length&&x[Z]!==10&&x[Z]!==13;){let it=0;for(let ht=j.start;ht<=Z;ht++)it+=K[ht];if(it>G&&Z>j.start)break;Z++;}for(;Z>j.start&&x[Z-1]===32;)Z--;let ut={start:j.start,end:Z};Z>j.end&&(z=ut),W[W.length-1]=ut;}V=W;}}if(V.length===0)return true;if(!st)return Ga(t,m,{codes:x.slice(0,V[0].end===jd(x)?x.length:V[0].end),glyphIndices:false,x:A,y:I,dx:D?D.slice(0,V[0].end===jd(x)?x.length:V[0].end):null,dy:null},k);for(let[B,W]of V.entries()){let j=U+(y.winAscent+B*Y)*h/y.unitsPerEm,Z=x.slice(W.start,W.end);if(Z.length===0)continue;let ut=ct=>{let tt=ct+1<W.end&&y.kerning?y.kerning(b.glyphIndex(x[ct]),b.glyphIndex(x[ct+1]))*h/y.unitsPerEm:0;return d?tt:Math.round(tt)},it=Array.from({length:W.end-W.start},(ct,tt)=>v(x[W.start+tt])+ut(W.start+tt));if(W===z&&!d&&b.mode==="mono"){let ct=_+R,tt=A;for(let lt=W.start;lt<W.end;lt++){let dt=lt-W.start;if(ct+=K[lt],tt+=it[dt],x[lt]===32&&x[lt-1]!==32&&x[lt+1]!==32){let zt=Math.round(ct);it[dt]+=zt-tt,tt=zt;}}}let ht=A;if(u!==0){let ct=it.length===1?N[W.start]:it.reduce((zt,Se)=>zt+Se,0),tt=Math.fround(ct+Math.fround(R+P)),lt=Math.fround(u/2*Math.fround(F-tt)),dt=Math.fround(Math.fround(_+lt)+R);ht=Math.ceil(dt-.5);}Ga(t,m,{codes:Z,glyphIndices:false,x:ht,y:d?U+Math.round(g)+B*X:Math.round(j),dx:it.some((ct,tt)=>ct!==v(x[W.start+tt]))||D?it:null,dy:null},k);}return true}function jd(t){let e=t.length;for(;e>0&&t[e-1]===32;)e--;return e}var mP=4096,fP=8192,bP=16384;function hP(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 pP=1,dP=2,xP=4;function yP(t,e,n,r,o,s,i){let a=(i&pP)!==0,u=(i&xP)!==0;if(!(i&dP)){let h=Ge(t,e,n),p=Vd(t,r,h,t.fonts?lo(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,E)=>E+1<x.length?x[E+1][g]-M[g]:0);Ga(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=Hr(r.family,t.fontFamilyMap),b=()=>{l.font=`${f}${c}${r.emSize}px ${m}`,l.textBaseline="alphabetic",l.textAlign="left";};if(u){b(),am(t,e,n,String.fromCharCode(...o),s[0].x,s[0].y,r.emSize);return}for(let h=0;h<o.length;h++)b(),am(t,e,n,String.fromCharCode(o[h]),s[h].x,s[h].y,r.emSize);}function zd(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"&&cm(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"&&mm(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=$d(t,a.get(p));if(c>0&&r+28+c*2<=r+o){let x=Ke(i,r+28,c);if(x.length>0&&d&&d.kind==="plus-font"){let y=a.get(l),g=Ge(t,n,u),M=y&&y.kind==="plus-stringformat"?y.alignment:0,E=y&&y.kind==="plus-stringformat"?y:void 0;if(cP(t,d,x,f,m,b,h,g,M,E,t.fonts?lo(t,n,u):null))return true;let T=d.flags&1?"bold ":"",R=d.flags&2?"italic ":"",P=Hr(d.family,t.fontFamilyMap);if(s.font=`${R}${T}${d.emSize}px ${P}`,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";am(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=$d(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{yP(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?Yd(t,l,r,m,b,h,p,(x,y,g,M)=>[L(h/g),0,0,L(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]):J(`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&u0)!==0?t.ext?.pendingEffect??null:null;if(t.ext&&(t.ext.pendingEffect=null),c>=3&&l&&l.kind==="plus-image"&&l.data){let b=Un(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,E=p,T=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)},${E.toFixed(1)},${T.toFixed(1)},${R.toFixed(1)})`),$(`DrawImagePoints: worldTransform=[${t.worldTransform.map(P=>P.toFixed(3)).join(", ")}]`),Yd(t,l,r,M,E,T,R,(P,A,I,S)=>{let w=L((d-h)/I),C=L((x-p)/I),v=L((y-h)/S),D=L((g-p)/S);return [w,C,v,D,h-w*P-v*A,p-C*P-D*A]},m,true,x===p&&y===h?(P,A)=>[Math.fround((d-h)/P),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 AP=8192;function fm(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function Wa(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 qd(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=Un(s,r+4,i,a,n);return !u||u.length<4||(u.length-1)%3!==0||an(t,fm(t,n),Wa(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=Un(s,r+16,i,c,n&16384);if(!f)return true;let m=Oa(f,a,false,u,l);return m.length>=4&&an(t,fm(t,n),Wa(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=Un(s,r+8,i,u,n),c=l?Oa(l,a,true):[];return c.length>=4&&an(t,fm(t,n),Wa(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=Un(s,r+12,i,l,n),f=c?Oa(c,u,true):[];if(f.length<4)return true;let m=n&AP?"nonzero":"evenodd",b=Wa(f,true);if(!vn(t,n,a,b,f,m)){let{ctx:h}=t;h.fillStyle=Ge(t,n,a),de(t),h.beginPath(),b(h),h.fill(m);}return true}case 16439:return IP(t,n,r,o),true;case 16403:return o<4||wP(t,n,s.getUint32(r,true)),true;default:return false}}function IP(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"&&cm(t,0,u,i);let c=a<=255?s.get(a):void 0;c&&c.kind==="plus-pen"&&mm(t,c,i);}function SP(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 wP(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=SP(i);if(hs(t)!=="canvas"&&a){let m={x:0,y:0,w:a.w,h:a.h},b=ka(o,s,m,Re(t.pixelOffsetMode??0)),h=b?ic(t,e,n):null;if(b&&h){let p=Dd(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(Kn(t,h,p,d,1,true))return}}let u=os(o,s,0,a?{x:0,y:0,w:a.w,h:a.h}:void 0);u.exact||J("FillRegion: region approximated (no canvas domain for an unbounded result)");let l=u.region,c=sn(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(),rs(i,b.cmds),i.clip(b.fillRule);i.fillStyle=Ge(t,e,n),de(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 kP(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 Zd(t,e,n,r,o){if(o&om)return Un(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(rm(t,l,s));return a}function bm(t,e){let n=t.objectTable.get(e&255);return n&&n.kind==="plus-pen"?n:null}function Qd(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(nm(i,b,c)),b+=f;if(!vn(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=Ge(t,n,u),de(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(nm(i,m,l)),m+=c;an(t,bm(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}];vn(t,n,u,h,p)||(s.fillStyle=Ge(t,n,u),de(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 an(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,E=Math.abs(x)/2,T=Math.abs(y)/2,{start:R,sweep:P}=kP(m,b,E,T);if(u){let I=w=>{w.moveTo(g,M),w.ellipse(g,M,E,T,0,R,R+P,P<0),w.closePath();},S=[{x:p,y:d},{x:p+x,y:d},{x:p,y:d+y},{x:p+x,y:d+y}];return vn(t,n,f,I,S)||(s.fillStyle=Ge(t,n,f),de(t),s.beginPath(),I(s),s.fill()),true}let A=e===16401;return an(t,bm(t,n),I=>{A&&I.moveTo(g,M),I.ellipse(g,M,E,T,0,R,R+P,P<0),A&&I.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=Zd(i,r+4,r+o,u,n);if(!l)return true;let c=(n&8192)!==0;an(t,bm(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=Zd(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();};vn(t,n,u,f,c)||(s.fillStyle=Ge(t,n,u),de(t),s.beginPath(),f(s),s.fill());}return true}default:return false}}function e1(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=Ei(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 2:{let l=hb(s,n,r,t.textureCache,o);l&&i.set(a,l);break}case 3:{let l=ir(s,n,r);l&&i.set(a,l);break}case 6:{let l=db(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=Ii(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=WP(s,n,r);l&&(i.set(a,l),$(`replayEmfPlusRecords: Stored Region object id=${a}`));break}}}var t1=64;function hm(t,e,n,r=0){if(e+4>n)return null;if(r>t1)return null;let o=t.getUint32(e,true),s=e+4;if(o<=5){let i=hm(t,s,n,r+1);if(!i)return null;s+=i.bytesRead;let a=hm(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=ir(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}:(J(`parseRegionNode: unknown node type 0x${o.toString(16)}`),{node:{type:"empty"},bytesRead:4})}function WP(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=hm(t,e+8,s);return i?{kind:"plus-region",nodes:[i.node]}:(null)}Vn();function VP(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 o1(t){return t>0&&t<=1e5?t:void 0}function*s1(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??Yi,pageScale:m.pageScale??1,dpiX:m.dpiX,dpiY:m.dpiY,videoDisplay:m.videoDisplay,...m.continuation??Si(),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=void 0;for(false;e+12<=h&&p<u;){Te(),jn()&&(yield);let x=t.getUint16(e,true),y=t.getUint16(e+2,true),g=t.getUint32(e+4,true),M=t.getUint32(e+8,true);if(g<12||e+g>h)break;p++;let E=e+12;if(m.gdiPassthrough=x===16388,b.ext?.multiFormatSkip&&x!==16386){e+=g;continue}switch(x){case 16385:{if(m.dualMode=(y&1)!==0,M>=16){let T=t.getUint32(E+4,true),R=t.getUint32(E+8,true),P=t.getUint32(E+12,true);b.dpiX=m.dpiX=o1(R),b.dpiY=m.dpiY=o1(P),b.videoDisplay=m.videoDisplay=(T&1)!==0;}break}case 16386:e=h;continue;case 16388:break;case 16389:VP(b,E,M);break;case 16390:case 16391:break;case 16440:(b.ext??(b.ext={})).pendingEffect=M<=g-12?di(t,E,M):null;break;case 16393:{if(M>=4){let T=t.getUint32(E,true);r.save(),r.setTransform(1,0,0,1,0,0),r.globalAlpha=1,r.globalCompositeOperation="source-over",T>>>24!==255&&r.clearRect(0,0,o,s),r.fillStyle=le(T),r.fillRect(0,0,o,s),r.restore();}break}case 16392:{let T=wi(b,t,y,E,M);T&&e1(T.view===t?b:{...b,view:T.view},T.flags,T.dataOff,T.dataSize,T.cacheKey);break}default:{Qd(b,x,y,E,M)||qd(b,x,y,E,M)||zd(b,x,y,E,M)||Mh(b,x,y,E,M)||console.warn(`[emf-converter] Unhandled EMF+ record type: 0x${x.toString(16)}`);break}}e+=g;}if(p>=u&&console.warn(`[emf-converter] EMF+ record limit reached (${u}). Output may be incomplete.`),d);return 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}Vn();function i1(t,e,n,r,o,s=1,i={}){return Di(xm(t,e,n,r,o,s,i))}function*xm(t,e,n,r,o,s=1,i={}){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;let d={ctx:e,view:t,objectTable:new Map,state:{...Ua(),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;for(;x+8<=y&&g<l;){Te(),jn()&&(yield);let T=t.getUint32(x,true),R=t.getUint32(x+4,true);if(R<8||x+R>y)break;g++;let P=x+8;if(T===70){if(R>=16){let I=t.getUint32(P,true),S=t.getUint32(P+4,true);if(S===726027589&&I>4){Ht(d);let w=yield*s1(t,P+8,I-4,e,r,o,u,s,c,i.fontFamilyMap,i.textureCache,i.fonts);a.push(...w);}}x+=R;continue}if(T===14){break}if(T===28||T===98||T===115||T===1){x+=R;continue}if(Qi(T)||Ht(d),i.gdiDrawing===false){x+=R;continue}if(u.dualMode&&!u.gdiPassthrough){T===33?QP(d):T===34?R>=12&&t4(d,t.getInt32(P,true)):Cs(d,T,x,P,R),x+=R;continue}Cs(d,T,x,P,R)||Aa(d,T,x,P,R)||wa(d,T,x,P,R)||console.warn(`[emf-converter] Unhandled EMR record type: ${T}`),x+=R;}if(Ht(d),g>=l&&console.warn(`[emf-converter] EMF record limit reached (${l}). Output may be incomplete.`),i.nestingDepth){let T=u.clipSaveDepth+d.clipSaveDepth+d.stateStack.length;for(;T-- >0;)e.restore();}return a}function QP(t){t.skippedDcStack??(t.skippedDcStack=[]),t.skippedDcStack.push({state:_a(t.state),mapping:{mapMode:t.mapMode,windowOrg:{...t.windowOrg},windowExt:{...t.windowExt},viewportOrg:{...t.viewportOrg},viewportExt:{...t.viewportExt},useMappingMode:t.useMappingMode}});}function t4(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 e4(t,e,n,r,o,s){let i=new DataView(t);if(!gr(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 i1(i,e,x,n,r,1,s)}return i1(i,e,{left:0,top:0,right:n,bottom:r},n,r,1,{...s,plusBaseTransform:o,gdiDrawing:false})}Ph(e4);Vn();var Lr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function a1(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+=Lr[a>>18]+Lr[a>>12&63]+Lr[a>>6&63]+Lr[a&63];}if(i<o){let a=t[i]<<16|(i+1<o?t[i+1]:0)<<8;s+=Lr[a>>18]+Lr[a>>12&63]+(i+1<o?Lr[a>>6&63]:"=")+"=";}e.push(s);}return e.join("")}var u1=256*1024*1024;async function Ha(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:n4(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));else if(typeof Blob<"u"&&t instanceof Blob)e=await t.arrayBuffer();else return null;return r4(e)?o4(e):e}function n4(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}function r4(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 o4(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>u1)return await e.cancel(),J(`readMetafileInput: gzip input inflates past ${u1} 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 J("readMetafileInput: gzip input is corrupt:",e instanceof Error?e.message:e),null}}var s4=15,i4=1128680791;function Xa(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===s4&&h>=34&&t.getUint32(p,true)===i4&&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 Ie=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 He(t,e){let n=e.getUint32(0,true),r=e.getUint32(4,true);Qi(n)||Ht(t);let o=t.view;t.view=e;try{!Cs(t,n,0,8,r)&&!Aa(t,n,0,8,r)&&wa(t,n,0,8,r);}finally{t.view=o;}}var l1=[0,8388608,32768,8421376,128,8388736,32896,12632256,12639424,10930928,16776176,10526884,8421504,16711680,65280,16776960,255,16711935,65535,16777215];function m1(){return {kind:"pen",style:0,width:0,color:0}}function f1(){return {kind:"brush",style:0,color:16777215,hatch:0}}function c1(t,e,n){return t<<16|e<<8|n}function tr(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:c1(i&255,i>>>8&255,i>>>16&255)}return l1[s<l1.length?s:0]}return c1(n,r,o)}function Dr(t,e){let n=tr(e,t.palette);return Fs(n>>16&255,n>>8&255,n&255)}function er(t,e){return t.getUint32(e,true)}function b1(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=Dr(t,e.color),n.penUserStyle=void 0,n.penExtended=false;}function Ls(t,e){t.brush=e;let n=t.rCtx.state;n.brushStyle=e.pattern?e.pattern.kind==="mono"?3:6:e.style,n.brushColor=Dr(t,e.color),n.brushPattern=e.pattern??(e.style===2&&e.hatch>=0&&e.hatch<=5?{kind:"hatch",hatch:e.hatch}:null);}function Eo(t){b1(t,t.pen),Ls(t,t.brush),t.rCtx.state.textColor=Dr(t,t.textColor),t.rCtx.state.bkColor=Dr(t,t.bkColor);}function Xe(t,e){let n=0;for(;t.objects[n]!==void 0;)n++;t.objects[n]=e;}function h1(t,e,n){let{view:r}=t;if(n<16){Xe(t,{kind:"other"});return}Xe(t,{kind:"pen",style:r.getUint16(e,true),width:r.getInt16(e+2,true),color:er(r,e+6)});}function p1(t,e,n){let{view:r}=t;if(n<14){Xe(t,{kind:"other"});return}Xe(t,{kind:"brush",style:r.getUint16(e,true),color:er(r,e+2),hatch:r.getUint16(e+6,true)});}function d1(t,e,n,r){let{view:o}=t;if(n<24){Xe(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(...Zn(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)}};Xe(t,{kind:"font",font:a});}function gm(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=tr(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 Mm(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 a4(t,e,n,r,o){let s=t.view,i=e,a=n;if(r===1){let f=gm(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+Mm(s,i);if(o&&s.getUint16(i+14,true)===1){let f=eu(s,i,u);if(f)return {kind:"mono",...f}}let l=Oe(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 x1(t,e,n){let{view:r}=t;if(e+4+40>n){Xe(t,{kind:"other"});return}let o=r.getUint16(e,true),s=r.getUint16(e+2,true),i=a4(t,e+4,n,s,o===3);Xe(t,{kind:"brush",style:i?6:0,color:8421504,hatch:0,...i?{pattern:i}:{}});}function y1(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 g1(t,e,n){if(e+4>n){Xe(t,{kind:"other"});return}Xe(t,{kind:"palette",entries:y1(t.view,e,n).entries});}function Em(t,e,n,r){let o=t.palette;if(!o||e+4>n)return;let{start:s,entries:i}=y1(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]);Eo(t);}function M1(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);Eo(t);}}function E1(t,e){let n=t.objects[e];n?.kind==="palette"&&(t.palette=n,Eo(t));}function T1(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]);}}Xe(t,o);}function R1(t,e){let n=t.objects[e];if(!n)return;let r=t.rCtx.state;switch(n.kind){case "pen":b1(t,n);break;case "brush":Ls(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 P1(t,e){e>=0&&e<t.objects.length&&(t.objects[e]=void 0);}function Tm(t,e,n,r,o){let s=gt(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 A1(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 u4(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,tr(t.textColor,t.palette)),s(1,tr(t.bkColor,t.palette)),{bmi:r,bits:e.bits}}function Rm(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=gm(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=Mm(i,0);return a>s.length?null:{bmi:s.subarray(0,a),bits:s.subarray(a)}}function Pm(t,e,n,r,o,s,i,a,u,l,c,f){[r,o,s,i]=Tm(t,r,o,s,i);let m=e?108:100,b=new Ie(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();A1(t,()=>He(t.rCtx,p));}function I1(t,e,n,r,o,s,i,a,u,l,c,f=false){f||([n,r,o,s]=Tm(t,n,r,o,s));let m=new Ie(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();A1(t,()=>He(t.rCtx,d));}function S1(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);Pm(t,false,o,u,a,i,s,0,0,i,s,null);}function w1(t,e){return e/2===(t>>8)+3}function C1(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true);if(!w1(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);Pm(t,false,u,m,f,c,l,0,0,c,l,null);}function v1(t,e,n,r){let{view:o}=t,s=o.getUint16(n+4,true),i=n+6,a=n+r,u=w1(s,r),l=i+4,c=()=>{let E=o.getInt16(l,true);return l+=2,E};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:u4(t,Rm(t,l,a,0));Pm(t,e,f,g,y,x,d,p,h,e?b:x,e?m:d,M);}function L1(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=Rm(t,e+22,n,s);h&&I1(t,o,b,m,f,c,l,u,a,i,h);}function D1(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=Rm(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,E]=Tm(t,m,f,0,0),T=t.layout&1?M-c:M;I1(t,13369376,T,E+(a+l-d),c,d-p,u,p-i,c,d-p,{bmi:x,bits:b.bits},true);}function U1(t,e,n){let r=gt(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 To(t,e,n,r,o){let s=U1(t,e,n),i=U1(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 l4(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 Am(t,e,n){Ht(t.rCtx);let r=e.length>0?cn(l4(t,e)):Ne();Cr(t.rCtx,r,n);}function _1(t,e,n,r,o){Am(t,[To(t,e,n,r,o)],"intersect");}function F1(t,e,n,r,o){Am(t,[To(t,e,n,r,o)],"exclude");}function k1(t,e,n){let{rCtx:r}=t;if(!r.clipRegion)return;Ht(r);let o=gt(r),s=Math.round(o[0]*e/t.kx)*t.kx,i=Math.round(o[3]*n/t.ky)*t.ky;r.clipRegion=pr(r.clipRegion,s,i),je(r,r.clipRegion);}function Im(t,e){let n=t.objects[e];if(n?.kind!=="region"){Ht(t.rCtx),t.rCtx.clipRegion=null,je(t.rCtx,null);return}Am(t,n.rects,"replace");}function Ya(t,e){return e.rects.map(([n,r,o,s])=>To(t,n,r,o,s)).filter(([n,r,o,s])=>o>n&&s>r)}function O1(t,e){let n=new Jt,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 Sm(t,e,n){let r=t.brush;if(n!==null){let s=t.objects[n];if(s?.kind!=="brush")return;Ls(t,s);}let o=on(t.rCtx);o&&ue(t.rCtx,O1(t,e),o,t.rCtx.state.rop2),n!==null&&Ls(t,r);}function $a(t,e){let n=t.objects[e];return n?.kind==="region"?n:null}function B1(t,e,n){let r=$a(t,e);r&&Sm(t,Ya(t,r),n);}function N1(t,e){let n=$a(t,e);n&&Sm(t,Ya(t,n),null);}function G1(t,e){let n=$a(t,e);n&&ue(t.rCtx,O1(t,Ya(t,n)),{kind:"solid",rgb:0},6);}function c4(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 W1(t,e,n,r,o){let s=$a(t,e);if(!s)return;let i=gt(t.rCtx),a=Math.abs(Math.round(i[0]*o/t.kx)),u=Math.abs(Math.round(i[3]*r/t.ky)),l=c4(Ya(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,E=g&&!M;E&&x<0?x=y:!E&&x>=0&&(p.push([c+x,f+d,c+y,f+d+1]),x=-1);}}Sm(t,p,n);}function m4(t,e,n){let r=new Jt,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 H1(t,e,n,r){let[o,s]=To(t,e,n,e,n);ue(t.rCtx,m4(t,o,s),{kind:"solid",rgb:tr(r,t.palette)},13);}function wm(t,e,n,r,o){let{rCtx:s}=t,{ctx:i}=s,a=Cn(i);if(!a||false||typeof i.getImageData!="function")return;let u=on(s);if(!u)return;Ht(s);let[l,c]=To(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=At(i,0,0,b,h).data,d=tr(r,t.palette),x=P=>p[P*4+3]===0?16777215:p[P*4]<<16|p[P*4+1]<<8|p[P*4+2],y=o===1,g=P=>y?x(P)===d:x(P)!==d,M=m*b+f;if(!g(M))return;let E=new Uint8Array(b*h),T=[M];for(E[M]=1;T.length>0;){let P=T.pop(),A=P%b,I=(P-A)/b,S=w=>{!E[w]&&g(w)&&(E[w]=1,T.push(w));};A>0&&S(P-1),A+1<b&&S(P+1),I>0&&S(P-b),I+1<h&&S(P+b);}let R=new Jt;for(let P=0;P<h;P++){let A=-1;for(let I=0;I<=b;I++){let S=I<b&&E[P*b+I]===1;S&&A<0?A=I:!S&&A>=0&&(R.add(P,A,I),A=-1);}}ue(s,R,u,s.state.rop2);}var X1=5,Y1=6;function ja(t,e,n,r,o,s={}){let i=s.exclusive!==false,a=xt(t.rCtx,e,n),u=xt(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&&vm(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)===Y1&&Math.round(ia(t.rCtx)/t.kx)>1){let b={...f},h=gt(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 Va(t,e,n=false){let r=n?rr(t.x0,t.y0,t.x1,t.y1):rr(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 Ds(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 f4(t,e){let{state:n}=t.rCtx,r=Jn(t.rCtx);if(Pr(n,r)===0||Rr(n,r)!==1)return;let o=Ds(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 $1(t,e,n,r,o){let s=ja(t,e,n,r,o);if(s.x1<s.x0||s.y1<s.y0)return;let i=Ds(s),{rCtx:a}=t,{state:u}=a,l=u.penStyle===X1||(u.penStyle===0||u.penStyle===6)&&ye(a);if(a.gdiAntialias!==false&&l&&ne(u).kind!=="tile"&&(he(u.rop2).exact||!qn(u.rop2))){let{ctx:c}=a;Ht(a),Wr(c,u),c.fillRect(i.x,i.y,i.w,i.h),Gr(c,u),c.lineWidth=1;let f=Pr(u,Jn(a));c.strokeRect(i.x+f,i.y+f,i.w,i.h);return}Zt(t.rCtx,{build:c=>{c.beginPath(),c.rect(i.x,i.y,i.w,i.h);},raster:()=>Tr(Va(s),Cm(t)),rectangle:true,fill:true,stroke:true,axisRect:{interior:f4(t,s)}});}function b4(t,e,n,r,o){let s=gt(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)===Y1&&!ye(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 ye(t.rCtx)&&!vm(t)?h:[Math.floor(h[0]),Math.floor(h[1])]}function j1(t,e,n,r,o,s,i){let a=ja(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]=b4(t,s,i,a,[e,n,r,o]),f=Ds(a);Zt(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:()=>sa(Va(a,c),u,l,Cm(t),s===0||i===0,!vm(t)&&ye(t.rCtx)),roundPen:true,fill:true,stroke:true});}function V1(t,e,n,r,o){let s=ja(t,e,n,r,o,{curved:true,half:true,clampEmpty:true});if(s.x1<s.x0||s.y1<s.y0)return;let i=Ds(s);Zt(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:()=>ms(Va(s),Cm(t)),roundPen:true,fill:true,stroke:true});}function h4(t,e,n,r,o,s,i,a,u,l,c=false){let f=ja(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=gt(t.rCtx),b=(E,T)=>[(m[0]*E+m[2]*T+m[4])*16,(m[1]*E+m[3]*T+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=(E,T,R,P,A)=>(P+A)/2+(R!==T?(E-(T+R)/2)*(A-P)/(R-T):E-(T+R)/2),M=(E,T)=>{let[R,P]=b(E,T);return [g(R,y.x0,y.x1,f.x0,f.x1),g(P,y.y0,y.y1,f.y0,f.y1)]};return {box:f,s:M(i,a),e:M(u,l)}}function z1(t,e,n,r,o,s,i,a,u,l){let c=h4(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=Ds(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),E=Math.atan2((b[1]/16-x)/g,(b[0]/16-d)/y),T=e==="chord"||e==="pie";Zt(t.rCtx,{build:R=>{R.beginPath(),e==="pie"&&R.moveTo(d,x),R.ellipse(d,x,p.w/2,p.h/2,0,M,E,!h),T&&R.closePath();},raster:()=>ao(Va(f),m,b,h,e).path,fill:T,stroke:true});}function Cm(t){return t.rCtx.state.arcDirection===2}function vm(t){return (t.rCtx.state.penStyle&15)===X1}function p4(t,e){let n=t.rCtx.fonts;if(!n)return null;let r=gt(t.rCtx),o=n.realize(Uc(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 d4(t,e){if(t.charExtra===0&&(t.justifyExtra===0||t.justifyCount===0))return null;let n=p4(t,e);if(!n)return null;let r=gt(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 x4(t,e,n,r){let{rCtx:o}=t;if(!o.fonts)return false;Ht(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:gt(o)});return i?(o.state.textAlign&1&&(o.state.curX+=i.dx,o.state.curY+=i.dy),true):false}function Lm(t,e){let n=t.rCtx.state.fontDetails?.charSet??1,{codes:r,byteLengths:o}=Zn(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}):d4(t,r);if(x4(t,e,r,a))return;let u=new Ie(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);}He(t.rCtx,u.finish());}function q1(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));Lm(t,{y:r.getInt16(i,true),x:r.getInt16(i+2,true),bytes:a,options:0,rect:null,dx:null});}function J1(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&(xo|yo))!==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&xo&&Lm(t,{x:s,y:o,bytes:[32],options:a,rect:c,dx:[0]});return}Lm(t,{x:s,y:o,bytes:m,options:a,rect:c,dx:h});}Vn();function PA(t,e,n,r,o,s={}){let i=Mo(t,n,s.wmfReferenceDpi),a=r/i.width,u=o/i.height,l={...Ua(),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:m1(),brush:f1(),palette:null,textColor:0,bkColor:16777215,charExtra:0,justifyExtra:0,justifyCount:0,layout:0};return zc(c,f.mapping,a,u),Eo(f),f}function un(t){zc(t.rCtx,t.mapping,t.kx,t.ky,t.layout&1?t.devW:0);}function AA(t){return {mapping:Vc(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 Us(t,e,n){He(t.rCtx,new Ie(e,16).u32(n).finish());}function IA(t,e,n,r){let o=new Ie(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));He(t.rCtx,o.finish());}function SA(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)&&(va(t.mapping,c(0)),un(t));return;case 523:u(4)&&(t.mapping.winOrg={y:l(0),x:l(1)},un(t));return;case 524:u(4)&&(Pd(t.mapping,l(1),l(0)),un(t));return;case 525:u(4)&&(t.mapping.vpOrg={y:l(0),x:l(1)},un(t));return;case 526:u(4)&&(Ad(t.mapping,l(1),l(0)),un(t));return;case 527:u(4)&&(t.mapping.winOrg={x:t.mapping.winOrg.x+l(1),y:t.mapping.winOrg.y+l(0)},un(t));return;case 529:u(4)&&(t.mapping.vpOrg={x:t.mapping.vpOrg.x+l(1),y:t.mapping.vpOrg.y+l(0)},un(t));return;case 1040:u(8)&&(La(t.mapping,l(3),l(2),l(1),l(0)),un(t));return;case 1042:u(8)&&(Da(t.mapping,l(3),l(2),l(1),l(0)),un(t));return;case 30:t.stack.push(AA(t)),He(s,new Ie(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,He(s,new Ie(34,12).i32(f).finish()),Object.assign(t,{...b,mapping:Vc(b.mapping)}),un(t),Eo(t);return}case 521:u(4)&&(t.textColor=er(o,i),s.state.textColor=Dr(t,t.textColor));return;case 513:u(4)&&(t.bkColor=er(o,i),s.state.bkColor=Dr(t,t.bkColor));return;case 258:u(2)&&Us(t,18,c(0));return;case 260:u(2)&&Us(t,20,c(0));return;case 262:u(2)&&Us(t,19,c(0));return;case 263:u(2)&&Us(t,21,c(0));return;case 302:u(2)&&Us(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),un(t));return;case 261:case 561:case 1574:case 53:return;case 762:h1(t,i,r);return;case 764:p1(t,i,r);return;case 763:d1(t,i,r,a);return;case 322:x1(t,i,a);return;case 505:return;case 247:g1(t,i,a);return;case 1791:T1(t,i,a);return;case 248:case 1790:case 765:Xe(t,{kind:"other"});return;case 301:u(2)&&(t.objects[c(0)]?.kind==="region"?Im(t,c(0)):R1(t,c(0)));return;case 564:u(2)&&E1(t,c(0));return;case 55:Em(t,i,a,false);return;case 1078:Em(t,i,a,true);return;case 313:u(2)&&M1(t,c(0));return;case 496:u(2)&&P1(t,c(0));return;case 532:u(4)&&He(s,new Ie(27,16).i32(l(1)).i32(l(0)).finish());return;case 531:u(4)&&He(s,new Ie(54,16).i32(l(1)).i32(l(0)).finish());return;case 1051:u(8)&&$1(t,l(3),l(2),l(1),l(0));return;case 1564:u(12)&&j1(t,l(5),l(4),l(3),l(2),l(1),l(0));return;case 1048:u(8)&&V1(t,l(3),l(2),l(1),l(0));return;case 2071:case 2096:case 2074:u(16)&&z1(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)&&IA(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 Ie(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));He(s,p.finish());}return;case 1313:q1(t,i,a);return;case 2610:J1(t,i,a);return;case 1565:S1(t,i,a);return;case 2338:case 2851:C1(t,e===2851,n,r);return;case 2368:case 2881:v1(t,e===2881,n,r);return;case 3907:L1(t,i,a);return;case 3379:D1(t,i,a);return;case 1046:u(8)&&_1(t,l(3),l(2),l(1),l(0));return;case 1045:u(8)&&F1(t,l(3),l(2),l(1),l(0));return;case 544:u(4)&&k1(t,l(1),l(0));return;case 300:u(2)&&Im(t,c(0));return;case 552:u(4)&&B1(t,c(0),c(1));return;case 299:u(2)&&N1(t,c(0));return;case 298:u(2)&&G1(t,c(0));return;case 1065:u(8)&&W1(t,c(0),c(1),l(2),l(3));return;case 1055:u(8)&&H1(t,l(3),l(2),er(o,i));return;case 1049:u(8)&&wm(t,l(3),l(2),er(o,i),0);return;case 1352:u(10)&&wm(t,l(4),l(3),er(o,i+2),c(0));return;default:return}}function*ex(t,e,n,r,o,s={}){let i=PA(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++,Te(),jn()&&(yield),SA(i,b,a,m),a+=m;}Ht(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 Ym(t,e){return e?{...t,[Li]:e}:t}var Xm=3;async function FA(t,e,n){if($(`replayMetafile: input buffer ${t.byteLength} bytes`),false);let r=e??{},o=$o(r),s=r.dpiScale??Br,i=new DataView(t),a=null;try{a=gr(i);}catch(u){J("replayMetafile: parseEmfHeader threw during detection:",u instanceof Error?u.message:u);}if(!a)try{let u=is(i),l=u?Xa(i,u.headerSize):null;if(l){let c=new DataView(l);a=gr(c),a&&($("replayMetafile: WMF carries an embedded EMF; playing the EMF"),i=c);}}catch(u){J("replayMetafile: embedded-EMF probe threw:",u instanceof Error?u.message:u);}if(a){try{let u=await vi(i),l=await cl(i,0,{maxRecords:r.maxRecords,budget:o});o?.check();let c=Vi(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 jo(o,xm(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:await ix(r)}));return f.ctx.restore(),$(`replayMetafile: EMF replay done, ${m.length} deferred images`),{surface:f,deferredImages:m}}catch(u){return o?.throwIfTripped(),J("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=is(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;await Lb(i,u.headerSize,{maxRecords:r.maxRecords,budget:o});let l=Mo(i,u,r.wmfReferenceDpi),c=n(l.width,l.height);return c?(c.ctx.save(),await jo(o,ex(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:await ix(r)})),c.ctx.restore(),{surface:c,deferredImages:[]}):null}catch(u){return o?.throwIfTripped(),J("replayMetafile: WMF EXCEPTION:",u instanceof Error?u.message:u),console.warn("[emf-converter] WMF conversion failed:",u instanceof Error?u.message:u),null}}async function ix(t){if(!t.fonts||t.fonts.length===0)return;let{GdiFontCollection:e}=await Promise.resolve().then(()=>(rx(),nx)),n=e.for(t.fonts,t.fontSmoothing??"cleartype");return n.size>0?n:void 0}function Hm(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}function kA(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=wt(i,a);if(!u)return false;pe(u.ctx,e.drawable,0,0,i,a);let l=At(u.ctx,0,0,i,a),c=Rn(l.data,i,a,n,{w:o,h:s});if(!c)return false;let f=wt(c.w,c.h);return f?(Lt(f.ctx,Rt(c.rgba,c.w,c.h),0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.imageSmoothingEnabled=false,pe(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=Hm(i.imageData);t.setTransform(...i.transform);let u=a,l;if(i.isMetafile){if(n>=Xm){J(` Deferred image [${s}]: skipping embedded metafile, recursion depth ${n}`);continue}let f=await ax(a,Ym({},r),n+1);if(!f){J(` Deferred image [${s}]: metafile conversion returned null`),o=!1;continue}l=f.mimeType,u=Hm(f.data.buffer);}if(i.effect&&!i.isMetafile){let f=await HA(u);if(f){let m=Fl({kind:"plus-image",type:1,data:i.imageData},{kind:"bitmap",rgba:f.data,width:f.width,height:f.height},i.effect,i,i.effectSource);if(m){let{encodePng:b}=await Promise.resolve().then(()=>(Wm(),Gm));u=Hm((await b(m.bitmap.rgba,m.bitmap.width,m.bitmap.height)).buffer),i=m.draw,t.setTransform(...i.transform);}l="image/png";}}let c=await So(u,l);c?(i.resample&&kA(t,c,i.resample)||pe(t,c.drawable,i.dx,i.dy,i.dw,i.dh),c.close()):(J(` 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 BA={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml"};async function NA(t,e,n,r,o){let s=$o(e);e=Ym(e,s);let i=await $m(t,e,n);if(!i)return null;try{let{width:a,height:u}=i;s?.check();let l=await o(i,s);return s?.check(),{format:r,mimeType:BA[r],data:l,width:a,height:u}}catch(a){return s?.throwIfTripped(),J("convertMetafile: EXCEPTION:",a instanceof Error?a.message:a),console.warn("[emf-converter] Conversion failed:",a instanceof Error?a.message:a),null}}function ax(t,e,n=0){return NA(t,e,n,"png",async({data:r,width:o,height:s},i)=>{let{encodePng:a}=await Promise.resolve().then(()=>(Wm(),Gm));return el(i,()=>a(r,o,s))})}async function $m(t,e,n=0){let r=$o(e);r?.check();let o=await Ha(t);r?.check();let s=o?await WA(o,Ym(e,r),n,"convertMetafileToImageData"):null;if(!s)return null;try{let{canvas:i,ctx:a}=s;return {data:i instanceof yn?new Uint8ClampedArray(i.pixels):At(a,0,0,i.width,i.height).data,width:i.width,height:i.height}}catch(i){return r?.throwIfTripped(),J("convertMetafileToImageData: EXCEPTION:",i instanceof Error?i.message:i),console.warn("[emf-converter] Conversion failed:",i instanceof Error?i.message:i),null}}async function ux(t,e){return GA(await ax(t,{...e}))}function GA(t){return t?`data:${t.mimeType};base64,${a1(t.data)}`:null}async function WA(t,e,n,r){let o=$o(e);if(await Sf(),n>Xm)return null;let s={...e,gdiAntialias:e?.gdiAntialias??false};o?.check();let i=null,a=await FA(t,s,(u,l)=>{let c=Cf(u,l,s.maxWidth,s.maxHeight,s.dpiScale??Br,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 yn?i:null;return l&&(l.textDraws>0||!u)?(J(`${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(),J(`${r}: EXCEPTION:`,u instanceof Error?u.message:u),console.warn("[emf-converter] Conversion failed:",u instanceof Error?u.message:u),null}}async function HA(t){let e=await qs(new Uint8Array(t));if(e||Js())return e;let n=await So(t);if(!n)return null;try{let r=wt(n.width,n.height);return r?(pe(r.ctx,n.drawable,0,0,n.width,n.height),{data:At(r.ctx,0,0,n.width,n.height).data,width:n.width,height:n.height}):null}finally{n.close();}}var XA=`
|
|
2
2
|
1:HEADER 2:POLYBEZIER 3:POLYGON 4:POLYLINE 5:POLYBEZIERTO 6:POLYLINETO 7:POLYPOLYLINE 8:POLYPOLYGON
|
|
3
3
|
9:SETWINDOWEXTEX 10:SETWINDOWORGEX 11:SETVIEWPORTEXTEX 12:SETVIEWPORTORGEX 13:SETBRUSHORGEX 14:EOF
|
|
4
4
|
15:SETPIXELV 16:SETMAPPERFLAGS 17:SETMAPMODE 18:SETBKMODE 19:SETPOLYFILLMODE 20:SETROP2 21:SETSTRETCHBLTMODE
|
|
@@ -18,7 +18,7 @@ function vs(t,e,n){let r=o=>o.toString(16).padStart(2,"0");return `#${r(t&255)}$
|
|
|
18
18
|
110:NAMEDESCAPE 111:COLORCORRECTPALETTE 112:SETICMPROFILEA 113:SETICMPROFILEW 114:ALPHABLEND 115:SETLAYOUT
|
|
19
19
|
116:TRANSPARENTBLT 118:GRADIENTFILL 119:SETLINKEDUFIS 120:SETTEXTJUSTIFICATION 121:COLORMATCHTOTARGETW
|
|
20
20
|
122:CREATECOLORSPACEW
|
|
21
|
-
`,
|
|
21
|
+
`,YA=`
|
|
22
22
|
0x0000:EOF 0x001e:SAVEDC 0x0035:REALIZEPALETTE 0x0037:SETPALENTRIES 0x00f7:CREATEPALETTE 0x00f8:CREATEBRUSH
|
|
23
23
|
0x0102:SETBKMODE 0x0103:SETMAPMODE 0x0104:SETROP2 0x0105:SETRELABS 0x0106:SETPOLYFILLMODE
|
|
24
24
|
0x0107:SETSTRETCHBLTMODE 0x0108:SETTEXTCHAREXTRA 0x0127:RESTOREDC 0x012a:INVERTREGION 0x012b:PAINTREGION
|
|
@@ -33,7 +33,7 @@ function vs(t,e,n){let r=o=>o.toString(16).padStart(2,"0");return `#${r(t&255)}$
|
|
|
33
33
|
0x0521:TEXTOUT 0x0538:POLYPOLYGON 0x0548:EXTFLOODFILL 0x061c:ROUNDRECT 0x061d:PATBLT 0x0626:ESCAPE
|
|
34
34
|
0x06fe:CREATEBITMAP 0x06ff:CREATEREGION 0x0817:ARC 0x081a:PIE 0x0830:CHORD 0x0922:BITBLT 0x0940:DIBBITBLT
|
|
35
35
|
0x0a32:EXTTEXTOUT 0x0b23:STRETCHBLT 0x0b41:DIBSTRETCHBLT 0x0d33:SETDIBTODEV 0x0f43:STRETCHDIB
|
|
36
|
-
|
|
36
|
+
`,$A=`
|
|
37
37
|
0x4001:HEADER 0x4002:ENDOFFILE 0x4003:COMMENT 0x4004:GETDC 0x4005:MULTIFORMATSTART 0x4006:MULTIFORMATSECTION
|
|
38
38
|
0x4007:MULTIFORMATEND 0x4008:OBJECT 0x4009:CLEAR 0x400a:FILLRECTS 0x400b:DRAWRECTS 0x400c:FILLPOLYGON
|
|
39
39
|
0x400d:DRAWLINES 0x400e:FILLELLIPSE 0x400f:DRAWELLIPSE 0x4010:FILLPIE 0x4011:DRAWPIE 0x4012:DRAWARC
|
|
@@ -46,5 +46,5 @@ function vs(t,e,n){let r=o=>o.toString(16).padStart(2,"0");return `#${r(t&255)}$
|
|
|
46
46
|
0x402d:TRANSLATEWORLDTRANSFORM 0x402e:SCALEWORLDTRANSFORM 0x402f:ROTATEWORLDTRANSFORM 0x4030:SETPAGETRANSFORM
|
|
47
47
|
0x4031:RESETCLIP 0x4032:SETCLIPRECT 0x4033:SETCLIPPATH 0x4034:SETCLIPREGION 0x4035:OFFSETCLIP
|
|
48
48
|
0x4036:DRAWDRIVERSTRING 0x4037:STROKEFILLPATH 0x4038:SERIALIZABLEOBJECT 0x4039:SETTSGRAPHICS 0x403a:SETTSCLIP
|
|
49
|
-
`;function
|
|
50
|
-
`)||null}function
|
|
49
|
+
`;function jm(t,e,n){let r=new Map;for(let o of t.split(/\s+/)){let s=o.indexOf(":");s>0&&r.set(n?parseInt(o.slice(0,s),16):Number(o.slice(0,s)),e+o.slice(s+1));}return r}function lx(){return {emr:jm(XA,"EMR_",false),meta:jm(YA,"META_",true),plus:jm($A,"EMFPLUS_",true)}}var jA=3,Vm=null;function zm(){return Vm??(Vm=lx()),Vm}function qm(t,e){t[e]=(t[e]??0)+1;}function Jm(){return {recordCount:0,emfPlusRecordCount:0,recordTypes:{},fonts:new Map,hasText:false,imageCount:0,mimeTypes:new Set,embeddedMetafiles:0,truncated:false,plus:"none"}}function Ur(t,e,n){if(!e)return;let r=e.toLowerCase(),o=t.fonts.get(r)??{name:e,gdi:false,emfPlus:false};o[n]=true,t.fonts.set(r,o);}function _s(t,e){t.imageCount++,t.mimeTypes.add(e);}function VA(t,e){for(let n of e.fonts.values())n.gdi&&Ur(t,n.name,"gdi"),n.emfPlus&&Ur(t,n.name,"emfPlus");t.hasText||(t.hasText=e.hasText);}function fx(t,e){if(e<0||e+20>t.byteLength)return null;let n=t.getUint32(e+16,true);return n===4?"image/jpeg":n===5?"image/png":"image/bmp"}function zA(t){let e=wo(t);if(e)return e;let n=t;return n.length>=4&&(n[0]===73&&n[1]===73&&n[2]===42&&n[3]===0||n[0]===77&&n[1]===77&&n[2]===0&&n[3]===42)?"image/tiff":n.length>=2&&n[0]===66&&n[1]===77?"image/bmp":n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255?"image/jpeg":"application/octet-stream"}function Km(t){try{return gr(t)}catch{return null}}var qA=new Set([83,84,96,97,108]),cx={76:84,77:84,78:84,114:84,116:84,79:96,80:48,81:48};function bx(t,e,n,r){let o=zm().emr,s=0;for(;s+8<=t.byteLength;){if(e.recordCount>=n){e.truncated=true;return}let i=t.getUint32(s,true),a=t.getUint32(s+4,true);if(a<8||s+a>t.byteLength){e.truncated=true;return}if(e.recordCount++,qm(e.recordTypes,o.get(i)??`UNKNOWN_0x${i.toString(16)}`),i===82)a>=332&&Ur(e,Ke(t,s+8+32,32),"gdi");else if(qA.has(i))e.hasText=true;else if(i===70)JA(t,s+8,s+a,e,r);else if(i in cx){let u=cx[i];if(a>=u+8){let l=t.getUint32(s+u,true),c=t.getUint32(s+u+4,true);if(c>=20&&l>=8&&l+c<=a){let f=fx(t,s+l);f&&_s(e,f);}}}else if(i===14)return;s+=a;}}function JA(t,e,n,r,o){if(e+8>n)return;let s=t.getUint32(e,true);if(t.getUint32(e+4,true)!==726027589||s<=4)return;let i=zm().plus,a=Math.min(n,e+8+s-4),u=e+8;for(;u+12<=a;){if(r.emfPlusRecordCount>=o){r.truncated=true;return}let l=t.getUint16(u,true),c=t.getUint16(u+2,true),f=t.getUint32(u+4,true);if(f<12||u+f>a){r.truncated=true;return}r.emfPlusRecordCount++,qm(r.recordTypes,i.get(l)??`UNKNOWN_0x${l.toString(16)}`),l===16385&&r.plus==="none"?r.plus=(c&1)!==0?"dual":"only":(l===16412||l===16438)&&(r.hasText=true),u+=f;}}function hx(t,e,n,r){Yo(t,o=>{let s=o.flags>>8&127,i=o.view,a=o.dataOff,u=o.dataSize;if(s===6&&u>=28){let l=i.getUint32(a+20,true);l>0&&24+l*2<=u&&Ur(e,Ke(i,a+24,l),"emfPlus");}else if(s===5&&u>=8){let l=i.getUint32(a+4,true);if(l===1&&u>=28)i.getUint32(a+24,true)===1&&u>28?_s(e,zA(new Uint8Array(i.buffer,i.byteOffset+a+28,Math.min(u-28,16)))):_s(e,"image/bmp");else if(l===2&&u>=16){let c=i.getUint32(a+8,true),f=i.getUint32(a+12,true);if(e.embeddedMetafiles++,_s(e,c<=2?"image/wmf":"image/emf"),c>=3&&n<jA&&f>0&&16+f<=u){let m=new DataView(i.buffer,i.byteOffset+a+16,f);if(Km(m)){let b=Jm();bx(m,b,r,r),hx(m,b,n+1,r),VA(e,b);}}}}});}function KA(t){if(t.byteLength<68)return null;let e=t.getUint32(60,true),n=t.getUint32(64,true);if(e===0||n<88||n+e*2>t.byteLength)return null;let r=[],o="";for(let s=0;s<e;s++){let i=t.getUint16(n+s*2,true);i===0?(r.push(o),o=""):o+=String.fromCharCode(i);}return r.push(o),r.filter(s=>s.length>0).join(`
|
|
50
|
+
`)||null}function px(t,e,n){let r=Vi(e);if(!r)return null;let o=Jm();bx(t,o,n.maxRecords??2e5,n.maxRecords??5e5),hx(t,o,0,n.maxRecords??2e5);let s=Io(r.right-r.left,r.bottom-r.top),i={left:t.getInt32(24,true),top:t.getInt32(28,true),right:t.getInt32(32,true),bottom:t.getInt32(36,true)},a={width:t.getInt32(72,true),height:t.getInt32(76,true)},u={width:t.getInt32(80,true),height:t.getInt32(84,true)},l=a.width>0&&a.height>0&&u.width>0&&u.height>0;return dx(o,{format:o.plus==="none"?"emf":o.plus==="dual"?"emf+dual":"emf+",bounds:e.bounds,frame:i,device:l?a:null,deviceMm:l?u:null,dpi:l?{x:a.width*25.4/u.width,y:a.height*25.4/u.height}:{x:96,y:96},width:s.w,height:s.h,description:KA(t)})}function dx(t,e){return {...e,recordCount:t.recordCount,emfPlusRecordCount:t.emfPlusRecordCount,recordTypes:t.recordTypes,fonts:[...t.fonts.values()],hasText:t.hasText,images:{count:t.imageCount,mimeTypes:[...t.mimeTypes].sort()},embeddedMetafiles:t.embeddedMetafiles,truncated:t.truncated}}var mx={2368:16,2881:20,3907:22,3379:18};function ZA(t,e,n,r,o){let s=zm().meta,i=e;for(;i+6<=t.byteLength;){if(n.recordCount>=r){n.truncated=true;return}let a=t.getUint32(i,true)*2,u=t.getUint16(i+4,true);if(a<6||i+a>t.byteLength){n.truncated=true;return}if(u===0)return;n.recordCount++,qm(n.recordTypes,s.get(u)??`UNKNOWN_0x${u.toString(16)}`);let l=i+6,c=i+a;if(u===763){if(a>=24){let f=[];for(let m=0;m<32&&l+18+m<c;m++){let b=t.getUint8(l+18+m);if(b===0)break;f.push(b);}Ur(n,String.fromCharCode(...Zn(f,1,{ansi:o}).codes),"gdi");}}else if(u===1313||u===2610)n.hasText=true;else if(u in mx){let f=l+mx[u];if(f+40<=c){let m=fx(t,f);m&&_s(n,m);}}i+=a;}}function QA(t,e){let n=is(t);if(!n||n.boundsRight-n.boundsLeft<=0||n.boundsBottom-n.boundsTop<=0)return null;let r=Jm();ZA(t,n.headerSize,r,e.maxRecords??2e5,e.ansiCodePage);let o=Mo(t,n),s=Io(o.width,o.height),i=s.w,a=s.h,u=null,l=false,c=Xa(t,n.headerSize);if(c){let b=new DataView(c),h=Km(b),p=h?px(b,h,e):null;if(p){l=true,i=p.width,a=p.height,u=p.description;for(let d of p.fonts)Ur(r,d.name,d.gdi?"gdi":"emfPlus"),d.gdi&&d.emfPlus&&Ur(r,d.name,"emfPlus");r.hasText||(r.hasText=p.hasText),r.imageCount+=p.images.count,p.images.mimeTypes.forEach(d=>r.mimeTypes.add(d)),r.embeddedMetafiles+=p.embeddedMetafiles;}}let f={left:n.boundsLeft,top:n.boundsTop,right:n.boundsRight,bottom:n.boundsBottom},m=b=>Math.round(b*2540/n.unitsPerInch);return dx(r,{format:"wmf",placeable:n.placeable,playsEmbeddedEmf:l,bounds:f,frame:n.placeable?{left:m(f.left),top:m(f.top),right:m(f.right),bottom:m(f.bottom)}:null,unitsPerInch:n.unitsPerInch,device:null,deviceMm:null,dpi:{x:96,y:96},width:i,height:a,description:u})}async function tI(t,e){try{let n=await Ha(t);if(!n)return null;let r=new DataView(n),o=e??{},s=Km(r);return s?px(r,s,o):QA(r,o)}catch(n){return J("getMetafileInfo: EXCEPTION:",n instanceof Error?n.message:n),null}}function ZU(t,e){return ux(t,e)}function QU(t,e){return $m(t,e)}export{Br as DEFAULT_DPI_SCALE,ZU as convertMetafileToDataUrl,QU as convertMetafileToImageData,tI as getMetafileInfo};
|