import{j as e}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89263.js";import{a as c}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89262.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892655.js";import{E as j}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926133.js";import{u as w}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89264.js";import{f as p,b1 as N,I as l}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89268.js";import{m as y,q as A,P as E,w as k}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892625.js";import{af as T,T as C,L as I,ac as P}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89267.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89266.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89269.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892610.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892620.js";const u="transferencia-atendimento-externo-urgencia",S=650;function _(n){return new Promise(s=>{window.setTimeout(s,n)})}function B({email:n,name:s}){const h=y(t=>t.trasferir_atendimento_externo),m=A(t=>t.close),f=E(t=>t.trasferirAtendimento),i=k(t=>t.activeChat?.id?.user??""),r=w(t=>t.language),[x,b]=c.useState(""),[o,g]=c.useState(!1),[a,d]=c.useState(!1),v=async()=>{if(!(!i||a)){d(!0);try{const[t]=await Promise.all([h(n,x,o),_(S)]);if(!t.ok){l({type:"Error",message:t.message??r.atendenteExternoOffline,position:"top-right"}),d(!1);return}f(i,s),l({type:"Success",message:`${r.transferenciaEnviadaPara} ${s}`,position:"top-right"}),m()}catch{l({type:"Error",message:r.transferenciaErroAoEnviar,position:"top-right"}),d(!1)}}};return e.jsxs("div",{className:"flex w-[32rem] max-w-[calc(100vw-4rem)] flex-col gap-4",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-solid border-[var(--conversation-header-border)] pr-8 pb-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-[var(--background-default-active)] text-[var(--primaria)]",children:e.jsx(T,{className:"h-5 w-5",strokeWidth:1.7,"aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("h2",{className:"truncate text-[17px] font-semibold leading-tight text-base-content/95",children:r.transferirAtendimentoTittle}),e.jsx("span",{className:"mt-0.5 block text-xs leading-tight text-base-content/55",children:r.transferenciaReviseDestinatario})]})]}),e.jsx("div",{className:p(a&&"pointer-events-none opacity-65"),"aria-busy":a,children:e.jsx(j,{id:"TransferirAtendimentoExterno_TextArea",titulo:e.jsxs(e.Fragment,{children:[r.transferirEmojiTittle," ",e.jsx("strong",{children:s})," ",e.jsxs("span",{className:"text-xs text-base-content/55",children:["(",n,")"]})]}),type:"textarea",className:"w-full",position:"right",placeholder:r.atendimentoEmojiAreaPlaceHolder,text:x,setText:b,heightCamp:160})}),e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-solid border-[var(--conversation-header-border)] px-3 py-2.5 transition-colors hover:bg-[var(--background-default-active)]/40",children:[e.jsxs("label",{htmlFor:u,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[e.jsx(C,{className:p("h-[17px] w-[17px] shrink-0 transition-colors",o?"text-warning":"text-base-content/45"),strokeWidth:1.75,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium text-base-content/70",children:r.atendimentoComUrgencia})]}),e.jsx(N,{estado:o,switchUpdate:()=>g(t=>!t),id:u,corPrimaria:!0,disabled:a})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-solid border-[var(--conversation-header-border)] pt-3",children:[e.jsx("button",{type:"button",className:"rounded-md px-4 py-2.5 text-sm font-semibold text-base-content/65 transition-colors hover:bg-[var(--background-default-active)] hover:text-base-content disabled:cursor-not-allowed disabled:opacity-45",disabled:a,onClick:m,children:r.cancel}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-md bg-[var(--primaria)] px-4 py-2.5 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:!i||a,onClick:()=>{v()},children:[a?e.jsx(I,{className:"h-3.5 w-3.5 animate-spin",strokeWidth:2,"aria-hidden":!0}):e.jsx(P,{className:"h-3.5 w-3.5",strokeWidth:1.8,"aria-hidden":!0}),a?r.transferenciaEnviando:r.botaoTransferir]})]})]})}export{B as default};
