!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function o(){}function n(t){if(!(this instanceof n))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=undefined;this._deferreds=[];e(t,this)}function f(r,u){for(;3===r._state;)r=r._value;0!==r._state?(r._handled=!0,n._immediateFn(function(){var n=1===r._state?u.onFulfilled:u.onRejected,f;if(null!==n){try{f=n(r._value)}catch(e){return void t(u.promise,e)}i(u.promise,f)}else(1===r._state?i:t)(u.promise,r._value)})):r._deferreds.push(u)}function i(i,u){try{if(u===i)throw new TypeError("A promise cannot be resolved with itself.");if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if(u instanceof n)return i._state=3,i._value=u,void r(i);if("function"==typeof f)return void e(function(n,t){return function(){n.apply(t,arguments)}}(f,u),i)}i._state=1;i._value=u;r(i)}catch(o){t(i,o)}}function t(n,t){n._state=2;n._value=t;r(n)}function r(t){2===t._state&&0===t._deferreds.length&&n._immediateFn(function(){t._handled||n._unhandledRejectionFn(t._value)});for(var i=0,r=t._deferreds.length;r>i;i++)f(t,t._deferreds[i]);t._deferreds=null}function e(n,r){var u=!1;try{n(function(n){u||(u=!0,i(r,n))},function(n){u||(u=!0,t(r,n))})}catch(f){if(u)return;u=!0;t(r,f)}}var s=setTimeout,u;n.prototype["catch"]=function(n){return this.then(null,n)};n.prototype.then=function(n,t){var i=new this.constructor(o);return f(this,new function(n,t,i){this.onFulfilled="function"==typeof n?n:null;this.onRejected="function"==typeof t?t:null;this.promise=i}(n,t,i)),i};n.prototype["finally"]=function(n){var t=this.constructor;return this.then(function(i){return t.resolve(n()).then(function(){return i})},function(i){return t.resolve(n()).then(function(){return t.reject(i)})})};n.all=function(t){return new n(function(n,i){function f(t,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var o=u.then;if("function"==typeof o)return void o.call(u,function(n){f(t,n)},i)}r[t]=u;0==--e&&n(r)}catch(s){i(s)}}var r,e,u;if(!t||"undefined"==typeof t.length)throw new TypeError("Promise.all accepts an array");if(r=Array.prototype.slice.call(t),0===r.length)return n([]);for(e=r.length,u=0;r.length>u;u++)f(u,r[u])})};n.resolve=function(t){return t&&"object"==typeof t&&t.constructor===n?t:new n(function(n){n(t)})};n.reject=function(t){return new n(function(n,i){i(t)})};n.race=function(t){return new n(function(n,i){for(var r=0,u=t.length;u>r;r++)t[r].then(n,i)})};n._immediateFn="function"==typeof setImmediate&&function(n){setImmediate(n)}||function(n){s(n,0)};n._unhandledRejectionFn=function(n){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",n)};u=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object");}();u.Promise||(u.Promise=n)})