YUI.add("async-queue",function(e,t){e.AsyncQueue=function(){this._init(),this.add.apply(this,arguments)};var i=e.AsyncQueue,s="shift",u="promote",r="remove",h=e.Lang.isObject,a=e.Lang.isFunction;i.defaults=e.mix({autoContinue:!0,iterations:1,timeout:10,until:function(){return this.iterations|=0,this.iterations<=0}},e.config.queueDefaults||{}),e.extend(i,e.EventTarget,{_running:!1,_init:function(){e.EventTarget.call(this,{prefix:"queue",emitFacade:!0}),this._q=[],this.defaults={},this._initEvents()},_initEvents:function(){this.publish({execute:{defaultFn:this._defExecFn,emitFacade:!0},shift:{defaultFn:this._defShiftFn,emitFacade:!0},add:{defaultFn:this._defAddFn,emitFacade:!0},promote:{defaultFn:this._defPromoteFn,emitFacade:!0},remove:{defaultFn:this._defRemoveFn,emitFacade:!0}})},next:function(){for(var t;this._q.length&&(t=this._q[0]=this._prepare(this._q[0]))&&t.until();)this.fire(s,{callback:t}),t=null;return t||null},_defShiftFn:function(t){0===this.indexOf(t.callback)&&this._q.shift()},_prepare:function(t){if(a(t)&&t._prepared)return t;var t=e.merge(i.defaults,{context:this,args:[],_prepared:!0},this.defaults,a(t)?{fn:t}:t),n=e.bind(function(){n._running||n.iterations--,a(n.fn)&&n.fn.apply(n.context||e,e.Array(n.args))},this);return e.mix(n,t)},run:function(){var t;if(this._executing)return this._running=!0,this;for(t=this.next();t&&!this.isRunning()&&(t.timeout<0?this._execute(t):this._schedule(t));t=this.next());return t||this.fire("complete"),this},_execute:function(t){this._running=t._running=!0,(this._executing=t).iterations--,this.fire("execute",{callback:t});var n=this._running&&t.autoContinue;return this._running=t._running=!1,this._executing=!1,n},_schedule:function(t){return this._running=e.later(t.timeout,this,function(){this._execute(t)&&this.run()}),!1},isRunning:function(){return!!this._running},_defExecFn:function(t){t.callback()},add:function(){return this.fire("add",{callbacks:e.Array(arguments,0,!0)}),this},_defAddFn:function(t){var n=this._q,i=[];e.Array.each(t.callbacks,function(t){h(t)&&(n.push(t),i.push(t))}),t.added=i},pause:function(){return this._running&&h(this._running)&&this._running.cancel(),this._running=!1,this},stop:function(){return this._q=[],this._running&&h(this._running)&&(this._running.cancel(),this._running=!1),this._executing||this.run(),this},indexOf:function(t){for(var n,i=0,e=this._q.length;i<e;++i)if((n=this._q[i])===t||n.id===t)return i;return-1},getCallback:function(t){t=this.indexOf(t);return-1<t?this._q[t]:null},promote:function(t){var n,i={callback:t};return this.isRunning()?n=this.after(s,function(){this.fire(u,i),n.detach()},this):this.fire(u,i),this},_defPromoteFn:function(t){var n=this.indexOf(t.callback),n=-1<n?this._q.splice(n,1)[0]:null;(t.promoted=n)&&this._q.unshift(n)},remove:function(t){var n,i={callback:t};return this.isRunning()?n=this.after(s,function(){this.fire(r,i),n.detach()},this):this.fire(r,i),this},_defRemoveFn:function(t){var n=this.indexOf(t.callback);t.removed=-1<n?this._q.splice(n,1)[0]:null},size:function(){return this.isRunning()||this.next(),this._q.length}})},"patched-v3.18.3",{requires:["event-custom"]});