AUI.add("liferay-notice",(e=>{const t=e.DOM,o=e.Node,n=e.Do,i=e.Lang,s="has-alerts",a="click",l="hide",c="show",_=function Notice(t){const o=this;return t=t||{},o._closeText=t.closeText,o._node=t.node,o._noticeType=t.type||"notice",o._noticeClass="alert-notice",o._onClose=t.onClose,o._useCloseButton=!0,t.useAnimation&&(o._noticeClass+=" popup-alert-notice",i.isNumber(t.timeout)||(t.timeout=5e3)),o._animationConfig=t.animationConfig||{duration:2,easing:"ease-out",top:"50px"},o._useAnimation=t.useAnimation,o._timeout=t.timeout,o._body=e.getBody(),o._useToggleButton=!1,o._hideText="",o._showText="",!1!==t.toggleText&&(o.toggleText=e.mix(t.toggleText,{hide:null,show:null}),o._useToggleButton=!0),"warning"===o._noticeType&&(o._noticeClass="alert-danger popup-alert-warning"),t.noticeClass&&(o._noticeClass+=" "+t.noticeClass),o._content=t.content||"",o._createHTML(),o._notice};_.prototype={_addCloseButton(e){const t=this;let o;if(!1!==t._closeText?t._closeText=t._closeText||Liferay.Language.get("close"):(t._useCloseButton=!1,t._closeText=""),t._useCloseButton){const n='<button class="btn btn-secondary c-ml-1 submit">'+t._closeText+"</button>";o=e.append(n)}else o=e.one(".close");o&&o.on(a,t.close,t)},_addToggleButton(e){const t=this;if(t._useToggleButton){t._hideText=t._toggleText.hide||Liferay.Language.get("hide"),t._showText=t._toggleText.show||Liferay.Language.get("show");const n=o.create('<a class="toggle-button" href="javascript:void(0);"><span>'+t._hideText+"</span></a>"),i=n.one("span");let s=0;const l=t._hideText,c=t._showText;n.on(a,(()=>{let t=c;0===s?(t=l,s=1):s=0,e.toggle(),i.text(t)})),e.append(n)}},_afterNoticeShow(){const n=this;n._preventHide();const i=n._notice;if(n._useAnimation){const s=n._animationConfig;let a=s.left,c=s.top;if(!a){const e=t.region(o.getDOMNode(i));a=t.winWidth()/2-e.width/2,c=-e.height,s.left=a+"px"}i.setXY([a,c]),i.transition(n._animationConfig,(()=>{n._hideHandle=e.later(n._timeout,i,l)}))}else n._timeout>-1&&(n._hideHandle=e.later(n._timeout,i,l));Liferay.fire("noticeShow",{notice:n,useAnimation:n._useAnimation})},_beforeNoticeHide(){const t=this;let o;if(t._useAnimation){const i=e.merge(t._animationConfig,{top:-t._notice.get("offsetHeight")+"px"});t._notice.transition(i,(()=>{t._notice.toggle(!1)})),o=new n.Halt(null)}return Liferay.fire("noticeHide",{notice:t,useAnimation:t._useAnimation}),o},_beforeNoticeShow(){this._notice.toggle(!0)},_createHTML(){const t=this,i=t._content,a=e.one(t._node),_=a||o.create('<div class="alert alert-warning" dynamic="true"></div>');i&&_.html(i),t._noticeClass.split(" ").forEach((e=>{_.addClass(e)})),t._addCloseButton(_),t._addToggleButton(_),(!a||a&&!a.inDoc())&&t._body.prepend(_),t._body.addClass(s),n.before(t._beforeNoticeHide,_,l,t),n.before(t._beforeNoticeShow,_,c,t),n.after(t._afterNoticeShow,_,c,t),t._notice=_},_preventHide(){const e=this;e._hideHandle&&(e._hideHandle.cancel(),e._hideHandle=null)},close(){const e=this;e._notice.hide(),e._body.removeClass(s),e._onClose&&e._onClose()},setClosing(){const t=this,o=e.all(".popup-alert-notice, .popup-alert-warning");o.size()&&(t._useCloseButton=!0,t._body||(t._body=e.getBody()),t._body.addClass(s),o.each(t._addCloseButton,t))}},Liferay.Notice=_}),"",{requires:["aui-base"]});
//# sourceMappingURL=notice.js.map