YUI.add("widget-parent",function(a,e){var d=a.Lang,s="rendered",r="boundingBox";function t(e){var t,i;this.publish("addChild",{defaultTargetOnly:!0,defaultFn:this._defAddChildFn}),this.publish("removeChild",{defaultTargetOnly:!0,defaultFn:this._defRemoveChildFn}),this._items=[],e&&e.children&&(t=e.children,i=this.after("initializedChange",function(e){this._add(t),i.detach()})),a.after(this._renderChildren,this,"renderUI"),a.after(this._bindUIParent,this,"bindUI"),this.after("selectionChange",this._afterSelectionChange),this.after("selectedChange",this._afterParentSelectedChange),this.after("activeDescendantChange",this._afterActiveDescendantChange),this._hDestroyChild=this.after("*:destroy",this._afterDestroyChild),this.after("*:focusedChange",this._updateActiveDescendant)}t.ATTRS={defaultChildType:{setter:function(e){var t=a.Attribute.INVALID_VALUE,e=d.isString(e)?a[e]:e;return t=d.isFunction(e)?e:t}},activeDescendant:{readOnly:!0},multiple:{value:!1,validator:d.isBoolean,writeOnce:!0,getter:function(e){var t=this.get("root");return t&&t!=this?t.get("multiple"):e}},selection:{readOnly:!0,setter:"_setSelection",getter:function(e){return d.isArray(e)?new a.ArrayList(e):e}},selected:{setter:function(e){var t=e;return t=1!==e||this.get("multiple")?t:a.Attribute.INVALID_VALUE}}},t.prototype={destructor:function(){this._destroyChildren()},_afterDestroyChild:function(e){e=e.target;e.get("parent")==this&&e.remove()},_afterSelectionChange:function(e){var t;e.target==this&&e.src!=this&&(t=0,(e=e.newVal)&&(t=2,a.instanceOf(e,a.ArrayList)&&e.size()===this.size()&&(t=1)),this.set("selected",t,{src:this}))},_afterActiveDescendantChange:function(e){var t=this.get("parent");t&&t._set("activeDescendant",e.newVal)},_afterParentSelectedChange:function(e){var t=e.newVal;this!=e.target||e.src==this||0!==t&&1!==t||this.each(function(e){e.set("selected",t,{src:this})},this)},_setSelection:function(e){var t,i=null;return this.get("multiple")&&!this.isEmpty()?(t=[],this.each(function(e){0<e.get("selected")&&t.push(e)}),0<t.length&&(i=t)):0<e.get("selected")&&(i=e),i},_updateSelection:function(e){var t,i=e.target;i.get("parent")==this&&("_updateSelection"!=e.src&&(t=this.get("selection"),!this.get("multiple")&&t&&0<e.newVal&&t.set("selected",0,{src:"_updateSelection"}),this._set("selection",i)),e.src==this&&this._set("selection",i,{src:this}))},_updateActiveDescendant:function(e){e=!0===e.newVal?e.target:null;this._set("activeDescendant",e)},_createChild:function(e){var t,i,n,s=this.get("defaultChildType"),r=e.childType||e.type;return r&&(i=d.isString(r)?a[r]:r),d.isFunction(i)?n=i:s&&(n=s),n?t=new n(e):a.error("Could not create a child instance because its constructor is either undefined or invalid."),t},_defAddChildFn:function(e){var t=e.child,i=e.index,n=this._items;t.get("parent")&&t.remove(),d.isNumber(i)?n.splice(i,0,t):n.push(t),t._set("parent",this),t.addTarget(this),e.index=t.get("index"),t.after("selectedChange",a.bind(this._updateSelection,this))},_defRemoveChildFn:function(e){var t=e.child,e=e.index,i=this._items;t.get("focused")&&t.blur(),t.get("selected")&&t.set("selected",0),i.splice(e,1),t.removeTarget(this),t._oldParent=t.get("parent"),t._set("parent",null)},_add:function(e,i){var n,s,t;return d.isArray(e)?(n=[],a.each(e,function(e,t){(s=this._add(e,i+t))&&n.push(s)},this),0<n.length&&(t=n)):(s=a.instanceOf(e,a.Widget)?e:this._createChild(e))&&this.fire("addChild",{child:s,index:i})&&(t=s),t},add:function(){var e=this._add.apply(this,arguments),e=e?d.isArray(e)?e:[e]:[];return new a.ArrayList(e)},remove:function(e){var t,i=this._items[e];return t=i&&this.fire("removeChild",{child:i,index:e})?i:t},removeAll:function(){var e,t=[];return a.each(this._items.concat(),function(){(e=this.remove(0))&&t.push(e)},this),new a.ArrayList(t)},selectChild:function(e){this.item(e).set("selected",1)},selectAll:function(){this.set("selected",1)},deselectAll:function(){this.set("selected",0)},_uiAddChild:function(e,t){e.render(t);var i=e.get("boundingBox"),n=e.next(!1);n&&n.get(s)?n.get(r).insert(i,"before"):(n=e.previous(!1))&&n.get(s)?n.get(r).insert(i,"after"):t.contains(i)||t.appendChild(i)},_uiRemoveChild:function(e){e.get("boundingBox").remove()},_afterAddChild:function(e){e=e.child;e.get("parent")==this&&this._uiAddChild(e,this._childrenContainer)},_afterRemoveChild:function(e){e=e.child;e._oldParent==this&&this._uiRemoveChild(e)},_bindUIParent:function(){this.after("addChild",this._afterAddChild),this.after("removeChild",this._afterRemoveChild)},_renderChildren:function(){var t=this._childrenContainer||this.get("contentBox");this._childrenContainer=t,this.each(function(e){e.render(t)})},_destroyChildren:function(){this._hDestroyChild.detach(),this.each(function(e){e.destroy()})}},a.augment(t,a.ArrayList),a.WidgetParent=t},"patched-v3.18.4",{requires:["arraylist","base-build","widget"]});