functionrs(e){vart=e.toString(16);return1===t.length?"0"+t:t}functionas(e){return"#"+e.map(rs).join("")}functionis(e){returne?(t=e,Array.isArray(t[0])?e:[e]):[];vart}functionss(e,t,o){for(varn=0;n<o.length;n++)if(ls(e,t,o[n]))return!0;return!1}functionls(e,t,o){switch(o.length){case3:if(function(e,t,o){if(255!==e[t+3])return!0;if(e[t]===o[0]&&e[t+1]===o[1]&&e[t+2]===o[2])return!0;return!1}(e,t,o))return!0;break;case4:if(function(e,t,o){if(e[t+3]&&o[3])returne[t]===o[0]&&e[t+1]===o[1]&&e[t+2]===o[2]&&e[t+3]===o[3];returne[t+3]===o[3]}(e,t,o))return!0;break;case5:if(function(e,t,o){varn=o[0],r=o[1],a=o[2],i=o[3],s=o[4],l=e[t+3],c=cs(l,i,s);if(!i)returnc;if(!l&&c)return!0;if(cs(e[t],n,s)&&cs(e[t+1],r,s)&&cs(e[t+2],a,s)&&c)return!0;return!1}(e,t,o))return!0;break;default:return!1}}functioncs(e,t,o){returne>=t-o&&e<=t+o}functionus(e,t,o){for(varn={},r=o.ignoredColor,a=o.step,i=[0,0,0,0,0],s=0;s<t;s+=a){varl=e[s],c=e[s+1],u=e[s+2],d=e[s+3];if(!r||!ss(e,s,r)){varp=Math.round(l/24)+","+Math.round(c/24)+","+Math.round(u/24);n[p]?n[p]=[n[p][0]+l*d,n[p][1]+c*d,n[p][2]+u*d,n[p][3]+d,n[p][4]+1]:n[p]=[l*d,c*d,u*d,d,1],i[4]<n[p][4]&&(i=n[p])}}varm=i[0],g=i[1],h=i[2],x=i[3],_=i[4];returnx?[Math.round(m/x),Math.round(g/x),Math.round(h/x),Math.round(x/_)]:o.defaultColor}functionds(e,t,o){for(varn=0,r=0,a=0,i=0,s=0,l=o.ignoredColor,c=o.step,u=0;u<t;u+=c){vard=e[u+3],p=e[u]*d,m=e[u+1]*d,g=e[u+2]*d;l&&ss(e,u,l)||(n+=p,r+=m,a+=g,i+=d,s++)}returni?[Math.round(n/i),Math.round(r/i),Math.round(a/i),Math.round(i/s)]:o.defaultColor}functionps(e,t,o){for(varn=0,r=0,a=0,i=0,s=0,l=o.ignoredColor,c=o.step,u=0;u<t;u+=c){vard=e[u],p=e[u+1],m=e[u+2],g=e[u+3];l&&ss(e,u,l)||(n+=d*d*g,r+=p*p*g,a+=m*m*g,i+=g,s++)}returni?[Math.round(Math.sqrt(n/i)),Math.round(Math.sqrt(r/i)),Math.round(Math.sqrt(a/i)),Math.round(i/s)]:o.defaultColor}functionms(e){returngs(e,"defaultColor",[0,0,0,0])}functiongs(e,t,o){returnvoid0===e[t]?o:e[t]}functionhs(e){if(_s(e)){vart=e.naturalWidth,o=e.naturalHeight;returne.naturalWidth||-1===e.src.search(/\.svg(\?|$)/i)||(t=o=100),{width:t,height:o}}returnfunction(e){return"undefined"!=typeofHTMLVideoElement&&einstanceofHTMLVideoElement}(e)?{width:e.videoWidth,height:e.videoHeight}:{width:e.width,height:e.height}}functionxs(e){returnfunction(e){return"undefined"!=typeofHTMLCanvasElement&&einstanceofHTMLCanvasElement}(e)?"canvas":function(e){returnbs&&einstanceofOffscreenCanvas}(e)?"offscreencanvas":function(e){return"undefined"!=typeofImageBitmap&&einstanceofImageBitmap}(e)?"imagebitmap":e.src}function_s(e){return"undefined"!=typeofHTMLImageElement&&einstanceofHTMLImageElement}varbs="undefined"!=typeofOffscreenCanvas;varys="undefined"==typeofwindow;functionfs(e){returnError("FastAverageColor: "+e)}functionvs(e,t){t||console.error(e)}varks=function(){functione(){this.canvas=null,this.ctx=null}returne.prototype.getColorAsync=function(e,t){if(!e)returnPromise.reject(fs("call .getColorAsync() without resource."));if("string"==typeofe){if("undefined"==typeofImage)returnPromise.reject(fs("resource as string is not supported in this environment"));varo=newImage;returno.crossOrigin=t&&t.crossOrigin||"",o.src=e,this.bindImageEvents(o,t)}if(_s(e)&&!e.complete)returnthis.bindImageEvents(e,t);varn=this.getColor(e,t);returnn.error?Promise.reject(n.error):Promise.resolve(n)},e.prototype.getColor=function(e,t){varo=ms(t=t||{});if(!e)returnvs(a=fs("call .getColor(null) without resource"),t.silent),this.prepareResult(o,a);varn=function(e,t){varo,n=gs(t,"left",0),r=gs(t,"top",0),a=gs(t,"width",e.width),i=gs(t,"height",e.height),s=a,l=i;return"precision"===t.mode||(a>i?(o=a/i,s=100,l=Math.round(s/o)):(o=i/a,l=100,s=Math.round(l/o)),(s>a||l>i||s<10||l<10)&&(s=a,l=i)),{srcLeft:n,srcTop:r,srcWidth:a,srcHeight:i,destWidth:s,destHeight:l}}(hs(e),t);if(!(n.srcWidth&&n.srcHeight&&n.destWidth&&n.destHeight))returnvs(a=fs('incorrect sizes for resource "'.concat(xs(e),'"')),t.silent),this.prepareResult(o,a);if(!this.canvas&&(this.canvas=ys?bs?newOffscreenCanvas(1,1):null:document.