define(["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n="fulfilled",r="pending",i="rejected",o=(s.attempt=function(e){return new s(function(t){t(e())})},s.race=function(o){return new s(function(t,e){for(var n=0,r=o;n<r.length;n++){var i=r[n];"object"==typeof i&&"function"==typeof i.then?i.then(t,e):t(i)}})},s.prototype.finally=function(e){function n(t){return Promise.resolve(e()).then(t)}return this.then(function(t){return n(function(){return t})},function(t){return n(function(){return Promise.reject(t)})})},s.prototype.then=function(e,n){function r(t){return o._state="fulfilled",o._value=t,e(t)}function i(t){return o._state="rejected",o._reason=t,n(t)}var o=this;return new s(function(t){return t(o._promise.then(r,i))})},s.prototype.isFulfilled=function(){return this._state===n},s.prototype.isPending=function(){return this._state===r},s.prototype.isRejected=function(){return this._state===i},s.prototype.isResolved=function(){return this._state!==r},s.prototype.reason=function(){if(this._state!==i)throw new Error("Attempting to read failure reason from a Task that is not rejected. This Task is "+this._state+".");return this._reason},s.prototype.value=function(){if(this._state!==n)throw new Error("Attempting to read value from a Task that is not resolved. This Task is "+this._state+".");return this._value},s);function s(t){this._promise=new Promise(t),this._state="pending"}e.Task=o});