AUI.add("liferay-staging",()=>{var a={init(a){var i=this,e=a.namespace;i.markAsReadyForPublicationURL=a.markAsReadyForPublicationURL,i.layoutRevisionStatusURL=a.layoutRevisionStatusURL,i._namespace=e,i.viewHistoryURL=a.viewHistoryURL,Liferay.publish({fireOnce:!0}),Liferay.after("initStagingBar",()=>{const a=document.body;if(a.classList.contains("has-staging-bar"))document.querySelector(".staging-bar-level-3-message")?a.classList.add("staging-ready-level-3"):a.classList.add("staging-ready")}),Liferay.fire("initStagingBar",
a)}};Liferay.StagingBar=a},"",{requires:["aui-io-plugin-deprecated","aui-modal"]});
AUI.add("liferay-staging-branch",(a)=>{var i=a.Lang,r=Liferay.StagingBar;a.mix(r,{_getBranchDialog(){var i=this,r=i._branchDialog;if(!r){var e=i._namespace;r=Liferay.Util.Window.getWindow({dialog:{bodyContent:a.one("#"+e+"addBranch").show()},title:'Branch'}),i._branchDialog=r}return r},addBranch(a){var r=this._getBranchDialog();i.isValue(a)&&r.set("title",a),r.show()}})},"",{requires:["liferay-staging"]});
AUI.add("liferay-staging-version",(e)=>{var t=Liferay.StagingBar,a={redo:"redo_layout_revision",undo:"undo_layout_revision"},n={redo:'Are\x20you\x20sure\x20you\x20want\x20to\x20redo\x20your\x20last\x20changes\x3f',undo:'Are\x20you\x20sure\x20you\x20want\x20to\x20undo\x20your\x20last\x20changes\x3f'};e.mix(t,{_cleanup(){this._eventHandles&&e.Array.invoke(this._eventHandles,"detach")},_onInit(){var t=this;t._cleanup();var a=t._namespace,n=[Liferay.on(a+"redo",t._onRevisionChange,t,"redo"),Liferay.on(a+"submit",t._onSubmit,
t),Liferay.on(a+"undo",t._onRevisionChange,t,"undo"),Liferay.on(a+"viewHistory",t._onViewHistory,t)],i=e.one("#"+a+"layoutRevisionDetails"),o=e.one("#"+a+"layoutRevisionStatus");i&&n.push(Liferay.after("updatedLayout",()=>{Liferay.Util.fetch(t.markAsReadyForPublicationURL).then((e)=>e.text()).then((t)=>{i.plug(e.Plugin.ParseContent),i.setContent(t),Liferay.fire("updatedStatus")}).catch(()=>{i.setContent('There\x20was\x20an\x20unexpected\x20error\x2e\x20Please\x20refresh\x20the\x20current\x20page\x2e')})})),o&&
Liferay.after("updatedStatus",()=>{Liferay.Util.fetch(t.layoutRevisionStatusURL).then((e)=>e.text()).then((t)=>{o.plug(e.Plugin.ParseContent),o.setContent(t)}).catch(()=>{o.setContent('There\x20was\x20an\x20unexpected\x20error\x2e\x20Please\x20refresh\x20the\x20current\x20page\x2e')})}),t._eventHandles=n},_onRevisionChange(e,t){var i=a[t];confirm(n[t])&&this._updateRevision(i,e.layoutRevisionId,e.layoutSetBranchId)},_onSubmit(t){var a=this._namespace,n=e.one("#"+a+"layoutRevisionDetails"),i=n.one(".layout-revision-info");
i&&i.addClass("loading");var o=e.one("#"+a+"submitLink");o&&o.html('Loading'+"..."),Liferay.Util.fetch(t.publishURL).then(()=>{t.incomplete?location.href=t.currentURL:Liferay.fire("updatedLayout")}).catch(()=>{n.addClass("alert alert-danger"),n.setContent('There\x20was\x20an\x20unexpected\x20error\x2e\x20Please\x20refresh\x20the\x20current\x20page\x2e')})},_onViewHistory(){Liferay.Util.openWindow({dialog:{after:{destroy(){window.location.reload()}},destroyOnHide:!0},title:'History',
uri:t.viewHistoryURL})},_updateRevision(e,t,a){var n={cmd:e,doAsUserId:themeDisplay.getDoAsUserIdEncoded(),layoutRevisionId:t,layoutSetBranchId:a,p_auth:Liferay.authToken,p_l_id:themeDisplay.getPlid(),p_v_l_s_g_id:themeDisplay.getSiteGroupId()};Liferay.Util.fetch(themeDisplay.getPathMain()+"/portal/update_layout",{body:Liferay.Util.objectToFormData(n),method:"POST"}).then(()=>{window.location.reload()}).catch(()=>{Liferay.Util.openToast({message:'There\x20was\x20an\x20unexpected\x20error\x2e\x20Please\x20refresh\x20the\x20current\x20page\x2e',
toastProps:{autoClose:1E4},type:"warning"})})},destructor(){this._cleanup()}}),Liferay.on("initStagingBar",t._onInit,t)},"",{requires:["aui-button","liferay-staging"]});
