import{j as e,v as w,D as A,J as S,V as N,I as y}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e10.js";import{a as s}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e4.js";import{n as v,m as I}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e22.js";import{u as x}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e19.js";import{I as B}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e173.js";import{W as h}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e18.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e8.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e5.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e7.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e6.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e2.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e3.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e9.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(o=>o.id.length>17?o.id+"@g.us":o.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(),[o,j]=s.useState([]),[p,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=>{var d;(c.id.includes(l)||(d=c.name)!=null&&d.toUpperCase().includes(l.toUpperCase()))&&t.push(c)}),n(t)}},[l]);const[u,f]=s.useState(new Set);s.useEffect(()=>{if(a)f(new Set);else{const t=p.map(c=>c.id);f(new Set(t))}},[a]);const _=t=>{f(c=>{const d=new Set(c);return d.has(t)?d.delete(t):d.add(t),d})};s.useEffect(()=>{m(o.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(N,{id:t.id,estado:u.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:[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 K({id:a}){const{openRendertype:l}=v(),{user:m}=I(),[r,i]=s.useState(""),[o,j]=s.useState(!0),p=()=>{j(!o)},{language:n}=x(),[u,f]=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)})()},[]),u.length>5&&!m.estado&&l("user_free"),e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(w,{children:n.menu_moreAba_copyContactForOtherLB}),e.jsx(A,{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:p,btnNegacaoName:n.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(R,{selectAll:o,pesquisar:r,setSelecionados:f,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:g=>c(g.target.value),children:_.map(g=>e.jsx("option",{value:g.id,children:g.name},g.id))})]}),e.jsxs("div",{className:"justify-around flex p-2",children:[e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonMove,funcao:()=>O(u,t,a)}),e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonCopy,funcao:()=>E(u,t)})]})]})}export{K as default};
