Liferay.Loader.define("@liferay/journal-content-web@6.0.66/js/JournalTemplate",["module","exports","require","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({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"),createTemplatePreview=({className:e,content:t,label:a})=>{const n=document.createElement(a);n.className=e,t&&(n.innerHTML=t),d.innerHTML="",d.append(n)},m=[(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,createTemplatePreview({className:"loading-animation",label:"div"});const m=new URLSearchParams(Liferay.Util.ns(a,{ddmTemplateKey:l.ddmtemplatekey}));(0,n.fetch)(e,{body:m,method:"POST"}).then((e=>e.text())).then((e=>{d.innerHTML=e})).catch((()=>{createTemplatePreview({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="",createTemplatePreview({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(){m.forEach((e=>e.dispose()))}}};var n=a("frontend-js-web")}));
//# sourceMappingURL=JournalTemplate.js.map