!function(e){("object"!=typeof exports||"undefined"==typeof module)&&"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(t){var n=this.constructor;return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){return n.reject(e)})})}function t(n){return new this(function(o,e){if(!n||"undefined"==typeof n.length)return e(new TypeError(typeof n+" "+n+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(n);if(0===r.length)return o([]);var i=r.length;for(var t=0;t<r.length;t++)!function f(t,e){if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if("function"==typeof n)return void n.call(e,function(e){f(t,e)},function(e){r[t]={status:"rejected",reason:e},0==--i&&o(r)})}r[t]={status:"fulfilled",value:e},0==--i&&o(r)}(t,r[t])})}var n=setTimeout;function l(e){return e&&"undefined"!=typeof e.length}function o(){}function f(e){if(!(this instanceof f))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],s(e,this)}function r(o,r){for(;3===o._state;)o=o._value;0!==o._state?(o._handled=!0,f._immediateFn(function(){var e,t=1===o._state?r.onFulfilled:r.onRejected;if(null!==t){try{e=t(o._value)}catch(n){return void u(r.promise,n)}i(r.promise,e)}else(1===o._state?i:u)(r.promise,o._value)})):o._deferreds.push(r)}function i(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if(t instanceof f)return e._state=3,e._value=t,void c(e);if("function"==typeof n)return void s((o=n,r=t,function(){o.apply(r,arguments)}),e)}e._state=1,e._value=t,c(e)}catch(i){u(e,i)}var o,r}function u(e,t){e._state=2,e._value=t,c(e)}function c(e){2===e._state&&0===e._deferreds.length&&f._immediateFn(function(){e._handled||f._unhandledRejectionFn(e._value)});for(var t=0,n=e._deferreds.length;t<n;t++)r(e,e._deferreds[t]);e._deferreds=null}function a(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function s(e,t){var n=!1;try{e(function(e){n||(n=!0,i(t,e))},function(e){n||(n=!0,u(t,e))})}catch(o){if(n)return;n=!0,u(t,o)}}f.prototype["catch"]=function(e){return this.then(null,e)},f.prototype.then=function(e,t){var n=new this.constructor(o);return r(this,new a(e,t,n)),n},f.prototype["finally"]=e,f.all=function(t){return new f(function(r,i){if(!l(t))return i(new TypeError("Promise.all accepts an array"));var f=Array.prototype.slice.call(t);if(0===f.length)return r([]);var u=f.length;function c(t,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if("function"==typeof n)return void n.call(e,function(e){c(t,e)},i)}f[t]=e,0==--u&&r(f)}catch(o){i(o)}}for(var e=0;e<f.length;e++)c(e,f[e])})},f.allSettled=t,f.resolve=function(t){return t&&"object"==typeof t&&t.constructor===f?t:new f(function(e){e(t)})},f.reject=function(n){return new f(function(e,t){t(n)})},f.race=function(r){return new f(function(e,t){if(!l(r))return t(new TypeError("Promise.race accepts an array"));for(var n=0,o=r.length;n<o;n++)f.resolve(r[n]).then(e,t)})},f._immediateFn="function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){n(e,0)},f._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var d=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")}();"function"!=typeof d.Promise?d.Promise=f:d.Promise.prototype["finally"]?d.Promise.allSettled||(d.Promise.allSettled=t):d.Promise.prototype["finally"]=e});