import{j as e,v as E,D as R,J as T,V as B}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e10.js";import{a as o}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e4.js";import{A as U,L as H}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e5.js";import{a as y,n as M,m as O}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e22.js";import{u as P}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e19.js";import{I as k}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e173.js";import{W as _}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e18.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e8.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e7.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e6.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e2.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e3.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e9.js";const V=({selectAll:u,pesquisar:a,setSelecionados:g,tabId:x})=>{const{userTabs:h}=y(),[d,j]=o.useState([]);o.useEffect(()=>{(async()=>{const s=await _.Chat("List"),n=await _.Contact("List","onlyMyContacts"),c=await _.Contact("List","allLabels"),S=h.find(i=>i.id===x),A=(S==null?void 0:S.chats.map(i=>({id:i.id,name:i.id})))??[],N=s.concat(n).concat(c).concat(A),w=[],L=new Set;N.forEach(i=>{i.id&&!L.has(i.id)&&(L.add(i.id),w.push(i))}),l(w),j(w)})()},[]);const[r,l]=o.useState([]);o.useEffect(()=>{if(a.length===0)l(d);else{let t=[];d.forEach(s=>{var n;(s.id.includes(a)||(n=s.name)!=null&&n.toUpperCase().includes(a.toUpperCase()))&&t.push(s)}),l(t)}},[a]);const[f,m]=o.useState(new Set);o.useEffect(()=>{if(u)m(new Set);else{const t=r.map(s=>s.id);m(new Set(t))}},[u]);const p=t=>{m(s=>{const n=new Set(s);return n.has(t)?n.delete(t):n.add(t),n})};o.useEffect(()=>{h.forEach(t=>{t.id===x&&t.chats.forEach(s=>{p(s.id)})})},[h]),o.useEffect(()=>{g(d.filter(t=>f.has(t.id)))},[d,f]);const C=({index:t,key:s,style:n})=>{const c=r[t];if(c)return e.jsx("li",{style:n,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(B,{id:c.id,estado:f.has(c.id),checkedUpdade:()=>p(c.id)}),e.jsx("span",{className:"flex-[inherit] overflow-hidden text-ellipsis whitespace-nowrap",children:e.jsx("strong",{children:c.name})}),e.jsx("span",{children:c.id})]})})},c.id)},v=e.jsx("div",{className:"w-full pt-2",children:e.jsx("ul",{className:"gap-2 overflow-y-auto overflow-x-hidden justify-center",style:{maxHeight:"calc(100vh - 240px)",minHeight:"60px",height:`${r.length*32}px`},children:e.jsx(U,{children:({width:t,height:s})=>e.jsx(H,{width:t,height:s,rowCount:r.length,rowHeight:32,rowRenderer:C})})})}),b=e.jsx("div",{children:e.jsx("ul",{children:e.jsx("div",{style:{maxHeight:"calc(100vh - 300px)"},className:"grid overflow-auto mt-4 gap-1",children:e.jsx("li",{children:e.jsx("div",{children:e.jsx("span",{className:"w-full flex justify-center p-4",children:e.jsxs("strong",{children:[" ",a.length!==0?"Nenhum contato encontrado":"Loading...","  "]})})})})})})});return r.length!==0?v:b};function ee({tabId:u}){const{language:a}=P(),{setChatsTab:g}=y(),{openRendertype:x,close:h}=M(),{user:d}=O(),[j,r]=o.useState(""),[l,f]=o.useState(!0),m=()=>{f(!l)},[p,C]=o.useState([]);p.length>5&&!d.estado&&x("user_free");const v=async()=>{h(),g(p,u)};return e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(E,{children:a.menu_moreAba_addContact_title}),e.jsx(R,{children:a.menu_moreAba_addContact_subTitle}),e.jsx(k,{inpPlaceTxt:a.menu_moreAba_addContact_placeContact,inpValue:j,inpSetValue:r,selectAll:l,btnConfirmName:a.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:m,btnNegacaoName:a.menu_moreAba_removeAll,btnNegacaoFuncao:m}),e.jsx(V,{selectAll:l,pesquisar:j,setSelecionados:C,tabId:u}),e.jsx("div",{className:"flex justify-end p-2",children:e.jsx(T,{name:a.menu_moreAba_addContact_placeButtonSave,funcao:v})})]})}export{ee as default};
