PageSourceSearch

https://foxleague.ai/assets/TournamentDetail-DMmfsBtB.js

js foxleague.ai collected 2026-10-05 13:49:12 UTC 30,848 bytes, 1 lines download raw bytes

1import{j as e,m as R,a as m}from"./motion-vendor-CK-a2t6Y.js";import{M as _e,i as $e,u as Me,a as Oe,T as Be,b as Ae,B as Je,s as xe,c as We,C as Ge,L as Ue,d as qe}from"./tournamentRemoved-ChUkzU1z.js";import{d4 as He,d5 as Ke,q as Ye,u as Xe,cR as Qe,a1 as fe,a2 as ye,d6 as Ve,O as Ze,M as et,K as tt,$ as at,e as ee,i as st,am as rt,bn as ot,n as P,r as nt,d7 as lt,d8 as it,d9 as ct,da as he,m as B,d as A,db as K,dc as dt,dd as mt,de as pt,df as ut,dg as xt,dh as ft,l as ve,di as yt,dj as ht}from"./index-DEqeXHOo.js";import{n as vt}from"./Star.es-B4ieSClN.js";import{n as gt}from"./Trash.es-gcCdrfXX.js";import{v as bt,s as jt}from"./lineupGate-bBT35kHo.js";import{d as _t,a as kt,t as Nt}from"./tournament-CfLAereN.js";import{W as ge,P as wt}from"./liveConfigWait-Bc3S_NMZ.js";import{r as be,s as Tt}from"./scoreLabel-CVibAHfG.js";import{u as St}from"./useCoalescedCallback-DQvAbx5g.js";import{F as Y}from"./FoxsyPrice-CmJqgdm2.js";import{T as Ft}from"./TierBadge-BwLseq_h.js";import{f as je}from"./format-BRyCMDlG.js";import{g as Pt,b as Et}from"./react-vendor-Do6Gfp74.js";import{J as Lt}from"./tournamentTxData-BUMUG5Fx.js";import"./core-vendor-4YwYXNuQ.js";import"./ArrowLeft.es-Bz3Klj6r.js";import"./three-vendor-sBiimosO.js";import"./ChartBar.es-DIjI-ANi.js";import"./Eye.es-T5NImZQ6.js";import"./MatchupTeam-BIkm2K8r.js";import"./OnChainProofs-ZgkBcCxQ.js";import"./MatchStatsModal-0sU6zPg_.js";import"./PitchPreview-ugSk96Mw.js";import"./formations-D9sDL5dR.js";import"./countries-BlIJUb-t.js";import"./PlayerAvatar-vovnxysW.js";import"./matchStatsGate-B9XwJjYp.js";import"./eloDelta-YP22ETZA.js";import"./opponentBadge-D-w7B-ia.js";import"./WatchLiveButton-ePdirOpG.js";import"./TeamPlayersModal-ByKVC6HI.js";import"./ArrowCounterClockwise.es-B0-gk0aS.js";import"./fusionWaivers-DK3UjwSC.js";import"./mvx-vendor-BGMFtqkf.js";import"./screenshot-vendor-k0ITeQhV.js";import"./txOutcome-BbFLLiJV.js";import"./gasLimits-CbiRoG6j.js";function Ct({matches:r}){const j=new Map;for(const n of r){const p=n.group_name==="3rd Place",h=`${n.round_number}-${p?"3p":"main"}`,c=j.get(h);c?c.matches.push(n):j.set(h,{roundNum:n.round_number,isThirdPlace:p,label:p?"3rd Place":n.round_label||`Round ${n.round_number}`,matches:[n]})}const t=Array.from(j.values()).sort((n,p)=>n.roundNum!==p.roundNum?n.roundNum-p.roundNum:(n.isThirdPlace?0:1)-(p.isThirdPlace?0:1)).map(n=>({...n,matches:n.matches.sort((p,h)=>(p.bracket_position??0)-(h.bracket_position??0))}));return t.length===0?e.jsx("div",{className:"card-stadium card-no-hover p-8 text-center",children:e.jsx("p",{style:{color:"var(--color-kit-faded)"},children:"Bracket will appear once the tournament starts."})}):e.jsx("div",{className:"overflow-x-auto pb-4",style:{scrollSnapType:"x mandatory",WebkitOverflowScrolling:"touch"},children:e.jsx("div",{className:"flex gap-4 md:gap-6 min-w-max",children:t.map((n,p)=>e.jsxs("div",{className:"flex flex-col",style:{scrollSnapAlign:"start"},children:[e.jsx("div",{className:"text-center mb-4",children:e.jsx("span",{className:"text-[12px] font-bold uppercase tracking-wider",style:{fontFamily:"var(--font-broadcast)",color:"var(--color-kit-faded)"},children:n.label})}),e.jsx("div",{className:"flex flex-col gap-4 justify-around flex-1",style:{minWidth:200},children:n.matches.map((h,c)=>e.jsx(Dt,{match:h,roundIndex:p,matchIndex:c},h.id))})]},`${n.roundNum}-${n.isThirdPlace?"3p":"main"}`))})})}function Dt({match:r,roundIndex:j,matchIndex:t}){const n=r.is_bye===!0,p=!n&&r.home_score!==void 0&&r.away_score!==void 0&&r.home_score!==null&&r.away_score!==null,h=p&&be(r.home_score??0,r.away_score??0,r.home_penalty,r.away_penalty,r.decided_by,!0)==="win",c=p&&be(r.home_score??0,r.away_score??0,r.home_penalty,r.away_penalty,r.decided_by,!1)==="win",_=p&&Tt(r.decided_by,r.home_penalty,r.away_penalty),v=h||n,f=!n&&(r.status==="live"||r.status==="simulating");return e.jsxs(R.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:j*.1+t*.05},className:"rounded-lg overflow-hidden",style:{border:`1px solid ${f?"rgba(0,229,255,0.3)":"var(--color-line)"}`,background:"var(--color-tunnel)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid var(--color-line)",background:v?"rgba(0,200,83,0.06)":void 0},children:[e.jsx("span",{className:"text-[13px] font-medium truncate flex-1",style:{color:r.home_team_name?v?"var(--color-success-text)":"var(--color-kit-primary)":"var(--color-kit-faded)",fontWeight:v?700:500},children:r.home_team_name||"TBD"}),p&&e.jsxs("span",{className:"flex items-center gap-1 ml-2",children:[e.jsx("span",{className:"text-[14px] font-bold",style:{fontFamily:"var(--font-broadcast)",color:h?"var(--color-success-text)":"var(--color-kit-faded)"},children:r.home_score}),_&&e.jsxs("span",{className:"text-[11px] font-semibold",style:{color:h?"var(--color-fox-text)":"var(--color-kit-faded)"},children:["(",r.home_penalty,")"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{background:c?"rgba(0,200,83,0.06)":void 0},children:[e.jsx("span",{className:"text-[13px] font-medium truncate flex-1",style:{color:r.away_team_name?c?"var(--color-success-text)":"var(--color-kit-primary)":"var(--color-kit-faded)",fontWeight:c?700:500,...n?{fontFamily:"var(--font-broadcast)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em"}:{}},children:n?"BYE":r.away_team_name||"TBD"}),p&&e.jsxs("span",{className:"flex items-center gap-1 ml-2",children:[e.jsx("span",{className:"text-[14px] font-bold",style:{fontFamily:"var(--font-broadcast)",color:c?"var(--color-success-text)":"var(--color-kit-faded)"},children:r.away_score}),_&&e.jsxs("span",{className:"text-[11px] font-semibold",style:{color:c?"var(--color-fox-text)":"var(--color-kit-faded)"},children:["(",r.away_penalty,")"]})]})]}),f&&e.jsx("div",{className:"px-3 py-1 text-center",style:{background:"rgba(0,229,255,0.05)"},children:e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider animate-pulse",style:{color:"var(--color-cyan)"},children:"Live"})})]})}function te({standings:r,participants:j,qualifyTop:t=2,format:n,developerMode:p}){const h=new Map;for(const f of j)h.set(f.id,f);const c=new Map;for(const f of r){const T=f.group_name||"Standings",l=c.get(T)||[],S=h.get(f.participant_id),k=p&&S?.dev_team_name||S?.team_name;l.push({...f,team_name:k||`Team #${f.participant_id}`,gd:f.goals_for-f.goals_against}),c.set(T,l)}const _=Array.from(c.entries()).sort(([f],[T])=>f.localeCompare(T)),v=n==="groups_knockout";return e.jsx("div",{className:"space-y-6",children:_.map(([f,T])=>e.jsxs(R.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},className:"card-stadium card-no-hover overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2.5",style:{borderBottom:"1px solid var(--color-line)",background:"rgba(255,102,0,0.03)"},children:e.jsx("h3",{className:"text-[14px] font-bold uppercase tracking-wider",style:{fontFamily:"var(--font-broadcast)",color:"var(--color-fox-text)"},children:f==="Standings"?"Standings":`Group ${f}`})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-line)"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-semibold",style:{color:"var(--color-kit-faded)",width:40},children:"#"}),e.jsx("th",{className:"px-3 py-2 text-left font-semibold",style:{color:"var(--color-kit-faded)"},children:"Team"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:36},children:"P"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:36},children:"W"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:36},children:"D"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:36},children:"L"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold max-sm:hidden",style:{color:"var(--color-kit-faded)",width:36},children:"GF"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold max-sm:hidden",style:{color:"var(--color-kit-faded)",width:36},children:"GA"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:40},children:"GD"}),e.jsx("th",{className:"px-3 py-2 text-center font-semibold",style:{color:"var(--color-kit-faded)",width:40},children:"Pts"})]})}),e.jsx("tbody",{children:T.map((l,S)=>{const k=v&&S<t;return e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-line)",background:k?"rgba(0,200,83,0.04)":void 0},children:[e.jsx("td",{className:"px-3 py-2 text-left",children:e.jsxs("div",{className:"flex items-center gap-1",children:[k&&e.jsx("div",{className:"w-1 h-4 rounded-full",style:{background:"var(--color-pitch-green)"}}),e.jsx("span",{style:{color:"var(--color-kit-faded)",fontFamily:"var(--font-broadcast)"},children:S+1})]})}),e.jsx("td",{className:"px-3 py-2 text-left font-medium",style:{color:k?"var(--color-kit-primary)":"var(--color-kit-secondary)"},children:l.team_name}),e.jsx("td",{className:"px-3 py-2 text-center",style:{color:"var(--color-kit-secondary)"},children:l.played}),e.jsx("td",{className:"px-3 py-2 text-center",style:{color:l.won>0?"var(--color-success-text)":"var(--color-kit-faded)"},children:l.won}),e.jsx("td",{className:"px-3 py-2 text-center",style:{color:"var(--color-kit-faded)"},children:l.drawn}),e.jsx("td",{className:"px-3 py-2 text-center",style:{color:l.lost>0?"var(--color-foul)":"var(--color-kit-faded)"},children:l.lost}),e.jsx("td",{className:"px-3 py-2 text-center max-sm:hidden",style:{color:"var(--color-kit-secondary)"},children:l.goals_for}),e.jsx("td",{className:"px-3 py-2 text-center max-sm:hidden",style:{color:"var(--color-kit-secondary)"},children:l.goals_against}),e.jsx("td",{className:"px-3 py-2 text-center font-semibold",style:{color:l.gd>0?"var(--color-success-text)":l.gd<0?"var(--color-foul)":"var(--color-kit-faded)"},children:l.gd>0?`+${l.gd}`:l.gd}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:"font-bold text-[14px]",style:{fontFamily:"var(--font-broadcast)",color:"var(--color-fox-text)"},children:l.points})})]},l.participant_id)})})]})}),v&&e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{borderTop:"1px solid var(--color-line)"},children:[e.jsx("div",{className:"w-1 h-3 rounded-full",style:{background:"var(--color-pitch-green)"}}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--color-kit-faded)"},children:"Qualified for knockout stage"})]})]},f))})}function It({standings:r,participants:j,matches:t,developerMode:n}){const p=new Map;for(const c of t){const _=p.get(c.round_number)||[];_.push(c),p.set(c.round_number,_)}const h=Array.from(p.entries()).sort(([c],[_])=>c-_);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(te,{standings:r,participants:j,qualifyTop:0,format:"swiss",developerMode:n}),h.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-[14px] font-bold uppercase tracking-wider",style:{fontFamily:"var(--font-broadcast)",color:"var(--color-kit-secondary)"},children:"Round Pairings"}),h.map(([c,_])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"var(--color-kit-faded)"},children:_[0]?.round_label||`Round ${c}`}),e.jsx("div",{className:"space-y-2",children:_.map(v=>e.jsx(_e,{match:v,developerMode:n},v.id))})]},c))]})]})}const Rt={knockout:"Knockout",groups_knockout:"Groups + KO",round_robin:"Round Robin",swiss:"Swiss"},zt={open:"#00e5ff",pending_sc:"#facc15",active:"#00c853",simulating:"#00c853",completed:"#586174",cancelled:"#ff3b30"};function _a(){const{id:r}=Pt(),j=Et(),[t,n]=m.useState(null),[p,h]=m.useState(!0),[c,_]=m.useState(""),[v,f]=m.useState(!1),T=m.useRef(null),[l,S]=m.useState("matches"),[k,N]=m.useState(!1),[J,ae]=m.useState(!1),{error:W,setError:g,shortfall:se,setShortfall:ke}=He(),{address:C}=Ke(),[Ne,E]=m.useState(!1),[re,we]=m.useState([]),[Te,Se]=m.useState(!1),[oe,X]=m.useState(null),[G,ne]=m.useState(!1),[Fe,U]=m.useState(!1),[le,Q]=m.useState(""),x=Ye(),{cfg:ie}=Xe(),z=ie?ie.tournamentPrizeSplit:null,o=parseInt(r||"0",10);m.useEffect(()=>{sessionStorage.getItem("foxleague_auth_token")&&Qe().then(u=>Se(u.is_admin)).catch(()=>{})},[]),m.useEffect(()=>{if(!C){X(null);return}fe(C).then(a=>
1X(a.user_id)).catch(()=>X(null))},[C]);const Pe=()=>{Q(""),U(!0)},Ee=async()=>{ne(!0),Q("");try{await ht(o),U(!1),j("/tournaments")}catch(a){Q(A(a,"Failed to delete")),U(!1)}finally{ne(!1)}},Le=m.useCallback(async()=>{if(o)try{const a=await ye(o,C);T.current=o,n(a),E(a.user_is_participant??!1)}catch(a){T.current===o&&$e(a)?f(!0):_("Failed to load tournament")}finally{h(!1)}},[o,C]),b=St(Le,o);m.useEffect(()=>{b()},[o,b]),m.useEffect(()=>{t&&t.tournament.max_teams===2&&j(`/challenges/${o}`,{replace:!0})},[t,o,j]);const ce=m.useRef(!1);m.useEffect(()=>{t&&(ce.current||(t.tournament.status==="open"&&l==="matches"&&S("lobby"),ce.current=!0))},[t,l]),m.useEffect(()=>{if(!o||v)return;const a=setInterval(b,3e4);return()=>clearInterval(a)},[o,b,v]),m.useEffect(()=>{if(!o||v||t?.tournament.status!=="pending_sc")return;const a=Date.now(),u=setInterval(()=>{if(Date.now()-a>2*6e4){clearInterval(u);return}b()},3e3);return()=>clearInterval(u)},[o,t?.tournament.status,b,v]);const F=m.useCallback(()=>{o&&Ve(o).then(we).catch(()=>{})},[o]);m.useEffect(()=>{l==="lobby"&&F()},[l,F]),Me(t&&!v?o:null,a=>{if(a.type==="deleted"){f(!0);return}b(),l==="lobby"&&F()}),Oe({address:C,tournamentId:o,loaded:!!t&&!v,isParticipant:!!t?.user_is_participant,busy:k,onOutcome:a=>{a.kind==="recovered"?(E(!0),B(),a.recovery.conditionWarning&&g(a.recovery.conditionWarning),b(),F()):a.kind==="already_in"?(E(!0),b()):g(A(a.error,"Failed to join"))}});const Ce=async()=>{N(!0),g("");const a=t?.tournament,u=!!a&&(a.tier==="silver"||a.tier==="gold")&&(a.entry_fee_foxsy??0)>0;if(u&&z===null){g(ge),N(!1);return}try{const d=P();if(!t?.tournament.developer_mode&&d?.address){const i=await fe(d.address),y=bt(i);if(!y.ok){g(y.reason||"Cannot join. Fix your lineup first."),N(!1);return}}}catch{}try{const d=P(),i=await ye(o,d?.address),y=i.tournament,w=y.status!=="open"?"This tournament is no longer open for joining.":i.user_is_participant?"You've already joined this tournament.":i.participants.length>=y.max_teams?"This tournament is now full.":i.user_can_join_private===!1?"This tournament is private. Only invited teams can join.":i.user_can_join_developer===!1?"This is a Developer-mode tournament. Upload and verify a team binary in Developers Hub first to join.":null;if(w){g(w),N(!1);return}}catch{}if(u){const d=P()?.address;if(d)try{const i=a.entry_fee_foxsy??0,[y,w]=await Promise.all([nt(d),lt(d)]),ze=BigInt(Math.round(i))*10n**18n;if(y!==null&&y<ze){ke(it(i,y)),N(!1);return}if(w!==null&&ct(w)){g("Not enough EGLD for the gas fee. Add a little EGLD and try again."),N(!1);return}}catch{}}let L=null;if(u)try{const d=await he(o,{onStatus:i=>{L=i}});if(d){E(!0),d.kind==="recovered"&&(B(),d.conditionWarning&&g(d.conditionWarning)),await b(),F(),N(!1);return}}catch(d){g(A(d,"Failed to join")),N(!1);return}if(u){const d=qe(L);if(d){g(d),await b(),N(!1);return}}u&&x.startTx("tournament_join");let H=!1,O;try{u&&(O=await jt({tournamentId:o,entryFeeFoxsy:a.entry_fee_foxsy??0},{onPreparing:()=>x.setTxStep("preparing"),onSigning:i=>x.setTxStep("signing",i),onSending:()=>x.setTxStep("sending"),onConfirming:i=>{x.setTxHash(i),x.setTxStep("confirming");const y=P()?.address;y&&dt(y,o,i)},onEntryRefused:i=>K(P()?.address,o,i),onError:i=>{x.setTxError(i),x.setTxStep("error")},onUnconfirmed:i=>{x.setTxError(i),x.setTxStep("unconfirmed")}}),H=!0);const d=await mt(o,O);O&&K(P()?.address,o,O),E(!0),u&&(x.setTxStep("done"),B()),d.condition_warning&&g(d.condition_warning),await b(),F()}catch(d){if(u)try{const y=await he(o);if(y){K(P()?.address,o),E(!0),x.setTxStep("done"),y.kind==="recovered"&&(B(),y.conditionWarning&&g(y.conditionWarning)),await b(),F(),N(!1);return}}catch{}if(d instanceof Lt)return;const i=A(d,"Failed to join");if(u){const y=d?.response?.status;if(pt(i)){x.setTxError("Payment confirmed: finalizing your seat. This updates automatically; do NOT pay again."),x.setTxStep("unconfirmed");const w=await ut(o);w&&(K(P()?.address,o),E(!0),x.setTxStep("done"),B(),w.kind==="recovered"&&w.conditionWarning&&g(w.conditionWarning),await b(),F());return}xt(P()?.address,o,O,d),ft(H,y,i)&&ve("error","tournament_join_failed_after_payment",`Tournament join rejected by backend after entry fee was paid on-chain: ${i}`,{tournamentId:o,tier:a?.tier,entryFeeFoxsy:a?.entry_fee_foxsy,status:y??null}),x.txStep!=="error"&&(x.setTxError(i),x.setTxStep("error"))}else g(i)}finally{N(!1)}},De=async()=>{ae(!0),g("");const a=!!t&&(t.tournament.entry_fee_foxsy??0)>0;a&&(x.startTx("tournament_leave"),x.setTxStep("confirming"));try{const u=await yt(o);a&&(u.refund_tx_hash&&x.setTxHash(u.refund_tx_hash),x.setTxStep("done")),E(!1),await b(),F()}catch(u){const L=A(u,"Failed to leave");a?(ve("error","tournament_leave_refund_failed",`Paid tournament leave failed after entry fee was charged (refund may not have been issued): ${L}`,{tournamentId:o,entryFeeFoxsy:t?.tournament.entry_fee_foxsy}),x.setTxError(L),x.setTxStep("error")):g(L)}finally{ae(!1)}};if(p)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"skeleton h-10 w-48"}),e.jsx(Ze,{size:"lg",text:"Loading tournament...",fullPage:!0})]});if(v)return e.jsx(Be,{kind:"tournament"});if(c||!t)return e.jsxs("div",{className:"card-stadium p-8 text-center",children:[e.jsx("p",{className:"text-[14px] mb-3",style:{color:"var(--color-foul)"},children:c||"Tournament not found"}),e.jsx("button",{onClick:()=>j("/tournaments"),className:"btn-ghost text-[14px] px-4 py-2 cursor-pointer",children:"Back to Tournaments"})]});const s=t.tournament,D=s.status==="open",V=s.status==="active"||s.status==="simulating",de=s.status==="completed",me=oe!=null&&s.creator_user_id===oe,Ie
1=!de&&!V&&(Te||me&&D),q=new Date(s.deadline).getTime()<Date.now(),I=Ne||Ae(t.participants,C),Z=(s.tier==="silver"||s.tier==="gold")&&(s.entry_fee_foxsy??0)>0&&z===null?ge:null,pe=[...t.matches].sort((a,u)=>{const L=a.scheduled_at?new Date(a.scheduled_at).getTime():Number.POSITIVE_INFINITY,H=u.scheduled_at?new Date(u.scheduled_at).getTime():Number.POSITIVE_INFINITY;return L-H||a.id-u.id}),$=s.entry_fee_foxsy*t.participants.length,Re=s.entry_fee_foxsy*s.max_teams,ue=z?_t({format:s.format,hasThirdPlaceMatch:s.has_third_place_match,split:z}):[],M=[];return D&&M.push({key:"lobby",label:"Lobby"}),M.push({key:"matches",label:"Matches"}),s.format!=="knockout"&&M.push({key:"standings",label:"Standings"}),s.format!=="round_robin"&&M.push({key:"bracket",label:"Bracket"}),e.jsxs("div",{children:[e.jsx(Je,{to:"/tournaments",label:"Back to Tournaments"}),e.jsxs(R.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"card-stadium card-no-hover p-5 mb-6",style:s.featured?{borderColor:"rgba(255,215,0,0.3)"}:void 0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-4",children:[e.jsxs("div",{className:"flex-1",children:[s.featured&&e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(vt,{size:12,style:{color:"#ffd700",fill:"#ffd700"}}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#ffd700"},children:"Featured"})]}),e.jsx("h1",{className:"text-[24px] sm:text-[32px] font-bold leading-tight mb-2",style:{fontFamily:"var(--font-broadcast)",color:"var(--color-kit-primary)"},children:s.title}),s.description&&e.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--color-kit-secondary)"},children:s.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[12px] px-2 py-1 rounded-lg",style:{background:"var(--color-fox-dim)",color:"var(--color-fox-text)"},children:[e.jsx(et,{size:12}),s.format==="round_robin"&&s.home_and_away?"Double Round Robin":Rt[s.format]||s.format]}),e.jsx(Ft,{tier:s.tier,className:"text-[11px] font-bold uppercase px-2 py-1 rounded-full"}),e.jsx("span",{className:"text-[11px] font-bold uppercase px-2 py-1 rounded-full",style:{background:`${zt[s.status]||"#586174"}15`,color:kt[s.status]??"var(--color-kit-faded)"},children:Nt(s.status)}),s.developer_mode&&e.jsx("span",{className:"text-[11px] font-bold uppercase px-2 py-1 rounded-full",style:{background:"rgba(167,139,250,0.12)",color:"#a78bfa",border:"1px solid rgba(167,139,250,0.3)"},children:"Developers"}),e.jsxs("span",{className:"flex items-center gap-1 text-[12px]",style:{color:"var(--color-kit-faded)"},children:[e.jsx(tt,{size:12}),t.participants.length,"/",s.max_teams," teams"]}),$>0&&e.jsxs("span",{className:"text-[12px] font-semibold inline-flex items-center gap-1.5",style:{color:"var(--color-fox-text)"},children:["Prize Pool:",e.jsx(Y,{amount:$,size:"sm"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 mt-3",children:[D&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",style:{color:"var(--color-kit-faded)"},children:[e.jsx(xe,{size:12}),q?"Registration Closed":`Deadline: ${je(s.deadline)}`]}),(D||V)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",style:{color:"var(--color-cyan)"},children:[e.jsx(at,{size:12}),D?`Starts in ${je(s.starts_at)}`:"In Progress"]}),de&&s.completed_at&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",style:{color:"var(--color-kit-faded)"},children:[e.jsx(xe,{size:12}),"Completed ",new Date(s.completed_at).toLocaleDateString()]})]})]}),D&&e.jsxs("div",{className:"flex flex-col items-stretch gap-2 flex-shrink-0 w-full sm:w-60",children:[q?e.jsx("div",{className:"px-5 py-2.5 min-h-[48px] flex items-center justify-center rounded-lg text-[13px] font-semibold text-center",style:{background:"var(--color-void)",color:"var(--color-kit-faded)",border:"1px solid var(--color-line)"},children:"Registration Closed"}):!I&&t.participants.length>=s.max_teams?e.jsx("div",{className:"px-5 py-2.5 min-h-[48px] flex items-center justify-center rounded-lg text-[13px] font-semibold text-center",style:{background:"var(--color-void)",color:"var(--color-kit-faded)",border:"1px solid var(--color-line)"}
1,children:"Tournament Full"}):t.user_can_join_private===!1&&!I?e.jsx("div",{className:"px-5 py-2.5 min-h-[48px] flex items-center justify-center rounded-lg text-[13px] font-semibold text-center",style:{background:"var(--color-void)",color:"var(--color-kit-faded)",border:"1px solid var(--color-line)"},children:"Invite Only"}):t.user_can_join_developer===!1&&!I?e.jsx("div",{className:"px-5 py-2.5 min-h-[48px] flex items-center justify-center rounded-lg text-[13px] font-semibold text-center",style:{background:"var(--color-void)",color:"var(--color-kit-faded)",border:"1px solid var(--color-line)"},title:"Developer-mode tournament. Upload and verify a team binary in Developers Hub first, then you can join.",children:"Developers Only"}):me&&s.organizer_only&&!I?e.jsx("div",{className:"px-5 py-2.5 min-h-[48px] flex items-center justify-center rounded-lg text-[13px] font-semibold text-center",style:{background:"var(--color-void)",color:"var(--color-kit-faded)",border:"1px solid var(--color-line)"},title:"You created this tournament as organizer-only: you run it without playing. Create it without 'Organizer only' to take part yourself.",children:"Organizer Only"}):I?e.jsxs("button",{onClick:De,disabled:J||q,"aria-busy":J||void 0,className:"btn btn-lg btn-danger w-full",children:[J?e.jsx(ee,{size:18,className:"animate-spin"}):e.jsx(st,{size:18}),J?"Leaving...":q?"Locked In":"Leave Tournament"]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:Ce,disabled:k||Z!==null,"aria-busy":k||void 0,className:"btn btn-lg btn-primary w-full",children:[k?e.jsx(ee,{size:18,className:"animate-spin"}):e.jsx(We,{size:18}),k?"Joining...":"Join Tournament"]}),Z&&e.jsx("p",{className:"text-[11px] text-center sm:text-right leading-snug",style:{color:"var(--color-kit-faded)"},children:Z})]}),W&&e.jsx("p",{className:"text-[12px] text-center sm:text-right leading-snug",style:{color:"var(--color-foul)"},children:se?e.jsx(rt,{shortfall:se,onSwapped:()=>g(""),className:"justify-center sm:justify-end"}):W})]})]}),!D&&W&&e.jsx("p",{className:"text-[12px] mt-3",style:{color:"var(--color-foul)"},children:W})]}),e.jsx(Ge,{tournamentId:s.id,status:s.status,entryFeeFoxsy:s.entry_fee_foxsy??0,noun:"tournament"}),$>0&&e.jsxs(R.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"rounded-lg px-4 py-3 mb-4",style:{background:"linear-gradient(135deg, rgba(251,146,60,0.10), rgba(251,146,60,0.02))",border:"1px solid rgba(251,146,60,0.25)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-[13px] font-semibold",style:{color:"var(--color-fox-text)"},children:"Prize structure"}),e.jsxs("span",{className:"text-[11px] inline-flex items-center gap-1.5 flex-wrap",style:{color:"var(--color-kit-faded)"},children:[e.jsx("span",{children:"Current pool:"}),e.jsx(Y,{amount:$,size:"sm",tone:"faded"}),e.jsx("span",{children:"· Max pool at full:"}),e.jsx(Y,{amount:s.entry_fee_foxsy*s.max_teams,size:"sm",tone:"faded"})]})]}),z===null?e.jsx("div",{className:"text-[12px]",style:{color:"var(--color-kit-faded)"},children:wt}):e.jsx("div",{className:`grid grid-cols-2 ${ue.length===3?"sm:grid-cols-3":"sm:grid-cols-4"} gap-3 text-[12px]`,children:ue.map(a=>{const u=a.label==="Winner"?"var(--color-fox)":a.label==="Runner-up"?"var(--color-kit-primary)":a.label==="3rd place"?"#92400e":"var(--color-kit-faded)";return e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",style:{color:u},children:`${a.label} · ${a.pct}%`}),e.jsxs("div",{className:"inline-flex items-center gap-1 flex-wrap",style:{color:"var(--color-kit-secondary)"},children:[e.jsx(Y,{amount:Math.floor($*a.pct/100),size:"sm",tone:"kit"}),e.jsx("span",{children:`now · up to ${Math.floor(Re*a.pct/100)} at full`})]})]},a.label)})})]}),(V||s.status==="simulating")&&I&&!s.developer_mode&&e.jsxs(R.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"rounded-lg px-4 py-3 mb-4",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.08), rgba(245,158,11,0.02))",border:"1px solid rgba(245,158,11,0.2)"},children:[e.jsx("p",{className:"text-[13px] font-medium",style:{color:"#f59e0b"},children:"Manager's notice"}),e.jsx("p",{className:"text-[12px] mt-1",style:{color:"var(--color-kit-secondary)"}
1,children:"Tournament matches consume player condition. Make sure your squad is well-rested before matches go live. Playing ranked matches before the tournament may drain your players' stamina."}),e.jsx("p",{className:"text-[12px] mt-1.5",style:{color:"var(--color-kit-secondary)"},children:s.tier==="bronze"?"This is a free Bronze tournament: it awards no ELO and no XP. Only your win/loss/draw record and player condition change (like a practice match).":"Results count: this tournament awards ELO and XP, plus the FOXSY prize pool."})]}),e.jsx("div",{className:"flex items-center gap-1 mb-5 border-b border-[var(--color-line)] overflow-x-auto scrollbar-hide",children:M.map(a=>e.jsx("button",{onClick:()=>S(a.key),className:`shrink-0 whitespace-nowrap px-4 py-2.5 text-[13px] font-medium transition-all border-b-2 -mb-px cursor-pointer ${l===a.key?"border-[var(--color-fox)] text-[var(--color-fox-text)]":"border-transparent text-[var(--color-kit-secondary)] hover:text-[var(--color-kit-primary)]"}`,children:a.label},a.key))}),e.jsxs(R.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.2},children:[l==="bracket"&&e.jsxs("div",{className:"space-y-4",children:[(t.tournament.format==="knockout"||t.tournament.format==="groups_knockout")&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"section-title mb-3",children:t.tournament.format==="groups_knockout"?"Knockout Stage":"Bracket"}),e.jsx(Ct,{matches:t.matches.filter(a=>t.tournament.format==="knockout"||a.round_label?.toLowerCase().includes("final")||a.round_label?.toLowerCase().includes("semi")||a.round_label?.toLowerCase().includes("quarter")||!a.group_name)})]}),t.tournament.format==="round_robin"&&t.standings&&e.jsx(te,{standings:t.standings,participants:t.participants,qualifyTop:0,format:"round_robin",developerMode:t.tournament.developer_mode}),t.tournament.format==="swiss"&&t.standings&&e.jsx(It,{standings:t.standings,participants:t.participants,matches:t.matches,developerMode:t.tournament.developer_mode})]}),l==="matches"&&e.jsx("div",{className:"space-y-2",children:pe.length===0?e.jsx("div",{className:"card-stadium card-no-hover p-8 text-center",children:e.jsx("p",{style:{color:"var(--color-kit-faded)"},children:"No matches yet. Tournament has not started."})}):pe.map(a=>e.jsx(_e,{match:a,developerMode:t.tournament.developer_mode},a.id))}),l==="standings"&&e.jsx("div",{children:t.standings&&t.standings.length>0?e.jsx(te,{standings:t.standings,participants:t.participants,qualifyTop:t.tournament.format==="groups_knockout"?2:0,format:t.tournament.format,developerMode:t.tournament.developer_mode}):e.jsx("div",{className:"card-stadium card-no-hover p-8 text-center",children:e.jsx("p",{style:{color:"var(--color-kit-faded)"},children:"Standings will appear after matches are played."})})}),l==="lobby"&&e.jsx(Ue,{participants:re.length>0?re:t.participants,startsAt:t.tournament.starts_at,developerMode:t.tournament.developer_mode})]},l),Ie&&e.jsxs("section",{"data-testid":"tournament-admin-section","aria-label":"Admin",className:"mt-8 pt-4",style:{borderTop:"1px solid var(--color-line)"},children:[e.jsx("h2",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--color-kit-faded)"},children:"Admin"}),e.jsx("p",{className:"text-[12px] mt-1 mb-3",style:{color:"var(--color-kit-faded)"},children:"Only the creator and admins see this."}),e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsxs("button",{onClick:Pe,disabled:G,"aria-busy":G||void 0,className:"btn btn-danger",children:[G?e.jsx(ee,{size:16,className:"animate-spin"}):e.jsx(gt,{size:16}),"Delete Tournament"]}),le&&e.jsx("p",{role:"alert",className:"text-[12px] leading-snug",style:{color:"var(--color-foul)"},children:le})]})]}),e.jsx(ot,{open:Fe,title:"Delete tournament",message:e.jsxs(e.Fragment,{children:["Permanently delete this tournament and all its data?",e.jsx("br",{}),e.jsx("span",{style:{color:"var(--color-kit-faded)"},children:"This cannot be undone. Standings, matches and participants are removed; on-chain entries are refunded automatically."})]}),confirmLabel:"Delete",cancelLabel:"Cancel",danger:!0,busy:G,onConfirm:Ee,onCancel:()=>U(!1)})]})}export{_a as TournamentDetail};

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.