import{Q as u}from"./quill-B-P71w5s.js";/* empty css                   */import"./vendor-C0v32J92.js";const m=[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],["blockquote","code-block"],["link","image"],["clean"]];function f(t,n){const e=document.getElementById(t.textarea);if(!e)return;const a=document.createElement("div");a.className="ticket-quill-editor",e.style.display="none",e.parentNode.insertBefore(a,e);const o=new u(a,{theme:"snow",modules:{toolbar:m},placeholder:n||e.getAttribute("placeholder")||""});e.value.trim()!==""&&o.setText(e.value),e.dataset.contentFormat="markdown";let l=!1;const r=()=>{l=!0;const d=o.getText().trim()===""?"":o.root.innerHTML;e.value=d,l=!1};o.on("text-change",r),r(),e.addEventListener("input",()=>{l||o.setText(e.value)}),e.addEventListener("ticket:set-content",d=>{var c;const s=((c=d.detail)==null?void 0:c.content)??e.value;o.setText(s),r()});const i=t.form?document.getElementById(t.form):e.closest("form");return i&&(p(i),i.addEventListener("submit",()=>{r(),v(i,"markdown")})),o}function p(t){if(t.querySelector('input[name="content_format"]'))return;const n=document.createElement("input");n.type="hidden",n.name="content_format",n.value="markdown",t.appendChild(n)}function v(t,n){const e=t.querySelector('input[name="content_format"]');e&&(e.value=n)}document.addEventListener("DOMContentLoaded",()=>{const t=window.ticketReplyEditor;!t||!Array.isArray(t.editors)||t.editors.forEach(n=>f(n,t.placeholder))});
