import{g as y,r as h}from"./api-DZ3cXm1m.js";document.addEventListener("DOMContentLoaded",()=>{var g,u;const n=document.getElementById("assignAdminSelect"),d=(u=(g=window.routes)==null?void 0:g.tickets)==null?void 0:u.assign;if(!n||!d)return;const c=document.getElementById("assignedAdminLabel"),a=window.translations||{};async function l(i,t){return fetch(d,{method:"POST",headers:{Authorization:`Bearer ${i}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})}n.addEventListener("change",async()=>{var t,m,o,w,r,f;const i={assigned_admin_id:n.value||null};n.disabled=!0;try{let s=await l(y(),i);if(s.status===401){const p=await h();p&&(s=await l(p,i))}const e=await s.json().catch(()=>null);s.ok&&(e!=null&&e.success)?(c&&(c.textContent=e.assigned_admin_name||a.assigned_none||"—"),(m=(t=window.toastr)==null?void 0:t.success)==null||m.call(t,a.assigned_saved||"Assigned")):(w=(o=window.toastr)==null?void 0:o.error)==null||w.call(o,(e==null?void 0:e.message)||a.assigned_error||"Error")}catch{(f=(r=window.toastr)==null?void 0:r.error)==null||f.call(r,a.assigned_error||"Error")}finally{n.disabled=!1}})});
