!function(e){function o(){}function r(e){if("object"!=typeof this)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=void 0,this._deferreds=[],a(e,this)}function i(t,o){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(o):(t._handled=!0,void r._immediateFn(function(){var e=1===t._state?o.onFulfilled:o.onRejected;if(null!==e){var n;try{n=e(t._value)}catch(e){return void f(o.promise,e)}u(o.promise,n)}else(1===t._state?u:f)(o.promise,t._value)}))}function u(n,e){try{if(e===n)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if(e instanceof r)return n._state=3,n._value=e,void c(n);if("function"==typeof t)return void a(function(e,n){return function(){e.apply(n,arguments)}}(t,e),n)}n._state=1,n._value=e,c(n)}catch(e){f(n,e)}}function f(e,n){e._state=2,e._value=n,c(e)}function c(e){2===e._state&&0===e._deferreds.length&&r._immediateFn(function(){e._handled||r._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n