!function(name,context,definition){context[name]=definition(),"undefined"!=typeofmodule&&module.exports?module.exports=context[name]:"function"==typeofdefine&&define.amd&&define(function(){returncontext[name]})}("Promise","undefined"!=typeofglobal?global:this,function(){"use strict";functionschedule(fn,self){scheduling_queue.add(fn,self),cycle||(cycle=timer(scheduling_queue.drain))}functionisThenable(o){var_then,o_type=typeofo;returnnull==o||"object"!=o_type&&"function"!=o_type||(_then=o.then),"function"==typeof_then&&_then}functionnotify(){for(vari=0;i<this.chain.length;i++)notifyIsolated(this,1===this.state?this.chain[i].success:this.chain[i].failure,this.chain[i]);this.chain.length=0}functionnotifyIsolated(self,cb,chain){varret,_then;try{cb===!1?chain.reject(self.msg):(ret=cb===!0?self.msg:cb.call(void0,self.msg),ret===chain.promise?chain.reject(TypeError("Promise-chain cycle")):(_then=isThenable(ret))?_then.call(ret,chain.resolve,chain.reject):chain.resolve(ret))}catch(err){chain.reject(err)}}functionresolve(msg){var_then,self=this;if(!self.triggered){self.triggered=!0,self.def&&(self=self.def);try{(_then=isThenable(msg))?schedule(function(){vardef_wrapper=newMakeDefWrapper(self);try{_then.call(msg,function(){resolve.apply(def_wrapper,arguments)},function(){reject.apply(def_wrapper,arguments)})}catch(err){reject.call(def_wrapper,err)}}):(self.msg=msg,self.state=1,self.chain.length>0&&schedule(notify,self))}catch(err){reject.call(newMakeDefWrapper(self),err)}}}functionreject(msg){varself=this;self.triggered||(self.triggered=!0,self.def&&(self=self.def),self.msg=msg,self.state=2,self.chain.length>0&&schedule(notify,self))}functioniteratePromises(Constructor,arr,resolver,rejecter){for(varidx=0;idx<arr.length;idx++)!function(idx){Constructor.resolve(arr[idx]).then(function(msg){resolver(idx,msg)},rejecter)}(idx)}functionMakeDefWrapper(self){this.def=self,this.triggered=!1}functionMakeDef(self){this.promise=self,this.state=0,this.triggered=!1,this.chain=[],this.msg=void0}functionPromise(executor){if("function"!=typeofexecutor)throwTypeError("Not a function");if(0!==this.__NPO__)throwTypeError("Not a promise");this.__NPO__=1;vardef=newMakeDef(this);this.then=function(success,failure){varo={success:"function"!=typeofsuccess||success,failure:"function"==typeoffailure&&failure};returno.promise=newthis.constructor(function(resolve,reject){if("function"!=typeofresolve||"function"!=typeofreject)throwTypeError("Not a function");o.resolve=resolve,o.reject=reject}),def.chain.push(o),0!==def.state&&schedule(notify,def),o.promise},this.catch=function(failure){returnthis.then(void0,failure)};try{executor.call(void0,function(msg){resolve.call(def,msg)},function(msg){reject.call(def,msg)})}catch(err){reject.call(def,err)}}varbuiltInProp,cycle,scheduling_queue,ToString=Object.prototype.toString,timer="undefined"!=typeofsetImmediate?function(fn){returnsetImmediate(fn)}:setTimeout;try{Object.defineProperty({},"x",{}),builtInProp=function(obj,name,val,config){returnObject.defineProperty(obj,name,{value:val,writable:!0,configurable:config!==!1})}}catch(err){builtInProp=function(obj,name,val){returnobj[name]=val,obj}}scheduling_queue=function(){functionItem(fn,self){this.fn=fn,this.self=self,this.next=void0}varfirst,last,item;return{add:function(fn,self){item=newItem(fn,self),last?last.next=item:first=item,last=item,item=void0},drain:function(){varf=first;for(first=last=cycle=void0;f;)f.fn.call(f.self),f=f.next}}}();varPromisePrototype=builtInProp({},"constructor",Promise,!1);returnPromise.prototype=PromisePrototype,builtInProp(PromisePrototype,"__NPO__",0,!1),builtInProp(Promise,"resolve",function(msg){varConstructor=this;returnmsg&&"object"==typeofmsg&&1===msg.__NPO__?msg:newConstructor(function(resolve,reject){if("function"!=typeofresolve||"function"!=typeofreject)throwTypeError("Not a function");resolve(msg)})}),builtInProp(Promise,"reject",function(msg){returnnewthis(function(resolve,reject){if("function"!=typeofresolve||"function"!=typeofreject)throwTypeError("Nota