functionns(e){vart=e.toString(16);return1===t.length?"0"+t:t}functionrs(e){return"#"+e.map(ns).join("")}functionas(e){returne?(t=e,Array.isArray(t[0])?e:[e]):[];vart}functionis(e,t,o){for(varn=0;n<o.length;n++)if(ss(e,t,o[n]))return!0;return!1}functionss(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=ls(l,i,s);if(!i)returnc;if(!l&&c)return!0;if(ls(e[t],n,s)&&ls(e[t+1],r,s)&&ls(e[t+2],a,s)&&c)return!0;return!1}(e,t,o))return!0;break;default:return!1}}functionls(e,t,o){returne>=t-o&&e<=t+o}functioncs(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||!is(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}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+3],p=e[u]*d,m=e[u+1]*d,g=e[u+2]*d;l&&is(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}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],p=e[u+1],m=e[u+2],g=e[u+3];l&&is(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}functionps(e){returnms(e,"defaultColor",[0,0,0,0])}functionms(e,t,o){returnvoid0===e[t]?o:e[t]}functiongs(e){if(xs(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}}functionhs(e){returnfunction(e){return"undefined"!=typeofHTMLCanvasElement&&einstanceofHTMLCanvasElement}(e)?"canvas":function(e){return_s&&einstanceofOffscreenCanvas}(e)?"offscreencanvas":function(e){return"undefined"!=typeofImageBitmap&&einstanceofImageBitmap}(e)?"imagebitmap":e.src}functionxs(e){return"undefined"!=typeofHTMLImageElement&&einstanceofHTMLImageElement}var_s="undefined"!=typeofOffscreenCanvas;varbs="undefined"==typeofwindow;functionys(e){returnError("FastAverageColor: "+e)}functionfs(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(ys("call .getColorAsync() without resource."));if("string"==typeofe){if("undefined"==typeofImage)returnPromise.reject(ys("resource as string is not supported in this environment"));varo=newImage;returno.crossOrigin=t&&t.crossOrigin||"",o.src=e,this.bindImageEvents(o,t)}if(xs(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=ps(t=t||{});if(!e)returnfs(a=ys("call .getColor(null) without resource"),t.silent),this.prepareResult(o,a);varn=function(e,t){varo,n=ms(t,"left",0),r=ms(t,"top",0),a=ms(t,"width",e.width),i=ms(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}}(gs(e),t);if(!(n.srcWidth&&n.srcHeight&&n.destWidth&&n.destHeight))returnfs(a=ys('incorrect sizes for resource "'.concat(hs(e),'"')),t.silent),this.prepareResult(o,a);if(!this.canvas&&(this.canvas=bs?_s?newOffscreenCanvas(1,1):null:document.