import{g as m,r as u}from"./api-DZ3cXm1m.js";document.addEventListener("DOMContentLoaded",function(){const e=window.quoteEditConfig;if(!e)return;const n=document.getElementById("sendQuoteBtn"),o=document.getElementById("sendForm");n&&o&&n.addEventListener("click",function(){confirm(e.translations.confirm_send)&&o.submit()});const i=document.getElementById("acceptQuoteBtn"),c=document.getElementById("acceptForm");i&&c&&i.addEventListener("click",function(){confirm(e.translations.confirm_accept)&&c.submit()});const r=document.getElementById("duplicateQuoteBtn"),s=document.getElementById("duplicateForm");r&&s&&r.addEventListener("click",function(){confirm(e.translations.confirm_duplicate)&&s.submit()});const d=document.getElementById("deleteQuoteBtn");d&&d.addEventListener("click",async function(){if(confirm(e.translations.confirm_delete))try{const t=await fetch(e.routes.destroy,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m()}`}});if(t.status===401){const a=await u();a&&(await fetch(e.routes.destroy,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).ok&&(window.location.href=e.routes.index);return}t.ok&&(window.location.href=e.routes.index)}catch(t){console.error("Delete error:",t)}})});
