import{r as m,j as e}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc.js";import{aL as v,p as C,aA as w}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc24.js";import{u as N}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc20.js";import{Q as b,$ as c,a2 as _,I as k}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc11.js";import{P as y}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc169.js";import{W as M}from"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc19.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc7.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc9.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc6.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc8.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc4.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc3.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc2.js";import"./v_7_4_2_27_fac7f92f-33f6-4d26-8a6f-b87b9638d3cc10.js";function R(){const{language:s}=N(),{contatos:r,setContatos:d}=v(),{close:p}=C(),[n,x]=m.useState(""),[l,h]=m.useState(""),[i,u]=m.useState(),f=t=>{let a={id:t,name:l};const o=r.find(g=>g.id===t);o?o.name=l:r.push(a),d([...r]),setTimeout(()=>{M.Utils("contatoSave",a)},15e3)},j=async()=>{if(n.length<6){u("Numero invalido"),k({type:"Error",message:s.error_contact,position:"top-right"});return}let t=n;if(t=t.replace(/[^\d]/g,""),await w("init_conversa")===!0)return;l.length>0&&f(t),u(null);let a=document.createElement("a");a.setAttribute("href",`https://api.whatsapp.com/send?phone=${t}`);let o=document.body.appendChild(a);o.click(),o.remove(),p()};return e.jsxs("div",{className:"flex flex-col h-full gap-4 w-[480px]",children:[e.jsx(b,{children:s.modal_startConversation_title}),e.jsx(c,{children:s.modal_startConversation_subTitle}),e.jsxs("div",{className:"w-full flex flex-col gap-5 items-center justify-center",children:[e.jsxs("div",{className:"flex flex-col w-full gap-3",children:[e.jsx(c,{weight:"bold",children:s.modal_numberWhatsapp}),e.jsx(y,{value:n,setValue:x,inputClass:"input input-bordered input-sm join-item w-full notFocus boxInput removeArrow",containerClass:"modalChat",required:!0})]}),e.jsxs("div",{className:"flex flex-col w-full gap-3",children:[e.jsx(c,{weight:"bold",children:s.modal_startConversation_optionalName}),e.jsx("div",{className:"join w-full",children:e.jsx("input",{className:"input input-bordered input-sm join-item min-w-[320px] w-full notFocus boxInput",required:!0,type:"text",placeholder:s.modal_startConversation_name,onChange:t=>h(t.target.value)})})]}),e.jsxs("div",{className:"w-full flex  flex-col justify-center items-center gap-5",children:[i&&i.length>1?e.jsxs("div",{className:"alert alert-error h-10 flex justify-center items-center",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg ",className:"stroke-current shrink-0 h-6 w-6 text-[var(--letra)]",fill:"none",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-[var(--letra)]",children:i})]}):null,e.jsx(_,{name:s.modal_startConversation_confirmationButton,funcao:j})]})]})]})}export{R as default};
