YUI.add("promise",function(t,e){var c=t.Lang,n=[].slice;function i(t){if(!(this instanceof i))return new i(t);var e=new i.Resolver(this);this._resolver=e;try{t.call(this,function(t){e.resolve(t)},function(t){e.reject(t)})}catch(n){e.reject(n)}}function r(t){this._callbacks=[],this._errbacks=[],this.promise=t,this._status="pending",this._result=null}t.mix(i.prototype,{then:function(n,r){var t=this.constructor,s=this._resolver;return new t(function(t,e){s._addCallbacks("function"==typeof n?i._wrap(t,e,n):t,"function"==typeof r?i._wrap(t,e,r):e)})},"catch":function(t){return this.then(undefined,t)},getStatus:function(){return this._resolver.getStatus()}}),i._wrap=function(r,s,i){return function(t){var e;try{e=i(t)}catch(n){return void s(n)}r(e)}},i.isPromise=function(t){var e;try{e=t.then}catch(n){}return"function"==typeof e},i.resolve=function(e){return i.isPromise(e)&&e.constructor===this?e:new this(function(t){t(e)})},i.reject=function(n){return new this(function(t,e){e(n)})},i.all=function(o){var u=this;return new u(function(n,t){if(c.isArray(o)){var r=o.length,e=0,s=o.length,i=[];if(s<1)return n(i);for(;e<s;e++)u.resolve(o[e]).then(function(e){return function(t){i[e]=t,--r||n(i)}}(e),t)}else t(new TypeError("Promise.all expects an array of values or promises"))})},i.race=function(s){var i=this;return new i(function(t,e){if(c.isArray(s))for(var n=0,r=s.length;n<r;n++)i.resolve(s[n]).then(t,e);else e(new TypeError("Promise.race expects an array of values or promises"))})},t.Promise=i,t.mix(r.prototype,{fulfill:function(t){"pending"===this._status&&(this._result=t,this._status="fulfilled"),"fulfilled"===this._status&&(this._notify(this._callbacks,this._result),this._callbacks=[],this._errbacks=null)},reject:function(t){"pending"===this._status&&(this._result=t,this._status="rejected"),"rejected"===this._status&&(this._notify(this._errbacks,this._result),this._callbacks=null,this._errbacks=[])},resolve:function(t){var e=this;i.isPromise(t)?t.then(function(t){e.resolve(t)},function(t){e.reject(t)}):this.fulfill(t)},then:function(t,e){return this.promise.then(t,e)},_addCallbacks:function(t,e){var n=this._callbacks,r=this._errbacks,s=this._status,i=this._result;n&&"function"==typeof t&&n.push(t),r&&"function"==typeof e&&r.push(e),"fulfilled"===s?this.fulfill(i):"rejected"===s&&this.reject(i)},getStatus:function(){return this._status},_notify:function(n,r){n.length&&t.soon(function(){for(var t=0,e=n.length;t<e;++t)n[t](r)})}},!0),t.Promise.Resolver=r,t.when=function(t,e,n){return t=i.resolve(t),e||n?t.then(e,n):t},t.batch=function(){return i.all(n.call(arguments))}},"patched-v3.18.3",{requires:["timers"]});