import{r as n,j as e}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b.js";import{A as k,L as E}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b6.js";import{b as A,p as B,o as L}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b24.js";import{u as T}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b20.js";import{Q as R,$ as M,a2 as S,I as N,a5 as P}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b11.js";import{I as U}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b214.js";import{W as C}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b19.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b7.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b9.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b8.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b4.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b3.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b2.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b10.js";const H=({selectAll:r,pesquisar:c,setSelecionados:y,tabId:v})=>{const{userTabs:w}=A(),[m,h]=n.useState([]),{language:b}=T(),[i,u]=n.useState([]),{user:f}=L();n.useEffect(()=>{const t=async()=>{let s;switch(v){case 1:s=await C.Chat("List");break;case 2:s=await C.Chat("List","onlyGroups");break;case 3:s=await C.Chat("List","nao-lido");break;case 4:s=await C.Chat("List","1:1");break;case 5:s=await C.Chat("List",{type:"tab_atendentes",user:f});break}u(s),h(s)},a=w.find(s=>s.id===v);a?(u(a.chats),h(a.chats)):t()},[m]),n.useEffect(()=>{if(c.length===0)u(m);else{let t=[];m.forEach(a=>{(a.id.includes(c)||a.name?.toUpperCase().includes(c.toUpperCase()))&&t.push(a)}),u(t)}},[c]);const[x,p]=n.useState(new Set);n.useEffect(()=>{if(r)p(new Set);else{const t=i.map(a=>a.id);p(new Set(t))}},[r]);const o=t=>{p(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})};n.useEffect(()=>{y(m.filter(t=>x.has(t.id)))},[x]);const g=({index:t,key:a,style:s})=>{const l=i[t];if(l)return e.jsx("li",{style:s,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(P,{id:l.id,estado:x.has(l.id),checkedUpdade:()=>o(l.id)}),e.jsx("span",{className:"flex-[inherit] overflow-hidden text-ellipsis whitespace-nowrap",children:e.jsx("strong",{children:l.name})}),e.jsx("span",{children:l.id})]})})},l.id)},_=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 - 340px)",minHeight:"60px",height:`${i.length*32}px`},children:e.jsx(k,{children:({width:t,height:a})=>e.jsx(E,{width:t,height:a,rowCount:i.length,rowHeight:32,rowRenderer:g})})})}),j=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:[" ",c.length!==0?b.nenhumContatoEncontrado:b.carregando,"  "]})})})})})})});return i.length!==0?_:j};function Z({tabId:r,aba_System:c}){const{userTabs:y,setCopyChats:v,setMoveChats:w}=A(),{openRendertype:m,close:h}=B(),{user:b}=L(),[i,u]=n.useState(""),[f,x]=n.useState(!0),p=()=>{x(!f)},{language:o}=T(),[g,_]=n.useState([]),[j,t]=n.useState(y.find(d=>d.id!==r)?.id);g.length>5&&!b.estado&&m("user_free");const a=async()=>{h(),v(g,j),N({type:"Success",message:o.sucessCopyContact,position:"top-right"})},s=async()=>{h(),w(g,r,j),N({type:"Success",message:o.contatosMovidosParaAbaSelecionada,position:"top-right"})};return e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(R,{children:o.menu_moreAba_copyContact_title}),e.jsx(M,{children:o.menu_moreAba_copyContact_subTitle}),e.jsx(U,{inpPlaceTxt:o.menu_moreAba_copyContact_placeContact,inpValue:i,inpSetValue:u,selectAll:f,btnConfirmName:o.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:p,btnNegacaoName:o.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(H,{selectAll:f,pesquisar:i,setSelecionados:_,tabId:r}),e.jsxs("div",{className:"py-4 form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:o.menu_moreAba_copyContact_selectDestiny})}),e.jsx("select",{className:"!py-0 select select-bordered !select-sm w-full",value:j,onChange:d=>t(d.target.value),children:y.map(d=>d.id==r?void 0:e.jsx("option",{value:d.id,children:d.tag}))})]}),e.jsxs("div",{className:(c?"justify-end":"justify-around")+" flex p-2",children:[!c&&e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonMove,funcao:s}),e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonCopy,funcao:a})]})]})}export{Z as default};
