import{j as e}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0286.js";import{a as s}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0282.js";import{b as w,u as x}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0285.js";import{k as v}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b02821.js";import{a as A,b as N,c as S,e as I,I as y}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0288.js";import{I as B}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b028223.js";import{W as h}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0283.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0284.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b02820.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b028.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0287.js";const E=async(a,l)=>{const m=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:m.menu_moreAba_contatosCopiados,position:"top-right"})},O=async(a,l,m)=>{const r=x.getState().language,i=v.getState().close;a=a.map(n=>n.id.length>17?n.id+"@g.us":n.id+"@c.us"),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:m,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:m,id:r})=>{const{language:i}=x(),[n,_]=s.useState([]),[p,o]=s.useState([]);s.useEffect(()=>{(async()=>{const t=await h.Contact("List",{type:"withLabels",id:r});o(t),_(t)})()},[]),s.useEffect(()=>{if(l.length===0)o(n);else{let t=[];n.forEach(c=>{(c.id.includes(l)||c.name?.toUpperCase().includes(l.toUpperCase()))&&t.push(c)}),o(t)}},[l]);const[u,g]=s.useState(new Set);s.useEffect(()=>{if(a)g(new Set);else{const t=p.map(c=>c.id);g(new Set(t))}},[a]);const j=t=>{g(c=>{const f=new Set(c);return f.has(t)?f.delete(t):f.add(t),f})};s.useEffect(()=>{m(n.filter(t=>u.has(t.id)))},[u]);const C=p.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:u.has(t.id),checkedUpdade:()=>j(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:[p.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 q({id:a}){const{openRendertype:l}=v(),m=w(d=>d.session),[r,i]=s.useState(""),[n,_]=s.useState(!0),p=()=>{_(!n)},{language:o}=x(),[u,g]=s.useState([]),[j,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)})()},[]),u.length>5&&!m.is_premium&&l("user_free"),e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(A,{children:o.menu_moreAba_copyContactForOtherLB}),e.jsx(N,{children:"Selecione os contatos para copiar desta etiqueta"}),e.jsx(B,{inpPlaceTxt:o.menu_moreAba_copyContact_placeContact,inpValue:r,inpSetValue:i,selectAll:n,btnConfirmName:o.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:p,btnNegacaoName:o.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(R,{selectAll:n,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:o.menu_moreAba_copyContact_selectDestiny})}),e.jsx("select",{className:"!py-0 select select-bordered !select-sm w-full",value:t.id,onChange:d=>c(d.target.value),children:j.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id))})]}),e.jsxs("div",{className:"justify-around flex p-2",children:[e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonMove,funcao:()=>O(u,t,a)}),e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonCopy,funcao:()=>E(u,t)})]})]})}export{q as default};
