PageSourceSearch

https://pblfg.com/assets/Stats-DTEQ_pF1.js

js pblfg.com collected 2026-09-24 14:49:56 UTC 128,067 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HeadToHeadComparison-Bos6Eet8.js","assets/react-vendor-Q2BSRknM.js","assets/index-CuraQpvj.js","assets/capacitor-DSpR9wll.js","assets/ui-radix-DzQ_orwq.js","assets/supabase-DoZmW4Yf.js","assets/lucide-DhlFjs1-.js","assets/query-BLOP9k_M.js","assets/date-utils-DaNoSKVa.js","assets/index-Dg-UEYD_.css","assets/calendar-BdktU-ss.js","assets/TeamHeadToHeadComparison-Czbjlr6b.js"])))=>i.map(i=>d[i]);
2import{_ as qs}from"./capacitor-DSpR9wll.js";import{r as i,j as e,k as Sa,m as Pa,L as fs}from"./react-vendor-Q2BSRknM.js";import{s as xe,bb as oe,c as T,aZ as O,bu as Ma,cB as Ca,J as ae,K as ne,N as re,O as y,a8 as P,b4 as aa,cC as _s,af as na,cD as ws,cE as Us,cF as Ta,cG as Ra,cm as vs,cH as Xs,R as Js,cI as $s,B as We,bY as Ge,C as Je,b as ls,d as Ns,e as is,cJ as Da,cK as La,cL as ra,h as la,u as Aa,cM as Wa,q as $a,a as Ia,a2 as Ea,a1 as Oa,a0 as Fa,cN as za,cO as Ba,cP as Ga,cQ as Is,cR as Ka,cS as Mt,cT as Ha,aX as Va,cU as qa,cV as Ua,bK as Xa,b5 as Ja,cW as Ya,bO as Qa,bm as Za,cX as en,b1 as sn,cY as tn,a4 as an,a3 as nn,cZ as Ct,a5 as Tt,a6 as Rt,a7 as Dt,ai as Lt,c_ as ue,c$ as At,aW as rs,L as rn,d0 as ln,d1 as on,d2 as cn,d3 as dn,bM as mn,d4 as un,bl as xn,M as ia,d5 as Wt}from"./index-CuraQpvj.js";import{u as os}from"./query-BLOP9k_M.js";import{b as oa,a as hn,u as pn}from"./usePartnerLeaderboard-CjMwUGsu.js";import{S as fn}from"./scroll-area-G9RincEy.js";import{r as Z,v as ys,o as Ce,q as Ye,S as $t,w as Ys,X as cs,aj as gn,d as jn,Z as Qe,Y as Qs,y as Ke,e as bn,b as wn,j as Gs,a3 as Ks,U as It,k as Et,i as vn}from"./lucide-DhlFjs1-.js";import{u as Nn,A as js,a as bs}from"./useAllTimePlayerStats-DAVCzUpt.js";import{R as ca,C as He,X as Ve,Y as qe,T as Ue,a as Xe,L as da,b as ma}from"./LineChart-CCRNn1iW.js";import{S as yn}from"./SuggestedPlayersBar-DHPH7tfM.js";import"./ui-radix-DzQ_orwq.js";import"./supabase-DoZmW4Yf.js";import"./date-utils-DaNoSKVa.js";import"./tiny-invariant-BaFNuDhB.js";function _n(a,n=!0){const c=os({queryKey:["mlp-team-events-played",a],enabled:n&&!!a,staleTime:3e5,queryFn:async()=>{const o=parseInt(a,10),p=`${o}-01-01`,d=`${o+1}-01-01`,{data:r,error:x}=await xe.from("tournaments").select("id, start_date").gte("start_date",p).lt("start_date",d).ilike("name","MLP%");if(x||!(r!=null&&r.length))return new Map;const b=r.map(w=>w.id),{data:h,error:f}=await xe.from("mlp_event_matchups").select("tournament_id, team1_uuid, team2_uuid, status").in("tournament_id",b);if(f||!(h!=null&&h.length))return new Map;const g=new Set,j=new Set;for(const w of h)j.add(w.tournament_id),w.status!=="completed"&&g.add(w.tournament_id);const l=Array.from(j).filter(w=>!g.has(w)),k=new Set(l),R=new Map;for(const w of h)if(k.has(w.tournament_id))for(const D of[w.team1_uuid,w.team2_uuid]){if(!D)continue;const F=R.get(D)||new Set;F.add(w.tournament_id),R.set(D,F)}const v=new Map;for(const[w,D]of R)v.set(w,D.size);return v}});return{eventsByTeam:c.data??new Map,isLoading:c.isLoading}}const kn=6*60*60*1e3,Sn="mlp-rank-history-v1:",Ot=a=>{try{const n=localStorage.getItem(a);return n?JSON.parse(n):null}catch{return null}},Es=(a,n)=>{try{localStorage.setItem(a,JSON.stringify(n))}catch{}},Pn=(a,n)=>{const c=a?`${Sn}${a}`:null,o=i.useRef({}),p=i.useMemo(()=>{var h,f;if(!c||!(n!=null&&n.length))return{};const r=Ot(c),x=((h=r==null?void 0:r.previous)==null?void 0:h.teams)??((f=r==null?void 0:r.current)==null?void 0:f.teams)??{},b={};for(const[g,j]of Object.entries(x))b[g]=j.standing;return b},[c,n]);return i.useEffect(()=>{if(!c||!(n!=null&&n.length))return;const r=Date.now(),x=Ot(c)??{},b={updatedAt:r,teams:Object.fromEntries(n.map(f=>[f.team_uuid,{standing:f.standing}]))};if(!x.current){Es(c,{current:b});return}r-(x.current.updatedAt||0)>=kn?Es(c,{previous:x.current,current:b}):Es(c,{previous:x.previous,current:b})},[c,n]),o.current=p,{getRankChange:(r,x)=>{const b=o.current[r];if(!(!b||b===x))return b-x}}},Mn=6*60*60*1e3,Cn="mlp-player-rank-history-v1:",Ft=a=>{try{const n=localStorage.getItem(a);return n?JSON.parse(n):null}catch{return null}},Os=(a,n)=>{try{localStorage.setItem(a,JSON.stringify(n))}catch{}},Tn=(a,n)=>
2{const c=a?`${Cn}${a}`:null,o=i.useRef({}),p=i.useMemo(()=>{var h,f;if(!c||!(n!=null&&n.length))return{};const r=Ft(c),x=((h=r==null?void 0:r.previous)==null?void 0:h.players)??((f=r==null?void 0:r.current)==null?void 0:f.players)??{},b={};for(const[g,j]of Object.entries(x))b[g]=j.rank;return b},[c,n]);return i.useEffect(()=>{if(!c||!(n!=null&&n.length))return;const r=Date.now(),x=Ft(c)??{},b={updatedAt:r,players:Object.fromEntries(n.map((f,g)=>[f.player_uuid,{rank:g+1}]))};if(!x.current){Os(c,{current:b});return}r-(x.current.updatedAt||0)>=Mn?Os(c,{previous:x.current,current:b}):Os(c,{previous:x.previous,current:b})},[c,n]),o.current=p,{getRankChange:(r,x)=>{const b=o.current[r];if(!(!b||b===x))return b-x}}};function zt({rows:a,isLightTheme:n,onPlayerClick:c,resolveTeamLogo:o,onTeamClick:p}){return a.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"DreamBreaker stats will appear once match rotations are synced."}):e.jsx(e.Fragment,{children:a.map((d,r)=>{const x=r>0?a[r-1]:null,h=!!x&&x.win_pct===d.win_pct&&x.points_won===d.points_won?`T${r+1}`:`#${r+1}`,f=d.player_name||"",g=(o==null?void 0:o(f))||oe(d.team_title||"")||null;return e.jsxs("button",{onClick:()=>c(f),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg text-left transition-colors",n?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsx("span",{className:"font-score text-sm text-muted-foreground",children:h})}),e.jsx(O,{name:f,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:f}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[g?e.jsx("span",{role:"button",tabIndex:0,onClick:j=>{j.stopPropagation(),p==null||p(f,d.team_title??null)},className:"w-4 h-4 rounded-full bg-muted/40 overflow-hidden flex items-center justify-center shrink-0 focus:outline-none transition-transform hover:scale-110","aria-label":d.team_title||"Team",children:e.jsx("img",{src:g,alt:d.team_title||"",className:"h-full w-full object-cover",loading:"lazy",onError:j=>{j.currentTarget.style.display="none"}})}):null,e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate",children:[d.points_won,"-",d.points_lost," DB PTS • ",d.db_matches," DB",d.db_matches===1?"":"s"]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-14",children:[e.jsxs("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:[Math.round(d.win_pct),"%"]}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground/50 uppercase tracking-wider leading-none",children:"PT WIN"})]})]},`${d.player_uuid}-${d.season}`)})})}const Hs="leaderboard_tabs_order_cache_v3";function Bt(){try{const a=localStorage.getItem(Hs);if(!a)return null;const n=JSON.parse(a);return Array.isArray(n)?n:null}catch{return null}}function Rn(a){const{data:n}=os({queryKey:["app_settings","leaderboard_tabs_order"],queryFn:async()=>{const{data:r}=await xe.from("app_settings").select("value").eq("key","leaderboard_tabs_order").maybeSingle();if(!(r!=null&&r.value)){try{localStorage.removeItem(Hs)}catch{}return null}try{const x=JSON.parse(r.value);if(Array.isArray(x)){try{localStorage.setItem(Hs,JSON.stringify(x))}catch{}return x}return null}catch{return null}},staleTime:0,refetchOnMount:"always",initialData:()=>Bt()??void 0}),c=n??Bt();if(!c||c.length===0||!n&&a.some(r=>!c.includes(r)))return a;const o=new Set(a),p=new Set,d=[];for(const r of c)o.has(r)&&!p.has(r)&&(d.push(r),p.add(r));for(const r of a)p.has(r)||d.push(r);if(o.has("mlpTeams")&&o.has("mlpPlayers")){const r=d.indexOf("mlpTeams"),x=d.indexOf("mlpPlayers");if(r>=0&&x>=0&&x!==r+1){const[b]=d.splice(x,1),h=d.indexOf("mlpTeams");d.splice(h+1,0,b)}}if(o.has("mlpPlayers")&&o.has("mlpDuos")){const r=d.indexOf("mlpPlayers"),x=d.indexOf("mlpDuos");if(r>=0&&x>=0&&x!==r+1){const[b]=d.splice(x,1),h=d.indexOf("mlpPlayers");d.splice(h+1,0,b)}}return d}const Vs="leaderboard_default_tab_cache";function Gt(){try{return localStorage.getItem(Vs)}catch{return null}}function Dn(a){const{data:n}=os({queryKey:["app_settings","leaderboard_default_tab"],queryFn:async()=>{const{data:o}=await xe.from("app_settings").select("value").eq("key","leaderboard_default_tab").maybeSingle(),p=((o==null?void 0:o.value)||"").toString().trim();if(!p){try{localStorage.removeItem(Vs)}catch{}return null}try{localStorage.setItem(Vs,p)}catch{}return p},staleTime:6e5,initialData:()=>Gt()??void 0}),c=n??Gt();return c&&a.includes(c)?c:null}const Ln={F:"Final",SF:"SF",QF:"QF",BRONZE:"Bronze",R16:"R16",R32:"R32",R64:"R64",R128:"R128"};
2function An(a){const n=a.round;return n==="F"?a.won?"Gold":"Silver":n==="BRONZE"?a.won?"Bronze":"4th":ua(n)}function ua(a){return a?Ln[a]??a:null}function Wn(a){if(!a)return null;const n=a.toLowerCase(),c=/singles/.test(n);return/mixed/.test(n)?"MXD":/women/.test(n)?c?"WS":"WD":/men/.test(n)?c?"MS":"MD":null}function $n(a){const n=_s(a).trim().split(/\s+/);return n.length>1?n.slice(1).join(" "):n[0]??a}function In(a){const n=_s(a).trim().split(/\s+/);return n.length<2?n[0]??a:`${n[0][0]}. ${n.slice(1).join(" ")}`}function En(a){const n=a.opponents??[],c=n.length>1?n.map($n).join("/"):n.length===1?In(n[0]):"";return c?a.seed!=null?`Beat #${a.seed} ${c}`:a.opponent_rank!=null?`Beat #${a.opponent_rank} ${c}`:`Beat ${c}`:a.label}const On=/\b(finals?|masters|world|championships?)\b/i;function Fn(a){return(a.split(/\s+presented by\s+/i)[0]??a).replace(/\b(19|20)\d{2}\b/g," ").replace(/\s+/g," ").trim()}function zn(a){if(!a)return null;let n=a.split(/\s+presented by\s+/i)[0]??a;return n=n.replace(/\b(19|20)\d{2}\b/g," ").replace(/\bppa\b/gi," ").replace(/\bmlp\b/gi," ").replace(/\btour\b/gi," ").replace(/\bchallenger\b/gi," ").replace(/\bchampionships?\b/gi," ").replace(/\bopen\b/gi," ").replace(/\bcup\b/gi," ").replace(/\bslam\b/gi," ").replace(/\s+/g," ").trim(),n||null}function Bn(a,n){const c=ua(a),o=c==="Final"?"Finals":c;if(n&&On.test(n)){const d=Fn(n);if(d&&o)return` in ${o} at ${d}`;if(d)return` at ${d}`}const p=zn(n);return p&&o?` in ${p} ${o}`:o?` in ${o}`:p?` in ${p}`:""}function Gn({className:a}){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:a,"aria-hidden":"true",children:e.jsx("path",{d:"M12 2.5l3 6.1 6.7 1-4.85 4.73L18 21l-6-3.15L6 21l1.15-6.67L2.3 9.6l6.7-1L12 2.5z"})})}function Kn({star:a,rank:n,onClick:c,onMatchClick:o}){var k,R,v;const p=a.best_run,d=a.signature_win,r=p?An(p):null,x=a.wins+a.losses,b=x>0?Math.round(a.wins/x*100):null,h=n<=10,f=((k=a.details)==null?void 0:k.best_win_rank)??null,g=((R=a.details)==null?void 0:R.best_win_match_id)??null,j=((v=a.details)==null?void 0:v.best_win_mlp_matchup_uuid)??null,l=(w,D)=>F=>{!w&&!D||(F.stopPropagation(),o({matchId:w,mlpMatchupUuid:D}))};return e.jsx("div",{className:"shrink-0",children:e.jsxs("div",{role:"button",tabIndex:0,onClick:c,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),c())},className:"stat-card-sheen cursor-pointer flex flex-col gap-2 p-3 rounded-xl border border-border/30 transition-all text-left w-[300px] hover:border-border/50",style:{background:"var(--gradient-match-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{name:a.player_name,className:"w-10 h-10"}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-primary text-primary-foreground text-[6px] font-bold w-3.5 h-3.5 rounded-full flex items-center justify-center",children:n})]}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[e.jsx("div",{className:"font-player font-medium uppercase text-lg leading-tight truncate min-w-0 flex-1",children:_s(a.player_name)}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 text-[13px] text-muted-foreground whitespace-nowrap",children:[a.rank_now!=null&&e.jsxs("span",{className:"font-score text-[13px] font-semibold leading-none",children:["WPR #",a.rank_now]}),a.rank_climb>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-primary",children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-score text-[13px] font-semibold leading-none",children:a.rank_climb})]}),a.rank_climb<0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-destructive",children:[e.jsx(ys,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-score text-[13px] font-semibold leading-none",children:Math.abs(a.rank_climb)})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1",children:[e.jsxs("div",{className:`rounded px-1.5 py-1 text-center ${h?"bg-primary/20":"bg-primary/10"}`,children:[e.jsx("div",{className:"text-[8px] uppercase tracking-wide whitespace-nowrap text-primary/80",children:"RISE Score"}),e.jsx("div",{className:"text-sm font-semibold font-score text-primary leading-tight",children:Math.round(a.rise_score)})]}),e.jsxs("div",{className:"rounded bg-muted/30 px-1.5 py-1 text-center",children:[e.jsx("div",{className:"text-[8px] uppercase tracking-wide whitespace-nowrap text-muted-foreground",children:"Record"}),e.jsxs("div",{className:"text-xs font-semibold font-score leading-tight mt-0.5 whitespace-nowrap",children:[a.wins,"-",a.losses,b!=null&&e.jsxs("span",{className:"text-[10px] text-muted-foreground font-normal",children:[" (",b,"%)"]})]})]}),e.jsxs("div",{className:"rounded bg-muted/30 px-1.5 py-1 text-center",children:[e.jsx("div",{className:"text-[8px] uppercase tracking-wide whitespace-nowrap text-muted-foreground",children:"Top 50 Ws"}),e.jsx("div",{className:"text-xs font-semibold font-score leading-tight mt-0.5",children:a.ranked_scalps})]}),e.jsxs("div",{className:`rounded bg-muted/30 px-1.5 py-1 text-center ${g||j?"cursor-pointer hover:bg-muted/50 transition-colors":""}`,onClick:l(g,j),children:[e.jsx("div",{className:"text-[8px] uppercase tracking-wide whitespace-nowrap text-muted-foreground",children:"Best W vs"}),e.jsx("div",{className:"text-xs font-semibold font-score leading-tight mt-0.5 whitespace-nowrap",children:f!=null?`#${f} WPR`:"—"})]})]}),p&&e.jsxs("div",{className:`flex items-start gap-1.5 text-[10px] leading-tight ${p.match_id?"cursor-pointer hover:opacity-80 transition-opacity":""}`,onClick:l(p.match_id),children:[e.jsx(Ce,{className:"h-3 w-3 shrink-0 text-primary/70 mt-px"}),e.jsxs("span",{children:[e.jsx("span",{className:"uppercase tracking-wide text-muted-foreground",children:"Best run: "}),e.jsxs("span",{className:"font-medium",children:[[Wn(p.event),r].filter(
2Boolean).join(" ")," · ",p.tournament]})]})]}),d&&e.jsxs("div",{className:`flex items-start gap-1.5 text-[10px] leading-tight text-muted-foreground ${d.match_id?"cursor-pointer hover:opacity-80 transition-opacity":""}`,onClick:l(d.match_id),children:[e.jsx(Ye,{className:"h-3 w-3 shrink-0 text-primary/70 mt-px"}),e.jsxs("span",{children:[e.jsx("span",{className:"uppercase tracking-wide",children:"Signature: "}),e.jsxs("span",{className:"text-foreground",children:[En(d),Bn(d.round,d.tournament)]})]})]})]})})}function Kt({onPlayerClick:a,minCount:n=4,limit:c=120}){const{stars:o,isLoading:p}=oa(c),[d,r]=i.useState("all"),[x,b]=i.useState(null),h=i.useCallback(async({matchId:g,mlpMatchupUuid:j})=>{if(g){const{data:w}=await xe.from("matches").select("*").eq("id",g).maybeSingle();w&&b(w);return}if(!j)return;let l=null;if(l=(await xe.from("mlp_event_matchups").select("*").eq("lineup_matchup_uuid",j).maybeSingle()).data,l||(l=(await xe.from("mlp_event_matchups").select("*").eq("id",j).maybeSingle()).data),!l)return;let R=null;if(l.tournament_id){const{data:w}=await xe.from("tournaments").select("name").eq("id",l.tournament_id).maybeSingle();R=(w==null?void 0:w.name)??null}const v=Ma(l,{tournament:R||"MLP"});b(v)},[]),f=d==="all"?o:o.filter(g=>g.gender===d);return!p&&o.length<n?null:e.jsxs("section",{className:"space-y-3 w-full max-w-full min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gn,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Rising Stars"}),e.jsx(Ca,{slot:"rising_stars",size:15})]}),e.jsxs(ae,{value:d,onValueChange:g=>r(g),children:[e.jsx(ne,{className:"h-5 w-auto min-w-[40px] text-[10px] border-0 bg-muted/40 focu
2s:ring-0 focus:ring-offset-0 focus:outline-none px-2",children:e.jsx("span",{children:d==="all"?"All":d==="M"?"Men":"Women"})}),e.jsxs(re,{children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"M",children:"Men"}),e.jsx(y,{value:"F",children:"Women"})]})]})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto scrollbar-hide w-full max-w-full",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:p?Array.from({length:5}).map((g,j)=>e.jsx("div",{className:"shrink-0",children:e.jsxs("div",{className:"flex flex-col gap-2 p-3 rounded-xl border border-border/30 bg-muted/20 w-[200px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-2 w-14"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(P,{className:"h-10 rounded"}),e.jsx(P,{className:"h-10 rounded"})]}),e.jsx(P,{className:"h-2 w-32"})]})},j)):f.map((g,j)=>e.jsx(Kn,{star:g,rank:j+1,onClick:()=>a(g.player_name),onMatchClick:h},g.player_name))}),e.jsx(aa,{match:x,open:!!x,onOpenChange:g=>!g&&b(null)})]})}const xa=()=>{const[a,n]=i.useState(!1);return i.useEffect(()=>{const c=o=>{var r;const p=o,d=!!((r=p==null?void 0:p.detail)!=null&&r.active);n(d)};return window.addEventListener("pblfg:auth-transition",c),()=>window.removeEventListener("pblfg:auth-transition",c)},[]),{isAuthTransitioning:a}},Hn=i.lazy(()=>qs(()=>import("./HeadToHeadComparison-Bos6Eet8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(a=>({default:a.HeadToHeadComparison}))),Vn=i.lazy(()=>qs(()=>import("./TeamHeadToHeadComparison-Czbjlr6b.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,8,9])).then(a=>({default:a.TeamHeadToHeadComparison}))),Ht=({showTitle:a=!1})=>{var Ne;const[n,c]=i.useState(!1),o=i.useRef(null),p=i.useRef(!1),{isAuthTransitioning:d}=xa(),{isLightTheme:r}=na(),[x,b]=i.useState(null),[h,f]=i.useState(null),[g,j]=i.useState(null),[l,k]=i.useState("");i.useEffect(()=>{const M=o.current;if(!M)return;const A=new IntersectionObserver(H=>{const $=H[0];$!=null&&$.isIntersecting&&!p.current&&(p.current=!0,ws(),i.startTransition(()=>c(!0)),A.disconnect())},{rootMargin:"100px 0px",threshold:.01});return A.observe(M),()=>A.disconnect()},[]),i.useEffect(()=>{if(n){const M=setTimeout(()=>{window.dispatchEvent(new Event("pblfg:resume-watchdog"))},800);return()=>clearTimeout(M)}},[n]);const R=n&&!d,v=(x==null?void 0:x.type)??(h==null?void 0:h.type)??null,{allPlayers:w}=Us({defer:!0,listenToGlobalTrigger:!0}),{data:D=[]}=Ta(),{topTeams:F}=Ra(24),U=i.useMemo(()=>new vs(w,{threshold:.3,minMatchCharLength:2}),[w.length>0?Math.floor(w.length/10):0]),K=i.useMemo(()=>new vs(D,{keys:["team_title"],threshold:.3,minMatchCharLength:2}),[D.length]),J=g==="A"?h:x,fe=(Ne=J==null?void 0:J.name)==null?void 0:Ne.toLowerCase(),ce=J==null?void 0:J.uuid,ee=i.useMemo(()=>v==="team"?[]:!l||l.length<2?[]:U.search(l).slice(0,12).map(M=>M.item).filter(M=>M.toLowerCase()!==fe).slice(0,8),[U,l,v,fe]),he=i.useMemo(()=>v==="player"?[]:!l||l.length<2?[]:K.search(l).slice(0,12).map(M=>M.item).filter(M=>M.team_uuid!==ce).slice(0,8),[K,l,v,ce]),Re=i.useMemo(()=>{if(v==="team")return[];const M=["Ben Johns","Anna Leigh Waters","Federico Staksrud","JW Johnson","Catherine Parenteau","Anna Bright","Christian Alshon","Parris Todd","Andrei Daescu","Jorja Johnson","Gabriel Tardio","Rachel Rohrabacher","Hayden Patriquin","Etta Wright","Dylan Frazier","Vivian Glozman","Connor Garnett","Tyra Black","Quang Duong","Lea Jansen"],A=new Set(w.map(q=>q.toLowerCase())),H=A.size>0?M.filter(q=>A.has(q.toLowerCase())):M,$=v==="player"?18:6;return H.filter(q=>q.toLowerCase()!==fe).slice(0,$)},[v,fe,w]),L=M=>/(collegiate|all[- ]stars|team\s+(usa|canada|australia|europe|world|international)|^(canada|australia|europe|usa|world|international)$|exhibition|challenger\s+all)/i.test(M.trim()),ge=i.useMemo(()=>{if(v==="player")return[];const M=F.filter($=>$.teamUuid&&$.teamName&&!L($.teamName)).map($=>({team_uuid:$.teamUuid,team_title:$.teamName})),A=M.length>0?M:D.filter($=>!L($.team_title)),H=v==="team"?24:6;return A.filter($=>$.team_uuid!==ce).slice(0,H)},[D,F,v,ce]),S=()=>{j(null),k("")},z=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{var M;(M=o.current)==null||M.scrollIntoView({block:"start",behavior:"smooth"})})})},E=M=>{const A={type:"player",name:M};g==="A"?b(A):g==="B"&&f(A),S(),z()},Y=M=>
2{const A={type:"team",name:M.team_title,uuid:M.team_uuid};g==="A"?b(A):g==="B"&&f(A),S(),z()},B=M=>{M==="A"?b(null):f(null)},je=x&&h,W=v==="player"?"Player":v==="team"?"Team":"Player or Team",Ie=v==="player"?"Search player...":v==="team"?"Search team...":"Search player or team...",de=(M,A)=>{if(A)return e.jsxs("div",{className:T("relative flex w-full flex-col items-center justify-center gap-1.5 rounded-xl border p-4 aspect-[5/4]",r?"bg-white border-border":"bg-muted/30 border-border"),children:[e.jsx(We,{variant:"ghost",size:"icon",onClick:()=>B(M),className:"absolute top-1 right-1 h-5 w-5","aria-label":"Remove",children:e.jsx(cs,{className:"h-3 w-3"})}),A.type==="player"?e.jsx(O,{name:A.name,className:"h-16 w-16"}):e.jsx($s,{teamName:A.name,size:"lg"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-center truncate w-full uppercase tracking-wide",children:A.type==="player"?Ge(A.name):A.name})]});const H=v==="player"?"Player":v==="team"?"Team":"Player or Team";return e.jsxs("button",{type:"button",className:T("flex w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed p-4 transition-colors aspect-[5/4]",r?"bg-white/50 border-border hover:bg-accent/30":"bg-muted/10 border-border/50 hover:bg-muted/20"),onClick:()=>{ws(),j(M)},children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full border-2 border-dashed border-muted-foreground/40 bg-muted/40",children:v==="team"?e.jsx(gn,{className:"h-7 w-7 text-muted-foreground"}):v==="player"?e.jsx(jn,{className:"h-8 w-8 text-muted-foreground"}):e.jsx($t,{className:"h-7 w-7 text-muted-foreground"})}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground -mb-0.5",children:"Choose"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-muted-foreground uppercase tracking-wide leading-tight text-center",children:H})]})};return e.jsx("div",{ref:o,className:"min-h-[200px] space-y-3",children:R?e.jsxs(e.Fragment,{children:[a&&e.jsx("div",{className:"flex items-center justify-between -mt-1",children:e.jsxs("div",{className:"flex items-center gap-2 text-scalable-sm font-semibold",children:[e.jsx($t,{className:"h-4 w-4 text-primary"}),"Compare Players & Teams"]})}),!je&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 max-w-[340px] mx-auto",children:[de("A",x),de("B",h)]}),je&&(x==null?void 0:x.type)==="player"&&(h==null?void 0:h.type)==="player"&&e.jsx(i.Suspense,{fallback:e.jsx(P,{className:"h-32 w-full"}),children:e.jsx(Hn,{initialPlayer1:x.name,initialPlayer2:h.name,showTitle:!1,onClearA:()=>B("A"),onClearB:()=>B("B")},`p-${x.name}-${h.name}`)}),je&&(x==null?void 0:x.type)==="team"&&(h==null?void 0:h.type)==="team"&&e.jsx(i.Suspense,{fallback:e.jsx(P,{className:"h-32 w-full"}),children:e.jsx(Vn,{initialTeamA:x.uuid,initialTeamB:h.uuid,showTitle:!1,onClearA:()=>B("A"),onClearB:()=>B("B")},`t-${x.uuid}-${h.uuid}`)}),e.jsxs(Xs,{open:g!==null,onOpenChange:M=>{M||S()},title:`Choose ${W}`,desktopClassName:"sm:max-w-md px-4 pb-6 flex flex-col h-[85vh]",mobileClassName:"px-4 pb-6 flex flex-col h-[85dvh]",children:[e.jsx("div",{className:"pb-3 pt-2 shrink-0",children:e.jsxs("h2",{className:"text-base font-semibold",children:["Choose ",W]})}),e.jsxs("div",{className:"relative mb-4 shrink-0",children:[e.jsx(Ys,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Js,{value:l,onChange:M=>k(M.target.value),placeholder:Ie,className:"pl-9",autoFocus:!1})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto -mx-1 pr-1",children:(()=>{const M=l.length>=2,A=v!=="team",H=v!=="player";return M?ee.length===0&&he.length===0?e.jsx("p",{className:"text-scalable-sm text-muted-foreground text-center py-4",children:"No matches found"}):e.jsxs("div",{className:"space-y-4",children:[H&&he.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:"Teams"}),e.jsx("div",{className:"space-y-0.5",children:he.map(q=>e.jsxs("button",{type:"button",onClick:()=>Y(q),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx($s,{teamName:q.team_title,size:"sm"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:q.team_title})]},q.team_uuid))})]}),A&&ee.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:"Players"}),e.jsx("div",{className:"space-y-0.5",children:ee.map(q=>e.jsxs("button",{type:"button",onClick:()=>E(q),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx(O,{name:q,className:"h-9 w-9"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:q})]},q))})]})]}):e.jsxs("div",{className:"space-y-4",children:[A&&Re.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:v==="player"?"Players":"Suggested Players"}),e.jsx("div",{className:"space-y-0.5",children:Re.map($=>e.jsxs("button",{type:"button",onClick:()=>E($),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx(O,{name:$,className:"h-9 w-9"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:$})]},$))})]}),H&&ge.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:v==="team"?"Teams":"Suggested Teams"}),e.jsx("div",{className:"space-y-0.5",children:ge.map($=>e.jsxs("button",{type:"button",onClick:()=>Y($),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx($s,{teamName:$.team_title,size:"sm"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:$.team_title})]},$.team_uuid))})]})]})})()})]})]}):e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(P,{className:"h-10 w-full rounded-md"}),e.jsx(P,{className:"h-10 w-full rounded-md"})]})})},qn=({playerName:a,onPlayerClick:n})=>{const{data:c,isLoading:o}=Nn(a),p=i.useRef(null),[d,r]=i.useState(0),x=i.useCallback(()=>{var w;if(!p.current)return;const j=p.current,l=j.scrollLeft,k=((w=j.firstElementChild)==null?void 0:w.clientWidth)||1,v=Math.round(l/(k+12));r(Math.min(3,Math.max(0,v)))},[]);i.useEffect(()=>{const j=p.current;if(j)return j.addEventListener("scroll",x,{passive:!0}),()=>j.removeEventListener("scroll",x)},[x]);const b=j=>{var v;if(!p.current)return;const l=p.current,k=((v=l.firstElementChild)==null?void 0:v.clientWidth)||0;l.scrollTo({left:j*(k+12),behavior:"smooth"})},h=i.useMemo(()=>c?c.tournamentStats.map(j=>{let l=j.tournament;return/world\s*championships?/i.test(l)?l="Worlds":l=l.replace(/^PPA\s+/i,"").replace(/\s+(Open|Cup|Slam)$/i,""),{...j,dateLabel:l.length>10?l.slice(0,8)+"…":l,fullLabel:j.tournament.replace(/^PPA\s+/i,"")}}):[],[c]);if(o)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx(P,{className:"h-10 w-10 rounded-full"}),e.jsx(P,{className:"h-5 w-32"})]}),e.jsx(P,{className:"h-[200px] w-full rounded-lg"}),e.jsx("div",{className:"flex justify-center gap-1.5",children:[0,1,2,3].map(j=>e.jsx(P,{className:"h-1.5 w-1.5 rounded-full"},j))})]});if(!c||c.tournamentStats.length<2)return e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Z,{className:"h-10 w-10 mx-auto mb-2 opacity-50"}),e.jsxs("p",{children:["Not enough data for ",a]}),e.jsx("p",{className:"text-scalable-xs mt-1",children:"Need at least 2 tournaments to show trends"})]});const f=({active:j,payload:l})=>{var D,F,U;if(!j||!l||!l.length)return null;
2const k=(D=l[0])==null?void 0:D.payload;if(!k)return null;const R=(F=l[0])==null?void 0:F.value,v=((U=l[0])==null?void 0:U.name)||"",w=typeof R=="number"?v.includes("%")||v==="Win Rate"||v==="Power Score"||v==="Points Won %"?`${R.toFixed(1)}%`:v==="Point Diff"?(R>0?"+":"")+R:R:R;return e.jsxs("div",{className:"bg-popover border border-border rounded-lg p-2 text-scalable-xs shadow-lg",children:[e.jsx("p",{className:"font-semibold text-foreground",children:k.fullLabel}),e.jsxs("p",{className:"text-primary",children:[v,": ",w]}),e.jsxs("p",{className:"text-muted-foreground",children:["Record: ",k.wins,"-",k.losses]})]})},g=[{title:"Power Rank",icon:e.jsx(Qe,{className:"h-4 w-4 text-primary"}),chart:e.jsxs(js,{data:h,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"powerGradientSearch",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(Ve,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},stroke:"hsl(var(--border))",interval:0}),e.jsx(qe,{domain:[0,100],ticks:[25,50,75,100],tick:{fill:"hsl(var(--muted-foreground))",fontSize:10,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:35}),e.jsx(Ue,{content:e.jsx(f,{})}),e.jsx(Xe,{y:50,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.5}),e.jsx(bs,{type:"monotone",dataKey:"powerScore",name:"Power Score",stroke:"hsl(var(--primary))",strokeWidth:2,fill:"url(#powerGradientSearch)"})]})},{title:"Win Rate",icon:e.jsx(Z,{className:"h-4 w-4 text-primary"}),chart:e.jsxs(js,{data:h,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"winRateGradientSearch",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(Ve,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},stroke:"hsl(var(--border))",interval:0}),e.jsx(qe,{domain:[0,100],ticks:[25,50,75,100],tick:{fill:"hsl(var(--muted-foreground))",fontSize:10,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:35}),e.jsx(Ue,{content:e.jsx(f,{})}),e.jsx(Xe,{y:50,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.5}),e.jsx(bs,{type:"monotone",dataKey:"winRate",name:"Win Rate",stroke:"hsl(var(--primary))",strokeWidth:2,fill:"url(#winRateGradientSearch)"})]})},{title:"Point Differential",icon:e.jsx(Qs,{className:"h-4 w-4 text-primary"}),chart:e.jsxs(da,{data:h,children:[e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(Ve,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},stroke:"hsl(var(--border))",interval:0}),e.jsx(qe,{domain:["auto","auto"],allowDataOverflow:!0,tick:{fill:"hsl(var(--muted-foreground))",fontSize:10,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:35,tickFormatter:j=>j===0?"":String(j)}),e.jsx(Ue,{content:e.jsx(f,{})}),e.jsx(Xe,{y:0,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.5}),e.jsx(ma,{type:"monotone",dataKey:"pointDifferential",name:"Point Diff",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1})]})},{title:"Points Won %",icon:e.jsx(Ye,{className:"h-4 w-4 text-primary"}),chart:e.jsxs(js,{data:h,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"ptsWonGradientSearch",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(Ve,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},stroke:"hsl(var(--border))",interval:0}),e.jsx(qe,{domain:[0,100],allowDataOverflow:!0,ticks:[25,50,75,100],tick:{fill:"hsl(var(--muted-foreground))",fontSize:10,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:35}),e.jsx(Ue,{content:e.jsx(f,{})}),e.jsx(Xe,{y:50,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.5}),e.jsx(bs,{type:"monotone",dataKey:"pointsWonPercent",name:"Points Won %",stroke:"hsl(var(--primary))",strokeWidth:2,fill:"url(#ptsWonGradientSearch)"})]})}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:n,className:"flex items-center gap-3 px-1 hover:opacity-80 transition-opacity w-full text-left",style:{WebkitTapHighlightColor:"transparent"},children:[e.jsx(O,{name:a,className:"h-10 w-10"}),e.jsx("p",{className:"font-semibold text-lg",children:a})]}),e.jsx("div",{ref:p,className:"flex gap-3 overflow-x-auto snap-x snap-mandatory scrollbar-hide pb-1",style:{touchAction:"pan-x pan-y"},children:g.map((j,l)=>e.jsxs(Je,{className:"snap-start shrink-0 w-full min-w-[calc(100%-1rem)]",children:[e.jsx(ls,{className:"pb-2 pt-3 px-3",children:e.jsxs(Ns,{className:"text-scalable-sm flex items-center gap-2",children:[j.icon,j.title]})}),e.jsx(is,{className:"px-2 pb-3",children:e.jsx(ca,{width:"100%",height:180,children:j.chart})})]},l))}),e.jsx("div",{className:"flex justify-center gap-1.5",children:g.map((j,l)=>e.jsx("button",{onClick:()=>b(l),className:T("h-1.5 rounded-full transition-all",d===l?"w-4 bg-primary":"w-1.5 bg-muted-foreground
2/30 hover:bg-muted-foreground/50"),"aria-label":`Go to chart ${l+1}`},l))})]})},Vt=(a,n=3,c,o)=>{const{resolve:p}=Da(),d=i.useMemo(()=>a.map(h=>p(h)),[a,p]),{data:r,isLoading:x}=La(d,"all",{enabled:d.length>0}),b=i.useMemo(()=>{const h=new Map;if(r)for(const f of r)h.set(f.player_name,f);return a.map(f=>{const g=h.get(p(f));return g?{data:{tournamentStats:g.tournament_stats||[],totalMatches:g.total_matches,totalWins:g.total_wins,totalLosses:g.total_losses},isLoading:!1}:{data:null,isLoading:x}})},[a,r,x,p]);return{results:b,allLoaded:!x&&b.every(h=>!h.isLoading)}},Un={powerScore:{label:"Power Rank",Icon:Qe,dataKey:"powerScore",name:"Power Score",domain:[0,100],isArea:!0,refLine:50,gradientId:"powerGradientDive"},winRate:{label:"Win Rate",Icon:Ce,dataKey:"winRate",name:"Win Rate",domain:[0,100],isArea:!0,refLine:50,gradientId:"winRateGradientDive"},pointDifferential:{label:"Point Differential",Icon:Qs,dataKey:"pointDifferential",name:"Point Differential",domain:["auto","auto"],isArea:!1,refLine:0,gradientId:"ptDiffGradientDive"},pointsWonPercent:{label:"Points Won %",Icon:Ye,dataKey:"pointsWonPercent",name:"Points Won %",domain:[0,100],isArea:!0,refLine:50,gradientId:"ptsWonGradientDive"}},Xn=({fullWidth:a})=>e.jsxs(Je,{className:a?"w-full":"min-w-[280px] w-[280px] flex-shrink-0",children:[e.jsx(ls,{className:"pb-2 pt-3 px-3",children:e.jsx(P,{className:"h-5 w-32"})}),e.jsx(is,{className:"px-3 pb-3",children:e.jsx(P,{className:"h-[140px] w-full"})})]}),qt=({playerName:a,metric:n,data:c,isLoading:o,onPlayerClick:p,fullWidth:d})=>{const r=Un[n],{Icon:x}=r;if(o)return e.jsx(Xn,{fullWidth:d});if(!c||c.tournamentStats.length<2)return null;const b=c.tournamentStats.slice(-5),h=(()=>
2{if(b.length<2)return 0;const l=b[b.length-1],k=b[b.length-2],R=r.dataKey,v=Number(l[R])||0,w=Number(k[R])||0;return v>w?1:v<w?-1:0})(),f=b.map(l=>{let k=l.tournament;return/world\s*championships?/i.test(k)?k="Worlds":/indoor\s*championships?/i.test(k)?k="Indoor":/virginia\s*beach/i.test(k)?k="VA Beach":k=k.replace(/^PPA\s+/i,"").replace(/\s+(Open|Cup|Slam)$/i,""),{...l,dateLabel:k.length>8?k.slice(0,6)+"…":k,fullLabel:l.tournament}}),g=({active:l,payload:k})=>{var D,F;if(!l||!k||!k.length)return null;const R=(D=k[0])==null?void 0:D.payload;if(!R)return null;const v=(F=k[0])==null?void 0:F.value,w=typeof v=="number"?r.name.includes("%")||r.name==="Win Rate"||r.name==="Power Score"||r.name==="Points Won %"?`${v.toFixed(1)}%`:r.name==="Point Diff"?(v>0?"+":"")+v:v:v;return e.jsxs("div",{className:"bg-popover border border-border rounded-lg p-2 text-scalable-xs shadow-lg",children:[e.jsx("p",{className:"font-semibold text-foreground",children:R.fullLabel}),e.jsxs("p",{className:"text-primary",children:[r.name,": ",w]})]})},j=l=>{const{x:k,y:R,payload:v,index:w}=l,D=w===0,F=w===f.length-1,U=D?"start":F?"end":"middle",K=D?2:F?-2:0;return e.jsx("g",{transform:`translate(${k},${R})`,children:e.jsx("text",{dx:K,dy:12,textAnchor:U,fill:"hsl(var(--muted-foreground))",fontSize:7,children:v==null?void 0:v.value})})};return e.jsxs(Je,{className:`stat-card-sheen ${d?"w-full":"min-w-[280px] w-[280px] flex-shrink-0"}`,children:[e.jsxs(ls,{className:"pb-2 pt-3 px-3",children:[e.jsxs(Ns,{className:"text-scalable-xs flex items-center gap-2",children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),p==null||p()},className:"flex items-center gap-2 min-w-0 flex-1 hover:opacity-80 transition-opacity focus:outline-none",style:{WebkitTapHighlightColor:"transparent"},children:[e.jsx(O,{name:a,className:"h-7 w-7 flex-shrink-0"}),e.jsx("span",{className:"truncate font-score text-lg font-normal",children:a}),h!==0&&(h>0?e.jsx(Z,{className:"h-3.5 w-3.5 flex-shrink-0 text-primary"}):e.jsx(ys,{className:"h-3.5 w-3.5 flex-shrink-0 text-destructive"}))]}),e.jsx("button",{onClick:l=>{l.stopPropagation(),p==null||p()},className:"hover:opacity-80 transition-opacity focus:outline-none",style:{WebkitTapHighlightColor:"transparent"},children:e.jsx(x,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[r.label," Over Time"]})]}),e.jsx(is,{className:"px-3 pb-3 overflow-visible",children:e.jsx(ca,{width:"100%",height:120,children:r.isArea?e.jsxs(js,{data:f,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:r.gradientId,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.5}),e.jsx(Ve,{dataKey:"dateLabel",tick:j,stroke:"hsl(var(--border))",interval:0,tickLine:!1,axisLine:!1,height:22,tickMargin:6}),e.jsx(qe,{domain:r.domain,allowDataOverflow:!0,tick:{fill:"hsl(var(--muted-foreground))",fontSize:11,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:30,tickLine:!1,axisLine:!1,ticks:r.domain[1]===100?[25,50,75,100]:void 0,interval:0,tickFormatter:l=>l===0?"":String(l)}),e.jsx(Ue,{content:e.jsx(g,{})}),r.refLine!==null&&e.jsx(Xe,{y:r.refLine,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.4}),e.jsx(bs,{type:"monotone",dataKey:r.dataKey,name:r.name,stroke:"hsl(var(--primary))",strokeWidth:2,fill:`url(#${r.gradientId})`,isAnimationActive:!1})]}):e.jsxs(da,{data:f,children:[e.jsx(He,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.5}),e.jsx(Ve,{dataKey:"dateLabel",tick:j,stroke:"hsl(var(--border))",interval:0,tickLine:!1,axisLine:!1,height:22,tickMargin:6}),e.jsx(qe,{domain:r.domain,allowDataOverflow:!0,tick:{fill:"hsl(var(--muted-foreground))",fontSize:11,fontFamily:"'Tanker', 'Khand', sans-serif"},stroke:"hsl(var(--border))",width:35,tickLine:!1,axisLine:!1,ticks:r.domain[1]===100?[25,50,75,100]:void 0,interval:0,tickFormatter:l=>l===0?"":String(l)}
2),e.jsx(Ue,{content:e.jsx(g,{})}),r.refLine!==null&&e.jsx(Xe,{y:r.refLine,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3",opacity:.4}),e.jsx(ma,{type:"monotone",dataKey:r.dataKey,name:r.name,stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1,isAnimationActive:!1})]})})})]})},Ut=({topPlayers:a,onPlayerClick:n})=>{const{isAuthTransitioning:c}=xa(),[o,p]=i.useState([]),d=i.useMemo(()=>a.map(S=>S.name).join("|"),[a]),r=i.useMemo(()=>a.map(S=>S.name),[d]);i.useEffect(()=>{if(r.length===0){p([]);return}let S=!1;const z=()=>{if(S)return;const Y=["powerScore","winRate","pointDifferential","pointsWonPercent"],B=[],je=new Set,W=[...r];for(let A=W.length-1;A>0;A--){const H=Math.floor(Math.random()*(A+1));[W[A],W[H]]=[W[H],W[A]]}const Ie=Math.min(8,W.length*Y.length);let de=0,Ne=0,M=0;for(;B.length<Ie&&M<W.length*Y.length;){const A=W[Ne%W.length],H=Y[de%Y.length],$=`${A}-${H}`;je.has($)||(je.add($),B.push({playerName:A,metric:H})),Ne++,de++,M++}i.startTransition(()=>p(B))};if(typeof window<"u"&&"requestIdleCallback"in window){const Y=window.requestIdleCallback(z,{timeout:800});return()=>{var B;S=!0,(B=window.cancelIdleCallback)==null||B.call(window,Y)}}const E=setTimeout(z,0);return()=>{S=!0,clearTimeout(E)}},[r]);const[x,b]=i.useState(!1),[h,f]=i.useState("all"),[g,j]=i.useState(""),[l,k]=i.useState(null),{allPlayers:R,loading:v}=Us({defer:!x,listenToGlobalTrigger:!1}),w=R.length,D=i.useMemo(()=>new vs(R,{threshold:.3,minMatchCharLength:2}),[w>0?Math.floor(w/10):0]),F=i.useMemo(()=>!g||g.length<2?[]:D.search(ra(g)).slice(0,8).map(S=>({name:S.item})),[D,g]),U=i.useMemo(()=>o.slice(0,8),[o]),K=i.useMemo(()=>Array.from(new Set(U.map(S=>S.playerName))),[U]),{results:J}=Vt(K,3),fe=i.useMemo(()=>{const S=new Map;return K.forEach((z,E)=>S.set(z,J[E])),S},[K,J]),ce=i.useMemo(()=>{const S=["powerScore","winRate","pointDifferential","pointsWonPercent"];return l?S.map(z=>({playerName:l,metric:z})):o.filter(z=>h==="all"||z.metric===h)},[l,o,h]),ee=i.useMemo(()=>!x||l?[]:Array.from(new Set(ce.map(S=>S.playerName))),[x,l,ce]),{results:he}=Vt(ee,6),Re=i.useMemo(()=>{const S=new Map;return ee.forEach((z,E)=>S.set(z,he[E])),S},[ee,he]),L=S=>{k(S),j(S)},ge=()=>{j(""),k(null)};return c?e.jsxs("section",{className:"space-y-3 w-full max-w-full min-w-0",children:[e.jsx("div",{className:"flex items-center justify-between px-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-scalable-sm font-semibold",children:"Player Trends"})]})}),e.jsxs("div",{className:"flex gap-3 overflow-hidden pb-2",children:[e.jsx(P,{className:"min-w-[280px] h-[180px] rounded-lg"}),e.jsx(P,{className:"min-w-[280px] h-[180px] rounded-lg"})]})]}):a.length===0||o.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-3 w-full max-w-full min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-scalable-sm font-semibold",children:"Player Trends"})]}),e.jsxs("button",{className:"text-[10px] text-primary hover:underline flex items-center gap-0.5",onClick:()=>b(!0),children:["More ",e.jsx(Ke,{className:"h-3 w-3"})]})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto snap-x snap-mandatory pb-2 scrollbar-hide w-full max-w-full",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:U.map((S,z)=>{const E=fe.get(S.playerName);return e.jsx(qt,{playerName:S.playerName,metric:S.metric,data:E==null?void 0:E.data,isLoading:(E==null?void 0:E.isLoading)??!0,onPlayerClick:()=>n==null?void 0:n(S.playerName)},`${S.playerName}-${S.metric}-${z}`)})})]}),e.jsxs(Xs,{open:x,onOpenChange:S=>{b(S),S||ge()},title:"Player Trends",desktopClassName:"sm:max-w-md h-[85vh] flex flex-col",mobileClassName:"h-[82dvh] flex flex-col",children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 border-b border-border/50 space-y-3",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[e.jsx(Z,{className:"h-4 w-4 text-primary"}),"Player Trends"]}),e.jsxs("div",{className:"relative pt-2",children:[e.jsx(Ys,{className:"absolute left-2.5 top-1/2 mt-1 -translate-y-1/2 h-3 w-3 text-muted-foreground z-10"}),e.jsx(Js,{placeholder:"Search any player or team...",value:g,onChange:S=>{j(S.target.value),l&&k(null)},onFocus:()=>ws(),className:"pl-7 pr-7 h-7 text-scalable-xs placeholder:italic",autoFocus:!1}),g&&e.jsx("button",{onClick:ge,className:"absolute right-2.5 top-1/2 mt-1 -translate-y-1/2 text-muted-foreground hover:text-foreground z-10",children:e.jsx(cs,{className:"h-3 w-3"})}),g.length>=2&&!l&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden max-h-[200px] overflow-y-auto",children:v?e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx(P,{className:"h-8 w-full"}),e.jsx(P,{className:"h-8 w-full"})]}):F.length>0?F.map(S=>e.jsxs("button",{onClick:()=>L(S.name),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-muted/50 text-left text-sm",children:[e.jsx(O,{name:S.name,className:"h-6 w-6"}),e.jsx("span",{children:S.name})]},S.name)):e.jsx("div",{className:"px-3 py-2 text-scalable-xs text-muted-foreground",children:"No players found"})})]}),!l&&e.jsxs("div",{className:"flex gap-1 justify-center w-full",children:[e.jsx(We,{variant:h==="all"?"default":"secondary",size:"sm",className:"h-6 text-[10px] px-1.5",onClick:()=>f("all"),children:"All"}),e.jsxs(We,{variant:h==="powerScore"?"default":"secondary",size:"sm",className:"h-6 text-[10px] px-1.5 gap-0.5",onClick:()=>f("powerScore"),children:[e.jsx(Qe,{className:"h-1.5 w-1.5"}),"Power"]}),e.jsxs(We,{variant:h==="winRate"?"default":"secondary",size:"sm",className:"h-6 text-[10px] px-1.5 gap-0.5",onClick:()=>f("winRate"),children:[e.jsx(Z,{className:"h-1.5 w-1.5"}),"Win %"]}),e.jsxs(We,{variant:h==="pointDifferential"?"default":"secondary",size:"sm",className:"h-6 text-[10px] px-1.5 gap-0.5",onClick:()=>f("pointDifferential"),children:[e.jsx(Qs,{className:"h-1.5 w-1.5"}),"Pt Diff"]}),e.jsxs(We,{variant:h==="pointsWonPercent"?"default":"secondary",size:"sm",className:"h-6 text-[10px] px-1.5 gap-0.5",onClick:()=>f("pointsWonPercent"),children:[e.jsx(Ye,{className:"h-1.5 w-1.5"}),"Pts Won"]})]}),l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-scalable-xs text-muted-foreground",children:"Showing trends for:"}),e.jsxs(la,{variant:"secondary",className:"gap-1",children:[e.jsx(O,{name:l,className:"h-4 w-4"}),l,e.jsx("button",{onClick:ge,className:"ml-1 hover:text-foreground",children:e.jsx(cs,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:l?e.jsx(qn,{playerName:l,onPlayerClick:()=>{b(!1),n==null||n(l)}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:ce.map((S,z)=>{const E=Re.get(S.playerName);return e.jsx(qt,{playerName:S.playerName,metric:S.metric,data:E==null?void 0:E.data,isLoading:(E==null?void 0:E.isLoading)??!0,fullWidth:!0,onPlayerClick:()=>{b(!1),n==null||n(S.playerName)}},`modal-${S.playerName}-${S.metric}-${z}`)})}),ce.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Z,{className:"h-10 w-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No trends available for this filter"})]})]})})]})]})},Xt=({children:a})=>{const[n,c]=i.useState(!1),[o,p]=i.useState(!1),d=i.useRef(null),r=i.useRef(!1);return i.useEffect(()=>{const x=d.current;if(!x||r.current)return;const b=()=>
2{r.current||(r.current=!0,c(!0),window.dispatchEvent(new Event("pblfg:pause-watchdog")),setTimeout(()=>{p(!0)},200))},h=new IntersectionObserver(([j])=>{j.isIntersecting&&(b(),h.disconnect())},{rootMargin:"200px"});h.observe(x);let f=0;const g=setInterval(()=>{if(f++,r.current||f>30){clearInterval(g);return}if(x.offsetHeight>0){const j=x.getBoundingClientRect(),l=window.innerHeight||document.documentElement.clientHeight;j.top<l+200&&(b(),h.disconnect(),clearInterval(g))}},500);return()=>{h.disconnect(),clearInterval(g)}},[]),i.useEffect(()=>{if(o){const x=setTimeout(()=>{window.dispatchEvent(new Event("pblfg:resume-watchdog"))},1e3);return()=>clearTimeout(x)}},[o]),o?e.jsx("div",{ref:d,children:a}):e.jsxs("div",{ref:d,className:"space-y-3 w-full max-w-full min-w-0",children:[e.jsx("div",{className:"flex items-center justify-between px-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-scalable-sm font-semibold",children:"Player Trends"})]})}),e.jsxs("div",{className:"flex gap-3 overflow-hidden pb-2",children:[e.jsx(P,{className:"min-w-[280px] h-[180px] rounded-lg shrink-0"}),e.jsx(P,{className:"min-w-[280px] h-[180px] rounded-lg shrink-0"})]})]})},Fs=1e3,ze=1e3,Jn=80,Yn=20,Qn=80,Zn=35,er=8,Te=a=>a.trim().toLowerCase(),Jt=a=>+(a.ppa_rank_ppr!=null)+ +(a.ppa_rank_doubles!=null)+ +(a.ppa_rank_mixed!=null)+ +(a.ppa_rank_singles!=null),Yt=a=>{const n=new Map;for(const c of a){const o=`${Te(c.player_name)}|${c.snapshot_date}`,p=n.get(o);(!p||Jt(c)>Jt(p))&&n.set(o,c)}return Array.from(n.values())},sr=(a,n)=>{switch(n){case"doubles":return a.ppa_rank_doubles;case"mixed":return a.ppa_rank_mixed;case"singles":return a.ppa_rank_singles;case"ppr":default:return a.ppa_rank_ppr}},tr=async a=>{const n=new Set,c=[];for(let o=0;o<Jn&&c.length<a;o+=1){const p=o*Fs,d=p+Fs-1,{data:r,error:x}=await xe.from("player_rank_history").select("snapshot_date").order("snapshot_date",{ascending:!1}).range(p,d);if(x)throw x;if(!(r!=null&&r.length))break;for(const b of r){const h=b.snapshot_date;if(!n.has(h)&&(n.add(h),c.push(h),c.length>=a))break}if(r.length<Fs)break}return c},ar=async(a,n)=>{if(!a.length||!n.length)return[];const c=[];for(let f=0;f<Yn;f+=1){const g=f*ze,j=g+ze-1,{data:l,error:k}=await xe.from("player_rank_history").select("snapshot_date, player_name, ppa_rank_ppr, ppa_rank_doubles, ppa_rank_mixed, ppa_rank_singles").in("snapshot_date",n).in("player_name",a).order("snapshot_date",{ascending:!1}).order("player_name",{ascending:!0}).range(g,j);if(k)throw k;if(!(l!=null&&l.length)||(c.push(...l),l.length<ze))break}const o=new Set(a.map(Te)),p=new Map;for(const f of c){const g=Te(f.player_name),j=p.get(g)??new Set;j.add(f.snapshot_date),p.set(g,j)}const d=Math.min(n.length,er),r=Array.from(o).filter(f=>{var g;return(((g=p.get(f))==null?void 0:g.size)??0)<d});if(r.length===0)return Yt(c);const x=new Set(r),b=[],h=new Map;for(let f=0;f<Qn;f+=1){const g=f*ze,j=g+ze-1,{data:l,error:k}=await xe.from("player_rank_history").select("snapshot_date, player_name, ppa_rank_ppr, ppa_rank_doubles, ppa_rank_mixed, ppa_rank_singles").in("snapshot_date",n).order("snapshot_date",{ascending:!1}).order("player_name",{ascending:!0}).range(g,j);if(k)throw k;if(!(l!=null&&l.length))break;const R=l.filter(w=>x.has(Te(w.player_name)));b.push(...R);for(const w of R){const D=Te(w.player_name),F=h.get(D)??new Set;F.add(w.snapshot_date),h.set(D,F)}if(r.every(w=>{var D;return(((D=h.get(w))==null?void 0:D.size)??0)>=d})||l.length<ze)break}return Yt([...c,...b])},nr=a=>{const{enabled:n=!0,playerNames:c=[],maxLookbackDates:o=Zn}=a||{},p=i.useMemo(()=>Array.from(new Set(c.map(Te))).sort().join("|"),[c]),d=i.useMemo(()=>Array.from(new Set(c.map(f=>f.trim()).filter(Boolean))).sort((f,g)=>f.localeCompare(g)),[p]),{data:r=[]}=os({queryKey:["ppa-rank-history-dates-v4",o],queryFn:()=>tr(o),enabled:n,staleTime:5*60*1e3,gcTime:30*60*1e3}),{data:x=[]}=os({queryKey:["ppa-rank-history-data-v4",r.join("|"),p],queryFn:async()=>!r.length||!d.length?[]:ar(d,r),enabled:n&&r.length>0&&d.length>0,staleTime:5*60*1e3,gcTime:30*60*1e3}),b=i.useMemo(()=>{const f=new Map;if(!x.length)return f;for(const g of x){const j=Te(g.player_name),l=f.get(j);l?l.push(g):f.set(j,[g])}for(const g of f.values())g.sort((j,l)=>l.snapshot_date.localeCompare(j.snapshot_date));return f},[x]);return{previousRankMap:b,getRankChange:(f,g,j)=>{if(!j)return;const l=b.get(Te(f));if(l!=null&&l.length)for(const k of l){const R=sr(k,g);
2if(R&&R!==j)return R-j}}}},Qt=[{suffix:"players",label:"All Players"},{suffix:"players:men",label:"Men"},{suffix:"players:women",label:"Women"},{suffix:"dbs:men",label:"Men's DBs"},{suffix:"dbs:women",label:"Women's DBs"}],Zt=[{suffix:"players",label:"All Players"}],zs=[{suffix:"duos",label:"All Duos"},{suffix:"duos:men",label:"Men"},{suffix:"duos:women",label:"Women"},{suffix:"duos:mixed",label:"Mixed"}];function ea({value:a,onChange:n,label:c,allow2026Players:o,allow2026Duos:p}){const[d,r]=i.useState(!1),[x,b]=a.split(":"),h=x==="2026"?"2026":"2025",f=b==="duos"?"duos":"players",g=f==="duos"?p:o,j=h==="2026"&&!g?"2025":h,l=f==="duos"?zs:j==="2026"?Qt:Zt,k=w=>{n(`${j==="2026"&&(w==="duos"?p:o)?"2026":"2025"}:${w==="duos"?"duos":"players"}`)},R=w=>{if(w==="2026"&&!g)return;const D=a.split(":").slice(1).join(":")||(f==="duos"?"duos":"players"),F=(w==="2026"?f==="duos"?zs:Qt:f==="duos"?zs:Zt).some(U=>U.suffix===D);n(`${w}:${F?D:f==="duos"?"duos":"players"}`)},v=(w,D)=>T("flex-1 rounded px-2 py-1 text-[11px] font-medium transition-colors",w?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground",D);return e.jsxs(ae,{value:a,onValueChange:n,children:[e.jsx(ne,{className:"h-5 w-auto text-[10px] border-0 bg-muted/40 focu
2s:ring-0 focus:ring-offset-0 focus:outline-none px-2 gap-1",children:e.jsx("span",{children:c})}),e.jsxs(re,{align:"end",className:"min-w-[190px]",children:[e.jsxs("div",{className:"p-1 space-y-1",children:[e.jsxs("div",{className:"flex gap-1 rounded bg-muted/40 p-0.5",children:[e.jsx("button",{type:"button",className:v(f==="players"),onClick:()=>k("players"),children:"Players"}),e.jsx("button",{type:"button",className:v(f==="duos"),onClick:()=>k("duos"),children:"Duos"})]}),e.jsxs("div",{className:"rounded bg-muted/25",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between rounded px-2 py-1 text-[11px] font-medium text-foreground",onClick:()=>r(w=>!w),children:[e.jsxs("span",{children:[j," Season"]}),e.jsx(bn,{className:T("h-3 w-3 opacity-60 transition-transform",d&&"rotate-180")})]}),d&&e.jsx("div",{className:"px-0.5 pb-0.5",children:["2026","2025"].map(w=>e.jsxs("button",{type:"button",disabled:w==="2026"&&!g,className:T("flex w-full items-center justify-between rounded px-2 py-1 text-[11px]",j===w?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground",w==="2026"&&!g&&"opacity-40 pointer-events-none"),onClick:()=>{R(w),r(!1)},children:[e.jsx("span",{children:w}),j===w&&e.jsx(wn,{className:"h-3 w-3"})]},w))})]})]}),l.map(w=>e.jsx(y,{value:`${j}:${w.suffix}`,children:w.label},w.suffix))]})]})}function sa(a,n,c=18){const o=(a||"").trim(),p=(n||"").trim();if(o.length+p.length<=c)return[o,p];const d=c-1,r=(h,f)=>h.length>f?h.slice(0,Math.max(1,f-1))+"…":h,x=Math.floor(d/2),b=d-x;return o.length>=p.length?[r(o,b),r(p,x)]:[r(o,x),r(p,b)]}function rr({className:a,...n}){const{strokeWidth:c,...o}=n;return e.jsx("span",{className:T("inline-flex items-center justify-center",a),...o,children:e.jsx(ia,{className:"h-full w-[1.6em] shrink-0"})})}function lr({className:a,...n}){const{strokeWidth:c,...o}=n;return e.jsx("span",{className:T("inline-flex items-center justify-center",a),...o,children:e.jsx(ia,{className:"h-full w-[1.6em] shrink-0"})})}const ir=({className:a,style:n,"data-active":c})=>{const o=!!c;return e.jsx("span",{role:"img","aria-label":"PPA Tour",className:T(a,"block shrink-0 origin-center transition-all",o?"bg-primary scale-[1.26] -translate-y-[1px]":"bg-muted-foreground scale-[1.26] -translate-y-[1px]"),style:{WebkitMaskImage:`url(${Wt})`,maskImage:`url(${Wt})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center",WebkitMaskSize:"contain",maskSize:"contain",...n}})},Be=({value:a,onChange:n,compact:c=!1})=>e.jsxs(ae,{value:String(a),onValueChange:o=>n(parseInt(o,10)),children:[e.jsxs(ne,{className:T("border-0 bg-muted/40 focu
2s:ring-0 focus:ring-offset-0 focus:outline-none",c?"h-5 min-w-[42px] text-[9px] px-1.5":"h-5 min-w-[50px] text-[10px] px-1.5"),children:[e.jsx(vn,{className:T(c?"h-2 w-2 mr-0.5":"h-2.5 w-2.5 mr-1")}),e.jsx("span",{children:a===0?"All":a===365?"1yr":`${a}d`})]}),e.jsxs(re,{children:[e.jsx(y,{value:"30",children:"30d"}),e.jsx(y,{value:"90",children:"90d"}),e.jsx(y,{value:"180",children:"180d"}),e.jsx(y,{value:"365",children:"1yr"}),e.jsx(y,{value:"0",children:"All"})]})]});i.lazy(()=>qs(()=>import("./index-CuraQpvj.js").then(a=>a.ek),__vite__mapDeps([2,3,1,4,5,6,7,8,9])).then(a=>({default:a.LazyPlayerPerformanceChart})));const or={all:null,"mens-doubles":"md","womens-doubles":"wd","mixed-doubles":"mxd","mens-singles":"ms","womens-singles":"ws"},gs={all:"All","mens-doubles":"MD","womens-doubles":"WD","mixed-doubles":"MXD","mens-singles":"MS","womens-singles":"WS"},Bs=[{mode:"mlpTeams",label:"Teams",shortLabel:"Teams",icon:rr,description:"MLP team standings"},{mode:"mlpPlayers",label:"Players",shortLabel:"Players",icon:lr,description:"MLP player leaderboard"},{mode:"ppaRank",label:"Tour",shortLabel:"Tour",icon:ir,description:"Official PPA rankings"},{mode:"overall",label:"Power",shortLabel:"Power",icon:Qe,description:"Combined performance score"},{mode:"rising",label:"Rising",shortLabel:"Rising",icon:Gs,description:"Breakout players on the rise"},{mode:"winRate",label:"Win %",shortLabel:"Win %",icon:Ce,description:"Match win percentage"},{mode:"clutch",label:"Clutch",shortLabel:"Clutch",icon:Ks,description:"Best in pressure situations"}],$e=a=>Math.round(a*10)/10%1===0?`${Math.round(a)}%`:`${a.toFixed(1)}%`,ta=(a,n)=>{switch(n){case"winRate":return $e(a.winRate);case"pointDifferential":return a.pointDifferential>0?`+${a.pointDifferential}`:`${a.pointDifferential}`;case"ppaRank":return`#${a.ppaRankPpr||"—"}`;case"mlpTeams":return`#${a.standing||"—"}`;case"clutch":return $e(a.clutchIndex||0);case"overall":default:const c=Math.min(100,Math.max(0,(a.pointDifferential+200)/400*100)),o=a.winRate*.5+c*.5;return $e(o)}},kr=()=>{const a=Aa(),n=Sa(),c=Pa(),o=n.pathname==="/stats",p=Wa(o),{isLightTheme:d,isPureVoid:r,theme:x}=na(),{user:b}=$a(),h=Ia().isNativeIOS,f=Ea().isNativeAndroid,g=Oa(),j=i.useRef(null),l=i.useRef(null),k=Fa(),R=i.useCallback(()=>{k()},[k]),{hasTallTicker:v,showTopPerformersInHeader:w,tickerHeight:D}=za(),[F]=i.useState(null),U=i.useCallback(()=>{},[]),[K,J]=i.useState(""),{allPlayers:fe,loading:ce}=Us(),ee=Rn(Bs.map(t=>t.mode)),he=Dn(Bs.map(t=>t.mode)),Re=i.useRef(!1),[L,ge]=i.useState(()=>he??ee[0]??"mlpTeams"),S=t=>{Re.current=!0,ge(t)};i.useEffect(()=>{if(Re.current)return;const t=he??ee[0];t&&t!==L&&ge(t)},[he,ee,L]);const z=i.useMemo(()=>{const t=new Map(Bs.map(s=>[s.mode,s]));return ee.map(s=>t.get(s)).filter(Boolean)},[ee]),E=Ba(),Y=Ga(),[B,je]=i.useState("all"),[W,Ie]=i.useState("overall-mens"),[de,Ne]=i.useState("all"),[M,A]=i.useState(30),[H,$]=i.useState(30),q=L==="clutch"||L==="ppaRank"||L==="mlpTeams"||L==="mlpPlayers"||L==="mlpDuos"||L==="rising"?"overall":L,{topPlayers:ds,loading:Zs}=Is(100,void 0,q,B,M,{enabled:o&&!["mlpTeams","mlpPlayers","mlpDuos","ppaRank","clutch","rising"].includes(L)}),{data:pe}=Ka({enabled:o}),[Ze,ye]=i.useState("2025:premier"),ks=i.useRef(!1),[le,ms,_e]=Ze.split(":"),be=ms==="players",Q=ms==="duos",me=ms==="dbs",et=_e==="women"?"women":"men",es=ms==="challenger"?"challenger":"premier",Ss=be&&(_e==="men"||_e==="women")?_e:"all",ke=Q&&(_e==="men"||_e==="women"||_e==="mixed")?_e:"all",De=le,Ps=es,ss=me?et==="women"?`${le} Women's DBs`:`${le} Men's DBs`:Q?ke==="men"?`${De} Men Duos`:ke==="women"?`${De} Women Duos`:ke==="mixed"?`${De} Mixed Duos`:`${De} All Duos`:De==="2026"?be?Ss==="men"?"2026 Men":Ss==="women"?"2026 Women":"2026 Players":"2026 Teams":be?`${De} Players`:`${De} ${Ps==="challenger"?"Challenger":"Premier"}`,{teamStandings:st,configured:us,isLoading:tt}=Mt({enabled:o&&!be,seasonOverride:le,levelOverride:es}),ha=es==="premier"?"challenger":"premier",{teamStandings:at}=Mt({enabled:o&&K.length>=2,seasonOverride:le,levelOverride:ha}),{players:se,isLoading:nt}=hn(le,{enabled:o&&be,gender:Ss}),{rows:xs,isLoading:rt}=Ha(le,et,{enabled:o&&me}),{data:lt,isLoading:it}=pn({period:le,context:"mlp",sort:"win_rate",minGames:5,limit:100,gender:ke,enabled:o&&L==="mlpPlayers"&&Q}),Ee=i.useMemo(()=>{const t=(lt||[]).filter(u=>u.context==="mlp_premier"||u.context==="mlp_challenger");if(ke==="all")return t.slice(0,50);if(ke==="mixed")return t.filter(u=>{const N=(u.player_a_gender||"").toLowerCase(),m=(u.player_b_gender||"").toLowerCase();return N==="m"&&m==="f"||N==="f"&&m==="m"}).slice(0,50);const s=ke==="men"?"m":"f";return t.filter(u=>{const N=(u.player_a_gender||"").toLowerCase(),m=(u.player_b_gender||"").toLowerCase();return N===s&&m===s}).slice(0,50)},[lt,ke]),{resolveTeam:Se,resolveTeamByUuid:ot}=Va();i.useEffect(()=>{if(ks.current)return;if(E){ye("2026:teams"),ks.current=!0;return}if(!(pe!=null&&pe.active_season))return;
2const t=pe.active_level==="challenger"?"challenger":"premier";ye(`2025:${t}`),ks.current=!0},[pe==null?void 0:pe.active_season,pe==null?void 0:pe.active_level,E]),i.useEffect(()=>{L==="mlpTeams"&&(be||Q||me)?ye(E?"2026:teams":`2025:${es==="challenger"?"challenger":"premier"}`):L==="mlpPlayers"&&!be&&!me&&!Q&&ye(Y?"2026:players":"2025:players")},[L,be,Q,me,E,Y,es]);const X=i.useMemo(()=>{const t=[...st||[]];return t.sort((s,u)=>{const N=(s.matchups_won||0)+(s.matchups_lost||0),m=(u.matchups_won||0)+(u.matchups_lost||0),C=N===0?1:0,_=m===0?1:0;return C!==_?C-_:(s.standing||9999)-(u.standing||9999)}),t},[st]),{eventsByTeam:ct}=_n(le,o&&!be),[dt,te]=i.useState(null),mt=i.useMemo(()=>`${le||"unknown"}:${Ps}`,[le,Ps]),{getRankChange:ut}=Pn(mt,X),{getRankChange:xt}=Tn(mt,se),hs=le!=="2025",pa=W,{players:Pe,isLoading:ht}=qa(pa,{enabled:o&&L==="ppaRank"}),{getRankChange:pt}=nr({enabled:o&&L==="ppaRank"&&Pe.length>0,playerNames:Pe.map(t=>t.playerName)}),{topPlayers:ts,loading:ft}=Is(60,void 0,"overall",de,H,{enabled:o&&p}),[Me,as]=i.useState(90),[we,gt]=i.useState("all"),{stars:Ms,isLoading:jt}=oa(60,o&&p),ps=i.useMemo(()=>we==="all"?Ms:Ms.filter(t=>t.gender===(we==="men"?"M":"F")),[Ms,we]),{topPlayers:bt}=Is(50,void 0,"overall","all",Me,{enabled:o&&p}),Cs=i.useMemo(()=>bt.map(t=>t.playerName).sort().join(","),[bt]),fa=i.useMemo(()=>{if(Cs)return new Set(Cs.split(","))},[Cs]),{topClutchPlayers:ve,loading:Oe}=Ua(100,Me,fa,{enabled:o&&p,eventFilter:or[B]}),wt=i.useRef(!1);i.useEffect(()=>{wt.current||!o||!p||Oe||ve.length>0||Me>=90||(wt.current=!0,as(90))},[o,p,Oe,ve.length,Me]);const[G,Fe]=i.useState(()=>{var N;const t=(N=n.state)==null?void 0:N.viewPlayer;if(t)return t;const u=window.location.hash.match(/push-player=([^&]+)/);if(u){const m=decodeURIComponent(u[1]);return setTimeout(()=>history.replaceState(null,"",window.location.pathname+window.location.search),0),m}return null}),{stats:ga,loading:ja}=Xa(G?[G]:[]),vt=i.useMemo(()=>{if(!G)return;const t=Se([G]),s=Ja(t==null?void 0:t.team_title,t==null?void 0:t.team_title);return Ya(s==null?void 0:s.leftHsl)},[G,Se]);i.useEffect(()=>{var m;const t=(m=n.state)==null?void 0:m.viewPlayer;t&&t!==G&&i.startTransition(()=>{Fe(t)});const s=window.location.hash,u=s.match(/push-player=([^&]+)/);if(u){const C=decodeURIComponent(u[1]);history.replaceState(null,"",window.location.pathname+window.location.search),i.startTransition(()=>{Fe(C)})}const N=s.match(/push-team=([^&]+)/);if(N){const C=decodeURIComponent(N[1]).trim();history.replaceState(null,"",window.location.pathname+window.location.search),C&&window.dispatchEvent(new CustomEvent("mlp-open-team",{detail:{team_title:C}}))}},[n.state,n.hash]),i.useLayoutEffect(()=>{G&&l.current&&(l.current.scrollTop=0)},[G]);const ba=i.useCallback(async()=>{G&&await Qa(G)},[G]),[wa,Nt]=i.useState(null),[va,yt]=i.useState(!1),[Na,Ts]=i.useState(!1),{followedPlayers:Rs,isLoading:ya}=Za(b==null?void 0:b.id),{followedTeams:Ds,isLoading:_a}=en(),_t=Rs.length+Ds.length>0,kt=!!b&&(ya||_a),{historyProgress:cr,isBackgroundLoading:dr,fullHistoryMatches:ns}=sn();i.useMemo(()=>{const t=new Map;if(!(ns!=null&&ns.length))return t;for(const s of ns){if(s.status!=="completed"||s.is_qualifier)continue;const u=tn(s);if(!u.isUpset||!u.winnerTeam)continue;const N=u.winnerTeam===1?s.team1:s.team2;for(const m of N)t.set(m,(t.get(m)||0)+1)}return t},[ns]);const St=fe.length,Pt=i.useMemo(()=>new vs(fe,{threshold:.3,minMatchCharLength:2}),[St>0?Math.floor(St/10):0]),Ls=i.useMemo(()=>!K||K.length<2?[]:Pt.search(ra(K)).slice(0,8).map(t=>t.item),[Pt,K]),As=i.useMemo(()=>{if(!K||K.length<2)return[];const t=K.toLowerCase(),s=[...X,...at||[]],u=new Set;return s.filter(m=>{const C=m.team_uuid||(m.team_title||"").toLowerCase();return u.has(C)?!1:(u.add(C),!0)}).filter(m=>(m.team_title||"").toLowerCase().includes(t)||(m.team_abbreviation||"").toLowerCase().includes(t)||(m.team_slug||"").toLowerCase().includes(t)).slice(0,6)},[K,X,at]);i.useLayoutEffect(()=>{n.pathname==="/stats"&&window.dispatchEvent(new CustomEvent("pblfg-ui-ready"))},[n.pathname]);const I=t=>{i.startTransition(()=>{Fe(t)})},ka=t=>{Nt(t),yt(!0)};return e.jsxs("div",{className:T("min-h-screen bg-gradient-match-card overflow-x-hidden",a&&h&&b&&"pb-20",a&&h&&!b&&"pb-12",a&&!h&&b&&"pb-20",a&&!h&&!b&&"pb-12"),children:[!a&&e.jsx(an,{onRefresh:U,lastRefreshTime:F,onAuthClick:R}),a&&e.jsx(nn,{onAuthClick:R}),a&&h&&e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[997] pointer-events-none bg-gradient-header",style:{height:"env(safe-area-inset-top)"}}),a&&(h||f)&&e.jsx("div",{className:T("fixed top-0 left-0 right-0 z-[35] pointer-events-none bg-gradient-header will-change-transform transition-transform [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]",g?"translate-y-0":h?"-translate-y-[4rem]":"-translate-y-[64px]"),style:{height:h?"calc(4rem + env(safe-area-inset-top))":"88px",transitionDuration:"350ms"}}),a&&e.jsx("div",{style:{height:h?`calc(4rem + env(safe-area-inset-top) + ${D}px - 32px)`:f?`${88+D-16}px`:`${64+D+8}px`}}),e.jsxs("div",{ref:j,className:T("mx-auto px-4 relative",a?"max-w-2xl":"max-w-7xl",a&&"pt-1",a&&h&&"-mt-4"),style:a?void 0:{paddingTop:`${64+D+16}px`},children:[e.jsxs("div",{className:T("mb-4 mt-0 relative",!a&&"max-w-sm mx-auto"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ys,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground
2/50"}),e.jsx(Js,{value:K,onChange:t=>J(t.target.value),onFocus:()=>ws(),placeholder:"Search any player or team...",className:"pl-7 h-8 !text-[11px] md:!text-[11px] bg-muted/15 border-border/30 placeholder:italic placeholder:text-muted-foreground/45 placeholder:!text-[11px] placeholder:font-normal"}),K&&e.jsx(We,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 h-8 w-8",onClick:()=>J(""),children:e.jsx(cs,{className:"h-4 w-4"})})]}),K.length>=2&&e.jsx(Je,{className:"absolute left-0 right-0 top-full mt-2 border-border/50 z-50 shadow-lg",children:e.jsx(fn,{className:"max-h-80",children:ce?e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx(P,{className:"h-12 w-full"}),e.jsx(P,{className:"h-12 w-full"})]}):Ls.length>0||As.length>0?e.jsxs("div",{className:"p-2",children:[As.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 pt-1 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground font-semibold",children:"MLP Teams"}),As.map(t=>e.jsxs("button",{onClick:()=>{te(t),J("")},className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-primary/10 transition-colors text-left",children:[(()=>{const s=oe(t.team_title)||"",u=t.primary_logo_url||s;return e.jsx("div",{className:"h-10 w-10 rounded-full bg-white flex items-center justify-center overflow-hidden shrink-0 border border-border/40",children:u?e.jsx("img",{src:u,alt:t.team_title,className:"h-full w-full object-contain",loading:"lazy",onError:N=>{const m=N.currentTarget;s&&m.src!==s?m.src=s:m.style.display="none"}}):e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground"})})})(),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"text-sm font-semibold truncate",children:t.team_title})}),e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"})]},t.team_uuid)),Ls.length>0&&e.jsx("div",{className:"px-2 pt-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground font-semibold",children:"Players"})]}),Ls.map(t=>e.jsxs("button",{onClick:()=>{I(t),J("")},className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-primary/10 transition-colors text-left",children:[e.jsx(O,{name:t,className:"h-10 w-10"}),e.jsx("span",{className:"text-sm font-semibold truncate",children:_s(t)}),e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},t))]}):e.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"No players or teams found"})})})]}),e.jsx("div",{className:T("mb-1.5",!a&&"flex flex-col items-center"),children:b?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>c("/notifications"),className:"flex items-center gap-2 mb-3 h-6 hover:opacity-80 transition-opacity",children:[e.jsx(Gs,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"font-semibold text-sm",children:"My Players & Teams"}),kt?e.jsx(P,{className:"h-4 w-6 rounded-full"}):_t?e.jsx(la,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] leading-none",children:Rs.length+Ds.length}):null]}),kt?e.jsx("div",{className:"flex gap-2 overflow-x-auto overflow-y-visible pb-2 scrollbar-hide -mx-4 px-4 pr-6",children:Array.from({length:5}).map((t,s)=>e.jsxs("div",{className:"flex flex-col items-center gap-1.5 shrink-0 py-1 h-[96px] min-h-[96px] w-16",children:[e.jsx("div",{className:"relative p-0.5",children:e.jsx(P,{className:"w-14 h-14 rounded-full ring-2 ring-primary/30"})}),e.jsx(P,{className:"w-14 h-4"})]},s))}):_t?e.jsx("div",{className:T("flex gap-2 overflow-x-auto overflow-y-visible pb-1 scrollbar-hide",a?"-mx-4 px-4 pr-6":"max-w-[calc(100vw-4rem)] justify-center",f&&"touch-pan-x"),style:f?{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y"}:void 0,children:[...Ds.map(t=>({kind:"team",sortKey:(t.team_title||"").toLowerCase(),team:t})),...Rs.map(t=>({kind:"player",sortKey:Ge(t).toLowerCase(),name:t}))].sort((t,s)=>t.sortKey.localeCompare(s.sortKey)).map(t=>{if(t.kind==="team"){const u=t.team,N=oe(u.team_title||""),m=u.team_title||"",C=/mad\s*drops/i.test(m),_=/brooklyn/i.test(m),V=/miami/i.test(m),ie=C?"MAD DROPS":_?"BROOKLYN":V?"MIAMI":m?(m.split(" ").pop()||m).toUpperCase():u.team_abbreviation||"TEAM";return e.jsxs("button",{onClick:()=>te({team_uuid:u.team_uuid,team_title:u.team_title||"",team_abbreviation:u.team_abbreviation||void 0}),className:"flex flex-col items-center gap-[7px] shrink-0 group py-1 w-16",children:[e.jsx("div",{className:"relative p-0.5",children:e.jsx("div",{className:"w-14 h-14 roun
2ded-full ring-2 ring-primary/30 group-hover:ring-primary group-hover:scale-105 transition-all duration-200 bg-muted/40 flex items-center justify-center overflow-hidden",children:N?e.jsx("img",{src:N,alt:u.team_title||"",className:"h-full w-full object-contain"}):e.jsx("span",{className:"font-score text-xs text-primary",children:ie})})}),e.jsx("span",{className:"text-[11px] font-player font-[500] text-foreground text-center leading-none line-clamp-1 uppercase tracking-wide",children:ie})]},`team-${u.team_uuid}`)}const s=t.name;return e.jsxs("button",{onClick:()=>I(s),className:"flex flex-col items-center gap-1 shrink-0 group py-1 w-16",children:[e.jsx("div",{className:"relative p-0.5",children:e.jsx(O,{name:s,className:"w-14 h-14 ring-2 ring-primary/30 group-hover:ring-primary group-hover:scale-105 transition-all duration-200"})}),e.jsx("span",{className:"text-[11px] font-player font-[500] text-foreground text-center leading-none line-clamp-1 uppercase tracking-wide",children:s.split(" ").pop()})]},`player-${s}`)})}):e.jsxs(fs,{to:"/notifications",className:T("flex items-center gap-3 p-4 rounded-lg border border-dashed border-primary/30 hover:border-primary/50 hover:bg-primary/5 transition-colors",d?"bg-white":"bg-muted/10"),children:[e.jsx(Gs,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Follow your favorite players & teams"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Follow players via the notifications page"})]}),e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"})]})]}):e.jsx("div",{className:"-mx-4",children:e.jsx(yn,{})})}),a?e.jsxs("div",{className:"flex flex-col gap-6 w-full max-w-full min-w-0",children:[e.jsxs(Je,{className:T("border-border/50 w-full relative overflow-hidden",d?"bg-white":"bg-gradient-match-card"),
2children:[e.jsx(Ct,{slot:"stats_leaderboard",size:140}),e.jsx(ls,{className:"pb-2 pt-3 relative z-10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ns,{className:"text-base flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4 text-primary"}),"Leaderboards"]}),e.jsx("div",{className:"flex items-center gap-1",children:L==="mlpTeams"?e.jsxs(ae,{value:Ze,onValueChange:t=>ye(t),children:[e.jsx(ne,{className:"h-5 w-auto text-[10px] border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 gap-1",children:e.jsx("span",{children:ss})}),e.jsxs(re,{children:[E&&e.jsx(y,{value:"2026:teams",children:"2026 Teams"}),e.jsx(y,{value:"2025:premier",children:"2025 Premier"}),e.jsx(y,{value:"2025:challenger",children:"2025 Challenger"})]})]}):L==="mlpPlayers"?e.jsx(ea,{value:Ze,onChange:t=>ye(t),label:ss,allow2026Players:!!Y,allow2026Duos:!!E}):L==="rising"?e.jsxs(ae,{value:we,onValueChange:t=>gt(t),children:[e.jsx(ne,{className:"h-5 w-auto text-[10px] border-0 bg-muted/40 focu
2s:ring-0 focus:ring-offset-0 focus:outline-none px-2 gap-1 [&>svg]:shrink-0",children:e.jsx("span",{className:"whitespace-nowrap",children:we==="men"?"Men":we==="women"?"Women":"All"})}),e.jsxs(re,{align:"end",children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"men",children:"Men"}),e.jsx(y,{value:"women",children:"Women"})]})]}):L==="ppaRank"?e.jsxs(ae,{value:W,onValueChange:t=>Ie(t),children:[e.jsx(ne,{className:"h-5 w-auto min-w-[40px] text-[10px] border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2",children:e.jsx("span",{children:W==="overall-mens"?"WPR Men's":W==="overall-womens"?"WPR Women's":W==="mens-doubles"?"MD":W==="womens-doubles"?"WD":W==="mens-mixed"?"MXD (M)":W==="womens-mixed"?"MXD (W)":W==="mens-singles"?"MS":"WS"})}),e.jsxs(re,{children:[e.jsx(y,{value:"overall-mens",children:"Overall Men's (WPR)"}),e.jsx(y,{value:"overall-womens",children:"Overall Women's (WPR)"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mens-mixed",children:"Men's Mixed"}),e.jsx(y,{value:"womens-mixed",children:"Women's Mixed"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ae,{value:B,onValueChange:t=>je(t),children:[e.jsx(ne,{className:"h-5 w-auto shrink-0 whitespace-nowrap text-[10px] [&>span]:line-clamp-none [&>span]:!flex [&>
2span]:items-center border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 [&>svg]:shrink-0",children:e.jsxs("span",{className:"flex items-center gap-0.5 whitespace-nowrap",children:[B==="mens-singles"||B==="womens-singles"?e.jsx(It,{className:"h-2.5 w-2.5 opacity-60 shrink-0",style:{clipPath:"inset(0 50% 0 0)"}}):B!=="all"?e.jsx(It,{className:"h-2.5 w-2.5 opacity-60 shrink-0"}):null,gs[B]]})}),e.jsxs(re,{children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mixed-doubles",children:"Mixed Doubles"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}),e.jsx(Be,{value:L==="clutch"?Me:M,onChange:t=>{L==="clutch"?as(t):A(t)}})]})})]})}),e.jsxs(is,{className:"pt-0 pb-4",children:[e.jsxs(Tt,{value:L,onValueChange:t=>S(t),children:[e.jsx(Rt,{className:"!grid !w-full mb-2 h-auto grid-cols-7 gap-0.5 min-w-0 p-1",children:z.map(({mode:t,shortLabel:s,icon:u})=>e.jsxs(Dt,{value:t,className:"w-full flex flex-col items-center justify-center gap-0.5 !px-0.5 py-1.5 min-w-0",children:[e.jsx(u,{className:T("shrink-0",t==="mlpTeams"||t==="mlpPlayers"?"!h-4 !w-10":t==="ppaRank"?"!h-4 !w-5":t==="winRate"?"!h-4 !w-4 scale-95":"!h-4 !w-4"),strokeWidth:2.5,"data-active":L===t}),e.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:s})]},t))}),z.map(({mode:t})=>e.jsx(Lt,{value:t,className:"mt-0",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-8 z-10 bg-transparent",style:{touchAction:"pan-y"},onTouchMove:s=>s.stopPropagation()}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-8 z-10 bg-transparent",style:{touchAction:"pan-y"},onTouchMove:s=>s.stopPropagation()}),e.jsx("div",{className:"space-y-0 max-h-80 overflow-y-auto",children:(t==="mlpPlayers"?me?rt:Q?it:nt:t==="mlpTeams"?tt:t==="ppaRank"?ht:t==="clutch"?Oe:t==="rising"?jt:Zs)||(t==="mlpPlayers"?me?xs.length===0:Q?Ee.length===0:se.length===0:t==="mlpTeams"?us&&X.length===0:t==="ppaRank"?Pe.length===0:t==="clutch"?ve.length===0:t==="rising"?ps.length===0:ds.length===0)?Array.from({length:10}).map((s,u)=>e.jsxs("div",{className:"flex items-center gap-3 p-2",children:[e.jsx(P,{className:"w-6 h-5"}),e.jsx(P,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-4 w-28"}),e.jsx(P,{className:"h-3 w-16"})]}),e.jsx(P,{className:"w-12 h-6"})]},u)):t==="mlpPlayers"&&me?e.jsx(zt,{rows:xs,isLightTheme:d,onPlayerClick:I,resolveTeamLogo:s=>{const u=Se([s]);return(u==null?void 0:u.primary_logo_url)||(u?oe(u.team_title):null)},onTeamClick:(s,u)=>{const N=Se([s]),m=N?X.find(_=>_.team_uuid===N.team_uuid):void 0;if(m){te(m);return}const C=u?X.find(_=>(_.team_title||"").toLowerCase()===u.toLowerCase()):void 0;if(C){te(C);return}N&&te({team_uuid:N.team_uuid,team_title:N.team_title||"",team_abbreviation:N.team_abbreviation||void 0,primary_logo_url:N.primary_logo_url})}}):t==="mlpPlayers"&&!Q?se.length>0?se.map((s,u)=>{const N=s.game_wins+s.game_losses,C=u>0&&se[u-1].win_pct===s.win_pct&&se[u-1].game_wins===s.game_wins&&se[u-1].points_diff===s.points_diff?`T${u+1}`:`#${u+1}`,_=Se([s.player_name]),V=(_==null?void 0:_.primary_logo_url)||(_?oe(_.team_title):null);return e.jsxs("button",{onClick:()=>I(s.player_name),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsx("span",{className:"font-score text-sm text-muted-foreground",children:C}),hs?e.jsx(ue,{change:xt(s.player_uuid,u+1)}):null]}),e.jsx(O,{name:s.player_name,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.player_name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[V?e.jsx("span",{role:"button",tabIndex:0,onClick:ie=>{if(ie.stopPropagation(),!_)return;const Le=X.find(Ae=>Ae.team_uuid===_.team_uuid);te(Le||{team_uuid:_.team_uuid,team_title:_.team_title||"",team_abbreviation:_.team_abbreviation||void 0,primary_logo_url:_.primary_logo_url})},className:"w-4 h-4 rounded-full bg-muted/40 overflow-hidden flex items-center justify-center shrink-0 focus:outline-none transition-transform hover:scale-110","aria-label":(_==null?void 0:_.team_title)||"Team",children:e.jsx("img",{src:V,alt:(_==null?void 0:_.team_title)||"",className:"h-full w-full object-cover",loading:"lazy",onError:ie=>{ie.currentTarget.style.display="none"}})}):null,e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate",children:[s.game_wins,"-",s.game_losses," G • ",s.points_diff>0?"+":"",s.points_diff," PT DIFF"]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-14",children:[e.jsx("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:N>0?`${Math.round(s.win_pct)}%`:"—"}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground
2/50 uppercase tracking-wider leading-none",children:"WIN RATE"})]})]},s.player_uuid)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP player stats will appear once season data is synced."}):t==="mlpPlayers"&&Q?Ee.length>0?Ee.map((s,u)=>{const N=s.game_wins+s.game_losses,m=(s.team_hint?ot(s.team_hint):null)||Se([s.player_a,s.player_b]),C=(m==null?void 0:m.primary_logo_url)||(m?oe(m.team_title):null);return e.jsxs("div",{className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]})}),e.jsxs("div",{className:"flex items-center -space-x-3 shrink-0 mr-1.5",children:[e.jsx("button",{onClick:()=>I(s.player_a),className:"focus:outline-none",children:e.jsx(O,{name:s.player_a,className:"w-8 h-8 ring-2 ring-background"})}),e.jsx("button",{onClick:()=>I(s.player_b),className:"focus:outline-none",children:e.jsx(O,{name:s.player_b,className:"w-8 h-8 ring-2 ring-background"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[(()=>{const[_,V]=sa(Ge(s.player_a),Ge(s.player_b),16);return e.jsxs("p",{className:"font-score text-[1.05rem] whitespace-nowrap overflow-hidden",children:[e.jsx("button",{onClick:()=>I(s.player_a),className:"hover:underline uppercase",children:_}),e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("button",{onClick:()=>I(s.player_b),className:"hover:underline uppercase",children:V})]})})(),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[C?e.jsx("button",{type:"button",onClick:()=>{if(!m)return;const _=X.find(V=>V.team_uuid===m.team_uuid);te(_||{team_uuid:m.team_uuid,team_title:m.team_title||"",team_abbreviation:m.team_abbreviation||void 0,primary_logo_url:m.primary_logo_url})},className:"w-4 h-4 rounded-full bg-muted/40 overflow-hidden flex items-center justify-center shrink-0 focus:outline-none transition-transform hover:scale-110","aria-label":(m==null?void 0:m.team_title)||"Team",children:e.jsx("img",{src:C,alt:(m==null?void 0:m.team_title)||"",className:"h-full w-full object-cover",loading:"lazy",onError:_=>{_.currentTarget.style.display="none"}})}):null,e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate",children:[s.game_wins,"-",s.game_losses," G • ",s.point_differential>0?"+":"",s.point_differential," PT DIFF"]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-14",children:[e.jsx("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:N>0?`${Math.round(s.game_win_rate)}%`:"—"}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground/50 uppercase tracking-wider leading-none",children:"WIN RATE"})]})]},s.id||`${s.player_a}::${s.player_b}`)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP duo stats will appear once season data is synced."}):t==="mlpTeams"?us&&X.length>0?X.map(s=>{const u=s.primary_logo_url||oe(s.team_title);return e.jsxs("button",{onClick:()=>te(s),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",s.standing]}),hs?e.jsx(ue,{change:typeof s.previous_standing=="number"?s.previous_standing-s.standing:ut(s.team_uuid,s.standing)}):null]}),e.jsx("div",{className:"w-10 h-10 shrink-0 mr-1.5 rounded-full bg-muted/40 flex items-center justify-center overflow-hidden",children:u?e.jsx("img",{src:u,alt:s.team_title,className:"h-full w-full object-cover",loading:"lazy",onError:N=>{const m=N.currentTarget,C=oe(s.team_title);C&&m.src!==C?m.src=C:m.style.display="none"}}):e.jsx("span",{className:"font-score text-xs text-primary",children:s.team_abbreviation||s.team_title.slice(0,2)})}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1rem] truncate",children:s.team_title}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:s.matchups_won+s.matchups_lost===0?"No matches played yet":e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary",children:[s.points_earned," PTS"]}),` • ${s.matchups_won}-${s.matchups_lost} W${s.matches_won+s.matches_lost>0?` • ${s.matches_won}-${s.matches_lost} G`:""}`]})})]}),e.jsx("div",{className:"flex flex-col items-end shrink-0 w-14",children:(()=>{const N=s.events_played??ct.get(s.team_uuid)??0,m=typeof s.points_per_event=="number"?s.points_per_event:N>0?s.points_earned/N:null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:m==null?"—":Number.isInteger(m)?m:m.toFixed(1)}),e.jsx("span",{className:"font-score text-[10px] text-muted-foreground
2/50 uppercase tracking-wider leading-none",children:"PTS PER EVT"})]})})()})]},s.team_uuid)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP standings will appear when the current season division is configured."}):t==="ppaRank"?Pe.map((s,u)=>{const N=s.gender==="M"?"M":s.gender==="F"?"W":"",m=W==="overall-mens"||W==="overall-womens",C=[];!m&&s.ppaRankPpr&&C.push(`#${s.ppaRankPpr} WPR`),s.ppaRankDoubles&&C.push(`#${s.ppaRankDoubles} ${N}D`),s.ppaRankMixed&&C.push(`#${s.ppaRankMixed} Mixed`),s.ppaRankSingles&&C.push(`#${s.ppaRankSingles} ${N}S`);const _=m?"ppr":W==="mens-doubles"||W==="womens-doubles"?"doubles":W==="mens-mixed"||W==="womens-mixed"?"mixed":"singles",V=pt(s.playerName,_,s.displayRank),Le=Pe.some((Ae,Ws)=>Ws!==u&&Ae.displayRank===s.displayRank)?`T${s.displayRank}`:`#${s.displayRank}`;return e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsx("span",{className:"font-score text-sm text-muted-foreground",children:Le}),e.jsx(ue,{change:V})]}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:C.join(" • ")})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-16",children:[e.jsx("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:s.displayPoints!=null?Math.round(s.displayPoints).toLocaleString():"—"}),e.jsx("span",{className:"font-score text-xs text-muted-foreground/50 uppercase tracking-wider leading-none",children:"PTS"})]})]},s.playerName)}):t==="rising"?ps.map((s,u)=>{const N=s.wins+s.losses,m=N>0?Math.round(s.wins/N*100):null;return e.jsxs("button",{onClick:()=>I(s.player_name),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]})}),e.jsx(O,{name:s.player_name,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.player_name}),e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate flex items-center gap-1",children:[e.jsxs("span",{children:[s.wins,"-",s.losses,m!==null?` (${m}%)`:"",s.rank_now?` • #${s.rank_now} WPR`:""]}),s.rank_climb>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-primary font-semibold",children:[e.jsx(Z,{className:"h-3 w-3"}),s.rank_climb]}),s.rank_climb<0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-destructive font-semibold",children:[e.jsx(ys,{className:"h-3 w-3"}),Math.abs(s.rank_climb)]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-16",children:[e.jsx("span",{className:"font-score text-[1.35rem] text-primary leading-none",children:Math.round(s.rise_score)}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground/50 uppercase tracking-wider leading-none",children:"RISE SCORE"})]})]},s.player_name)}):t==="clutch"?ve.map((s,u)=>e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]}),e.jsx(ue,{change:s.rankChange})]}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-0.5",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsxs("p",{className:"text-xs text-muted-foreground font-score flex items-center gap-1",children:[s.clutchGamesWon,"-",s.clutchGamesPlayed-s.clutchGamesWon," Close • ",s.tiebreakersWon,"-",s.tiebreakersPlayed-s.tiebreakersWon," Deciding"]})]}),e.jsx("span",{className:"font-score text-[1.35rem] shrink-0 w-16 text-right text-primary",children:$e(s.clutchIndex)})]},s.playerName)):ds.map((s,u)=>e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-1 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]}),e.jsx(ue,{change:s.rankChange})]}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:t==="overall"?e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses," (",s.winRate.toFixed(0),"%) • ",s.pointsWonPercent.toFixed(0),"% Pts • ",s.pointDifferential>0?"+":"",s.pointDifferential]}):t==="pointDifferential"?e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses," • ",s.pointsWonPercent.toFixed(0),"% Pts"]}):e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses]})})]}),e.jsx("span",{className:T("font-score text-[1.35rem] shrink-0 w-16 text-right",t==="pointDifferential"?s.pointDifferential>0?"text-primary":"text-destructive":"text-primary"),children:ta(s,t)})]},s.playerName))})]})},t))]}),e.jsx(At,{slot:"stats_leaderboard",prefix:"Rankings by"})]})]}),e.jsx("div",{className:"-mb-2",children:e.jsx(Kt,{onPlayerClick:I})}),e.jsxs("section",{className:"space-y-3 w-full max-w-full min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Et,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Top Performers"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ae,{value:de,onValueChange:t=>Ne(t),children:[e.jsx(ne,{className:"h-5 w-auto shrink-0 whitespace-nowrap text-[10px] [&>span]:line-clamp-none [&>span]:!flex [&>
2span]:items-center border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 [&>svg]:shrink-0",children:e.jsx("span",{className:"whitespace-nowrap",children:gs[de]})}),e.jsxs(re,{children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mixed-doubles",children:"Mixed Doubles"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}),e.jsx(Be,{value:H,onChange:$})]})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto snap-x snap-mandatory pb-2 scrollbar-hide w-full max-w-full",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:ft||ts.length===0?Array.from({length:5}).map((t,s)=>e.jsx("div",{className:"shrink-0 first:ml-0",style:{scrollSnapAlign:"start"},children:e.jsxs("div",{className:"flex flex-col gap-2 p-3 rounded-xl border border-border/30 bg-muted/20 w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-3 w-20"}),e.jsx(P,{className:"h-2 w-12"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(P,{className:"h-12 rounded"}),e.jsx(P,{className:"h-12 rounded"})]})]})},s)):ts.map((t,s)=>{const u=Math.min(100,Math.max(0,(t.pointDifferential+200)/400*100)),N=Math.round(t.compositeScore??t.winRate*.5+u*.5);return e.jsx("div",{className:"shrink-0 first:ml-0",style:{scrollSnapAlign:"start"},children:e.jsxs("button",{onClick:()=>I(t.playerName),className:"stat-card-sheen flex flex-col gap-2 p-3 rounded-xl border border-border/40 bg-muted/10 transition-all hover:bg-primary/10 text-left w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{name:t.playerName,className:"w-10 h-10"}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-primary text-primary-foreground text-[6px] font-bold w-3.5 h-3.5 rounded-full flex items-center justify-center",children:s+1})]}),e.jsxs("div",{className:"flex-1 min-w-0 -space-y-1",children:[e.jsxs("p",{className:"font-score text-base flex items-center gap-1 min-w-0",children:[e.jsx("span",{className:"truncate",children:t.playerName}),e.jsx(ue,{change:t.rankChange,className:"shrink-0"})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[t.wins,"-",t.losses," Wins"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-center",children:[e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Qe,{className:"h-2 w-2"}),"Pwr Rank"]}),e.jsxs("p",{className:"text-lg font-score text-primary",children:[N,"%"]})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Ce,{className:"h-2 w-2"}),"Win %"]}),e.jsxs("p",{className:"text-lg font-score text-primary",children:[Math.round(t.winRate),"%"]})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Z,{className:"h-2 w-2"}),"Pt Diff"]}),e.jsxs("p",{className:T("text-lg font-score",t.pointDifferential>0?"text-primary":"text-destructive"),children:[t.pointDifferential>0?"+":"",t.pointDifferential]})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Ye,{className:"h-2 w-2"}),"Pts Won"]}),e.jsxs("p",{className:"text-lg font-score text-primary",children:[Math.round(t.pointsWonPercent),"%"]})]})]})]})},t.playerName)})})]}),e.jsx("div",{className:"w-full max-w-full min-w-0 -mt-2",children:e.jsx(rs,{name:"stats:data-dive:mobile",children:e.jsx(Xt,{children:e.jsx(Ut,{topPlayers:ts.map(t=>({name:t.playerName})),onPlayerClick:I})})})}),e.jsxs("section",{className:"-mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ks,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-bold",children:"Clutch Leaders"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{value:Me,onChange:as,compact:!0}),e.jsxs("button",{onClick:()=>Ts(!0),className:"text-[10px] text-primary hover:underline flex items-center gap-0.5",children:["More ",e.jsx(Ke,{className:"h-3 w-3"})]})]})]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto snap-x snap-mandatory pb-2 scrollbar-hide",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:Oe||ve.length===0?Array.from({length:5}).map((t,s)=>e.jsx("div",{className:"shrink-0",style:{scrollSnapAlign:"start"},children:e.jsx("div",{className:"flex flex-col gap-1.5 p-2 rounded-lg border border-border/30 bg-muted/20 w-[120px]",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(P,{className:"w-8 h-8 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-2.5 w-14"}),e.jsx(P,{className:"h-2 w-10"})]})]})})},s)):ve.map((t,s)=>e.jsx("div",{className:"shrink-0",style:{scrollSnapAlign:"start"},children:e.jsxs("button",{onClick:()=>I(t.playerName),className:"stat-card-sheen flex flex-col gap-1.5 p-2 rounded-lg border border-border/40 bg-muted/10 transition-all hover:bg-primary/10 text-left w-[120px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(O,{name:t.playerName,className:"w-8 h-8"}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-primary text-primary-foreground text-[5px] font-bold w-3 h-3 rounded-full flex items-center justify-center",children:s+1})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[e.jsx("p",{className:"font-score text-sm truncate leading-none",children:t.playerName}),e.jsxs("p",{className:T("text-sm font-score leading-none",t.clutchIndex>=60?"text-primary":"text-foreground"),children:[(t.clutchIndex??0).toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-center text-[8px]",children:[e.jsxs("div",{className:"bg-muted/40 rounded px-1 py-0.5",children:[e.jsx("span",{className:"text-muted-foreground",children:"Close"}),e.jsxs("p",{className:"font-score text-sm",children:[t.clutchGamesWon,"-",t.clutchGamesPlayed-t.clutchGamesWon]})]}),e.jsxs("div",{className:"bg-muted/40 rounded px-1 py-0.5",children:[e.jsx("span",{className:"text-muted-foreground",children:"Deciding"}),e.jsxs("p",{className:"font-score text-sm",children:[t.tiebreakersWon,"-",t.tiebreakersPlayed-t.tiebreakersWon]})]})]})]})},t.playerName))})]})]}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6 min-w-0",children:[e.jsxs(Je,{className:T("border-border/50 relative overflow-hidden",d?"bg-white":"bg-gradient-match-card"),
2children:[e.jsx(Ct,{slot:"stats_leaderboard",size:160}),e.jsx(ls,{className:"pb-2 pt-3 relative z-10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ns,{className:"text-base flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4 text-primary"}),"Leaderboards"]}),e.jsx("div",{className:"flex items-center gap-3",children:L==="mlpTeams"?e.jsxs(ae,{value:Ze,onValueChange:t=>ye(t),children:[e.jsx(ne,{className:"h-5 w-auto text-[10px] border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 gap-1",children:e.jsx("span",{children:ss})}),e.jsxs(re,{children:[E&&e.jsx(y,{value:"2026:teams",children:"2026 Teams"}),e.jsx(y,{value:"2025:premier",children:"2025 Premier"}),e.jsx(y,{value:"2025:challenger",children:"2025 Challenger"})]})]}):L==="mlpPlayers"?e.jsx(ea,{value:Ze,onChange:t=>ye(t),label:ss,allow2026Players:!!Y,allow2026Duos:!!E}):L==="rising"?e.jsxs(ae,{value:we,onValueChange:t=>gt(t),children:[e.jsx(ne,{className:"h-5 w-auto text-[10px] border-0 bg-muted/40 focu
2s:ring-0 focus:ring-offset-0 focus:outline-none px-2 gap-1 [&>svg]:shrink-0",children:e.jsx("span",{className:"whitespace-nowrap",children:we==="men"?"Men":we==="women"?"Women":"All"})}),e.jsxs(re,{align:"end",children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"men",children:"Men"}),e.jsx(y,{value:"women",children:"Women"})]})]}):L==="ppaRank"?e.jsxs(ae,{value:W,onValueChange:t=>Ie(t),children:[e.jsx(ne,{className:"h-5 w-[88px] text-[10px] border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2",children:e.jsx(rn,{placeholder:"Overall Men's"})}),e.jsxs(re,{children:[e.jsx(y,{value:"overall-mens",children:"Overall Men's (WPR)"}),e.jsx(y,{value:"overall-womens",children:"Overall Women's (WPR)"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mens-mixed",children:"Men's Mixed"}),e.jsx(y,{value:"womens-mixed",children:"Women's Mixed"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ae,{value:B,onValueChange:t=>je(t),children:[e.jsx(ne,{className:"h-5 w-auto shrink-0 whitespace-nowrap text-[10px] [&>span]:line-clamp-none [&>span]:!flex [&>
2span]:items-center border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 [&>span]:whitespace-nowrap [&>svg]:shrink-0",children:e.jsx("span",{className:"whitespace-nowrap",children:gs[B]})}),e.jsxs(re,{children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mixed-doubles",children:"Mixed Doubles"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}),e.jsx(Be,{value:L==="clutch"?Me:M,onChange:t=>{L==="clutch"?as(t):A(t)}})]})})]})}),e.jsxs(is,{className:"pt-0 pb-4",children:[e.jsxs(Tt,{value:L,onValueChange:t=>S(t),children:[e.jsx(Rt,{className:"!grid !w-full mb-4 h-auto grid-cols-7 gap-1 min-w-0 p-1",children:z.map(({mode:t,label:s,icon:u})=>e.jsxs(Dt,{value:t,className:"w-full flex flex-col items-center justify-center gap-0.5 !text-[11px] !px-1 py-1.5 min-w-0",children:[e.jsx(u,{className:T("shrink-0",t==="mlpTeams"||t==="mlpPlayers"?"!h-3.5 !w-9":t==="ppaRank"?"!h-3.5 !w-5":t==="winRate"?"!h-3.5 !w-3.5 scale-95":"!h-3.5 !w-3.5"),strokeWidth:2.5,"data-active":L===t}),e.jsx("span",{className:"leading-tight truncate w-full text-center",children:s})]},t))}),z.map(({mode:t})=>e.jsx(Lt,{value:t,className:"mt-0",children:e.jsx("div",{className:"space-y-1 max-h-80 overflow-y-auto",children:(t==="mlpPlayers"?me?rt:Q?it:nt:t==="mlpTeams"?tt:t==="ppaRank"?ht:t==="clutch"?Oe:t==="rising"?jt:Zs)||(t==="mlpPlayers"?me?xs.length===0:Q?Ee.length===0:se.length===0:t==="mlpTeams"?us&&X.length===0:t==="ppaRank"?Pe.length===0:t==="clutch"?ve.length===0:t==="rising"?ps.length===0:ds.length===0)?Array.from({length:10}).map((s,u)=>e.jsxs("div",{className:"flex items-center gap-3 p-2",children:[e.jsx(P,{className:"w-6 h-5"}),e.jsx(P,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-4 w-28"}),e.jsx(P,{className:"h-3 w-16"})]}),e.jsx(P,{className:"w-12 h-6"})]},u)):t==="mlpPlayers"&&me?e.jsx(zt,{rows:xs,isLightTheme:d,onPlayerClick:I}):t==="mlpPlayers"&&!Q?se.length>0?se.map((s,u)=>{const N=s.game_wins+s.game_losses,C=u>0&&se[u-1].win_pct===s.win_pct&&se[u-1].game_wins===s.game_wins&&se[u-1].points_diff===s.points_diff?`T${u+1}`:`#${u+1}`,_=Se([s.player_name]),V=(_==null?void 0:_.primary_logo_url)||(_?oe(_.team_title):null);return e.jsxs("button",{onClick:()=>I(s.player_name),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsx("span",{className:"font-score text-sm text-muted-foreground",children:C}),hs?e.jsx(ue,{change:xt(s.player_uuid,u+1)}):null]}),e.jsx(O,{name:s.player_name,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1rem] truncate",children:s.player_name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[V?e.jsx("span",{role:"button",tabIndex:0,onClick:ie=>{if(ie.stopPropagation(),!_)return;const Le=X.find(Ae=>Ae.team_uuid===_.team_uuid);te(Le||{team_uuid:_.team_uuid,team_title:_.team_title||"",team_abbreviation:_.team_abbreviation||void 0,primary_logo_url:_.primary_logo_url})},className:"w-4 h-4 rounded-full bg-muted/40 overflow-hidden flex items-center justify-center shrink-0 focus:outline-none transition-transform hover:scale-110","aria-label":(_==null?void 0:_.team_title)||"Team",children:e.jsx("img",{src:V,alt:(_==null?void 0:_.team_title)||"",className:"h-full w-full object-cover",loading:"lazy",onError:ie=>{ie.currentTarget.style.display="none"}})}):null,e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate",children:[s.game_wins,"-",s.game_losses," G • ",s.points_diff>0?"+":"",s.points_diff," PT DIFF"]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-14",children:[e.jsx("span",{className:"font-score text-xl text-primary leading-none",children:N>0?`${Math.round(s.win_pct)}%`:"—"}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground
2/50 uppercase tracking-wider leading-none",children:"WIN RATE"})]})]},s.player_uuid)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP player stats will appear once season data is synced."}):t==="mlpPlayers"&&Q?Ee.length>0?Ee.map((s,u)=>{const N=s.game_wins+s.game_losses,m=(s.team_hint?ot(s.team_hint):null)||Se([s.player_a,s.player_b]),C=(m==null?void 0:m.primary_logo_url)||(m?oe(m.team_title):null);return e.jsxs("div",{className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]})}),e.jsxs("div",{className:"flex items-center -space-x-3 shrink-0 mr-1.5",children:[e.jsx("button",{onClick:()=>I(s.player_a),className:"focus:outline-none",children:e.jsx(O,{name:s.player_a,className:"w-8 h-8 ring-2 ring-background"})}),e.jsx("button",{onClick:()=>I(s.player_b),className:"focus:outline-none",children:e.jsx(O,{name:s.player_b,className:"w-8 h-8 ring-2 ring-background"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[(()=>{const[_,V]=sa(Ge(s.player_a),Ge(s.player_b),16);return e.jsxs("p",{className:"font-score text-[1rem] whitespace-nowrap overflow-hidden",children:[e.jsx("button",{onClick:()=>I(s.player_a),className:"hover:underline uppercase",children:_}),e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("button",{onClick:()=>I(s.player_b),className:"hover:underline uppercase",children:V})]})})(),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[C?e.jsx("button",{type:"button",onClick:()=>{if(!m)return;const _=X.find(V=>V.team_uuid===m.team_uuid);te(_||{team_uuid:m.team_uuid,team_title:m.team_title||"",team_abbreviation:m.team_abbreviation||void 0,primary_logo_url:m.primary_logo_url})},className:"w-4 h-4 rounded-full bg-muted/40 overflow-hidden flex items-center justify-center shrink-0 focus:outline-none transition-transform hover:scale-110","aria-label":(m==null?void 0:m.team_title)||"Team",children:e.jsx("img",{src:C,alt:(m==null?void 0:m.team_title)||"",className:"h-full w-full object-cover",loading:"lazy",onError:_=>{_.currentTarget.style.display="none"}})}):null,e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate",children:[s.game_wins,"-",s.game_losses," G • ",s.point_differential>0?"+":"",s.point_differential," PT DIFF"]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-14",children:[e.jsx("span",{className:"font-score text-xl text-primary leading-none",children:N>0?`${Math.round(s.game_win_rate)}%`:"—"}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground/50 uppercase tracking-wider leading-none",children:"WIN RATE"})]})]},s.id||`${s.player_a}::${s.player_b}`)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP duo stats will appear once season data is synced."}):t==="mlpTeams"?us&&X.length>0?X.map(s=>{const u=s.primary_logo_url||oe(s.team_title);return e.jsxs("button",{onClick:()=>te(s),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg text-left transition-colors",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",s.standing]}),hs?e.jsx(ue,{change:typeof s.previous_standing=="number"?s.previous_standing-s.standing:ut(s.team_uuid,s.standing)}):null]}),e.jsx("div",{className:"w-10 h-10 shrink-0 mr-1.5 rounded-full bg-muted/40 flex items-center justify-center overflow-hidden",children:u?e.jsx("img",{src:u,alt:s.team_title,className:"h-full w-full object-cover",loading:"lazy",onError:N=>{const m=N.currentTarget,C=oe(s.team_title);C&&m.src!==C?m.src=C:m.style.display="none"}}):e.jsx("span",{className:"font-score text-xs text-primary",children:s.team_abbreviation||s.team_title.slice(0,2)})}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1rem] truncate",children:s.team_title}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:s.matchups_won+s.matchups_lost===0?"No matches played yet":e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary",children:[s.points_earned," PTS"]}),` • ${s.matchups_won}-${s.matchups_lost} W${s.matches_won+s.matches_lost>0?` • ${s.matches_won}-${s.matches_lost} G`:""}`]})})]}),e.jsx("div",{className:"flex flex-col items-end shrink-0 w-14",children:(()=>{const N=s.events_played??ct.get(s.team_uuid)??0,m=typeof s.points_per_event=="number"?s.points_per_event:N>0?s.points_earned/N:null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-score text-xl text-primary leading-none",children:m==null?"—":Number.isInteger(m)?m:m.toFixed(1)}),e.jsx("span",{className:"font-score text-[10px] text-muted-foreground
2/50 uppercase tracking-wider leading-none",children:"PTS PER EVT"})]})})()})]},s.team_uuid)}):e.jsx("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"MLP standings will appear when the current season division is configured."}):t==="ppaRank"?Pe.map((s,u)=>{const N=s.gender==="M"?"M":s.gender==="F"?"W":"",m=W==="overall-mens"||W==="overall-womens",C=[];!m&&s.ppaRankPpr&&C.push(`#${s.ppaRankPpr} WPR`),s.ppaRankDoubles&&C.push(`#${s.ppaRankDoubles} ${N}D`),s.ppaRankMixed&&C.push(`#${s.ppaRankMixed} Mixed`),s.ppaRankSingles&&C.push(`#${s.ppaRankSingles} ${N}S`);const _=m?"ppr":W==="mens-doubles"||W==="womens-doubles"?"doubles":W==="mens-mixed"||W==="womens-mixed"?"mixed":"singles",V=pt(s.playerName,_,s.displayRank),Le=Pe.some((Ae,Ws)=>Ws!==u&&Ae.displayRank===s.displayRank)?`T${s.displayRank}`:`#${s.displayRank}`;return e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsx("span",{className:"font-score text-sm text-muted-foreground",children:Le}),e.jsx(ue,{change:V})]}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:C.join(" • ")})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-16",children:[e.jsx("span",{className:"font-score text-xl text-primary leading-none",children:s.displayPoints!=null?Math.round(s.displayPoints).toLocaleString():"—"}),e.jsx("span",{className:"font-score text-xs text-muted-foreground/50 uppercase tracking-wider leading-none",children:"PTS"})]})]},s.playerName)}):t==="rising"?ps.map((s,u)=>{const N=s.wins+s.losses,m=N>0?Math.round(s.wins/N*100):null;return e.jsxs("button",{onClick:()=>I(s.player_name),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]})}),e.jsx(O,{name:s.player_name,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.player_name}),e.jsxs("p",{className:"text-xs text-muted-foreground font-score truncate flex items-center gap-1",children:[e.jsxs("span",{children:[s.wins,"-",s.losses,m!==null?` (${m}%)`:"",s.rank_now?` • #${s.rank_now} WPR`:""]}),s.rank_climb>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-primary font-semibold",children:[e.jsx(Z,{className:"h-3 w-3"}),s.rank_climb]}),s.rank_climb<0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-destructive font-semibold",children:[e.jsx(ys,{className:"h-3 w-3"}),Math.abs(s.rank_climb)]})]})]}),e.jsxs("div",{className:"flex flex-col items-end shrink-0 w-16",children:[e.jsx("span",{className:"font-score text-xl text-primary leading-none",children:Math.round(s.rise_score)}),e.jsx("span",{className:"font-score text-[0.6rem] text-muted-foreground/50 uppercase tracking-wider leading-none",children:"RISE SCORE"})]})]},s.player_name)}):t==="clutch"?ve.map((s,u)=>e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsx("div",{className:"w-5 flex flex-col items-center shrink-0",children:e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]})}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsxs("p",{className:"text-xs text-muted-foreground font-score flex items-center gap-1",children:[s.clutchGamesWon,"-",s.clutchGamesPlayed-s.clutchGamesWon," Close • ",s.tiebreakersWon,"-",s.tiebreakersPlayed-s.tiebreakersWon," Deciding"]})]}),e.jsx("span",{className:"font-score text-xl shrink-0 w-16 text-right text-primary",children:$e(s.clutchIndex)})]},s.playerName)):ds.map((s,u)=>e.jsxs("button",{onClick:()=>I(s.playerName),className:T("w-full flex items-center gap-2 py-1.5 px-2.5 rounded-lg transition-colors text-left",d?"hover:bg-muted/50":"hover:bg-muted/30"),children:[e.jsxs("div",{className:"w-5 flex flex-col items-center shrink-0",children:[e.jsxs("span",{className:"font-score text-sm text-muted-foreground",children:["#",u+1]}),e.jsx(ue,{change:s.rankChange})]}),e.jsx(O,{name:s.playerName,className:"w-10 h-10 shrink-0 mr-1.5"}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden -space-y-1",children:[e.jsx("p",{className:"font-score text-[1.15rem] truncate",children:s.playerName}),e.jsx("p",{className:"text-xs text-muted-foreground font-score truncate",children:t==="overall"?e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses," (",s.winRate.toFixed(0),"%) • ",s.pointsWonPercent.toFixed(0),"% Pts • ",s.pointDifferential>0?"+":"",s.pointDifferential]}):t==="pointDifferential"?e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses," • ",s.pointsWonPercent.toFixed(0),"% Pts"]}):e.jsxs(e.Fragment,{children:[s.wins,"-",s.losses]})})]}),e.jsx("span",{className:T("font-score text-xl shrink-0 w-16 text-right",t==="pointDifferential"?s.pointDifferential>0?"text-primary":"text-destructive":"text-primary"),children:ta(s,t)})]},s.playerName))})},t))]}),e.jsx(At,{slot:"stats_leaderboard",prefix:"Rankings by"})]})]}),!a&&e.jsx("div",{className:"px-0.5",children:e.jsx(rs,{name:"stats:h2h:desktop",children:e.jsx(Ht,{showTitle:!0})})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Kt,{onPlayerClick:I}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(Et,{className:"h-4 w-4 text-primary"}),"Top Performers"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ae,{value:de,onValueChange:t=>Ne(t),children:[e.jsx(ne,{className:"h-5 w-auto shrink-0 whitespace-nowrap text-[10px] [&>span]:line-clamp-none [&>span]:!flex [&>
2span]:items-center border-0 bg-muted/40 focus:ring-0 focus:ring-offset-0 focus:outline-none px-2 [&>svg]:shrink-0",children:e.jsx("span",{className:"whitespace-nowrap",children:gs[de]})}),e.jsxs(re,{children:[e.jsx(y,{value:"all",children:"All"}),e.jsx(y,{value:"mens-doubles",children:"Men's Doubles"}),e.jsx(y,{value:"womens-doubles",children:"Women's Doubles"}),e.jsx(y,{value:"mixed-doubles",children:"Mixed Doubles"}),e.jsx(y,{value:"mens-singles",children:"Men's Singles"}),e.jsx(y,{value:"womens-singles",children:"Women's Singles"})]})]}),e.jsx(Be,{value:H,onChange:$})]})]}),e.jsx("div",{className:"pb-2 scrollbar-hide flex gap-3 snap-x snap-mandatory overflow-x-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:ft?Array.from({length:a?5:8}).map((t,s)=>e.jsx("div",{className:"shrink-0 first:ml-0",style:{scrollSnapType:"x mandatory",scrollSnapAlign:"start"},children:e.jsxs("div",{className:"flex flex-col gap-2 p-3 rounded-xl border border-border/30 bg-muted/20 w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-3 w-20"}),e.jsx(P,{className:"h-2 w-12"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(P,{className:"h-12 rounded"}),e.jsx(P,{className:"h-12 rounded"})]})]})},s)):ts.map((t,s)=>{const u=Math.min(100,Math.max(0,(t.pointDifferential+200)/400*100)),N=Math.round(t.compositeScore??t.winRate*.5+u*.5);return e.jsx("div",{className:"shrink-0 first:ml-0",style:{scrollSnapAlign:"start"},children:e.jsxs("button",{onClick:()=>I(t.playerName),className:"stat-card-sheen flex flex-col gap-2 p-3 rounded-xl border border-border/40 bg-muted/10 transition-all hover:bg-primary/10 text-left w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{name:t.playerName,className:"w-10 h-10"}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-primary text-primary-foreground text-[8px] font-bold w-4 h-4 rounded-full flex items-center justify-center",children:s+1})]}),e.jsxs("div",{className:"flex-1 min-w-0 -space-y-1",children:[e.jsxs("p",{className:"font-score text-base flex items-center gap-1 min-w-0",children:[e.jsx("span",{className:"truncate",children:t.playerName}),e.jsx(ue,{change:t.rankChange,className:"shrink-0"})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[t.wins,"-",t.losses," Wins"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-center",children:[e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Qe,{className:"h-2 w-2"}),"Pwr Rank"]}),e.jsxs("p",{className:"font-score text-base text-primary",children:[N,"%"]})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Ce,{className:"h-2 w-2"}),"Win %"]}),e.jsx("p",{className:"font-score text-base text-primary",children:$e(t.winRate)})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Z,{className:"h-2 w-2"}),"Pt Diff"]}),e.jsxs("p",{className:T("font-score text-base",t.pointDifferential>0?"text-primary":"text-destructive"),children:[t.pointDifferential>0?"+":"",t.pointDifferential]})]}),e.jsxs("div",{className:"bg-muted/40 rounded p-1.5",children:[e.jsxs("p",{className:"text-[7px] text-muted-foreground uppercase flex items-center justify-center gap-0.5",children:[e.jsx(Ye,{className:"h-2 w-2"}),"Pts Won"]}),e.jsx("p",{className:"font-score text-base text-primary",children:$e(t.pointsWonPercent)})]})]})]})},t.playerName)})})]}),e.jsx(rs,{name:"stats:data-dive:desktop",children:e.jsx(Xt,{children:e.jsx(Ut,{topPlayers:ts.map(t=>({name:t.playerName})),onPlayerClick:I})})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ks,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-bold",children:"Clutch Leaders"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{value:Me,onChange:as,compact:!0}),e.jsxs("button",{onClick:()=>Ts(!0),className:"text-[10px] text-primary hover:underline flex items-center gap-0.5",children:["More ",e.jsx(Ke,{className:"h-3 w-3"})]})]})]}),e.jsx("div",{className:"pb-2 scrollbar-hide flex gap-2 snap-x snap-mandatory overflow-x-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-x pan-y",overscrollBehaviorX:"contain"},children:Oe?Array.from({length:a?5:10}).map((t,s)=>e.jsx("div",{className:"shrink-0",style:{scrollSnapAlign:"start"},children:e.jsx("div",{className:"flex flex-col gap-1.5 p-2 rounded-lg border border-border/30 bg-muted/20 w-[120px]",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(P,{className:"w-8 h-8 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(P,{className:"h-2.5 w-14"}),e.jsx(P,{className:"h-2 w-10"})]})]})})},s)):ve.map((t,s)=>e.jsx("div",{className:"shrink-0",style:{scrollSnapAlign:"start"},children:e.jsxs("button",{onClick:()=>I(t.playerName),className:"stat-card-sheen flex flex-col gap-1.5 p-2 rounded-lg border border-border/40 bg-muted/10 transition-all hover:bg-primary/10 text-left w-[120px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{name:t.playerName,className:"w-8 h-8"}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-primary text-primary-foreground text-[5px] font-bold w-3 h-3 rounded-full flex items-center justify-center",children:s+1})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0",children:[e.jsx("p",{className:"font-score text-xs truncate leading-tight",children:t.playerName}),e.jsxs("p",{className:T("text-base font-score leading-tight",t.clutchIndex>=60?"text-primary":"text-foreground"),children:[(t.clutchIndex??0).toFixed(0),"%"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-center text-[8px]",children:[e.jsxs("div",{className:"bg-muted/40 rounded px-1 py-0.5",children:[e.jsx("span",{className:"text-muted-foreground",children:"Close"}),e.jsxs("p",{className:"font-score text-sm",children:[t.clutchGamesWon,"-",t.clutchGamesPlayed-t.clutchGamesWon]})]}),e.jsxs("div",{className:"bg-muted/40 rounded px-1 py-0.5",children:[e.jsx("span",{className:"text-muted-foreground",children:"Deciding"}),e.jsxs("p",{className:"font-score text-sm",children:[t.tiebreakersWon,"-",t.tiebreakersPlayed-t.tiebreakersWon]})]})]})]})},t.playerName))})]})]})]}),a&&e.jsx("div",{className:T("mt-2.5 px-0.5",h?"mb-6":"mb-4"),children:e.jsx(rs,{name:"stats:h2h:mobile",children:e.jsx(Ht,{showTitle:!0})})})]}),e.jsxs(Xs,{open:!!G,onOpenChange:t=>!t&&i.startTransition(()=>Fe(null)),title:"Player profile",desktopClassName:"sm:max-w-lg flex flex-col sm:h-[82vh]",mobileClassName:"h-[82dvh] flex flex-col",children:[e.jsxs("div",{className:"shrink-0 z-10 bg-background px-4 -mt-4 -mb-px pt-8 pb-1 relative sm:mt-0 sm:pt-4",children:[vt&&e.jsx("div",{"aria-hidden":!0,
2className:"pointer-events-none absolute inset-x-0 top-0 -bottom-px -z-10",style:vt}),G&&e.jsxs("div",{className:"absolute right-2 top-4 z-30 flex items-center gap-0",children:[e.jsxs("button",{type:"button",onClick:ba,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-transparent p-0 text-foreground/80 transition-colors hover:bg-muted/60 hover:text-foreground",children:[e.jsx(ln,{size:16,className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Share profile"})]}),e.jsxs("button",{type:"button",onClick:()=>i.startTransition(()=>Fe(null)),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-transparent p-0 text-foreground/80 transition-colors hover:bg-muted/60 hover:text-foreground",children:[e.jsx(cs,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"sr-only",children:[G," Stats"]}),G&&e.jsx("div",{className:"flex min-w-0 items-start overflow-x-hidden overflow-y-visible",children:e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center gap-0.5 overflow-visible px-4",children:[e.jsx(on,{name:G,className:"w-20 h-20"}),e.jsx(cn,{playerName:G,className:"w-full"})]})})]})]}),e.jsxs("div",{ref:l,"data-allow-scroll":"true",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain touch-pan-y px-4 pb-24",style:{WebkitOverflowScrolling:"touch"},children:[e.jsx("div",{className:"flex items-center justify-center gap-2 pb-2",children:e.jsx(dn,{playerName:G})}),G&&e.jsx(rs,{name:"player-stats-dialog",fallback:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Unable to load player stats. Please try again."}),children:e.jsx(mn,{playerName:G,stats:ga[G],loading:ja,compact:!0,onMatchOpen:ka,onPlayerOpen:t=>{i.startTransition(()=>{Fe(t)})}},G)})]})]}),e.jsx(aa,{match:wa,open:va,onOpenChange:t=>{yt(t),t||Nt(null)}}),e.jsx(un,{open:Na,onOpenChange:Ts,onPlayerOpen:I}),e.jsx(xn,{team:dt,open:!!dt,onOpenChange:t=>!t&&te(null),seasonLabel:ss,onPlayerOpen:t=>{te(null),I(t)}}),!b&&a&&e.jsx("footer",{className:"text-center pt-3 pb-4",children:e.jsxs("p",{className:"text-[9px] text-muted-foreground/60",children:[e.jsx(fs,{to:"/support",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Contact Us"})," · ",e.jsx(fs,{to:"/privacy-policy",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Privacy Policy"})," · ",e.jsx(fs,{to:"/terms-of-service",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Terms of Use"})]})})]})};export{kr 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.