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