Liferay.Loader.define("@liferay/journal-content-web@6.0.36/js/JournalTemplate",["module","exports","require","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({actionURL:e,namespace:t,portletNamespace:a,portletURL:l}){const o=document.getElementById("".concat(t,"fm")),c=document.getElementById("".concat(t,"ddmTemplateKey")),d=document.querySelector(".template-preview-content"),m=({className:e,content:t,label:a})=>{const n=document.createElement(a);n.className=e,t&&(n.innerHTML=t),d.innerHTML="",d.append(n)},r=[(0,n.delegate)(o,"click","#".concat(t,"selectDDMTemplateButton"),(t=>{t.preventDefault(),(0,n.openSelectionModal)({onSelect:t=>{const l=JSON.parse(t.value);c.value=l.ddmtemplatekey,m({className:"loading-animation",label:"div"});const r=new URLSearchParams(Liferay.Util.ns(a,{ddmTemplateKey:l.ddmtemplatekey}));(0,n.fetch)(e,{body:r,method:"POST"}).then((e=>e.text())).then((e=>{d.innerHTML=e})).catch((()=>{m({className:"alert alert-danger hidden",content:Liferay.Language.get("an-unexpected-error-occurred"),label:"div"})})),(0,n.openToast)({container:o.parentElement.previousElementSibling,message:Liferay.Language.get("changing-the-template-will-not-affect-the-original-web-content-default-template.-the-change-only-applies-to-this-web-content-display"),type:"info"})},selectEventName:"selectDDMTemplate",title:Liferay.Language.get("templates"),url:l})})),(0,n.delegate)(o,"click","#".concat(t,"clearddmTemplateButton, #").concat(t,"ddmTemplateTypeDefault"),(()=>{c.value="",m({className:"text-default",content:Liferay.Language.get("no-template"),label:"p"})}))];return(0,n.toggleRadio)("".concat(t,"ddmTemplateTypeCustom"),"".concat(t,"customDDMTemplateContainer"),null),(0,n.toggleRadio)("".concat(t,"ddmTemplateTypeDefault"),null,"".concat(t,"customDDMTemplateContainer")),{dispose(){r.forEach((e=>e.dispose()))}}};var n=a("frontend-js-web")}));
//# sourceMappingURL=JournalTemplate.js.map