functionos(e){vart=e.toString(16);return1===t.length?"0"+t:t}functionns(e){return"#"+e.map(os).join("")}functionrs(e){returne?(t=e,Array.isArray(t[0])?e:[e]):[];vart}functionas(e,t,o){for(varn=0;n<o.length;n++)if(is(e,t,o[n]))return!0;return!1}functionis(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=ss(l,i,s);if(!i)returnc;if(!l&&c)return!0;if(ss(e[t],n,s)&&ss(e[t+1],r,s)&&ss(e[t+2],a,s)&&c)return!0;return!1}(e,t,o))return!0;break;default:return!1}}functionss(e,t,o){returne>=t-o&&e<=t+o}functionls(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||!as(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],b=i[4];returnx?[Math.round(m/x),Math.round(g/x),Math.round(h/x),Math.round(x/b)]:o.defaultColor}functioncs(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&&as(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}functionus(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&&as(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}functionds(e){returnps(e,"defaultColor",[0,0,0,0])}functionps(e,t,o){returnvoid0===e[t]?o:e[t]}functionms(e){if(hs(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}}functiongs(e){returnfunction(e){return"undefined"!=typeofHTMLCanvasElement&&einstanceofHTMLCanvasElement}(e)?"canvas":function(e){returnxs&&einstanceofOffscreenCanvas}(e)?"offscreencanvas":function(e){return"undefined"!=typeofImageBitmap&&einstanceofImageBitmap}(e)?"imagebitmap":e.src}functionhs(e){return"undefined"!=typeofHTMLImageElement&&einstanceofHTMLImageElement}varxs="undefined"!=typeofOffscreenCanvas;varbs="undefined"==typeofwindow;function_s(e){returnError("FastAverageColor: "+e)}functionys(e,t){t||console.error(e)}varvs=function(){functione(){this.canvas=null,this.ctx=null}returne.prototype.getColorAsync=function(e,t){if(!e)returnPromise.reject(_s("call .getColorAsync() without resource."));if("string"==typeofe){if("undefined"==typeofImage)returnPromise.reject(_s("resource as string is not supported in this environment"));varo=newImage;returno.crossOrigin=t&&t.crossOrigin||"",o.src=e,this.bindImageEvents(o,t)}if(hs(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=ds(t=t||{});if(!e)returnys(a=_s("call .getColor(null) without resource"),t.silent),this.prepareResult(o,a);varn=function(e,t){varo,n=ps(t,"left",0),r=ps(t,"top",0),a=ps(t,"width",e.width),i=ps(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}}(ms(e),t);if(!(n.srcWidth&&n.srcHeight&&n.destWidth&&n.destHeight))returnys(a=_s('incorrect sizes for resource "'.concat(gs(e),'"')),t.silent),this.prepareResult(o,a);if(!this.canvas&&(this.canvas=bs?xs?newOffscreenCanvas(1,1):null:document.