import{Q as u}from"./quill-Rz6pzzkC.js";/* empty css                   */import"./datatables-Bo82YvhT.js";const r={},d=[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{color:[]},{background:[]}],[{list:"ordered"},{list:"bullet"}],[{align:[]}],["link","image"],["clean"]];function i(t,e){const n=t.selectionStart??t.value.length,o=t.selectionEnd??t.value.length;t.value=t.value.substring(0,n)+e+t.value.substring(o),t.selectionStart=t.selectionEnd=n+e.length,t.focus(),t.dispatchEvent(new Event("input",{bubbles:!0}))}function m(t){document.querySelectorAll(".quill-editor").forEach(e=>{var a;const n=e.dataset.lang,o=document.getElementById(`content-${n}`),c=new u(e,{theme:"snow",modules:{toolbar:d},placeholder:((a=t.translations)==null?void 0:a.contentPlaceholder)||""});c.on("text-change",()=>{o&&(o.value=c.root.innerHTML)}),r[n]=c})}function g(t){document.querySelectorAll(".sms-char-counter").forEach(e=>{const n=document.getElementById(e.dataset.charcount);if(!n)return;const o=()=>{var l;const c=n.value.length,a=c===0?0:Math.ceil(c/160);e.textContent=(((l=t.translations)==null?void 0:l.charCount)||":count / :sms").replace(":count",c).replace(":sms",a)};n.addEventListener("input",o),o()})}function f(){let t=null;document.querySelectorAll(".template-subject, .template-content").forEach(e=>{e.addEventListener("focus",()=>{t=e})}),document.querySelectorAll(".merge-field-btn").forEach(e=>{e.addEventListener("click",()=>{const n=e.dataset.field,o=document.querySelector(".tab-pane.show.active");if(!o)return;if(t&&o.contains(t)&&!t.classList.contains("d-none")){i(t,n);return}const c=o.dataset.language,a=r[c];if(a){const s=a.getSelection(!0);a.insertText(s.index,n),a.setSelection(s.index+n.length);return}const l=o.querySelector(".template-content");l&&i(l,n)})})}document.addEventListener("DOMContentLoaded",()=>{const t=window.pageConfig||{};t.channel==="email"&&m(t),t.channel==="sms"&&g(t),f()});
