1import{c as le,r as n,s as p,j as e,X as V,L as J,a3 as d,aw as pe,a1 as be,aL as ee,U as ge,K as se,ar as fe,I as ve,d as u}from"./index-D4We9MQH.js";import{a as m}from"./api-Bym0Qq7Y.js";import{P as te}from"./plus-VmBq9j9n.js";import{S as ae}from"./save-BFKRwwgm.js";import{T as O}from"./trash-2-D-2wB5p1.js";import{U as re}from"./user-plus-B9jsPwDW.js";import{S as je}from"./shield-check-BHgb0Vb8.js";import{S as we}from"./search-BFBC9axV.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ne=le("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const X=le("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),ye=({isOpen:b,onClose:E,onUpdate:h})=>{const[_,w]=n.useState("teams"),[U,C]=n.useState([]),[P,$]=n.useState([]),[N,F]=n.useState(!0),[T,i]=n.useState(null),[r,c]=n.useState({name:"",description:"",color:"#3b82f6"}),[A,f]=n.useState(!1);n.useEffect(()=>{b&&(v(),y())},[b]);const v=async()=>{F(!0);try{const[t,l]=await Promise.all([m.fetchTeams(),m.fetchTeamFunctions()]);C(t),$(l)}catch(t){console.error("Error loading data:",t)}finally{F(!1)}},y=()=>{const t=p.channel("teams-changes").on("postgres_changes",{event:"*",schema:"public",table:"teams"},()=>{v()}).subscribe(),l=p.channel("functions-changes").on("postgres_changes",{event:"*",schema:"public",table:"team_functions"},()=>{v()}).subscribe();return()=>{p.removeChannel(t),p.removeChannel(l)}},k=async()=>{if(r.name.trim())try{await m.createTeam({name:r.name,description:r.description,color:r.color}),c({name:"",description:"",color:"#3b82f6"}),f(!1),h()}catch(t){console.error("Error creating team:",t)}},D=async()=>{if(r.name.trim())try{await m.createTeamFunction({name:r.name,description:r.description}),c({name:"",description:"",color:"#3b82f6"}),f(!1),h()}catch(t){console.error("Error creating function:",t)}},I=async t=>{try{await m.updateTeam(t,{name:r.name,description:r.description,color:r.color}),i(null),c({name:"",description:"",color:"#3b82f6"}),h()}catch(l){console.error("Error updating team:",l)}},q=async t=>{try{await m.updateTeamFunction(t,{name:r.name,description:r.description}),i(null),c({name:"",description:"",color:"#3b82f6"}),h()}catch(l){console.error("Error updating function:",l)}},R=async t=>{if(confirm("Tem certeza que deseja excluir este time?"))try{await m.deleteTeam(t),h()}catch(l){console.error("Error deleting team:",l)}},G=async t=>{if(confirm("Tem certeza que deseja excluir esta função?"))try{await m.deleteTeamFunction(t),h()}catch(l){console.error("Error deleting function:",l)}},M=(t,l)=>{i(t.id),c({name:t.name,description:t.description||"",color:l==="team"&&t.color||"#3b82f6"})};return b?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"p-6 border-b border-slate-800 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"âï¸ Configurar Equipe"}),e.jsx("button",{onClick:E,className:"text-slate-400 hover:text-white transition-colors",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex border-b border-slate-800",children:[e.jsx("button",{onClick:()=>w("teams"),className:`flex-1 px-6 py-3 text-sm font-medium transition-colors ${_==="teams"?"text-white border-b-2 border-cyan-500 bg-slate-800/50":"text-slate-400 hover:text-white"}`,children:"ð¢ Times"}),e.jsx("button",{onClick:()=>w("functions"),className:`flex-1 px-6 py-3 text-sm font-medium transition-colors ${_==="functions"?"text-white border-b-2 border-cyan-500 bg-slate-800/50":"text-slate-400 hover:text-white"}`,children:"ð¼ Funções"})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[50vh] custom-scrollbar",children:N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(J,{className:"h-6 w-6 animate-spin text-cyan-500"})}):_==="teams"?e.jsxs("div",{className:"space-y-3",children:[A?e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4 space-y-3",children:[e.jsx("input",{type:"text",placeholder:"Nome do time",value:r.name,onChange:t=>c({...r,name:t.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsx("input",{type:"text",placeholder:"Descrição (opcional)",value:r.description,onChange:t=>c({...r,description:t.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:r.color,onChange:t=>c({...r,color:t.target.value}),className:"w-12 h-8 rounded cursor-pointer"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Cor do time"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{onClick:k,className:"flex-1",children:"Salvar"}),e.jsx(d,{onClick:()=>f(!1),variant:"ghost",children:"Cancelar"})]})]}):e.jsxs("button",{onClick:()=>f(!0),className:"w-full bg-slate-800/30 border border-dashed border-slate-700 rounded-lg p-4 text-slate-400 hover:text-white hover:border-slate-600 transition-colors flex items-center justify-center gap-2",children:[e.jsx(te,{className:"w-4 h-4"}),"Novo Time"]}),U.map(t=>e.jsx("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4",children:T===t.id?e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:r.name,onChange:l=>c({...r,name:l.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsx("input",{type:"text",value:r.description,onChange:l=>c({...r,description:l.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("input",{type:"color",value:r.color,onChange:l=>c({...r,color:l.target.value}),className:"w-12 h-8 rounded cursor-pointer"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{onClick:()=>I(t.id),size:"sm",children:[e.jsx(ae,{className:"w-3 h-3 mr-1"}),"Salvar"]}),e.jsx(d,{onClick:()=>i(null),variant:"ghost",size:"sm",children:"Cancelar"})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:t.color||"#3b82f6"}}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.name}),t.description&&e.jsx("div",{className:"text-xs text-slate-400",children:t.description})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>M(t,"team"),className:"p-2 text-slate-400 hover:text-white transition-colors",children:e.jsx(X,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>R(t.id),className:"p-2 text-slate-400 hover:text-red-400 transition-colors",children:e.jsx(O,{className:"w-4 h-4"})})]})]})},t.id))]}):e.jsxs("div",{className:"space-y-3",children:[A?e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4 space-y-3",children:[e.jsx("input",{type:"text",placeholder:"Nome da função",value:r.name,onChange:t=>c({...r,name:t.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsx("input",{type:"text",placeholder:"Descrição (opcional)",value:r.description,onChange:t=>c({...r,description:t.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{onClick:D,className:"flex-1",children:"Salvar"}),e.jsx(d,{onClick:()=>f(!1),variant:"ghost",children:"Cancelar"})]})]}):e.jsxs("button",{onClick:()=>f(!0),className:"w-full bg-slate-800/30 border border-dashed border-slate-700 rounded-lg p-4 text-slate-400 hover:text-white hover:border-slate-600 transition-colors flex items-center justify-center gap-2",children:[e.jsx(te,{className:"w-4 h-4"}),"Nova Função"]}),P.map(t=>e.jsx("div",{className:"bg-slate-800/50 border border-slate-700 rounded-lg p-4",children:T===t.id?e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:r.name,onChange:l=>c({...r,name:l.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsx("input",{type:"text",value:r.description,onChange:l=>c({...r,description:l.target.value}),className:"w-full bg-slate-950 border border-slate-700 rounded-lg px-3 py-2 text-sm text-white"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{onClick:()=>
11q(t.id),size:"sm",children:[e.jsx(ae,{className:"w-3 h-3 mr-1"}),"Salvar"]}),e.jsx(d,{onClick:()=>i(null),variant:"ghost",size:"sm",children:"Cancelar"})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.name}),t.description&&e.jsx("div",{className:"text-xs text-slate-400",children:t.description})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>M(t,"function"),className:"p-2 text-slate-400 hover:text-white transition-colors",children:e.jsx(X,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>G(t.id),className:"p-2 text-slate-400 hover:text-red-400 transition-colors",children:e.jsx(O,{className:"w-4 h-4"})})]})]})},t.id))]})}),e.jsx("div",{className:"p-4 border-t border-slate-800 flex justify-end",children:e.jsx(d,{onClick:E,variant:"ghost",children:"Fechar"})})]})}):null},Pe=()=>{const[b,E]=n.useState([]),[h,_]=n.useState([]),[w,U]=n.useState([]),[C,P]=n.useState(!0),[$,N]=n.useState(!1),[F,T]=n.useState(!1),[i,r]=n.useState({name:"",email:"",role:"agent",team_id:"",function_id:"",weight:1}),[c,A]=n.useState(""),[f,v]=n.useState(!1),[y,k]=n.useState(null),[D,I]=n.useState(!0),[q,R]=n.useState(null),[G,M]=n.useState(!1),[t,l]=n.useState(""),[H,B]=n.useState(!1),[Q,W]=n.useState(!1),[o,j]=n.useState({name:"",email:"",role:"agent",status:"invited",team_id:"",function_id:"",weight:1});n.useEffect(()=>(S(),ne()),[]);const S=async()=>{P(!0);try{const[s,a,g]=await Promise.all([m.fetchTeam(),m.fetchTeams(),m.fetchTeamFunctions()]);E(s),_(a),U(g);const{data:x}=await p.from("system_settings").select("*").maybeSingle();I((x==null?void 0:x.registration_enabled)??!0),R((x==null?void 0:x.id)??null)}catch(s){console.error("Erro ao carregar dados da equipe",s)}finally{P(!1)}},ne=()=>{const s=p.channel("team-members-changes").on("postgres_changes",{event:"*",schema:"public",table:"team_members"},a=>{a.eventType==="UPDATE"&&a.new?E(g=>g.map(x=>x.id===a.new.id?{...x,...a.new}:x)):S()}).subscribe();return()=>{p.removeChannel(s)}},ie=async s=>{M(!0);try{if(q)await p.from("system_settings").update({registration_enabled:s}).eq("id",q);else{const{data:a}=await p.from("system_settings").insert({registration_enabled:s}).select().single();a&&R(a.id)}I(s),u.success(s?"Registro de novos usuários habilitado":"Registro de novos usuários desabilitado")}catch(a){console.error("Erro ao atualizar configuração de registro:",a),u.error("Erro ao atualizar configuração")}finally{M(!1)}},oe=async s=>{s.preventDefault();try{await m.createTeamMember({name:i.name,email:i.email,role:i.role,team_id:i.team_id||void 0,function_id:i.function_id||void 0,weight:i.weight}),u.success("Membro convidado com sucesso!"),N(!1),r({name:"",email:"",role:"agent",team_id:"",function_id:"",weight:1}),await S()}catch(a){console.error("Erro ao convidar membro:",a),u.error("Erro ao convidar membro. Verifique se o email já não está cadastrado.")}},z=async(s,a,g)=>{try{await m.updateTeamMember(s,{[a]:g}),u.success("Membro atualizado com sucesso")}catch(x){console.error("Erro ao atualizar membro:",x),u.error("Erro ao atualizar membro")}},ce=async(s,a)=>{if(confirm(`Tem certeza que deseja excluir ${a}?`))try{await m.deleteTeamMember(s),u.success("Membro removido com sucesso"),await S()}catch(g){console.error("Erro ao remover membro:",g),u.error("Erro ao remover membro")}},de=s=>{k(s),l(""),B(!1),j({name:s.name,email:s.email,role:s.role,status:s.status,team_id:s.team_id||"",function_id:s.function_id||"",weight:s.weight||1}),v(!0)},me=async s=>{if(s.preventDefault(),!!y)try{await m.updateTeamMember(y.id,{name:o.name,email:o.email,role:o.role,status:o.status,team_id:o.team_id||null,function_id:o.function_id||null,weight:o.weight}),u.success("Membro atualizado com sucesso!"),v(!1),k(null),await S()}catch(a){console.error("Erro ao editar membro:",a),u.error("Erro ao editar membro")}},xe=async()=>{if(y){if(!t||t.length<6){u.error("A senha precisa ter pelo menos 6 caracteres");return}W(!0);try{const{data:s,error:a}=await p.functions.invoke("admin-update-user-password",{body:{email:y.email,password:t}});if(a)throw a;if(s!=null&&s.error)throw new Error(s.error);u.success("Senha atualizada com sucesso"),l(""),B(!1)}catch(s){console.error("Erro ao atualizar senha:",s),u.error((s==null?void 0:s.message)||"Erro ao atualizar senha")}finally{W(!1)}}},ue=s=>{switch(s){case"active":return e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-bold bg-slate-950 border border-slate-700 text-white shadow-sm",children:"Ativo"});case"invited":return e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-bold bg-slate-950 border border-amber-900/50 text-amber-500 shadow-sm",children:"Pendente"});default:return e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-bold bg-slate-950 border border-slate-800 text-slate-500 shadow-sm",children:"Inativo"})}},he=b.filter(s=>{var Y,Z;if(!c.trim())return!0;const a=c.toLowerCase(),g=((Y=h.find(K=>K.id===s.team_id))==null?void 0:Y.name)||"",x=((Z=w.find(K=>K.id===s.function_id))==null?void 0:Z.name)||"";return s.name.toLowerCase().includes(a)||s.email.toLowerCase().includes(a)||g.toLowerCase().includes(a)||x.toLowerCase().includes(a)}),L={total:b.length,admins:b.filter(s=>s.role==="admin").length,members:b.filter(s=>s.role!=="admin").length,teams:h.length};return e.jsxs("div",{className:"p-8 h-full overflow-y-auto bg-slate-950 text-slate-50 relative custom-scrollbar",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between mb-8 gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight text-white",children:"Equipe"}),e.jsx("p",{className:"text-sm text-slate-400 mt-1",children:"Gerencie usuários e times da organização"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(d,{onClick:()=>T(!0),variant:"outline",className:"border-slate-700",children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),"Configurar"]}),e.jsxs(d,{onClick:()=>N(!0),className:"shadow-lg shadow-cyan-500/20 bg-slate-100 text-slate-900 hover:bg-white hover:text-black",children:[e.jsx(re,{className:"w-4 h-4 mr-2"}),"Convidar Usuário"]})]})]}),e.jsx("div",{className:"bg-slate-900/50 border border-slate-800 rounded-xl p-5 shadow-sm mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(je,{className:"w-5 h-5 text-emerald-400"}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"registration-toggle",className:"text-sm font-medium text-slate-200 cursor-pointer",children:"Permitir novos registros"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:D?"Novos usuários podem criar conta na plataforma":"Registro de novos usuários está bloqueado"})]})]}),e.jsx(ee,{id:"registration-toggle",checked:D,onCheckedChange:ie,disabled:G})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-xl p-5 shadow-sm",children:[e.jsx("div",{className:"text-sm font-medium text-slate-400 mb-2",children:"Total de Usuários"}),e.jsx("div",{className:"text-3xl font-bold text-white",children:C?"-":L.total})]}),e.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-xl p-5 shadow-sm",children:[e.jsx("div",{className:"text-sm font-medium text-slate-400 mb-2",children:"Admins"}),e.jsx("div",{className:"text-3xl font-bold text-white",children:C?"-":L.admins})]}),e.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-xl p-5 shadow-sm",children:[e.jsx("div",{className:"text-sm font-medium text-slate-400 mb-2",children:"Membros"}),e.jsx("div",{className:"text-3xl font-bold text-white",children:C?"-":L.members})]}),e.jsxs("div",{className:"bg-slate-900/50 border border-slate-800 rounded-xl p-5 shadow-sm",children:[e.jsx("div",{className:"text-sm font-medium text-slate-400 mb-2",children:"Times Ativos"}),e.jsx("div",{className:"text-3xl font-bold text-white",children:L.teams})]})]}),e.jsxs("div",{className:"mb-6 relative",children:[e.jsx(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Buscar por nome, email, time ou função...",value:c,onChange:s=>A(s.target.value),className:"w-full sm:w-96 pl-10 pr-4 py-2 bg-slate-900/50 border border-slate-800 rounded-lg text-sm text-slate-200 focus:ring-1 focus:ring-slate-700 outline-none placeholder:text-slate-600 transition-all"})]}),e.jsxs("div",{className:"bg-slate-900/30 border border-slate-800 rounded-xl overflow-hidden shadow-xl",children:[e.jsxs("div",{className:"p-6 border-b border-slate-800",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Usuários da Equipe"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"Gerencie roles e times dos usuários"})]}),C?e.jsxs("div",{className:"flex flex-col items-center justify-center p-12",children:[e.jsx(J,{className:"h-8 w-8 animate-spin text-cyan-500 mb-3"}),e.jsx("span",{className:"text-sm text-slate-400",children:"Carregando dados..."})]}):b.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-12",children:[e.jsx(ge,{className:"w-12 h-12 text-slate-600 mb-4"}),e.jsx("p",{className:"text-slate-400 mb-4",children:"Nenhum membro cadastrado ainda."}),e.jsxs(d,{onClick:()=>N(!0),className:"bg-slate-100 text-slate-900 hover:bg-white",children:[e.jsx(re,{className:"w-4 h-4 mr-2"}),"Convidar Primeiro Membro"]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Usuário"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Email"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Role"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Time"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Função"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Peso"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider text-center",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-xs font-medium text-slate-500 uppercase tracking-wider text-center",children:"Ações"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-800/30",children:he.map(s=>e.jsxs("tr",{className:"hover:bg-slate-800/20 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-slate-800 flex items-center justify-center text-xs font-bold text-slate-300 border border-slate-700 uppercase",children:s.name.substring(0,2)}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-slate-900 ${s.status==="active"?"bg-emerald-400":s.status==="invited"?"bg-amber-400":"bg-slate-500"}`,title:s.status==="active"?"DisponÃvel":s.status==="invited"?"Pendente":"IndisponÃvel"}),s.status==="active"&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full bg-emerald-400 animate-ping opacity-60"})]}),e.jsx("span",{className:"text-sm font-medium text-slate-200",children:s.name})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-slate-400",children:s.email})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("select",{value:s.role,onChange:a=>z(s.id,"role",a.target.value),className:"w-32 px-3 py-1.5 bg-slate-950 border border-slate-800 rounded-md text-sm text-slate-300 cursor-pointer hover:border-slate-600 transition-colors",children:[e.jsx("option",{value:"agent",children:"Atendente"}),e.jsx("option",{value:"manager",children:"Gerente"}),e.jsx("option",{value:"admin",children:"Admin"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("select",{value:s.team_id||"",onChange:a=>z(s.id,"team_id",a.target.value||null),className:"w-32 px-3 py-1.5 bg-slate-950 border border-slate-800 rounded-md text-sm text-slate-300 cursor-pointer hover:border-slate-600 transition-colors",children:[e.jsx("option",{value:"",children:"Sem time"}),h.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("select",{value:s.function_id||"",onChange:a=>z(s.id,"function_id",a.target.value||null),className:"w-32 px-3 py-1.5 bg-slate-950 border border-slate-800 rounded-md text-sm text-slate-300 cursor-pointer hover:border-slate-600 transition-colors",children:[e.jsx("option",{value:"",children:"Sem função"}),w.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("input",{type:"number",min:"1",max:"10",value:s.weight||1,onChange:a=>z(s.id,"weight",parseInt(a.target.value)),className:"w-16 px-2 py-1 bg-slate-950 border border-slate-800 rounded-md text-sm text-slate-300 text-center"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-center",children:s.status==="invited"?ue(s.status):e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(ee,{checked:s.status==="active",onCheckedChange:a=>z(s.id,"status",a?"active":"disabled")}),e.jsx("span",{className:`text-xs font-semibold ${s.status==="active"?"text-emerald-400":"text-slate-500"}`,children:s.status==="active"?"DisponÃvel":"IndisponÃvel"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx("button",{onClick:()=>de(s),className:"p-2 rounded-lg text-slate-500 hover:bg-slate-800 hover:text-white transition-colors",title:"Editar membro",children:e.jsx(X,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ce(s.id,s.name),className:"p-2 rounded-lg text-slate-500 hover:bg-red-900/50 hover:text-red-400 transition-colors",title:"Excluir membro",children:e.jsx(O,{className:"w-4 h-4"})})]})})]},s.id))})]})})]}),$&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-xl shadow-2xl max-w-md w-full overflow-hidden animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"p-6 border-b border-slate-800 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Convidar para a Equipe"}),e.jsx("button",{onClick:()=>N(!1),className:"text-slate-400 hover:text-white transition-colors",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:oe,className:"p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Nome Completo"}),e.jsx("input",{required:!0,type:"text",className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white focus:ring-1 focus:ring-slate-600 outline-none transition-all",placeholder:"Ex: João da Silva",value:i.name,onChange:s=>r({...i,name:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Email Corporativo"}),e.jsx("input",{required:!0,type:"email",className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white focus:ring-1 focus:ring-slate-600 outline-none transition-all",placeholder:"[email protected]",value:i.email,onChange:s=>r({...i,email:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"NÃvel de Acesso"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["agent","manager","admin"].map(s=>e.jsxs("div",{onClick:()=>r({.
11..i,role:s}),className:`cursor-pointer rounded-lg border p-2 text-center transition-all ${i.role===s?"bg-slate-800 border-slate-500 text-white":"bg-slate-950 border-slate-800 text-slate-500 hover:border-slate-700"}`,children:[e.jsx("div",{className:"text-xs font-bold uppercase mb-1",children:s==="agent"?"Atendente":s==="manager"?"Gerente":"Admin"}),i.role===s&&e.jsx("div",{className:"flex justify-center",children:e.jsx(se,{className:"w-3 h-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Time (opcional)"}),e.jsxs("select",{value:i.team_id,onChange:s=>r({...i,team_id:s.target.value}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white",children:[e.jsx("option",{value:"",children:"Sem time"}),h.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Função (opcional)"}),e.jsxs("select",{value:i.function_id,onChange:s=>r({...i,function_id:s.target.value}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white",children:[e.jsx("option",{value:"",children:"Sem função"}),w.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Peso (para distribuição)"}),e.jsx("input",{type:"number",min:"1",max:"10",value:i.weight,onChange:s=>r({...i,weight:parseInt(s.target.value)}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white"})]}),e.jsxs("div",{className:"pt-4 flex gap-3",children:[e.jsx(d,{type:"button",variant:"ghost",onClick:()=>N(!1),className:"flex-1 border border-slate-700 hover:bg-slate-800",children:"Cancelar"}),e.jsx(d,{type:"submit",className:"flex-1 bg-white text-black hover:bg-slate-200",children:"Enviar Convite"})]})]})]})}),e.jsx(ye,{isOpen:F,onClose:()=>T(!1),onUpdate:S}),f&&y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-xl shadow-2xl max-w-md w-full overflow-hidden animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"p-6 border-b border-slate-800 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Editar Membro"}),e.jsx("button",{onClick:()=>{v(!1),k(null)},className:"text-slate-400 hover:text-white transition-colors",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:me,className:"p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Nome Completo"}),e.jsx("input",{required:!0,type:"text",className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white focus:ring-1 focus:ring-slate-600 outline-none transition-all",value:o.name,onChange:s=>j({...o,name:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Email"}),e.jsx("input",{required:!0,type:"email",className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white focus:ring-1 focus:ring-slate-600 outline-none transition-all",value:o.email,onChange:s=>j({...o,email:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"NÃvel de Acesso"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["agent","manager","admin"].map(s=>e.jsxs("div",{onClick:()=>j({...o,role:s}),className:`cursor-pointer rounded-lg border p-2 text-center transition-all ${o.role===s?"bg-slate-800 border-slate-500 text-white":"bg-slate-950 border-slate-800 text-slate-500 hover:border-slate-700"}`,children:[e.jsx("div",{className:"text-xs font-bold uppercase mb-1",children:s==="agent"?"Atendente":s==="manager"?"Gerente":"Admin"}),o.role===s&&e.jsx("div",{className:"flex justify-center",children:e.jsx(se,{className:"w-3 h-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Status"}),e.jsxs("select",{value:o.status,onChange:s=>j({...o,status:s.target.value}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white",children:[e.jsx("option",{value:"active",children:"Ativo"}),e.jsx("option",{value:"invited",children:"Pendente"}),e.jsx("option",{value:"disabled",children:"Inativo"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Time"}),e.jsxs("select",{value:o.team_id,onChange:s=>j({...o,team_id:s.target.value}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white",children:[e.jsx("option",{value:"",children:"Sem time"}),h.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Função"}),e.jsxs("select",{value:o.function_id,onChange:s=>j({...o,function_id:s.target.value}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white",children:[e.jsx("option",{value:"",children:"Sem função"}),w.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-300",children:"Peso"}),e.jsx("input",{type:"number",min:"1",max:"10",value:o.weight,onChange:s=>j({...o,weight:parseInt(s.target.value)}),className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 text-sm text-white"})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-800",children:[e.jsxs("label",{className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 text-amber-400"}),"Alterar senha do membro"]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Define uma nova senha de login. O membro precisa já ter conta criada com este email."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:H?"text":"password",value:t,onChange:s=>l(s.target.value),placeholder:"Nova senha (mÃn. 6 caracteres)",className:"w-full bg-slate-950 border border-slate-800 rounded-lg p-2.5 pr-10 text-sm text-white focus:ring-1 focus:ring-slate-600 outline-none",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>B(s=>!s),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-slate-400 hover:text-white",tabIndex:-1,
11children:H?e.jsx(fe,{className:"w-4 h-4"}):e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsx(d,{type:"button",onClick:xe,disabled:Q||!t,className:"bg-amber-500 text-black hover:bg-amber-400 disabled:opacity-50",children:Q?e.jsx(J,{className:"w-4 h-4 animate-spin"}):"Salvar senha"})]})]}),e.jsxs("div",{className:"pt-4 flex gap-3",children:[e.jsx(d,{type:"button",variant:"ghost",onClick:()=>{v(!1),k(null)},className:"flex-1 border border-slate-700 hover:bg-slate-800",children:"Cancelar"}),e.jsx(d,{type:"submit",className:"flex-1 bg-white text-black hover:bg-slate-200",children:"Salvar Alterações"})]})]})]})})]})};export{Pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.