1import{c as B,n as L,a as T,r as o,d,p as E,j as e,q as N,X as v,L as c,b as l}from"./index-B7K0hbsK.js";import{T as O}from"./triviaQuestions-DzwSBmSh.js";import{A as U}from"./AcademyHeader-B-hvZw2N.js";import{P as z}from"./play-CaBjQeDj.js";import{C as F}from"./clock-DS1lY6td.js";import{T as R}from"./trophy-DSgpSoCc.js";import"./academy-DW3XVGCf.js";import"./heart-BN6blTLw.js";import"./zap-D8U1ozAB.js";import"./graduation-cap-COd5h-H7.js";import"./book-open-DPG1iE9C.js";import"./image-CbsQmqyH.js";/** 2 * @license lucide-react v0.475.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 K=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],M=B("Swords",K);function te(){const m=L(),y=T(),[t,w]=o.useState(null),[x,h]=o.useState(!1),[u,_]=o.useState("");o.useEffect(()=>{const s=localStorage.getItem("colaborador_logado");s&&w(JSON.parse(s))},[]);const{data:A}=d({queryKey:["progresso-ingles",t==null?void 0:t.id],queryFn:async()=>(await l.entities.ProgressoIngles.filter({colaborador_id:t.id}))[0]||null,enabled:!!t}),{data:k=[],isLoading:C}=d({queryKey:["todos-progressos"],queryFn:()=>l.entities.ProgressoIngles.list(),enabled:x}),{data:i=[],isLoading:D}=d({queryKey:["batalhas-ingles",t==null?void 0:t.id],queryFn:async()=>{const[s,a]=await Promise.all([l.entities.DesafioIngles.filter({criador_id:t.id}),l.entities.DesafioIngles.filter({oponente_id:t.id})]);return[...s,...a]},enabled:!!t}),{mutate:P,isPending:n}=E({mutationFn:async s=>{if(!s)return;const a=[...O].sort(()=>Math.random()-.5).slice(0,5).map(r=>r.id);return await l.entities.DesafioIngles.create({criador_id:t.id,criador_nome:t.nome,oponente_id:s.colaborador_id,oponente_nome:s.colaborador_nome,perguntas_indices:a,status:"AGUARDANDO",criador_acertos:null,criador_tempo:null,oponente_acertos:null,oponente_tempo:null,vencedor_id:null})},onSuccess:s=>{y.invalidateQueries({queryKey:["batalhas-ingles"]}),s!=null&&s.id&&m(N("ArenaBatalha")+"?id=".concat(s.id))}});if(!t)return null;const f=k.filter(s=>{var a;return s.colaborador_id!==t.id&&((a=s.colaborador_nome)==null?void 0:a.toLowerCase().includes(u.toLowerCase()))}).sort((s,a)=>(a.nivel||1)-(s.nivel||1)),p=i.filter(s=>s.status==="AGUARDANDO"&&s.oponente_id===t.id),g=i.filter(s=>s.status==="AGUARDANDO"&&s.criador_id===t.id),b=i.filter(s=>s.status==="FINALIZADO"&&(s.criador_id===t.id||s.oponente_id===t.id)).sort((s,a)=>a.id.localeCompare(s.id));return e.jsxs("div",{className:"relative english-academy min-h-screen bg-slate-50/50 flex flex-col items-center",children:[e.jsx(U,{progresso:A,currentPage:"TrilhasIngles"}),e.jsxs("div",{className:"w-full max-w-3xl mt-6 p-4 sm:p-6 mb-20 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-indigo-900 via-slate-800 to-indigo-950 rounded-2xl p-8 shadow-sm mb-8 border border-slate-700/50 flex flex-col sm:flex-row items-center justify-between gap-6 group",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-fuchsia-500/10 rounded-full blur-3xl -translate-y-1/2 translate-x-1/3 group-hover:bg-fuchsia-500/20 transition-all duration-700"}),e.jsxs("div",{className:"flex items-center gap-6 relative z-10 w-full sm:w-auto",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-white/10 flex items-center justify-center text-4xl shadow-xl backdrop-blur-md group-hover:scale-105 group-hover:-rotate-3 transition-transform border border-white/20 shrink-0",children:"âï¸"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight",children:"Arena Trivia"}),e.jsx("p",{className:"text-indigo-200 mt-1 font-medium",children:"Desafie seus colegas e roube XP em batalhas rápidas!"})]})]}),e.jsxs("button",{onClick:()=>h(!0),className:"w-full sm:w-auto flex items-center justify-center gap-2 bg-gradient-to-r from-fuchsia-500 to-rose-500 hover:from-fuchsia-400 hover:to-rose-400 text-white font-extrabold px-8 py-4 rounded-xl shadow-lg shadow-rose-500/30 transition-all hover:-translate-y-1 active:scale-95 z-10",children:[e.jsx(M,{className:"w-5 h-5"}),"Desafiar Alguém"]})]}),p.length>0&&e.jsxs("div",{className:"mb-10",children:[e.jsxs("h2",{className:"text-xl font-extrabold text-slate-800 mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"w-3 h-3 bg-rose-500 rounded-full animate-pulse"}),"à a sua vez!"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:p.map(s=>{var a,r;return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-200 flex items-center justify-between hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center font-bold text-slate-500 border border-slate-200",children:(a=s.criador_nome)==null?void 0:a.charAt(0)}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-800 leading-tight",children:(r=s.criador_nome)==null?void 0:r.split(" ")[0]}),e.jsx("p",{className:"text-xs text-rose-500 font-bold tracking-wide uppercase mt-0.5",children:"Te Desafiou"})]})]}),e.jsx("button",{onClick:()=>m(N("ArenaBatalha")+"?id=".concat(s.id)),className:"w-12 h-12 rounded-xl bg-slate-900 text-white flex items-center justify-center hover:bg-slate-800 transition-colors shadow-md",children:e.jsx(z,{className:"w-6 h-6 fill-current ml-1"})})]},s.id)})})]}),g.length>0&&e.jsxs("div",{className:"mb-10 opacity-70",children:[e.jsxs("h2",{className:"text-sm font-bold text-slate-400 mb-3 uppercase tracking-wider flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4"})," Desafios Enviados"]}),e.jsx("div",{className:"space-y-3",children:g.map(s=>{var a;return e.jsxs("div",{className:"bg-slate-100 rounded-xl p-4 flex items-center justify-between border border-slate-200",children:[e.jsxs("span",{className:"text-slate-600 font-semibold text-sm",children:["Aguardando ",(a=s.oponente_nome)==null?void 0:a.split(" ")[0]," jogar..."]}),e.jsx("span",{className:"text-xs font-bold text-indigo-500 bg-indigo-100 px-3 py-1 rounded-full",children:"Pendente"})]},s.id)})})]}),b.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-extrabold text-slate-800 mb-4 flex items-center gap-2",children:"Histórico de Batalhas"}),e.jsx("div",{className:"space-y-3",children:b.map(s=>{var j;const a=s.criador_id===t.id,r=s.vencedor_id===t.id,I=(j=a?s.oponente_nome:s.criador_nome)==null?void 0:j.split(" ")[0],q=a?s.criador_acertos:s.oponente_acertos,S=a?s.oponente_acertos:s.criador_acertos;return e.jsx("div",{className:"bg-white rounded-2xl p-4 shadow-sm border ".concat(r?"border-emerald-200":"border-slate-200/60"," flex items-center justify-between"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shrink-0 ".concat(r?"bg-emerald-100 text-emerald-600":"bg-slate-100 text-slate-400"),children:r?e.jsx(R,{className:"w-6 h-6"}):e.jsx(v,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-slate-800 text-lg",children:r?"Vitória!":"Derrota"}),e.jsxs("span",{className:"text-slate-400 font-medium text-sm",children:["vs ",I]})]}
6),e.jsxs("p",{className:"text-sm text-slate-500 font-medium mt-0.5",children:["Placar: ",e.jsx("span",{className:"font-bold text-slate-700",children:q})," a ",e.jsx("span",{className:"font-bold text-slate-700",children:S})]})]})]})},s.id)})})]}),D&&!i.length&&e.jsxs("div",{className:"py-20 flex flex-col items-center justify-center text-slate-400",children:[e.jsx(c,{className:"w-8 h-8 animate-spin mb-4 text-indigo-500"}),e.jsx("p",{className:"font-medium",children:"Carregando a arena..."})]}),x&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-50 flex flex-col",children:e.jsxs("div",{className:"mt-auto bg-white w-full rounded-t-[2.5rem] p-6 pb-safe h-[85vh] flex flex-col shadow-sm animate-in slide-in-from-bottom-full duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black text-slate-800",children:"Escolha seu Oponente"}),e.jsx("p",{className:"text-sm text-slate-500 font-medium",children:"Você responderá 5 perguntas primeiro."})]}),e.jsx("button",{onClick:()=>h(!1),className:"w-10 h-10 rounded-full bg-slate-100 flex items-center justify-center hover:bg-slate-200 transition-colors text-slate-500",children:e.jsx(v,{className:"w-5 h-5"})})]}),e.jsx("input",{value:u,onChange:s=>_(s.target.value),placeholder:"Buscar colega...",className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-5 py-4 font-medium placeholder-slate-400 outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 mb-4 transition-all"}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-3 pr-2 scrollbar-thin",children:C?e.jsx("div",{className:"py-8 text-center text-slate-400",children:e.jsx(c,{className:"w-6 h-6 animate-spin mx-auto"})}):f.length>0?f.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl border border-slate-100 hover:border-slate-300 transition-colors bg-white group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-indigo-100 to-blue-100 flex items-center justify-center font-bold text-indigo-700",children:["N",s.nivel||1]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-800 text-sm",children:s.colaborador_nome}),e.jsxs("p",{className:"text-xs text-slate-400 font-medium",children:[s.xp_total||0," XP Total"]})]})]}),e.jsx("button",{onClick:()=>{n||P(s)},disabled:n,className:"px-4 py-2 bg-slate-900 text-white text-sm font-bold rounded-lg hover:bg-indigo-600 transition-colors shadow-sm disabled:opacity-50",children:n?e.jsx(c,{className:"w-4 h-4 animate-spin"}):"Combater"})]},s.id)):e.jsx("div",{className:"py-12 text-center text-slate-500 font-medium",children:"Nenhum colega encontrado."})})]})})]})]})}export{te 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.