import{j as e}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67155.js";import{r as n}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b6715.js";import{A as k,L as E}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671512.js";import{b as A,u as L}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67154.js";import{u as T,m as B}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671523.js";import{o as R,p as M,r as S,I as N,u as P}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67157.js";import{I as H}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b6715213.js";import{W as C}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67152.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67158.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67153.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67159.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671510.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671520.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67156.js";const O=({selectAll:d,pesquisar:i,setSelecionados:y,tabId:v})=>{const{userTabs:w}=T(),[m,h]=n.useState([]),{language:b}=L(),[l,u]=n.useState([]),f=A(t=>t.user);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(i.length===0)u(m);else{let t=[];m.forEach(a=>{(a.id.includes(i)||a.name?.toUpperCase().includes(i.toUpperCase()))&&t.push(a)}),u(t)}},[i]);const[x,p]=n.useState(new Set);n.useEffect(()=>{if(d)p(new Set);else{const t=l.map(a=>a.id);p(new Set(t))}},[d]);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 r=l[t];if(r)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:r.id,estado:x.has(r.id),checkedUpdade:()=>o(r.id)}),e.jsx("span",{className:"flex-[inherit] overflow-hidden text-ellipsis whitespace-nowrap",children:e.jsx("strong",{children:r.name})}),e.jsx("span",{children:r.id})]})})},r.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:`${l.length*32}px`},children:e.jsx(k,{children:({width:t,height:a})=>e.jsx(E,{width:t,height:a,rowCount:l.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:[" ",i.length!==0?b.nenhumContatoEncontrado:b.carregando,"  "]})})})})})})});return l.length!==0?_:j};function Z({tabId:d,aba_System:i}){const{userTabs:y,setCopyChats:v,setMoveChats:w}=T(),{openRendertype:m,close:h}=B(),b=A(c=>c.session),[l,u]=n.useState(""),[f,x]=n.useState(!0),p=()=>{x(!f)},{language:o}=L(),[g,_]=n.useState([]),[j,t]=n.useState(y.find(c=>c.id!==d)?.id);g.length>5&&!b.is_premium&&m("user_free");const a=async()=>{h(),v(g,j),N({type:"Success",message:o.sucessCopyContact,position:"top-right"})},s=async()=>{h(),w(g,d,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(H,{inpPlaceTxt:o.menu_moreAba_copyContact_placeContact,inpValue:l,inpSetValue:u,selectAll:f,btnConfirmName:o.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:p,btnNegacaoName:o.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(O,{selectAll:f,pesquisar:l,setSelecionados:_,tabId:d}),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:c=>t(c.target.value),children:y.map(c=>c.id==d?void 0:e.jsx("option",{value:c.id,children:c.tag}))})]}),e.jsxs("div",{className:(i?"justify-end":"justify-around")+" flex p-2",children:[!i&&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};
