vhv06 / Youtube Channel Colored Header

// ==UserScript==
// @name         Youtube Channel Colored Header
// @name:vi      Header của kênh YouTube Tự Đổi Màu
// @version      0.1.3
// @description  Colored header for channel based on its cover image.
// @description:vi  Đổi màu header dựa trên ảnh bìa của kênh.
// @author       vhv06
// @license      MIT
// @include      *://www.youtube.com/*
// @include      *://www.youtube.com/user/*
// @include      *://www.youtube.com/channel/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

// node-vibrant
/* The MIT License (MIT)
 *
 * Copyright (c) 2013-2015 Petka Antonov
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */
!function(n){var r={};function o(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=n,o.c=r,o.i=function(t){return t},o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},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=151)}([function(t,e,n){var r=n(33),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},function(t,e,n){var r=n(66),o=n(90);t.exports=function(t,e){var n=o(t,e);return r(n)?n:void 0}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var u=n(28),l=n(29);t.exports=function(t,e,n,r){var o=!n;n||(n={});for(var i=-1,s=e.length;++i<s;){var a=e[i],c=r?r(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),o?l(n,a,c):u(n,a,c)}return n}},function(t,e,n){var r=n(102),o=n(103),i=n(104),s=n(105),a=n(106);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,t.exports=c},function(t,e,n){var r=n(9);t.exports=function(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return-1}},function(t,e,n){var r=n(15),o=n(88),i=n(116),s=r?r.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?o(t):i(t)}},function(t,e,n){var r=n(100);t.exports=function(t,e){var n=t.__data__;return r(e)?n["string"==typeof e?"string":"hash"]:n.map}},function(t,e,n){var r=n(1)(Object,"create");t.exports=r},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=e(13);function n(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return null===e?null:[e[1],e[2],e[3]].map(function(t){return parseInt(t,16)})}function i(t,e,n){return e/=255,n/=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,n=.04045<n?Math.pow((n+.005)/1.055,2.4):n/12.92,[.4124*(t*=100)+.3576*(e*=100)+.1805*(n*=100),.2126*t+.7152*e+.0722*n,.0193*t+.1192*e+.9505*n]}function s(t,e,n){return e/=100,n/=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-(n=.008856<n?Math.pow(n,1/3):7.787*n+16/116))]}function a(t,e,n){var r=i(t,e,n);return s(r[0],r[1],r[2])}function c(t,e){var n=t[0],r=t[1],o=t[2],i=e[0],s=e[1],a=e[2],c=n-i,u=r-s,l=o-a,f=Math.sqrt(r*r+o*o),h=i-n,p=Math.sqrt(s*s+a*a)-f,_=Math.sqrt(c*c+u*u+l*l),d=Math.sqrt(_)>Math.sqrt(Math.abs(h))+Math.sqrt(Math.abs(p))?Math.sqrt(_*_-h*h-p*p):0;return h/=1,p/=1*(1+.045*f),d/=1*(1+.015*f),Math.sqrt(h*h+p*p+d*d)}function u(t,e){return c(a.apply(void 0,t),a.apply(void 0,e))}r.DELTAE94_DIFF_STATUS={NA:0,PERFECT:1,CLOSE:2,GOOD:10,SIMILAR:50},r.SIGBITS=5,r.RSHIFT=8-r.SIGBITS,r.defer=function(){var n,r,t=new o(function(t,e){n=t,r=e});return{resolve:n,reject:r,promise:t}},r.hexToRgb=n,r.rgbToHex=function(t,e,n){return"#"+((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1,7)},r.rgbToHsl=function(t,e,n){t/=255,e/=255,n/=255;var r,o,i=Math.max(t,e,n),s=Math.min(t,e,n),a=(i+s)/2;if(i===s)r=o=0;else{var c=i-s;switch(o=.5<a?c/(2-i-s):c/(i+s),i){case t:r=(e-n)/c+(e<n?6:0);break;case e:r=(n-t)/c+2;break;case n:r=(t-e)/c+4}r/=6}return[r,o,a]},r.hslToRgb=function(t,e,n){var r,o,i;function s(t,e,n){return n<0&&(n+=1),1<n&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(0===e)r=o=i=n;else{var a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;r=s(c,a,t+1/3),o=s(c,a,t),i=s(c,a,t-1/3)}return[255*r,255*o,255*i]},r.rgbToXyz=i,r.xyzToCIELab=s,r.rgbToCIELab=a,r.deltaE94=c,r.rgbDiff=u,r.hexDiff=function(t,e){return u(n(t),n(e))},r.getColorDiffStatus=function(t){return t<r.DELTAE94_DIFF_STATUS.NA?"N/A":t<=r.DELTAE94_DIFF_STATUS.PERFECT?"Perfect":t<=r.DELTAE94_DIFF_STATUS.CLOSE?"Close":t<=r.DELTAE94_DIFF_STATUS.GOOD?"Good":t<r.DELTAE94_DIFF_STATUS.SIMILAR?"Similar":"Wrong"},r.getColorIndex=function(t,e,n){return(t<<2*r.SIGBITS)+(e<<r.SIGBITS)+n}},function(Sc,Tc){var Uc;Uc=function(){return this}();try{Uc=Uc||Function("return this")()||eval("this")}catch(t){"object"==typeof window&&(Uc=window)}Sc.exports=Uc},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(e,t,n){(function(Y,q,u){var t;t=function(){var t,e,n;return function i(s,a,c){function u(n,t){if(!a[n]){if(!s[n]){var e="function"==typeof _dereq_&&_dereq_;if(!t&&e)return e(n,!0);if(l)return l(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var o=a[n]={exports:{}};s[n][0].call(o.exports,function(t){var e=s[n][1][t];return u(e||t)},o,o.exports,i,s,a,c)}return a[n].exports}for(var l="function"==typeof _dereq_&&_dereq_,t=0;t<c.length;t++)u(c[t]);return u}({1:[function(t,e,n){"use strict";e.exports=function(t){var r=t._SomePromiseArray;function e(t){var e=new r(t),n=e.promise();return e.setHowMany(1),e.setUnwrap(),e.init(),n}t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},{}],2:[function(t,e,n){"use strict";var r;try{throw new Error}catch(t){r=t}var o=t("./schedule"),i=t("./queue"),s=t("./util");function a(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new i(16),this._normalQueue=new i(16),this._haveDrainedQueues=!1,this._trampolineEnabled=!0;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=o}function c(t,e,n){this._lateQueue.push(t,e,n),this._queueTick()}function u(t,e,n){this._normalQueue.push(t,e,n),this._queueTick()}function l(t){this._normalQueue._pushOne(t),this._queueTick()}a.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},a.prototype.hasCustomScheduler=function(){return this._customScheduler},a.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},a.prototype.disableTrampolineIfNecessary=function(){s.hasDevTools&&(this._trampolineEnabled=!1)},a.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},a.prototype.fatalError=function(t,e){e?(Y.stderr.write("Fatal "+(t instanceof Error?t.stack:t)+"\n"),Y.exit(2)):this.throwLater(t)},a.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n    See http://goo.gl/MqrFmX\n")}},s.hasDevTools?(a.prototype.invokeLater=function(t,e,n){this._trampolineEnabled?c.call(this,t,e,n):this._schedule(function(){setTimeout(function(){t.call(e,n)},100)})},a.prototype.invoke=function(t,e,n){this._trampolineEnabled?u.call(this,t,e,n):this._schedule(function(){t.call(e,n)})},a.prototype.settlePromises=function(t){this._trampolineEnabled?l.call(this,t):this._schedule(function(){t._settlePromises()})}):(a.prototype.invokeLater=c,a.prototype.invoke=u,a.prototype.settlePromises=l),a.prototype._drainQueue=function(t){for(;0<t.length();){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},a.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},a.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},a.prototype._reset=function(){this._isTickUsed=!1},e.exports=a,e.exports.firstLineError=r},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(i,s,a,c){var u=!1,n=function(t,e){this._reject(e)},l=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},f=function(t,e){0==(50397184&this._bitField)&&this._resolveCallback(e.target)},h=function(t,e){e.promiseRejectionQueued||this._reject(t)};i.prototype.bind=function(t){u||(u=!0,i.prototype._propagateFrom=c.propagateFromFunction(),i.prototype._boundValue=c.boundValueFunction());var e=a(t),n=new i(s);n._propagateFrom(this,1);var r=this._target();if(n._setBoundTo(e),e instanceof i){var o={promiseRejectionQueued:!1,promise:n,target:r,bindingPromise:e};r._then(s,l,void 0,n,o),e._then(f,h,void 0,n,o),n._setOnCancel(e)}else n._resolveCallback(r);return n},i.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},i.prototype._isBound=function(){return 2097152==(2097152&this._bitField)},i.bind=function(t,e){return i.resolve(e).bind(t)}}},{}],4:[function(t,e,n){"use strict";var r;"undefined"!=typeof Promise&&(r=Promise);var o=t("./promise")();o.noConflict=function(){try{Promise===o&&(Promise=r)}catch(t){}return o},e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var o=r(null),i=r(null);o[" size"]=i[" size"]=0}e.exports=function(o){var r,i=t("./util"),s=i.canEvaluate;i.isIdentifier;function e(t,e){var n;if(null!=t&&(n=t[e]),"function"!=typeof n){var r="Object "+i.classString(t)+" has no method '"+i.toString(e)+"'";throw new o.TypeError(r)}return n}function n(t){return e(t,this.pop()).apply(t,this)}function a(t){return t[this]}function c(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}o.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(n,void 0,void 0,e,void 0)},o.prototype.get=function(t){var e;if("number"==typeof t)e=c;else if(s){var n=r(t);e=null!==n?n:a}else e=a;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(c,t,e){"use strict";t.exports=function(t,e,n,r){var o=c("./util"),i=o.tryCatch,s=o.errorObj,a=t._async;t.prototype.break=t.prototype.cancel=function(){if(!r.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},t.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},t.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},t.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},t.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},t.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),a.invoke(this._cancelPromises,this,void 0))},t.prototype._cancelPromises=function(){0<this._length()&&this._settlePromises()},t.prototype._unsetOnCancel=function(){this._onCancelField=void 0},t.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},t.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},t.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n<t.length;++n)this._doInvokeOnCancel(t[n],e);else if(void 0!==t)if("function"==typeof t){if(!e){var r=i(t).call(this._boundValue());r===s&&(this._attachExtraTrace(r.e),a.throwLater(r.e))}}else t._resultCancelled(this)},t.prototype._invokeOnCancel=function(){var t=this._onCancel();this._unsetOnCancel(),a.invoke(this._doInvokeOnCancel,this,t)},t.prototype._invokeInternalOnCancel=function(){this._isCancellable()&&(this._doInvokeOnCancel(this._onCancel(),!0),this._unsetOnCancel())},t.prototype._resultCancelled=function(){this.cancel()}}},{"./util":36}],7:[function(t,e,n){"use strict";e.exports=function(f){var h=t("./util"),p=t("./es5").keys,_=h.tryCatch,d=h.errorObj;return function(c,u,l){return function(t){var e=l._boundValue();t:for(var n=0;n<c.length;++n){var r=c[n];if(r===Error||null!=r&&r.prototype instanceof Error){if(t instanceof r)return _(u).call(e,t)}else if("function"==typeof r){var o=_(r).call(e,t);if(o===d)return o;if(o)return _(u).call(e,t)}else if(h.isObject(t)){for(var i=p(r),s=0;s<i.length;++s){var a=i[s];if(r[a]!=t[a])continue t}return _(u).call(e,t)}}return f}}}},{"./es5":13,"./util":36}],8:[function(t,e,n){"use strict";e.exports=function(i){var s=!1,n=[];function a(){this._trace=new a.CapturedTrace(c())}function c(){var t=n.length-1;if(0<=t)return n[t]}return i.prototype._promiseCreated=function(){},i.prototype._pushContext=function(){},i.prototype._popContext=function(){return null},i._peekContext=i.prototype._peekContext=function(){},a.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,n.push(this._trace))},a.prototype._popContext=function(){if(void 0!==this._trace){var t=n.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},a.CapturedTrace=null,a.create=function(){if(s)return new a},a.deactivateLongStackTraces=function(){},a.activateLongStackTraces=function(){var t=i.prototype._pushContext,e=i.prototype._popContext,n=i._peekContext,r=i.prototype._peekContext,o=i.prototype._promiseCreated;a.deactivateLongStackTraces=function(){i.prototype._pushContext=t,i.prototype._popContext=e,i._peekContext=n,i.prototype._peekContext=r,i.prototype._promiseCreated=o,s=!1},s=!0,i.prototype._pushContext=a.prototype._pushContext,i.prototype._popContext=a.prototype._popContext,i._peekContext=i.prototype._peekContext=c,i.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},a}},{}],9:[function(K,t,e){"use strict";t.exports=function(s,n){var r,o,i,a=s._getDomain,c=s._async,u=K("./errors").Warning,l=K("./util"),f=l.canAttachTrace,h=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,_=/\((?:timers\.js):\d+:\d+\)/,d=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,p=null,v=null,y=!1,t=!(0==l.env("BLUEBIRD_DEBUG")),e=!(0==l.env("BLUEBIRD_WARNINGS")||!t&&!l.env("BLUEBIRD_WARNINGS")),m=!(0==l.env("BLUEBIRD_LONG_STACK_TRACES")||!t&&!l.env("BLUEBIRD_LONG_STACK_TRACES")),g=0!=l.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(e||!!l.env("BLUEBIRD_W_FORGOTTEN_RETURN"));s.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},s.prototype._ensurePossibleRejectionHandled=function(){0==(524288&this._bitField)&&(this._setRejectionIsUnhandled(),c.invokeLater(this._notifyUnhandledRejection,this,void 0))},s.prototype._notifyUnhandledRejectionIsHandled=function(){H("rejectionHandled",r,void 0,this)},s.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},s.prototype._returnedNonUndefined=function(){return 0!=(268435456&this._bitField)},s.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),H("unhandledRejection",o,t,this)}},s.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},s.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},s.prototype._isUnhandledRejectionNotified=function(){return 0<(262144&this._bitField)},s.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},s.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},s.prototype._isRejectionUnhandled=function(){return 0<(1048576&this._bitField)},s.prototype._warn=function(t,e,n){return L(t,e,n||this)},s.onPossiblyUnhandledRejection=function(t){var e=a();o="function"==typeof t?null===e?t:l.domainBind(e,t):void 0},s.onUnhandledRejectionHandled=function(t){var e=a();r="function"==typeof t?null===e?t:l.domainBind(e,t):void 0};var b=function(){};s.longStackTraces=function(){if(c.haveItemsQueued()&&!X.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n    See http://goo.gl/MqrFmX\n");if(!X.longStackTraces&&B()){var t=s.prototype._captureStackTrace,e=s.prototype._attachExtraTrace;X.longStackTraces=!0,b=function(){if(c.haveItemsQueued()&&!X.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n    See http://goo.gl/MqrFmX\n");s.prototype._captureStackTrace=t,s.prototype._attachExtraTrace=e,n.deactivateLongStackTraces(),c.enableTrampoline(),X.longStackTraces=!1},s.prototype._captureStackTrace=D,s.prototype._attachExtraTrace=M,n.activateLongStackTraces(),c.disableTrampolineIfNecessary()}},s.hasLongStackTraces=function(){return X.longStackTraces&&B()};var w=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return l.global.dispatchEvent(t),function(t,e){var n=new CustomEvent(t.toLowerCase(),{detail:e,cancelable:!0});return!l.global.dispatchEvent(n)}}if("function"==typeof Event){t=new Event("CustomEvent");return l.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,!l.global.dispatchEvent(n)}}return(t=document.createEvent("CustomEvent")).initCustomEvent("testingtheevent",!1,!0,{}),l.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!l.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),j=l.isNode?function(){return Y.emit.apply(Y,arguments)}:l.global?function(t){var e="on"+t.toLowerCase(),n=l.global[e];return!!n&&(n.apply(l.global,[].slice.call(arguments,1)),!0)}:function(){return!1};function x(t,e){return{promise:e}}var C={promiseCreated:x,promiseFulfilled:x,promiseRejected:x,promiseResolved:x,promiseCancelled:x,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:x},E=function(t){var e=!1;try{e=j.apply(null,arguments)}catch(t){c.throwLater(t),e=!0}var n=!1;try{n=w(t,C[t].apply(null,arguments))}catch(t){c.throwLater(t),n=!0}return n||e};function k(){return!1}function F(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+l.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function T(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?l.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function O(){return this._onCancelField}function S(t){this._onCancelField=t}function A(){this._cancellationParent=void 0,this._onCancelField=void 0}function P(t,e){if(0!=(1&e)){var n=(this._cancellationParent=t)._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}s.config=function(t){if("longStackTraces"in(t=Object(t))&&(t.longStackTraces?s.longStackTraces():!t.longStackTraces&&s.hasLongStackTraces()&&b()),"warnings"in t){var e=t.warnings;X.warnings=!!e,g=X.warnings,l.isObject(e)&&"wForgottenReturn"in e&&(g=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!X.cancellation){if(c.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");s.prototype._clearCancellationData=A,s.prototype._propagateFrom=P,s.prototype._onCancel=O,s.prototype._setOnCancel=S,s.prototype._attachCancellationCallback=T,s.prototype._execute=F,R=P,X.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!X.monitoring?(X.monitoring=!0,s.prototype._fireEvent=E):!t.monitoring&&X.monitoring&&(X.monitoring=!1,s.prototype._fireEvent=k)),s},s.prototype._fireEvent=k,s.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},s.prototype._onCancel=function(){},s.prototype._setOnCancel=function(t){},s.prototype._attachCancellationCallback=function(t){},s.prototype._captureStackTrace=function(){},s.prototype._attachExtraTrace=function(){},s.prototype._clearCancellationData=function(){},s.prototype._propagateFrom=function(t,e){};var R=function(t,e){0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)};function I(){var t=this._boundTo;return void 0!==t&&t instanceof s?t.isFulfilled()?t.value():void 0:t}function D(){this._trace=new G(this._peekContext())}function M(t,e){if(f(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=V(t);l.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),l.notEnumerableProp(t,"__stackCleaned__",!0)}}}function L(t,e,n){if(X.warnings){var r,o=new u(t);if(e)n._attachExtraTrace(o);else if(X.longStackTraces&&(r=s._peekContext()))r.attachExtraTrace(o);else{var i=V(o);o.stack=i.message+"\n"+i.stack.join("\n")}E("warning",o)||N(o,"",!0)}}function U(t){for(var e=[],n=0;n<t.length;++n){var r=t[n],o="    (No stack trace)"===r||p.test(r),i=o&&z(r);o&&!i&&(y&&" "!==r.charAt(0)&&(r="    "+r),e.push(r))}return e}function V(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&0<e.length?function(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n<e.length;++n){var r=e[n];if("    (No stack trace)"===r||p.test(r))break}return 0<n&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}(t):["    (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:U(e)}}function N(t,e,n){if("undefined"!=typeof console){var r;if(l.isObject(t)){var o=t.stack;r=e+v(o,t)}else r=e+String(t);"function"==typeof i?i(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function H(t,e,n,r){var o=!1;try{"function"==typeof e&&(o=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){c.throwLater(t)}"unhandledRejection"===t?E(t,n,r)||o||N(n,"Unhandled rejection "):E(t,r)}function q(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():l.toString(t);if(/\[object [a-zA-Z0-9$_]+\]/.test(e))try{e=JSON.stringify(t)}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+function(t){if(t.length<41)return t;return t.substr(0,38)+"..."}(e)+">, no stack trace)"}function B(){return"function"==typeof W}var z=function(){return!1},$=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function Q(t){var e=t.match($);if(e)return{fileName:e[1],line:parseInt(e[2],10)}}function G(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);W(this,G),32<e&&this.uncycle()}l.inherits(G,Error),(n.CapturedTrace=G).prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,o=this;void 0!==o;++r)e.push(o),o=o._parent;for(r=(t=this._length=r)-1;0<=r;--r){var i=e[r].stack;void 0===n[i]&&(n[i]=r)}for(r=0;r<t;++r){var s=n[e[r].stack];if(void 0!==s&&s!==r){0<s&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var a=0<r?e[r-1]:this;s<t-1?(a._parent=e[s+1],a._parent.uncycle(),a._length=a._parent._length+1):(a._parent=void 0,a._length=1);for(var c=a._length+1,u=r-2;0<=u;--u)e[u]._length=c,c++;return}}}},G.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=V(t),n=e.message,r=[e.stack],o=this;void 0!==o;)r.push(U(o.stack.split("\n"))),o=o._parent;!function(t){for(var e=t[0],n=1;n<t.length;++n){for(var r=t[n],o=e.length-1,i=e[o],s=-1,a=r.length-1;0<=a;--a)if(r[a]===i){s=a;break}for(a=s;0<=a;--a){var c=r[a];if(e[o]!==c)break;e.pop(),o--}e=r}}(r),function(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}(r),l.notEnumerableProp(t,"stack",function(t,e){for(var n=0;n<e.length-1;++n)e[n].push("From previous event:"),e[n]=e[n].join("\n");return n<e.length&&(e[n]=e[n].join("\n")),t+"\n"+e.join("\n")}(n,r)),l.notEnumerableProp(t,"__stackCleaned__",!0)}};var W=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():q(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,p=t,v=e;var n=Error.captureStackTrace;return z=function(t){return h.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r,o=new Error;if("string"==typeof o.stack&&0<=o.stack.split("\n")[0].indexOf("stackDetection@"))return p=/@/,v=e,y=!0,function(t){t.stack=(new Error).stack};try{throw new Error}catch(t){r="stack"in t}return"stack"in o||!r||"number"!=typeof Error.stackTraceLimit?(v=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?q(e):e.toString()},null):(p=t,v=e,function(e){Error.stackTraceLimit+=6;try{throw new Error}catch(t){e.stack=t.stack}Error.stackTraceLimit-=6})}();"undefined"!=typeof console&&void 0!==console.warn&&(i=function(t){console.warn(t)},l.isNode&&Y.stderr.isTTY?i=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:l.isNode||"string"!=typeof(new Error).stack||(i=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var X={warnings:e,longStackTraces:!1,cancellation:!1,monitoring:!1};return m&&s.longStackTraces(),{longStackTraces:function(){return X.longStackTraces},warnings:function(){return X.warnings},cancellation:function(){return X.cancellation},monitoring:function(){return X.monitoring},propagateFromFunction:function(){return R},boundValueFunction:function(){return I},checkForgottenReturns:function(t,e,n,r,o){if(void 0===t&&null!==e&&g){if(void 0!==o&&o._returnedNonUndefined())return;if(0==(65535&r._bitField))return;n&&(n+=" ");var i="",s="";if(e._trace){for(var a=e._trace.stack.split("\n"),c=U(a),u=c.length-1;0<=u;--u){var l=c[u];if(!_.test(l)){var f=l.match(d);f&&(i="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(0<c.length){var h=c[0];for(u=0;u<a.length;++u)if(a[u]===h){0<u&&(s="\n"+a[u-1]);break}}}var p="a promise was created in a "+n+"handler "+i+"but was not returned from it, see http://goo.gl/rRqMUw"+s;r._warn(p,!0,e)}},setBounds:function(t,e){if(B()){for(var n,r,o=t.stack.split("\n"),i=e.stack.split("\n"),s=-1,a=-1,c=0;c<o.length;++c)if(u=Q(o[c])){n=u.fileName,s=u.line;break}for(c=0;c<i.length;++c){var u;if(u=Q(i[c])){r=u.fileName,a=u.line;break}}s<0||a<0||!n||!r||n!==r||a<=s||(z=function(t){if(h.test(t))return!0;var e=Q(t);return!!(e&&e.fileName===n&&s<=e.line&&e.line<=a)})}},warn:L,deprecated:function(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),L(n)},CapturedTrace:G,fireDomEvent:w,fireGlobalEvent:j}}},{"./errors":12,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(n){function r(){return this.value}function o(){throw this.reason}n.prototype.return=n.prototype.thenReturn=function(t){return t instanceof n&&t.suppressUnhandledRejections(),this._then(r,void 0,void 0,{value:t},void 0)},n.prototype.throw=n.prototype.thenThrow=function(t){return this._then(o,void 0,void 0,{reason:t},void 0)},n.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,o,void 0,{reason:t},void 0);var e=arguments[1];return this.caught(t,function(){throw e})},n.prototype.catchReturn=function(t){if(arguments.length<=1)return t instanceof n&&t.suppressUnhandledRejections(),this._then(void 0,r,void 0,{value:t},void 0);var e=arguments[1];e instanceof n&&e.suppressUnhandledRejections();return this.caught(t,function(){return e})}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,n){var r=t.reduce,e=t.all;function o(){return e(this)}t.prototype.each=function(t){return r(this,t,n,0)._then(o,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return r(this,t,n,n)},t.each=function(t,e){return r(t,e,n,0)._then(o,void 0,void 0,t,void 0)},t.mapSeries=function(t,e){return r(t,e,n,n)}}},{}],12:[function(t,e,n){"use strict";var r,o,i=t("./es5"),s=i.freeze,a=t("./util"),c=a.inherits,u=a.notEnumerableProp;function l(e,n){function r(t){if(!(this instanceof r))return new r(t);u(this,"message","string"==typeof t?t:n),u(this,"name",e),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return c(r,Error),r}var f=l("Warning","warning"),h=l("CancellationError","cancellation error"),p=l("TimeoutError","timeout error"),_=l("AggregateError","aggregate error");try{r=TypeError,o=RangeError}catch(t){r=l("TypeError","type error"),o=l("RangeError","range error")}for(var d="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),v=0;v<d.length;++v)"function"==typeof Array.prototype[d[v]]&&(_.prototype[d[v]]=Array.prototype[d[v]]);i.defineProperty(_.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),_.prototype.isOperational=!0;var y=0;function m(t){if(!(this instanceof m))return new m(t);u(this,"name","OperationalError"),u(this,"message",t),this.cause=t,this.isOperational=!0,t instanceof Error?(u(this,"message",t.message),u(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}_.prototype.toString=function(){var t=Array(4*y+1).join(" "),e="\n"+t+"AggregateError of:\n";y++,t=Array(4*y+1).join(" ");for(var n=0;n<this.length;++n){for(var r=this[n]===this?"[Circular AggregateError]":this[n]+"",o=r.split("\n"),i=0;i<o.length;++i)o[i]=t+o[i];e+=(r=o.join("\n"))+"\n"}return y--,e},c(m,Error);var g=Error.__BluebirdErrorTypes__;g||(g=s({CancellationError:h,TimeoutError:p,OperationalError:m,RejectionError:m,AggregateError:_}),i.defineProperty(Error,"__BluebirdErrorTypes__",{value:g,writable:!1,enumerable:!1,configurable:!1})),e.exports={Error:Error,TypeError:r,RangeError:o,CancellationError:g.CancellationError,OperationalError:g.OperationalError,TimeoutError:g.TimeoutError,AggregateError:g.AggregateError,Warning:f}},{"./es5":13,"./util":36}],13:[function(t,e,n){var r=function(){"use strict";return void 0===this}();if(r)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(t,e){var n=Object.getOwnPropertyDescriptor(t,e);return!(n&&!n.writable&&!n.set)}};else{var o={}.hasOwnProperty,i={}.toString,s={}.constructor.prototype,a=function(t){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};e.exports={isArray:function(t){try{return"[object Array]"===i.call(t)}catch(t){return!1}},keys:a,names:a,defineProperty:function(t,e,n){return t[e]=n.value,t},getDescriptor:function(t,e){return{value:t[e]}},freeze:function(t){return t},getPrototypeOf:function(t){try{return Object(t).constructor.prototype}catch(t){return s}},isES5:r,propertyIsWritable:function(){return!0}}}},{}],14:[function(t,e,n){"use strict";e.exports=function(t,r){var o=t.map;t.prototype.filter=function(t,e){return o(this,t,e,r)},t.filter=function(t,e,n){return o(t,e,n,r)}}},{}],15:[function(n,t,e){"use strict";t.exports=function(s,a){var t=n("./util"),c=s.CancellationError,u=t.errorObj;function o(t,e,n){this.promise=t,this.type=e,this.handler=n,this.called=!1,this.cancelPromise=null}function l(t){this.finallyHandler=t}function f(t,e){return null!=t.cancelPromise&&(1<arguments.length?t.cancelPromise._reject(e):t.cancelPromise._cancel(),!(t.cancelPromise=null))}function h(){return e.call(this,this.promise._target()._settledValue())}function p(t){if(!f(this,t))return u.e=t,u}function e(t){var e=this.promise,n=this.handler;if(!this.called){this.called=!0;var r=this.isFinallyHandler()?n.call(e._boundValue()):n.call(e._boundValue(),t);if(void 0!==r){e._setReturnedNonUndefined();var o=a(r,e);if(o instanceof s){if(null!=this.cancelPromise){if(o._isCancelled()){var i=new c("late cancellation observer");return e._attachExtraTrace(i),u.e=i,u}o.isPending()&&o._attachCancellationCallback(new l(this))}return o._then(h,p,void 0,this,void 0)}}}return e.isRejected()?(f(this),u.e=t,u):(f(this),t)}return o.prototype.isFinallyHandler=function(){return 0===this.type},l.prototype._resultCancelled=function(){f(this.finallyHandler)},s.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new o(this,e,t),void 0)},s.prototype.lastly=s.prototype.finally=function(t){return this._passThrough(t,0,e,e)},s.prototype.tap=function(t){return this._passThrough(t,1,e)},o}},{"./util":36}],16:[function(n,t,e){"use strict";t.exports=function(a,r,s,c,t,u){var l=n("./errors").TypeError,e=n("./util"),f=e.errorObj,h=e.tryCatch,p=[];function _(t,e,n,r){if(u.cancellation()){var o=new a(s),i=this._finallyPromise=new a(s);this._promise=o.lastly(function(){return i}),o._captureStackTrace(),o._setOnCancel(this)}else{(this._promise=new a(s))._captureStackTrace()}this._stack=r,this._generatorFunction=t,this._receiver=e,this._generator=void 0,this._yieldHandlers="function"==typeof n?[n].concat(p):p,this._yieldedPromise=null,this._cancellationPhase=!1}e.inherits(_,t),_.prototype._isResolved=function(){return null===this._promise},_.prototype._cleanup=function(){this._promise=this._generator=null,u.cancellation()&&null!==this._finallyPromise&&(this._finallyPromise._fulfill(),this._finallyPromise=null)},_.prototype._promiseCancelled=function(){if(!this._isResolved()){var t;if(void 0!==this._generator.return)this._promise._pushContext(),t=h(this._generator.return).call(this._generator,void 0),this._promise._popContext();else{var e=new a.CancellationError("generator .return() sentinel");a.coroutine.returnSentinel=e,this._promise._attachExtraTrace(e),this._promise._pushContext(),t=h(this._generator.throw).call(this._generator,e),this._promise._popContext()}this._cancellationPhase=!0,this._yieldedPromise=null,this._continue(t)}},_.prototype._promiseFulfilled=function(t){this._yieldedPromise=null,this._promise._pushContext();var e=h(this._generator.next).call(this._generator,t);this._promise._popContext(),this._continue(e)},_.prototype._promiseRejected=function(t){this._yieldedPromise=null,this._promise._attachExtraTrace(t),this._promise._pushContext();var e=h(this._generator.throw).call(this._generator,t);this._promise._popContext(),this._continue(e)},_.prototype._resultCancelled=function(){if(this._yieldedPromise instanceof a){var t=this._yieldedPromise;this._yieldedPromise=null,t.cancel()}},_.prototype.promise=function(){return this._promise},_.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._promiseFulfilled(void 0)},_.prototype._continue=function(t){var e=this._promise;if(t===f)return this._cleanup(),this._cancellationPhase?e.cancel():e._rejectCallback(t.e,!1);var n=t.value;if(!0===t.done)return this._cleanup(),this._cancellationPhase?e.cancel():e._resolveCallback(n);var r=c(n,this._promise);if(r instanceof a||null!==(r=function(t,e,n){for(var r=0;r<e.length;++r){n._pushContext();var o=h(e[r])(t);if(n._popContext(),o===f){n._pushContext();var i=a.reject(f.e);return n._popContext(),i}var s=c(o,n);if(s instanceof a)return s}return null}(r,this._yieldHandlers,this._promise))){var o=(r=r._target())._bitField;0==(50397184&o)?(this._yieldedPromise=r)._proxy(this,null):0!=(33554432&o)?a._async.invoke(this._promiseFulfilled,this,r._value()):0!=(16777216&o)?a._async.invoke(this._promiseRejected,this,r._reason()):this._promiseCancelled()}else this._promiseRejected(new l("A value %s was yielded that could not be treated as a promise\n\n    See http://goo.gl/MqrFmX\n\n".replace("%s",n)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")))},a.coroutine=function(r,t){if("function"!=typeof r)throw new l("generatorFunction must be a function\n\n    See http://goo.gl/MqrFmX\n");var o=Object(t).yieldHandler,i=_,s=(new Error).stack;return function(){var t=r.apply(this,arguments),e=new i(void 0,void 0,o,s),n=e.promise();return e._generator=t,e._promiseFulfilled(void 0),n}},a.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new l("expecting a function but got "+e.classString(t));p.push(t)},a.spawn=function(t){if(u.deprecated("Promise.spawn()","Promise.coroutine()"),"function"!=typeof t)return r("generatorFunction must be a function\n\n    See http://goo.gl/MqrFmX\n");var e=new _(t,this),n=e.promise();return e._run(a.spawn),n}}},{"./errors":12,"./util":36}],17:[function(a,t,e){"use strict";t.exports=function(t,o,e,n,r,i){var s=a("./util");s.canEvaluate,s.tryCatch,s.errorObj;t.join=function(){var t,e=arguments.length-1;0<e&&"function"==typeof arguments[e]&&(t=arguments[e]);var n=[].slice.call(arguments);t&&n.pop();var r=new o(n).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(e,t,n){"use strict";t.exports=function(p,t,i,_,s,d){var a=p._getDomain,c=e("./util"),v=c.tryCatch,y=c.errorObj,u=p._async;function l(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var o=a();this._callback=null===o?e:c.domainBind(o,e),this._preservedValues=r===s?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=[],u.invoke(this._asyncInit,this,void 0)}function o(t,e,n,r){if("function"!=typeof e)return i("expecting a function but got "+c.classString(e));var o=0;if(void 0!==n){if("object"!=typeof n||null===n)return p.reject(new TypeError("options argument must be an object but it is "+c.classString(n)));if("number"!=typeof n.concurrency)return p.reject(new TypeError("'concurrency' must be a number but it is "+c.classString(n.concurrency)));o=n.concurrency}return new l(t,e,o="number"==typeof o&&isFinite(o)&&1<=o?o:0,r).promise()}c.inherits(l,t),l.prototype._asyncInit=function(){this._init$(void 0,-2)},l.prototype._init=function(){},l.prototype._promiseFulfilled=function(t,e){var n=this._values,r=this.length(),o=this._preservedValues,i=this._limit;if(e<0){if(n[e=-1*e-1]=t,1<=i&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(1<=i&&this._inFlight>=i)return n[e]=t,this._queue.push(e),!1;null!==o&&(o[e]=t);var s=this._promise,a=this._callback,c=s._boundValue();s._pushContext();var u=v(a).call(c,t,e,r),l=s._popContext();if(d.checkForgottenReturns(u,l,null!==o?"Promise.filter":"Promise.map",s),u===y)return this._reject(u.e),!0;var f=_(u,this._promise);if(f instanceof p){var h=(f=f._target())._bitField;if(0==(50397184&h))return 1<=i&&this._inFlight++,(n[e]=f)._proxy(this,-1*(e+1)),!1;if(0==(33554432&h))return 0!=(16777216&h)?this._reject(f._reason()):this._cancel(),!0;u=f._value()}n[e]=u}return r<=++this._totalResolved&&(null!==o?this._filter(n,o):this._resolve(n),!0)},l.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;0<t.length&&this._inFlight<e;){if(this._isResolved())return;var r=t.pop();this._promiseFulfilled(n[r],r)}},l.prototype._filter=function(t,e){for(var n=e.length,r=new Array(n),o=0,i=0;i<n;++i)t[i]&&(r[o++]=e[i]);r.length=o,this._resolve(r)},l.prototype.preservedValues=function(){return this._preservedValues},p.prototype.map=function(t,e){return o(this,t,e,null)},p.map=function(t,e,n,r){return o(t,e,n,r)}}},{"./util":36}],19:[function(e,t,n){"use strict";t.exports=function(s,a,t,c,u){var l=e("./util"),f=l.tryCatch;s.method=function(r){if("function"!=typeof r)throw new s.TypeError("expecting a function but got "+l.classString(r));return function(){var t=new s(a);t._captureStackTrace(),t._pushContext();var e=f(r).apply(this,arguments),n=t._popContext();return u.checkForgottenReturns(e,n,"Promise.method",t),t._resolveFromSyncValue(e),t}},s.attempt=s.try=function(t){if("function"!=typeof t)return c("expecting a function but got "+l.classString(t));var e,n=new s(a);if(n._captureStackTrace(),n._pushContext(),1<arguments.length){u.deprecated("calling Promise.try with more than 1 argument");var r=arguments[1],o=arguments[2];e=l.isArray(r)?f(t).apply(o,r):f(t).call(o,r)}else e=f(t)();var i=n._popContext();return u.checkForgottenReturns(e,i,"Promise.try",n),n._resolveFromSyncValue(e),n},s.prototype._resolveFromSyncValue=function(t){t===l.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";var s=t("./util"),a=s.maybeWrapAsError,c=t("./errors").OperationalError,u=t("./es5");var l=/^(?:name|message|stack|cause)$/;function f(t){var e,n;if((n=t)instanceof Error&&u.getPrototypeOf(n)===Error.prototype){(e=new c(t)).name=t.name,e.message=t.message,e.stack=t.stack;for(var r=u.keys(t),o=0;o<r.length;++o){var i=r[o];l.test(i)||(e[i]=t[i])}return e}return s.markAsOriginatingFromRejection(t),t}e.exports=function(o,i){return function(t,e){if(null!==o){if(t){var n=f(a(t));o._attachExtraTrace(n),o._reject(n)}else if(i){var r=[].slice.call(arguments,1);o._fulfill(r)}else o._fulfill(e);o=null}}}},{"./errors":12,"./es5":13,"./util":36}],21:[function(e,t,n){"use strict";t.exports=function(t){var r=e("./util"),o=t._async,i=r.tryCatch,s=r.errorObj;function a(t,e){if(!r.isArray(t))return c.call(this,t,e);var n=i(e).apply(this._boundValue(),[null].concat(t));n===s&&o.throwLater(n.e)}function c(t,e){var n=this._boundValue(),r=void 0===t?i(e).call(n,null):i(e).call(n,null,t);r===s&&o.throwLater(r.e)}function u(t,e){if(!t){var n=new Error(t+"");n.cause=t,t=n}var r=i(e).call(this._boundValue(),t);r===s&&o.throwLater(r.e)}t.prototype.asCallback=t.prototype.nodeify=function(t,e){if("function"==typeof t){var n=c;void 0!==e&&Object(e).spread&&(n=a),this._then(n,u,void 0,this,t)}return this}}},{"./util":36}],22:[function(S,A,t){"use strict";A.exports=function(){var c=function(){return new f("circular promise resolution chain\n\n    See http://goo.gl/MqrFmX\n")},a=function(){return new k.PromiseInspection(this._target())},s=function(t){return k.reject(new f(t))};function u(){}var p,l={},_=S("./util");p=_.isNode?function(){var t=Y.domain;return void 0===t&&(t=null),t}:function(){return null},_.notEnumerableProp(k,"_getDomain",p);var t=S("./es5"),e=S("./async"),d=new e;t.defineProperty(k,"_async",{value:d});var n=S("./errors"),f=k.TypeError=n.TypeError;k.RangeError=n.RangeError;var v=k.CancellationError=n.CancellationError;k.TimeoutError=n.TimeoutError,k.OperationalError=n.OperationalError,k.RejectionError=n.OperationalError,k.AggregateError=n.AggregateError;var y=function(){},h={},m={},g=S("./thenables")(k,y),b=S("./promise_array")(k,y,g,s,u),r=S("./context")(k),o=r.create,w=S("./debuggability")(k,r),j=(w.CapturedTrace,S("./finally")(k,g)),x=S("./catch_filter")(m),i=S("./nodeback"),C=_.errorObj,E=_.tryCatch;function k(t){this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,t!==y&&(!function(t,e){if("function"!=typeof e)throw new f("expecting a function but got "+_.classString(e));if(t.constructor!==k)throw new f("the promise constructor cannot be invoked directly\n\n    See http://goo.gl/MqrFmX\n")}(this,t),this._resolveFromExecutor(t)),this._promiseCreated(),this._fireEvent("promiseCreated",this)}function F(t){this.promise._resolveCallback(t)}function T(t){this.promise._rejectCallback(t,!1)}function O(t){var e=new k(y);e._fulfillmentHandler0=t,e._rejectionHandler0=t,e._promise0=t,e._receiver0=t}return k.prototype.toString=function(){return"[object Promise]"},k.prototype.caught=k.prototype.catch=function(t){var e=arguments.length;if(1<e){var n,r=new Array(e-1),o=0;for(n=0;n<e-1;++n){var i=arguments[n];if(!_.isObject(i))return s("expecting an object but got A catch statement predicate "+_.classString(i));r[o++]=i}return r.length=o,t=arguments[n],this.then(void 0,x(r,t,this))}return this.then(void 0,t)},k.prototype.reflect=function(){return this._then(a,a,void 0,this,void 0)},k.prototype.then=function(t,e){if(w.warnings()&&0<arguments.length&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+_.classString(t);1<arguments.length&&(n+=", "+_.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},k.prototype.done=function(t,e){this._then(t,e,void 0,void 0,void 0)._setIsFinal()},k.prototype.spread=function(t){return"function"!=typeof t?s("expecting a function but got "+_.classString(t)):this.all()._then(t,void 0,void 0,h,void 0)},k.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},k.prototype.all=function(){return 0<arguments.length&&this._warn(".all() was passed arguments but it does not take any"),new b(this).promise()},k.prototype.error=function(t){return this.caught(_.originatesFromRejection,t)},k.getNewLibraryCopy=A.exports,k.is=function(t){return t instanceof k},k.fromNode=k.fromCallback=function(t){var e=new k(y);e._captureStackTrace();var n=1<arguments.length&&!!Object(arguments[1]).multiArgs,r=E(t)(i(e,n));return r===C&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},k.all=function(t){return new b(t).promise()},k.resolve=k.fulfilled=k.cast=function(t){var e=g(t);return e instanceof k||((e=new k(y))._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},k.reject=k.rejected=function(t){var e=new k(y);return e._captureStackTrace(),e._rejectCallback(t,!0),e},k.setScheduler=function(t){if("function"!=typeof t)throw new f("expecting a function but got "+_.classString(t));return d.setScheduler(t)},k.prototype._then=function(t,e,n,r,o){var i=void 0!==o,s=i?o:new k(y),a=this._target(),c=a._bitField;i||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===r&&0!=(2097152&this._bitField)&&(r=0!=(50397184&c)?this._boundValue():a===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var u=p();if(0!=(50397184&c)){var l,f,h=a._settlePromiseCtx;0!=(33554432&c)?(f=a._rejectionHandler0,l=t):0!=(16777216&c)?(f=a._fulfillmentHandler0,l=e,a._unsetRejectionIsUnhandled()):(h=a._settlePromiseLateCancellationObserver,f=new v("late cancellation observer"),a._attachExtraTrace(f),l=e),d.invoke(h,a,{handler:null===u?l:"function"==typeof l&&_.domainBind(u,l),promise:s,receiver:r,value:f})}else a._addCallbacks(t,e,s,r,u);return s},k.prototype._length=function(){return 65535&this._bitField},k.prototype._isFateSealed=function(){return 0!=(117506048&this._bitField)},k.prototype._isFollowing=function(){return 67108864==(67108864&this._bitField)},k.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},k.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},k.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},k.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},k.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},k.prototype._isFinal=function(){return 0<(4194304&this._bitField)},k.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},k.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},k.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},k.prototype._setAsyncGuaranteed=function(){d.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},k.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==l)return void 0===e&&this._isBound()?this._boundValue():e},k.prototype._promiseAt=function(t){return this[4*t-4+2]},k.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},k.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},k.prototype._boundValue=function(){},k.prototype._migrateCallback0=function(t){t._bitField;var e=t._fulfillmentHandler0,n=t._rejectionHandler0,r=t._promise0,o=t._receiverAt(0);void 0===o&&(o=l),this._addCallbacks(e,n,r,o,null)},k.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),o=t._promiseAt(e),i=t._receiverAt(e);void 0===i&&(i=l),this._addCallbacks(n,r,o,i,null)},k.prototype._addCallbacks=function(t,e,n,r,o){var i=this._length();if(65531<=i&&(i=0,this._setLength(0)),0===i)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===o?t:_.domainBind(o,t)),"function"==typeof e&&(this._rejectionHandler0=null===o?e:_.domainBind(o,e));else{var s=4*i-4;this[s+2]=n,this[s+3]=r,"function"==typeof t&&(this[s+0]=null===o?t:_.domainBind(o,t)),"function"==typeof e&&(this[s+1]=null===o?e:_.domainBind(o,e))}return this._setLength(i+1),i},k.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},k.prototype._resolveCallback=function(t,e){if(0==(117506048&this._bitField)){if(t===this)return this._rejectCallback(c(),!1);var n=g(t,this);if(!(n instanceof k))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r!==this){var o=r._bitField;if(0==(50397184&o)){var i=this._length();0<i&&r._migrateCallback0(this);for(var s=1;s<i;++s)r._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!=(33554432&o))this._fulfill(r._value());else if(0!=(16777216&o))this._reject(r._reason());else{var a=new v("late cancellation observer");r._attachExtraTrace(a),this._reject(a)}}else this._reject(c())}},k.prototype._rejectCallback=function(t,e,n){var r=_.ensureErrorObject(t),o=r===t;if(!o&&!n&&w.warnings()){var i="a promise was rejected with a non-error: "+_.classString(t);this._warn(i,!0)}this._attachExtraTrace(r,!!e&&o),this._reject(t)},k.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)},k.prototype._settlePromiseFromHandler=function(t,e,n,r){var o=r._bitField;if(0==(65536&o)){var i;r._pushContext(),e===h?n&&"number"==typeof n.length?i=E(t).apply(this._boundValue(),n):(i=C).e=new f("cannot .spread() a non-array: "+_.classString(n)):i=E(t).call(e,n);var s=r._popContext();0==(65536&(o=r._bitField))&&(i===m?r._reject(n):i===C?r._rejectCallback(i.e,!1):(w.checkForgottenReturns(i,s,"",r,this),r._resolveCallback(i)))}},k.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},k.prototype._followee=function(){return this._rejectionHandler0},k.prototype._setFollowee=function(t){this._rejectionHandler0=t},k.prototype._settlePromise=function(t,e,n,r){var o=t instanceof k,i=this._bitField,s=0!=(134217728&i);0!=(65536&i)?(o&&t._invokeInternalOnCancel(),n instanceof j&&n.isFinallyHandler()?(n.cancelPromise=t,E(e).call(n,r)===C&&t._reject(C.e)):e===a?t._fulfill(a.call(n)):n instanceof u?n._promiseCancelled(t):o||t instanceof b?t._cancel():n.cancel()):"function"==typeof e?o?(s&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,n,r,t)):e.call(n,r,t):n instanceof u?n._isResolved()||(0!=(33554432&i)?n._promiseFulfilled(r,t):n._promiseRejected(r,t)):o&&(s&&t._setAsyncGuaranteed(),0!=(33554432&i)?t._fulfill(r):t._reject(r))},k.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof k?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof k&&n._reject(o)},k.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},k.prototype._settlePromise0=function(t,e,n){var r=this._promise0,o=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,o,e)},k.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},k.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=c();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,0<(65535&e)&&(0!=(134217728&e)?this._settlePromises():d.settlePromises(this))}},k.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(this._setRejected(),this._fulfillmentHandler0=t,this._isFinal())return d.fatalError(t,_.isNode);0<(65535&e)?d.settlePromises(this):this._ensurePossibleRejectionHandled()}},k.prototype._fulfillPromises=function(t,e){for(var n=1;n<t;n++){var r=this._fulfillmentHandlerAt(n),o=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(o,r,i,e)}},k.prototype._rejectPromises=function(t,e){for(var n=1;n<t;n++){var r=this._rejectionHandlerAt(n),o=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(o,r,i,e)}},k.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(0<e){if(0!=(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},k.prototype._settledValue=function(){var t=this._bitField;return 0!=(33554432&t)?this._rejectionHandler0:0!=(16777216&t)?this._fulfillmentHandler0:void 0},k.defer=k.pending=function(){return w.deprecated("Promise.defer","new Promise"),{promise:new k(y),resolve:F,reject:T}},_.notEnumerableProp(k,"_makeSelfResolutionError",c),S("./method")(k,y,g,s,w),S("./bind")(k,y,g,w),S("./cancel")(k,b,s,w),S("./direct_resolve")(k),S("./synchronous_inspection")(k),S("./join")(k,b,g,y,d,p),(k.Promise=k).version="3.4.7",S("./map.js")(k,b,s,g,y,w),S("./call_get.js")(k),S("./using.js")(k,s,g,o,y,w),S("./timers.js")(k,y,w),S("./generators.js")(k,s,y,g,u,w),S("./nodeify.js")(k),S("./promisify.js")(k,y),S("./props.js")(k,b,g,s),S("./race.js")(k,y,g,s),S("./reduce.js")(k,b,s,g,y,w),S("./settle.js")(k,b,w),S("./some.js")(k,b,s),S("./filter.js")(k,y),S("./each.js")(k,y),S("./any.js")(k),_.toFastProperties(k),_.toFastProperties(k.prototype),O({a:1}),O({b:2}),O({c:3}),O(1),O(function(){}),O(void 0),O(!1),O(new k(y)),w.setBounds(e.firstLineError,_.lastLineError),k}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(r,t,e){"use strict";t.exports=function(a,n,c,s,t){var u=r("./util");u.isArray;function e(t){var e=this._promise=new a(n);t instanceof a&&e._propagateFrom(t,3),e._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return u.inherits(e,t),e.prototype.length=function(){return this._length},e.prototype.promise=function(){return this._promise},e.prototype._init=function t(e,n){var r=c(this._values,this._promise);if(r instanceof a){var o=(r=r._target())._bitField;if(this._values=r,0==(50397184&o))return this._promise._setAsyncGuaranteed(),r._then(t,this._reject,void 0,this,n);if(0==(33554432&o))return 0!=(16777216&o)?this._reject(r._reason()):this._cancel();r=r._value()}if(null!==(r=u.asArray(r)))0!==r.length?this._iterate(r):-5===n?this._resolveEmptyArray():this._resolve(function(t){switch(t){case-2:return[];case-3:return{}}}(n));else{var i=s("expecting an array or an iterable object but got "+u.classString(r)).reason();this._promise._rejectCallback(i,!1)}},e.prototype._iterate=function(t){var e=this.getActualLength(t.length);this._length=e,this._values=this.shouldCopyValues()?new Array(e):this._values;for(var n=this._promise,r=!1,o=null,i=0;i<e;++i){var s=c(t[i],n);o=s instanceof a?(s=s._target())._bitField:null,r?null!==o&&s.suppressUnhandledRejections():null!==o?0==(50397184&o)?(s._proxy(this,i),this._values[i]=s):r=0!=(33554432&o)?this._promiseFulfilled(s._value(),i):0!=(16777216&o)?this._promiseRejected(s._reason(),i):this._promiseCancelled(i):r=this._promiseFulfilled(s,i)}r||n._setAsyncGuaranteed()},e.prototype._isResolved=function(){return null===this._values},e.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},e.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},e.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},e.prototype._promiseFulfilled=function(t,e){return this._values[e]=t,++this._totalResolved>=this._length&&(this._resolve(this._values),!0)},e.prototype._promiseCancelled=function(){return this._cancel(),!0},e.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},e.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof a)t.cancel();else for(var e=0;e<t.length;++e)t[e]instanceof a&&t[e].cancel()}},e.prototype.shouldCopyValues=function(){return!0},e.prototype.getActualLength=function(t){return t},e}},{"./util":36}],24:[function(r,t,e){"use strict";t.exports=function(u,l){var p={},_=r("./util"),f=r("./nodeback"),h=_.withAppended,d=_.maybeWrapAsError,t=_.canEvaluate,v=r("./errors").TypeError,y={__isPromisified__:!0},e=new RegExp("^(?:"+["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"].join("|")+")$"),m=function(t){return _.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t};function s(t){return!e.test(t)}function g(t){try{return!0===t.__isPromisified__}catch(t){return!1}}function b(t,e,n,r){for(var o,i,s,a,c=_.inheritedDataKeys(t),u=[],l=0;l<c.length;++l){var f=c[l],h=t[f],p=r===m||m(f,h,t);"function"!=typeof h||g(h)||(o=t,i=f,s=e,void 0,(a=_.getDataPropertyOrDefault(o,i+s,y))&&g(a))||!r(f,h,t,p)||u.push(f,h)}return function(t,e,n){for(var r=0;r<t.length;r+=2){var o=t[r];if(n.test(o))for(var i=o.replace(n,""),s=0;s<t.length;s+=2)if(t[s]===i)throw new v("Cannot promisify an API that has normal methods with '%s'-suffix\n\n    See http://goo.gl/MqrFmX\n".replace("%s",e))}}(u,e,n),u}var n,w=function(t){return t.replace(/([$])/,"\\$")};var j=t?n:function(o,i,t,e,n,s){var a=function(){return this}(),c=o;function r(){var t=i;i===p&&(t=this);var e=new u(l);e._captureStackTrace();var n="string"==typeof c&&this!==a?this[c]:o,r=f(e,s);try{n.apply(t,h(arguments,r))}catch(t){e._rejectCallback(d(t),!0,!0)}return e._isFateSealed()||e._setAsyncGuaranteed(),e}return"string"==typeof c&&(o=e),_.notEnumerableProp(r,"__isPromisified__",!0),r};function x(t,e,n,r,o){for(var i=new RegExp(w(e)+"$"),s=b(t,e,i,n),a=0,c=s.length;a<c;a+=2){var u=s[a],l=s[a+1],f=u+e;if(r===j)t[f]=j(u,p,u,l,e,o);else{var h=r(l,function(){return j(u,p,u,l,e,o)});_.notEnumerableProp(h,"__isPromisified__",!0),t[f]=h}}return _.toFastProperties(t),t}u.promisify=function(t,e){if("function"!=typeof t)throw new v("expecting a function but got "+_.classString(t));if(g(t))return t;var n,r=void 0===(e=Object(e)).context?p:e.context,o=!!e.multiArgs,i=j(n=t,r,void 0,n,null,o);return _.copyDescriptors(t,i,s),i},u.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new v("the target of promisifyAll must be an object or a function\n\n    See http://goo.gl/MqrFmX\n");var n=!!(e=Object(e)).multiArgs,r=e.suffix;"string"!=typeof r&&(r="Async");var o=e.filter;"function"!=typeof o&&(o=m);var i=e.promisifier;if("function"!=typeof i&&(i=j),!_.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n    See http://goo.gl/MqrFmX\n");for(var s=_.inheritedDataKeys(t),a=0;a<s.length;++a){var c=t[s[a]];"constructor"!==s[a]&&_.isClass(c)&&(x(c.prototype,r,o,i,n),x(c,r,o,i,n))}return x(t,r,o,i,n)}}},{"./errors":12,"./nodeback":20,"./util":36}],25:[function(f,t,e){"use strict";t.exports=function(r,t,o,i){var a,e=f("./util"),s=e.isObject,c=f("./es5");"function"==typeof Map&&(a=Map);var u=function(){var n=0,r=0;function o(t,e){this[n]=t,this[n+r]=e,n++}return function(t){r=t.size,n=0;var e=new Array(2*t.size);return t.forEach(o,e),e}}();function l(t){var e,n=!1;if(void 0!==a&&t instanceof a)e=u(t),n=!0;else{var r=c.keys(t),o=r.length;e=new Array(2*o);for(var i=0;i<o;++i){var s=r[i];e[i]=t[s],e[i+o]=s}}this.constructor$(e),this._isMap=n,this._init$(void 0,-3)}function n(t){var e,n=o(t);return s(n)?(e=n instanceof r?n._then(r.props,void 0,void 0,void 0,void 0):new l(n).promise(),n instanceof r&&e._propagateFrom(n,2),e):i("cannot await properties of a non-object\n\n    See http://goo.gl/MqrFmX\n")}e.inherits(l,t),l.prototype._init=function(){},l.prototype._promiseFulfilled=function(t,e){if(this._values[e]=t,++this._totalResolved>=this._length){var n;if(this._isMap)n=function(t){for(var e=new a,n=t.length/2|0,r=0;r<n;++r){var o=t[n+r],i=t[r];e.set(o,i)}return e}(this._values);else{n={};for(var r=this.length(),o=0,i=this.length();o<i;++o)n[this._values[o+r]]=this._values[o]}return this._resolve(n),!0}return!1},l.prototype.shouldCopyValues=function(){return!1},l.prototype.getActualLength=function(t){return t>>1},r.prototype.props=function(){return n(this)},r.props=function(t){return n(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t){this._capacity=t,this._length=0,this._front=0}r.prototype._willBeOverCapacity=function(t){return this._capacity<t},r.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1),this[this._front+e&this._capacity-1]=t,this._length=e+1},r.prototype.push=function(t,e,n){var r=this.length()+3;if(this._willBeOverCapacity(r))return this._pushOne(t),this._pushOne(e),void this._pushOne(n);var o=this._front+r-3;this._checkCapacity(r);var i=this._capacity-1;this[o+0&i]=t,this[o+1&i]=e,this[o+2&i]=n,this._length=r},r.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},r.prototype.length=function(){return this._length},r.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},r.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t,function(t,e,n,r,o){for(var i=0;i<o;++i)n[i+r]=t[i+e],t[i+e]=void 0}(this,0,this,e,this._front+this._length&e-1)},e.exports=r},{}],27:[function(t,e,n){"use strict";e.exports=function(u,l,f,h){var p=t("./util"),_=function(e){return e.then(function(t){return n(t,e)})};function n(t,e){var n=f(t);if(n instanceof u)return _(n);if(null===(t=p.asArray(t)))return h("expecting an array or an iterable object but got "+p.classString(t));var r=new u(l);void 0!==e&&r._propagateFrom(e,3);for(var o=r._fulfill,i=r._reject,s=0,a=t.length;s<a;++s){var c=t[s];(void 0!==c||s in t)&&u.cast(c)._then(o,i,void 0,r,null)}return r}u.race=function(t){return n(t,void 0)},u.prototype.race=function(){return n(this,void 0)}}},{"./util":36}],28:[function(e,t,n){"use strict";t.exports=function(s,t,o,n,i,a){var c=s._getDomain,u=e("./util"),l=u.tryCatch;function f(t,e,n,r){this.constructor$(t);var o=c();this._fn=null===o?e:u.domainBind(o,e),void 0!==n&&(n=s.resolve(n))._attachCancellationCallback(this),this._initialValue=n,this._currentCancellable=null,this._eachValues=r===i?Array(this._length):0===r?null:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function h(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function p(t,e,n,r){return"function"!=typeof e?o("expecting a function but got "+u.classString(e)):new f(t,e,n,r).promise()}function _(t){this.accum=t,this.array._gotAccum(t);var e=n(this.value,this.array._promise);return e instanceof s?(this.array._currentCancellable=e)._then(r,void 0,void 0,this,void 0):r.call(this,e)}function r(t){var e,n=this.array,r=n._promise,o=l(n._fn);r._pushContext(),(e=void 0!==n._eachValues?o.call(r._boundValue(),t,this.index,this.length):o.call(r._boundValue(),this.accum,t,this.index,this.length))instanceof s&&(n._currentCancellable=e);var i=r._popContext();return a.checkForgottenReturns(e,i,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),e}u.inherits(f,t),f.prototype._gotAccum=function(t){void 0!==this._eachValues&&null!==this._eachValues&&t!==i&&this._eachValues.push(t)},f.prototype._eachComplete=function(t){return null!==this._eachValues&&this._eachValues.push(t),this._eachValues},f.prototype._init=function(){},f.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},f.prototype.shouldCopyValues=function(){return!1},f.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},f.prototype._resultCancelled=function(t){if(t===this._initialValue)return this._cancel();this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof s&&this._currentCancellable.cancel(),this._initialValue instanceof s&&this._initialValue.cancel())},f.prototype._iterate=function(t){var e,n,r=(this._values=t).length;if(void 0!==this._initialValue?(e=this._initialValue,n=0):(e=s.resolve(t[0]),n=1),!(this._currentCancellable=e).isRejected())for(;n<r;++n){var o={accum:null,value:t[n],index:n,length:r,array:this};e=e._then(_,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(e=e._then(this._eachComplete,void 0,void 0,this,void 0)),e._then(h,h,void 0,e,this)},s.prototype.reduce=function(t,e){return p(this,t,e,null)},s.reduce=function(t,e,n,r){return p(t,e,n,r)}}},{"./util":36}],29:[function(t,e,n){"use strict";var r,o=t("./util"),i=o.getNativePromise();if(o.isNode&&"undefined"==typeof MutationObserver){var s=q.setImmediate,a=Y.nextTick;r=o.isRecentNode?function(t){s.call(q,t)}:function(t){a.call(Y,t)}}else if("function"==typeof i&&"function"==typeof i.resolve){var c=i.resolve();r=function(t){c.then(t)}}else r="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&(window.navigator.standalone||window.cordova)?void 0!==u?function(t){u(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:function(){throw new Error("No async scheduler available\n\n    See http://goo.gl/MqrFmX\n")}:function(){var n=document.createElement("div"),r={attributes:!0},o=!1,i=document.createElement("div");new MutationObserver(function(){n.classList.toggle("foo"),o=!1}).observe(i,r);return function(t){var e=new MutationObserver(function(){e.disconnect(),t()});e.observe(n,r),o||(o=!0,i.classList.toggle("foo"))}}();e.exports=r},{"./util":36}],30:[function(i,t,e){"use strict";t.exports=function(t,e,n){var r=t.PromiseInspection;function o(t){this.constructor$(t)}i("./util").inherits(o,e),o.prototype._promiseResolved=function(t,e){return this._values[t]=e,++this._totalResolved>=this._length&&(this._resolve(this._values),!0)},o.prototype._promiseFulfilled=function(t,e){var n=new r;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},o.prototype._promiseRejected=function(t,e){var n=new r;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},t.settle=function(t){return n.deprecated(".settle()",".reflect()"),new o(t).promise()},t.prototype.settle=function(){return t.settle(this)}}},{"./util":36}],31:[function(l,t,e){"use strict";t.exports=function(t,e,o){var n=l("./util"),r=l("./errors").RangeError,i=l("./errors").AggregateError,s=n.isArray,a={};function c(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function u(t,e){if((0|e)!==e||e<0)return o("expecting a positive integer\n\n    See http://goo.gl/MqrFmX\n");var n=new c(t),r=n.promise();return n.setHowMany(e),n.init(),r}n.inherits(c,e),c.prototype._init=function(){if(this._initialized)if(0!==this._howMany){this._init$(void 0,-5);var t=s(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}else this._resolve([])},c.prototype.init=function(){this._initialized=!0,this._init()},c.prototype.setUnwrap=function(){this._unwrap=!0},c.prototype.howMany=function(){return this._howMany},c.prototype.setHowMany=function(t){this._howMany=t},c.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0)},c.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},c.prototype._promiseCancelled=function(){return this._values instanceof t||null==this._values?this._cancel():(this._addRejected(a),this._checkOutcome())},c.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new i,e=this.length();e<this._values.length;++e)this._values[e]!==a&&t.push(this._values[e]);return 0<t.length?this._reject(t):this._cancel(),!0}return!1},c.prototype._fulfilled=function(){return this._totalResolved},c.prototype._rejected=function(){return this._values.length-this.length()},c.prototype._addRejected=function(t){this._values.push(t)},c.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},c.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},c.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new r(e)},c.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},t.some=function(t,e){return u(t,e)},t.prototype.some=function(t){return u(this,t)},t._SomePromiseArray=c}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n    See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n    See http://goo.gl/MqrFmX\n");return this._settledValue()},o=e.prototype.isFulfilled=function(){return 0!=(33554432&this._bitField)},i=e.prototype.isRejected=function(){return 0!=(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0==(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!=(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!=(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536==(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!=(8454144&this._target()._bitField)},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return i.call(this._target())},t.prototype.isFulfilled=function(){return o.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(a,c){var u=t("./util"),l=u.errorObj,o=u.isObject;var i={}.hasOwnProperty;return function(t,e){if(o(t)){if(t instanceof a)return t;var n=function(t){try{return t.then}catch(t){return l.e=t,l}}(t);if(n===l){e&&e._pushContext();var r=a.reject(n.e);return e&&e._popContext(),r}if("function"==typeof n)return function(t){try{return i.call(t,"_promise0")}catch(t){return!1}}(t)?(r=new a(c),t._then(r._fulfill,r._reject,void 0,r,null),r):function(t,e,n){var r=new a(c),o=r;n&&n._pushContext(),r._captureStackTrace(),n&&n._popContext();var i=!0,s=u.tryCatch(e).call(t,function(t){r&&(r._resolveCallback(t),r=null)},function(t){r&&(r._rejectCallback(t,i,!0),r=null)});return i=!1,r&&s===l&&(r._rejectCallback(s.e,!0,!0),r=null),o}(t,n,e)}return t}}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(o,i,a){var c=t("./util"),u=o.TimeoutError;function l(t){this.handle=t}l.prototype._resultCancelled=function(){clearTimeout(this.handle)};var s=function(t){return e(+this).thenReturn(t)},e=o.delay=function(t,e){var n,r;return void 0!==e?(n=o.resolve(e)._then(s,null,null,t,void 0),a.cancellation()&&e instanceof o&&n._setOnCancel(e)):(n=new o(i),r=setTimeout(function(){n._fulfill()},+t),a.cancellation()&&n._setOnCancel(new l(r)),n._captureStackTrace()),n._setAsyncGuaranteed(),n};o.prototype.delay=function(t){return e(t,this)};function n(t){return clearTimeout(this.handle),t}function r(t){throw clearTimeout(this.handle),t}o.prototype.timeout=function(t,o){var i,s;t=+t;var e=new l(setTimeout(function(){var t,e,n,r;i.isPending()&&(t=i,n=s,r="string"!=typeof(e=o)?e instanceof Error?e:new u("operation timed out"):new u(e),c.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel())},t));return a.cancellation()?(s=this.then(),(i=s._then(n,r,void 0,e,void 0))._setOnCancel(e)):i=this._then(n,r,void 0,e,void 0),i}}},{"./util":36}],35:[function(s,t,e){"use strict";t.exports=function(h,p,_,e,t,d){var v=s("./util"),n=s("./errors").TypeError,r=s("./util").inherits,y=v.errorObj,m=v.tryCatch,o={};function u(t){setTimeout(function(){throw t},0)}function g(o,i){var s=0,a=o.length,c=new h(t);return function t(){if(a<=s)return c._fulfill();var e,n,r=(e=o[s++],(n=_(e))!==e&&"function"==typeof e._isDisposable&&"function"==typeof e._getDisposer&&e._isDisposable()&&n._setDisposable(e._getDisposer()),n);if(r instanceof h&&r._isDisposable()){try{r=_(r._getDisposer().tryDispose(i),o.promise)}catch(t){return u(t)}if(r instanceof h)return r._then(t,u,null,null,null)}t()}(),c}function b(t,e,n){this._data=t,this._promise=e,this._context=n}function i(t,e,n){this.constructor$(t,e,n)}function w(t){return b.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function j(t){this.length=t,this.promise=null,this[t-1]=null}b.prototype.data=function(){return this._data},b.prototype.promise=function(){return this._promise},b.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():o},b.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==o?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},b.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},r(i,b),i.prototype.doDispose=function(t,e){return this.data().call(t,t,e)},j.prototype._resultCancelled=function(){for(var t=this.length,e=0;e<t;++e){var n=this[e];n instanceof h&&n.cancel()}},h.using=function(){var t=arguments.length;if(t<2)return p("you must pass at least 2 arguments to Promise.using");var e,i=arguments[t-1];if("function"!=typeof i)return p("expecting a function but got "+v.classString(i));var s=!0;2===t&&Array.isArray(arguments[0])?(t=(e=arguments[0]).length,s=!1):(e=arguments,t--);for(var n=new j(t),r=0;r<t;++r){var o=e[r];if(b.isDisposer(o)){var a=o;(o=o.promise())._setDisposable(a)}else{var c=_(o);c instanceof h&&(o=c._then(w,null,null,{resources:n,index:r},void 0))}n[r]=o}var u=new Array(n.length);for(r=0;r<u.length;++r)u[r]=h.resolve(n[r]).reflect();var l=h.all(u).then(function(t){for(var e=0;e<t.length;++e){var n=t[e];if(n.isRejected())return y.e=n.error(),y;if(!n.isFulfilled())return void l.cancel();t[e]=n.value()}f._pushContext(),i=m(i);var r=s?i.apply(void 0,t):i(t),o=f._popContext();return d.checkForgottenReturns(r,o,"Promise.using",f),r}),f=l.lastly(function(){var t=new h.PromiseInspection(l);return g(n,t)});return(n.promise=f)._setOnCancel(n),f},h.prototype._setDisposable=function(t){this._bitField=131072|this._bitField,this._disposer=t},h.prototype._isDisposable=function(){return 0<(131072&this._bitField)},h.prototype._getDisposer=function(){return this._disposer},h.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},h.prototype.disposer=function(t){if("function"==typeof t)return new i(t,this,e());throw new n}}},{"./errors":12,"./util":36}],36:[function(t,e,n){"use strict";var u=t("./es5"),r="undefined"==typeof navigator,o={e:{}},i,s="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==q?q:void 0!==this?this:null;function a(){try{var t=i;return i=null,t.apply(this,arguments)}catch(t){return o.e=t,o}}function c(t){return i=t,a}var l=function(e,n){var r={}.hasOwnProperty;function t(){for(var t in this.constructor=e,(this.constructor$=n).prototype)r.call(n.prototype,t)&&"$"!==t.charAt(t.length-1)&&(this[t+"$"]=n.prototype[t])}return t.prototype=n.prototype,e.prototype=new t,e.prototype};function f(t){return null==t||!0===t||!1===t||"string"==typeof t||"number"==typeof t}function h(t){return"function"==typeof t||"object"==typeof t&&null!==t}function p(t){return f(t)?new Error(E(t)):t}function _(t,e){var n,r=t.length,o=new Array(r+1);for(n=0;n<r;++n)o[n]=t[n];return o[n]=e,o}function d(t,e,n){if(!u.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function v(t,e,n){if(f(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return u.defineProperty(t,e,r),t}function y(t){throw t}var m=function(){var o=[Array.prototype,Object.prototype,Function.prototype],a=function(t){for(var e=0;e<o.length;++e)if(o[e]===t)return!0;return!1};if(u.isES5){var c=Object.getOwnPropertyNames;return function(t){for(var e=[],n=Object.create(null);null!=t&&!a(t);){var r;try{r=c(t)}catch(t){return e}for(var o=0;o<r.length;++o){var i=r[o];if(!n[i]){n[i]=!0;var s=Object.getOwnPropertyDescriptor(t,i);null!=s&&null==s.get&&null==s.set&&e.push(i)}}t=u.getPrototypeOf(t)}return e}}var i={}.hasOwnProperty;return function(t){if(a(t))return[];var e=[];t:for(var n in t)if(i.call(t,n))e.push(n);else{for(var r=0;r<o.length;++r)if(i.call(o[r],n))continue t;e.push(n)}return e}}(),g=/this\s*\.\s*\S+\s*=/;function b(t){try{if("function"==typeof t){var e=u.names(t.prototype),n=u.isES5&&1<e.length,r=0<e.length&&!(1===e.length&&"constructor"===e[0]),o=g.test(t+"")&&0<u.names(t).length;if(n||r||o)return!0}return!1}catch(t){return!1}}function w(t){function e(){}e.prototype=t;for(var n=8;n--;)new e;return t}var j=/^[a-z$_][a-z$_0-9]*$/i;function x(t){return j.test(t)}function C(t,e,n){for(var r=new Array(t),o=0;o<t;++o)r[o]=e+o+n;return r}function E(t){try{return t+""}catch(t){return"[no string representation]"}}function k(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function F(t){try{v(t,"isOperational",!0)}catch(t){}}function T(t){return null!=t&&(t instanceof Error.__BluebirdErrorTypes__.OperationalError||!0===t.isOperational)}function O(t){return k(t)&&u.propertyIsWritable(t,"stack")}var S="stack"in new Error?function(t){return O(t)?t:new Error(E(t))}:function(t){if(O(t))return t;try{throw new Error(E(t))}catch(t){return t}};function A(t){return{}.toString.call(t)}function P(t,e,n){for(var r=u.names(t),o=0;o<r.length;++o){var i=r[o];if(n(i))try{u.defineProperty(e,i,u.getDescriptor(t,i))}catch(t){}}}var R=function(t){return u.isArray(t)?t:null};if("undefined"!=typeof Symbol&&Symbol.iterator){var I="function"==typeof Array.from?function(t){return Array.from(t)}:function(t){for(var e,n=[],r=t[Symbol.iterator]();!(e=r.next()).done;)n.push(e.value);return n};R=function(t){return u.isArray(t)?t:null!=t&&"function"==typeof t[Symbol.iterator]?I(t):null}}var D=void 0!==Y&&"[object process]"===A(Y).toLowerCase(),M=void 0!==Y&&void 0!==Y.env;function L(t){return M?Y.env[t]:void 0}function U(){if("function"==typeof Promise)try{var t=new Promise(function(){});if("[object Promise]"==={}.toString.call(t))return Promise}catch(t){}}function V(t,e){return t.bind(e)}var N={isClass:b,isIdentifier:x,inheritedDataKeys:m,getDataPropertyOrDefault:d,thrower:y,isArray:u.isArray,asArray:R,notEnumerableProp:v,isPrimitive:f,isObject:h,isError:k,canEvaluate:r,errorObj:o,tryCatch:c,inherits:l,withAppended:_,maybeWrapAsError:p,toFastProperties:w,filledRange:C,toString:E,canAttachTrace:O,ensureErrorObject:S,originatesFromRejection:T,markAsOriginatingFromRejection:F,classString:A,copyDescriptors:P,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:D,hasEnvVariables:M,env:L,global:s,getNativePromise:U,domainBind:V},H;N.isRecentNode=N.isNode&&(H=Y.versions.node.split(".").map(Number),0===H[0]&&10<H[1]||0<H[0]),N.isNode&&N.toFastProperties(Y);try{throw new Error}catch(t){N.lastLineError=t}e.exports=N},{"./es5":13}]},{},[4])(4)},e.exports=t(),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(t,n(45),n(11),n(137).setImmediate)},function(t,e,n){var r=n(1)(n(0),"Map");t.exports=r},function(t,e,n){var r=n(0).Symbol;t.exports=r},function(t,e,n){var r=n(55);t.exports=function(t){var e=new t.constructor(t.byteLength);return new r(e).set(new r(t)),e}},function(t,e,n){var r=n(60),o=n(44),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:o;t.exports=a},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var r=n(42),o=n(43);t.exports=function(t){return null!=t&&o(t.length)&&!r(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,n){var r=n(25),o=n(68),i=n(20);t.exports=function(t){return i(t)?r(t):o(t)}},function(t,e,n){var r=n(25),o=n(69),i=n(20);t.exports=function(t){return i(t)?r(t,!0):o(t)}},function(t,e){t.exports=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}},function(t,e,n){var l=n(71),f=n(129),h=n(19),p=n(41),_=n(36),d=n(130),v=Object.prototype.hasOwnProperty;t.exports=function(t,e){var n=h(t),r=!n&&f(t),o=!n&&!r&&p(t),i=!n&&!r&&!o&&d(t),s=n||r||o||i,a=s?l(t.length,String):[],c=a.length;for(var u in t)!e&&!v.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||_(u,c))||a.push(u);return a}},function(t,e){t.exports=function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}},function(t,e){t.exports=function(t,e,n,r){var o=-1,i=null==t?0:t.length;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}},function(t,e,n){var o=n(29),i=n(9),s=Object.prototype.hasOwnProperty;t.exports=function(t,e,n){var r=t[e];s.call(t,e)&&i(r,n)&&(void 0!==n||e in t)||o(t,e,n)}},function(t,e,n){var r=n(32);t.exports=function(t,e,n){"__proto__"==e&&r?r(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}},function(t,e,n){var o=n(26),i=n(19);t.exports=function(t,e,n){var r=e(t);return i(t)?r:o(r,n(t))}},function(t,e,n){var r=n(40),o=n(117),i=n(119);t.exports=function(t,e){return i(o(t,e,r),t+"")}},function(t,e,n){var r=n(1),o=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},function(n,t,e){(function(t){var e="object"==typeof t&&t&&t.Object===Object&&t;n.exports=e}).call(t,e(11))},function(t,e,n){var r=n(37)(Object.getPrototypeOf,Object);t.exports=r},function(t,e,n){var r=n(26),o=n(34),i=n(17),s=n(44),a=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)r(e,i(t)),t=o(t);return e}:s;t.exports=a},function(t,e){var n=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||n.test(t))&&-1<t&&t%1==0&&t<e}},function(t,e){t.exports=function(e,n){return function(t){return e(n(t))}}},function(t,e){var n=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return n.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,e,n){var r=n(24),o=n(126),i=n(31),s=n(85),a=i(function(t){return t.push(void 0,s),r(o,void 0,t)});t.exports=a},function(t,e){t.exports=function(t){return t}},function(t,a,c){(function(t){var e=c(0),n=c(131),r="object"==typeof a&&a&&!a.nodeType&&a,o=r&&"object"==typeof t&&t&&!t.nodeType&&t,i=o&&o.exports===r?e.Buffer:void 0,s=(i?i.isBuffer:void 0)||n;t.exports=s}).call(a,c(12)(t))},function(t,e,n){var r=n(6),o=n(2);t.exports=function(t){if(!o(t))return!1;var e=r(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},function(t,e){t.exports=function(t){return"number"==typeof t&&-1<t&&t%1==0&&t<=9007199254740991}},function(t,e){t.exports=function(){return[]}},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var c,u=[],l=!1,f=-1;function h(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!l){var t=a(h);l=!0;for(var e=u.length;e;){for(c=u,u=[];++f<e;)c&&c[f].run();f=-1,e=u.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(t)}}function _(t,e){this.fun=t,this.array=e}function d(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new _(t,e)),1!==u.length||l||a(p)},_.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=d,o.addListener=d,o.once=d,o.off=d,o.removeListener=d,o.removeAllListeners=d,o.emit=d,o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(10),r=function(){function t(t,e){this._rgb=t,this._population=e}return t.prototype.getRgb=function(){return this._rgb},t.prototype.getHsl=function(){if(!this._hsl){var t=this._rgb,e=t[0],n=t[1],r=t[2];this._hsl=o.rgbToHsl(e,n,r)}return this._hsl},t.prototype.getPopulation=function(){return this._population},t.prototype.getHex=function(){if(!this._hex){var t=this._rgb,e=t[0],n=t[1],r=t[2];this._hex=o.rgbToHex(e,n,r)}return this._hex},t.prototype.getYiq=function(){if(!this._yiq){var t=this._rgb;this._yiq=(299*t[0]+587*t[1]+114*t[2])/1e3}return this._yiq},t.prototype.getTitleTextColor=function(){return this.getYiq()<200?"#fff":"#000"},t.prototype.getBodyTextColor=function(){return this.getYiq()<150?"#fff":"#000"},t}();e.Swatch=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=n(13),r=n(39),o=n(138),i=n(10),a=n(145),c=n(142),u=n(140),l=function(){function n(t,e){this._src=t,this.opts=r({},e,n.DefaultOpts)}return n.from=function(t){return new o.default(t)},n.prototype._process=function(t){var e=this,n=this.opts,r=n.quantizer,o=n.generator;t.scaleDown(n);var i=t.getImageData();return s.resolve(r(i.data,n)).then(function(t){return s.resolve(o(t))}).tap(function(t){return e._palette=t}).finally(function(){return t.remove()})},n.prototype.palette=function(){return this.swatches()},n.prototype.swatches=function(){return this._palette},n.prototype.getPalette=function(t){var e=this;return(new this.opts.ImageClass).load(this._src).then(function(t){return e._process(t)}).asCallback(t)},n}();l.Builder=o.default,l.Quantizer=a,l.Generator=c,l.Filter=u,l.Util=i,l.DefaultOpts={colorCount:64,quality:5,generator:c.Default,ImageClass:null,quantizer:a.MMCQ,filters:[u.Default]},e.default=l},function(t,e,n){"use strict";var r=n(47),o=n(144);r.default.DefaultOpts.ImageClass=o.default,t.exports=r.default},function(t,e,n){var r=n(1)(n(0),"DataView");t.exports=r},function(t,e,n){var r=n(91),o=n(92),i=n(93),s=n(94),a=n(95);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,t.exports=c},function(t,e,n){var r=n(107),o=n(108),i=n(109),s=n(110),a=n(111);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,t.exports=c},function(t,e,n){var r=n(1)(n(0),"Promise");t.exports=r},function(t,e,n){var r=n(1)(n(0),"Set");t.exports=r},function(t,e,n){var r=n(4),o=n(121),i=n(122),s=n(123),a=n(124),c=n(125);function u(t){var e=this.__data__=new r(t);this.size=e.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=c,t.exports=u},function(t,e,n){var r=n(0).Uint8Array;t.exports=r},function(t,e,n){var r=n(1)(n(0),"WeakMap");t.exports=r},function(t,e){t.exports=function(t,e){return t.set(e[0],e[1]),t}},function(t,e){t.exports=function(t,e){return t.add(e),t}},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}},function(t,e,n){var r=n(3),o=n(22);t.exports=function(t,e){return t&&r(e,o(e),t)}},function(t,e,n){var r=n(3),o=n(23);t.exports=function(t,e){return t&&r(e,o(e),t)}},function(t,e,n){var y=n(54),m=n(59),g=n(28),b=n(61),w=n(62),j=n(73),x=n(80),C=n(81),E=n(82),k=n(86),F=n(87),T=n(89),O=n(96),S=n(97),A=n(98),P=n(19),R=n(41),I=n(2),D=n(22),M=1,L=2,U=4,V="[object Arguments]",N="[object Function]",H="[object GeneratorFunction]",q="[object Object]",B={};B[V]=B["[object Array]"]=B["[object ArrayBuffer]"]=B["[object DataView]"]=B["[object Boolean]"]=B["[object Date]"]=B["[object Float32Array]"]=B["[object Float64Array]"]=B["[object Int8Array]"]=B["[object Int16Array]"]=B["[object Int32Array]"]=B["[object Map]"]=B["[object Number]"]=B[q]=B["[object RegExp]"]=B["[object Set]"]=B["[object String]"]=B["[object Symbol]"]=B["[object Uint8Array]"]=B["[object Uint8ClampedArray]"]=B["[object Uint16Array]"]=B["[object Uint32Array]"]=!0,B["[object Error]"]=B[N]=B["[object WeakMap]"]=!1,t.exports=function n(r,o,i,t,e,s){var a,c=o&M,u=o&L,l=o&U;if(i&&(a=e?i(r,t,e,s):i(r)),void 0!==a)return a;if(!I(r))return r;var f=P(r);if(f){if(a=O(r),!c)return x(r,a)}else{var h=T(r),p=h==N||h==H;if(R(r))return j(r,c);if(h==q||h==V||p&&!e){if(a=u||p?{}:A(r),!c)return u?E(r,w(a,r)):C(r,b(a,r))}else{if(!B[h])return e?r:{};a=S(r,h,n,c)}}s||(s=new y);var _=s.get(r);if(_)return _;s.set(r,a);var d=l?u?F:k:u?keysIn:D,v=f?void 0:d(r);return m(v||r,function(t,e){v&&(t=r[e=t]),g(a,e,n(t,o,i,e,r,s))}),a}},function(t,e,n){var r=n(2),o=Object.create,i=function(){function n(){}return function(t){if(!r(t))return{};if(o)return o(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}();t.exports=i},function(t,e,n){var r=n(6),o=n(21);t.exports=function(t){return o(t)&&"[object Arguments]"==r(t)}},function(t,e,n){var r=n(42),o=n(101),i=n(2),s=n(38),a=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,f=u.hasOwnProperty,h=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(r(t)?h:a).test(s(t))}},function(t,e,n){var r=n(6),o=n(43),i=n(21),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,t.exports=function(t){return i(t)&&o(t.length)&&!!s[r(t)]}},function(t,e,n){var r=n(18),o=n(113),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return o(t);var e=[];for(var n in Object(t))i.call(t,n)&&"constructor"!=n&&e.push(n);return e}},function(t,e,n){var o=n(2),i=n(18),s=n(114),a=Object.prototype.hasOwnProperty;t.exports=function(t){if(!o(t))return s(t);var e=i(t),n=[];for(var r in t)("constructor"!=r||!e&&a.call(t,r))&&n.push(r);return n}},function(t,e,n){var r=n(128),o=n(32),i=n(40),s=o?function(t,e){return o(t,"toString",{configurable:!0,enumerable:!1,value:r(e),writable:!0})}:i;t.exports=s},function(t,e){t.exports=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}},function(t,e){t.exports=function(e){return function(t){return e(t)}}},function(t,s,a){(function(t){var e=a(0),n="object"==typeof s&&s&&!s.nodeType&&s,r=n&&"object"==typeof t&&t&&!t.nodeType&&t,o=r&&r.exports===n?e.Buffer:void 0,i=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=i?i(n):new t.constructor(n);return t.copy(r),r}}).call(s,a(12)(t))},function(t,e,n){var r=n(16);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}},function(t,e,n){var o=n(57),i=n(27),s=n(112);t.exports=function(t,e,n){var r=e?n(s(t),1):s(t);return i(r,o,new t.constructor)}},function(t,e){var n=/\w*$/;t.exports=function(t){var e=new t.constructor(t.source,n.exec(t));return e.lastIndex=t.lastIndex,e}},function(t,e,n){var o=n(58),i=n(27),s=n(118);t.exports=function(t,e,n){var r=e?n(s(t),1):s(t);return i(r,o,new t.constructor)}},function(t,e,n){var r=n(15),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;t.exports=function(t){return i?Object(i.call(t)):{}}},function(t,e,n){var r=n(16);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}},function(t,e){t.exports=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}},function(t,e,n){var r=n(3),o=n(17);t.exports=function(t,e){return r(t,o(t),e)}},function(t,e,n){var r=n(3),o=n(35);t.exports=function(t,e){return r(t,o(t),e)}},function(t,e,n){var r=n(0)["__core-js_shared__"];t.exports=r},function(t,e,n){var r=n(31),c=n(99);t.exports=function(a){return r(function(t,e){var n=-1,r=e.length,o=1<r?e[r-1]:void 0,i=2<r?e[2]:void 0;for(o=3<a.length&&"function"==typeof o?(r--,o):void 0,i&&c(e[0],e[1],i)&&(o=r<3?void 0:o,r=1),t=Object(t);++n<r;){var s=e[n];s&&a(t,s,n,o)}return t})}},function(t,e,n){var o=n(9),i=Object.prototype,s=i.hasOwnProperty;t.exports=function(t,e,n,r){return void 0===t||o(t,i[n])&&!s.call(r,n)?e:t}},function(t,e,n){var r=n(30),o=n(17),i=n(22);t.exports=function(t){return r(t,i,o)}},function(t,e,n){var r=n(30),o=n(35),i=n(23);t.exports=function(t){return r(t,i,o)}},function(t,e,n){var r=n(15),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;t.exports=function(t){var e=i.call(t,a),n=t[a];try{var r=!(t[a]=void 0)}catch(t){}var o=s.call(t);return r&&(e?t[a]=n:delete t[a]),o}},function(t,e,n){var r=n(49),o=n(14),i=n(52),s=n(53),a=n(56),c=n(6),u=n(38),l="[object Map]",f="[object Promise]",h="[object Set]",p="[object WeakMap]",_="[object DataView]",d=u(r),v=u(o),y=u(i),m=u(s),g=u(a),b=c;(r&&b(new r(new ArrayBuffer(1)))!=_||o&&b(new o)!=l||i&&b(i.resolve())!=f||s&&b(new s)!=h||a&&b(new a)!=p)&&(b=function(t){var e=c(t),n="[object Object]"==e?t.constructor:void 0,r=n?u(n):"";if(r)switch(r){case d:return _;case v:return l;case y:return f;case m:return h;case g:return p}return e}),t.exports=b},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e,n){var r=n(8);t.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(t,e){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},function(t,e,n){var r=n(8),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(r){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(e,t)?e[t]:void 0}},function(t,e,n){var r=n(8),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return r?void 0!==e[t]:o.call(e,t)}},function(t,e,n){var r=n(8);t.exports=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=r&&void 0===e?"__lodash_hash_undefined__":e,this}},function(t,e){var r=Object.prototype.hasOwnProperty;t.exports=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&r.call(t,"index")&&(n.index=t.index,n.input=t.input),n}},function(t,e,n){var i=n(16),s=n(74),a=n(75),c=n(76),u=n(77),l=n(78),f=n(79);t.exports=function(t,e,n,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return i(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return s(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return f(t,r);case"[object Map]":return a(t,r,n);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return c(t);case"[object Set]":return u(t,r,n);case"[object Symbol]":return l(t)}}},function(t,e,n){var r=n(64),o=n(34),i=n(18);t.exports=function(t){return"function"!=typeof t.constructor||i(t)?{}:r(o(t))}},function(t,e,n){var o=n(9),i=n(20),s=n(36),a=n(2);t.exports=function(t,e,n){if(!a(n))return!1;var r=typeof e;return!!("number"==r?i(n)&&s(e,n.length):"string"==r&&e in n)&&o(n[e],t)}},function(t,e){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},function(t,e,n){var r,o=n(83),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return!!i&&i in t}},function(t,e){t.exports=function(){this.__data__=[],this.size=0}},function(t,e,n){var r=n(5),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,n=r(e,t);return!(n<0||(n==e.length-1?e.pop():o.call(e,n,1),--this.size,0))}},function(t,e,n){var r=n(5);t.exports=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]}},function(t,e,n){var r=n(5);t.exports=function(t){return-1<r(this.__data__,t)}},function(t,e,n){var o=n(5);t.exports=function(t,e){var n=this.__data__,r=o(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}},function(t,e,n){var r=n(50),o=n(4),i=n(14);t.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},function(t,e,n){var r=n(7);t.exports=function(t){var e=r(this,t).delete(t);return this.size-=e?1:0,e}},function(t,e,n){var r=n(7);t.exports=function(t){return r(this,t).get(t)}},function(t,e,n){var r=n(7);t.exports=function(t){return r(this,t).has(t)}},function(t,e,n){var o=n(7);t.exports=function(t,e){var n=o(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}},function(t,e){t.exports=function(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}},function(t,e,n){var r=n(37)(Object.keys,Object);t.exports=r},function(t,e){t.exports=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}},function(t,s,a){(function(t){var e=a(33),n="object"==typeof s&&s&&!s.nodeType&&s,r=n&&"object"==typeof t&&t&&!t.nodeType&&t,o=r&&r.exports===n&&e.process,i=function(){try{return o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=i}).call(s,a(12)(t))},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e,n){var c=n(24),u=Math.max;t.exports=function(i,s,a){return s=u(void 0===s?i.length-1:s,0),function(){for(var t=arguments,e=-1,n=u(t.length-s,0),r=Array(n);++e<n;)r[e]=t[s+e];e=-1;for(var o=Array(s+1);++e<s;)o[e]=t[e];return o[s]=a(r),c(i,this,o)}}},function(t,e){t.exports=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}},function(t,e,n){var r=n(70),o=n(120)(r);t.exports=o},function(t,e){var i=Date.now;t.exports=function(n){var r=0,o=0;return function(){var t=i(),e=16-(t-o);if(o=t,0<e){if(800<=++r)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}},function(t,e,n){var r=n(4);t.exports=function(){this.__data__=new r,this.size=0}},function(t,e){t.exports=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}},function(t,e){t.exports=function(t){return this.__data__.get(t)}},function(t,e){t.exports=function(t){return this.__data__.has(t)}},function(t,e,n){var o=n(4),i=n(14),s=n(51);t.exports=function(t,e){var n=this.__data__;if(n instanceof o){var r=n.__data__;if(!i||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new s(r)}return n.set(t,e),this.size=n.size,this}},function(t,e,n){var o=n(3),r=n(84),i=n(23),s=r(function(t,e,n,r){o(e,i(e),t,r)});t.exports=s},function(t,e,n){var r=n(63);t.exports=function(t){return r(t,4)}},function(t,e){t.exports=function(t){return function(){return t}}},function(t,e,n){var r=n(65),o=n(21),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,c=r(function(){return arguments}())?r:function(t){return o(t)&&s.call(t,"callee")&&!a.call(t,"callee")};t.exports=c},function(t,e,n){var r=n(67),o=n(72),i=n(115),s=i&&i.isTypedArray,a=s?o(s):r;t.exports=a},function(t,e){t.exports=function(){return!1}},function(t,A,P){(function(_,d){var v;!function(t){"object"==typeof A&&A&&A.nodeType,"object"==typeof _&&_&&_.nodeType;var e="object"==typeof d&&d;e.global!==e&&e.window!==e&&e.self;var n,y=2147483647,m=36,g=1,b=26,o=38,i=700,w=72,j=128,x="-",r=/^xn--/,s=/[^\x20-\x7E]/,a=/[\x2E\u3002\uFF0E\uFF61]/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},u=m-g,C=Math.floor,E=String.fromCharCode;function k(t){throw new RangeError(c[t])}function l(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function f(t,e){var n=t.split("@"),r="";return 1<n.length&&(r=n[0]+"@",t=n[1]),r+l((t=t.replace(a,".")).split("."),e).join(".")}function F(t){for(var e,n,r=[],o=0,i=t.length;o<i;)55296<=(e=t.charCodeAt(o++))&&e<=56319&&o<i?56320==(64512&(n=t.charCodeAt(o++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--):r.push(e);return r}function T(t){return l(t,function(t){var e="";return 65535<t&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=E(t)}).join("")}function O(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function S(t,e,n){var r=0;for(t=n?C(t/i):t>>1,t+=C(t/e);u*b>>1<t;r+=m)t=C(t/u);return C(r+(u+1)*t/(t+o))}function h(t){var e,n,r,o,i,s,a,c,u,l,f,h=[],p=t.length,_=0,d=j,v=w;for((n=t.lastIndexOf(x))<0&&(n=0),r=0;r<n;++r)128<=t.charCodeAt(r)&&k("not-basic"),h.push(t.charCodeAt(r));for(o=0<n?n+1:0;o<p;){for(i=_,s=1,a=m;p<=o&&k("invalid-input"),f=t.charCodeAt(o++),(m<=(c=f-48<10?f-22:f-65<26?f-65:f-97<26?f-97:m)||c>C((y-_)/s))&&k("overflow"),_+=c*s,!(c<(u=a<=v?g:v+b<=a?b:a-v));a+=m)s>C(y/(l=m-u))&&k("overflow"),s*=l;v=S(_-i,e=h.length+1,0==i),C(_/e)>y-d&&k("overflow"),d+=C(_/e),_%=e,h.splice(_++,0,d)}return T(h)}function p(t){var e,n,r,o,i,s,a,c,u,l,f,h,p,_,d,v=[];for(h=(t=F(t)).length,e=j,i=w,s=n=0;s<h;++s)(f=t[s])<128&&v.push(E(f));for(r=o=v.length,o&&v.push(x);r<h;){for(a=y,s=0;s<h;++s)e<=(f=t[s])&&f<a&&(a=f);for(a-e>C((y-n)/(p=r+1))&&k("overflow"),n+=(a-e)*p,e=a,s=0;s<h;++s)if((f=t[s])<e&&++n>y&&k("overflow"),f==e){for(c=n,u=m;!(c<(l=u<=i?g:i+b<=u?b:u-i));u+=m)d=c-l,_=m-l,v.push(E(O(l+d%_,0))),c=C(d/_);v.push(E(O(c,0))),i=S(n,p,r==o),n=0,++r}++n,++e}return v.join("")}n={version:"1.4.1",ucs2:{decode:F,encode:T},decode:h,encode:p,toASCII:function(t){return f(t,function(t){return s.test(t)?"xn--"+p(t):t})},toUnicode:function(t){return f(t,function(t){return r.test(t)?h(t.slice(4).toLowerCase()):t})}},void 0===(v=function(){return n}.call(A,P,A,_))||(_.exports=v)}()}).call(A,P(12)(t),P(11))},function(t,e,n){"use strict";t.exports=function(t,e,n,r){e=e||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e);var s=1e3;r&&"number"==typeof r.maxKeys&&(s=r.maxKeys);var a,c,u=t.length;0<s&&s<u&&(u=s);for(var l=0;l<u;++l){var f,h,p,_,d=t[l].replace(i,"%20"),v=d.indexOf(n);0<=v?(f=d.substr(0,v),h=d.substr(v+1)):(f=d,h=""),p=decodeURIComponent(f),_=decodeURIComponent(h),a=o,c=p,Object.prototype.hasOwnProperty.call(a,c)?y(o[p])?o[p].push(_):o[p]=[o[p],_]:o[p]=_}return o};var y=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";var i=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(n,r,o,t){return r=r||"&",o=o||"=",null===n&&(n=void 0),"object"==typeof n?a(c(n),function(t){var e=encodeURIComponent(i(t))+o;return s(n[t])?a(n[t],function(t){return e+encodeURIComponent(i(t))}).join(r):e+encodeURIComponent(i(n[t]))}).join(r):t?encodeURIComponent(i(t))+o+encodeURIComponent(i(n)):""};var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r<t.length;r++)n.push(e(t[r],r));return n}var c=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}},function(t,e,n){"use strict";e.decode=e.parse=n(133),e.encode=e.stringify=n(134)},function(t,e,n){(function(t,_){!function(n,r){"use strict";if(!n.setImmediate){var o,i,e,s,t,a=1,c={},u=!1,l=n.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(n);f=f&&f.setTimeout?f:n,"[object process]"==={}.toString.call(n.process)?o=function(t){_.nextTick(function(){p(t)})}:!function(){if(n.postMessage&&!n.importScripts){var t=!0,e=n.onmessage;return n.onmessage=function(){t=!1},n.postMessage("","*"),n.onmessage=e,t}}()?n.MessageChannel?((e=new MessageChannel).port1.onmessage=function(t){p(t.data)},o=function(t){e.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,o=function(t){var e=l.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):o=function(t){setTimeout(p,0,t)}:(s="setImmediate$"+Math.random()+"$",t=function(t){t.source===n&&"string"==typeof t.data&&0===t.data.indexOf(s)&&p(+t.data.slice(s.length))},n.addEventListener?n.addEventListener("message",t,!1):n.attachEvent("onmessage",t),o=function(t){n.postMessage(s+t,"*")}),f.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var r={callback:t,args:e};return c[a]=r,o(a),a++},f.clearImmediate=h}function h(t){delete c[t]}function p(t){if(u)setTimeout(p,0,t);else{var e=c[t];if(e){u=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(r,n)}}(e)}finally{h(t),u=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(e,n(11),n(45))},function(t,e,n){var r=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(r.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new o(r.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;0<=e&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(136),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(127),o=n(47),i=function(){function t(t,e){void 0===e&&(e={}),this._src=t,this._opts=e,this._opts.filters=r(o.default.DefaultOpts.filters)}return t.prototype.maxColorCount=function(t){return this._opts.colorCount=t,this},t.prototype.maxDimension=function(t){return this._opts.maxDimension=t,this},t.prototype.addFilter=function(t){return this._opts.filters.push(t),this},t.prototype.removeFilter=function(t){var e=this._opts.filters.indexOf(t);return 0<e&&this._opts.filters.splice(e),this},t.prototype.clearFilters=function(){return this._opts.filters=[],this},t.prototype.quality=function(t){return this._opts.quality=t,this},t.prototype.useImageClass=function(t){return this._opts.ImageClass=t,this},t.prototype.useGenerator=function(t){return this._opts.generator=t,this},t.prototype.useQuantizer=function(t){return this._opts.quantizer=t,this},t.prototype.build=function(){return new o.default(this._src,this._opts)},t.prototype.getPalette=function(t){return this.build().getPalette(t)},t.prototype.getSwatches=function(t){return this.build().getPalette(t)},t}();e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n,r){return 125<=r&&!(250<t&&250<e&&250<n)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(139);e.Default=r.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var u=n(46),l=n(10),f=n(39),h={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,weightPopulation:1};function p(a,t,c,u,l,f,h,p,_,d){var v=null,y=0;return t.forEach(function(t){var e,n,r=t.getHsl(),o=r[1],i=r[2];if(p<=o&&o<=_&&l<=i&&i<=f&&(n=t,(e=a).Vibrant!==n&&e.DarkVibrant!==n&&e.LightVibrant!==n&&e.Muted!==n&&e.DarkMuted!==n&&e.LightMuted!==n)){var s=function(t,e,n,r,o,i,s){function a(t,e){return 1-Math.abs(t-e)}return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=0,o=0;o<t.length;o+=2){var i=t[o],s=t[o+1];n+=i*s,r+=s}return n/r}(a(t,e),s.weightSaturation,a(n,r),s.weightLuma,o/i,s.weightPopulation)}(o,h,i,u,t.getPopulation(),c,d);(null===v||y<s)&&(v=t,y=s)}}),v}e.default=function(t,e){e=f({},e,h);var n,r,o,i,s,a=(n=0,t.forEach(function(t){n=Math.max(n,t.getPopulation())}),n),c=((s={}).Vibrant=p(s,r=t,o=a,(i=e).targetNormalLuma,i.minNormalLuma,i.maxNormalLuma,i.targetVibrantSaturation,i.minVibrantSaturation,1,i),s.LightVibrant=p(s,r,o,i.targetLightLuma,i.minLightLuma,1,i.targetVibrantSaturation,i.minVibrantSaturation,1,i),s.DarkVibrant=p(s,r,o,i.targetDarkLuma,0,i.maxDarkLuma,i.targetVibrantSaturation,i.minVibrantSaturation,1,i),s.Muted=p(s,r,o,i.targetNormalLuma,i.minNormalLuma,i.maxNormalLuma,i.targetMutesSaturation,0,i.maxMutesSaturation,i),s.LightMuted=p(s,r,o,i.targetLightLuma,i.minLightLuma,1,i.targetMutesSaturation,0,i.maxMutesSaturation,i),s.DarkMuted=p(s,r,o,i.targetDarkLuma,0,i.maxDarkLuma,i.targetMutesSaturation,0,i.maxMutesSaturation,i),s);return function(t,e,n){if(null===t.Vibrant&&null!==t.DarkVibrant){var r=t.DarkVibrant.getHsl(),o=r[0],i=r[1],s=r[2];s=n.targetNormalLuma,t.Vibrant=new u.Swatch(l.hslToRgb(o,i,s),0)}if(null===t.DarkVibrant&&null!==t.Vibrant){var a=t.Vibrant.getHsl();o=a[0],i=a[1],s=a[2],s=n.targetDarkLuma,t.DarkVibrant=new u.Swatch(l.hslToRgb(o,i,s),0)}}(c,0,e),c}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(141);e.Default=r.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){}return t.prototype.scaleDown=function(t){var e=this.getWidth(),n=this.getHeight(),r=1;if(0<t.maxDimension){var o=Math.max(e,n);o>t.maxDimension&&(r=t.maxDimension/o)}else r=1/t.quality;r<1&&this.resize(e*r,n*r,r)},t}();e.ImageBase=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var l=n(13),i=n(143),f=n(149);var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype._initCanvas=function(){var t=this.image,e=this._canvas=document.createElement("canvas"),n=this._context=e.getContext("2d");e.className="vibrant-canvas",e.style.visibility="hidden",this._width=e.width=t.width,this._height=e.height=t.height,n.drawImage(t,0,0),document.body.appendChild(e)},e.prototype.load=function(t){var e,n,r,o,i,s,a=this,c=null,u=null;if("string"==typeof t)c=document.createElement("img"),u=t;else{if(!(t instanceof HTMLImageElement))return l.reject(new Error("Cannot load buffer as an image in browser"));u=(c=t).src}return this.image=c,i=u,null===(s=f.parse(i)).protocol&&null===s.host&&null===s.port||(e=window.location.href,n=u,r=f.parse(e),o=f.parse(n),r.protocol===o.protocol&&r.hostname===o.hostname&&r.port===o.port)||(c.crossOrigin="anonymous"),"string"==typeof t&&(c.src=u),new l(function(t,e){var n=function(){a._initCanvas(),t(a)};c.onload=n,c.complete&&n(),c.onerror=function(t){return e(new Error("Fail to load image: "+u))}})},e.prototype.clear=function(){this._context.clearRect(0,0,this._width,this._height)},e.prototype.update=function(t){this._context.putImageData(t,0,0)},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e.prototype.resize=function(t,e,n){var r=this._canvas,o=this._context,i=this.image;this._width=r.width=t,this._height=r.height=e,o.scale(n,n),o.drawImage(i,0,0)},e.prototype.getPixelCount=function(){return this._width*this._height},e.prototype.getImageData=function(){return this._context.getImageData(0,0,this._width,this._height)},e.prototype.remove=function(){this._canvas.parentNode.removeChild(this._canvas)},e}(i.ImageBase);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(146);e.MMCQ=r.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var p=n(46),_=n(148),d=n(147);function v(t,e){for(var n=1,r=0;r<1e3;){r++;var o=t.pop();if(o.count()){var i=o.split(),s=i[0],a=i[1];if(t.push(s),a&&(t.push(a),n++),e<=n||1e3<r)return}}}e.default=function(t,s){if(0===t.length||s.colorCount<2||256<s.colorCount)throw new Error("Wrong MMCQ parameters");var e=null;Array.isArray(s.filters)&&0<s.filters.length&&(e=function(t,e,n,r){for(var o=0,i=s.filters;o<i.length;o++)if(!(0,i[o])(t,e,n,r))return!0;return!1});var n=_.default.build(t,e),r=n.hist,o=(Object.keys(r).length,new d.default(function(t,e){return t.count()-e.count()}));o.push(n),v(o,.75*s.colorCount);var i=new d.default(function(t,e){return t.count()*t.volume()-e.count()*e.volume()});i.contents=o.contents,v(i,s.colorCount-i.size());for(var a=[];i.size();){var c=i.pop(),u=c.avg(),l=u[0],f=u[1],h=u[2];null!==e&&e(l,f,h,255)||a.push(new p.Swatch(u,c.count()))}return a}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this._comparator=t,this.contents=[],this._sorted=!1}return t.prototype._sort=function(){this._sorted||(this.contents.sort(this._comparator),this._sorted=!0)},t.prototype.push=function(t){this.contents.push(t),this._sorted=!1},t.prototype.peek=function(t){return this._sort(),t="number"==typeof t?t:this.contents.length-1,this.contents[t]},t.prototype.pop=function(){return this._sort(),this.contents.pop()},t.prototype.size=function(){return this.contents.length},t.prototype.map=function(t){return this._sort(),this.contents.map(t)},t}();e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var E=n(10),r=function(){function y(t,e,n,r,o,i,s){this._volume=-1,this._count=-1,this.dimension={r1:t,r2:e,g1:n,g2:r,b1:o,b2:i},this.hist=s}return y.build=function(t,e){var n,r,o,i,s,a,c,u,l,f,h=1<<3*E.SIGBITS,p=new Uint32Array(h);n=o=s=0,r=i=a=Number.MAX_VALUE;for(var _=t.length/4,d=0;d<_;){var v=4*d;if(d++,c=t[v+0],u=t[v+1],l=t[v+2],f=t[v+3],"function"!=typeof e||!e(c,u,l,f))c>>=E.RSHIFT,u>>=E.RSHIFT,l>>=E.RSHIFT,p[E.getColorIndex(c,u,l)]+=1,n<c&&(n=c),c<r&&(r=c),o<u&&(o=u),u<i&&(i=u),s<l&&(s=l),l<a&&(a=l)}return new y(r,n,i,o,a,s,p)},y.prototype.invalidate=function(){this._volume=this._count=-1,this._avg=null},y.prototype.volume=function(){if(this._volume<0){var t=this.dimension,e=t.r1,n=t.r2,r=t.g1,o=t.g2,i=t.b1,s=t.b2;this._volume=(n-e+1)*(o-r+1)*(s-i+1)}return this._volume},y.prototype.count=function(){if(this._count<0){for(var t=this.hist,e=this.dimension,n=e.r1,r=e.r2,o=e.g1,i=e.g2,s=e.b1,a=e.b2,c=0,u=n;u<=r;u++)for(var l=o;l<=i;l++)for(var f=s;f<=a;f++){c+=t[E.getColorIndex(u,l,f)]}this._count=c}return this._count},y.prototype.clone=function(){var t=this.hist,e=this.dimension;return new y(e.r1,e.r2,e.g1,e.g2,e.b1,e.b2,t)},y.prototype.avg=function(){if(!this._avg){var t=this.hist,e=this.dimension,n=e.r1,r=e.r2,o=e.g1,i=e.g2,s=e.b1,a=e.b2,c=0,u=1<<8-E.SIGBITS,l=void 0,f=void 0,h=void 0;l=f=h=0;for(var p=n;p<=r;p++)for(var _=o;_<=i;_++)for(var d=s;d<=a;d++){var v=t[E.getColorIndex(p,_,d)];c+=v,l+=v*(p+.5)*u,f+=v*(_+.5)*u,h+=v*(d+.5)*u}this._avg=c?[~~(l/c),~~(f/c),~~(h/c)]:[~~(u*(n+r+1)/2),~~(u*(o+i+1)/2),~~(u*(s+a+1)/2)]}return this._avg},y.prototype.contains=function(t){var e=t[0],n=t[1],r=t[2],o=this.dimension,i=o.r1,s=o.r2,a=o.g1,c=o.g2,u=o.b1,l=o.b2;return e>>=E.RSHIFT,n>>=E.RSHIFT,r>>=E.RSHIFT,i<=e&&e<=s&&a<=n&&n<=c&&u<=r&&r<=l},y.prototype.split=function(){var t=this.hist,e=this.dimension,n=e.r1,r=e.r2,o=e.g1,i=e.g2,s=e.b1,a=e.b2,c=this.count();if(!c)return[];if(1===c)return[this.clone()];var u,l,f=r-n+1,h=i-o+1,p=a-s+1,_=Math.max(f,h,p),d=null;u=l=0;var v=null;if(_===f){v="r",d=new Uint32Array(r+1);for(var y=n;y<=r;y++){u=0;for(var m=o;m<=i;m++)for(var g=s;g<=a;g++){u+=t[E.getColorIndex(y,m,g)]}l+=u,d[y]=l}}else if(_===h){v="g",d=new Uint32Array(i+1);for(m=o;m<=i;m++){u=0;for(y=n;y<=r;y++)for(g=s;g<=a;g++){u+=t[E.getColorIndex(y,m,g)]}l+=u,d[m]=l}}else{v="b",d=new Uint32Array(a+1);for(g=s;g<=a;g++){u=0;for(y=n;y<=r;y++)for(m=o;m<=i;m++){u+=t[E.getColorIndex(y,m,g)]}l+=u,d[g]=l}}for(var b=-1,w=new Uint32Array(d.length),j=0;j<d.length;j++){var x=d[j];b<0&&l/2<x&&(b=j),w[j]=l-x}var C=this;return function(t){var e=t+"1",n=t+"2",r=C.dimension[e],o=C.dimension[n],i=C.clone(),s=C.clone(),a=b-r,c=o-b;for(a<=c?(o=Math.min(o-1,~~(b+c/2)),o=Math.max(0,o)):(o=Math.max(r,~~(b-1-a/2)),o=Math.min(C.dimension[n],o));!d[o];)o++;for(var u=w[o];!u&&d[o-1];)u=w[--o];return i.dimension[n]=o,s.dimension[e]=o+1,[i,s]}(v)},y}();e.default=r},function(t,e,n){"use strict";var R=n(132),I=n(150);function F(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=i,e.resolve=function(t,e){return i(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?i(t,!1,!0).resolveObject(e):e},e.format=function(t){I.isString(t)&&(t=i(t));return t instanceof F?t.format():F.prototype.format.call(t)},e.Url=F;var D=/^([a-z0-9.+-]+:)/i,r=/:[0-9]*$/,M=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,o=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),L=["'"].concat(o),U=["%","/","?",";","#"].concat(L),V=["/","?","#"],N=/^[+a-z0-9A-Z_-]{0,63}$/,H=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,q={javascript:!0,"javascript:":!0},B={javascript:!0,"javascript:":!0},z={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},$=n(135);function i(t,e,n){if(t&&I.isObject(t)&&t instanceof F)return t;var r=new F;return r.parse(t,e,n),r}F.prototype.parse=function(t,e,n){if(!I.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var r=t.indexOf("?"),o=-1!==r&&r<t.indexOf("#")?"?":"#",i=t.split(o);i[0]=i[0].replace(/\\/g,"/");var s=t=i.join(o);if(s=s.trim(),!n&&1===t.split("#").length){var a=M.exec(s);if(a)return this.path=s,this.href=s,this.pathname=a[1],a[2]?(this.search=a[2],this.query=e?$.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var c=D.exec(s);if(c){var u=(c=c[0]).toLowerCase();this.protocol=u,s=s.substr(c.length)}if(n||c||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var l="//"===s.substr(0,2);!l||c&&B[c]||(s=s.substr(2),this.slashes=!0)}if(!B[c]&&(l||c&&!z[c])){for(var f,h,p=-1,_=0;_<V.length;_++){-1!==(d=s.indexOf(V[_]))&&(-1===p||d<p)&&(p=d)}-1!==(h=-1===p?s.lastIndexOf("@"):s.lastIndexOf("@",p))&&(f=s.slice(0,h),s=s.slice(h+1),this.auth=decodeURIComponent(f)),p=-1;for(_=0;_<U.length;_++){var d;-1!==(d=s.indexOf(U[_]))&&(-1===p||d<p)&&(p=d)}-1===p&&(p=s.length),this.host=s.slice(0,p),s=s.slice(p),this.parseHost(),this.hostname=this.hostname||"";var v="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!v)for(var y=this.hostname.split(/\./),m=(_=0,y.length);_<m;_++){var g=y[_];if(g&&!g.match(N)){for(var b="",w=0,j=g.length;w<j;w++)127<g.charCodeAt(w)?b+="x":b+=g[w];if(!b.match(N)){var x=y.slice(0,_),C=y.slice(_+1),E=g.match(H);E&&(x.push(E[1]),C.unshift(E[2])),C.length&&(s="/"+C.join(".")+s),this.hostname=x.join(".");break}}}255<this.hostname.length?this.hostname="":this.hostname=this.hostname.toLowerCase(),v||(this.hostname=R.toASCII(this.hostname));var k=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+k,this.href+=this.host,v&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!q[u])for(_=0,m=L.length;_<m;_++){var T=L[_];if(-1!==s.indexOf(T)){var O=encodeURIComponent(T);O===T&&(O=escape(T)),s=s.split(T).join(O)}}var S=s.indexOf("#");-1!==S&&(this.hash=s.substr(S),s=s.slice(0,S));var A=s.indexOf("?");if(-1!==A?(this.search=s.substr(A),this.query=s.substr(A+1),e&&(this.query=$.parse(this.query)),s=s.slice(0,A)):e&&(this.search="",this.query={}),s&&(this.pathname=s),z[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){k=this.pathname||"";var P=this.search||"";this.path=k+P}return this.href=this.format(),this},F.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,i="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&I.isObject(this.query)&&Object.keys(this.query).length&&(i=$.stringify(this.query));var s=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||z[e])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),e+o+(n=n.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(s=s.replace("#","%23"))+r},F.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},F.prototype.resolveObject=function(t){if(I.isString(t)){var e=new F;e.parse(t,!1,!0),t=e}for(var n=new F,r=Object.keys(this),o=0;o<r.length;o++){var i=r[o];n[i]=this[i]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),a=0;a<s.length;a++){var c=s[a];"protocol"!==c&&(n[c]=t[c])}return z[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!z[t.protocol]){for(var u=Object.keys(t),l=0;l<u.length;l++){var f=u[l];n[f]=t[f]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||B[t.protocol])n.pathname=t.pathname;else{for(var h=(t.pathname||"").split("/");h.length&&!(t.host=h.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==h[0]&&h.unshift(""),h.length<2&&h.unshift(""),n.pathname=h.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search){var p=n.pathname||"",_=n.search||"";n.path=p+_}return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var d=n.pathname&&"/"===n.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),y=v||d||n.host&&t.pathname,m=y,g=n.pathname&&n.pathname.split("/")||[],b=(h=t.pathname&&t.pathname.split("/")||[],n.protocol&&!z[n.protocol]);if(b&&(n.hostname="",n.port=null,n.host&&(""===g[0]?g[0]=n.host:g.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===h[0]?h[0]=t.host:h.unshift(t.host)),t.host=null),y=y&&(""===h[0]||""===g[0])),v)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,g=h;else if(h.length)g||(g=[]),g.pop(),g=g.concat(h),n.search=t.search,n.query=t.query;else if(!I.isNullOrUndefined(t.search)){if(b)n.hostname=n.host=g.shift(),(E=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=E.shift(),n.host=n.hostname=E.shift());return n.search=t.search,n.query=t.query,I.isNull(n.pathname)&&I.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!g.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var w=g.slice(-1)[0],j=(n.host||t.host||1<g.length)&&("."===w||".."===w)||""===w,x=0,C=g.length;0<=C;C--)"."===(w=g[C])?g.splice(C,1):".."===w?(g.splice(C,1),x++):x&&(g.splice(C,1),x--);if(!y&&!m)for(;x--;x)g.unshift("..");!y||""===g[0]||g[0]&&"/"===g[0].charAt(0)||g.unshift(""),j&&"/"!==g.join("/").substr(-1)&&g.push("");var E,k=""===g[0]||g[0]&&"/"===g[0].charAt(0);b&&(n.hostname=n.host=k?"":g.length?g.shift():"",(E=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=E.shift(),n.host=n.hostname=E.shift()));return(y=y||n.host&&g.length)&&!k&&g.unshift(""),g.length?n.pathname=g.join("/"):(n.pathname=null,n.path=null),I.isNull(n.pathname)&&I.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},F.prototype.parseHost=function(){var t=this.host,e=r.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,n){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(48);("object"==typeof window&&window instanceof Window?window:t.exports).Vibrant=r}]);

(function() {
    'use strict';

    $('body').append(`<style>
    #channel-header.ytd-c4-tabbed-header-renderer {
      padding-bottom: 12px;
    }
    app-header paper-button.ytd-subscribe-button-renderer {
      box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    }
    app-header ytd-toggle-button-renderer #button.ytd-toggle-button-renderer {
      color: var(--yt-lightsource-primary-title-color);
    }
    ytd-expandable-tab-renderer {
      color: var(--yt-lightsource-secondary-title-color);
    }
    ytd-expandable-tab-renderer[show-input] {
      color: var(--yt-lightsource-primary-title-color);
    }
    paper-input.ytd-expandable-tab-renderer {
      --paper-input-container-color: var(--yt-lightsource-primary-title-color);
      --paper-input-container-input-color: var(--yt-lightsource-primary-title-color);
      --paper-input-container-focus-color: var(--yt-lightsource-primary-title-color);
    }
    app-header::before {
      opacity: 0.5;
    }
    app-toolbar > #tabs-container.ytd-c4-tabbed-header-renderer > #tabs-inner-container.ytd-c4-tabbed-header-renderer::after {
      position: absolute;
      content: '';
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.075);
      pointer-events: none;
    }
    </style>`);

    // Helpers
    let _parseHex = function(_ar) {
        return "#" +
            ("0" + parseInt(_ar[0],10).toString(16)).slice(-2) +
            ("0" + parseInt(_ar[1],10).toString(16)).slice(-2) +
            ("0" + parseInt(_ar[2],10).toString(16)).slice(-2);
    };
    let _isDark = function(_cl, level) {
        let cl = _cl.substring(1);  // Remove #
        let rgb = parseInt(cl, 16); // Convert hex to decimal
        let r = (rgb >> 16) & 0xff; // Extract red
        let g = (rgb >>  8) & 0xff; // Extract green
        let b = (rgb >>  0) & 0xff; // Extract blue

        let luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // ITU-R BT.709

        if (luma < level) {
            return true;
        } else {
            return false;
        }
    };
    let defaults = {
        headerSelector: 'app-header',
        mainSelector: '#channel-container.ytd-c4-tabbed-header-renderer, #tabs-container.ytd-c4-tabbed-header-renderer',
        imgSelector: '#backgroundFrontLayer.app-header',
        backgroundColor: '--yt-lightsource-section1-color',
        primaryTitleColor: '--yt-lightsource-primary-title-color',
        secondaryTitleColor: '--yt-lightsource-secondary-title-color',
        lightBackgroundColor: '#FAFAFA',
        lightPrimary: '#0A0A0A',
        lightSecondary: '#606060',
        darkBackgroundColor: '#1A1A1A',
        darkPrimary: '#FFFFFF',
        darkSecondary: 'rgba(255, 255, 255, 0.87)'
    };
    // Main
    function runSet() {
        // Init
        let $header = $(defaults.headerSelector);
        //const $main = $(defaults.mainSelector);
        let $img = $(defaults.imgSelector);
        let bgImg = $img.css('background-image');
        let imgUrl = (bgImg) ? bgImg.replace('url(','').replace(')','').replace(/\"/gi, "") : null; // Remove url(...)

        // Fetching colors
        if (imgUrl !== null) Vibrant.from(imgUrl, {quality: 7, colorCount: 32}).getPalette().then(function(palette) {
            console.log(palette);
            const fetchedColors = {
                bgColor: (palette.Vibrant !== null) ? _parseHex(palette.Vibrant._rgb) : (palette.Muted !== null) ? _parseHex(palette.Muted._rgb) : defaults.lightBackgroundColor
            };
            replaceColor(fetchedColors);
        });

        function replaceColor(fetchedColors) {
            let $style = $header.get(0).style;
            let isDark = _isDark(fetchedColors.bgColor, 188);

            let styleColors = {
                bg: fetchedColors.bgColor,
                primary: (isDark) ? defaults.darkPrimary : defaults.lightPrimary,
                secondary: (isDark) ? defaults.darkSecondary : defaults.lightSecondary
            }

            $style.setProperty(defaults.backgroundColor, styleColors.bg);
            $style.setProperty(defaults.primaryTitleColor, styleColors.primary);
            $style.setProperty(defaults.secondaryTitleColor, styleColors.secondary);
        }
    }

    // Events
    if (window.location.pathname != '/') runSet(); // Don't run on main YT page
    document.body.addEventListener("yt-navigate-finish", function() { // When navigate to new pages
        if (window.location.pathname != '/') runSet();
    });
})();