import{r as s,j as e}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b.js";import{p as v,o as w}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b24.js";import{u as x}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b20.js";import{Q as A,$ as N,a2 as S,a5 as I,I as y}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b11.js";import{I as B}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b214.js";import{W as h}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-5de50369a90b6.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 E=async(a,l)=>{const d=x.getState().language,r=v.getState().close;a=a.map(i=>i.id.length>17?i.id+"@g.us":i.id+"@c.us"),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:l,type:"add"}}),r(),y({type:"Success",message:d.menu_moreAba_contatosCopiados,position:"top-right"})},O=async(a,l,d)=>{const r=x.getState().language,i=v.getState().close;a=a.map(o=>o.id.length>17?o.id+"@g.us":o.id+"@c.us"),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:d,type:"remove"}}),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:l,type:"add"}}),i(),y({type:"Success",message:r.menu_moreAba_contatosMovidos,position:"top-right"})},R=({selectAll:a,pesquisar:l,setSelecionados:d,id:r})=>{const{language:i}=x(),[o,j]=s.useState([]),[u,n]=s.useState([]);s.useEffect(()=>{(async()=>{const t=await h.Contact("List",{type:"withLabels",id:r});n(t),j(t)})()},[]),s.useEffect(()=>{if(l.length===0)n(o);else{let t=[];o.forEach(c=>{(c.id.includes(l)||c.name?.toUpperCase().includes(l.toUpperCase()))&&t.push(c)}),n(t)}},[l]);const[m,g]=s.useState(new Set);s.useEffect(()=>{if(a)g(new Set);else{const t=u.map(c=>c.id);g(new Set(t))}},[a]);const _=t=>{g(c=>{const f=new Set(c);return f.has(t)?f.delete(t):f.add(t),f})};s.useEffect(()=>{d(o.filter(t=>m.has(t.id)))},[m]);const C=u.map(t=>e.jsx("li",{children:e.jsx("div",{className:"form-control animate__animated animate__fadeInDownBig",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(I,{id:t.id,estado:m.has(t.id),checkedUpdade:()=>_(t.id)}),e.jsx("span",{children:e.jsx("strong",{children:t.name})}),e.jsx("span",{children:t.id})]})})},t.id));return e.jsx("div",{children:e.jsx("ul",{children:e.jsxs("div",{style:{maxHeight:"calc(100vh - 400px)"},className:"grid overflow-auto mt-4 gap-1",children:[u.length===0?e.jsx("li",{children:e.jsx("div",{children:e.jsxs("span",{className:"w-full text-center p-4",children:[" ",e.jsx("strong",{children:i.menu_moreAba_copyContact_noContact})," "]})})}):void 0,C]})})})};function G({id:a}){const{openRendertype:l}=v(),{user:d}=w(),[r,i]=s.useState(""),[o,j]=s.useState(!0),u=()=>{j(!o)},{language:n}=x(),[m,g]=s.useState([]),[_,C]=s.useState([]),[t,c]=s.useState([]);return s.useEffect(()=>{(async()=>{let b=await h.Labels("getAllLabels");b=b.filter(L=>L.id!==a),c(b[0]),C(b)})()},[]),m.length>5&&!d.estado&&l("user_free"),e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(A,{children:n.menu_moreAba_copyContactForOtherLB}),e.jsx(N,{children:"Selecione os contatos para copiar desta etiqueta"}),e.jsx(B,{inpPlaceTxt:n.menu_moreAba_copyContact_placeContact,inpValue:r,inpSetValue:i,selectAll:o,btnConfirmName:n.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:u,btnNegacaoName:n.menu_moreAba_removeAll,btnNegacaoFuncao:u}),e.jsx(R,{selectAll:o,pesquisar:r,setSelecionados:g,id:a}),e.jsxs("div",{className:"py-4 form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:n.menu_moreAba_copyContact_selectDestiny})}),e.jsx("select",{className:"!py-0 select select-bordered !select-sm w-full",value:t.id,onChange:p=>c(p.target.value),children:_.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.jsxs("div",{className:"justify-around flex p-2",children:[e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonMove,funcao:()=>O(m,t,a)}),e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonCopy,funcao:()=>E(m,t)})]})]})}export{G as default};
