import{j as e,d9 as i,U as u,ar as x,I as n}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578110.js";import{u as h}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578119.js";import{s as f}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578123.js";import{d as g}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd945781154.js";import{V as w}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578118.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457814.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd945781.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457818.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457815.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457817.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457816.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457819.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457812.js";import"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457813.js";function L({rel:r}){const{label:m}=f(),{language:t}=h(),l=[{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--secundaria)]"}),name:`${t.baixar_todos}`,type:"all"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--primaria)]"}),name:`${t.baixar_com_falha}`,type:"error"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--terciaria)]"}),name:`${t.baixar_com_sucesso}`,type:"success"}],p=async o=>{let s=[];if(o==="all"?s=r.send.map(a=>({id:a.phone,name:a.nome,status:a.status})):o==="success"?s=r.send.filter(a=>a.status==="Enviado").map(a=>({id:a.phone,name:a.nome,status:a.status})):s=r.send.filter(a=>a.status==="Erro").map(a=>({id:a.phone,name:a.nome,status:a.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:m.nameID,type:o};try{const a=await fetch(`${w.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!a.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await a.json();g(d.XLSXbase64,`${m.nameID}_relatorio_${o}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(a){console.error("Erro ao exportar relatório:",a),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:u.MillisToFormattedDate(parseInt(r.id))}),l.map((o,s)=>e.jsx("span",{children:e.jsx(x,{content:o.name,icon:o.ico,setFunction:()=>p(o.type),stroke:"1"})},s))]})}export{L as default};
