import{u as p}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a55.js";import{ai as s,m as i,P as r}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a525.js";function D(t){const e=p.getState().whatsappID,a=s(t),n=i.getState().atendimentos.find(o=>s(o.chatID)===a&&!!o.whatsappID&&o.whatsappID!==e);if(n?.whatsappID)return n.whatsappID;const{activeTrasferencia:I,trasferencias:c}=r.getState();return[I,...c].filter(o=>o!=null).find(o=>s(o.chatID)===a&&!!o.atendimentoWhatsappID&&o.atendimentoWhatsappID!==e)?.atendimentoWhatsappID}function f(t,e){const a=s(t),n=p.getState().whatsappID,I=e?.atendimentoWhatsappID??D(a)??n;i.getState().send_atendimento(a,"Finalizado",I),r.getState().finalizarAtendimento(a)}function l(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().send_atendimento(e,"Ativo",n),i.getState().socket?.emit("inbox:accept",{whatsappID:n,chatID:e,fromUserId:t.remetenteID}),r.getState().removerTransferenciaInbox(t.chatID)}function g(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().socket?.emit("inbox:dismiss",{whatsappID:n,chatID:e,...t.inboxDocId?{inboxId:t.inboxDocId}:{}}),r.getState().removerTransferenciaInbox(t.chatID)}function w(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().socket?.emit("inbox:remove-done",{...t.inboxDocId?{inboxId:t.inboxDocId}:{},whatsappID:n,chatID:e}),typeof t.finalizadoEm=="number"&&r.getState().removerTransferenciaDoHistorico(t.finalizadoEm)}export{l as a,g as d,f as e,w as r};
