YUI.add("lazy-model-list",function(s,t){var i=s.Attribute.prototype,e=YUI.namespace("Env.Model"),n=s.Lang,d=s.Array;s.LazyModelList=s.Base.create("lazyModelList",s.ModelList,[],{initializer:function(){this.after("*:change",this._afterModelChange)},free:function(t){return t?0<=(t=n.isNumber(t)?t:this.indexOf(t))&&delete this._models[t]:this._models=[],this},get:function(e){return this.attrAdded(e)?i.get.apply(this,arguments):d.map(this._items,function(t){return t[e]})},getAsHTML:function(e){return this.attrAdded(e)?s.Escape.html(i.get.apply(this,arguments)):d.map(this._items,function(t){return s.Escape.html(t[e])})},getAsURL:function(e){return this.attrAdded(e)?encodeURIComponent(i.get.apply(this,arguments)):d.map(this._items,function(t){return encodeURIComponent(t[e])})},indexOf:function(t){return d.indexOf(t&&t._isYUIModel?this._models:this._items,t)},reset:function(t,e){t=t||[];var i=s.merge({src:"reset"},e=e||{});return t=t._isYUIModelList?t.map(this._modelToObject):d.map(t,this._modelToObject),i.models=t,e.silent?this._defResetFn(i):(this.comparator&&t.sort(s.bind(this._sort,this)),this.fire("reset",i)),this},revive:function(t){var e,i,s;if(t||0===t)return this._revive(n.isNumber(t)?t:this.indexOf(t));for(s=[],e=0,i=this._items.length;e<i;e++)s.push(this._revive(e));return s},toJSON:function(){return this.toArray()},_add:function(t,e){var i;if(e=e||{},"clientId"in(t=this._modelToObject(t))||(t.clientId=this._generateClientId()),!this._isInList(t))return i=s.merge(e,{index:"index"in e?e.index:this._findIndex(t),model:t}),e.silent?this._defAddFn(i):this.fire("add",i),t;this.fire("error",{error:"Model is already in the list.",model:t,src:"add"})},_clear:function(){d.each(this._models,this._detachList,this),this._clientIdMap={},this._idMap={},this._items=[],this._models=[]},_generateClientId:function(){return e.lastId||(e.lastId=0),this.model.NAME+"_"+(e.lastId+=1)},_isInList:function(t){return!!("clientId"in t&&this._clientIdMap[t.clientId]||"id"in t&&this._idMap[t.id])},_modelToObject:function(t){return t._isYUIModel&&(delete(t=t.getAttrs()).destroyed,delete t.initialized),t},_remove:function(t,e){return t._isYUIModel&&(t=this.indexOf(t)),s.ModelList.prototype._remove.call(this,t,e)},_revive:function(t){var e,i;return!(t<0)&&(e=this._items[t])?((i=this._models[t])||((i=new this.model(e))._set("clientId",e.clientId),this._attachList(i),this._models[t]=i),i):null},_afterModelChange:function(t){var e,i=t.changed,s=this._clientIdMap[t.target.get("clientId")];if(s)for(e in i)i.hasOwnProperty(e)&&(s[e]=i[e].newVal)},_defAddFn:function(t){var e=t.model;this._clientIdMap[e.clientId]=e,n.isValue(e.id)&&(this._idMap[e.id]=e),this._items.splice(t.index,0,e)},_defRemoveFn:function(t){var e=t.index,t=t.model,i=this._models[e];delete this._clientIdMap[t.clientId],"id"in t&&delete this._idMap[t.id],i&&this._detachList(i),this._items.splice(e,1),this._models.splice(e,1)}})},"patched-v3.18.7",{requires:["model-list"]});