Liferay.Loader.define("layout-admin-web@5.0.150/js/AddLayout",["module","exports","require","frontend-js-web","./checkFriendlyURL"],(function(e,t,n){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function AddLayout({getFriendlyURLWarningURL:e,namespace:t,shouldCheckFriendlyURL:n}){const d=document.getElementById("".concat(t,"addButton")),a=document.getElementById("".concat(t,"fm")),onSubmit=async t=>{if(t.preventDefault(),t.stopPropagation(),d.disabled)return;d.disabled=!0;const i=new FormData(a);if(n){const{shouldSubmit:t}=await(0,r.checkFriendlyURL)(e,i);if(!t)return void(d.disabled=!1)}(0,o.fetch)(a.action,{body:i,method:"POST"}).then((e=>e.json())).then((e=>{if(e.redirectURL){const t=new URL(e.redirectURL,window.location.origin);t.searchParams.set("p_p_state","normal");(0,o.getOpener)().Liferay.fire("closeModal",{id:"addLayoutDialog",redirect:t.toString()})}else{if(d.disabled=!1,a.querySelector(".alert"))return;const t=document.createElement("div");a.prepend(t),(0,o.openToast)({autoClose:!1,container:t,message:e.errorMessage,type:"danger"})}}))};return a.addEventListener("submit",onSubmit),{dispose(){a.removeEventListener("submit",onSubmit)}}};var o=n("frontend-js-web"),r=n("./checkFriendlyURL")}));
//# sourceMappingURL=AddLayout.js.map