function initializeTextarea(){var e=Array.from(document.getElementsByClassName("srfm-textarea-block"));if(e)for(let r of e){let i=r.querySelector("textarea");if(i)if(i.addEventListener("input",function(){var e,t=i.value,l=i.getAttribute("maxLength");""!==l&&(e=r.querySelector(".srfm-text-counter"))&&(t=l-t.length,e.innerText=t+"/"+l)}),"true"===i.getAttribute("data-is-richtext")){addQuillEditor(i),localizeQuillToolbar(i),handleQuillEditorA11Y(i);let e=i?.parentElement?.querySelector(".quill-editor-container");var t=e?.querySelector(".ql-editor");t?.addEventListener("focus",function(){e.parentElement.classList.add("srfm-quill-editor-focused")}),t?.addEventListener("click",function(){e.parentElement.classList.add("srfm-quill-editor-focused")}),t?.addEventListener("blur",function(){e.parentElement.classList.remove("srfm-quill-editor-focused")})}}}function addQuillEditor(l){var e=l.getAttribute("id"),t=Quill.import("attributors/style/align"),i=Quill.import("attributors/style/direction"),r=Quill.import("ui/icons"),r=(r.undo='',r.redo='',Quill.register(t,!0),Quill.register(i,!0),"quill-"+e),t=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"];let n=new Quill("#"+r,{theme:"snow",modules:{toolbar:{container:[[{header:[1,2,3,4,5,6,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],["blockquote"],[{align:[]}],[{color:t},{background:t}],["link"],["clean"],["undo","redo"]],handlers:{undo(){this.quill.history.undo()},redo(){this.quill.history.redo()}}},keyboard:{bindings:{tab:!0}},history:{delay:1e3,maxStack:100,userOnly:!0}}});window?.addGlobalSrfmObject(e,n);i=l.value;n.clipboard.dangerouslyPasteHTML(i),n.blur(),n.on("text-change",function(){var e=n.root.innerHTML,t=n.getLength();l.value=1e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n"),(t=document.createElement("style")).id="srfm-quill-i18n-css",t.textContent='.ql-snow .ql-tooltip::before { content: "'+e(srfm_quill_i18n.visit_url)+'" !important; }.ql-snow .ql-tooltip a.ql-action::after { content: "'+e(srfm_quill_i18n.edit)+'" !important; }.ql-snow .ql-tooltip a.ql-remove::before { content: "'+e(srfm_quill_i18n.remove)+'" !important; }.ql-snow .ql-tooltip.ql-editing a.ql-action::after { content: "'+e(srfm_quill_i18n.save)+'" !important; }.ql-snow .ql-tooltip[data-mode=link]::before { content: "'+e(srfm_quill_i18n.enter_link)+'" !important; }',document.head.appendChild(t))}}}document.addEventListener("DOMContentLoaded",initializeTextarea);