(function(v,w){"object"===typeofexports&&"undefined"!==typeofmodule?module.exports=w():"function"===typeofdefine&&define.amd?define(w):v.ES6Promise=w()})(this,function(){functionv(a){return"function"===typeofa}functionw(){returnfunction(){returnprocess.nextTick(n)}}functionR(){return"undefined"!==typeofB?function(){B(n)}:C()}functionS(){vara=0,b=newJ(n),c=document.createTextNode("");b.observe(c,{characterData:!0});returnfunction(){c.data=a=++a%2}}functionT(){vara=newMessageChannel;a.port1.onmessage=n;returnfunction(){returna.port2.postMessage(0)}}functionC(){vara=setTimeout;returnfunction(){returna(n,1)}}functionn(){for(vara=0;a<k;a+=2)(0,q[a])(q[a+1]),q[a]=void0,q[a+1]=void0;k=0}functionU(){try{vara=Function("return this")().require("vertx");B=a.runOnLoop||a.runOnContext;returnR()}catch(b){returnC()}}functionD(a,b){varc=this,d=newthis.constructor(r);void0===d[z]&&K(d);vare=c._state;if(e){varf=arguments[e-1];l(function(){returnL(e,d,f,c._result)})}elseE(c,d,a,b);returnd}functionF(a){if(a&&"object"===typeofa&&a.constructor===this)returna;varb=newthis(r);x(b,a);returnb}functionr(){}functionM(a){try{returna.then}catch(b){returnp.error=b,p}}functionV(a,b,c,d){try{a.call(b,c,d)}catch(e){returne}}functionW(a,b,c){l(function(a){vare=!1,f=V(c,b,function(c){e||(e=!0,b!==c?x(a,c):m(a,c))},function(b){e||(e=!0,g(a,b))},"Settle: "+(a._label||" unknown promise"));!e&&f&&(e=!0,g(a,f))},a)}functionX(a,b){b._state===y?m(a,b._result):b._state===t?g(a,b._result):E(b,void0,function(b){returnx(a,b)},function(b){returng(a,b)})}functionN(a,b,c){b.constructor===a.constructor&&c===D&&b.constructor.resolve===F?X(a,b):c===p?(g(a,p.error),p.error=null):void0===c?m(a,b):v(c)?W(a,b,c):m(a,b)}functionx(a,b){if(a===b)g(a,newTypeError("You cannot resolve a promise with itself"));else{varc=typeofb;null===b||"object"!==c&&"function"!==c?m(a,b):N(a,b,M(b))}}functionY(a){a._onerror&&a._onerror(a._result);G(a)}functionm(a,b){a._state===u&&(a._result=b,a._state=y,0!==a._subscribers.length&&l(G,a))}functiong(a,b){a._state===u&&(a._state=t,a._result=b,l(Y,a))}functionE(a,b,c,d){vare=a._subscribers,f=e.length;a._onerror=null;e[f]=b;e[f+y]=c;e[f+t]=d;0===f&&a._state&&l(G,a)}functionG(a){varb=a._subscribers,c=a._state;if(0!==b.length){for(vard=void0,e=void0,f=a._result,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?L(c,d,e,f):e(f);a._subscribers.length=0}}functionL(a,b,c,d){vare=v(c),f=void0,h=void0,k=void0,l=void0;if(e){try{f=c(d)}catch(n){p.error=n,f=p}f===p?(l=!0,h=f.error,f.error=null):k=!0;if(b===f){g(b,newTypeError("A promises callback cannot return that same promise."));return}}elsef=d,k=!0;b._state===u&&(e&&k?x(b,f):l?g(b,h):a===y?m(b,f):a===t&&g(b,f))}functionZ(a,b){try{b(function(b){x(a,b)},function(b){g(a,b)})}catch(c){g(a,c)}}functionK(a){a[z]=O++;a._state=void0;a._result=void0;a._subscribers=[]}varH=void0,P=H=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},k=0,B=void0,I=void0,l=function(a,b){q[k]=a;q[k+1]=b;k+=2;2===k&&(I?I(n):Q())},A=(H="undefined"!==typeofwindow?window:void0)||{},J=A.MutationObserver||A.WebKitMutationObserver,A="undefined"===typeofself&&"undefined"!==typeofprocess&&"[object process]"==={}.toString.call(process),aa="undefined"!==typeofUint8ClampedArray&&"undefined"!==typeofimportScripts&&"undefined"!==typeofMessageChannel,q=Array(1E3),Q=void0,Q=A?w():J?S():aa?T():void0===H&&"function"===typeofrequire?U():C(),z=Math.random().toString(36).substring(2),u=void0,y=1,t=2,p={error:null},O=0,ba=function(){functiona(a,c){this._instanceConstructor=a;this.promise=newa(r);this.promise[z]||K(this.promise);P(c)?(this._remaining=this.length=c.length,this._result=Array(this.length),0===this.length?m(this.promise,this._result):(this.length=this.length||0,this._enumerate(c),0===this._remaining&&m(this.promise,this._result))):g(this.promise,Error("Array Methods must be provided an Array"))}a.prototype._enumerate=function(a){for(varc=0;this._state===u&&c<a.length;c++)this._eachEntry(a[c],c)};a.prototype._eachEntry=function(a,c){vard=this._instanceConstructor,e=d.resolve;e===F?(e=M(a),e===D&&a._state!==u?this._settledAt(a._state,c,a._result):"function"!==typeofe?(this._remaining--,this._result[c]=a):d===h?(d=newd(r),N(d,a,e),this._willSettleAt(d,c)):this._willSettleAt(newd(function(c){returnc(a)}),c)):this._willSettleAt(e(a),c)};a.prototype._settledAt=function(a,c,d){vare=this.promise;e._state===u&&(this._remaining--,a===t?g(e,d):this._result[c]=d);0===this._remaining&&m(e,this._result)};a.prototype._willSettleAt=function(a,c){vard=this;E(a,void0,function(a){returnd._settledAt(y,c,a)},function(a){returnd._settledAt(t,c,a)})};returna}(),h=function(){functiona(b){this[z]=O++;this._result=this._state=void0;this._subscribers=[];if(r!==b){if("function"!==typeofb)thrownewTypeError("You must pass a resolver function as the first argument to the promise constructor");if(thisinstanceofa)Z(this,b);elsethrownewTypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");}}a.prototype["catch"]=function(a){returnthis.then(null,a)};a.prototype["finally"]=function(a){varc=this.constructor;returnv(a)?this.then(function(d){returnc.resolve(a()).then(function(){returnd})},function(d){returnc.resolve(a()).then(function(){throwd;})}):this.then(a,a)};returna}();h.prototype.then=D;h.all=function(a){return(newba(this,a)).promise};h.race=function(a){varb=this;returnP(a)?newb(function(c,d){for(vare=a.length,f=0;f<e;f++)b.resolve(a[f]).then(c,d)}):newb(function(a,b){returnb(newTypeError("You must pass an array to race."))})};h.resolve=F;h.reject=function(a){varb=newthis(r);g(b,a);returnb};h._setScheduler=function(a){I=a};h._setAsap=function(a){l=a};h._asap=l;h.polyfill=function(){vara=void0;if("undefined"!==typeofglobal)a=global;elseif("undefined"!==typeofself)a=self;elsetry{a=Function("return this")()}catch(b){throwError("polyfill failed because global object is unavailable in this environment");}varc=a.Promise;if(c){vard=null;try{d=Object.prototype.toString.call(c.resolve())}catch(e){}if("[object Promise]"===d&&!c.cast)return}a.Promise=h};returnh.Promise=h});