import{j as e,Q as E,Z as B,a1 as N,I as A,a4 as R}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf10.js";import{a as n}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf4.js";import{A as M,L as P}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf5.js";import{b as L,o as U,n as T}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf23.js";import{u as k}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf19.js";import{I as H}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf212.js";import{W as C}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf18.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf8.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf7.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf6.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf9.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf2.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf3.js";const O=({selectAll:r,pesquisar:c,setSelecionados:y,tabId:v})=>{const{userTabs:w}=L(),[m,h]=n.useState([]),{language:b}=k(),[i,u]=n.useState([]),{user:f}=T();n.useEffect(()=>{const s=async()=>{let t;switch(v){case 1:t=await C.Chat("List");break;case 2:t=await C.Chat("List","onlyGroups");break;case 3:t=await C.Chat("List","nao-lido");break;case 4:t=await C.Chat("List","1:1");break;case 5:t=await C.Chat("List",{type:"tab_atendentes",user:f});break}u(t),h(t)},a=w.find(t=>t.id===v);a?(u(a.chats),h(a.chats)):s()},[m]),n.useEffect(()=>{if(c.length===0)u(m);else{let s=[];m.forEach(a=>{var t;(a.id.includes(c)||(t=a.name)!=null&&t.toUpperCase().includes(c.toUpperCase()))&&s.push(a)}),u(s)}},[c]);const[x,p]=n.useState(new Set);n.useEffect(()=>{if(r)p(new Set);else{const s=i.map(a=>a.id);p(new Set(s))}},[r]);const o=s=>{p(a=>{const t=new Set(a);return t.has(s)?t.delete(s):t.add(s),t})};n.useEffect(()=>{y(m.filter(s=>x.has(s.id)))},[x]);const g=({index:s,key:a,style:t})=>{const l=i[s];if(l)return e.jsx("li",{style:t,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(R,{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(M,{children:({width:s,height:a})=>e.jsx(P,{width:s,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 q({tabId:r,aba_System:c}){var S;const{userTabs:y,setCopyChats:v,setMoveChats:w}=L(),{openRendertype:m,close:h}=U(),{user:b}=T(),[i,u]=n.useState(""),[f,x]=n.useState(!0),p=()=>{x(!f)},{language:o}=k(),[g,_]=n.useState([]),[j,s]=n.useState((S=y.find(d=>d.id!==r))==null?void 0:S.id);g.length>5&&!b.estado&&m("user_free");const a=async()=>{h(),v(g,j),A({type:"Success",message:o.sucessCopyContact,position:"top-right"})},t=async()=>{h(),w(g,r,j),A({type:"Success",message:o.contatosMovidosParaAbaSelecionada,position:"top-right"})};return e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(E,{children:o.menu_moreAba_copyContact_title}),e.jsx(B,{children:o.menu_moreAba_copyContact_subTitle}),e.jsx(H,{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(O,{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=>s(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(N,{name:o.menu_moreAba_copyContact_placeButtonMove,funcao:t}),e.jsx(N,{name:o.menu_moreAba_copyContact_placeButtonCopy,funcao:a})]})]})}export{q as default};
