Liferay.Loader.define("document-library-web@6.0.77/document_library/js/data-engine/DataEngineLayoutBuilderHandler.es",["module","exports","require","../saveDDMStructure.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({namespace:t}){const a=document.getElementById("".concat(t,"fm")),i=()=>Liferay.componentReady("".concat(t,"dataLayoutBuilder")),r=async({target:a})=>{if(e(a,".ddm-form-builder-wrapper",".multi-panel-sidebar",".lfr-icon-menu-open",".input-localized-content")){(await i()).current.dispatch({submitButtonId:"".concat(t,"submitButton"),type:"sidebar_field_blur"})}};window.addEventListener("click",r,!0);const d=async()=>{const e=await i(),r=document.getElementById("".concat(t,"name")),d=(0,n.getInputLocalizedValues)(t,"name"),{defaultLanguageId:u}=e.current.state.dataDefinition;if(!r.value||!d[u])return Liferay.Util.openToast({message:Liferay.Util.sub(Liferay.Language.get("please-enter-a-valid-title-for-the-default-language-x"),u.replace("_","-")),title:Liferay.Language.get("error"),type:"danger"}),void r.focus();Liferay.Util.postForm(a,{data:(0,n.getDataEngineStructure)({dataLayoutBuilder:e,namespace:t})})};return a.addEventListener("submit",d),Liferay.after("inputLocalized:localeChanged",(async e=>{const t=e.item.getAttribute("data-value"),a=await i();a.current.dispatch({payload:{languageId:t},type:"language_add"}),a.current.dispatch({payload:{editingLanguageId:t},type:"language_change"})})),{dispose(){a.removeEventListener("submit",d),window.removeEventListener("click",r,!0)}}};var n=a("../saveDDMStructure.es");const e=(e,...t)=>!t.some((t=>e.closest(t)))}}));
//# sourceMappingURL=DataEngineLayoutBuilderHandler.es.js.map