!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Vibrant=e():t.Vibrant=e()}(window,function(){return n={},o.m=r=[function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assignDeep=e.mapValues=void 0,e.mapValues=function(t,e){var r,n,o={};for(r in t)t.hasOwnProperty(r)&&(n=t[r],o[r]=e(n));return o},e.assignDeep=function n(o){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return t.forEach(function(t){if(t)for(var e in t){var r;t.hasOwnProperty(e)&&(r=t[e],Array.isArray(r)?o[e]=r.slice(0):"object"==typeof r?(o[e]||(o[e]={}),n(o[e],r)):o[e]=r)}}),o}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=(Object.defineProperty(e,"__esModule",{value:!0}),r(7)),i=n(r(8)),a=r(0),r=(u.use=function(t){this._pipeline=t},u.from=function(t){return new i.default(t)},Object.defineProperty(u.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0}),u.prototype._process=function(t,e){return this.opts.quantizer,t.scaleDown(this.opts),e=o.buildProcessOptions(this.opts,e),u._pipeline.process(t.getImageData(),e)},u.prototype.palette=function(){return this.swatches()},u.prototype.swatches=function(){throw new Error("Method deprecated. Use `Vibrant.result.palettes[name]` instead")},u.prototype.getPalette=function(){var e=this,t=arguments[0],r="string"==typeof t?t:"default",n="string"==typeof t?arguments[1]:t,o=new this.opts.ImageClass;return o.load(this._src).then(function(t){return e._process(t,{generators:[r]})}).then(function(t){return(e._result=t).palettes[r]}).then(function(t){return o.remove(),n&&n(void 0,t),t}).catch(function(t){return o.remove(),n&&n(t),Promise.reject(t)})},u.prototype.getPalettes=function(){var e=this,t=arguments[0],r=arguments[1],n=Array.isArray(t)?t:["*"],o=Array.isArray(t)?r:t,i=new this.opts.ImageClass;return i.load(this._src).then(function(t){return e._process(t,{generators:n})}).then(function(t){return(e._result=t).palettes}).then(function(t){return i.remove(),o&&o(void 0,t),t}).catch(function(t){return i.remove(),o&&o(t),Promise.reject(t)})},u.DefaultOpts={colorCount:64,quality:5,filters:[]},u);function u(t,e){this._src=t,this.opts=a.assignDeep({},u.DefaultOpts,e)}e.default=r},function(t,e,r){"use strict";function n(){}Object.defineProperty(e,"__esModule",{value:!0}),e.applyFilters=e.ImageBase=void 0,n.prototype.scaleDown=function(t){var e,r=this.getWidth(),n=this.getHeight(),o=1;0<t.maxDimension?(e=Math.max(r,n))>t.maxDimension&&(o=t.maxDimension/e):o=1/t.quality,o<1&&this.resize(r*o,n*o,o)},e.ImageBase=n,e.applyFilters=function(t,e){if(0<e.length)for(var r,n=t.data,o=n.length/4,i=0;i<o;i++)for(var a=n[0+(r=4*i)],u=n[1+r],s=n[2+r],l=n[3+r],c=0;c<e.length;c++)if(!e[c](a,u,s,l)){n[3+r]=0;break}return t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Swatch=void 0;var n=r(4),r=(o.applyFilters=function(t,i){return 0<i.length?t.filter(function(t){for(var e=t.r,r=t.g,n=t.b,o=0;o<i.length;o++)if(!i[o](e,r,n,255))return!1;return!0}):t},o.clone=function(t){return new o(t._rgb,t._population)},Object.defineProperty(o.prototype,"r",{get:function(){return this._rgb[0]},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"g",{get:function(){return this._rgb[1]},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"b",{get:function(){return this._rgb[2]},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"rgb",{get:function(){return this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"hsl",{get:function(){var t,e,r;return this._hsl||(t=(r=this._rgb)[0],e=r[1],r=r[2],this._hsl=n.rgbToHsl(t,e,r)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"hex",{get:function(){var t,e,r;return this._hex||(t=(r=this._rgb)[0],e=r[1],r=r[2],this._hex=n.rgbToHex(t,e,r)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"population",{get:function(){return this._population},enumerable:!1,configurable:!0}),o.prototype.toJSON=function(){return{rgb:this.rgb,population:this.population}},o.prototype.getRgb=function(){return this._rgb},o.prototype.getHsl=function(){return this.hsl},o.prototype.getPopulation=function(){return this._population},o.prototype.getHex=function(){return this.hex},o.prototype.getYiq=function(){var t;return this._yiq||(t=this._rgb,this._yiq=(299*t[0]+587*t[1]+114*t[2])/1e3),this._yiq},Object.defineProperty(o.prototype,"titleTextColor",{get:function(){return this._titleTextColor&&(this._titleTextColor=this.getYiq()<200?"#fff":"#000"),this._titleTextColor},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"bodyTextColor",{get:function(){return this._bodyTextColor&&(this._bodyTextColor=this.getYiq()<150?"#fff":"#000"),this._bodyTextColor},enumerable:!1,configurable:!0}),o.prototype.getTitleTextColor=function(){return this.titleTextColor},o.prototype.getBodyTextColor=function(){return this.bodyTextColor},o);function o(t,e){this._rgb=t,this._population=e}e.Swatch=r},function(t,e,r){"use strict";function n(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(e)return[e[1],e[2],e[3]].map(function(t){return parseInt(t,16)});throw new RangeError("'"+t+"' is not a valid hex color")}function o(t,e,r){return e/=255,r/=255,t=.04045<(t/=255)?Math.pow((t+.005)/1.055,2.4):t/12.92,e=.04045<e?Math.pow((e+.005)/1.055,2.4):e/12.92,r=.04045<r?Math.pow((r+.005)/1.055,2.4):r/12.92,[.4124*(t*=100)+.3576*(e*=100)+.1805*(r*=100),.2126*t+.7152*e+.0722*r,.0193*t+.1192*e+.9505*r]}function i(t,e,r){return e/=100,r/=108.883,t=.008856<(t/=95.047)?Math.pow(t,1/3):7.787*t+16/116,[116*(e=.008856<e?Math.pow(e,1/3):7.787*e+16/116)-16,500*(t-e),200*(e-(r=.008856<r?Math.pow(r,1/3):7.787*r+16/116))]}function a(t,e,r){return i((r=o(t,e,r))[0],r[1],r[2])}function u(t,e){var r=t[0],n=t[1],o=t[2],i=e[0],a=e[1],u=r-i,t=n-a,e=o-(s=e[2]),o=Math.sqrt(n*n+o*o),r=i-r,s=Math.sqrt(a*a+s*s)-o,e=Math.sqrt(u*u+t*t+e*e),e=Math.sqrt(e)>Math.sqrt(Math.abs(r))+Math.sqrt(Math.abs(s))?Math.sqrt(e*e-r*r-s*s):0;return r/=1,s/=1+.045*o,e/=1+.015*o,Math.sqrt(r*r+s*s+e*e)}function s(t,e){return u(a.apply(void 0,t),a.apply(void 0,e))}Object.defineProperty(e,"__esModule",{value:!0}),e.getColorDiffStatus=e.hexDiff=e.rgbDiff=e.deltaE94=e.rgbToCIELab=e.xyzToCIELab=e.rgbToXyz=e.hslToRgb=e.rgbToHsl=e.rgbToHex=e.hexToRgb=e.DELTAE94_DIFF_STATUS=void 0,e.DELTAE94_DIFF_STATUS={NA:0,PERFECT:1,CLOSE:2,GOOD:10,SIMILAR:50},e.hexToRgb=n,e.rgbToHex=function(t,e,r){return"#"+((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1,7)},e.rgbToHsl=function(t,e,r){t/=255,e/=255,r/=255;var n=Math.max(t,e,r),o=Math.min(t,e,r),i=0,a=0,u=(n+o)/2;if(n!==o){var s=n-o,a=.5<u?s/(2-n-o):s/(n+o);switch(n){case t:i=(e-r)/s+(e<r?6:0);break;case e:i=(r-t)/s+2;break;case r:i=(t-e)/s+4}i/=6}return[i,a,u]},e.hslToRgb=function(t,e,r){var n,o,i;function a(t,e,r){return r<0&&(r+=1),1<r&&--r,r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}return 0===e?n=o=i=r:(n=a(e=2*r-(r=r<.5?r*(1+e):r+e-r*e),r,t+1/3),o=a(e,r,t),i=a(e,r,t-1/3)),[255*n,255*o,255*i]},e.rgbToXyz=o,e.xyzToCIELab=i,e.rgbToCIELab=a,e.deltaE94=u,e.rgbDiff=s,e.hexDiff=function(t,e){return s(n(t),n(e))},e.getColorDiffStatus=function(t){return t<e.DELTAE94_DIFF_STATUS.NA?"N/A":t<=e.DELTAE94_DIFF_STATUS.PERFECT?"Perfect":t<=e.DELTAE94_DIFF_STATUS.CLOSE?"Close":t<=e.DELTAE94_DIFF_STATUS.GOOD?"Good":t<e.DELTAE94_DIFF_STATUS.SIMILAR?"Similar":"Wrong"}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=n(r(6)),r=n(r(9));o.default.DefaultOpts.ImageClass=r.default,t.exports=o.default},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),(r=n(r(1))).default.DefaultOpts.quantizer="mmcq",r.default.DefaultOpts.generators=["default"],r.default.DefaultOpts.filters=["default"],e.default=r.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.buildProcessOptions=void 0;var i=r(0);e.buildProcessOptions=function(t,e){var r=t.colorCount,n=t.quantizer,o=t.generators,t=t.filters;return(n="string"==typeof n?{name:n,options:{}}:n).options=i.assignDeep({},{colorCount:r},n.options),i.assignDeep({},{quantizer:n,generators:o,filters:t},e)}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=(Object.defineProperty(e,"__esModule",{value:!0}),n(r(1))),i=r(0),r=(a.prototype.maxColorCount=function(t){return this._opts.colorCount=t,this},a.prototype.maxDimension=function(t){return this._opts.maxDimension=t,this},a.prototype.addFilter=function(t){return this._opts.filters?this._opts.filters.push(t):this._opts.filters=[t],this},a.prototype.removeFilter=function(t){return this._opts.filters&&0<(t=this._opts.filters.indexOf(t))&&this._opts.filters.splice(t),this},a.prototype.clearFilters=function(){return this._opts.filters=[],this},a.prototype.quality=function(t){return this._opts.quality=t,this},a.prototype.useImageClass=function(t){return this._opts.ImageClass=t,this},a.prototype.useGenerator=function(t,e){return this._opts.generators||(this._opts.generators=[]),this._opts.generators.push(e?{name:t,options:e}:t),this},a.prototype.useQuantizer=function(t,e){return this._opts.quantizer=e?{name:t,options:e}:t,this},a.prototype.build=function(){return new o.default(this._src,this._opts)},a.prototype.getPalette=function(t){return this.build().getPalette(t)},a.prototype.getSwatches=function(t){return this.build().getPalette(t)},a);function a(t,e){void 0===e&&(e={}),this._src=t,this._opts=i.assignDeep({},o.default.DefaultOpts,e)}e.default=r},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),r=r(2);o(a,i=r.ImageBase),a.prototype._initCanvas=function(){var t=this.image,e=this._canvas=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new ReferenceError("Failed to create canvas context");this._context=r,e.className="@vibrant/canvas",e.style.display="none",this._width=e.width=t.width,this._height=e.height=t.height,r.drawImage(t,0,0),document.body.appendChild(e)},a.prototype.load=function(t){var n,o,e,r,i=this;if("string"==typeof t)n=document.createElement("img"),o=t,(r=new URL(o,location.href)).protocol===location.protocol&&r.host===location.host&&r.port===location.port||(e=window.location.href,r=o,e=new URL(e),r=new URL(r),e.protocol===r.protocol&&e.hostname===r.hostname&&e.port===r.port)||(n.crossOrigin="anonymous"),n.src=o;else{if(!(t instanceof HTMLImageElement))return Promise.reject(new Error("Cannot load buffer as an image in browser"));o=(n=t).src}return this.image=n,new Promise(function(t,e){function r(){i._initCanvas(),t(i)}n.complete?r():(n.onload=r,n.onerror=function(t){return e(new Error("Fail to load image: "+o))})})},a.prototype.clear=function(){this._context.clearRect(0,0,this._width,this._height)},a.prototype.update=function(t){this._context.putImageData(t,0,0)},a.prototype.getWidth=function(){return this._width},a.prototype.getHeight=function(){return this._height},a.prototype.resize=function(t,e,r){var n=this._canvas,o=this._context,i=this.image;this._width=n.width=t,this._height=n.height=e,o.scale(r,r),o.drawImage(i,0,0)},a.prototype.getPixelCount=function(){return this._width*this._height},a.prototype.getImageData=function(){return this._context.getImageData(0,0,this._width,this._height)},a.prototype.remove=function(){this._canvas&&this._canvas.parentNode&&this._canvas.parentNode.removeChild(this._canvas)};var i,o=a;function a(){return null!==i&&i.apply(this,arguments)||this}e.default=o},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(5),r=n(r(11));o.use(r.default),t.exports=o},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=(Object.defineProperty(e,"__esModule",{value:!0}),n(r(12))),n=n(r(16)),n=(new(r(17).BasicPipeline)).filter.register("default",function(t,e,r,n){return 125<=n&&!(250<t&&250<e&&250<r)}).quantizer.register("mmcq",o.default).generator.register("default",n.default);e.default=n},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},u=(Object.defineProperty(e,"__esModule",{value:!0}),r(3)),s=n(r(13)),l=n(r(15));function c(t,e){for(var r=t.size();t.size()<e;){if(!((n=t.pop())&&0<n.count()))break;var n=(o=n.split())[0],o=o[1];if(t.push(n),o&&0<o.count()&&t.push(o),t.size()===r)break;r=t.size()}}e.default=function(t,e){if(0===t.length||e.colorCount<2||256<e.colorCount)throw new Error("Wrong MMCQ parameters");for(var r=s.default.build(t),n=(r.histogram.colorCount,(t=new l.default(function(t,e){return t.count()-e.count()})).push(r),c(t,.75*e.colorCount),(r=new l.default(function(t,e){return t.count()*t.volume()-e.count()*e.volume()})).contents=t.contents,c(r,e.colorCount-r.size()),r),o=[];n.size();){var i=n.pop(),a=i.avg();a[0],a[1],a[2],o.push(new u.Swatch(a,i.count()))}return o}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=(Object.defineProperty(e,"__esModule",{value:!0}),n(r(14))),r=(i.build=function(t){return new i((t=new o.default(t,{sigBits:5})).rmin,t.rmax,t.gmin,t.gmax,t.bmin,t.bmax,t)},i.prototype.invalidate=function(){this._volume=this._count=-1,this._avg=null},i.prototype.volume=function(){var t,e,r,n,o,i;return this._volume<0&&(t=(i=this.dimension).r1,e=i.r2,r=i.g1,n=i.g2,o=i.b1,i=i.b2,this._volume=(e-t+1)*(n-r+1)*(i-o+1)),this._volume},i.prototype.count=function(){if(this._count<0){for(var t=(n=this.histogram).hist,e=n.getColorIndex,r=this.dimension,n=r.r1,o=r.r2,i=r.g1,a=r.g2,u=r.b1,s=r.b2,l=0,c=n;c<=o;c++)for(var h=i;h<=a;h++)for(var f=u;f<=s;f++)l+=t[e(c,h,f)];this._count=l}return this._count},i.prototype.clone=function(){var t=this.histogram,e=this.dimension;return new i(e.r1,e.r2,e.g1,e.g2,e.b1,e.b2,t)},i.prototype.avg=function(){if(!this._avg){for(var t=(n=this.histogram).hist,e=n.getColorIndex,r=this.dimension,n=r.r1,o=r.r2,i=r.g1,a=r.g2,u=r.b1,s=r.b2,l=0,c=void 0,h=void 0,f=void 0,c=h=f=0,p=n;p<=o;p++)for(var g=i;g<=a;g++)for(var d=u;d<=s;d++){var m=t[e(p,g,d)];l+=m,c+=m*(p+.5)*8,h+=m*(g+.5)*8,f+=m*(d+.5)*8}this._avg=l?[~~(c/l),~~(h/l),~~(f/l)]:[~~(8*(n+o+1)/2),~~(8*(i+a+1)/2),~~(8*(u+s+1)/2)]}return this._avg},i.prototype.contains=function(t){var e=t[0],r=t[1],n=t[2],o=(s=this.dimension).r1,i=s.r2,a=s.g1,u=s.g2,t=s.b1,s=s.b2;return r>>=3,n>>=3,o<=(e>>=3)&&e<=i&&a<=r&&r<=u&&t<=n&&n<=s},i.prototype.split=function(){var t=(c=this.histogram).hist,e=c.getColorIndex,r=(h=this.dimension).r1,n=h.r2,o=h.g1,i=h.g2,a=h.b1,u=h.b2;if(!(f=this.count()))return[];if(1===f)return[this.clone()];var s,l=n-r+1,c=i-o+1,h=u-a+1,f=Math.max(l,c,h),p=null,g=s=0,h=null;if(f===l){h="r";for(var p=new Uint32Array(n+1),d=r;d<=n;d++){for(var g=0,m=o;m<=i;m++)for(var b=a;b<=u;b++)g+=t[e(d,m,b)];s+=g,p[d]=s}}else if(f===c)for(h="g",p=new Uint32Array(i+1),m=o;m<=i;m++){for(g=0,d=r;d<=n;d++)for(b=a;b<=u;b++)g+=t[e(d,m,b)];s+=g,p[m]=s}else for(h="b",p=new Uint32Array(u+1),b=a;b<=u;b++){for(g=0,d=r;d<=n;d++)for(m=o;m<=i;m++)g+=t[e(d,m,b)];s+=g,p[b]=s}for(var _=-1,y=new Uint32Array(p.length),v=0;v<p.length;v++){var w=p[v];_<0&&s/2<w&&(_=v),y[v]=s-w}for(var l=this,M=void 0,f=h+"1",c=h+"2",h=l.dimension[f],x=l.dimension[c],D=l.clone(),L=l.clone(),P=_-h,x=P<=(M=x-_)?(x=Math.min(x-1,~~(_+M/2)),Math.max(0,x)):(x=Math.max(h,~~(_-1-P/2)),Math.min(l.dimension[c],x));!p[x];)x++;for(var T=y[x];!T&&p[x-1];)T=y[--x];return D.dimension[c]=x,L.dimension[f]=x+1,[D,L]},i);function i(t,e,r,n,o,i,a){this.histogram=a,this._volume=-1,this._count=-1,this.dimension={r1:t,r2:e,g1:r,g2:n,b1:o,b2:i}}e.default=r},function(t,e,r){"use strict";function n(t,e){function r(t,e,r){return(t<<2*n)+(e<<n)+r}this.pixels=t;var n=(this.opts=e).sigBits;this.getColorIndex=r;for(var o,i,a,u,s,l,c,h=8-n,f=new Uint32Array(1<<3*n),p=o=a=0,g=i=u=Number.MAX_VALUE,d=t.length/4,m=0;m<d;){var b=4*m;m++,s=t[0+b],l=t[1+b],c=t[2+b],0!==t[3+b]&&(f[r(s>>=h,l>>=h,c>>=h)]+=1,p<s&&(p=s),s<g&&(g=s),o<l&&(o=l),l<i&&(i=l),a<c&&(a=c),c<u)&&(u=c)}this._colorCount=f.reduce(function(t,e){return 0<e?t+1:t},0),this.hist=f,this.rmax=p,this.rmin=g,this.gmax=o,this.gmin=i,this.bmax=a,this.bmin=u}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(n.prototype,"colorCount",{get:function(){return this._colorCount},enumerable:!1,configurable:!0}),e.default=n},function(t,e,r){"use strict";function n(t){this._comparator=t,this.contents=[],this._sorted=!1}Object.defineProperty(e,"__esModule",{value:!0}),n.prototype._sort=function(){this._sorted||(this.contents.sort(this._comparator),this._sorted=!0)},n.prototype.push=function(t){this.contents.push(t),this._sorted=!1},n.prototype.peek=function(t){return this._sort(),t="number"==typeof t?t:this.contents.length-1,this.contents[t]},n.prototype.pop=function(){return this._sort(),this.contents.pop()},n.prototype.size=function(){return this.contents.length},n.prototype.map=function(t){return this._sort(),this.contents.map(t)},e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var p=r(3),g=r(4),d={targetDarkLuma:.26,maxDarkLuma:.45,minLightLuma:.55,targetLightLuma:.74,minNormalLuma:.3,targetNormalLuma:.5,maxNormalLuma:.7,targetMutesSaturation:.3,maxMutesSaturation:.4,targetVibrantSaturation:1,minVibrantSaturation:.35,weightSaturation:3,weightLuma:6.5,weightPopulation:.5};function m(c,t,h,f,p,g,d,m,b,_){var y=null,v=0;return t.forEach(function(t){var e,r,n,o,i,a,u=t.hsl,s=u[1],u=u[2];function l(t,e){return 1-Math.abs(t-e)}m<=s&&s<=b&&p<=u&&u<=g&&c.Vibrant!==(e=t)&&c.DarkVibrant!==e&&c.LightVibrant!==e&&c.Muted!==e&&c.DarkMuted!==e&&c.LightMuted!==e&&(r=u,n=f,o=t.population,i=h,a=_,u=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=0,o=0;o<t.length;o+=2){var i=t[o+1];r+=t[o]*i,n+=i}return r/n}(l(s,d),a.weightSaturation,l(r,n),a.weightLuma,o/i,a.weightPopulation),null===y||v<u)&&(y=t,v=u)}),y}e.default=function(t,e){e=Object.assign({},d,e);r=0,t.forEach(function(t){r=Math.max(r,t.population)});var r,n,o,i,a,u,s,l,c,h=r,h=((f={Vibrant:null,DarkVibrant:null,LightVibrant:null,Muted:null,DarkMuted:null,LightMuted:null}).Vibrant=m(f,n=t,t=h,(h=e).targetNormalLuma,h.minNormalLuma,h.maxNormalLuma,h.targetVibrantSaturation,h.minVibrantSaturation,1,h),f.LightVibrant=m(f,n,t,h.targetLightLuma,h.minLightLuma,1,h.targetVibrantSaturation,h.minVibrantSaturation,1,h),f.DarkVibrant=m(f,n,t,h.targetDarkLuma,0,h.maxDarkLuma,h.targetVibrantSaturation,h.minVibrantSaturation,1,h),f.Muted=m(f,n,t,h.targetNormalLuma,h.minNormalLuma,h.maxNormalLuma,h.targetMutesSaturation,0,h.maxMutesSaturation,h),f.LightMuted=m(f,n,t,h.targetLightLuma,h.minLightLuma,1,h.targetMutesSaturation,0,h.maxMutesSaturation,h),f.DarkMuted=m(f,n,t,h.targetDarkLuma,0,h.maxDarkLuma,h.targetMutesSaturation,0,h.maxMutesSaturation,h),f),f=e;return(e=h).Vibrant||e.DarkVibrant||e.LightVibrant||(!e.DarkVibrant&&e.DarkMuted&&(s=(c=e.DarkMuted.hsl)[0],l=c[1],c=c[2],c=f.targetDarkLuma,e.DarkVibrant=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.LightVibrant&&e.LightMuted&&(s=(o=e.LightMuted.hsl)[0],l=o[1],c=o[2],c=f.targetDarkLuma,e.DarkVibrant=new p.Swatch(g.hslToRgb(s,l,c),0))),!e.Vibrant&&e.DarkVibrant?(s=(o=e.DarkVibrant.hsl)[0],l=o[1],c=o[2],c=f.targetNormalLuma,e.Vibrant=new p.Swatch(g.hslToRgb(s,l,c),0)):!e.Vibrant&&e.LightVibrant&&(s=(i=e.LightVibrant.hsl)[0],l=i[1],c=i[2],c=f.targetNormalLuma,e.Vibrant=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.DarkVibrant&&e.Vibrant&&(s=(i=e.Vibrant.hsl)[0],l=i[1],c=i[2],c=f.targetDarkLuma,e.DarkVibrant=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.LightVibrant&&e.Vibrant&&(s=(a=e.Vibrant.hsl)[0],l=a[1],c=a[2],c=f.targetLightLuma,e.LightVibrant=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.Muted&&e.Vibrant&&(s=(a=e.Vibrant.hsl)[0],l=a[1],c=a[2],c=f.targetMutesSaturation,e.Muted=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.DarkMuted&&e.DarkVibrant&&(s=(u=e.DarkVibrant.hsl)[0],l=u[1],c=u[2],c=f.targetMutesSaturation,e.DarkMuted=new p.Swatch(g.hslToRgb(s,l,c),0)),!e.LightMuted&&e.LightVibrant&&(s=(u=e.LightVibrant.hsl)[0],l=u[1],c=u[2],c=f.targetMutesSaturation,e.LightMuted=new p.Swatch(g.hslToRgb(s,l,c),0)),h}},function(t,e,r){"use strict";var o=this&&this.__awaiter||function(t,a,u,s){return new(u=u||Promise)(function(r,e){function n(t){try{i(s.next(t))}catch(t){e(t)}}function o(t){try{i(s.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?r(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(n,o)}i((s=s.apply(t,a||[])).next())})},u=this&&this.__generator||function(n,o){var i,a,u,s={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(r){return function(t){var e=[r,t];if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,a&&(u=2&e[0]?a.return:e[0]?a.throw||((u=a.return)&&u.call(a),0):a.next)&&!(u=u.call(a,e[1])).done)return u;switch(a=0,(e=u?[2&e[0],u.value]:e)[0]){case 0:case 1:u=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,a=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(u=0<(u=s.trys).length&&u[u.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!u||e[1]>u[0]&&e[1]<u[3]))s.label=e[1];else if(6===e[0]&&s.label<u[1])s.label=u[1],u=e;else{if(!(u&&s.label<u[2])){u[2]&&s.ops.pop(),s.trys.pop();continue}s.label=u[2],s.ops.push(e)}}e=o.call(n,s)}catch(t){e=[6,t],a=0}finally{i=u=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.BasicPipeline=e.Stage=void 0,r(2)),i=(a.prototype.names=function(){return Object.keys(this._map)},a.prototype.has=function(t){return!!this._map[t]},a.prototype.get=function(t){return this._map[t]},a.prototype.register=function(t,e){return this._map[t]=e,this.pipeline},a);function a(t){this.pipeline=t,this._map={}}function s(){this.filter=new i(this),this.quantizer=new i(this),this.generator=new i(this)}e.Stage=i,s.prototype._buildProcessTasks=function(t){var e=this,r=t.filters,n=t.quantizer;return 1===(t=t.generators).length&&"*"===t[0]&&(t=this.generator.names()),{filters:r.map(function(t){return o(e.filter,t)}),quantizer:o(this.quantizer,n),generators:t.map(function(t){return o(e.generator,t)})};function o(t,e){var r,n;return"string"==typeof e?r=e:(r=e.name,n=e.options),{name:r,fn:t.get(r),options:n}}},s.prototype.process=function(i,a){return o(this,void 0,void 0,function(){var e,r,n,o;return u(this,function(t){switch(t.label){case 0:return o=this._buildProcessTasks(a),r=o.filters,e=o.quantizer,o=o.generators,[4,this._filterColors(r,i)];case 1:return r=t.sent(),[4,this._generateColors(e,r)];case 2:return n=t.sent(),[4,this._generatePalettes(o,n)];case 3:return o=t.sent(),[2,{colors:n,palettes:o}]}})})},s.prototype._filterColors=function(t,e){return Promise.resolve(n.applyFilters(e,t.map(function(t){return t.fn})))},s.prototype._generateColors=function(t,e){return Promise.resolve(t.fn(e.data,t.options))},s.prototype._generatePalettes=function(n,r){return o(this,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return[4,Promise.all(n.map(function(t){var e=t.fn,t=t.options;return Promise.resolve(e(r,t))}))];case 1:return e=t.sent(),[2,Promise.resolve(e.reduce(function(t,e,r){return t[n[r].name]=e,t},{}))]}})})},e.BasicPipeline=r=s}],o.c=n,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,(function(t){return e[t]}).bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=10);function o(t){var e;return(n[t]||(e=n[t]={i:t,l:!1,exports:{}},r[t].call(e.exports,e,e.exports,o),e.l=!0,e)).exports}var r,n});