e.exports=function(){"use strict";functione(e,t){for(varn=0;n<t.length;n++){varr=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}functiont(e,t){returnfunction(e){if(Array.isArray(e))returne}(e)||function(e,t){varn=[],r=!0,a=!1,o=void0;try{for(varc,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throwo}}returnn}(e,t)||function(){thrownewTypeError("Invalid attempt to destructure non-iterable instance")}()}returnfunction(){functionn(){!function(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}(this,n)}varr,a,o;returnr=n,(a=[{key:"getColorAsync",value:function(e,t,n){e.complete?t.call(e,this.getColor(e,n),n&&n.data):this._bindImageEvents(e,t,n)}},{key:"getColor",value:function(e,t){t=t||{};varn=this._getDefaultColor(t),r=this._getOriginalSize(e),a=this._prepareSizeAndPosition(r,t),o=null,c=n;if(!(a.srcWidth&&a.srcHeight&&a.destWidth&&a.destHeight))returnthis._prepareResult(n,newError("FastAverageColor: Incorrect sizes."));if(!this._ctx&&(this._canvas=this._makeCanvas(),this._ctx=this._canvas.getContext&&this._canvas.getContext("2d"),!this._ctx))returnthis._prepareResult(n,newError("FastAverageColor: Canvas Context 2D is not supported in this browser."));this._canvas.width=a.destWidth,this._canvas.height=a.destHeight;try{this._ctx.clearRect(0,0,a.destWidth,a.destHeight),this._ctx.drawImage(e,a.srcLeft,a.srcTop,a.srcWidth,a.srcHeight,0,0,a.destWidth,a.destHeight);vari=this._ctx.getImageData(0,0,a.destWidth,a.destHeight).data;c=this.getColorFromArray4(i,t)}catch(e){o=e}returnthis._prepareResult(c,o)}},{key:"getColorFromArray4",value:function(e,t){t=t||{};varn=e.length;if(n<4)returnthis._getDefaultColor(t);varr=n-n%4,a=4*(t.step||1),o="_"+(t.algorithm||"sqrt")+"Algorithm";if("function"!=typeofthis[o])thrownewError("FastAverageColor: ".concat(t.algorithm," is unknown algorithm."));returnthis[o](e,r,a)}},{key:"destroy",value:function(){deletethis._canvas,deletethis._ctx}},{key:"_getDefaultColor",value:function(e){returnthis._getOption(e,"defaultColor",[255,255,255,255])}},{key:"_getOption",value:function(e,t,n){returnvoid0===e[t]?n:e[t]}},{key:"_prepareSizeAndPosition",value:function(e,t){varn,r=this._getOption(t,"left",0),a=this._getOption(t,"top",0),o=this._getOption(t,"width",e.width),c=this._getOption(t,"height",e.height),i=o,l=c;return"precision"===t.mode?{srcLeft:r,srcTop:a,srcWidth:o,srcHeight:c,destWidth:i,destHeight:l}:(o>c?(n=o/c,i=100,l=Math.round(i/n)):(n=c/o,l=100,i=Math.round(l/n)),(i>o||l>c||i<10||l<10)&&(i=o,l=c),{srcLeft:r,srcTop:a,srcWidth:o,srcHeight:c,destWidth:i,destHeight:l})}},{key:"_simpleAlgorithm",value:function(e,t,n){for(varr=0,a=0,o=0,c=0,i=0,l=0;l<t;l+=n){vars=e[l+3];r+=e[l]*s,a+=e[l+1]*s,o+=e[l+2]*s,c+=s,i++}returnc?[Math.round(r/c),Math.round(a/c),Math.round(o/c),Math.round(c/i)]:[0,0,0,0]}},{key:"_sqrtAlgorithm",value:function(e,t,n){for(varr=0,a=0,o=0,c=0,i=0,l=0;l<t;l+=n){vars=e[l],u=e[l+1],b=e[l+2],m=e[l+3];r+=s*s*m,a+=u*u*m,o+=b*b*m,c+=m,i++}returnc?[Math.round(Math.sqrt(r/c)),Math.round(Math.sqrt(a/c)),Math.round(Math.sqrt(o/c)),Math.round(c/i)]:[0,0,0,0]}},{key:"_dominantAlgorithm",value:function(e,n,r){for(vara={},o=0;o<n;o+=r){varc=e[o],i=e[o+1],l=e[o+2],s=e[o+3],u=Math.round(c/24)+","+Math.round(i/24)+","+Math.round(l/24);a[u]?a[u]=[a[u][0]+c*s,a[u][1]+i*s,a[u][2]+l*s,a[u][3]+s,a[u][4]+1]:a[u]=[c*s,i*s,l*s,s,1]}varb=t(Object.keys(a).map((function(e){returna[e]})).sort((function(e,t){varn=e[4],r=t[4];returnn>r?-1:n===r?0:1}))[0],5),m=b[0],d=b[1],h=b[2],p=b[3],g=b[4];returnp?[Math.round(m/p),Math.round(d/p),Math.round(h/p),Math.round(p/g)]:[0,0,0,0]}},{key:"_bindImageEvents",value:function(e,t,n){varr=this,a=(n=n||{})&&n.data,o=this._getDefaultColor(n),c=function(){s(),t.call(e,r.getColor(e,n),a)},i=function(){s(),t.call(e,r._prepareResult(o,newError("Image error")),a)},l=function(){s(),t.call(e,r._prepareResult(o,newError("Im