1import{l as pe,r as o,a1 as he,j as e,X as ge,G as k,m as Ee,c as Ae,Q as ke,u as De,B as Ie,C as ce}from"./index-C-TaAGmN.js";import{b as Pe}from"./dateFormat-Bk-Flexx.js";import{A as Re}from"./AppShell-Q1pZnWHm.js";import{R as fe,P as be,O as ye,C as je,T as Ne,a as we,D as ve,u as _e}from"./useMediaQuery-BotE5nYp.js";import{u as Fe}from"./usePageTitle-CEBpYjDi.js";import{A as Ve}from"./arrow-left-BETh3RQS.js";import{P as oe}from"./plus-CrdQB4xe.js";import{F as se}from"./funnel-SjXUUxz6.js";import{C as ne}from"./calendar-hALzZk5-.js";import{C as te}from"./check-CmZB1Ziq.js";import{M as me}from"./map-pin-D-g9GdsR.js";import{P as xe}from"./pen-CODXXAl5.js";import{T as ue}from"./trash-2-DVOGqM4U.js";import"./crown-BPCHVQg4.js";import"./credit-card-Dt4NydP0.js";import"./shield-check-Cz_0e103.js";import"./trophy-PecPrR9l.js";import"./award-D22YU6tU.js";import"./chart-no-axes-column-DNi2on0A.js";import"./target-BWCUukSP.js";import"./users-B_d8OqAX.js";import"./info-BK4a7HNe.js";import"./chevron-left-BcdrX4IQ.js";const Le=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],He=pe("download",Le);const Me=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ie=pe("upload",Me);function Ue({open:s,onClose:D,onSuccess:u,poolId:q}){const[c,I]=o.useState([]),[P,h]=o.useState(""),[d,U]=o.useState(""),[g,R]=o.useState(""),[G,$]=o.useState(""),[N,f]=o.useState(""),[w,F]=o.useState(!1),[W,V]=o.useState(!0),[z,v]=o.useState("");o.useEffect(()=>{s&&Y()},[s]);const Y=async()=>{try{V(!0);const r=await he.list();I(r)}catch(r){console.error("Erro ao carregar times:",r),v("Erro ao carregar lista de times")}finally{V(!1)}},L=async r=>{if(r.preventDefault(),v(""),!P||!d||!g){v("Preencha todos os campos obrigatórios");return}if(P===d){v("Os times devem ser diferentes");return}F(!0);try{let l=g;!g.includes("Z")&&!g.includes("+")&&!g.includes(":00",g.lastIndexOf(":"))&&(l=g+":00");const n=new Date(l).toISOString();await k.create({poolId:q,homeTeamId:Number(P),awayTeamId:Number(d),startsAt:n,phase:G||void 0,roundNumber:N?Number(N):void 0}),await Promise.resolve(u()),h(""),U(""),R(""),$(""),f(""),D()}catch(l){v(l.response?.data?.message||"Erro ao criar partida")}finally{F(!1)}};return e.jsx(fe,{open:s,onOpenChange:D,children:e.jsxs(be,{children:[e.jsx(ye,{className:"fixed inset-0 bg-black bg-opacity-50 z-40"}),e.jsxs(je,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white rounded-lg shadow-xl p-6 w-full max-w-md z-50 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx(Ne,{className:"text-2xl font-bold text-gray-800 pr-2 pt-1",children:"Adicionar Partida"}),e.jsx(we,{className:"text-gray-400 hover:text-gray-600 p-1 -mr-1 -mt-1 flex-shrink-0",children:e.jsx(ge,{className:"w-6 h-6"})})]}),e.jsx(ve,{className:"text-gray-600 mb-6",children:"Preencha os dados da nova partida"}),W?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600 mx-auto"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Carregando times..."})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Time da Casa *"}),e.jsxs("select",{value:P,onChange:r=>h(r.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent",children:[e.jsx("option",{value:"",children:"Selecione um time"}),c.map(r=>e.jsxs("option",{value:r.id,children:[r.ptName??r.name," (",r.code3,")"]},r.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Time Visitante *"}),e.jsxs("select",{value:d,onChange:r=>U(r.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent",children:[e.jsx("option",{value:"",children:"Selecione um time"}),c.map(r=>
1e.jsxs("option",{value:r.id,children:[r.ptName??r.name," (",r.code3,")"]},r.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Data e Hora *"}),e.jsx("input",{type:"datetime-local",value:g,onChange:r=>R(r.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fase (opcional)"}),e.jsx("input",{type:"text",value:G,onChange:r=>$(r.target.value),placeholder:"Ex: Oitavas de Final, Quartas",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Rodada (opcional)"}),e.jsx("input",{type:"number",value:N,onChange:r=>f(r.target.value),placeholder:"Ex: 1, 2, 3...",min:"1",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"})]}),z&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg",children:z}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:D,className:"flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 font-medium transition",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:w,className:"flex-1 px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 font-medium transition disabled:opacity-50 disabled:cursor-not-allowed",children:w?"Salvando...":"Adicionar"})]})]})]})]})})}function Ge({open:s,onClose:D,onSuccess:u,poolId:q}){const[c,I]=o.useState([]),[P,h]=o.useState(null),[d,U]=o.useState([]),[g,R]=o.useState(!1),[G,$]=o.useState(!0),[N,f]=o.useState(""),w=o.useRef(null);o.useEffect(()=>{s&&F()},[s]);const F=async()=>{try{$(!0);const l=await he.list();I(l)}catch(l){console.error("Erro ao carregar times:",l),f("Erro ao carregar lista de times")}finally{$(!1)}},W=()=>{const l=`homeTeam,awayTeam,startsAt,phase,roundNumber 2BRA,ARG,2025-06-01T15:00:00Z,Grupo A,1 3URU,CHI,2025-06-01T18:00:00Z,Grupo A,1 4COL,PER,2025-06-02T15:00:00Z,Grupo B,1 5FRA,GER,2025-06-02T18:00:00Z,Grupo B,1`,i=new Blob([l],{type:"text/csv;charset=utf-8;"}),n=document.createElement("a");n.href=URL.createObjectURL(i),n.download="template_partidas.csv",n.click()},V=l=>{const i=l.trim().toLowerCase();return c.find(n=>n.name.toLowerCase()===i||n.code3.toLowerCase()===i||n.country?.toLowerCase()===i)},z=l=>{const i=l.split(` 6`).filter(p=>p.trim());if(i.length<2)return f("Arquivo CSV vazio ou inválido"),[];const n=i[0].split(",").map(p=>p.trim()),m=["homeTeam","awayTeam","startsAt"].filter(p=>!n.includes(p));if(m.length>0)return f(`Cabeçalhos obrigatórios faltando: ${m.join(", ")}`),[];const T=[];for(let p=1;p<i.length;p++){const _=i[p].split(",").map(b=>b.trim()),x={};n.forEach((b,E)=>{x[b]=_[E]||""});const y=[];let Z=0,J=0;const Q=V(x.homeTeam);Q?Z=Q.id:y.push(`Time da casa "${x.homeTeam}" não encontrado`);const B=V(x.awayTeam);B?J=B.id:y.push(`Time visitante "${x.awayTeam}" não encontrado`),Z&&J&&Z===J&&y.push("Times devem ser diferentes");let K=x.startsAt;if(!x.startsAt)y.push("Data e hora são obrigatórias");else{let b=x.startsAt.trim();b&&b.length===16&&b.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/)&&(b=b+":00");const E=new Date(b);isNaN(E.getTime())?y.push("Data inválida (use formato: YYYY-MM-DDTHH:mm:ss ou YYYY-MM-DDTHH:mm)"):K=b}T.push({homeTeamId:Z,awayTeamId:J,startsAt:K,phase:x.phase||void 0,roundNumber:x.roundNumber?parseInt(x.roundNumber):void 0,rowNumber:p+1,errors:y})}return T},v=l=>{const i=l.target.files?.[0];if(!i)return;if(!i.name.endsWith(".csv")){f("Por favor, selecione um arquivo CSV válido");return}h(i),f("");const n=new FileReader;n.onload=S=>{const m=S.target?.result,T=z(m);U(T)},n.readAsText(i)},Y=async l=>{if(l.preventDefault(),f(""),!P||d.length===0){f("Por favor, selecione um arquivo CSV válido");return}if(d.some(n=>n.errors.length>0)){f("Corrija os erros antes de enviar");return}R(!0);try{const n=["homeTeam,awayTeam,startsAt,phase,roundNumber"];d.forEach(m=>{const T=c.find(y=>y.id===m.homeTeamId),p=c.find(y=>y.id===m.awayTeamId);let _=m.startsAt;!_.includes("Z")&&!_.includes("+")&&(_=new Date(_).toISOString());const x=[T?.code3||"",p?.code3||"",_,m.phase||"",m.roundNumber?.toString()||""].join(",");n.push(x)});const S=n.join(` 7`);await k.bulkCreate({poolId:q,csvData:S}),await Promise.resolve(u()),h(null),U([]),w.current&&(w.current.value=""),D()}catch(n){f(n.response?.data?.message||"Erro ao criar partidas")}finally{R(!1)}},L=d.filter(l=>l.errors.length===0),r=d.filter(l=>l.errors.length>0);return e.jsx(fe,{open:s,onOpenChange:D,children:e.jsxs(be,{children:[e.jsx(ye,{className:"fixed inset-0 bg-black bg-opacity-50 z-40"}),e.jsxs(je,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white rounded-lg shadow-xl p-6 w-full max-w-3xl z-50 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx(Ne,{className:"text-2xl font-bold text-gray-800 pr-2 pt-1",children:"Importar Partidas via CSV"}),e.jsx(we,{className:"text-gray-400 hover:text-gray-600 p-1 -mr-1 -mt-1 flex-shrink-0",children:e.jsx(ge,{className:"w-6 h-6"})})]}),e.jsx(ve,{className:"text-gray-600 mb-6",children:"Faça upload de um arquivo CSV com as partidas. Baixe o template para ver o formato correto."}),G?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600 mx-auto"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Carregando times..."})]}):e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ee,{className:"w-5 h-5 text-blue-600 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 mb-1",children:"Formato do CSV"}),e.jsxs("p",{className:"text-sm text-blue-800 mb-2",children:["O arquivo deve conter as colunas: homeTeam, awayTeam, startsAt (obrigatórios), phase, roundNumber (opcionais).",e.jsx("br",{}),e.jsx("strong",{children:"Importante:"})," Use os códigos de 3 caracteres dos times (ex: BRA, ARG, FRA) e data no formato ISO 8601 com timezone (ex: 2025-06-01T15:00:00Z)."]}),e.jsxs("button",{type:"button",onClick:W,className:"flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-1.5 rounded transition",children:[e.jsx(He,{className:"w-4 h-4"}),"Baixar Template"]})]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Arquivo CSV *"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:w,type:"file",accept:".csv",onChange:v,className:"flex-1 text-sm text-gray-600 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100"}),P&&e.jsxs("span",{className:"text-sm text-gray-600",children:[d.length," partidas encontradas"]})]})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-semibold text-gray-800 mb
7-2",children:["Prévia (",L.length," válidas, ",r.length," com erros)"]}),e.jsx("div",{className:"border border-gray-200 rounded-lg max-h-64 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500",children:"#"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500",children:"Times"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500",children:"Data"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:d.map((l,i)=>{const n=c.find(m=>m.id===l.homeTeamId),S=c.find(m=>m.id===l.awayTeamId);return e.jsxs("tr",{className:l.errors.length>0?"bg-red-50":"",children:[e.jsx("td",{className:"px-3 py-2 text-gray-600",children:l.rowNumber}),e.jsxs("td",{className:"px-3 py-2",children:[n?e.jsxs("span",{children:[e.jsx("strong",{children:n.code3})," ((homeTeam.ptName ?? homeTeam.name))"]}):"?"," ","vs"," ",S?e.jsxs("span",{children:[e.jsx("strong",{children:S.code3})," ((awayTeam.ptName ?? awayTeam.name))"]}):"?"]}),e.jsx("td",{className:"px-3 py-2 text-gray-600",children:l.startsAt?new Date(l.startsAt).toLocaleString("pt-BR"):"-"}),e.jsx("td",{className:"px-3 py-2",children:l.errors.length>0?e.jsx("div",{className:"text-xs text-red-700",children:l.errors.map((m,T)=>e.jsxs("div",{children:["⢠",m]},T))}):e.jsx("span",{className:"text-green-600 text-xs font-semibold",children:"â OK"})})]},i)})})]})})]}),N&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg",children:N}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:D,className:"flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 font-medium transition",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:g||d.length===0||r.length>0,className:"flex-1 px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 font-medium transition disabled:opacity-50 disabled:cursor-not-allowed",children:g?"Importando...":`Importar ${L.length} Partidas`})]})]})]})]})})}function ma(){const{t:s,i18n:D}=Ae("pool");Fe(s("compmatches.page_title","Partidas"));const{competitionId:u}=ke(),q=De(),c=_e(),[I,P]=o.useState(null),[h,d]=o.useState([]),[U,g]=o.useState(0),[R,G]=o.useState(!0),[$,N]=o.useState(!1),[f,w]=o.useState(!1),[F,W]=o.useState(!1),[V,z]=o.useState([]),[v,Y]=o.useState(null),[L,r]=o.useState([]),[l,i]=o.useState(null),[n,S]=o.useState(null),[m,T]=o.useState(null),[p,_]=o.useState([]);o.useEffect(()=>{x()},[u]);const x=async()=>{if(u)try{G(!0);const[a,t]=await Promise.all([Ie.getById(Number(u)),k.listByCompetition(Number(u))]);P(a),g(t.length);const j=[...new Set(t.map(A=>
7A.phaseCode).filter(Boolean))];if(j.length>0){W(!0);const A=j.map(M=>{const O=t.find(le=>le.phaseCode===M);return{code:M,name:O?.phase||M,order:O?.phaseDisplayOrder||99}}).sort((M,O)=>M.order-O.order);z(A);const C=new Date;let H=A[0].code;for(const M of A){const O=t.filter(ee=>ee.phaseCode===M.code),le=O.some(ee=>ee.status==="LIVE"),Ce=O.some(ee=>new Date(ee.startsAt)>=C);if(le||Ce){H=M.code;break}}const X=await k.getPhaseSummary(Number(u),H);Y(H),r(X.rounds),i(X.currentRound),d(X.matches)}else{W(!1);const A=Array.from(new Set(t.map(C=>C.roundNumber).filter(C=>C!=null))).sort((C,H)=>C-H);if(_(A),A.length>0){const C=await k.getCurrentRound(Number(u)),H=A.includes(C)?C:A[0];T(H);const X=await k.listByCompetition(Number(u),void 0,H);d(X)}else d(t)}G(!1)}catch(a){console.error("Erro ao carregar dados:",a),alert(s("compmatches.alert.load_error","Erro ao carregar competição")),q("/competicoes")}},y=async a=>{Y(a),S(null);try{const t=await k.getPhaseSummary(Number(u),a);r(t.rounds),i(t.currentRound),d(t.matches)}catch(t){console.error("Erro ao carregar resumo da fase:",t),r([]),i(null),d([])}},Z=async a=>{if(v){i(a);try{const t=await k.getPhaseSummary(Number(u),v,a);d(t.matches)}catch(t){console.error("Erro ao carregar partidas da rodada na fase:",t)}}},J=async a=>{T(a);try{const t=await k.listByCompetition(Number(u),void 0,a);d(t)}catch(t){console.error("Erro ao carregar partidas da rodada:",t)}},Q=async a=>{if(confirm(s("compmatches.confirm_delete","Tem certeza que deseja deletar esta partida?")))try{await k.delete(a),d(h.filter(t=>t.id!==a)),g(t=>t-1)}catch(t){alert(t.response?.data?.message||s("compmatches.alert.delete_error","Erro ao deletar partida"))}},B=(a,t)=>a.status!=="FINISHED"?!1:a.penaltyHomeScore!==null&&a.penaltyHomeScore!==void 0&&a.penaltyAwayScore!==null&&a.penaltyAwayScore!==void 0?t==="home"?a.penaltyHomeScore>a.penaltyAwayScore:a.penaltyAwayScore>a.penaltyHomeScore:a.homeScore==null||a.awayScore==null?!1:t==="home"?a.homeScore>a.awayScore:a.awayScore>a.homeScore,K=a=>Pe(a,D.language),b=a=>{const t={SCHEDULED:"bg-blue-500 text-white",LIVE:"bg-green-500 text-white",FINISHED:"bg-gray-600 text-white",CANCELLED:"bg-red-500 text-white"},j={SCHEDULED:s("matches.status.scheduled","Agendada"),LIVE:s("matches.status.live","Ao Vivo"),FINISHED:s("matches.status.finished","Finalizada"),CANCELLED:s("matches.status.cancelled","Cancelada")};return e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-bold ${t[a]}`,children:j[a]})},E=[...new Set(h.filter(a=>a.subCompetitionName).map(a=>a.subCompetitionName))].sort(),ae=E.length>0,de=h.filter(a=>!a.subCompetitionName),re=de.length>0,Se=ae?n===null?de:h.filter(a=>a.subCompetitionName===n):h,Te=I?I.name.replace(/^Campeonato\s+/i,""):s("matches.main_label","Principal");return o.useEffect(()=>{ae&&!re&&n===null&&E.length>0&&S(E[0])},[ae,re,n,E.join(",")]),e.jsxs(Re,{children:[e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"mb-6 md:mb-8",children:[e.jsxs("button",{onClick:()=>q("/competicoes"),className:"flex items-center gap-2 text-primary-600 hover:text-primary-700 mb-3 md:mb-4 text-sm md:text-base",children:[e.jsx(Ve,{className:"w-4 h-4 md:w-5 md:h-5"}),s("compmatches.back","Voltar para Competições")]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl md:text-3xl font-bold text-primary-800 mb-1 md:mb-2 line-clamp-2",children:s("compmatches.title",{name:I?.name??"",defaultValue:"Partidas - {{name}}"})}),e.jsxs("p",{className:"text-sm md:text-base text-gray-600",children:[I?.year&&`${I.year} ⢠`,s("matches.count",{count:U,defaultValue_one:"{{count}} partida",defaultValue_other:"{{count}} partidas"})]})]}),!c&&e.jsxs("div",{className:"flex gap-3 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>w(!0),className:"flex items-center gap-2 bg-white hover:bg-gray-50 text-primary-600 border-2 border-primary-600 px-4 py-2 rounded-lg font-semibold transition",children:[e.jsx(ie,{className:"w-5 h-5"}),s("compmatches.import_csv","Importar CSV")]}),e.jsxs("button",{onClick:()=>N(!0),className:"flex items-center gap-2 bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg font-semibold transition shadow-lg",children:[e.jsx(oe,{className:"w-5 h-5"}),s("compmatches.new_match","Nova Partida")]})]})]}),c&&e.jsxs("div",{className:"flex flex-col gap-2 mt-4",children:[e.jsxs("button",{onClick:()=>w(!0),className:"w-full flex items-center justify-center gap-2 bg-white hover:bg-gray-50 text-primary-600 border-2 border-primary-600 px-4 py-3 rounded-lg font-semibold transition",children:[e.jsx(ie,{className:"w-5 h-5"}),s("compmatches.import_csv","Importar CSV")]}),e.jsxs("button",{onClick:()=>N(!0),className:"w-full flex items-center justify-center gap-2 bg-primary-600 hover:bg-primary-700 text-white px-4 py-3 rounded-lg font-semibold transition shadow-lg",children:[e.jsx(oe,{className:"w-5 h-5"}),s("compmatches.new_match","Nova Partida")]})]})]}),F&&V.length>0&&e.jsx("div",{className:"mb-4 bg-white rounded-xl shadow-sm border border-gray-100 p-4",children:e.jsxs("div",{className:`flex ${c?"flex-col":"items-center"} gap-3`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{className:"w-4 h-4 text-primary-500 flex-shrink-0"}),e.jsx("label",{className:"font-semibold text-gray-600 text-sm whitespace-nowrap",children:s("compmatches.filter_phase","Fase:")})]}),e.jsx("select",{value:v??"",onChange:a=>y(a.target.value),className:`${c?"w-full":"flex-1 max-w-xs"} px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-gray-50`,disabled:R,children:V.map(a=>e.jsx("option",{value:a.code,children:a.name},a.code))})]})}),ae&&e.jsx("div",{className:"mb-4 bg-white rounded-xl shadow-sm border border-gray-100 p-4",children:e.jsxs("div",{className:`flex ${c?"flex-col":"items-center"} gap-3`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{className:"w-4 h-4 text-primary-500 flex-shrink-0"}),e.jsx("label",{className:"font-semibold text-gray-600 text-sm whitespace-nowrap",children:E.every(a=>a.startsWith("Grupo "))?s("compmatches.filter_group","Grupo:"):s("compmatches.filter_division","Divisão:")})]}),e.jsxs("select",{value:n??"",onChange:a=>S(a.target.value||null),className:`${c?"w-full":"flex-1 max-w-xs"} px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-gray-50`,children:[re&&e.jsx("option",{value:"",children:Te}),E.map(a=>e.jsx("option",{value:a,children:a},a))]})]})}),F&&L.length>0&&e.jsx("div",{className:"mb-6 bg-white rounded-xl shadow-sm border border-gray-100 p-4",children:e.jsxs("div",{className:`flex ${c?"flex-col":"items-center"} gap-3`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{className:"w-4 h-4 text-primary-500 flex-shrink-0"}),e.jsx("label",{className:"font-semibold text-gray-600 text-sm whitespace-nowrap",children:s("compmatches.filter_round","Rodada:")})]}),e.jsx("select",{value:l!==null?l:"",onChange:a=>Z(Number(a.target.value)),className:`${c?"w-full":"flex-1 max-w-xs"} px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-gray-50`,disabled:R||L.length===0,children:L.map(a=>e.jsx("option",{value:a,children:s("matches.round",{round:a,defaultValue:"Rodada {{round}}"})},a))}),!c&&e.jsx("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:s("compmatches.matches_in_round",{count:h.length,defaultValue_one:"{{count}} partida nesta rodada",defaultValue_other:"{{count}} partidas nesta rodada"})})]})}),!F&&p.length>0&&e.jsx("div",{className:"mb-6 bg-white rounded-xl shadow-sm border border-gray-100 p-4",children:e.jsxs("div",{className:`flex ${c?"flex-col":"items-center"} gap-3`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{className:"w-4 h-4 text-primary-500 flex-shrink-0"}),e.jsx("label",{className:"font-semibold text-gray-600 text-sm whitespace-nowrap",children:s("compmatches.filter_round","Rodada:")})]}),e.jsxs("select",{value:m!==null?m:"",onChange:a=>J(Number(a.target.value)),className:`${c?"w-full":"flex-1 max-w-xs"} px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-gray-50`,disabled:R,children:[m===null&&e.jsx("option",{value:"",children:s("compmatches.loading","Carregando...")}),p.map(a=>e.jsx("option",{value:a,children:s("matches.round",{round:a,defaultValue:"Rodada {{round}}"})},a))]}),m!==null&&!c&&e.jsx("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:s("compmatches.matches_in_round",{count:h.length,defaultValue_one:"{{count}} partida nesta rodada",defaultValue_other:"{{count}} partidas nesta rodada"})})]})}),h.length===0?e.jsxs("div",{className:"bg-white rounded-lg shadow-md p-8 md:p-12 text-center",children:[e.jsx(ne,{className:"w-12 h-12 md:w-16 md:h-16 text-gray-400 mx-auto mb-3 md:mb-4"}),e.jsx("h3",{className:"text-lg md:text-xl font-semibold text-gray-700 mb-2",children:s("compmatches.empty_title","Nenhuma partida cadastrada")}),e.jsx("p",{className:"text-sm md:text-base text-gray-600 mb-4 md:mb-6",children:s("compmatches.empty_text","Comece adicionando partidas individualmente ou importe via CSV")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("button",{onClick:()=>w(!0),className:"flex items-center justify-center gap-2 bg-white hover:bg-gray-50 text-primary-600 border-2 border-primary-600 px-4 py-2 rounded-lg font-semibold transition",children:[e.jsx(ie,{className:"w-5 h-5"}),s("compmatches.import_csv","Importar CSV")]}),e.jsxs("button",{onClick:()=>N(!0),className:"flex items-center justify-center gap-2 bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg font-semibold transition",children:[e.jsx(oe,{className:"w-5 h-5"}),s("compmatches.add_match","Adicionar Partida")]})]})]}):e.jsx("div",{className:"space-y-3 md:space-y-4",children:Se.map(a=>e.jsx("div",{className:"bg-white rounded-xl shadow-md hover:shadow-xl transition-all border border-gray-100 overflow-hidden",children:c?e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[b(a.status),a.roundNumber&&e.jsx("span",{className:"text-xs font-semibold text-gray-600",children:s("matches.round",{round:a.roun
7dNumber,defaultValue:"Rodada {{round}}"})}),a.legNumber&&e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${a.legNumber===1?"bg-blue-100 text-blue-600":"bg-amber-100 text-amber-700"}`,children:a.legNumber===1?s("matches.leg_first","Jogo de Ida"):s("matches.leg_second","Jogo de Volta")})]})}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2 flex-1",children:[a.homeTeamForm&&a.homeTeamForm.length>0&&e.jsx("div",{className:"flex gap-1 justify-center",children:a.homeTeamForm.map((t,j)=>e.jsx("div",{title:t==="W"?s("matches.form.win","Vitória"):t==="D"?s("matches.form.draw","Empate"):s("matches.form.loss","Derrota"),className:`w-2.5 h-2.5 rounded-full ${t==="W"?"bg-green-500":t==="D"?"bg-yellow-400":"bg-red-500"}`},j))}),(a.homeTeam.logoUrl||a.homeTeam.flagUrl)&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:a.homeTeam.logoUrl||a.homeTeam.flagUrl,alt:a.homeTeam.ptName??a.homeTeam.name,className:"w-12 h-12 object-contain",onError:t=>{t.currentTarget.style.display="none"}}),B(a,"home")&&e.jsx("div",{className:"absolute -top-2 -right-2 w-6 h-6 bg-purple-600 rounded-full flex items-center justify-center shadow-md",children:e.jsx(te,{className:"w-3.5 h-3.5 text-white",strokeWidth:3})})]}),e.jsx("span",{className:"font-bold text-sm text-gray-900 text-center line-clamp-2",children:a.homeTeam.ptName??a.homeTeam.name})]}),e.jsx("div",{className:"flex flex-col items-center justify-center px-4 flex-shrink-0",children:a.status==="FINISHED"?e.jsx("div",{className:"flex flex-col items-center gap-1",children:a.penaltyHomeScore!=null&&a.penaltyAwayScore!=null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"text-2xl font-black text-gray-900",children:["(",a.penaltyHomeScore,")"]}),e.jsx("span",{className:"text-xl font-bold text-gray-700",children:a.homeScore}),e.jsx("span",{className:"text-lg font-bold text-gray-400",children:"Ã"}),e.jsx("span",{className:"text-xl font-bold text-gray-700",children:a.awayScore}),e.jsxs("span",{className:"text-2xl font-black text-gray-900",children:["(",a.penaltyAwayScore,")"]})]}),e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:s("matches.penalties","Pênaltis")})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-black text-gray-900",children:a.homeScore}),e.jsx("span",{className:"text-xl font-bold text-gray-400",children:"Ã"}),e.jsx("span",{className:"text-3xl font-black text-gray-900",children:a.awayScore})]})}):e.jsx("div",{className:"text-xl font-bold text-gray-400",children:s("matches.vs","VS")})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 flex-1",children:[a.awayTeamForm&&a.awayTeamForm.length>0&&e.jsx("div",{className:"flex gap-1 justify-center",children:a.awayTeamForm.map((t,j)=>e.jsx("div",{title:t==="W"?s("matches.form.win","Vitória"):t==="D"?s("matches.form.draw","Empate"):s("matches.form.loss","Derrota"),className:`w-2.5 h-2.5 rounded-full ${t==="W"?"bg-green-500":t==="D"?"bg-yellow-400":"bg-red-500"}`},j))}),(a.awayTeam.logoUrl||a.awayTeam.flagUrl)&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:a.awayTeam.logoUrl||a.awayTeam.flagUrl,alt:a.awayTeam.ptName??a.awayTeam.name,className:"w-12 h-12 object-contain",onError:t=>{t.currentTarget.style.display="none"}}),B(a,"away")&&e.jsx("div",{className:"absolute -top-2 -right-2 w-6 h-6 bg-purple-600 rounded-full flex items-center justify-center shadow-md",children:e.jsx(te,{className:"w-3.5 h-3.5 text-white",strokeWidth:3})})]}),e.jsx("span",{className:"font-bold text-sm text-gray-900 text-center line-clamp-2",children:a.awayTeam.ptName??a.awayTeam.name})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 space-y-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{children:K(a.startsAt)})]}),a.stadium&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[e.jsx(me,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a.stadium})]}),a.legNumber===2&&a.aggregateHomeGoals!=null&&a.aggregateAwayGoals!=null&&!["REGULAR_SEASON","GROUP_STAGE","LEAGUE_STAGE"].includes(a.phaseCode??"")&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-semibold text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded-full",children:s("matches.aggregate",{home:a.aggregateHomeGoals,away:a.aggregateAwayGoals,defaultValue:"Agregado: {{home}} à {{away}}"})})})]}),a.status!=="FINISHED"&&e.jsxs("div",{className:"flex gap-2",children:[(a.status==="SCHEDULED"||a.status==="LIVE"||a.status==="CANCELLED")&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{},className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 text-primary-600 border border-primary-600 hover:bg-primary-50 rounded-lg transition text-sm font-medium",children:[e.jsx(xe,{className:"w-4 h-4"}),s("compmatches.edit","Editar")]}),e.jsxs("button",{onClick:()=>Q(a.id),className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 text-red-600 border border-red-600 hover:bg-red-50 rounded-lg transition text-sm font-medium",children:[e.jsx(ue,{className:"w-4 h-4"}
7),s("compmatches.delete","Deletar")]})]}),a.status==="SCHEDULED"&&e.jsxs("button",{onClick:()=>{},className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 text-green-600 border border-green-600 hover:bg-green-50 rounded-lg transition text-sm font-medium",children:[e.jsx(ce,{className:"w-4 h-4"}),s("compmatches.finalize","Finalizar")]})]})]}):e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"flex items-center gap-8 flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2 flex-1",children:[a.homeTeamForm&&a.homeTeamForm.length>0&&e.jsx("div",{className:"flex gap-1 justify-center",children:a.homeTeamForm.map((t,j)=>e.jsx("div",{title:t==="W"?s("matches.form.win","Vitória"):t==="D"?s("matches.form.draw","Empate"):s("matches.form.loss","Derrota"),className:`w-2.5 h-2.5 rounded-full ${t==="W"?"bg-green-500":t==="D"?"bg-yellow-400":"bg-red-500"}`},j))}),(a.homeTeam.logoUrl||a.homeTeam.flagUrl)&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:a.homeTeam.logoUrl||a.homeTeam.flagUrl,alt:a.homeTeam.ptName??a.homeTeam.name,className:"w-16 h-16 object-contain flex-shrink-0",onError:t=>{t.currentTarget.style.display="none"}}),B(a,"home")&&e.jsx("div",{className:"absolute -top-2 -right-2 w-6 h-6 bg-purple-600 rounded-full flex items-center justify-center shadow-md",children:e.jsx(te,{className:"w-3.5 h-3.5 text-white",strokeWidth:3})})]}),e.jsx("span",{className:"font-bold text-lg text-gray-900 text-center",children:a.homeTeam.ptName??a.homeTeam.name})]}),e.jsx("div",{className:"flex flex-col items-center justify-center min-w-[120px] px-6",children:a.status==="FINISHED"?e.jsx("div",{className:"flex flex-col items-center gap-1",children:a.penaltyHomeScore!=null&&a.penaltyAwayScore!=null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-4xl font-black text-gray-900",children:["(",a.penaltyHomeScore,")"]}),e.jsx("span",{className:"text-3xl font-bold text-gray-700",children:a.homeScore}),e.jsx("span",{className:"text-2xl font-bold text-gray-400",children:"Ã"}),e.jsx("span",{className:"text-3xl font-bold text-gray-700",children:a.awayScore}),e.jsxs("span",{className:"text-4xl font-black text-gray-900",children:["(",a.penaltyAwayScore,")"]})]}),e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:s("matches.penalties","Pênaltis")})]}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-5xl font-black text-gray-900",children:a.homeScore}),e.jsx("span",{className:"text-3xl font-bold text-gray-400",children:"Ã"}),e.jsx("span",{className:"text-5xl font-black text-gray-900",children:a.awayScore})]})}):e.jsx("div",{className:"text-2xl font-bold text-gray-400",children:s("matches.vs","VS")})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 flex-1",children:[a.awayTeamForm&&a.awayTeamForm.length>0&&e.jsx("div",{className:"flex gap-1 justify-center",children:a.awayTeamForm.map((t,j)=>e.jsx("div",{title:t==="W"?s("matches.form.win","Vitória"):t==="D"?s("matches.form.draw","Empate"):s("matches.form.loss","Derrota"),className:`w-2.5 h-2.5 rounded-full ${t==="W"?"bg-green-500":t==="D"?"bg-yellow-400":"bg-red-500"}`},j))}),(a.awayTeam.logoUrl||a.awayTeam.flagUrl)&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:a.awayTeam.logoUrl||a.awayTeam.flagUrl,alt:a.awayTeam.ptName??a.awayTeam.name,className:"w-16 h-16 object-contain flex-shrink-0",onError:t=>{t.currentTarget.style.display="none"}}),B(a,"away")&&e.jsx("div",{className:"absolute -top-2 -right-2 w-6 h-6 bg-purple-600 rounded-full flex items-center justify-center shadow-md",children:e.jsx(te,{className:"w-3.5 h-3.5 text-white",strokeWidth:3})})]}),e.jsx("span",{className:"font-bold text-lg text-gray-900 text-center",children:a.awayTeam.ptName??a.awayTeam.name})]})]}),e.jsx("div",{className:"h-24 w-px bg-gray-200"}),e.jsxs("div",{className:"flex flex-col items-start gap-2.5 min-w-[220px] max-w-[220px]",children:[e.jsx("div",{children:b(
7a.status)}),a.roundNumber&&e.jsx("div",{className:"text-sm font-semibold text-gray-700",children:s("matches.round",{round:a.roundNumber,defaultValue:"Rodada {{round}}"})}),a.legNumber&&e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${a.legNumber===1?"bg-blue-100 text-blue-600":"bg-amber-100 text-amber-700"}`,children:a.legNumber===1?s("matches.leg_first","Jogo de Ida"):s("matches.leg_second","Jogo de Volta")}),a.legNumber===2&&a.aggregateHomeGoals!=null&&a.aggregateAwayGoals!=null&&!["REGULAR_SEASON","GROUP_STAGE","LEAGUE_STAGE"].includes(a.phaseCode??"")&&e.jsx("span",{className:"text-xs font-semibold text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded-full",children:s("matches.aggregate",{home:a.aggregateHomeGoals,away:a.aggregateAwayGoals,defaultValue:"Agregado: {{home}} Ã {{away}}"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(ne,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"whitespace-nowrap",children:K(a.startsAt)})]}),a.stadium&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 w-full",title:a.stadium,children:[e.jsx(me,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a.stadium})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[a.status!=="FINISHED"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{},className:"p-2 text-primary-600 hover:bg-primary-50 rounded-lg transition",title:s("compmatches.edit","Editar"),children:e.jsx(xe,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Q(a.id),className:"p-2 text-red-600 hover:bg-red-50 rounded-lg transition",title:s("compmatches.delete","Deletar"),children:e.jsx(ue,{className:"w-5 h-5"})})]}),a.status==="SCHEDULED"&&e.jsx("button",{onClick:()=>{},className:"p-2 text-green-600 hover:bg-green-50 rounded-lg transition",title:s("compmatches.finalize","Finalizar"),children:e.jsx(ce,{className:"w-5 h-5"})})]})]})]})})},a.id))})]}),e.jsx(Ue,{open:$,onClose:()=>N(!1),onSuccess:x,competitionId:Number(u)}),e.jsx(Ge,{open:f,onClose:()=>w(!1),onSuccess:x,competitionId:Number(u)})]})}export{ma as default}; 8//# sourceMappingURL=CompetitionMatches-Cr4h8Ae2.js.map
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.