YUI.add("moodle-core-widget-focusafterclose",function(t,e){function i(){t.after(this._bindUIFocusAfterHide,this,"bindUI"),this.get("rendered")&&this._bindUIFocusAfterHide()}i.ATTRS={focusOnPreviousTargetAfterHide:{value:!1},focusAfterHide:{value:null,type:t.Node}},i.prototype={_uiHandlesFocusAfterHide:[],_showFocusAfterHide:null,_previousTargetFocusAfterHide:null,initializer:function(){this.get("focusOnPreviousTargetAfterHide")&&this.show&&(this._showFocusAfterHide=this.show,this.show=function(e){this._showFocusAfterHide.apply(this,arguments),this._previousTargetFocusAfterHide=null,e&&e.currentTarget&&(this._previousTargetFocusAfterHide=e.currentTarget)})},destructor:function(){new t.EventHandle(this.uiHandleFocusAfterHide).detach()},_bindUIFocusAfterHide:function(){new t.EventHandle(this.uiHandleFocusAfterHide).detach(),this.uiHandleFocusAfterHide=[this.after("visibleChange",this._afterHostVisibleChangeFocusAfterHide)]},_afterHostVisibleChangeFocusAfterHide:function(){this.get("visible")||this._attemptFocus(this._previousTargetFocusAfterHide)||this._attemptFocus(this.get("focusAfterHide"))},_attemptFocus:function(e){e=t.one(e);return!!(e=e&&e.ancestor('input:not([type="hidden"]), a[href], button, textarea, select, [tabindex], [contenteditable="true"]',!0))&&(e.focus(),!0)}},t.namespace("M.core").WidgetFocusAfterHide=i},"@VERSION@",{requires:["base-build","widget"]});