import{g as i,r as c}from"./api-DZ3cXm1m.js";import{M as a}from"./bootstrap.esm-Bb7dPm-H.js";const o=window.verificationShowConfig||{};async function d(){if(confirm(o.translations.approve_confirm))try{const e=await fetch(o.routes.approve,{method:"POST",headers:{Authorization:`Bearer ${i()}`,Accept:"application/json","Content-Type":"application/json"}});if(e.status===401&&await c())return d();const t=await e.json();t.success?(r("success",o.translations.success,o.translations.approved_success),setTimeout(()=>{window.location.href=o.routes.index},1500)):r("error",o.translations.error,t.error)}catch(e){console.error("Approve error:",e),r("error",o.translations.error,e.message)}}async function l(e){try{const t=await fetch(o.routes.reject,{method:"POST",headers:{Authorization:`Bearer ${i()}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({reason:e})});if(t.status===401&&await c())return l(e);const n=await t.json();n.success?(r("success",o.translations.success,o.translations.rejected_success),setTimeout(()=>{window.location.href=o.routes.index},1500)):r("error",o.translations.error,n.error)}catch(t){console.error("Reject error:",t),r("error",o.translations.error,t.message)}}function r(e,t,n){typeof toastr<"u"?toastr[e](n,t):typeof window.showAlert=="function"?window.showAlert(e,n):alert(`${t}: ${n}`)}document.addEventListener("DOMContentLoaded",function(){var e,t,n;(e=document.getElementById("approveBtn"))==null||e.addEventListener("click",d),(t=document.getElementById("rejectBtn"))==null||t.addEventListener("click",function(){new a(document.getElementById("rejectModal")).show()}),(n=document.getElementById("confirmRejectBtn"))==null||n.addEventListener("click",function(){const s=document.getElementById("rejectReason").value.trim();if(!s){document.getElementById("rejectReason").classList.add("is-invalid");return}a.getInstance(document.getElementById("rejectModal")).hide(),l(s)})});
