1import{eH as na,j as e,eI as oa,r as _,Z as ia,k as la,K as da,i as Nr,u as jr,q as yt,fl as Qt,a4 as ca,w as h,I as fa,t as or,H as ma,D as ct,ba as pa,B as Qe,b7 as ua,c as ft,aG as mt,d as pt,e as Ct,a$ as js,O as ga,v as Rr,br as ws,ah as Ot,ac as wr,m as Xe,cM as St,b as Fr,a3 as xa,bJ as ir,bD as _a,aX as ha,ab as va,au as ya,_ as ba,d3 as Na,d4 as ja,d5 as wa,dj as Mt,eq as Fa,M as Oa}from"./index-BAz9GNw5.js";import{P as Pa,a as Ca,b as Sa}from"./popover-C-OztIQk.js";import{g as Ta,n as Ir,b as Fs,c as Os,a as Or}from"./pbpTeamIds-CVPNUg-e.js";import{r as lr,f as dr,c as Ea,d as Ps,e as qa,g as Br,i as ka}from"./wowyService-CO34E5fb.js";import{o as Ma}from"./ogImage-BhGBAgoT.js";import{S as Wa}from"./slider-7uI5sUv0.js";import{u as Ze,W as La}from"./WowyLeagueContext-CCFsWHG4.js";import{f as Pr,u as Cr,c as Sr,m as Aa,F as Kr,D as Da,$ as $a,o as Ra,d as Ia,E as ut}from"./usePress-CNm3E4qw.js";import{a as Ba,f as Yr}from"./useHover-BdVsLByw.js";import{u as Ka,a as Ya,r as Ga}from"./chunk-6VC6TS2O-DA4Oq8F2.js";import{C as Ha}
1from"./chart-pie-CHVoA0DZ.js";import{P as Ua}from"./palette-BhefMrjy.js";import{W as za}from"./WowyTeamSelector-lPI-SaOj.js";import{C as Cs,S as Va}from"./SelectorPanel-CzGTikqw.js";import{O as Qa,D as Xa}from"./DefensiveLuckSlider-M0rNZ1Dz.js";import{a as Tt,b as ot}from"./imageLoader-Cei7HNzV.js";import{T as cr,a as fr,b as mr,c as pr}from"./tooltip-DB4M2sfq.js";import{S as ne}from"./skeleton-DTZLiOvS.js";import{T as Tr,a as Ss,b as Pt,d as Er,e as Be,c as st}from"./table-DKwdjDhn.js";import{S as Gr}from"./scroll-area-DIRnm0WR.js";import{T as Ja}from"./TeamLogo-ig19kBh5.js";import{C as Za,a as en,b as tn}from"./collapsible-wxDIKa5S.js";import{g as Ts}from"./imageUtils-DYLk9oTa.js";import{b as rn,c as sn,g as Xt,d as an}from"./wowyNameUtils-T3cRkcBD.js";import{b as qr,a as kr,g as Mr,c as nn,t as on}from"./wowyPortraitTheme-DtJf5nJE.js";import{C as Es}from"./copy-Dn2gqfNo.js";import{T as ln}from"./trending-down-DJ8MJ475.js";import{S as dn}from"./shield-BRg04akB.js";import{W as cn}from"./WowyLeadersPortrait-D34t550x.js";import{C as qs}from"./camera-B4HABkS0.js";import{A as fn}from"./arrow-up-CvYEP-du.js";import{i as mn,g as pn,e as un}from"./exportSafeHeadshots-BxR39Mh4.js";import{I as Hr}from"./image-DT-ep0XC.js";import{S as gn}from"./sliders-horizontal-B10SADdC.js";import"./index-uAq2S7DT.js";import"./index-D17hSi50.js";import"./index-B9XaoZwp.js";import"./proxy-CwxAoO5U.js";import"./WowyYearSelector-P9K2EeX8.js";import"./calendar-BaykPKMC.js";import"./checkbox-D8xkxhzg.js";import"./settings-2-DCMmezz9.js";import"./chevrons-up-down-DAYyoE2W.js";import"./table-BytisQSz.js";import"./layout-grid-CcvsC3uv.js";import"./WowyHotkeysLegend-BGX9WNlp.js";import"./chevron-up-DSE8rSwP.js";import"./index.module-DE9tvZLS.js";import"./textSelection-CSU_5_-k.js";import"./teamColors-BZv_g0DU.js";var[xn,ks]=na({name:"CardContext",strict:!0,errorMessage:"useCardContext: `context` is undefined. Seems you forgot to wrap component within <Card />"}),Ms=Pr((t,r)=>{var o;const{as:f,className:m,children:i,...l}=t,s=f||"div",d=Cr(r),{slots:c,classNames:n}=ks(),N=Sr(n==null?void 0:n.body,m);return e.jsx(s,{ref:d,className:(o=c.body)==null?void 0:o.call(c,{class:N}),...l,children:i})});Ms.displayName="HeroUI.CardBody";var gt=Ms,Ws=Pr((t,r)=>{var o;const{as:f,className:m,children:i,...l}=t,s=f||"div",d=Cr(r),{slots:c,classNames:n}=ks(),N=Sr(n==null?void 0:n.header,m);return e.jsx(s,{ref:d,className:(o=c.header)==null?void 0:o.call(c,{class:N}),...l,children:i})});Ws.displayName="HeroUI.CardHeader";var xt=Ws;function _n(t){var r,o,f,m;const i=oa(),[l,s]=Aa(t,Kr.variantKeys),{ref:d,as:c,children:n,onClick:N,onPress:y,autoFocus:W,className:E,classNames:S,allowTextSelectionOnPress:j=!0,...A}=l,T=Cr(d),p=c||(t.isPressable?"button":"div"),F=typeof p=="string",ie=(o=(r=t.disableAnimation)!=null?r:i==null?void 0:i.disableAnimation)!=null?o:!1,$=(m=(f=t.disableRipple)!=null?f:i==null?void 0:i.disableRipple)!=null?m:!1,G=Sr(S==null?void 0:S.base,E),{onClear:M,onPress:ge,ripples:te}=Ka(),oe=_.useCallback(Y=>{$||ie||T.current&&ge(Y)},[$,ie,T,ge]),{buttonProps:ce,isPressed:K}=Ya({onPress:Da(y,oe),elementType:c,isDisabled:!t.isPressable,onClick:N,allowTextSelectionOnPress:j,...A},T),{hoverProps:b,isHovered:X}=Ba({isDisabled:!t.isHoverable,...A}),{isFocusVisible:V,isFocused:me,focusProps:ve}=$a({autoFocus:W}),z=_.useMemo(()=>Kr({...s,disableAnimation:ie}),[Ra(s),ie]),Ce=_.useMemo(()=>({slots:z,classNames:S,disableAnimation:ie,isDisabled:t.isDisabled,isFooterBlurred:t.isFooterBlurred,fullWidth:t.fullWidth}),[z,S,t.isDisabled,t.isFooterBlurred,ie,t.fullWidth]),le=_.useCallback((Y={})=>({ref:T,className:z.base({class:G}),tabIndex:t.isPressable?0:-1,"data-hover":ut(X),"data-pressed":ut(K),"data-focus":ut(me),"data-focus-visible":ut(V),"data-disabled":ut(t.isDisabled),...Ia(t.isPressable?{...ce,...ve,role:"button"}:{},t.isHoverable?b:{},Yr(A,{enabled:F}),Yr(Y))}),[T,z,G,F,t.isPressable,t.isHoverable,t.isDisabled,X,K,V,ce,ve,b,A]),je=_.useCallback(()=>({ripples:te,onClear:M}),[te,M]);return{context:Ce,domRef:T,Component:p,classNames:S,children:n,isHovered:X,isPressed:K,disableAnimation:ie,isPressable:t.isPressable,isHoverable:t.isHoverable,disableRipple:$,handlePress:oe,isFocusVisible:V,getCardProps:le,getRippleProps:je}}var Ls=Pr((t,r)=>{const{children:o,context:f,Component:m,isPressable:i,disableAnimation:l,disableRipple:s,getCardProps:d,getRippleProps:c}=_n({...t,ref:r});return e.jsxs(m,{...d(),children:[e.jsx(xn,{value:f,children:o}),i&&!l&&!s&&e.jsx(Ga,{...c()})]})});Ls.displayName="HeroUI.Card";var _t=Ls;/** 2 * @license lucide-react v0.577.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const hn=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]],vn=ia("chart-no-axes-column-increasing",hn);function Et(t){return t==="wnba"?"Woman":"Man"}function ur(t,r){return r==="wowy"?"WOWY":`${r.charAt(0)} ${Et(t)}`}function yn(t,r){const o=r.charAt(0),f=Et(t).toUpperCase();return`${o}-${f} LINEUPS`}function jt(t,r){return`${r.charAt(0)}-${Et(t)}`}function dt(t,r){return`${r.charAt(0)}-${Et(t).toLowerCase()}`}function Wt(t,r){return`${jt(t,r)} Lineups`}function As(t){const r=Et(t).toLowerCase();return`2-${r} to 5-${r}`}function bn(t,r){return`No ${dt(t,r)} lineups`}function Wr(t){return t==="wnba"?"text-pink-400":"text-primary"}function Nn(t){return t==="wnba"?"text-pink-400/85":"text-primary/85"}function Bt(t){return t==="wnba"?"text-pink-400":"text-primary"}function Kt(t){return"text-secondary"}function jn(t){return t==="wnba"?"bg-pink-500/5":"bg-primary/5"}function wn(t){return t==="wnba"?"bg-card shadow-[inset_0_0_0_9999px_rgba(236,72,153,0.05)]":"bg-card shadow-[inset_0_0_0_9999px_hsl(var(--primary)/0.05)]"}function Fn(t){return t==="wnba"?"inline-flex items-center rounded-full border border-pink-500/40 bg-pink-500/10 px-2 py-0.5 font-semibold text-pink-400":"inline-flex items-center rounded-full border border-primary/40 bg-primary/10 px-2 py-0.5 font-semibold text-primary"}function Ur(t){return t==="wnba"?"bg-pink-500/25":"bg-primary/25"}const De=t=>typeof t=="number"&&Number.isFinite(t),at=(t,r,o)=>Math.min(o,Math.max(r,t)),Ve=(t,r)=>{if(!(!Number.isFinite(t)||!Number.isFinite(r)||r<=0))return t/r*100},Yt=({fg2a:t,fg2m:r,fg3a:o,fg3m:f,rimFga:m,rimFgm:i})=>{if(!De(t)||!De(r)||!De(o)||!De(f)||!De(m)||!De(i))return{};const l=t+o;if(!Number.isFinite(l)||l<=0)return{};const s=t-m,d=r-i,c=Ve(m,l),n=Ve(i,m),N=s>=0?Ve(s,l):void 0,y=s>0?Ve(d,s):void 0,W=Ve(o,l),E=Ve(f,o);return{rimFreq:c,rimFgPct:n,midFreq:N,midFgPct:y,threeFreq:W,threeFgPct:E}},Lr=({rimFreqPct:t,rimFgPct:r,threeFreqPct:o,fg2Pct:f})=>{if(!De(t)||!De(r)||!De(o)||!De(f))return{midFreqPct:void 0,midFgPct:void 0};const m=at(t/100,0,1),i=at(o/100,0,1),l=at(1-i,0,1),s=at(l-m,0,1);if(s<=0||l<=0)return{midFreqPct:s*100,midFgPct:void 0};
6const d=at(f/100,0,1),c=at(r/100,0,1),n=at((d*l-c*m)/s,0,1);return{midFreqPct:s*100,midFgPct:n*100}},Gt=({fg2a:t,fg3a:r,arc3Fga:o,arc3Fgm:f,corner3Fga:m,corner3Fgm:i})=>{if(!De(t)||!De(r)||!De(o)||!De(f)||!De(m)||!De(i))return{};const l=t+r;return!Number.isFinite(l)||l<=0?{}:{arc3Freq:Ve(o,l),arc3FgPct:Ve(f,o),corner3Freq:Ve(m,l),corner3FgPct:Ve(i,m)}},He=(t,r)=>{if(!(!De(t)||!De(r)))return t-r},Ar=({rimFreqPct:t,rimFgPct:r,threeFreqPct:o,threeFgPct:f,fg2Pct:m})=>{const{midFreqPct:i,midFgPct:l}=Lr({rimFreqPct:t,rimFgPct:r,threeFreqPct:o,fg2Pct:m});return{rimFreq:t,rimFgPct:r,midFreq:i,midFgPct:l,threeFreq:o,threeFgPct:f}},ae=(t,r=0)=>{if(t==null)return r;const o=typeof t=="string"?parseFloat(t):t;return Number.isFinite(o)?o:r},zr={PG:0,SG:1,SF:2,PF:3,C:4,G:1,F:3},Vr=t=>{const r=(t.Pos2||"").toUpperCase();if(!r)return 99;const o=r.split(/[^A-Z0-9]+/).filter(Boolean),f=new Set(o);for(const m of["PG","SG","SF","PF","C","G","F"])if(f.has(m))return zr[m];for(const m of["PG","SG","SF","PF","C","G","F"])if(r.includes(m))return zr[m];return 99},it=t=>typeof t=="number"&&Number.isFinite(t),Rt=(t,r)=>{const o=Vr(t)-Vr(r);if(o!==0)return o;const f=t.d_dpm,m=r.d_dpm;return it(f)&&it(m)&&f!==m?m-f:it(f)&&!it(m)?-1:!it(f)&&it(m)?1:t.name.localeCompare(r.name)};async function Dr(t,r,o=0,f=0,m="wowy",i=[]){const l=performance.now();if(console.debug(`[wowyCalculator] Starting calculations for mode: ${m}`),!t.length)return[];if(m==="wowy"){if(!r.length)return[];const n=On(t,r,o,f),N=performance.now();return console.debug(`[wowyCalculator] WOWY calculation completed in ${(N-l).toFixed(1)}ms. Generated ${n.length} combinations.`),n}const s=parseInt(m.charAt(0));if(isNaN(s)||s<2||s>5)return console.error(`[wowyCalculator] Invalid lineup size: ${m}`),[];const d=await Cn(t,r,s,o,f,i),c=performance.now();return console.debug(`[wowyCalculator] ${m} calculation completed in ${(c-l).toFixed(1)}ms. Generated ${d.length} combinations.`),d}function On(t,r,o=0,f=0){const m=[...r].sort(Rt);new Set(r.map(c=>c.nba_id.toString()));const i=t.filter(c=>!!(c!=null&&c.EntityId)),l=new Map;let s=0;i.forEach(c=>{const n=c.EntityId.split("-"),N=new Set(n),y=[],W=[];for(const w of r)N.has(w.nba_id.toString())?y.push(w):W.push(w);if(r.length>=4){if(r.length===5){if(!(y.length===5||y.length===4))return}else if(r.length===4&&!(y.length===4||y.length===3))return}let E;y.length===0?E="none":y.length===1?E=y[0].nba_id.toString():E=y.map(L=>parseInt(L.nba_id)).sort((L,be)=>L-be).join("-");const S=Number(c.OffPoss)||0,j=Number(c.DefPoss)||0,A=Number(c.Points)||0,T=Number(c.OpponentPoints)||0,p=Number(c.Minutes)||0;if(p===0)return;const F=Math.max(S,.001),ie=Math.max(j,.001),$=ae(c.o_ts)*100,G=ae(c.o_tov),M=G/F*100,ge=ae(c.o_orb)*100,te=ae(c.d_ts)*100,oe=ae(c.d_tov),ce=oe/ie*100,K=ae(c.d_orb)*100,b=Number(c.arc3fgm)||0,X=Number(c.arc3fga)||0,V=Number(c.corner3fgm)||0,me=Number(c.corner3fga)||0,ve=Number(c.fg3m)||0,z=Number(c.fg3a)||0,Ce=Number(c.fg2m)||0,le=Number(c.fg2a)||0,je=Number(c.rimfgm)||0,Y=Number(c.rimfga)||0,xe=Number(c.d_fg3m)||0,pe=Number(c.d_fg3a)||0,Fe=Number(c.d_fg2m)||0,Oe=Number(c.d_fg2a)||0,k=Number(c.d_rimfgm)||0,H=Number(c.d_rimfga)||0,_e=Number(c.shotqualityavg)||0,J=X>0?b/X*100:0,D=me>0?V/me*100:0,g=z>0?ve/z*100:0,O=Number(c.lg_avg_ortg)||0,Z=A/F*100,R=T/ie*100,U=Z-R,ue=Z-O,re=(R-O)*-1,we=ue+re,fe=Number(c.d_arc3fgm)||0,he=Number(c.d_arc3fga)||0,P=Number(c.d_corner3fgm)||0,I=Number(c.d_corner3fga)||0,ee=Number(c.lg_avg_arc)||0,ye=Number(c.lg_avg_corner)||0,Te=Number(c.lg_avg_three)||0,$e=Number(c.lg_avg_rim_freq)*100||0,Me=Number(c.lg_avg_rim_acc)*100||0,ke=Number(c.lg_avg_3p_freq)*100||0,We=Number(c.lg_avg_corner_freq)*100||0,de=Number(c.lg_avg_fg2_pct)*100||0,Se=he*ee,qe=I*ye,Pe=fe+P,Le=(Se+qe-Pe)*3,Ke=Le/F*2*100,Ye=Le*.9,a=(T+Ye)/ie*100,v=(a-O)*-1,C=he+I,q=C>0?(Se+qe)/C*100:0,u=l.get(E);if(u){u.total_points_for+=A,u.total_points_against+=T,u.total_off_poss+=S,u.total_def_poss+=j,u.minutes+=p,u.rel_off=(u.rel_off*u.possessions+ue*S)/(u.possessions+S),u.rel_def=(u.rel_def*u.possessions+re*j)/(u.possessions+j),u.rel_net=u.rel_off+u.rel_def,u.lg_avg_ortg=((u.lg_avg_ortg||0)*u.possessions+O*S)/(u.possessions+S),u.lg_avg_ts=((u.lg_avg_ts||0)*u.possessions+(Number(c.lg_avg_ts)*100||0)*S)/(u.possessions+S),u.lg_avg_tov=((u.lg_avg_tov||0)*u.possessions+(Number(c.lg_avg_tov)*100||0)*S)/(u.possessions+S),u.lg_avg_orb=((u.lg_avg_orb||0)*u.possessions+(Number(c.lg_avg_orb)*100||0)*S)/(u.possessions+S);const w=u.possessions+S,L=u.possessions+j;if(w>0){u.ts_pct=(u.ts_pct*u.possessions+$*S)/w;const Ee=u.tov_pct/100*u.possessions+G;u.tov_pct=Ee/w*100,u.orb_pct=(u.orb_pct*u.possessions+ge*S)/w}if(L>0){u.opp_ts_pct=(u.opp_ts_pct*u.possessions+te*j)/L;const Ee=u.opp_tov_pct/100*u.possessions+oe;u.opp_tov_pct=Ee/L*100,u.opp_orb_pct=(u.opp_orb_pct*u.possessions+K*j)/L}if(u.fg3_pct!==void 0&&z>0&&(u.total_fg3m+=ve,u.total_fg3a+=z,u.fg3_pct=u.total_fg3m/u.total_fg3a*100),u.total_fg2m+=Ce,u.total_fg2a+=le,u.total_rimfgm+=je,u.total_rimfga+=Y,w>0){const se=u.shot_quality??0;u.shot_quality=(se*u.possessions+_e*S)/w}u.total_d_fg3m+=xe,u.total_d_fg3a+=pe,u.total_d_fg2m+=Fe,u.total_d_fg2a+=Oe,u.total_d_rimfgm+=k,u.total_d_rimfga+=H;const be=u.total_d_arc3fga+he;if(be>0){const se=u.lg_avg_arc??ee;u.lg_avg_arc=(se*u.total_d_arc3fga+ee*he)/be}else u.lg_avg_arc=ee;
6const Ae=u.total_d_corner3fga+I;if(Ae>0){const se=u.lg_avg_corner??ye;u.lg_avg_corner=(se*u.total_d_corner3fga+ye*I)/Ae}else u.lg_avg_corner=ye;u.total_d_arc3fgm+=fe,u.total_d_arc3fga+=he,u.total_d_corner3fgm+=P,u.total_d_corner3fga+=I,u.total_arc3fgm+=b,u.total_arc3fga+=X,u.total_corner3fgm+=V,u.total_corner3fga+=me,u.arc3_pct=u.total_arc3fga>0?u.total_arc3fgm/u.total_arc3fga*100:0,u.corner3_pct=u.total_corner3fga>0?u.total_corner3fgm/u.total_corner3fga*100:0,u.lg_avg_three=((u.lg_avg_three||0)*u.possessions+Te*100*S)/(u.possessions+S),u.lg_avg_rim_freq=((u.lg_avg_rim_freq||0)*u.possessions+$e*S)/(u.possessions+S),u.lg_avg_rim_acc=((u.lg_avg_rim_acc||0)*u.possessions+Me*S)/(u.possessions+S),u.lg_avg_3p_freq=((u.lg_avg_3p_freq||0)*u.possessions+ke*S)/(u.possessions+S),u.lg_avg_corner_freq=((u.lg_avg_corner_freq||0)*u.possessions+We*S)/(u.possessions+S),u.lg_avg_fg2_pct=((u.lg_avg_fg2_pct||0)*u.possessions+de*S)/(u.possessions+S),u.possessions+=S}else{const w=[...y].sort(Rt),L=[...W].sort(Rt);l.set(E,{id:s++,players:m,on_players:w,off_players:L,off:Z,def:R,net:U,rel_off:ue,rel_def:re,rel_net:we,possessions:S,minutes:p,ts_pct:$,tov_pct:M,orb_pct:ge,opp_ts_pct:te,opp_tov_pct:ce,opp_orb_pct:K,arc3_pct:J,corner3_pct:D,fg3_pct:g,shot_quality:_e,total_fg3m:ve,total_fg3a:z,total_fg2m:Ce,total_fg2a:le,total_rimfgm:je,total_rimfga:Y,total_d_fg3m:xe,total_d_fg3a:pe,total_d_fg2m:Fe,total_d_fg2a:Oe,total_d_rimfgm:k,total_d_rimfga:H,lg_avg_ortg:O,lg_avg_ts:Number(c.lg_avg_ts)*100||0,lg_avg_tov:Number(c.lg_avg_tov)*100||0,lg_avg_orb:Number(c.lg_avg_orb)*100||0,lg_avg_three:Te*100||0,lg_avg_rim_freq:$e,lg_avg_rim_acc:Me,lg_avg_3p_freq:ke,lg_avg_corner_freq:We,lg_avg_fg2_pct:de,luckadj_def:a,luckadj_rel_def:v,luckadj_3p:q,luckadj_d_ts_impact:Ke,total_d_arc3fgm:fe,total_d_arc3fga:he,total_d_corner3fgm:P,total_d_corner3fga:I,total_arc3fgm:b,total_arc3fga:X,total_corner3fgm:V,total_corner3fga:me,total_points_for:A,total_points_against:T,total_off_poss:S,total_def_poss:j,lg_avg_arc:ee,lg_avg_corner:ye})}});const d=Array.from(l.values()).map(c=>{const n=c.total_d_arc3fga*(c.lg_avg_arc||.36),N=c.total_d_corner3fga*(c.lg_avg_corner||.36),y=c.total_d_arc3fgm+c.total_d_corner3fgm,S=(n+N-y)*3,j=S/c.total_def_poss/2*100,A=S*.9,p=(c.total_points_against+A)/c.total_def_poss*100,F=(p-(c.lg_avg_ortg||0))*-1,ie=c.total_points_against*100/c.total_def_poss,$=c.total_d_arc3fga+c.total_d_corner3fga,G=$>0?(c.total_d_arc3fgm+c.total_d_corner3fgm)/$*100:0,M=$>0?(n+N)/$*100:0,ge=c.total_arc3fga*(c.lg_avg_arc||.36),te=c.total_corner3fga*(c.lg_avg_corner||.39),oe=c.total_arc3fgm+c.total_corner3fgm,b=(ge+te-oe)*3,X=b/c.total_off_poss/2*100,V=b*.9,ve=(c.total_points_for+V)/c.total_off_poss*100,z=ve-(c.lg_avg_ortg||0),Ce=c.total_points_for*100/c.total_off_poss,le=c.total_arc3fga+c.total_corner3fga,je=le>0?(c.total_arc3fgm+c.total_corner3fgm)/le*100:0,Y=le>0?(ge+te)/le*100:0,xe=o/100,pe=f/100,Fe=Yt({fg2a:c.total_fg2a,fg2m:c.total_fg2m,fg3a:c.total_fg3a,fg3m:c.total_fg3m,rimFga:c.total_rimfga,rimFgm:c.total_rimfgm}),Oe=Yt({fg2a:c.total_d_fg2a,fg2m:c.total_d_fg2m,fg3a:c.total_d_fg3a,fg3m:c.total_d_fg3m,rimFga:c.total_d_rimfga,rimFgm:c.total_d_rimfgm}),k=Gt({fg2a:c.total_fg2a,fg3a:c.total_fg3a,arc3Fga:c.total_arc3fga,arc3Fgm:c.total_arc3fgm,corner3Fga:c.total_corner3fga,corner3Fgm:c.total_corner3fgm}),H=Gt({fg2a:c.total_d_fg2a,fg3a:c.total_d_fg3a,arc3Fga:c.total_d_arc3fga,arc3Fgm:c.total_d_arc3fgm,corner3Fga:c.total_d_corner3fga,corner3Fgm:c.total_d_corner3fgm}),{midFreqPct:_e,midFgPct:J}=Lr({rimFreqPct:c.lg_avg_rim_freq,rimFgPct:c.lg_avg_rim_acc,threeFreqPct:c.lg_avg_3p_freq,fg2Pct:c.lg_avg_fg2_pct}),D=pe*ve+(1-pe)*Ce,g=xe*p+(1-xe)*ie;return{...c,ts_pct:c.ts_pct+pe*X,off:D,rel_off:pe*z+(1-pe)*c.rel_off,off_3p_pct:pe*Y+(1-pe)*je,opp_ts_pct:c.opp_ts_pct+xe*j,def:g,rel_def:xe*F+(1-xe)*c.rel_def,fg3_pct:xe*M+(1-xe)*G,def_3p_pct:xe*M+(1-xe)*G,net:D-g,off_rim_freq:Fe.rimFreq,off_rim_fg_pct:Fe.rimFgPct,off_mid_freq:Fe.midFreq,off_mid_fg_pct:Fe.midFgPct,off_3p_freq:Fe.threeFreq,off_arc3_freq:k.arc3Freq,off_arc3_fg_pct:k.arc3FgPct,off_corner3_freq:k.corner3Freq,off_corner3_fg_pct:k.corner3FgPct,def_rim_freq:Oe.rimFreq,def_rim_fg_pct:Oe.rimFgPct,def_mid_freq:Oe.midFreq,def_mid_fg_pct:Oe.midFgPct,def_3p_freq:Oe.threeFreq,def_arc3_freq:H.arc3Freq,def_arc3_fg_pct:H.arc3FgPct,def_corner3_freq:H.corner3Freq,def_corner3_fg_pct:H.corner3FgPct,lg_avg_mid_freq:_e,lg_avg_mid_acc:J}}).sort((c,n)=>n.net-c.net);return d.length>
61&&console.log("[wowyCalculator] Second combination stats:",JSON.stringify(d[1],null,2)),d}async function Pn(t){if(!t.length)return{};try{console.log(`[wowyCalculator] Fetching names for ${t.length} players from Supabase`);const{data:r,error:o}=await la.from("index_master").select("nba_id, player").in("nba_id",t.map(m=>parseInt(m))).order("year",{ascending:!1});if(o)return console.error("[wowyCalculator] Error fetching player names:",o),{};const f={};return r==null||r.forEach(m=>{const i=m.nba_id.toString();!f[i]&&m.player&&(f[i]=m.player)}),console.log(`[wowyCalculator] Retrieved names for ${Object.keys(f).length} players`),f}catch(r){return console.error("[wowyCalculator] Error in getPlayerNamesByIds:",r),{}}}async function Cn(t,r,o,f=0,m=0,i=[]){console.log(`[wowyCalculator] Calculating ${o}-man lineups`);const l=new Map;r.forEach(j=>{l.set(j.nba_id.toString(),j)}),i.forEach(j=>{l.has(j.nba_id.toString())||l.set(j.nba_id.toString(),j)}),console.log(`[wowyCalculator] Using player map with ${l.size} players`);const s=new Map,d=new Map;t.forEach(j=>{if(!j.EntityId)return;const A=j.EntityId.split("-");if(A.length===0)return;Sn(A,o,s);const T=Number(j.Minutes)||0;if(T===0)return;const p=Math.max(Number(j.OffPoss)||0,1),F=Math.max(Number(j.DefPoss)||0,1);if(p===0||F===0)return;const ie=A.sort((G,M)=>G.localeCompare(M)).join("-");(s.get(ie)||new Set).forEach(G=>{const M=d.get(G)||{minutes:0,pointsFor:0,pointsAgainst:0,offPoss:0,defPoss:0,o_ts:0,o_tov:0,o_orb:0,d_ts:0,d_tov:0,d_orb:0,total_fg3m:0,total_fg3a:0,total_fg2m:0,total_fg2a:0,total_rimfgm:0,total_rimfga:0,total_d_fg3m:0,total_d_fg3a:0,total_d_fg2m:0,total_d_fg2a:0,total_d_rimfgm:0,total_d_rimfga:0,total_d_arc3fgm:0,total_d_arc3fga:0,total_d_corner3fgm:0,total_d_corner3fga:0,total_arc3fgm:0,total_arc3fga:0,total_corner3fgm:0,total_corner3fga:0,occurrences:0,lg_avg_ortg:0,lg_avg_ts:0,lg_avg_tov:0,lg_avg_orb:0,lg_avg_arc:0,lg_avg_corner:0,lg_avg_three:0,lg_avg_rim_freq:0,lg_avg_rim_acc:0,lg_avg_3p_freq:0,lg_avg_corner_freq:0,lg_avg_fg2_pct:0};M.minutes+=T,M.pointsFor+=ae(j.Points),M.pointsAgainst+=ae(j.OpponentPoints),M.offPoss+=p,M.defPoss+=F;const ge=ae(j.o_ts),te=ae(j.o_tov),oe=ae(j.o_orb),ce=ae(j.d_ts),K=ae(j.d_tov),b=ae(j.d_orb);M.o_ts+=ge*p,M.o_tov+=te,M.o_orb+=oe*p,M.d_ts+=ce*F,M.d_tov+=K,M.d_orb+=b*F,M.total_fg3m+=ae(j.fg3m),M.total_fg3a+=ae(j.fg3a),M.total_fg2m+=ae(j.fg2m),M.total_fg2a+=ae(j.fg2a),M.total_rimfgm+=ae(j.rimfgm),M.total_rimfga+=ae(j.rimfga),M.total_d_fg3m+=ae(j.d_fg3m),M.total_d_fg3a+=ae(j.d_fg3a),M.total_d_fg2m+=ae(j.d_fg2m),M.total_d_fg2a+=ae(j.d_fg2a),M.total_d_rimfgm+=ae(j.d_rimfgm),M.total_d_rimfga+=ae(j.d_rimfga),M.total_d_arc3fgm+=ae(j.d_arc3fgm),M.total_d_arc3fga+=ae(j.d_arc3fga),M.total_d_corner3fgm+=ae(j.d_corner3fgm),M.total_d_corner3fga+=ae(j.d_corner3fga),M.total_arc3fgm+=ae(j.arc3fgm),M.total_arc3fga+=ae(j.arc3fga),M.total_corner3fgm+=ae(j.corner3fgm),M.total_corner3fga+=ae(j.corner3fga),M.lg_avg_ortg+=ae(j.lg_avg_ortg)*p,M.lg_avg_ts+=ae(j.lg_avg_ts)*p,M.lg_avg_tov+=ae(j.lg_avg_tov)*p,M.lg_avg_orb+=ae(j.lg_avg_orb)*p,M.lg_avg_arc+=ae(j.lg_avg_arc)*ae(j.d_arc3fga),M.lg_avg_corner+=ae(j.lg_avg_corner)*ae(j.d_corner3fga),M.lg_avg_three+=ae(j.lg_avg_three)*p,M.lg_avg_rim_freq+=ae(j.lg_avg_rim_freq)*p,M.lg_avg_rim_acc+=ae(j.lg_avg_rim_acc)*p,M.lg_avg_3p_freq+=ae(j.lg_avg_3p_freq)*p,M.lg_avg_corner_freq+=ae(j.lg_avg_corner_freq)*p,M.lg_avg_fg2_pct+=ae(j.lg_avg_fg2_pct)*p,M.occurrences+=1,d.set(G,M)})});const c=[];let n=0;const N=r.map(j=>j.nba_id.toString()),y=Array.from(d.entries()).sort((j,A)=>A[1].minutes-j[1].minutes);console.log("[wowyCalculator] Top 5 lineups by minutes:"),y.slice(0,5).forEach((j,A)=>{const[T,p]=j;console.log(` ${A+1}. ${T}: ${p.minutes.toFixed(1)} minutes`)});const W=[];if(N.length>0){console.log(`[wowyCalculator] Filtering for lineups containing selected players: ${N.join(", ")}`);const j=y.filter(([A])=>{const T=A.split("-");return N.every(p=>T.includes(p))});if(j.length>0)console.log(`[wowyCalculator] Found ${j.length} lineups containing ALL selected players`),W.push(...j);else if(N.length>1){console.log("[wowyCalculator] No lineups with ALL selected players found, looking for ANY");const A=y.filter(([T])=>{const p=T.split("-");return N.some(F=>p.includes(F))});A.length>0&&(console.log(`[wowyCalculator] Found ${A.length} lineups containing SOME selected players`),W.push(...A))}}const E=W.length>0?W:y;return await(async()=>{const j=[];for(const[T,p]of E){if(p.minutes<5)continue;const F=T.split("-");for(const ie of F)l.has(ie)||j.push(ie)}let A={};j.length>0&&(A=await Pn(j));for(const[T,p]of E){if(p.minutes<5)continue;const F=T.split("-"),ie=[];for(const w of F){const L=l.get(w);if(L)ie.push(L);else{const be=A[w]||`Player #${w}`;
6ie.push({id:parseInt(w),name:be,nba_id:w,year:0,vpm:0})}}const $=p.pointsFor/p.offPoss*100,G=p.pointsAgainst/p.defPoss*100,M=p.offPoss>0?p.o_ts/p.offPoss*100:0,ge=p.offPoss>0?p.o_tov/p.offPoss*100:0,te=p.offPoss>0?p.o_orb/p.offPoss*100:0,oe=p.defPoss>0?p.d_ts/p.defPoss*100:0,ce=p.defPoss>0?p.d_tov/p.defPoss*100:0,K=p.defPoss>0?p.d_orb/p.defPoss*100:0;p.total_fg3a>0&&p.total_fg3m/p.total_fg3a*100;const b=p.offPoss>0?p.lg_avg_ortg/p.offPoss:0,X=p.offPoss>0?p.lg_avg_ts/p.offPoss*100:0,V=p.offPoss>0?p.lg_avg_tov/p.offPoss*100:0,me=p.offPoss>0?p.lg_avg_orb/p.offPoss*100:0,ve=p.offPoss>0?p.lg_avg_three/p.offPoss*100:0,z=p.offPoss>0?p.lg_avg_rim_freq/p.offPoss*100:0,Ce=p.offPoss>0?p.lg_avg_rim_acc/p.offPoss*100:0,le=p.offPoss>0?p.lg_avg_3p_freq/p.offPoss*100:0,je=p.offPoss>0?p.lg_avg_corner_freq/p.offPoss*100:0,Y=p.offPoss>0?p.lg_avg_fg2_pct/p.offPoss*100:0,xe=$-b,pe=(G-b)*-1,Fe=p.lg_avg_arc/Math.max(p.total_d_arc3fga,1),Oe=p.lg_avg_corner/Math.max(p.total_d_corner3fga,1),{midFreqPct:k,midFgPct:H}=Lr({rimFreqPct:z,rimFgPct:Ce,threeFreqPct:le,fg2Pct:Y}),_e=p.total_d_arc3fga*(Fe||.36),J=p.total_d_corner3fga*(Oe||.36),D=p.total_d_arc3fgm+p.total_d_corner3fgm,Z=(_e+J-D)*3,R=Z/p.defPoss/2*100,U=Z*.9,re=(p.pointsAgainst+U)/p.defPoss*100,we=(re-b)*-1,fe=p.total_d_arc3fga+p.total_d_corner3fga,he=fe>0?(p.total_d_arc3fgm+p.total_d_corner3fgm)/fe*100:0,P=fe>0?(_e+J)/fe*100:0,I=p.total_arc3fga*(Fe||.36),ee=p.total_corner3fga*(Oe||.39),ye=p.total_arc3fgm+p.total_corner3fgm,Me=(I+ee-ye)*3,ke=Me/p.offPoss/2*100,We=Me*.9,Se=(p.pointsFor+We)/p.offPoss*100,qe=Se-b,Pe=p.total_arc3fga+p.total_corner3fga,Ge=Pe>0?(p.total_arc3fgm+p.total_corner3fgm)/Pe*100:0,Re=Pe>0?(I+ee)/Pe*100:0,Le=Yt({fg2a:p.total_fg2a,fg2m:p.total_fg2m,fg3a:p.total_fg3a,fg3m:p.total_fg3m,rimFga:p.total_rimfga,rimFgm:p.total_rimfgm}),Ke=Yt({fg2a:p.total_d_fg2a,fg2m:p.total_d_fg2m,fg3a:p.total_d_fg3a,fg3m:p.total_d_fg3m,rimFga:p.total_d_rimfga,rimFgm:p.total_d_rimfgm}),Ye=Gt({fg2a:p.total_fg2a,fg3a:p.total_fg3a,arc3Fga:p.total_arc3fga,arc3Fgm:p.total_arc3fgm,corner3Fga:p.total_corner3fga,corner3Fgm:p.total_corner3fgm}),x=Gt({fg2a:p.total_d_fg2a,fg3a:p.total_d_fg3a,arc3Fga:p.total_d_arc3fga,arc3Fgm:p.total_d_arc3fgm,corner3Fga:p.total_d_corner3fga,corner3Fgm:p.total_d_corner3fgm}),a=f/100,v=m/100,C=v*Se+(1-v)*$,q=a*re+(1-a)*G,u=[...ie].sort(Rt);c.push({id:n++,players:u,on_players:u,off_players:[],off:C,def:q,net:C-q,rel_off:v*qe+(1-v)*xe,rel_def:a*we+(1-a)*pe,rel_net:v*qe+(1-v)*xe+(a*we+(1-a)*pe),possessions:p.offPoss,minutes:p.minutes,ts_pct:M+v*ke,tov_pct:ge,orb_pct:te,opp_ts_pct:oe+a*R,opp_tov_pct:ce,opp_orb_pct:K,fg3_pct:a*P+(1-a)*he,def_3p_pct:a*P+(1-a)*he,off_3p_pct:v*Re+(1-v)*Ge,total_fg3m:p.total_fg3m,total_fg3a:p.total_fg3a,total_fg2m:p.total_fg2m,total_fg2a:p.total_fg2a,total_rimfgm:p.total_rimfgm,total_rimfga:p.total_rimfga,total_d_fg3m:p.total_d_fg3m,total_d_fg3a:p.total_d_fg3a,total_d_fg2m:p.total_d_fg2m,total_d_fg2a:p.total_d_fg2a,total_d_rimfgm:p.total_d_rimfgm,total_d_rimfga:p.total_d_rimfga,lg_avg_ortg:b,lg_avg_ts:X,lg_avg_tov:V,lg_avg_orb:me,lg_avg_three:ve,lg_avg_rim_freq:z,lg_avg_rim_acc:Ce,lg_avg_3p_freq:le,lg_avg_corner_freq:je,lg_avg_fg2_pct:Y,lg_avg_mid_freq:k,lg_avg_mid_acc:H,luckadj_def:re,luckadj_rel_def:we,luckadj_3p:P,luckadj_d_ts_impact:R,total_d_arc3fgm:p.total_d_arc3fgm,total_d_arc3fga:p.total_d_arc3fga,total_d_corner3fgm:p.total_d_corner3fgm,total_d_corner3fga:p.total_d_corner3fga,total_arc3fgm:p.total_arc3fgm,total_arc3fga:p.total_arc3fga,total_corner3fgm:p.total_corner3fgm,total_corner3fga:p.total_corner3fga,off_rim_freq:Le.rimFreq,off_rim_fg_pct:Le.rimFgPct,off_mid_freq:Le.midFreq,off_mid_fg_pct:Le.midFgPct,off_3p_freq:Le.threeFreq,off_arc3_freq:Ye.arc3Freq,off_arc3_fg_pct:Ye.arc3FgPct,off_corner3_freq:Ye.corner3Freq,off_corner3_fg_pct:Ye.corner3FgPct,def_rim_freq:Ke.rimFreq,def_rim_fg_pct:Ke.rimFgPct,def_mid_freq:Ke.midFreq,def_mid_fg_pct:Ke.midFgPct,def_3p_freq:Ke.threeFreq,def_arc3_freq:x.arc3Freq,def_arc3_fg_pct:x.arc3FgPct,def_corner3_freq:x.corner3Freq,def_corner3_fg_pct:x.corner3FgPct,total_points_for:p.pointsFor,total_points_against:p.pointsAgainst,total_off_poss:p.offPoss,total_def_poss:p.defPoss,lg_avg_arc:Fe,lg_avg_corner:Oe})}})(),c.length>
61&&console.log("[wowyCalculator N-Man] Second combination stats:",JSON.stringify(c[1],null,2)),c}function Sn(t,r,o){if(t.length<r)return;if(t.length===r){const i=[...t].sort((d,c)=>d.localeCompare(c)).join("-"),l=t.sort((d,c)=>d.localeCompare(c)).join("-"),s=o.get(l)||new Set;s.add(i),o.set(l,s);return}function f(m,i){if(i.length===r){const s=[...i].sort((n,N)=>n.localeCompare(N)).join("-"),d=t.sort((n,N)=>n.localeCompare(N)).join("-"),c=o.get(d)||new Set;c.add(s),o.set(d,c);return}for(let l=m;l<t.length;l++)i.push(t[l]),f(l+1,i),i.pop()}f(0,[])}const Tn=!1,Lt=(t,r)=>{if(t==null)return r;const o=parseInt(t,10);return isNaN(o)?r:o},Qr=["regular","playoffs","all"],Xr=["high","all"],Jt=["wowy","2man","3man","4man","5man"],En="regular",qn="high",kn="wowy",Jr=2,Mn=300,Zr="player-replacement-mode",es="force-player-removal",ts={players:[],playerMetricsByYear:{}},Wn=t=>new Promise(r=>{window.setTimeout(r,t)}),Ln=t=>{const r={};return t.forEach(o=>{const f=o.nba_id.toString(),m=Number(o.year);Number.isFinite(m)&&(r[f]||(r[f]={}),r[f][m]={dpm:o.dpm??null,o_dpm:o.o_dpm??null,d_dpm:o.d_dpm??null})}),r};function An(t={}){const{league:r="nba",basePath:o="/wowy"}=t,f=_.useMemo(()=>Ta(r),[r]),m=Os(),i=Fs(),l=da(),s=Nr(),d=jr(),c=_.useRef(!1),n=_.useRef(null),N=Ir(l.teamAbbr??"",r),[y,W]=_.useState(N&&f[N]?N:null),[E,S]=_.useState([]),j=Math.min(i,Lt(l.startYear,m)),A=Math.min(i,Lt(l.endYear,m)),[T,p]=_.useState(Math.min(j,A)),[F,ie]=_.useState(Math.max(j,A)),[$,G]=_.useState(Qr.includes(l.seasonType)?l.seasonType:En),[M,ge]=_.useState(lr(r,Xr.includes(l.leverageFilter)?l.leverageFilter:r==="wnba"?"all":qn)),te=_.useCallback(a=>{ge(lr(r,a))},[r]),[oe,ce]=_.useState(Jt.includes(l.lineupMode)?l.lineupMode:kn),[K,b]=_.useState([]),[X,V]=_.useState([]),[me,ve]=_.useState(10),[z,Ce]=_.useState(!1),[le,je]=_.useState(null),[Y,xe]=_.useState(!N||!f[N]),[pe,Fe]=_.useState(!1),[Oe,k]=_.useState(!1),[H,_e]=_.useState(0),[J,D]=_.useState(0),[g,O]=_.useState(!0),Z=_.useRef(0),R=_.useMemo(()=>{const a=d.pathname.split("/").filter(Boolean),v=a.findIndex(C=>Jt.includes(C));return v<0?[]:a.slice(v+1).filter(C=>C&&!Number.isNaN(Number.parseInt(C,10))).map(C=>Number.parseInt(C,10))},[d.pathname]);_.useEffect(()=>{const a=()=>k(window.innerWidth>=640);a(),window.addEventListener("resize",a);const v=C=>{const q=C.target;if(!(q&&(q.isContentEditable||q.tagName==="INPUT"||q.tagName==="TEXTAREA"||q.tagName==="SELECT")||C.defaultPrevented||q!=null&&q.closest('[role="dialog"]'))){if(C.code==="Digit2"||C.code==="Numpad2"||C.key==="2"){Y||Ce(!1),xe(!Y);return}C.key==="Escape"&&!Y&&S([])}};return window.addEventListener("keydown",v),()=>{window.removeEventListener("resize",a),window.removeEventListener("keydown",v)}},[Y]),_.useEffect(()=>{const a=v=>{Fe(v.detail.active),console.log(`[useWowy] Replacement mode changed to: ${v.detail.active}`)};return window.addEventListener(Zr,a),()=>window.removeEventListener(Zr,a)},[]),_.useEffect(()=>{const a=v=>{const C=v.detail.player;console.log(`[useWowy] Force removing player: ${C.name}`),S(q=>q.filter(u=>u.nba_id!==C.nba_id))};return window.addEventListener(es,a),()=>window.removeEventListener(es,a)},[]),_.useEffect(()=>{if(!c.current){if(l.teamAbbr){console.log("[useWowy] Initializing from URL params:",l);const a=Ir(l.teamAbbr,r);a&&f[a]&&(W(a),xe(!1),Ce(!1));let v=Math.min(i,Lt(l.startYear,m)),C=Math.min(i,Lt(l.endYear,m));if(v>C){const q=v;v=C,C=q}p(v),ie(C),l.seasonType&&Qr.includes(l.seasonType)&&G(l.seasonType),l.leverageFilter&&Xr.includes(l.leverageFilter)?te(l.leverageFilter):r==="wnba"&&te("all"),l.lineupMode&&Jt.includes(l.lineupMode)&&ce(l.lineupMode)}else console.log("[useWowy] No URL params - normal onboarding flow");c.current=!0}},[]);const{data:U=[],isLoading:ue}=yt({queryKey:["players",r,y,F,$],queryFn:async()=>y?dr(y,F,$,r):[],enabled:!!y&&g,staleTime:5*60*1e3,retry:3,retryDelay:200,placeholderData:Qt}),re=!!y&&g&&T!==F&&(oe!=="wowy"||E.length>0||R.length>0),{data:we=ts}=yt({queryKey:["all-years-players",r,y,T,F,$],queryFn:async()=>{if(!y)return ts;const v=Array.from({length:F-T+1},(w,L)=>T+L).map(w=>dr(y,w,$,r)),C=await Promise.all(v),q=new Map,u={};
6return C.flat().forEach(w=>{const L=w.nba_id.toString();q.has(L)||q.set(L,w);const be=Number(w.year);Number.isFinite(be)&&(u[L]||(u[L]={}),u[L][be]={dpm:w.dpm??null,o_dpm:w.o_dpm??null,d_dpm:w.d_dpm??null})}),{players:Array.from(q.values()),playerMetricsByYear:u}},enabled:re,staleTime:10*60*1e3,retry:3,retryDelay:200,placeholderData:Qt}),fe=_.useMemo(()=>T===F?U:we.players,[T,F,U,we.players]),he=_.useMemo(()=>T===F?Ln(U):we.playerMetricsByYear,[T,F,U,we.playerMetricsByYear]),{data:P=[],isLoading:I,error:ee,isFetching:ye}=yt({queryKey:["wowy-stats",r,y,T,F,$,M],queryFn:async({signal:a})=>{if(!y)return[];const v=Array.from({length:F-T+1},(se,Ee)=>T+Ee).sort((se,Ee)=>Ee-se),C=f[y];if(!C)throw console.error(`[useWowy] Invalid team abbreviation: ${y}`),new Error(`Invalid team: ${y}`);const q=parseInt(C);if(r==="nba"){const se=await Ea(T,F,q,$,M,a,r);return console.log(`[useWowy] Total stats fetched: ${se.length}`),se}const u=se=>{const Ee=se==null?void 0:se.name,Ie=se==null?void 0:se.code;return Ee==="AbortError"||Ie==="ERR_CANCELED"},w=async se=>{let Ee=null;for(let Ie=1;Ie<=Jr;Ie+=1){if(a!=null&&a.aborted)throw new DOMException("Aborted","AbortError");try{const Ue=await Ps(se,q,$,M,a,r);return console.log(`[useWowy] Fetched ${Ue.length} stats for year ${se} on attempt ${Ie}`),Ue}catch(Ue){if(u(Ue))throw Ue;Ee=Ue,console.error(`[useWowy] Error fetching stats for year ${se} on attempt ${Ie}:`,Ue),Ie<Jr&&await Wn(Mn*Ie)}}throw Ee instanceof Error?Ee:new Error(`Failed to fetch WOWY stats for year ${se}`)},L=await Promise.allSettled(v.map(se=>w(se))),be=L.flatMap(se=>se.status==="fulfilled"?se.value:[]),Ae=L.map((se,Ee)=>({result:se,year:v[Ee]})).filter(se=>se.result.status==="rejected");if(Ae.length===v.length&&Ae.every(se=>se.result.status==="rejected"&&u(se.result.reason)))throw new DOMException("Aborted","AbortError");if(be.length===0&&Ae.length>0){const se=Ae[0].result;throw se.reason instanceof Error?se.reason:new Error("Failed to fetch WOWY stats")}return Ae.length>0&&console.warn(`[useWowy] ${Ae.length}/${v.length} year fetches failed; serving partial data`,Ae.map(se=>se.year)),console.log(`[useWowy] Total stats fetched: ${be.length}`),be},enabled:!!y&&g,staleTime:5*60*1e3,retry:2,retryDelay:a=>Math.min(1e3*2**a,4e3),refetchOnWindowFocus:!1,gcTime:10*60*1e3,placeholderData:Qt}),Te=F-T+1,$e=!!y&&oe==="wowy"&&E.length===0&&g&&Te>=1&&Te<=5,{data:Me=[],isLoading:ke}=yt({queryKey:["wowy-team-rapm",r,y,T,F,$],queryFn:async()=>y?qa(y,T,F,$,r):[],enabled:r==="nba"&&$e,staleTime:5*60*1e3,retry:3,retryDelay:200}),We=_.useRef(null),de=_.useCallback(()=>{b(a=>a.length>0?[]:a),V(a=>a.length>0?[]:a),ve(a=>a===10?a:10),We.current=null},[]),Se=_.useCallback(async(a=H,v=J,C=oe)=>{const q=++Z.current;if(!y){if(q!==Z.current)return;de();return}if(P.length===0){if(q!==Z.current)return;de();return}if(C!=="wowy"&&fe.length===0){console.log(`[useWowy] Skipping ${C} calculation until allYearsPlayers metadata is loaded`);return}const u=`${y}-${E.map(w=>w.nba_id).join(",")}-${a}-${v}-${C}-${T}-${F}-${M}-${$}-${P.length}`;if(u===We.current&&C==="wowy"){console.log("[useWowy] Skipping WOWY combination calculation - inputs unchanged");return}console.log(`[useWowy] Calculating combinations for mode: ${C}, using client-side calculation`);try{je(null);let w;if(Tn||(w=await Dr(P,E,a,v,C,fe)),q!==Z.current){console.log("[useWowy] Dropping stale combination result");return}if(C!=="wowy"){V(w);const L=10;ve(L),b(w.slice(0,L))}else V([]),ve(10),b(w);We.current=u}catch(w){if(q!==Z.current){console.log("[useWowy] Dropping stale combination error");return}console.error(`Error processing combinations in ${C} mode:`,w);const L=w instanceof Error?w.message:"Unknown calculation error";je(`Error processing combinations: ${L}`),de()}},[y,E,P,T,F,$,M,fe,f,H,J,oe,de]),qe=_.useRef(!1);_.useEffect(()=>{if(!c.current||!l.teamAbbr||qe.current)return;if(E.length>0){qe.current=!0;return}if(R.length===0){qe.current=!0;return}if(U.length===0||fe.length===0){console.log("[useWowy] Waiting for players to load before setting from URL...",{availablePlayers:U.length,allYearsPlayers:fe.length});return}console.log("[useWowy] Setting players from URL:",R);const a=R.map(v=>{let C=U.find(q=>Number(q.nba_id)===v);return C||(C=fe.find(q=>Number(q.nba_id)===v)),C}).filter(v=>v!==void 0);console.log("[useWowy] Players matched from URL:",a.length,a.map(v
6=>v.name)),a.length>0?S(a):console.warn("[useWowy] No players matched from URL IDs"),qe.current=!0},[l.teamAbbr,U,fe,R,E.length]),_.useEffect(()=>{if(!g){console.log("[useWowy] Skipping calculation: allowDataFetch is false.");return}if(g&&y)if(P.length>0){if(oe==="wowy"&&E.length===0){de();return}console.log("[useWowy] Triggering calculation due to state change"),Se(H,J,oe)}else de();else(!y||!g)&&de()},[g,y,E,P,H,J,oe,T,F,M,$,Se,de]),_.useEffect(()=>{if(!y||E.length===0||!fe||fe.length===0)return;const a=new Set(fe.map(C=>C.nba_id.toString())),v=E.filter(C=>!a.has(C.nba_id));v.length>0&&(console.log(`[useWowy] Removing ${v.length} players not found in range ${T}-${F}:`,v.map(C=>C.name)),S(C=>C.filter(q=>a.has(q.nba_id))))},[T,F,y,fe,E]);const Pe=_.useRef(null);_.useEffect(()=>{if(y!==null){if(Pe.current===null){Pe.current=y;return}Pe.current!==y&&(console.log("[useWowy] Team changed, resetting players and combinations."),S([]),b([]),V([]),ve(10),Pe.current=y)}},[y]),_.useEffect(()=>{ee?(console.error("[useWowy] WOWY stats query error:",ee),je("Error loading player combinations. Please try again.")):!I&&!ye&&(le!=null&&le.startsWith("Error loading"))&&je(null)},[ee,I,ye,le]);const Ge=_.useCallback(a=>{console.log("[useWowy] Team selected:",a),W(a),xe(!1),Ce(!0)},[]),Re=_.useRef(null),Le=_.useCallback(a=>{console.log("[useWowy] Player clicked:",a.name),Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>{S(v=>{const C=v.findIndex(u=>u.nba_id===a.nba_id);let q;return C!==-1?(console.log("[useWowy] Removing player from selection"),q=v.filter((u,w)=>w!==C)):v.length<5||pe?(console.log(`[useWowy] Adding player to selection, replacement mode: ${pe}`),q=[...v,a]):(console.log("[useWowy] Max players reached (5), no change"),q=v),q}),le!=null&&le.startsWith("Error processing")&&je(null)},100)},[pe,le]),Ke=_.useCallback((a,v)=>{const C=Math.min(i,a),q=Math.min(i,v);p(C),ie(q)},[i]),Ye=_.useCallback(()=>{ve(a=>{const v=Math.min(a+5,X.length);return b(X.slice(0,v)),v})},[X]);_.useEffect(()=>{if(!(!c.current||!y))return n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{const a=E.map(C=>C.nba_id).join("/"),v=`${o}/${y}/${T}/${F}/${$}/${M}/${oe}${a?"/"+a:""}`;d.pathname!==v&&(console.log("[useWowy] Updating URL to:",v),window.history.replaceState(null,"",v))},500),()=>{n.current&&clearTimeout(n.current)}},[y,E,T,F,$,M,oe,s]);const x=ee instanceof Error?ee.message:ee?String(ee):null;return{state:{selectedTeam:y,selectedPlayers:E,availablePlayers:U,allYearsPlayers:fe,playerMetricsByYear:he,combinations:K,isLoading:ue||I,isRefreshing:ye&&!I,error:le??x,startYear:T,endYear:F,seasonType:$,leverageFilter:M,lineupMode:oe,isTeamSelectorOpen:Y,isPanelOpen:z,wowyStats:P,defLuckValue:H,offLuckValue:J,allowDataFetch:g,allNManCombinations:X,displayedNManCount:me,timedecayRapm:Me,isTimedecayRapmLoading:ke},actions:{setYearRange:Ke,setSeasonType:G,setLeverageFilter:te,setLineupMode:ce,setDefLuckValue:_e,setOffLuckValue:D,setAllowDataFetch:O,setIsTeamSelectorOpen:xe,setIsPanelOpen:Ce,setSelectedTeam:W,setSelectedPlayers:S,handleTeamSelect:Ge,handlePlayerClick:Le,fetchCombinations:Se,showMoreNManLineups:Ye}}}const Dn="regular",$n="all",Rn="2man",rs=5*60*1e3,In=1250,Bn=["2man","3man","4man","5man"],ss=(t,r,o,f,m)=>["wowy-leaders",t,r,o,f,m];function Kn(t="nba"){const r=ca(),o=Fs(),[f,m]=_.useState(()=>Math.min(o,Os())),i=_.useCallback(F=>{m(Math.min(o,F))},[o]),[l,s]=_.useState(Dn),[d,c]=_.useState(t==="wnba"?"all":$n),n=_.useCallback(F=>{c(lr(t,F))},[t]),[N,y]=_.useState(Rn),W=_.useRef(null),E=Number(N.charAt(0)),S=ss(t,f,l,d,N),{data:j=[],isLoading:A,isFetching:T,error:p}=yt({queryKey:S,queryFn:()=>Br(f,E,l,d,200,t),staleTime:rs,retry:2,retryDelay:200,refetchOnWindowFocus:!1});return _.useEffect(()=>{if(A||T||p)return;const F=`${f}-${l}-${d}`;if(W.current===F)return;const ie=window.setTimeout(()=>{W.current=F,Promise.allSettled(Bn.filter($=>$!==N).map($=>r.prefetchQuery({queryKey:ss(t,f,l,d,$),queryFn:()=>Br(f,Number($.charAt(0)),l,d,200,t),staleTime:rs})))},In);return()=>{window.clearTimeout(ie)}},[p,T,A,t,d,N,r,l,f]),{state:{selectedYear:f,seasonType:l,leverageFilter:d,lineupMode:N,leaders:j,isLoading:A||T,error:p instanceof Error?p.message:null},actions:{setSelectedYear:i,setSeasonType:s,setLeverageFilter:n,setLineupMode:y}}}const gr=550,xr=850,Ds=({off:t,def:r,possessions:o,offPossessions:f,defPosse
6ssions:m,lgAvgOrtg:i})=>{const l=Number.isFinite(f)&&Number(f)>0?Number(f):Number.isFinite(o)&&Number(o)>0?Number(o):Number.NaN,s=Number.isFinite(m)&&Number(m)>0?Number(m):Number.isFinite(o)&&Number(o)>0?Number(o):Number.NaN;if(!Number.isFinite(i)||!Number.isFinite(l)||!Number.isFinite(s))return null;const d=Number(i),c=(t*l+d*gr)/(l+gr),n=(r*s+d*xr)/(s+xr),N=c-n,y=c-d,W=n-d,E=y-W;return{paddedOff:c,paddedDef:n,paddedNet:N,paddedRelOff:y,paddedRelDef:W,paddedRelNet:E}},as=266,ns=410,Yn=266,Gn=10,Hn=10,Un=[100,266,500,1e3],Je=(t,r=1)=>Number.isFinite(t)?`${t>0?"+":""}${t.toFixed(r)}`:"0.0",_r=t=>`${(t*100).toFixed(1)}%`,$s=(t,r,o)=>Math.min(o,Math.max(r,t)),os=(t,r)=>t<=0?0:t/(t+r),Ht=t=>t==="offense"?{border:"border-primary/40",heading:"text-primary",value:"text-primary",track:"bg-primary/16",fill:"bg-primary"}:t==="defense"?{border:"border-secondary/40",heading:"text-secondary",value:"text-secondary",track:"bg-secondary/16",fill:"bg-secondary"}:{border:"border-border",heading:"text-foreground",value:"text-foreground",track:"bg-foreground
6/12",fill:"bg-foreground"};function wt({label:t,value:r,tone:o="net"}){const f=Ht(o);return e.jsxs("div",{className:"rounded-md border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:h("mt-1 font-numeric text-xl font-bold",f.value),children:r})]})}function zn({retainedShare:t,tone:r}){const o=Ht(r);return e.jsx("div",{className:h("h-1.5 overflow-hidden rounded-full",o.track),children:e.jsx("div",{className:h("h-full rounded-full",o.fill),style:{width:`${t*100}%`}})})}function is({title:t,rawEdge:r,paddedEdge:o,retainedShare:f,sampleMinutes:m,priorMinutes:i,tone:l}){const s=_r(f),d=_r(1-f),c=Ht(l);return e.jsxs("div",{className:h("rounded-md border bg-card p-3",c.border),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:h("text-[11px] font-semibold uppercase tracking-wide",c.heading),children:t}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:h("font-numeric text-sm font-bold",c.value),children:s}),e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"kept"})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-end gap-2",children:[e.jsxs("div",{className:"rounded-md border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Raw"}),e.jsx("div",{className:"mt-1 font-numeric text-2xl font-bold text-foreground/70",children:Je(r)})]}),e.jsx("div",{className:h("pb-2 text-sm font-semibold",c.heading),"aria-hidden":"true",children:"â"}),e.jsxs("div",{className:h("rounded-md border bg-background px-3 py-2",c.border),children:[e.jsx("div",{className:h("text-[10px] font-medium uppercase tracking-wide",c.heading),children:"Padded"}),e.jsx("div",{className:h("mt-1 font-numeric text-2xl font-bold",c.value),children:Je(o)})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between text-[11px] font-medium uppercase tracking-wide",children:[e.jsx("span",{className:c.heading,children:s}),e.jsx("span",{className:"text-muted-foreground",children:d})]}),e.jsx(zn,{retainedShare:f,tone:l})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsxs("span",{className:"font-numeric",children:[e.jsx("span",{className:h("mr-1",c.heading),children:m.toFixed(0)}),"sample"]}),e.jsxs("span",{className:"font-numeric",children:[e.jsx("span",{className:"mr-1 text-foreground/80",children:i}),"prior"]})]})]})}function Vn({rawNetEdge:t,paddedNetEdge:r,netReduction:o}){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Net"}),e.jsx("div",{className:"mt-1 font-numeric text-3xl font-bold tracking-tight text-foreground",children:Je(r)}),e.jsxs("div",{className:"mt-1 font-numeric text-sm font-medium text-muted-foreground",children:[Je(t)," â ",Je(r)]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx(wt,{label:"Dropped",value:Je(o)}),e.jsx(wt,{label:"Kept",value:t===0?"0.0%":_r(r/t)})]})]})}function ls({label:t,value:r,min:o,max:f,step:m,tone:i,onChange:l}){const s=Ht(i);return e.jsxs("label",{className:h("rounded-md border bg-background px-3 py-2",s.border),children:[e.jsx("div",{className:h("text-xs font-semibold",s.heading),children:t}),e.jsx(fa,{type:"number",value:r,min:o,max:f,step:m,onChange:d=>{const c=Number(d.target.value);l(Number.isFinite(c)?$s(c,o,f):o)},className:"mt-2 h-9 rounded-md border-border bg-background font-numeric text-lg font-bold text-foreground"})]})}function ds({offenseEdge:t,defenseEdge:r,rawNetEdge:o,className:f}){return e.jsxs("div",{className:h("grid grid-cols-3 gap-2",f),children:[e.jsx(wt,{label:"OFF",value:Je(t),tone:"offense"}),e.jsx(wt,{label:"DEF",value:Je(r),tone:"defense"}),e.jsx(wt,{label:"NET",value:Je(o),tone:"net"})]})}function Qn(){const[t,r]=_.useState(Yn),[o,f]=_.useState(Gn),[m,i]=_.useState(Hn);_.useEffect(()=>{if(typeof window>"u"||window.location.hash!=="#padding")return;let E=!1,S=0,j=0;const A=20,T=()=>{if(E)return;const F=document.getElementById("padding");F&&(F.scrollIntoView({block:"start"}),S+=1,F.getBoundingClientRect().top>180&&S<A&&(j=window.setTimeout(T,100)))},p=window.requestAnimationFrame(T);return()=>{E=!0,window.cancelAnimationFrame(p),window.clearTimeout(j)}},[]);const l=$s(t,0,1500),s=os(l,as),d=os(l,ns),c=o*s,n=m*d,N=o+m,y=c+n,W=N-y;return e.jsxs("div",{id:"padding",className:"scroll-mt-[calc(var(--app-header-offset)+1rem)] mt-4 space-y-4",children:[e.jsxs("div",{className:"max-w-[75ch] space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsx("p",{children:"Small samples dominate a raw leaderboard. A 10-minute +40 NET sits above a 400-minute +12. A minutes cutoff just moves the problem: the lineup that barely clears it still has an easier path to an extreme rating."}),e.jsxs("p",{children:["So every lineup starts with a league-average prior: about"," ",e.jsx("span",{className:"font-medium text-foreground",children:"266 offensive minutes"})," and"," ",e.jsx("span",{className:"font-medium text-foreground",children:"410 defensive minutes"})," (",e.jsx("span",{className:"font-medium text-foreground",children:gr})," offensive possessions and"," ",e.jsx("span",{className:"font-medium text-foreground",children:xr})," defensive possessions). Extreme 10-minute ratings get tempered. Larger samples keep more of what they earned. Defense is padded more because it takes longer to stabilize."]}),e.jsxs("p",{children:["At ",e.jsx("span",{className:"font-medium text-foreground",children:"266 real minutes"}),", a"," ",e.jsx("span",{className:"font-medium text-primary",children:"+10 offensive edge is cut to +5.0"}),". The same"," ",e.jsx("span",{className:"font-medium text-secondary",children:"+10 defensive edge keeps about 39.3%"})," ","and lands at ",e.jsx("span",{className:"font-medium text-foreground",children:"+3.9"}),"."]})]}),e.jsxs("div",{className:"rounded-md border border-border bg-card p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Padding sandbox"}),e.jsxs("div",{className:"mt-3 grid items-start gap-3 lg:grid-cols-[minmax(0,0.88fr)_minmax(0,1.12fr)]",children:[e.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[e.jsxs("div",{className:"rounded-md border border-border bg-card px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Minutes"}),e.jsxs("div",{className:"mt-1 font-numeric text-2xl font-bold text-foreground",children:[l.toFixed(0),e.jsx("span",{className:"ml-1 text-sm font-medium text-muted-foreground",children:"min"})]}),e.jsx(Wa,{value:[l],min:0,max:1500,step:5,onValueChange:E=>r(E[0]??0),className:"mt-3 py-0 [&>span:first-child]:h-1.5 [&>span:first-child]:bg-border [&>span:last-child]:h-4 [&>span:last-child]:w-4"}),e.jsx("div",{className:"mt-3 grid grid-cols-4 gap-2",children:Un.map(E=>e.jsxs("button",{type:"button",onClick:()=>r(E),className:h("rounded-md border px-2 py-1 text-xs font-semibold tabular-nums transition-colors",l===E?"border-primary/60 bg-primary/10 text-primary":"border-border bg-background text-muted-foreground hover:bg-accent hover:text-foreground"),children:[E,"m"]},E))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ls,{label:"OFF edge",value:o,min:-30,max:30,step:.5,tone:"offense",onChange:f}),e.jsx(ls,{label:"DEF edge",value:m,min:-30,max:30,step:.5,tone:"defense",onChange:i})]}),e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Raw"}),e.jsx(ds,{offenseEdge:o,defenseEdge:m,rawNetEdge:N})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"hidden items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground lg:flex",children:[e.jsx("span",{children:"Raw"}
6),e.jsx("span",{className:"text-foreground/30",children:"â"}),e.jsx("span",{children:"Padded"}),e.jsx("span",{className:"text-foreground/30",children:"â"}),e.jsx("span",{children:"Net"})]}),e.jsx(ds,{offenseEdge:o,defenseEdge:m,rawNetEdge:N,className:"hidden lg:grid"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsx(is,{title:"OFF",rawEdge:o,paddedEdge:c,retainedShare:s,sampleMinutes:l,priorMinutes:as,tone:"offense"}),e.jsx(is,{title:"DEF",rawEdge:m,paddedEdge:n,retainedShare:d,sampleMinutes:l,priorMinutes:ns,tone:"defense"})]}),e.jsx(Vn,{rawNetEdge:N,paddedNetEdge:y,netReduction:W})]})]})]})]})}const Rs=t=>`${t} WOWY, short for With or Without You, compares how a team performs with specific players or lineups on and off the court across selected seasons, leverage filters, and lineup sizes.`,Is="On-off results describe how team performance changed across the selected minutes. They provide context but do not prove that one player caused the full difference because teammates, opponents, roles, and sample size also matter.",Bs="League Leaders adds league-average performance to 550 offensive and 850 defensive possessions to reduce extreme small-sample ratings while keeping larger-minute lineups closer to their observed results.";function Xn({league:t,mode:r}){const o=t==="wnba"?"WNBA":"NBA",f=t==="wnba"?"/wnba/wowy/leaders":"/wowy/leaders",m=As(t);return e.jsx("section",{className:"mx-auto mt-6 max-w-xl border-t border-border pt-4 text-left","aria-labelledby":`${t}-wowy-guide-title`,children:e.jsxs("details",{className:"max-w-3xl",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-muted-foreground hover:text-foreground",children:["What is ",o," WOWY analysis?"]}),e.jsxs("div",{className:"pt-4",children:[e.jsxs("h2",{id:`${t}-wowy-guide-title`,className:"text-2xl font-bold tracking-tight text-foreground",children:["What is ",o," WOWY analysis?"]}),e.jsxs("p",{className:"mt-3 max-w-[75ch] text-sm leading-7 text-muted-foreground",children:[Rs(o)," databallr lets you study minutes, offensive rating, defensive rating, net rating, shooting, turnovers, and rebounding across those same filters."]}),e.jsxs("div",{className:"mt-8 border-t border-border pt-6",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"What does on-off tell you?"}),e.jsx("p",{className:"mt-2 max-w-[75ch] text-sm leading-6 text-muted-foreground",children:Is})]}),e.jsxs("div",{className:"mt-8 border-t border-border pt-6",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"How do lineup modes differ?"}),e.jsxs("p",{className:"mt-2 max-w-[75ch] text-sm leading-6 text-muted-foreground",children:["WOWY mode compares with-and-without combinations for selected players. The"," ",m," modes rank exact lineup sizes, so you can move from player-pair context to full five-player units."]})]}),e.jsxs("div",{className:"mt-8 border-t border-border pt-6",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Why are league leaders padded?"}),e.jsx("p",{className:"mt-2 max-w-[75ch] text-sm leading-6 text-muted-foreground",children:Bs}),r==="team"?e.jsxs("p",{className:"mt-2 max-w-[75ch] text-sm leading-6 text-muted-foreground",children:["A minutes cutoff just moves the problem."," ",e.jsx(or,{to:`${f}#padding`,className:"font-medium text-primary hover:underline",children:"See how the prior tempers a raw edge"})," ","as minutes change."]}):e.jsx(Qn,{})]}),e.jsxs("p",{className:"mt-8 text-sm text-muted-foreground",children:["Need a metric definition? Use the"," ",e.jsx(or,{to:"/stats/glossary",className:"font-medium text-primary hover:underline",children:"databallr Stats Glossary"}),"."]})]})]})})}function Ks({selectedTeam:t,selectedPlayers:r,startYear:o,endYear:f,seasonType:m,leverageFilter:i,lineupMode:l,isLeadersMode:s=!1,league:d="nba"}){const c=Or(d),n=d.toUpperCase(),N=(()=>{if(typeof window>"u")return{team:null,startYear:null,endYear:null,seasonType:null,leverageFilter:null,lineupMode:null,playerIds:[]};const K=window.location.pathname.split("/").filter(Boolean),b=K[0]==="wnba"&&K[1]==="wowy"?1:0;
6if(K[b]!=="wowy")return{team:null,startYear:null,endYear:null,seasonType:null,leverageFilter:null,lineupMode:null,playerIds:[]};if(K[b+1]==="leaders")return{team:null,startYear:null,endYear:null,seasonType:null,leverageFilter:null,lineupMode:null,playerIds:[]};const X=K[b+4],V=K[b+5],me=K[b+6];return{team:K[b+1]||null,startYear:Number(K[b+2])||null,endYear:Number(K[b+3])||null,seasonType:X==="regular"||X==="playoffs"||X==="all"?X:null,leverageFilter:V==="high"||V==="all"?V:null,lineupMode:me==="wowy"||me==="2man"||me==="3man"||me==="4man"||me==="5man"?me:null,playerIds:K.slice(b+7).filter(ve=>/^\d+$/.test(ve))}})(),y=t||N.team,W=N.startYear||o,E=N.endYear||f,S=N.seasonType||m,j=N.leverageFilter||i,A=N.lineupMode??l,T=r.length>0?r:N.playerIds.map((K,b)=>({id:Number(K),nba_id:K,name:`Player ${b+1}`})),p=K=>K!=="wowy",F=()=>{if(s){const V=W===E?`${W}`:`${W}-${E}`;return`${p(A)?jt(d,A):jt(d,"2man")} League Leaders ${V} | databallr WOWY`}if(!y)return`databallr WOWY - ${n} Lineup Analysis`;const K=c[y]||y,b=W===E?`${W}`:`${W}-${E}`;return p(A)?`${jt(d,A)} Lineups - ${K} ${b} | databallr WOWY`:T.length===0?`${K} WOWY Analysis ${b} | databallr`:`${T.map(V=>V.name).join(" & ")} - ${K} WOWY Stats | databallr`},ie=()=>{if(s){const ve=W===E?`${W}`:`${W}-${E}`;return`League-wide padded ${p(A)?dt(d,A):dt(d,"2man")} lineup leaderboard for ${ve}. ${S==="regular"?"regular season":S==="playoffs"?"playoffs":"regular season + playoffs"}, ${j==="high"?"medium/high leverage":"all leverage"}. Compare the best ${n} lineups and drill into team WOWY pages.`}if(!y)return`Analyze ${n} lineup combinations with advanced WOWY (With or Without You) statistics. View plus/minus, offensive and defensive ratings.`;const K=c[y]||y,b=W===E?`${W}`:`${W}-${E}`,X=S==="regular"?"regular season":S==="playoffs"?"playoffs":"regular season + playoffs",V=j==="high"?"high leverage situations":"all situations";return p(A)?`View top ${dt(d,A)} lineup combinations for ${K}. ${b} ${X}, ${V}. Detailed plus/minus and efficiency stats.`:T.length===0?`Explore ${K} lineup combinations and player impacts. ${b} ${X}, ${V}.`:`Analyze ${T.map(ve=>ve.name).join(", ")} performance on ${K}. ${b} ${X}, ${V}. With/without comparisons and lineup efficiency.`},$=F(),G=ie(),M=typeof window<"u"?`https://databallr.com${window.location.pathname.replace(/\/+$/,"")||"/"}`:`https://databallr.com${d==="wnba"?"/wnba/wowy":"/wowy"}`,ge=new URLSearchParams({type:"wowy",team:y||"",startYear:String(W),endYear:String(E),seasonType:S,leverage:j,mode:A});T.slice(0,2).forEach((K,b)=>{const X=b+1;ge.set(`p${X}id`,String(K.nba_id)),ge.set(`p${X}name`,K.name)}),T.length>2&&ge.set("count",String(T.length));const te=!s&&y?Ma(ge.toString()):typeof window<"u"?`${window.location.origin}/og-image.png`:"/og-image.png",oe=d==="wnba"?"WNBA":"NBA",ce={"@context":"https://schema.org","@type":"FAQPage",mainEntity:[{"@type":"Question",name:`What is ${oe}
6 WOWY analysis?`,acceptedAnswer:{"@type":"Answer",text:Rs(oe)}},{"@type":"Question",name:"What does on-off tell you in basketball?",acceptedAnswer:{"@type":"Answer",text:Is}},{"@type":"Question",name:"Why are databallr WOWY league leaders padded?",acceptedAnswer:{"@type":"Answer",text:Bs}}]};return e.jsxs(ma,{children:[e.jsx("title",{children:$}),e.jsx("meta",{name:"description",content:G}),e.jsx("link",{rel:"canonical",href:M}),e.jsx("meta",{property:"og:title",content:$}),e.jsx("meta",{property:"og:description",content:G}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:M}),e.jsx("meta",{property:"og:image",content:te}),e.jsx("meta",{property:"og:image:width",content:"1200"}),e.jsx("meta",{property:"og:image:height",content:"630"}),e.jsx("meta",{property:"og:site_name",content:"databallr"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:$}),e.jsx("meta",{name:"twitter:description",content:G}),e.jsx("meta",{name:"twitter:image",content:te}),e.jsx("script",{id:"wowy-faq-schema",type:"application/ld+json",children:JSON.stringify(ce)})]})}function Jn({triggerMode:t="full",className:r}){return e.jsxs(ct,{children:[e.jsx(pa,{asChild:!0,children:t==="icon"?e.jsx(Qe,{variant:"default",size:"icon",title:"Understand WOWY Data","aria-label":"Understand WOWY Data",className:h("h-10 w-10 rounded-full text-xl font-black leading-none",r),children:e.jsx("span",{className:"relative -top-[1px]",children:"?"})}):e.jsxs(Qe,{variant:"outline",size:"sm",className:h("w-full sm:w-auto px-4 py-2 sm:py-1.5 text-sm sm:text-xs gap-2 flex items-center justify-center",r),children:[e.jsx(ua,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),e.jsx("span",{children:"Understand WOWY Data"})]})}),e.jsxs(ft,{className:"sm:max-w-[550px] max-h-[80vh] overflow-y-auto bg-popover text-popover-foreground border-border backdrop-blur-md",children:[e.jsxs(mt,{className:"mb-4",children:[e.jsx(pt,{className:"text-xl font-bold",children:"Understanding WOWY Lineup Data"}),e.jsx(Ct,{className:"text-muted-foreground",children:"A guide to interpreting lineup statistics"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-2 border-b border-border pb-4 text-sm",children:[e.jsx("h3",{className:"font-semibold",children:"Lineup modes"}),e.jsx("p",{className:"text-muted-foreground",children:"WOWY uses your selected players as ON/OFF filters to show with-or-without impact. The 2â5 player modes show lineups of that size that include your selected players."}),e.jsx("p",{className:"text-muted-foreground",children:"Choose players from the Players button above the table or the bottom menu. Use Range in the year picker to select either endpoint first, up to seven seasons."})]}),e.jsxs(_t,{className:"bg-card text-card-foreground border-border shadow-md hover:shadow-lg transition-shadow",children:[e.jsxs(xt,{className:"pb-2 flex flex-row items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-primary/10",children:e.jsx(js,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-base",children:"Player ON/OFF Filtering"})]}),e.jsxs(gt,{className:"pt-2",children:[e.jsx("p",{className:"text-sm mb-3",children:"Player portraits indicate ON/OFF court status for lineup filtering:"}),e.jsxs("div",{className:"flex justify-center gap-10 mb-4",children:[e.jsxs("div",{className:"flex flex-col items-center w-24",children:[e.jsx("div",{className:"relative w-[58px] h-[58px] rounded-full overflow-hidden ring-2 ring-primary ring-offset-1 ring-offset-background",children:e.jsx("div",{className:"absolute inset-0 h-[133%]",children:e.jsx("img",{src:"https://cdn.nba.com/headshots/nba/latest/1040x760/203999.png",alt:"Nikola Jokic",className:"w-full h-full object-cover"})})}),e.jsx("span",{className:"text-xs mt-1.5 text-foreground text-center",children:"Nikola JokiÄ"}),e.jsx("div",{className:"mt-1 flex items-center justify-center bg-primary/10 px-2 py-0.5 rounded-full",children:e.jsx("span",{className:"text-xs font-semibold text-primary",children:"ON Court"})})]}),e.jsxs("div",{className:"flex flex-col items-center w-24",children:[e.jsx("div",{className:"relative w-[58px] h-[58px] rounded-full overflow-hidden ring-1 ring-border",children:e.jsx("div",{className:"absolute inset-0 h-[133%]",children:e.jsx("img",{src:"https://cdn.nba.com/headshots/nba/latest/1040x760/1627750.png",alt:"Jamal Murray",className:"w-full h-full object-cover opacity-90"})})}),e.jsx("span",{className:"text-xs mt-1.5 text-muted-foreground text-center",children:"Jamal Murray"}),e.jsx("div",{className:"mt-1 flex items-center justify-center bg-muted px-2 py-0.5 rounded-full",children:e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"OFF Court"})})]})]}),e.jsxs("div",{className:"bg-card/50 p-3 rounded-lg border border-border",children:[e.jsx("h4",{className:"text-sm font-semibold mb-1.5",children:"What This Means:"}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary mr-2"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-primary",children:"Player ON"})," means only lineups where this player is on the court"]})]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground mr-2"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-muted-foreground",children:"Player OFF"})," means only lineups where this player is not on the court"]})]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-secondary mr-2"}),e.jsx("span",{children:"WOWY shows how team performs with specific player combinations on and off court"})]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary mr-2"}),e.jsx("span",{children:"Click the lineup cell with the portraits in it to find out more detailed information about that lineup"})]})]})]})]})]}),e.jsxs(_t,{className:"bg-card text-card-foreground border-border shadow-md hover:shadow-lg transition-shadow",children:[e.jsxs(xt,{className:"pb-2 flex flex-row items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-primary/10",children:e.jsx(ga,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-base",children:"Key Metrics"})]}),e.jsx(gt,{className:"pt-2",children:e.jsxs("ul",{className:"space-y-3 text-sm",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"OFF:"}),e.jsx("span",{children:"Offensive Rating: points scored per 100 possessions"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"DEF:"}),e.jsx("span",{children:"Defensive Rating: points allowed per 100 possessions"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"NET:"}),e.jsx("span",{children:"Net Rating: the difference between OFF and DEF (OFF - DEF)"})]})]})})]}),e.jsxs(_t,{className:"bg-card text-card-foreground border-border shadow-md hover:shadow-lg transition-shadow",children:[e.jsxs(xt,{className:"pb-2 flex flex-row items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-primary/10",children:e.jsx(Ha,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-base",children:"Data Views"})]}),e.jsx(gt,{className:"pt-2",children:e.jsxs("ul",{className:"space-y-3 text-sm",children:[e.jsx("li",{className:"flex flex-col",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"Raw:"}),e.jsx("span",{children:"Actual values without any adjustment"})]})}),e.jsxs("li",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"Relative:"}),e.jsx("span",{children:"Values compared to league average"})]}),e.jsxs("div",{className:"mt-1.5 ml-6 p-2 rounded-md bg-muted text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:"League avg OFF: 115"}),e.jsx(Rr,{className:"h-3 w-3"}),e.jsx("span",{className:"text-xs",children:"Lineup OFF: 120"}),e.jsx(Rr,{className:"h-3 w-3"}),e.jsx("span",{className:"text-xs font-semibold text-primary",children:"Relative: +5"})]})]})]})})]}),e.jsxs(_t,{className:"bg-card text-card-foreground border-border shadow-md hover:shadow-lg transition-shadow",children:[e.jsxs(xt,{className:"pb-2 flex flex-row items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-primary/10",children:e.jsx(ws,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-base",children:"Key Performance Factors"})]}),e.jsxs(gt,{className:"pt-2",children:[e.jsxs("ul",{className:"space-y-3 text-sm",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"TS%:"}),e.jsx("span",{children:"True Shooting Percentage - shooting efficiency accounting for field goals, 3-pointers, and free throws"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"TOV%:"}),e.jsx("span",{children:"Turnover Percentage - percentage of possessions ending in turnovers"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-semibold text-primary",children:"ORB%:"}),e.jsx("span",{children:"Offensive Rebound Percentage - percentage of available offensive rebounds a team obtains"})]})]}),e.jsx("p",{className:"text-sm mt-3 text-muted-foreground",children:"These three factors are crucial in explaining why a lineup performs well or poorly."})]})]}),e.jsxs(_t,{className:"bg-card text-card-foreground border-border shadow-md hover:shadow-lg transition-shadow",children:[e.jsxs(xt,{className:"pb-2 flex flex-row items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-primary/10",children:e.jsx(Ua,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-base",children:"Color Co
6ding"})]}),e.jsxs(gt,{className:"pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-primary/10",children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-primary"}),e.jsx("span",{children:"Good performance"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-secondary/10",children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-secondary"}),e.jsx("span",{children:"Poor performance"})]})]}),e.jsxs("p",{className:"text-sm mt-3 text-muted-foreground",children:["The ",e.jsx("span",{className:"font-semibold text-primary",children:"primary color"})," (typically yellow-ish) indicates better performance for that specific metric.",e.jsx("br",{}),"The ",e.jsx("span",{className:"font-semibold text-secondary",children:"secondary color"})," indicates poorer performance for that specific metric."]})]})]})]})]})]})}function cs(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ne(t,r){const o=cs(t),f=cs(r);if(!(o===void 0||f===void 0))return o-f}async function Zn({stats:t,availablePlayers:r,defLuckAdjustment:o=0,offLuckAdjustment:f=0}){return r.length?t.length?await Promise.all(r.map(async i=>{try{const l=await Dr(t,[i],o,f,"wowy"),s=l.find(c=>c.on_players.some(n=>n.nba_id===i.nba_id)),d=l.find(c=>c.on_players.length===0);return{player:i,minutes:s==null?void 0:s.minutes,off:s==null?void 0:s.off,def:s==null?void 0:s.def,net:s==null?void 0:s.net,lgAvgOrtg:s==null?void 0:s.lg_avg_ortg,lgAvgTs:s==null?void 0:s.lg_avg_ts,lgAvgTov:s==null?void 0:s.lg_avg_tov,lgAvgOrb:s==null?void 0:s.lg_avg_orb,lgAvgRimFreq:s==null?void 0:s.lg_avg_rim_freq,lgAvgRimAcc:s==null?void 0:s.lg_avg_rim_acc,lgAvg3pFreq:s==null?void 0:s.lg_avg_3p_freq,lgAvgCornerFreq:s==null?void 0:s.lg_avg_corner_freq,lgAvgFg2Pct:s==null?void 0:s.lg_avg_fg2_pct,lgAvgMidFreq:s==null?void 0:s.lg_avg_mid_freq,lgAvgMidAcc:s==null?void 0:s.lg_avg_mid_acc,lgAvgThree:s==null?void 0:s.lg_avg_three,lgAvgArc:s==null?void 0:s.lg_avg_arc,lgAvgCorner:s==null?void 0:s.lg_avg_corner,relOff:Ne(s==null?void 0:s.off,s==null?void 0:s.lg_avg_ortg),relDef:Ne(s==null?void 0:s.def,s==null?void 0:s.lg_avg_ortg),tsPct:s==null?void 0:s.ts_pct,tovPct:s==null?void 0:s.tov_pct,orbPct:s==null?void 0:s.orb_pct,oppTsPct:s==null?void 0:s.opp_ts_pct,oppTovPct:s==null?void 0:s.opp_tov_pct,oppOrbPct:s==null?void 0:s.opp_orb_pct,offRimFreq:s==null?void 0:s.off_rim_freq,offRimFgPct:s==null?void 0:s.off_rim_fg_pct,offMidFreq:s==null?void 0:s.off_mid_freq,offMidFgPct:s==null?void 0:s.off_mid_fg_pct,off3pFreq:s==null?void 0:s.off_3p_freq,off3pPct:s==null?void 0:s.off_3p_pct,offArc3Freq:s==null?void 0:s.off_arc3_freq,offArc3FgPct:s==null?void 0:s.off_arc3_fg_pct,offCorner3Freq:s==null?void 0:s.off_corner3_freq,offCorner3FgPct:s==null?void 0:s.off_corner3_fg_pct,defRimFreq:s==null?void 0:s.def_rim_freq,defRimFgPct:s==null?void 0:s.def_rim_fg_pct,defMidFreq:s==null?void 0:s.def_mid_freq,defMidFgPct:s==null?void 0:s.def_mid_fg_pct,def3pFreq:s==null?void 0:s.def_3p_freq,def3pPct:s==null?void 0:s.def_3p_pct,defArc3Freq:s==null?void 0:s.def_arc3_freq,defArc3FgPct:s==null?void 0:s.def_arc3_fg_pct,defCorner3Freq:s==null?void 0:s.def_corner3_freq,defCorner3FgPct:s==null?void 0:s.def_corner3_fg_pct,offOnOff:Ne(s==null?void 0:s.off,d==null?void 0:d.off),defOnOff:Ne(s==null?void 0:s.def,d==null?void 0:d.def),netOnOff:Ne(s==null?void 0:s.net,d==null?void 0:d.net),tsPctOnOff:Ne(s==null?void 0:s.ts_pct,d==null?void 0:d.ts_pct),tovPctOnOff:Ne(s==null?void 0:s.tov_pct,d==null?void 0:d.tov_pct),orbPctOnOff:Ne(s==null?void 0:s.orb_pct,d==null?void 0:d.orb_pct),oppTsPctOnOff:Ne(s==null?void 0:s.opp_ts_pct,d==null?void 0:d.opp_ts_pct),oppTovPctOnOff:Ne(s==null?void 0:s.opp_tov_pct,d==null?void 0:d.opp_tov_pct),oppOrbPctOnOff:Ne(s==null?void 0:s.opp_orb_pct,d==null?void 0:d.opp_orb_pct),offRimFreqOnOff:Ne(s==null?void 0:s.off_rim_freq,d==null?void 0:d.off_rim_freq),offRimFgPctOnOff:Ne(s==null?void 0:s.off_rim_fg_pct,d==null?void 0:d.off_rim_fg_pct),offMidFreqOnOff:Ne(s==null?void 0:s.off_mid_freq,d==null?void 0:d.off_mid_freq),offMidFgPctOnOff:Ne(s==null?void 0:s.off_mid_fg_pct,d==null?void 0:d.off_mid_fg_pct),off3pFreqOnOff:Ne(s==null?void 0:s.off_3p_freq,d==null?void 0:d.off_3p_freq),off3pPctOnOff:Ne(s==null?void 0:s.off_3p_pct,d==null?void 0:d.off_3p_pct),offArc3FreqOnOff:Ne(s==null?void 0:s.off_arc3_freq,d==null?void 0:d.off_arc3_freq),offArc3FgPctOnOff:Ne(s==null?void 0:s.off_arc3_fg_pct,d==null?void 0:d.off_arc3_fg_pct),offCorner3FreqOnOff:Ne(s==null?void 0:s.off_corner3_freq,d==null?void 0:d.off_corner3_freq),offCorner3FgPctOnOff:Ne(s==null?void 0:s.off_corner3_fg_pct,d==null?void 0:d.off_corner3_fg_pct),defRimFreqOnOff:Ne(s==null?void 0:s.def_rim_freq,d==null?void 0:d.def_rim_freq),defRimFgPctOnOff:Ne(s==null?void 0:s.def_rim_fg_pct,d==null?void 0:d.def_rim_fg_pct),defMidFreqOnOff:Ne(s==null?void 0:s.def_mid_freq,d==null?void 0:d.def_mid_freq),defMidFgPctOnOff:Ne(s==null?void 0:s.def_mid_fg_pct,d==null?void 0:d.def_mid_fg_pct),def3pFreqOnOff:Ne(s==null?void 0:s.def_3p_freq,d==null?void 0:d.def_3p_freq),def3pPctOnOff:Ne(s==null?void 0:s.def_3p_pct,d==null?void 0:d.def_3p_pct),defArc3FreqOnOff:Ne(s==null?void 0:s.def_arc3_freq,d==null?void 0:d.def_arc3_freq),defArc3FgPctOnOff:Ne(s==null?void 0:s.def_arc3_fg_pct,d==null?void 0:d.def_arc3_fg_pct),defCorner3FreqOnOff:Ne(s==null?void 0:s.def_corner3_freq,d==null?void 0:d.def_corner3_freq),defCorner3FgPctOnOff:Ne(s==null?void 0:s.def_corner3_fg_pct,d==null?void 0:d.def_corner3_fg_pct)}}
6catch(l){return console.error("[wowyTeamView] Failed to calculate player row",i.name,l),{player:i}}})):r.map(i=>({player:i})):[]}const eo=t=>{switch(t){case"regular":return"Regular Season";case"playoffs":return"Playoffs";case"all":return"Regular Season + Playoffs";default:return"Regular Season"}},to=t=>t===void 0||!Number.isFinite(t)?"-":Math.round(t),fs=t=>t===void 0||!Number.isFinite(t)?"-":t.toFixed(1),ms=t=>{if(t===void 0||!Number.isFinite(t))return"-";const r=t.toFixed(1);return t>0?`+${r}`:r},Zt=(t,r=!1,o=!0)=>{if(t===void 0||!Number.isFinite(t))return"-";const f=Number(t.toFixed(1)),m=Math.abs(f)===100?`${f<0?"-":""}100`:f.toFixed(1),i=o?"%":"";return r?`${f>0?"+":""}${m}${i}`:`${m}${i}`},er=(t,r=!1)=>{if(t===void 0||!Number.isFinite(t))return"-";const o=Number(t.toFixed(1)),f=Math.abs(o).toFixed(1);return r?t>0?`+${f}`:t<0?`-${f}`:f:t<0?`-${f}`:f},ro=(t,r)=>t===void 0||!Number.isFinite(t)?"text-muted-foreground":t>0?Bt(r):Kt(),so=(t,r)=>t===void 0||!Number.isFinite(t)?"text-muted-foreground":t<0?Bt(r):Kt(),et=(t,r,o=!1)=>t===void 0||!Number.isFinite(t)?"text-muted-foreground":o?t<0?Bt(r):Kt():t<0?Kt():Bt(r),ao=t=>{const r=t.trim().split(" ");return r[r.length-1]||t},tr=({left:t,right:r,className:o,leftClassName:f,rightClassName:m,separatorClassName:i})=>e.jsxs("div",{className:h("grid w-full grid-cols-[minmax(0,1fr)_0.7rem_minmax(0,1fr)] items-baseline tabular-nums",o),children:[e.jsx("span",{className:h("w-full text-right whitespace-nowrap",f),children:t}),e.jsx("span",{className:h("text-center leading-none",i),children:"|"}),e.jsx("span",{className:h("w-full text-left whitespace-nowrap",m),children:r})]}),no=(t,r)=>{switch(r){case"off":return t.relOff;case"def":return t.relDef;case"tsPct":return Number.isFinite(t.tsPct)&&Number.isFinite(t.lgAvgTs)?t.tsPct-t.lgAvgTs:void 0;case"tovPct":return Number.isFinite(t.tovPct)&&Number.isFinite(t.lgAvgTov)?t.tovPct-t.lgAvgTov:void 0;case"orbPct":return Number.isFinite(t.orbPct)&&Number.isFinite(t.lgAvgOrb)?t.orbPct-t.lgAvgOrb:void 0;case"oppTsPct":return Number.isFinite(t.oppTsPct)&&Number.isFinite(t.lgAvgTs)?t.oppTsPct-t.lgAvgTs:void 0;case"oppTovPct":return Number.isFinite(t.oppTovPct)&&Number.isFinite(t.lgAvgTov)?t.oppTovPct-t.lgAvgTov:void 0;case"oppOrbPct":return Number.isFinite(t.oppOrbPct)&&Number.isFinite(t.lgAvgOrb)?t.oppOrbPct-t.lgAvgOrb:void 0;default:return}},oo=(t,r,o)=>{switch(r){case"offRimFreq":case"defRimFreq":return t.lgAvgRimFreq??o.rimFreq;case"offMidFreq":case"defMidFreq":return t.lgAvgMidFreq??o.midFreq;case"off3pFreq":case"def3pFreq":return t.lgAvg3pFreq??o.threeFreq;case"offArc3Freq":case"defArc3Freq":return;case"offCorner3Freq":case"defCorner3Freq":return t.lgAvgCornerFreq;default:return}},io=(t,r,o)=>{switch(r){case"offRimFgPct":case"defRimFgPct":return t.lgAvgRimAcc??o.rimFgPct;case"offMidFgPct":case"defMidFgPct":return t.lgAvgMidAcc??o.midFgPct;case"off3pPct":case"def3pPct":return t.lgAvgThree??o.threeFgPct;case"offArc3FgPct":case"defArc3FgPct":return Number.isFinite(t.lgAvgArc)?t.lgAvgArc*100:void 0;case"offCorner3FgPct":case"defCorner3FgPct":return Number.isFinite(t.lgAvgCorner)?t.lgAvgCorner*100:void 0;default:return}},lo=t=>{switch(t.id){case"player":return{title:"Player",description:"Team roster players in current ordering."};case"minutes":return{title:"Minutes",description:"Total on-court minutes for that player."};case"rapm":return{title:"RAPM DECOMP",description:"Windowed Alt3 EFG-value RAPM DECOMP net value (higher is better)."};case"orapm":return{title:"ORAPM",description:"Windowed Alt3 EFG-value offensive RAPM DECOMP (higher is better)."};case"drapm":return{title:"DRAPM",description:"Windowed Alt3 EFG-value defensive RAPM DECOMP where positive values are better."};case"neff":return{title:"NEFF",description:"Net Efficiency is the persons impact on the efficiency game, the combined value of offensive true shooting impact and defensive true shooting impact."};case"pval":return{title:"PVAL",description:"Possession value from combined turnover and second-chance RAPM impact (oTOV + oSC + dTOV + dSC)."};case"resid":return{title:"?",description:"Net RAPM residual not explained by the six factor components."};case"oResid":return{title:"O ?",description:"Offensive RAPM residual: ORAPM - (oTS + oTOV + oSC)."};case"dResid":return{title:"D ?",description:"Defensive RAPM residual: DRAPM - (dTS + dTOV + dSC)."};case"oTSRapm":return{title:"oTS",description:"Offensive true shooting RAPM component."};case"oTOVRapm":return{title:"oTOV",description:"Offensive turnover RAPM component."};case"oREBRapm":return{title:"oSC",description:"Offensive second-chance RAPM DECOMP component."};case"dTSRapm":return{title:"dTS",description:"Defensive true shooting RAPM component (positive is better)."};case"dTOVRapm":return{title:"dTOV",description:"Defensive turnover RAPM component (positive is better)."};case"dREBRapm":return{title:"dSC",description:"Defensive second-chance RAPM DECOMP component (positive is better)."};case"off":return{title:"Offensive Rating",description:"Points scored per 100 possessions with player on court.",relativeNote:"Subtext = on-court OFF relative to league average."};case"def":return{title:"Defensive Rating",description:"Points allowed per 100 possessions with player on court.",relativeNote:"Subtext = on-court DEF relative to league average."};case"net":return{title:"Net Rating",description:"Point differential per 100 possessions with player on court."};case"offOnOff":return{title:"OFF ON-OFF",description:"On-court OFF minu
6s off-court OFF."};case"defOnOff":return{title:"DEF ON-OFF",description:"On-court DEF minus off-court DEF."};case"netOnOff":return{title:"NET ON-OFF",description:"On-court NET minus off-court NET."};case"tsPct":return{title:"TS%",description:"True Shooting percentage with player on court.",relativeNote:"Subtext = on-court TS% relative to league average."};case"tovPct":return{title:"TOV%",description:"Turnover percentage with player on court.",relativeNote:"Subtext = on-court TOV% relative to league average."};case"orbPct":return{title:"ORB%",description:"Offensive rebound percentage with player on court.",relativeNote:"Subtext = on-court ORB% relative to league average."};case"oppTsPct":return{title:"Opponent TS%",description:"Opponent true shooting percentage while player is on court.",relativeNote:"Subtext = on-court Opp TS% relative to league average."};case"oppTovPct":return{title:"Opponent TOV%",description:"Opponent turnover percentage while player is on court.",relativeNote:"Subtext = on-court Opp TOV% relative to league average."};case"oppOrbPct":return{title:"Opponent ORB%",description:"Opponent offensive rebound percentage while player is on court.",relativeNote:"Subtext = on-court Opp ORB% relative to league average."};case"tsPctOnOff":return{title:"TS% ON-OFF",description:"On-court TS% minus off-court TS%."};case"tovPctOnOff":return{title:"TOV% ON-OFF",description:"On-court TOV% minus off-court TOV%."};case"orbPctOnOff":return{title:"ORB% ON-OFF",description:"On-court ORB% minus off-court ORB%."};case"oppTsPctOnOff":return{title:"Opp TS% ON-OFF",description:"On-court Opp TS% minus off-court Opp TS%."};case"oppTovPctOnOff":return{title:"Opp TOV% ON-OFF",description:"On-court Opp TOV% minus off-court Opp TOV%."};case"oppOrbPctOnOff":return{title:"Opp ORB% ON-OFF",description:"On-court Opp ORB% minus off-court Opp ORB%."};case"rimProfile":return{title:"Rim Profile",description:"Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average."};case"rimProfileOnOff":return{title:"Rim Profile ON-OFF",description:"Signed on-court minus off-court deltas for frequency (left) and FG (right)."};case"midProfile":return{title:"Midrange Profile",description:"Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average."};case"midProfileOnOff":return{title:"Midrange Profile ON-OFF",description:"Signed on-court minus off-court deltas for frequency (left) and FG (right)."};case"threeProfile":return{title:"3P Profile",description:"Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average."};case"threeProfileOnOff":return{title:"3P Profile ON-OFF",description:"Signed on-court minus off-court deltas for frequency (left) and FG (right)."};case"arc3Profile":return{title:"Arc 3 Profile",description:"Top row shows frequency (decimal) and FG. Bottom row shows relative FG delta vs league average (frequency baseline unavailable)."};case"arc3ProfileOnOff":return{title:"Arc 3 Profile ON-OFF",description:"Signed on-court minus off-court deltas for frequency (left) and FG (right)."};case"corner3Profile":return{title:"Corner 3 Profile",description:"Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average."};case"corner3ProfileOnOff":return{title:"Corner 3 Profile ON-OFF",description:"Signed on-court minus off-court deltas for frequency (left) and FG (right)."};default:return{title:t.header,description:"Column metric"}}},ps=(t,r)=>{switch(r){case"minutes":return t.minutes;case"rapm":return t.rapm;case"orapm":return t.orapm;case"drapm":return t.drapm;case"neff":return t.neff;case"pval":return t.pval;case"resid":return t.resid;case"oResid":return t.oResid;case"dResid":return t.dResid;case"oTSRapm":return t.oTS;case"oTOVRapm":return t.oTOV;case"oREBRapm":return t.oSC??t.oREB;case"dTSRapm":return t.dTS;case"dTOVRapm":return t.dTOV;case"dREBRapm":return t.dSC??t.dREB;case"off":return t.off;case"offOnOff":return t.offOnOff;case"def":return t.def;case"defOnOff":return t.defOnOff;case"net":return t.net;case"netOnOff":return t.netOnOff;case"tsPct":return t.tsPct;case"tsPctOnOff":return t.tsPctOnOff;case"tovPct":return t.tovPct;case"tovPctOnOff":return t.tovPctOnOff;case"orbPct":return t.orbPct;case"orbPctOnOff":return t.orbPctOnOff;case"oppTsPct":return t.oppTsPct;case"oppTsPctOnOff":return t.oppTsPctOnOff;case"oppTovPct":return t.oppTovPct;case"oppTovPctOnOff":return t.oppTovPctOnOff;case"oppOrbPct":return t.oppOrbPct;case"oppOrbPctOnOff":return t.oppOrbPctOnOff;case"rimProfile":return t.offRimFreq??t.defRimFreq;case"rimProfileOnOff":return t.offRimFreqOnOff??t.defRimFreqOnOff;case"midProfile":return t.offMidFreq??t.defMidFreq;case"midProfileOnOff":return t.offMidFreqOnOff??t.defMidFreqOnOff;case"threeProfile":return t.off3pFreq??t.def3pFreq;case"threeProfileOnOff":return t.off3pFreqOnOff??t.def3pFreqOnOff;case"arc3Profile":return t.offArc3Freq??t.defArc3Freq;case"arc3ProfileOnOff":return t.offArc3FreqOnOff??t.defArc3FreqOnOff;case"corner3Profile":return t.offCorner3Freq??t.defCorner3Freq;case"corner3ProfileOnOff":return t.offCorner3FreqOnOff??t.defCorner3FreqOnOff;default:return}},co=(t,r,o,f)=>{const m=[{id:"player",header:"PLAYER",kind:"player",minWidthClass:"min-w-[80px] sm:min-w-[170px]"},{id:"minutes",header:"MIN",kind:"minutes",valueKey:"minutes",minWidthClass:"min-w-[50px] sm:min-w-[64px]",signed:!1}],i=[{id:"rapm",header:"RAPM",kind:"metric",valueKey:"rapm",minWidthClass:"min-w-[76px]",signed:!0},{id:"orapm",header:"ORAPM",kind:"metric",valueKey:"orapm",minWidthClass:"min-w-[80px]",signed:!0},{id:"drapm",header:"DRAPM",kind:"metric",valueKey:"drapm",minWidthClass:"min-w-[80px]",signed:!0},{id:"neff",header:"NEFF",kind:"metric",valueKey:"neff",minWidthClass:"min-w-[76px]",signed:!0},{id:"pval",header:"PVAL",kind:"metric",valueKey:"pval",minWidthClass:"min-w-[76px]",signed:!0},{id:"resid",header:"?",kind:"metric",valueKey:"resid",minWidthClass:"min-w-[76px]",signed:!0}],l=[{id:"orapm",header:"ORAPM",kind:"metric",valueKey:"orapm",minWidthClass:"min-w-[80px]",signed:!0},{id:"oTSRapm",header:"oTS",kind:"metric",valueKey:"oTS",minWidthClass:"min-w-[70px]",signed:!0},{id:"oTOVRapm",header:"oTOV",kind:"metric",valueKey:"oTOV",minWidthClass:"min-w-[74px]",signed:!0},{id:"oREBRapm",header:"oSC",kind:"metric",valueKey:"oSC",minWidthClass:"min-w-[74px]",signed:!0},{id:"oResid",header:"O ?",kind:"metric",valueKey:"oResid",minWidthClass:"min-w-[90px]",signed:!0}],s=[{id:"drapm",header:"DRAPM",kind:"metric",valueKey:"drapm",minWidthClass:"min-w-[80px]",signed:!0},{id:"dTSRapm",header:"dTS",kind:"metric",valueKey:"dTS",minWidthClass:"min-w-[70px]",signed:!0},{id:"dTOVRapm",header:"dTOV",kind:"metric",valueKey:"dTOV",minWidthClass:"min-w-[74px]",signed:!0},{id:"dREBRapm",header:"dSC",kind:"metric",valueKey:"dSC",minWidthClass:"min-w-[74px]",signed:!0},{id:"dResid",header:"D ?",kind:"metric",valueKey:"dResid",minWidthClass:"min-w-[90px]",signed:!0}];if(r==="rapm")return t==="overview"?[...m,...i.filter(S=>S.id!=="resid")]:t==="offense"?[...m,...l]:t==="defense"?[...m,...s]:[...m,...i.filter(S=>!["pval","resid"].includes(S.id)),...l.filter(S=>S.id!=="orapm"),...s.filter(S=>S.id!=="drapm"),i.find(S=>S.id==="pval"),i.find(S=>S.id==="resid")];const d=[{id:"net",header:"NET",kind:"metric",valueKey:"net",minWidthClass:"min-w-[76px]",signed:!0},{id:"netOnOff",header:"NET",subHeader:"ON-OFF",kind:"onoff",valueKey:"netOnOff",minWidthClass:"min-w-[80px]",signed:!0},{id:"off",header:"OFF",kind:"metric",valueKey:"off",minWidthClass:"min-w-[76px]",relativeKey:"off"},{id:"offOnOff",header:"OFF",subHeader:"ON-OFF",kind:"onoff",valueKey:"offOnOff",minWidthClass:"min-w-[80px]",signed:!0},{id:"def",header:"DEF",kind:"metric",valueKey:"def",minWidthClass:"min-w-[76px]",relativeKey:"def"},{id:"defOnOff",header:"DEF",subHeader:"ON-OFF",kind:"onoff",valueKey:"defOnOff",minWidthClass:"min-w-[80px]",signed:!0,lowerBetter:!0}],c=[{id:"off",header:"OFF",kind:"metric",valueKey:"off",minWidthClass:"min-w-[76px]",relativeKey:"off"},{id:"offOnOff",header:"OFF",subHeader:"ON-OFF",kind:"onoff",valueKey:"offOnOff",minWidthClass:"min-w-[80px]",signed:!0},{id:"tsPct",header:"TS%",kind:"metric",valueKey:"tsPct",minWidthClass:"min-w-[76px]",relativeKey:"tsPct"},{id:"tsPctOnOff",header:"TS%",subHeader:"ON-OFF",kind:"onoff",valueKey:"tsPctOnOff",minWidthClass:"min-w-[80px]",signed:!0},{id:"tovPct",header:"TOV%",kind:"metric",valueKey:"tovPct",minWidthClass:"min-w-[76px]",lowerBetter:!0,relativeKey:"tovPct"},{id:"tovPctOnOff",header:"TOV%",subHeader:"ON-OFF",kind:"onoff",valueKey:"tovPctOnOff",minWidthClass:"min-w-[80px]",signed:!0,lowerBetter:!0},{id:"orbPct",header:"ORB%",kind:"metric",valueKey:"orbPct",minWidthClass:"min-w-[76px]",relativeKey:"orbPct"},{id:"orbPctOnOff",header:"ORB%",subHeader:"ON-OFF",kind:"onoff",valueKey:"orbPctOnOff",minWidthClass:"min-w-[80px]",signed:!0}],n=[{id:"rimProfile",header:"RIM",subHeader:"FREQ | FG%",kind:"location",valueKey:"offRimFreq",secondaryValueKey:"offRimFgPct",minWidthClass:"min-w-[94px]",lowerBetter:!1,secondaryLowerBetter:!1},{id:"rimProfileOnOff",header:"RIM",subHeader:`FREQ | FG% 7ON-OFF`,kind:"locationOnOff",valueKey:"offRimFreqOnOff",secondaryValueKey:"offRimFgPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!1,secondaryLowerBetter:!1},{id:"midProfile",header:"MID",subHeader:"FREQ | FG%",kind:"location",valueKey:"offMidFreq",secondaryValueKey:"offMidFgPct",minWidthClass:"min-w-[94px]",lowerBetter:!0,secondaryLowerBetter:!1},{id:"midProfileOnOff",header:"MID",subHeader:`FREQ | FG% 8ON-OFF`,kind:"locationOnOff",valueKey:"offMidFreqOnOff",secondaryValueKey:"offMidFgPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!0,secondaryLowerBetter:!1},{id:"threeProfile",header:"3P",subHeader:"FREQ | FG%",kind:"location",valueKey:"off3pFreq",secondaryValueKey:"off3pPct",minWidthClass:"min-w-[94px]",lowerBetter:!1,secondaryLowerBetter:!1},{id:"threeProfileOnOff",header:"3P",subHeader:`FREQ | FG% 9ON-OFF`,kind:"locationOnOff",valueKey:"off3pFreqOnOff",secondaryValueKey:"off3pPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!1,secondaryLowerBetter:!1},{id:"corner3Profile",header:"CORNER 3",subHeader:"FREQ | FG%",kind:"location",valueKey:"offCorner3Freq",secondaryValueKey:"offCorner3FgPct",minWidthClass:"min-w-[104px]",lowerBetter:!1,secondaryLowerBetter:!1},{id:"corner3ProfileOnOff",header:"CORNER 3",subHeader:`FREQ | FG% 10ON-OFF`,kind:"locationOnOff",valueKey:"offCorner3FreqOnOff",secondaryValueKey:"offCorner3FgPctOnOff",minWidthClass:"min-w-[108px]",signed:!0,lowerBetter:!1,secondaryLowerBetter:!1}],N=[{id:"def",header:"DEF",kind:"metric",valueKey:"def",minWidthClass:"min-w-[76px]",relativeKey:"def"},{id:"defOnOff",header:"DEF",subHeader:"ON-OFF",kind:"onoff",valueKey:"defOnOff",minWidthClass:"min-w-[80px]",signed:!0,lowerBetter:!0},{id:"oppTsPct",header:"OPP TS%",kind:"metric",valueKey:"oppTsPct",minWidthClass:"min-w-[84px]",relativeKey:"oppTsPct"},{id:"oppTsPctOnOff",header:"OPP TS%",subHeader:"ON-OFF",kind:"onoff",valueKey:"oppTsPctOnOff",minWidthClass:"min-w-[90px]",signed:!0,lowerBetter:!0},{id:"oppTovPct",header:"OPP TOV%",kind:"metric",valueKey:"oppTovPct",minWidthClass:"min-w-[90px]",relativeKey:"oppTovPct"},{id:"oppTovPctOnOff",header:"OPP TOV%",subHeader:"ON-OFF",kind:"onoff",valueKey:"oppTovPctOnOff",minWidthClass:"min-w-[96px]",signed:!0},{id:"oppOrbPct",header:"OPP ORB%",kind:"metric",valueKey:"oppOrbPct",minWidthClass:"min-w-[90px]",relativeKey:"oppOrbPct"},{id:"oppOrbPctOnOff",header:"OPP ORB%",subHeader:"ON-OFF",kind:"onoff",valueKey:"oppOrbPctOnOff",minWidthClass:"min-w-[96px]",signed:!0,lowerBetter:!0}],y=[{id:"rimProfile",header:"DEF RIM",subHeader:"FREQ | FG%",kind:"location",valueKey:"defRimFreq",secondaryValueKey:"defRimFgPct",minWidthClass:"min-w-[94px]",lowerBetter:!0,secondaryLowerBetter:!0},{id:"rimProfileOnOff",header:"DEF RIM",subHeader:`FREQ | FG% 11ON-OFF`,kind:"locationOnOff",valueKey:"defRimFreqOnOff",secondaryValueKey:"defRimFgPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!0,secondaryLowerBetter:!0},{id:"midProfile",header:"DEF MID",subHeader:"FREQ | FG%",kind:"location",valueKey:"defMidFreq",secondaryValueKey:"defMidFgPct",minWidthClass:"min-w-[94px]",lowerBetter:!0,secondaryLowerBetter:!0},{id:"midProfileOnOff",header:"DEF MID",subHeader:`FREQ | FG% 12ON-OFF`,kind:"locationOnOff",valueKey:"defMidFreqOnOff",secondaryValueKey:"defMidFgPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!0,secondaryLowerBetter:!0},{id:"threeProfile",header:"DEF 3P",subHeader:"FREQ | FG%",kind:"location",valueKey:"def3pFreq",secondaryValueKey:"def3pPct",minWidthClass:"min-w-[94px]",lowerBetter:!0,secondaryLowerBetter:!0},{id:"threeProfileOnOff",header:"DEF 3P",subHeader:`FREQ | FG% 13ON-OFF`,kind:"locationOnOff",valueKey:"def3pFreqOnOff",secondaryValueKey:"def3pPctOnOff",minWidthClass:"min-w-[98px]",signed:!0,lowerBetter:!0,secondaryLowerBetter:!0},{id:"corner3Profile",header:"DEF CORNER 3",subHeader:"FREQ | FG%",kind:"location",valueKey:"defCorner3Freq",secondaryValueKey:"defCorner3FgPct",minWidthClass:"min-w-[110px]",lowerBetter:!0,secondaryLowerBetter:!0},{id:"corner3ProfileOnOff",header:"DEF CORNER 3",subHeader:`FREQ | FG% 14ON-OFF`,kind:"locationOnOff",valueKey:"defCorner3FreqOnOff",secondaryValueKey:"defCorner3FgPctOnOff",minWidthClass:"min-w-[114px]",signed:!0,lowerBetter:!0,secondaryLowerBetter:!0}],W=o==="location"?n:c,E=f==="location"?y:N;return t==="overview"?[...m,...d]:t==="offense"?[...m,...W]:t==="defense"?[...m,...E]:[...m,...d,...c.filter(S=>!["off","offOnOff"].includes(S.id)),...N.filter(S=>!["def","defOnOff"].includes(S.id))]},fo=(t,r,o,f)=>t==="rapm"?r==="overview"?["rapm","orapm","drapm","neff","pval"]:r==="offense"?["orapm","oTSRapm"]:r==="defense"?["drapm","dTSRapm"]:["rapm","orapm","drapm","neff","oTSRapm","dTSRapm","pval","resid"]:r==="offense"&&o==="location"?["rimProfile","midProfile","threeProfile","corner3Profile"]:r==="defense"&&f==="location"?["rimProfile","midProfile","threeProfile","corner3Profile"]:["net","off","def","tsPct","tovPct","orbPct","oppTsPct","oppTovPct","oppOrbPct"],us=(t,r,o,f,m)=>fo(t,r,o,f).includes(m),gs=(t,r,o,f,m)=>t==="onoff"?r==="offense"&&o==="location"||r==="defense"&&f==="location"?m==="rimProfileOnOff":m==="netOnOff":r==="overview"?m==="rapm":r==="offense"?m==="orapm":r==="defense"?m==="drapm":!1,mo=t=>["def","defOnOff","tovPct","tovPctOnOff","oppTsPct","oppTsPctOnOff","oppOrbPct","oppOrbPctOnOff","midProfile","midProfileOnOff"].includes(t),po=()=>{const t=Ze();return e.jsxs("div",{className:"mx-auto rounded-lg border border-border shadow-sm bg-card w-full sm:w-[719px] min-h-[420px] sm:h-[660px] overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-4 py-2 md:py-3 border-b border-border",children:[e.jsx("div",{className:"justify-self-start",children:e.jsx(St,{className:Nn(t)})}),e.jsx("div",{className:"justify-self-center",children:e.jsxs("div",{className:"inline-flex rounded-xl border border-border bg-muted/70 p-0.5",children:[e.jsx(ne,{className:h("h-6 w-20 rounded-lg",Ur(t))}),e.jsx(ne,{className:"ml-1 h-6 w-20 rounded-lg"})]})}),e.jsxs("div",{className:"flex flex-col items-end gap-1 justify-self-end",children:[e.jsx(ne,{className:"h-3 w-44 rounded"}),e.jsx(ne,{className:"h-3 w-24 rounded"})]})]}),e.jsx("div",{className:"border-b border-border bg-card",children:e.jsxs("div",{className:"grid grid-cols-[1.7fr_repeat(6,minmax(0,1fr))] gap-0",children:[e.jsx("div",{className:"px-3 py-3 border-r border-border",children:e.jsx(ne,{className:"h-4 w-24"})}),Array.from({length:6}).map((r,o)=>e.jsx("div",{className:"px-3 py-3 border-r border-border last:border-r-0",children:e.jsx(ne,{className:"mx-auto h-4 w-14"})},`header-skeleton-${o}`))]})}),e.jsx("div",{className:"h-[520px] overflow-hidden",children:Array.from({length:9}).map((r,o)=>e.jsxs("div",{className:"grid grid-cols-[1.7fr_repeat(6,minmax(0,1fr))] border-b border-border/70",children:[e.jsxs("div",{className:"px-3 py-3 border-r border-border flex items-center gap-3",children:[e.jsx(ne,{className:"h-9 w-9 rounded-full"}),e.jsx(ne,{className:"h-4 w-24"})]}),Array.from({length:6}).map((f,m)=>e.jsxs("div",{className:"px-3 py-3 border-r border-border last:border-r-0",children:[e.jsx(ne,{className:"mx-auto h-4 w-12"}
14),e.jsx(ne,{className:"mx-auto mt-1 h-3 w-8 opacity-70"})]},`cell-skeleton-${o}-${m}`))]},`team-row-skeleton-${o}`))}),e.jsxs("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",children:[e.jsx(ne,{className:h("h-8 w-36 rounded-full",Ur(t))}),e.jsx(ne,{className:"h-8 w-40 rounded-full bg-secondary/20"}),e.jsx(ne,{className:"h-4 flex-1 max-w-[280px]"})]})]})},uo=Ot.memo(Ot.forwardRef(function({selectedTeam:r,seasonType:o,startYear:f,endYear:m,leverageFilter:i,activeView:l,wowyStats:s,availablePlayers:d,timedecayRapmRows:c,defLuckAdjustment:n=0,offLuckAdjustment:N=0,isLoading:y,isTimedecayRapmLoading:W=!1,onPlayerSelect:E,theme:S="dark",offenseDetailMode:j,defenseDetailMode:A,onTableModeChange:T},p){const F=Ze(),[ie,$]=_.useState([]),[G,M]=_.useState("onoff"),[ge,te]=_.useState(!1),[oe,ce]=_.useState({}),[K,b]=_.useState(null),[X,V]=_.useState("desc"),[me,ve]=_.useState(""),[z,Ce]=_.useState(()=>typeof window>"u"?!0:window.innerWidth>=640);_.useEffect(()=>{T==null||T(G)},[T,G]);const le=_.useMemo(()=>r?Tt(r,F):"",[F,r]),je=_.useMemo(()=>{const g=new Map(d.map(O=>[O.nba_id,O]));return c.forEach(O=>{const Z=String(O.nba_id);g.has(Z)||g.set(Z,{id:Number(O.nba_id),name:O.player_name||`Player ${O.nba_id}`,nba_id:Z,year:O.year??m,vpm:0,Pos2:O.pos2??null,dpm:null,o_dpm:null,d_dpm:null,td_rapm:null,td_orapm:null,td_drapm:null,Minutes:null})}),Array.from(g.values())},[d,m,c]);_.useEffect(()=>{ce({})},[F,r,f,m,je]);const Y=_.useMemo(()=>f===m?`${f}`:`${f}-${m}`,[f,m]),xe=_.useMemo(()=>co(l,G,j,A),[l,G,j,A]),pe=_.useMemo(()=>c.reduce((g,O)=>(g.set(String(O.nba_id),O),g),new Map),[c]),Fe=_.useMemo(()=>ie.map(g=>{const O=pe.get(g.player.nba_id);if(!O)return g;const Z=O.oSC??O.oREB,R=O.dSC??O.dREB,U=Number.isFinite(O.off)&&Number.isFinite(O.oTS)&&Number.isFinite(O.oTOV)&&Number.isFinite(Z),ue=Number.isFinite(O.def)&&Number.isFinite(O.dTS)&&Number.isFinite(O.dTOV)&&Number.isFinite(R);return{...g,rapm:O.net_rapm,orapm:O.off,drapm:O.def,neff:Number.isFinite(O.oTS)&&Number.isFinite(O.dTS)?O.oTS+O.dTS:void 0,pval:O.pval,resid:O.RESID,oResid:U?O.off-(O.oTS+O.oTOV+Z):void 0,dResid:ue?O.def-(O.dTS+O.dTOV+R):void 0,oTS:O.oTS,oTOV:O.oTOV,oREB:Z,oSC:Z,dTS:O.dTS,dTOV:O.dTOV,dREB:R,dSC:R}}),[ie,pe]);_.useEffect(()=>{if(typeof window>"u")return;const g=()=>{Ce(window.innerWidth>=640)};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}},[]),_.useEffect(()=>{let g=!1;return(async()=>{te(!0);const Z=await Zn({stats:s,availablePlayers:je,defLuckAdjustment:n,offLuckAdjustment:N});g||($(Z),te(!1))})().catch(Z=>{console.error("[WowyTeamPlayersTable] Failed to build team rows",Z),g||($(je.map(R=>({player:R}))),te(!1))}),()=>{g=!0}},[je,s,n,N]),_.useEffect(()=>{if(!K)return;xe.some(O=>O.id===K)||(b(null),V("desc"))},[xe,K]);const Oe=_.useCallback(g=>{if(K===g){V(R=>R==="asc"?"desc":"asc");return}if(b(g),g==="player"){V("asc");return}const Z=["rimProfile","rimProfileOnOff","midProfile","midProfileOnOff","threeProfile","threeProfileOnOff","arc3Profile","arc3ProfileOnOff","corner3Profile","corner3ProfileOnOff"].includes(g)&&l==="defense"&&A==="location"?!0:mo(g);V(Z?"asc":"desc")},[K,l,A]),k=_.useMemo(()=>{const g=me.length>0?Number.parseInt(me,10):Number.NaN,Z=Number.isFinite(g)?Fe.filter(U=>U.minutes!==void 0&&Number.isFinite(U.minutes)&&U.minutes>=g):Fe;if(!K)return Z;const R=[...Z];return K==="player"?(R.sort((U,ue)=>{const re=U.player.name.localeCompare(ue.player.name);return X==="asc"?re:-re}),R):(R.sort((U,ue)=>{const re=ps(U,K),we=ps(ue,K),fe=re===void 0||!Number.isFinite(re),he=we===void 0||!Number.isFinite(we);return fe&&he?0:fe?1:he?-1:X==="asc"?re-we:we-re}),R)},[Fe,K,X,me]),H=_.useCallback(g=>{z&&E(g)},[z,E]),_e=y||ge||G==="rapm"&&W,J=jn(F),D=wn(F);return e.jsx("div",{className:"overflow-hidden font-numeric w-full mx-auto",children:e.jsx(wr,{mode:"wait",children:_e?e.jsx(Xe.div,{initial:{opacity:0}
14,animate:{opacity:1},exit:{opacity:0},className:"w-full",children:e.jsx(po,{})},"team-loading"):e.jsx(Xe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"w-full",children:e.jsxs("div",{ref:p,className:`mx-auto rounded-lg border border-border shadow-sm bg-card w-full sm:w-fit max-w-full overflow-hidden wowy-${S}`,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-4 py-2 md:py-3 border-b border-border",children:[e.jsx("div",{className:"justify-self-start",children:e.jsx(St,{className:Wr(F)})}),e.jsx("div",{className:"justify-self-center",children:e.jsxs("div",{className:"inline-flex rounded-xl border border-border bg-muted/70 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>M("onoff"),className:h("rounded-lg px-2.5 py-1 text-[10px] sm:text-xs font-semibold transition-colors",G==="onoff"?"bg-white text-slate-900 shadow-sm":"text-muted-foreground hover:text-foreground"),"aria-pressed":G==="onoff",children:"ON-OFF"}),e.jsx("button",{type:"button",onClick:()=>M("rapm"),className:h("rounded-lg px-2.5 py-1 text-[10px] sm:text-xs font-semibold transition-colors",G==="rapm"?"bg-white text-slate-900 shadow-sm":"text-muted-foreground hover:text-foreground"),"aria-pressed":G==="rapm",children:"RAPM"})]})}),e.jsxs("div",{className:"flex flex-col items-end gap-0.5 ml-4 justify-self-end text-right",children:[e.jsxs("p",{className:"text-xs max-[500px]:text-[9px] text-muted-foreground leading-tight",children:[Y," ⢠",eo(o)]}),e.jsx("p",{className:"text-xs max-[500px]:text-[9px] text-muted-foreground leading-tight",children:i==="high"?"Low Leverage Removed":"All Leverage"})]})]}),e.jsx("div",{className:"relative max-h-[560px] overflow-auto [scrollbar-width:thin] [scrollbar-color:rgba(148,163,184,0.45)_transparent] [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-slate-400/45 hover:[&::-webkit-scrollbar-thumb]:bg-slate-300/55",children:e.jsxs("table",{className:"w-max table-auto caption-bottom text-xs sm:text-sm",children:[e.jsx("thead",{className:"[&_tr]:border-b",children:e.jsx(cr,{children:e.jsx("tr",{children:xe.map(g=>{const O=g.id==="player",Z=gs(G,l,j,A,g.id),U=K===g.id?X==="asc"?"ascending":"descending":"none",ue=lo(g);return e.jsxs("th",{"aria-sort":U,className:h(g.minWidthClass,"px-1.5 py-0.5 max-sm:px-1 max-sm:py-0.5 sticky top-0 z-30 border-b border-border/80",g.id==="minutes"?"h-11 sm:h-12 align-top pt-1 sm:pt-1.5 pb-1.5 sm:pb-2":"h-8 sm:h-9 align-middle",O?"text-left z-40 bg-card max-sm:sticky max-sm:left-0 max-sm:shadow-[2px_0_5px_-2px_rgba(0,0,0,0.15)] sm:shadow-none":"text-center bg-card",g.id==="player"?"max-sm:min-w-[78px]":g.id==="minutes"?"max-sm:min-w-[46px]":"max-sm:min-w-[56px]",Z&&D,us(G,l,j,A,g.id)&&"border-l border-border/60"),children:[e.jsxs(fr,{children:[e.jsx(mr,{asChild:!0,children:e.jsx("button",{type:"button",onClick:()=>Oe(g.id),className:h("w-full text-left font-semibold text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-sm px-0.5 max-sm:text-[11px]",O?"text-left":"text-center"),"aria-label":`Sort by ${g.header}${g.subHeader?` ${g.subHeader}`:""}`,children:g.id==="player"?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[le&&e.jsx("img",{src:le,alt:`${r} logo`,className:"h-5 w-5 sm:h-6 sm:w-6 object-contain"}),e.jsx("span",{children:g.header})]}):e.jsxs("span",{className:"block leading-tight",children:[e.jsx("span",{className:"block",children:g.header}),g.subHeader?e.jsx("span",{className:"block leading-tight text-muted-foreground",children:g.subHeader.split(` 15`).map((re,we)=>e.jsx("span",{className:"block text-[10px] ",children:we===0&&re.includes("FREQ | FG%")?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"FREQ"}),e.jsx("span",{className:"text-foreground",children:" | "}),e.jsx("span",{className:"text-muted-foreground",children:"FG%"})]}):re},re))}):null]})})}),e.jsxs(pr,{side:"top",className:"max-w-[260px]",children:[e.jsx("p",{className:"text-xs font-semibold",children:ue.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ue.description}),ue.relativeNote?e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ue.relativeNote}):null,e.jsx("p",{className:"text-xs italic mt-1",children:"Click to sort."})]})]}),g.id==="minutes"?e.jsx("div",{className:"mt-1 px-0.5 pb-0.5",children:e.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:me,onClick:re=>re.stopPropagation(),onKeyDown:re=>re.stopPropagation(),onChange:re=>{const we=re.target.value.replace(/\D/g,"");ve(we)}
15,placeholder:"min","aria-label":"Minimum minutes filter",className:"mx-auto h-5 w-9 text-[9px] sm:h-6 sm:w-11 sm:text-[10px] rounded border border-border/70 bg-background/80 px-1 text-center text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary"})}):null]},g.id)})})})}),e.jsx("tbody",{className:"[&_tr:last-child]:border-0",children:k.length===0?e.jsx("tr",{className:"border-b transition-colors sm:hover:bg-muted/50 data-[state=selected]:bg-muted",children:e.jsx("td",{className:"text-center text-muted-foreground py-8",colSpan:xe.length,children:"No players found for this team."})}):k.map(g=>{const O=ot(g.player.nba_id,F),Z=oe[g.player.nba_id]===!0;return e.jsx("tr",{tabIndex:z?0:void 0,role:z?"button":void 0,onClick:()=>H(g.player),onKeyDown:R=>{z&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),H(g.player))},className:"border-b transition-colors sm:hover:bg-accent/20 data-[state=selected]:bg-muted sm:cursor-pointer duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary [&>td]:transition-colors [&>td]:duration-150",children:xe.map(R=>{const U=gs(G,l,j,A,R.id);if(R.id==="player")return e.jsx("td",{className:h(R.minWidthClass,"px-2 py-1.5 max-sm:px-1.5 max-sm:py-1 max-sm:min-w-[78px] max-sm:sticky max-sm:left-0 max-sm:z-20 max-sm:bg-card max-sm:shadow-[2px_0_5px_-2px_rgba(0,0,0,0.12)] sm:shadow-none"),children:e.jsxs("button",{type:"button",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),H(g.player)},tabIndex:z?0:-1,"aria-disabled":!z,className:"flex items-center gap-2 text-left max-sm:w-full max-sm:justify-center max-sm:flex-col max-sm:items-center max-sm:gap-0.5","aria-label":`View WOWY details for ${g.player.name}`,children:[e.jsx("div",{className:"relative h-9 w-9 sm:h-9 sm:w-9 rounded-full overflow-hidden ring-[1.5px] sm:ring-1 ring-primary sm:ring-border bg-muted flex items-center justify-center",children:Z?e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground",children:g.player.name.split(" ").map(Se=>Se[0]).join("").slice(0,2).toUpperCase()}):e.jsx("div",{className:"absolute inset-0 h-[122%]",children:e.jsx("img",{src:O,alt:g.player.name,className:"h-full w-full object-cover object-top",style:{transform:"scale(1.14)",transformOrigin:"top"},onError:()=>ce(Se=>({...Se,[g.player.nba_id]:!0}))})})}),e.jsx("div",{className:"flex flex-col min-w-0 max-sm:items-center",children:e.jsxs("span",{className:"text-[10px] sm:text-sm font-medium text-foreground truncate max-sm:max-w-[72px] max-sm:text-center",children:[e.jsx("span",{className:"sm:hidden",children:ao(g.player.name)}),e.jsx("span",{className:"hidden sm:inline",children:g.player.name})]})})]})},R.id);if(R.id==="minutes")return e.jsx("td",{className:h(R.minWidthClass,"px-1.5 py-1.5 max-sm:px-0.5 max-sm:py-1 max-sm:min-w-[46px] text-center"),children:e.jsx("span",{className:"font-bold text-foreground whitespace-nowrap",children:to(g.minutes)})},R.id);const ue=R.valueKey===void 0?void 0:g[R.valueKey],re=R.secondaryValueKey===void 0?void 0:g[R.secondaryValueKey],we=R.kind==="onoff",fe=R.kind==="location",he=R.kind==="locationOnOff",P=Ar({rimFreqPct:g.lgAvgRimFreq,rimFgPct:g.lgAvgRimAcc,threeFreqPct:g.lgAvg3pFreq,threeFgPct:g.lgAvgThree,fg2Pct:g.lgAvgFg2Pct}),I=oo(g,R.valueKey,P),ee=io(g,R.secondaryValueKey,P),ye=fe?He(ue,I):void 0,Te=fe?He(re,ee):void 0,$e=no(g,R.relativeKey),Me=R.relativeKey!==void 0,ke=R.relativeKey==="off"?ro($e,F):R.relativeKey==="def"?so($e,F):et($e,F,R.lowerBetter),We=G==="rapm"&&R.kind==="metric",de=we?et(ue,F,R.lowerBetter):R.id==="net"||We?et(ue,F,!1):"text-foreground";return e.jsx("td",{className:h(R.minWidthClass,"px-1.5 py-1.5 max-sm:px-1 max-sm:py-1 max-sm:min-w-[56px] text-center",us(G,l,j,A,R.id)&&"border-l border-border/60",U&&J),children:fe?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-0.5 leading-tight w-full",children:[e.jsx(tr,{left:er(ue),right:Zt(re,!1,z),leftClassName:"text-[11px] sm:text-[12px] font-medium text-muted-foreground/90",rightClassName:"text-[11px] sm:text-[12px] font-semibold text-foreground",separatorClassName:"text-[9px] text-muted-foreground
15/65"}),e.jsx(tr,{left:er(ye,!0),right:Zt(Te,!0,z),leftClassName:h("text-[8px] sm:text-[11px] font-semibold",et(ye,F,R.lowerBetter)),rightClassName:h("text-[8px] sm:text-[11px] font-semibold",et(Te,F,R.secondaryLowerBetter)),separatorClassName:"text-[8px] text-muted-foreground/65"})]}):he?e.jsx("div",{className:"flex flex-col items-center justify-center gap-0.5 leading-tight w-full",children:e.jsx(tr,{left:er(ue,!0),right:Zt(re,!0,z),leftClassName:h("text-[10px] sm:text-[11px] font-semibold",et(ue,F,R.lowerBetter)),rightClassName:h("text-[10px] sm:text-[11px] font-semibold",et(re,F,R.secondaryLowerBetter)),separatorClassName:"text-[9px] text-muted-foreground/65"})}):Me?e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:"font-bold text-foreground whitespace-nowrap",children:fs(ue)}),e.jsx("span",{className:h("text-[9px] sm:text-[11px] leading-tight whitespace-nowrap",ke),children:ms($e)})]}):e.jsx("span",{className:h("font-bold whitespace-nowrap",de),children:R.signed?ms(ue):fs(ue)})},R.id)})},g.player.nba_id)})})]})}),e.jsx("div",{className:"border-t border-border/70 px-3 py-2 bg-card",children:e.jsxs("div",{className:"flex flex-col gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:Fn(F),children:"Primary = Good"}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-secondary/40 bg-secondary/10 px-2 py-0.5 font-semibold text-secondary",children:"Secondary = Bad"}),G==="onoff"?l!=="overview"&&(l==="offense"&&j==="location"||l==="defense"&&A==="location")?e.jsx("span",{className:"text-muted-foreground/80",children:"In location view, top row is frequency (decimal) and FG. Bottom row is league-relative deltas. ON-OFF columns stay signed deltas."}):e.jsx("span",{className:"text-muted-foreground/80",children:"Subtext under raw metrics = on-court value relative to league average."}):e.jsxs("span",{className:"text-muted-foreground/80",children:["RAPM mode uses ",m-f+1,"Y RAPM DECOMP from active Alt3 EFG-value weighted factors. Positive values are better."]})]}),G==="rapm"?e.jsxs("span",{className:"text-muted-foreground/80",children:["Learn more in"," ",e.jsx(or,{to:"/six-factor-rapm",className:"text-secondary hover:underline hover:text-secondary/90",children:"six-factor RAPM methodology"}),"."]}):null]})})]})},"team-content")})})})),go=t=>{const r=t.year??t.Year,o=Number(r);return Number.isFinite(o)?o:null};function hr(t,r,o,f){if(!t.length)return[];const m=new Set(r.map(y=>y.nba_id.toString())),i=new Set(o.map(y=>y.nba_id.toString())),l=new Set([...m,...i]),s=new Map,d=new Map;let c=0,n=0;if(t.forEach(y=>{const W=y.EntityId.split("-"),E=new Set(W),S=go(y),j=r.every(T=>E.has(T.nba_id.toString())),A=o.every(T=>!E.has(T.nba_id.toString()));if(r.length===1&&o.length===0&&j||o.length===1&&r.length===0&&!E.has(o[0].nba_id.toString())||j&&A){const T=Number(y.Minutes)||0;if(T<=0)return;c+=T,S===null&&(n+=1),W.forEach(p=>{if(!l.has(p)){if(s.set(p,(s.get(p)||0)+T),S===null)return;d.has(p)||d.set(p,new Map);const F=d.get(p);F.set(S,(F.get(S)||0)+T)}})}}),c<=0)return[];n>0&&console.warn(`[lineupPartners] ${n} row(s) missing year. Partner percentages are still calculated, but yearly weighting may be incomplete.`);const N=[];return s.forEach((y,W)=>{const E=f.find(S=>S.nba_id.toString()===W);if(E){const S=y/c*100,j=d.get(W),A=Array.from((j==null?void 0:j.entries())||[]).map(([T,p])=>({year:T,minutes:p}));N.push({player:E,minutes:y,percentage:S,yearlyMinutes:A.sort((T,p)=>T.year-p.year),off:0,def:0,net:0})}}),N.sort((y,W)=>W.minutes-y.minutes)}const ze=t=>typeof t=="number"&&Number.isFinite(t),xo=t=>{const r=new Map;return t.yearlyMinutes.forEach(({year:o,minutes:f})=>{!Number.isFinite(o)||!Number.isFinite(f)||f<=0||r.set(o,(r.get(o)||0)+f)}),r},It=(t,r,o)=>{if(!r)return;let f=0,m=0;if(t.forEach((i,l)=>{const s=r[l],d=s==null?void 0:s[o];!ze(d)||i<=0||(f+=d*i,m+=i)}),!(m<=0))return f/m},_o=(t,r)=>{if(!t)return;let o=0,f=0;if(Object.values(t).forEach(m=>{const i=m==null?void 0:m[r];ze(i)&&(o+=i,f+=1)}),!(f<=0))return o/f},ho=(t,r,o,f)=>{const m=f[t];if(m){if(o.size>0){const i=It(o,m,r);if(ze(i))return i}return _o(m,r)}},vo=(t,r)=>t.map(o=>{const f=xo(o),m=r[o.player.nba_id.toString()],i=It(f,m,"dpm"),l=It(f,m,"o_dpm"),s=It(f,m,"d_dpm");return{...o,metrics:ze(i)&&ze(l)&&ze(s)?{dpm:i,o_dpm:l,d_dpm:s}:void 0,yearDistribution:f}}
15),rr=(t,r,o)=>{let f=0,m=0;if(t.forEach(s=>{var c;const d=(c=s.metrics)==null?void 0:c[o];ze(d)&&(f+=d*s.percentage,m+=s.percentage)}),m<=0)return;const i=f/m,l=Math.max(0,5-r);return i*l},yo=t=>{const r=new Map;t.forEach(f=>{f.yearDistribution.forEach((m,i)=>{if(!Number.isFinite(m)||m<=0)return;const l=r.get(i);if(!l){r.set(i,{weightedSum:m,totalMinutes:m});return}l.weightedSum+=m,l.totalMinutes+=m,r.set(i,l)})});const o=new Map;return r.forEach((f,m)=>{f.totalMinutes<=0||o.set(m,f.weightedSum)}),o},sr=(t,r,o,f,m)=>{let i=0,l=!1;if(t.forEach(s=>{const d=ho(s.nba_id.toString(),m,r,o);ze(d)&&(i+=d,l=!0)}),!(!l&&!ze(f)))return l?ze(f)?i+f:i:f},vr=({partners:t,onPlayers:r,playerMetricsByYear:o})=>{const f=vo(t,o),m=rr(f,r.length,"dpm"),i=rr(f,r.length,"o_dpm"),l=rr(f,r.length,"d_dpm"),s=yo(f),d=sr(r,s,o,m,"dpm"),c=sr(r,s,o,i,"o_dpm"),n=sr(r,s,o,l,"d_dpm");return{partnersWithMetrics:f,teammateHelp:{net:m,off:i,def:l},expectedLineup:{net:d,off:c,def:n}}},Ft=t=>{if(!ze(t))return"-";const r=t.toFixed(1);return t>0?`+${r}`:r},bo=t=>t.split(" ")[0]||"",Q=t=>typeof t=="number"&&Number.isFinite(t),tt=(t,r=!1)=>{if(!Q(t))return"-";const o=Number(t.toFixed(1)),f=Math.abs(o).toFixed(1);return r?t>0?`+${f}`:t<0?`-${f}`:f:t<0?`-${f}`:f},rt=(t,r=!1,o=!0)=>{if(!Q(t))return"-";const f=Number(t.toFixed(1)),m=Math.abs(f).toFixed(1),i=o?"%":"";return r?t>0?`+${m}${i}`:t<0?`-${m}${i}`:m+i:(t<0?`-${m}`:m)+i},xs=({player:t,isOn:r,numPlayers:o,teamAbbr:f})=>{const m=Ze(),i=y=>(y.preventDefault(),y.stopPropagation(),!1),l=sn(t.name,10),s=qr(f,m),d=r?kr(f,m):void 0,c=Mr(f,m),n=o>=5?"w-10 h-10 sm:w-12 sm:h-12":o>=4?"w-12 h-12 sm:w-14 sm:h-14":"w-14 h-14 sm:w-16 sm:h-16",N=o>=5?"text-[9px]":o>=4?"text-[10px]":"text-xs";return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:h("relative rounded-full overflow-hidden transition-all duration-300",n,r?"opacity-100":"opacity-40",r&&!f?"ring-2 ring-primary":""),style:{...s,...d},draggable:"false",onDragStart:i,children:[f&&e.jsx("img",{src:Tt(f,m),alt:"","aria-hidden":"true",className:"absolute inset-[6%] z-0 h-[88%] w-[88%] scale-[1.2] object-contain select-none",style:c,draggable:"false",onDragStart:i,onError:y=>{y.currentTarget.style.display="none"}}),e.jsx("div",{className:"absolute inset-0 z-[1] h-[120%]",draggable:"false",onDragStart:i,children:e.jsx("img",{src:ot(t.nba_id,m),alt:t.name,className:"w-full h-full object-cover object-top bg-muted select-none",style:{WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none",pointerEvents:"none",transform:"scale(1.2)",transformOrigin:"top"},draggable:"false",onDragStart:i})}),!r&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/28 pointer-events-none",children:e.jsx("span",{className:"text-white text-[10px] font-semibold tracking-[0.08em] bg-black/60 px-1.5 py-0.5 rounded-sm shadow-[0_0_10px_rgba(0,0,0,0.35)]",children:"OFF"})})]}),e.jsx("span",{className:h("text-center text-white max-w-full truncate mt-0.5",N),children:l})]})};function Ys({isOpen:t,onClose:r,onPlayers:o,offPlayers:f,partners:m,partnersWithMetrics:i=[],teammateHelp:l,startYear:s,endYear:d,teamAbbr:c,ratings:n,isPaddingEnabled:N=!1,isLoadingDetails:y=!1}){const W=Ze(),E=i,S=y,j=o.length+f.length,[A,T]=_.useState(window.innerWidth),p=A<450,[F,ie]=_.useState(!1),[$,G]=_.useState(!1),M=_.useRef(null),{toast:ge}=Fr(),te=P=>e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("span",{children:P}),N&&e.jsx("span",{className:"text-primary text-[10px] sm:text-xs -top-1 relative ml-0.5 font-bold",children:"P"})]});_.useEffect(()=>{t&&ie(!1)},[t]),_.useEffect(()=>{const P=()=>{T(window.innerWidth)};return window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P)}},[]);const oe=P=>(P.preventDefault(),P.stopPropagation(),!1),ce=P=>{if(!Q(P))return null;const I=P.toFixed(1);return P>0?`+${I}`:I},K=(P,I,ee="overview")=>{if(!P.length)return;let ye=0,Te=0;if(P.forEach(ke=>{var de,Se,qe;const We=ee==="offense"?(de=ke.metrics)==null?void 0:de.o_dpm:ee==="defense"?(Se=ke.metrics)==null?void 0:Se.d_dpm:(qe=ke.metrics)==null?void 0:qe.dpm;Q(We)&&(ye+=We*ke.percentage,Te+=ke.percentage)}),Te<=0)return;
15const $e=ye/Te,Me=Math.max(0,5-I);return $e*Me},b=Q(l==null?void 0:l.net)?l.net:K(E,o.length,"overview"),X=Q(l==null?void 0:l.off)?l.off:K(E,o.length,"offense"),V=Q(l==null?void 0:l.def)?l.def:K(E,o.length,"defense"),me=P=>{if(P)return P.dpm},ve=()=>"DARKO",z=P=>Q(P)?P.toFixed(1):"-",Ce=P=>Q(P)?`${P>0?"+":""}${P.toFixed(1)}`:"-",le=P=>Q(P)?P<0?P.toFixed(1):Math.abs(P).toFixed(1):"-",je=()=>{const P=n==null?void 0:n.total_fg3a;return!Q(P)||P<=0?"-":(((n==null?void 0:n.total_fg3m)||0)/P*100).toFixed(1)+"%"},Y=()=>Q(n==null?void 0:n.fg3_pct)?n.fg3_pct.toFixed(1)+"%":"-",xe=P=>{if(!Q(P))return"-";const I=P.toFixed(1);return(P>0?"+":"")+I},pe=()=>n?Q(n.rel_net)?n.rel_net:Q(n.rel_off)&&Q(n.rel_def)?n.rel_off-n.rel_def:Q(n.net)?n.net:null:null,Fe=()=>`Lineups Analysis ${s===d?`(${s})`:`(${s}-${d})`}`,Oe=()=>{if(!(!Q(n==null?void 0:n.ts_pct)||!Q(n==null?void 0:n.lg_avg_ts)))return n.ts_pct-n.lg_avg_ts},k=()=>{if(!(!Q(n==null?void 0:n.tov_pct)||!Q(n==null?void 0:n.lg_avg_tov)))return n.tov_pct-n.lg_avg_tov},H=()=>{if(!(!Q(n==null?void 0:n.orb_pct)||!Q(n==null?void 0:n.lg_avg_orb)))return n.orb_pct-n.lg_avg_orb},_e=()=>{if(!(!Q(n==null?void 0:n.opp_ts_pct)||!Q(n==null?void 0:n.lg_avg_ts)))return n.opp_ts_pct-n.lg_avg_ts},J=()=>{if(!(!Q(n==null?void 0:n.opp_tov_pct)||!Q(n==null?void 0:n.lg_avg_tov)))return n.opp_tov_pct-n.lg_avg_tov},D=()=>{if(!(!Q(n==null?void 0:n.opp_orb_pct)||!Q(n==null?void 0:n.lg_avg_orb)))return n.opp_orb_pct-n.lg_avg_orb},g=Q(n==null?void 0:n.def)&&Q(n==null?void 0:n.lg_avg_ortg)?n.def-n.lg_avg_ortg:n==null?void 0:n.rel_def,O=n?Ar({rimFreqPct:n.lg_avg_rim_freq,rimFgPct:n.lg_avg_rim_acc,threeFreqPct:n.lg_avg_3p_freq,threeFgPct:n.lg_avg_three,fg2Pct:n.lg_avg_fg2_pct}):void 0,Z=Q(n==null?void 0:n.off_rim_freq)||Q(n==null?void 0:n.off_mid_freq)||Q(n==null?void 0:n.off_3p_freq),R=Q(n==null?void 0:n.def_rim_freq)||Q(n==null?void 0:n.def_mid_freq)||Q(n==null?void 0:n.def_3p_freq),U=y||E.length>0||m.length>0,ue=N&&(Q(n==null?void 0:n.raw_net)||Q(n==null?void 0:n.raw_off)||Q(n==null?void 0:n.raw_def)),re=(P,I)=>!Q(P)||P===0?"text-muted-foreground":(I?P<0:P>0)?"text-primary":"text-secondary",we=P=>e.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-foreground uppercase tracking-wider text-center",children:P==="offense"?"Offensive":"Defensive"}),e.jsxs("div",{className:"grid grid-cols-3 gap-0.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:P==="offense"?"TS%":"D-TS%"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:P==="offense"?"TOV%":"D-TOV%"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:P==="offense"?"ORB%":"D-ORB%"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-0.5 text-center",children:Array.from({length:3}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-4 w-10 rounded-sm"})},`${P}-factor-main-${ee}`))}),e.jsx("div",{className:"grid grid-cols-3 gap-0.5 text-center",children:Array.from({length:3}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-3 w-8 rounded-sm"})},`${P}-factor-rel-${ee}`))}),e.jsx("div",{className:"border-t border-dotted border-border/50 mt-1 mb-0.5"}),e.jsx("div",{className:"text-[10px] font-semibold text-foreground uppercase tracking-wider text-center",children:"Shot Location"}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center items-end",children:[e.jsx("div",{}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"RIM"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"MID"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"3P"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"C3"})]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center items-center",children:[e.jsx("div",{className:"text-[8px] text-muted-foreground/60 font-medium text-right pr-0.5",children:"FREQ"}),Array.from({length:4}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-3 w-8 rounded-sm"})},`${P}-freq-main-${ee}`))]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center",children:[e.jsx("div",{}),Array.from({length:4}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-3 w-7 rounded-sm"})},`${P}-freq-rel-${ee}`))]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center items-center",children:[e.jsx("div",{className:"text-[8px] text-muted-foreground
15/60 font-medium text-right pr-0.5",children:"FG%"}),Array.from({length:4}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-3 w-8 rounded-sm"})},`${P}-fg-main-${ee}`))]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center",children:[e.jsx("div",{}),Array.from({length:4}).map((I,ee)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:"h-3 w-7 rounded-sm"})},`${P}-fg-rel-${ee}`))]})]}),fe=P=>{if(y)return we(P);const I=P==="offense",ee=I?n==null?void 0:n.off_rim_freq:n==null?void 0:n.def_rim_freq,ye=I?n==null?void 0:n.off_rim_fg_pct:n==null?void 0:n.def_rim_fg_pct,Te=I?n==null?void 0:n.off_mid_freq:n==null?void 0:n.def_mid_freq,$e=I?n==null?void 0:n.off_mid_fg_pct:n==null?void 0:n.def_mid_fg_pct,Me=I?n==null?void 0:n.off_3p_freq:n==null?void 0:n.def_3p_freq,ke=I?n==null?void 0:n.off_3p_pct:n==null?void 0:n.def_3p_pct,We=I?n==null?void 0:n.off_corner3_freq:n==null?void 0:n.def_corner3_freq,de=I?n==null?void 0:n.off_corner3_fg_pct:n==null?void 0:n.def_corner3_fg_pct,Se=I?n==null?void 0:n.ts_pct:n==null?void 0:n.opp_ts_pct,qe=I?n==null?void 0:n.tov_pct:n==null?void 0:n.opp_tov_pct,Pe=I?n==null?void 0:n.orb_pct:n==null?void 0:n.opp_orb_pct,Ge=I?Oe():_e(),Re=I?k():J(),Le=I?H():D(),Ke=O?He(ee,O.rimFreq):void 0,Ye=O?He(ye,O.rimFgPct):void 0,x=O?He(Te,O.midFreq):void 0,a=O?He($e,O.midFgPct):void 0,v=O?He(Me,O.threeFreq):void 0,C=O?He(ke,O.threeFgPct):void 0,q=(n==null?void 0:n.lg_avg_corner_freq)!==void 0?He(We,n.lg_avg_corner_freq):void 0,u=(n==null?void 0:n.lg_avg_corner)!==void 0?He(de,n.lg_avg_corner*100):void 0,w=Q(Ge)&&Ge!==0?I?Ge>0?"text-primary":"text-secondary":Ge<0?"text-primary":"text-secondary":"text-muted-foreground",L=Q(Re)&&Re!==0?I?Re<0?"text-primary":"text-secondary":Re>0?"text-primary":"text-secondary":"text-muted-foreground",be=Q(Le)&&Le!==0?I?Le>0?"text-primary":"text-secondary":Le<0?"text-primary":"text-secondary":"text-muted-foreground",Ae=re(Ke,!I),se=re(x,!!I),Ee=re(v,!I),Ie=re(q,!I),Ue=re(Ye,!I),zt=re(a,!I),Vt=re(C,!I),qt=re(u,!I),kt=I?Z:R;return e.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-foreground uppercase tracking-wider text-center",children:I?"Offensive":"Defensive"}),e.jsxs("div",{className:"grid grid-cols-3 gap-0.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:I?"TS%":"D-TS%"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:I?"TOV%":"D-TOV%"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:I?"ORB%":"D-ORB%"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-0.5 text-center font-numeric -mt-0.5",children:[e.jsx("div",{className:"text-sm",children:Q(Se)?Se.toFixed(1):"-"}),e.jsx("div",{className:"text-sm",children:Q(qe)?qe.toFixed(1):"-"}),e.jsx("div",{className:"text-sm",children:Q(Pe)?Pe.toFixed(1):"-"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-0.5 text-center font-numeric -mt-1",children:[e.jsx("div",{className:h("text-[11px] font-semibold",w),children:xe(Ge)}),e.jsx("div",{className:h("text-[11px] font-semibold",L),children:xe(Re)}),e.jsx("div",{className:h("text-[11px] font-semibold",be),children:xe(Le)})]}),kt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-dotted border-border/50 mt-1 mb-0.5"}),e.jsx("div",{className:"text-[10px] font-semibold text-foreground uppercase tracking-wider text-center",children:"Shot Location"}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center items-end",children:[e.jsx("div",{}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"RIM"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"MID"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"3P"}),e.jsx("div",{className:"text-[10px] text-muted-foreground/80",children:"C3"})]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center font-numeric items-center -mt-0.5",children:[e.jsx("div",{className:"text-[8px] text-muted-foreground
15/60 font-medium text-right pr-0.5",children:"FREQ"}),e.jsx("div",{className:"text-xs",children:tt(ee)}),e.jsx("div",{className:"text-xs",children:tt(Te)}),e.jsx("div",{className:"text-xs",children:tt(Me)}),e.jsx("div",{className:"text-xs",children:tt(We)})]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center font-numeric -mt-1",children:[e.jsx("div",{}),e.jsx("div",{className:h("text-[11px] font-semibold",Ae),children:tt(Ke,!0)}),e.jsx("div",{className:h("text-[11px] font-semibold",se),children:tt(x,!0)}),e.jsx("div",{className:h("text-[11px] font-semibold",Ee),children:tt(v,!0)}),e.jsx("div",{className:h("text-[11px] font-semibold",Ie),children:tt(q,!0)})]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center font-numeric items-center",children:[e.jsx("div",{className:"text-[8px] text-muted-foreground/60 font-medium text-right pr-0.5",children:"FG%"}),e.jsx("div",{className:"text-xs",children:rt(ye,!1,!1)}),e.jsx("div",{className:"text-xs",children:rt($e,!1,!1)}),e.jsx("div",{className:"text-xs",children:rt(ke,!1,!1)}),e.jsx("div",{className:"text-xs",children:rt(de,!1,!1)})]}),e.jsxs("div",{className:"grid grid-cols-[24px_1fr_1fr_1fr_1fr] gap-0.5 text-center font-numeric -mt-1",children:[e.jsx("div",{}),e.jsx("div",{className:h("text-[11px] font-semibold",Ue),children:rt(Ye,!0,!1)}),e.jsx("div",{className:h("text-[11px] font-semibold",zt),children:rt(a,!0,!1)}),e.jsx("div",{className:h("text-[11px] font-semibold",Vt),children:rt(C,!0,!1)}),e.jsx("div",{className:h("text-[11px] font-semibold",qt),children:rt(u,!0,!1)})]})]})]})},he=async P=>{if(!(!M.current||$)){G(!0);try{const I=await Ts(M.current);if(!I)throw new Error("Export returned empty");if(P==="download"){const ee=document.createElement("a");ee.download=`lineup-card-${new Date().getTime()}.png`,ee.href=I,ee.click(),ge({title:"Image downloaded!",duration:2e3})}else{const ye=await(await fetch(I)).blob();await navigator.clipboard.write([new ClipboardItem({"image/png":ye})]),ge({title:"Copied to clipboard!",duration:2e3})}}catch(I){console.error("Export failed:",I),ge({title:"Export failed",description:"Please try again",variant:"destructive",duration:2e3})}finally{G(!1)}}};return e.jsx(ct,{open:t,onOpenChange:r,children:e.jsx(ft,{className:"max-w-lg h-[min(90vh,44rem)] sm:h-[min(90vh,48rem)] overflow-hidden flex flex-col pt-5 pb-3 px-2 [&>button]:h-6 [&>button]:w-6 [&>button]:right-1.5 [&>button]:top-1.5 [&>button]:rounded-full [&>button]:p-0.5 [&>button]:border-0 [&>button]:bg-transparent [&>button]:text-muted-foreground [&>button]:shadow-none [&>button]:opacity-100 hover:[&>button]:bg-transparent hover:[&>button]:text-primary sm:[&>button]:right-2 sm:[&>button]:top-1.5 [&>button>svg]:h-4 [&>button>svg]:w-4",children:e.jsxs(mt,{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx(pt,{className:"sr-only",children:Fe()}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:[e.jsxs("div",{ref:M,className:"space-y-1.5 pb-2",children:[e.jsxs("div",{className:"border border-border rounded-lg p-2 py-3",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center mb-2 px-1",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(St,{size:"xs",className:"text-primary"})}),e.jsxs("div",{className:"flex items-center gap-1.5 justify-center",children:[c&&e.jsx(Ja,{abbr:c,className:"w-6 h-6 sm:w-7 sm:h-7"}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Lineups"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx("span",{className:"text-xs text-muted-foreground font-numeric",children:s===d?s:`${s}-${d}`})})]}),e.jsx("div",{className:"flex justify-center mb-2",children:e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{display:"inline-grid",gridTemplateColumns:`repeat(${j+(E.length>0||y?1:0)}, auto)`,justifyContent:"center",columnGap:j<=2?"1.5rem":j<=3?"1rem":"min(0.5rem, 4%)",maxWidth:"100%"},children:[o.map(P=>e.jsx(xs,{player:P,isOn:!0,numPlayers:j,teamAbbr:c},P.nba_id)),f.map(P=>e.jsx(xs,{player:P,isOn:!1,numPlayers:j,teamAbbr:c},P.nba_id)),(E.length>0||y)&&(()=>{const P=Ft(b),I=Q(b)&&b>0,ee=j>=5?"w-10 h-10 sm:w-12 sm:h-12":j>=4?"w-12 h-12 sm:w-14 sm:h-14":"w-14 h-14 sm:w-16 sm:h-16",ye=j>=5?"text-[9px]":j>=4?"text-[10px]":"text-xs";return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:h("relative rounded-full overflow-hidden ring-2 bg-muted flex items-center justify-center",y?"ring-border bg-card":I?"ring-primary":"ring-secondary",ee),children:y?e.jsx(ne,{className:"h-4 w-7 rounded-sm sm:h-5 sm:w-9"}):e.jsx("span",{className:h("font-numeric font-bold",I?"text-primary":"text-secondary",j>=5?"text-xs":"text-sm"),children:P})}),e.jsx("span",{className:h("text-center text-white max-w-full truncate mt-0.5",ye),children:"Team Help"})]})})()]})}),e.jsxs("div",{className:h("flex items-center justify-center mt-2 flex-wrap px-1",A<400?"space-x-2":"space-x-4"),children:[e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:"MIN"}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:Q(n==null?void 0:n.minutes)?Math.round(n.minutes):"-"}),e.jsx("div",{className:"h-4",children:"Â "})]})]}),e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:te("NET")}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:e.jsx("span",{className:h(pe()!==null&&((pe()||0)>0?"text-primary":"text-secondary")),children:pe()!==null?((pe()||0)>0?"+":"")+z(pe()):"-"})}),e.jsx("div",{className:"h-4",children:"Â "})]})]}),e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:te("OFF")}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:z(n==null?void 0:n.off)}),Q(n==null?void 0:n.rel_off)?e.jsx("div",{className:h("font-numeric text-xs"),children:e.jsxs("span",{className:h(n.rel_off>0?"text-primary":"text-secondary"),children:[n.rel_off>0?"+":"",z(n.rel_off)]})}):e.jsx("div",{className:"h-4",children:"Â "})]})]}),e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:te("DEF")}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:z(n==null?void 0:n.def)}),Q(g)?e.jsx("div",{className:h("font-numeric text-xs"),children:e.jsxs("span",{className:h(g<0?"text-primary":"text-secondary"),children:[g>0?"+":"",z(g)]})}):e.jsx("div",{className:"h-4",children:"Â "})]})]}),e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:"O-3P%"}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:je()}),e.jsx("div",{className:"h-4",children:"Â "})]})]}),e.jsxs("div",{className:"text-center min-w-[40px]",children:[e.jsx("div",{className:h("text-muted-foreground",p?"text-[9px]":"text-xs"),children:"D-3P%"}),e.jsxs("div",{className:"h-[32px] flex flex-col items-center justify-start",children:[e.jsx("div",{className:h("font-numeric",p?"text-sm":"text-base"),children:Y()}),e.jsx("div",{className:"h-4",children:"Â "})]})]})]}),ue&&e.jsxs("div",{className:"mt-2 border-t border-border/60 pt-2",children:[e.jsx("div",{className:"text-center text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Raw Ratings"}),e.jsxs("div",{className:"mt-1 flex items-center justify-center gap-4 font-numeric",children:[e.jsxs("div",{className:"text-center min-w-[44px]",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"NET"}),e.jsx("div",{className:h("text-xs font-semibold",Q(n==null?void 0:n.raw_net)?
15n.raw_net>0?"text-primary":"text-secondary":"text-muted-foreground"),children:Ce(n==null?void 0:n.raw_net)})]}),e.jsxs("div",{className:"text-center min-w-[44px]",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"OFF"}),e.jsx("div",{className:"text-xs text-foreground",children:z(n==null?void 0:n.raw_off)})]}),e.jsxs("div",{className:"text-center min-w-[44px]",children:[e.jsx("div",{className:"text-[9px] text-muted-foreground",children:"DEF"}),e.jsx("div",{className:"text-xs text-foreground",children:z(n==null?void 0:n.raw_def)})]})]})]}),!F&&(y||Z||R)&&e.jsxs("div",{className:"border-t border-border mt-4 pt-1 grid grid-cols-2",children:[e.jsx("div",{className:"border-r border-border",children:fe("offense")}),e.jsx("div",{children:fe("defense")})]})]}),U&&e.jsxs(Za,{open:F,onOpenChange:ie,children:[e.jsx(en,{asChild:!0,children:e.jsx("button",{className:"w-full text-left",children:e.jsx("div",{className:"w-full bg-muted py-2 px-3 rounded-md",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("span",{className:h("text-foreground font-semibold uppercase tracking-wide",p?"text-[10px]":"text-xs"),children:["Teammate Help (",5-o.length,")"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground leading-tight",children:"Weighted avg DARKO of other teammates on floor"}),S?e.jsxs("div",{className:"mt-1 flex items-center justify-center gap-1.5 font-numeric",children:[e.jsx(ne,{className:"h-4 w-16 rounded-sm"}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx(ne,{className:"h-3 w-12 rounded-sm"}),e.jsx("span",{className:"text-muted-foreground",children:"+"}),e.jsx(ne,{className:"h-3 w-12 rounded-sm"})]}):e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-1.5 font-numeric",children:[e.jsxs("span",{className:h("text-sm font-semibold",Q(b)&&b>0?"text-primary":"text-secondary"),children:[Ft(b)," ",e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"NET"})]}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"="}),e.jsxs("span",{className:h("text-sm font-semibold",Q(X)&&X>0?"text-primary":"text-secondary"),children:[le(X)," ",e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"OFF"})]}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"+"}),e.jsxs("span",{className:h("text-sm font-semibold",Q(V)&&V>0?"text-primary":"text-secondary"),children:[le(V)," ",e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"DEF"})]})]}),e.jsx("div",{className:"mt-1 flex justify-center text-muted-foreground",children:e.jsx(xa,{className:h("h-3 w-3 transition-transform duration-200",F&&"rotate-180")})})]})})})}),!F&&e.jsxs("div",{className:"flex flex-col items-center mt-2 min-h-[74px]",children:[e.jsx("span",{className:"text-[8px] text-muted-foreground tracking-wide mb-1",children:"SHARED FLOOR WITH LINEUP % | DARKO"}),e.jsx("div",{className:"flex justify-center gap-2.5 flex-wrap",children:S?Array.from({length:7}).map((P,I)=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(ne,{className:"h-2.5 w-14 mb-0.5"}),e.jsx(ne,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"mt-0.5 flex flex-col items-center gap-0.5",children:[e.jsx(ne,{className:"h-2 w-12"}),e.jsx(ne,{className:"h-2 w-10"})]})]},`avatar-skeleton-${I}`)):E.slice(0,7).map(P=>{const ee=me(P.metrics),ye=ee!==void 0&&ee>0;return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[e.jsxs("span",{className:"text-[10px] sm:text-[11px] font-numeric text-white",children:[Math.round(P.percentage),"%"]}),e.jsx("span",{className:h("text-[10px] sm:text-[11px] font-numeric font-semibold",ye?"text-primary":"text-secondary"),children:ce(ee)})]}),e.jsx("div",{className:h("relative rounded-full overflow-hidden ring-[1.5px]",ye?"ring-primary":"ring-secondary"),style:{width:40,height:40},children:e.jsx("img",{src:ot(P.player.nba_id,W),alt:P.player.name,className:"w-full h-full object-cover bg-muted select-none",style:{objectPosition:"center 10%",WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none",pointerEvents:"none"},draggable:"false"})}),e.jsxs("div",{className:"text-center text-muted-foreground mt-0.5 leading-tight text-[8px] sm:text-[9px]",children:[e.jsx("div",{className:"truncate",style:{maxWidth:"8ch"},children:bo(P.player.name)}
15),e.jsx("div",{className:"truncate",style:{maxWidth:"8ch"},children:rn(P.player.name)})]})]},P.player.nba_id)})})]}),e.jsx(tn,{children:e.jsx("div",{className:"mt-0.5",children:S?e.jsx(Gr,{className:"h-[35vh] max-h-[300px] min-h-[180px]",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_56px_68px_72px] items-center gap-2 p-1 text-sm text-muted-foreground border-b border-border mb-1 bg-background sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-8"}),e.jsx(ne,{className:"h-4 w-24"})]}),e.jsx(ne,{className:"h-4 w-10 justify-self-end"}),e.jsx(ne,{className:"h-4 w-12 justify-self-end"}),e.jsx(ne,{className:"h-4 w-14 justify-self-end"})]}),e.jsx("div",{children:Array.from({length:8}).map((P,I)=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_56px_68px_72px] items-center gap-2 p-1 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ne,{className:"w-8 h-8 rounded-full flex-shrink-0"}),e.jsx(ne,{className:"h-4 w-32 max-sm:w-24"})]}),e.jsx(ne,{className:"h-4 w-10 justify-self-end"}),e.jsx(ne,{className:"h-4 w-12 justify-self-end"}),e.jsx(ne,{className:"h-4 w-14 justify-self-end"})]},`skeleton-${I}`))})]})}):e.jsx(Gr,{className:"h-[35vh] max-h-[300px] min-h-[180px]",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_56px_68px_72px] items-center gap-2 p-1 text-sm text-muted-foreground border-b border-border mb-1 bg-background sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-8"}),e.jsx("span",{className:"text-center font-semibold text-foreground sm:text-left",children:"TEAMMATES"})]}),e.jsx("span",{className:"justify-self-center text-center font-semibold text-foreground",children:"MIN"}),e.jsxs("div",{className:"justify-self-center text-center flex flex-col items-center text-[0.65rem] leading-[1]",children:[e.jsx("div",{className:"font-medium text-foreground",children:"SHARED"}),e.jsx("div",{className:"font-medium text-foreground",children:"FLOOR%"})]}),e.jsx("span",{className:"justify-self-center text-center font-semibold text-foreground",children:ve()})]}),e.jsx("div",{children:E.map(P=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_56px_68px_72px] items-center gap-2 p-1 rounded-lg hover:bg-secondary/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"relative w-8 h-8 rounded-full overflow-hidden flex-shrink-0",children:e.jsx("img",{src:ot(P.player.nba_id,W),alt:P.player.name,className:"w-full h-full object-cover bg-muted select-none",style:{objectPosition:"center 10%",WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none",pointerEvents:"none"},draggable:"false",onDragStart:oe})}),e.jsx("span",{className:"max-sm:text-xs truncate",children:P.player.name})]}),e.jsx("span",{className:"text-sm text-center max-sm:text-xs justify-self-center",children:Math.round(P.minutes)}),e.jsxs("span",{className:"text-base text-center max-sm:text-sm justify-self-center",children:[Math.round(P.percentage),"%"]}),P.metrics&&e.jsx("span",{className:h("font-semibold text-base text-center max-sm:text-sm justify-self-center",me(P.metrics)>0?"text-primary":"text-secondary"),children:ce(me(P.metrics))})]},P.player.nba_id))})]})})})})]})]}),e.jsxs("div",{className:"export-hide hidden md:flex items-center justify-center gap-2 pt-1.5",children:[e.jsxs("button",{onClick:()=>he("download"),disabled:$,className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-primary transition-colors disabled:opacity-50",children:[e.jsx(ir,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:$?"Exporting...":"Download"})]}),e.jsx("span",{className:"text-muted-foreground/30",children:"|"}),e.jsxs("button",{onClick:()=>he("copy"),disabled:$,className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-primary transition-colors disabled:opacity-50",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Copy"})]})]})]})]})})})}const bt=Ot.memo(function({player:r,isOn:o,isLarge:f=!1,compact:m=!1,teamLogoAbbr:i,locationDesktopTight:l=!1,numPlayers:s,lineupMode:d}){const c=Ze(),n=r.nba_id?String(r.nba_id):"",N=n?ot(n,c):ot(r.nba_id,c),y=ot(r.nba_id,c),[W,E]=_.useState(typeof window<"u"?window.innerWidth:1280),[S,j]=_.useState(!1),[A,T]=_.useState(N),p=_.useRef(!0);_.useEffect(()=>{const ce=()=>{p.current&&typeof window<"u"&&E(window.innerWidth)},K=()=>{typeof document<"u"&&(p.current=document.visibilityState==="visible")};return window.addEventListener("resize",ce),document.addEventListener("visibilitychange",K),()=>{window.removeEventListener("resize",ce),document.removeEventListener("visibilitychange",K)}},[]),_.useEffect(()=>{j(!1),T(N)},[N]);const F=ce=>(ce.preventDefault(),ce.stopPropagation(),!1),ie=W<640&&s>=4,$=W<400&&s>=4,G=_.useMemo(()=>qr(i,c),[i,c]),M=_.useMemo(()=>o?kr(i,c):void 0,[o,i,c]),ge=_.useMemo(()=>Mr(i,c),[i,c]),te=W<450&&s>=4?Xt(r.name,7):W<640&&s>=4?Xt(r.name,7):Xt(r.name,10),oe=r.name.split(" ").map(ce=>ce[0]).join("").slice(0,2).toUpperCase();return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:` 16 relative 17 ${m?"w-[54px] h-[54px] sm:w-[58px] sm:h-[58px]":l?"w-[calc(3rem*1.3)] h-[calc(3rem*1.3)] sm:w-[calc(3.25rem*1.3)] sm:h-[calc(3.25rem*1.3)]":f?"max-[410px]:w-[calc(2.8rem*1.3)] max-[410px]:h-[calc(2.8rem*1.3)] w-[calc(3.2rem*1.3)] h-[calc(3.2rem*1.3)] sm:w-[calc(3.5rem*1.3)] sm:h-[calc(3.5rem*1.3)]":$?"w-6 h-9":ie?"w-7 h-10":"max-[410px]:w-10 max-[410px]:h-10 w-12 h-12 sm:w-14 sm:h-14"} 18 rounded-full overflow-hidden transition-all duration-300 19 ${o?"opacity-100":"opacity-40"} 20 ${o&&!i?"ring-2 ring-primary":""} 21 `,style:{...G,...M},draggable:"false",onDragStart:F,"aria-label":`${r.name}${o?" on court":" off court"}`,children:[i&&e.jsx("img",{src:Tt(i,c),alt:"","aria-hidden":"true",className:"absolute inset-[6%] z-0 h-[88%] w-[88%] scale-[1.2] object-contain opacity-100 select-none",style:ge,draggable:"false",onDragStart:F,onError:ce=>{ce.currentTarget.style.display="none"}}),S?e.jsx("div",{className:`absolute inset-0 z-10 flex items-center justify-center bg-muted/85 text-foreground font-semibold select-none ${f?"text-sm":$?"text-[8px]":ie?"text-[9px]":"text-xs"}`,children:oe}):e.jsx("div",{className:"absolute inset-0 z-[1] h-[120%]",draggable:"false",onDragStart:F,children:e.jsx("img",{src:A,alt:`${r.name}${o?" (on court)":" (off court)"}`,className:"w-full h-full object-cover object-top select-none",style:{WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none",pointerEvents:"none"},draggable:"false",onDragStart:F,onError:()=>{if(A!==y){T(y);return}j(!0)}})}),!o&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/28 pointer-events-none",children:e.jsx("span",{className:"text-white text-[10px] font-semibold tracking-[0.08em] bg-black/60 px-1.5 py-0.5 rounded-sm shadow-[0_0_10px_rgba(0,0,0,0.35)]",children:"OFF"})})]}),e.jsx("span",{"data-export-player-name":an(r.name),className:` 22 text-center text-foreground max-w-full truncate 23 ${m?W>=640?"text-xs":"text-[9px]":s>=4&&W<450?"text-[8px]":W>=640?"text-sm":"text-[10px]"} 24 `,children:te})]})});bt.displayName="WowyLineupPortrait";const lt=-999,No=["off_rim_profile","off_mid_profile","off_3p_profile","off_arc3_profile","off_corner3_profile"],jo=["def_rim_profile","def_mid_profile","def_3p_profile","def_arc3_profile","def_corner3_profile"],wo=[...No,...jo],_s=["off_mid_profile","off_3p_profile","off_arc3_profile","off_corner3_profile","def_mid_profile","def_3p_profile","def_arc3_profile","def_corner3_profile"],hs={off_rim_profile:{label:"RIM",displayLabel:"RIM",freqKey:"off_rim_freq",fgKey:"off_rim_fg_pct",leagueFreqKey:"lg_avg_rim_freq",leagueFgKey:"lg_avg_rim_acc",leagueFreqFallback:"rim",leagueFgFallback:"rim",lowerBetter:!1,lowerBetterFg:!1},off_mid_profile:{label:"MID",displayLabel:"MID",freqKey:"off_mid_freq",fgKey:"off_mid_fg_pct",leagueFreqKey:"lg_avg_mid_freq",leagueFgKey:"lg_avg_mid_acc",leagueFreqFallback:"mid",leagueFgFallback:"mid",lowerBetter:!0,lowerBetterFg:!1}
24,off_3p_profile:{label:"3P",displayLabel:"3P",freqKey:"off_3p_freq",fgKey:"off_3p_pct",leagueFreqKey:"lg_avg_3p_freq",leagueFgKey:"lg_avg_three",leagueFreqFallback:"three",leagueFgFallback:"three",lowerBetter:!1,lowerBetterFg:!1},off_arc3_profile:{label:"ARC 3",displayLabel:"ARC 3",freqKey:"off_arc3_freq",fgKey:"off_arc3_fg_pct",leagueFgKey:"lg_avg_arc",leagueFgAsPercent:!0,lowerBetter:!1,lowerBetterFg:!1},off_corner3_profile:{label:"CORNER 3",displayLabel:"CORNER 3",freqKey:"off_corner3_freq",fgKey:"off_corner3_fg_pct",leagueFreqKey:"lg_avg_corner_freq",leagueFgKey:"lg_avg_corner",leagueFgAsPercent:!0,lowerBetter:!1,lowerBetterFg:!1},def_rim_profile:{label:"RIM",displayLabel:"DEF RIM",freqKey:"def_rim_freq",fgKey:"def_rim_fg_pct",leagueFreqKey:"lg_avg_rim_freq",leagueFgKey:"lg_avg_rim_acc",leagueFreqFallback:"rim",leagueFgFallback:"rim",lowerBetter:!0,lowerBetterFg:!0},def_mid_profile:{label:"MID",displayLabel:"DEF MID",freqKey:"def_mid_freq",fgKey:"def_mid_fg_pct",leagueFreqKey:"lg_avg_mid_freq",leagueFgKey:"lg_avg_mid_acc",leagueFreqFallback:"mid",leagueFgFallback:"mid",lowerBetter:!0,lowerBetterFg:!0},def_3p_profile:{label:"3P",displayLabel:"DEF 3P",freqKey:"def_3p_freq",fgKey:"def_3p_pct",leagueFreqKey:"lg_avg_3p_freq",leagueFgKey:"lg_avg_three",leagueFreqFallback:"three",leagueFgFallback:"three",lowerBetter:!0,lowerBetterFg:!0},def_arc3_profile:{label:"ARC 3",displayLabel:"DEF ARC 3",freqKey:"def_arc3_freq",fgKey:"def_arc3_fg_pct",leagueFgKey:"lg_avg_arc",leagueFgAsPercent:!0,lowerBetter:!0,lowerBetterFg:!0},def_corner3_profile:{label:"CORNER 3",displayLabel:"DEF CORNER 3",freqKey:"def_corner3_freq",fgKey:"def_corner3_fg_pct",leagueFreqKey:"lg_avg_corner_freq",leagueFgKey:"lg_avg_corner",leagueFgAsPercent:!0,lowerBetter:!0,lowerBetterFg:!0}},B=t=>t!=null&&!Number.isNaN(t)&&Number.isFinite(t),At=(t,r=!1)=>B(t)?r?t<0?"text-primary":"text-secondary":t>0?"text-primary":"text-secondary":"text-muted-foreground/60",Dt=({left:t,right:r,className:o,leftClassName:f,rightClassName:m,separatorClassName:i})=>e.jsxs("div",{className:h("grid w-full grid-cols-[minmax(0,1fr)_0.7rem_minmax(0,1fr)] items-baseline tabular-nums",o),children:[e.jsx("span",{className:h("w-full text-right whitespace-nowrap",f),children:t}),e.jsx("span",{className:h("text-center leading-none",i),children:"|"}),e.jsx("span",{className:h("w-full text-left whitespace-nowrap",m),children:r})]}),Fo=Ot.memo(Ot.forwardRef(function({combinations:r,isLoading:o,seasonType:f,startYear:m,endYear:i,activeView:l,setActiveView:s,dataView:d,setDataView:c,leverageFilter:n,stats:N,availablePlayers:y,allYearsPlayers:W,playerMetricsByYear:E,defLuckAdjustment:S=0,offLuckAdjustment:j=0,selectedTeam:A=null,lineupMode:T="wowy",theme:p="dark",setIsCursorTextVisible:F,setCursorTitleText:ie,setCursorDescriptionText:$,setCursorSortHintText:G,offenseDetailMode:M,defenseDetailMode:ge,isPaddingEnabled:te=!1,showExpectedMetrics:oe=!1},ce){const K=Ze(),[b,X]=_.useState(typeof window<"u"?window.innerWidth<640:!1),[V,me]=_.useState(typeof window<"u"?window.innerWidth:0),ve=_.useRef(!0),[z,Ce]=_.useState("minutes"),[le,je]=_.useState("desc"),[Y,xe]=_.useState(null),[pe,Fe]=_.useState(null),[Oe,k]=_.useState(!1),H=oe&&(l==="overview"||l==="expanded");_.useMemo(()=>["off","def","net","ts_pct","tov_pct","orb_pct","opp_ts_pct","opp_tov_pct","opp_orb_pct"],[]);const _e=_.useMemo(()=>[e.jsx(_a,{size:14,className:"text-blue-500"},"tu"),e.jsx(ln,{size:14,className:"text-red-500"},"td"),e.jsx(ha,{size:14,className:"text-yellow-500"},"z"),e.jsx(dn,{size:14,className:"text-green-500"},"s"),e.jsx(ws,{size:14,className:"text-purple-500"},"a"),e.jsx(vn,{size:14,className:"text-indigo-500"},"bc")],[]);_.useCallback(()=>_e.length===0?null:_e[Math.floor(Math.random()*_e.length)],[_e]);const J=_.useMemo(()=>A?Tt(A,K):"",[K,A]),D=b?"Press":"Click",g=_.useMemo(()=>r.length>0?r[0].players.length:0,[r]),O=_.useCallback(()=>{if(b&&l==="overview"&&g>=2&&g<=5){let x=0;if(g<3)V<410?x=2.8*1.3*16:x=3.2*1.3*16;else{const w=V<400&&g>=4,L=g>=4;w?x=24:L?x=28:V<410?x=40:x=48}const q=g*x+Math.max(0,g-1)*8+10,u=`${Math.round(q)}px`;return{minWidth:u,width:u}}},[b,l,g,V]),Z=_.useCallback((x,a)=>{let v="",C="";const q="Click to sort.";switch(x){case"minutes":v="Minutes Played:",C="Total minutes this lineup has been on the court.";break;case"off":v=a==="raw"?"Offensive Rating:":"Relative Off. Rating:",C=a==="raw"?"Points scored per 100 possessions. The value below is relative to league average. Blue indicates worse offense.":"Points scored per 100 possessions relative to league average for that season. The value below shows the difference from league average. Blue indicates worse offense.";break;case"def":v=a==="raw"?"Defensive Rating:":"Relative Def. Rating:",C=a==="raw"?"Points allowed per 100 possessions. The value below is relative to league average. Blue indicates worse defense.":"Points allowed per 100 possessions relative to league average for that season. The value below shows the difference from league average. Blue indicates worse defense.";break;case"net":v="Net Rating:",C="Point differential per 100 possessions.";break;
24case"ts_pct":v=a==="raw"?"True Shooting %:":"Relative TS%:",C=a==="raw"?"Shooting efficiency (accounts for 2s, 3s, and FTs).":"Shooting efficiency relative to league average for that season.";break;case"tov_pct":v=a==="raw"?"Turnover %:":"Relative TOV%:",C=a==="raw"?"Estimated turnovers per 100 possessions.":"Turnover percentage relative to league average for that season.";break;case"orb_pct":v=a==="raw"?"Off. Rebound %:":"Relative ORB%:",C=a==="raw"?"Percentage of available offensive rebounds secured.":"Offensive rebound percentage relative to league average for that season.";break;case"opp_ts_pct":v=a==="raw"?"Opponent TS%:":"Relative Opp. TS%:",C=a==="raw"?"Opponent's shooting efficiency.":"Opponent's shooting efficiency relative to league average for that season.";break;case"opp_tov_pct":v=a==="raw"?"Opponent TOV%:":"Relative Opp. TOV%:",C=a==="raw"?"Turnovers forced per 100 opponent possessions.":"Opponent turnover percentage relative to league average for that season.";break;case"opp_orb_pct":v=a==="raw"?"Opponent ORB%:":"Relative Opp. ORB%:",C=a==="raw"?"Percentage of available offensive rebounds allowed.":"Opponent offensive rebound percentage relative to league average for that season.";break;case"off_rim_profile":v="Rim Profile:",C="Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"off_mid_profile":v="Midrange Profile:",C="Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"off_3p_profile":v="3P Profile:",C="Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"off_arc3_profile":v="Arc 3 Profile:",C="Top row shows frequency (decimal) and FG. Bottom row shows relative FG delta vs league average (frequency baseline unavailable).";break;case"off_corner3_profile":v="Corner 3 Profile:",C="Top row shows frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;
24case"def_rim_profile":v="DEF Rim Profile:",C="Top row shows allowed frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"def_mid_profile":v="DEF Midrange Profile:",C="Top row shows allowed frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"def_3p_profile":v="DEF 3P Profile:",C="Top row shows allowed frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;case"def_arc3_profile":v="DEF Arc 3 Profile:",C="Top row shows allowed frequency (decimal) and FG. Bottom row shows relative FG delta vs league average (frequency baseline unavailable).";break;case"def_corner3_profile":v="DEF Corner 3 Profile:",C="Top row shows allowed frequency (decimal) and FG. Bottom row shows relative deltas vs league average.";break;default:return{title:"",description:"",sortHint:""}}return{title:v,description:C,sortHint:q}},[]),R=_.useCallback(x=>{x!=="lineup"&&(z===x?je(le==="asc"?"desc":"asc"):(Ce(x),je(x==="tov_pct"||x==="opp_ts_pct"||x==="opp_orb_pct"||x==="off_mid_profile"||x==="def_rim_profile"||x==="def_mid_profile"||x==="def_3p_profile"||x==="def_arc3_profile"||x==="def_corner3_profile"?"asc":"desc")))},[z,le]),U=_.useMemo(()=>!te||!r.length?r:r.map(x=>{const a=Ds({off:x.off,def:x.def,possessions:x.possessions,offPossessions:x.total_off_poss,defPossessions:x.total_def_poss,lgAvgOrtg:x.lg_avg_ortg});return a?{...x,off:a.paddedOff,def:a.paddedDef,net:a.paddedNet,rel_off:a.paddedRelOff,rel_def:a.paddedRelDef,rel_net:a.paddedRelNet}:x}),[r,te]),ue=_.useMemo(()=>{if(!U.length)return[];if(T==="wowy"&&g===1){const x=U.find(v=>v.on_players.length>0),a=U.find(v=>v.on_players.length===0);if(x&&a){const v={...x,id:lt,minutes:0,off:x.off-a.off,def:x.def-a.def,net:x.net-a.net,ts_pct:B(x.ts_pct)&&B(a.ts_pct)?x.ts_pct-a.ts_pct:void 0,tov_pct:B(x.tov_pct)&&B(a.tov_pct)?x.tov_pct-a.tov_pct:void 0,orb_pct:B(x.orb_pct)&&B(a.orb_pct)?x.orb_pct-a.orb_pct:void 0,opp_ts_pct:B(x.opp_ts_pct)&&B(a.opp_ts_pct)?x.opp_ts_pct-a.opp_ts_pct:void 0,opp_tov_pct:B(x.opp_tov_pct)&&B(a.opp_tov_pct)?x.opp_tov_pct-a.opp_tov_pct:void 0,opp_orb_pct:B(x.opp_orb_pct)&&B(a.opp_orb_pct)?x.opp_orb_pct-a.opp_orb_pct:void 0,rel_off:B(x.rel_off)&&B(a.rel_off)?x.rel_off-a.rel_off:void 0,rel_def:B(x.rel_def)&&B(a.rel_def)?x.rel_def-a.rel_def:void 0,fg3_pct:B(x.fg3_pct)&&B(a.fg3_pct)?x.fg3_pct-a.fg3_pct:void 0,off_3p_pct:B(x.off_3p_pct)&&B(a.off_3p_pct)?x.off_3p_pct-a.off_3p_pct:void 0,off_rim_freq:B(x.off_rim_freq)&&B(a.off_rim_freq)?x.off_rim_freq-a.off_rim_freq:void 0,off_rim_fg_pct:B(x.off_rim_fg_pct)&&B(a.off_rim_fg_pct)?x.off_rim_fg_pct-a.off_rim_fg_pct:void 0,off_mid_freq:B(x.off_mid_freq)&&B(a.off_mid_freq)?x.off_mid_freq-a.off_mid_freq:void 0,off_mid_fg_pct:B(x.off_mid_fg_pct)&&B(a.off_mid_fg_pct)?x.off_mid_fg_pct-a.off_mid_fg_pct:void 0,off_3p_freq:B(x.off_3p_freq)&&B(a.off_3p_freq)?x.off_3p_freq-a.off_3p_freq:void 0,off_arc3_freq:B(x.off_arc3_freq)&&B(a.off_arc3_freq)?x.off_arc3_freq-a.off_arc3_freq:void 0,off_arc3_fg_pct:B(x.off_arc3_fg_pct)&&B(a.off_arc3_fg_pct)?x.off_arc3_fg_pct-a.off_arc3_fg_pct:void 0,off_corner3_freq:B(x.off_corner3_freq)&&B(a.off_corner3_freq)?x.off_corner3_freq-a.off_corner3_freq:void 0,off_corner3_fg_pct:B(x.off_corner3_fg_pct)&&B(a.off_corner3_fg_pct)?x.off_corner3_fg_pct-a.off_corner3_fg_pct:void 0,def_rim_freq:B(x.def_rim_freq)&&B(a.def_rim_freq)?x.def_rim_freq-a.def_rim_freq:void 0,def_rim_fg_pct:B(x.def_rim_fg_pct)&&B(a.def_rim_fg_pct)?x.def_rim_fg_pct-a.def_rim_fg_pct:void 0,def_mid_freq:B(x.def_mid_freq)&&B(a.def_mid_freq)?x.def_mid_freq-a.def_mid_freq:void 0,def_mid_fg_pct:B(x.def_mid_fg_pct)&&B(a.def_mid_fg_pct)?x.def_mid_fg_pct-a.def_mid_fg_pct:void 0,def_3p_freq:B(x.def_3p_freq)&&B(a.def_3p_freq)?x.def_3p_freq-a.def_3p_freq:void 0,def_3p_pct:B(x.def_3p_pct)&&B(a.def_3p_pct)?x.def_3p_pct-a.def_3p_pct:void 0,def_arc3_freq:B(x.def_arc3_freq)&&B(a.def_arc3_freq)?x.def_arc3_freq-a.def_arc3_freq:void 0,def_arc3_fg_pct:B(x.def_arc3_fg_pct)&&B(a.def_arc3_fg_pct)?x.def_arc3_fg_pct-a.def_arc3_fg_pct:void 0,def_corner3_freq:B(x.def_corner3_freq)&&B(a.def_corner3_freq)?x.def_corner3_freq-a.def_corner3_freq:void 0,def_corner3_fg_pct:B(x.def_corner3_fg_pct)&&B(a.def_corner3_fg_pct)?x.def_corner3_fg_pct-a.def_corner3_fg_pct:void 0};return[x,a,v]}}return[...U].sort((x,a)=>
24{if(z==="minutes")return le==="asc"?(x.minutes||0)-(a.minutes||0):(a.minutes||0)-(x.minutes||0);const C={off_rim_profile:"off_rim_freq",off_mid_profile:"off_mid_freq",off_3p_profile:"off_3p_freq",off_arc3_profile:"off_arc3_freq",off_corner3_profile:"off_corner3_freq",def_rim_profile:"def_rim_freq",def_mid_profile:"def_mid_freq",def_3p_profile:"def_3p_freq",def_arc3_profile:"def_arc3_freq",def_corner3_profile:"def_corner3_freq"}[z]??z,q=x[C],u=a[C];return q===void 0&&u===void 0?0:q===void 0?le==="asc"?-1:1:u===void 0?le==="asc"?1:-1:le==="asc"?q-u:u-q})},[U,z,le,T,g]),re=_.useMemo(()=>{const x=new Map;return!oe||!(N!=null&&N.length)||!(W!=null&&W.length)||ue.forEach(a=>{if(a.id===lt)return;const v=hr(N,a.on_players,a.off_players,W),C=vr({partners:v,onPlayers:a.on_players,playerMetricsByYear:E});x.set(a.id,{partners:v,...C})}),x},[oe,ue,N,W,E]),we=_.useCallback(x=>{if(!(N!=null&&N.length)||!(W!=null&&W.length)){console.warn("Missing required data for lineup partners calculation",{hasStats:!!(N!=null&&N.length),hasPlayers:!!(W!=null&&W.length)});return}const a=re.get(x.id);if(a){Fe(a),xe(x),k(!0);return}const v=hr(N,x.on_players,x.off_players,W),C=vr({partners:v,onPlayers:x.on_players,playerMetricsByYear:E});Fe({partners:v,...C}),xe(x),k(!0)},[N,W,E,re]),fe=_.useMemo(()=>{const x=[{id:"lineup",header:"LINEUP",frozen:!0},{id:"minutes",header:"MIN"}];let a=[];switch(l){case"overview":a=[{id:"off",header:"OFF"},{id:"def",header:"DEF"},{id:"net",header:"NET"}];break;case"offense":a=M==="location"?[{id:"off_rim_profile",header:`RIM 25FREQ | FG%`},{id:"off_mid_profile",header:`MID 26FREQ | FG%`},{id:"off_3p_profile",header:`3P 27FREQ | FG%`},{id:"off_corner3_profile",header:`CORNER 3 28FREQ | FG%`}]:[{id:"off",header:"OFF"},{id:"ts_pct",header:"TS%"},{id:"tov_pct",header:"TOV%"},{id:"orb_pct",header:"ORB%"}];break;case"defense":a=ge==="location"?[{id:"def_rim_profile",header:`DEF RIM 29FREQ | FG%`},{id:"def_mid_profile",header:`DEF MID 30FREQ | FG%`},{id:"def_3p_profile",header:`DEF 3P 31FREQ | FG%`},{id:"def_corner3_profile",header:`DEF CORNER 3 32FREQ | FG%`}]:[{id:"def",header:"DEF"},{id:"opp_ts_pct",header:`OPP 33TS%`},{id:"opp_tov_pct",header:`OPP 34TOV%`},{id:"opp_orb_pct",header:`OPP 35ORB%`}];break;case"expanded":a=[{id:"off",header:"OFF"},{id:"def",header:"DEF"},{id:"net",header:"NET"},{id:"ts_pct",header:`OFF 36TS%`},{id:"tov_pct",header:`OFF 37TOV%`},{id:"orb_pct",header:`OFF 38ORB%`},{id:"opp_ts_pct",header:`DEF 39TS%`},{id:"opp_tov_pct",header:`DEF 40TOV%`},{id:"opp_orb_pct",header:`DEF 41ORB%`}];break}return[...x,...a]},[l,M,ge]),he=l==="offense"&&M==="location"||l==="defense"&&ge==="location",P=b&&l==="overview"&&g===1,I=!b&&g===1&&l!=="expanded",ee=_.useMemo(()=>{if(!I)return;const x=160+Math.max(fe.length-1,1)*90;return`${Math.max(576,x)}px`},[I,fe.length]),ye=_.useMemo(()=>{if(!P)return;const x=Math.max(V-18,300);return`${Math.round(x/5+30)}px`},[P,V]),Te=_.useMemo(()=>{if(!P||!ye)return;const x=Math.max(V-18,300),a=Number.parseInt(ye,10);return`${Math.round((x-a)/4)}px`},[P,ye,V]),$e=()=>{switch(T){case"wowy":return"WOWY Mode";case"2man":return Wt(K,"2man");case"3man":return Wt(K,"3man");case"4man":return Wt(K,"4man");case"5man":return Wt(K,"5man");default:return"WOWY Mode"}};_.useEffect(()=>{r.length>0&&console.log("First combination:",r[0])},[r]),_.useEffect(()=>{if(typeof window>"u")return;const x=()=>{ve.current&&(X(window.innerWidth<640),me(window.innerWidth))},a=()=>{ve.current=document.visibilityState==="visible",ve.current&&x()};return x(),window.addEventListener("resize",x),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("resize",x),document.removeEventListener("visibilitychange",a)}},[]);const Me=g<3,ke=()=>{switch(f){case"regular":return"Regular Season";case"playoffs":return"Playoffs";case"all":return"Regular Season + Playoffs"}},We=()=>m===i?`${m}`:`${m}-${i}`,de=x=>B(x)?x.toFixed(1):"-",Se=(x,a=!1)=>{if(!B(x))return"-";const v=Number(x.toFixed(1)),C=Math.abs(v).toFixed(1);return a?x>0?`+${C}`:x<0?`-${C}`:C:x<0?`-${C}`:C},qe=(x,a=!1,v=!0)=>{if(!B(x))return"-";const C=Number(x.toFixed(1)),q=Math.abs(C)===100?`${C<0?"-":""}100`:C.toFixed(1);if(!a)return v?`${q}%`:q;const u=`${C>0?"+":""}${q}`;return v?`${u}%`:u},Pe=x=>{if(!B(x))return"-";const a=Number(x.toFixed(1)),v=Math.abs(a)===100?`${a<0?"-":""}100`:a.toFixed(1);return a>0?`+${v}%`:`${v}%`},Ge=x=>x===void 0?"-":Math.round(x),Re=(x,a)=>{var v;return(v=re.get(x.id))==null?void 0:v.expectedLineup[a]},Le=(x,a)=>
41{if(a.id===lt){if(x==="lineup")return e.jsx("div",{className:"w-full flex justify-center items-center h-full",children:e.jsx("span",{className:"text-sm font-bold text-foreground whitespace-nowrap",children:"On - Off"})});if(x==="minutes")return e.jsx("div",{className:"flex justify-center items-center"});const q=hs[x];if(q){const se=a[q.freqKey],Ee=a[q.fgKey];return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-0.5 w-full",children:[e.jsx(Dt,{left:"FREQ",right:"FG%",className:"leading-[1.05]",leftClassName:"text-[9px] sm:text-[10px] text-muted-foreground",rightClassName:"text-[9px] sm:text-[10px] text-muted-foreground",separatorClassName:"text-[9px] text-foreground"}),e.jsx(Dt,{left:Se(se,!0),right:qe(Ee,!0,!1),className:"leading-tight",leftClassName:h("text-[10px] sm:text-[11px] font-semibold",At(se,q.lowerBetter)),rightClassName:h("text-[10px] sm:text-[11px] font-semibold",At(Ee,q.lowerBetterFg)),separatorClassName:"text-[9px] text-foreground"})]})}const w=(()=>{switch(x){case"off":return a.off;case"def":return a.def;case"net":return a.net;case"ts_pct":return a.ts_pct;case"tov_pct":return a.tov_pct;case"orb_pct":return a.orb_pct;case"opp_ts_pct":return a.opp_ts_pct;case"opp_tov_pct":return a.opp_tov_pct;case"opp_orb_pct":return a.opp_orb_pct;case"off_rim_profile":return a.off_rim_freq;case"off_mid_profile":return a.off_mid_freq;case"off_3p_profile":return a.off_3p_freq;case"off_arc3_profile":return a.off_arc3_freq;case"off_corner3_profile":return a.off_corner3_freq;case"def_rim_profile":return a.def_rim_freq;case"def_mid_profile":return a.def_mid_freq;case"def_3p_profile":return a.def_3p_freq;case"def_arc3_profile":return a.def_arc3_freq;case"def_corner3_profile":return a.def_corner3_freq;default:return}})();if(!B(w))return null;const L=de(Math.abs(w)),be=w>0?"+":w<0?"-":"";let Ae=w>0;return["def","tov_pct","opp_orb_pct","opp_ts_pct"].includes(x)&&(Ae=w<0),e.jsxs("span",{className:h("font-bold whitespace-nowrap",b?"text-sm":"text-base",Ae?"text-primary":"text-secondary"),children:[w===0?"0.0":`${be}${L}`,["ts_pct","tov_pct","orb_pct","opp_ts_pct","opp_tov_pct","opp_orb_pct","off_rim_profile","off_mid_profile","off_3p_profile","off_arc3_profile","off_corner3_profile","def_rim_profile","def_mid_profile","def_3p_profile","def_arc3_profile","def_corner3_profile"].includes(x)&&"%"]})}const v=q=>{const u=hs[q],w=a[u.freqKey],L=a[u.fgKey],be=Ar({rimFreqPct:a.lg_avg_rim_freq,rimFgPct:a.lg_avg_rim_acc,threeFreqPct:a.lg_avg_3p_freq,threeFgPct:a.lg_avg_three,fg2Pct:a.lg_avg_fg2_pct}),Ae=u.leagueFreqKey!==void 0?a[u.leagueFreqKey]:void 0,se=u.leagueFreqFallback==="rim"?be.rimFreq:u.leagueFreqFallback==="mid"?be.midFreq:u.leagueFreqFallback==="three"?be.threeFreq:void 0,Ee=Ae??se,Ie=u.leagueFgKey!==void 0?a[u.leagueFgKey]:void 0,Ue=Ie===void 0?void 0:u.leagueFgAsPercent?Ie*100:Ie,zt=u.leagueFgFallback==="rim"?be.rimFgPct:u.leagueFgFallback==="mid"?be.midFgPct:u.leagueFgFallback==="three"?be.threeFgPct:void 0,Vt=Ue??zt,qt=He(w,Ee),kt=He(L,Vt),ta=At(qt,u.lowerBetter),ra=At(kt,u.lowerBetterFg),sa=b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":b?"text-[11px]":"text-[12px]",aa=b?"text-[11px]":"text-[12px]",$r=b?"text-[9px]":"text-[11px]";return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-0.5 leading-tight w-full",children:[e.jsx(Dt,{left:Se(w),right:qe(L,!1,!b),leftClassName:h(sa,"font-medium text-muted-foreground/90"),rightClassName:h(aa,"font-semibold text-foreground"),separatorClassName:"text-[9px] text-muted-foreground/65"}),e.jsx(Dt,{left:Se(qt,!0),right:qe(kt,!0,!b),leftClassName:h($r,"font-semibold",ta),rightClassName:h($r,"font-semibold",ra),separatorClassName:"text-[8px] text-muted-foreground/65"})]})},C=oe&&a.players.length>=3;switch(x){case"lineup":return e.jsx("div",{className:"w-full flex justify-center",style:{display:"inline-grid",gridTemplateColumns:`repeat(${a.players.length}, auto)`,justifyContent:"center",columnGap:"min(0.5rem, 4%)",maxWidth:"100%"},children:a.players.map(q=>e.jsx(bt,{player:q,isOn:a.on_players.some(u=>u.id===q.id),isLarge:Me,teamLogoAbbr:A??void 0,numPlayers:a.players.length,lineupMode:T},q.nba_id))});case"minutes":return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",l!=="overview"&&"max-[500px]:text-xs"),children:Ge(a.minutes)})}),!he&&!C&&e.jsx("div",{className:"absolute bottom-[2px] left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"text-[0.6rem] text-muted-foreground
41/60",children:"3P%:"})})]});case"off":{const q=Re(a,"off"),u=H&&B(q),w=h(b&&g>=3&&g<=5&&l==="expanded"?"text-[10px]":"text-[11px]","leading-tight text-muted-foreground font-numeric");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[u&&e.jsx("span",{className:w,children:Ft(q)}),d==="raw"?e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense"||l==="expanded")&&"text-[11px]"),children:de(a.off)}),a.lg_avg_ortg!==void 0&&a.off!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense"||l==="expanded")?"text-[10px]":"text-[11px]","leading-tight",b?"font-medium":"font-bold",a.off-a.lg_avg_ortg>0?"text-primary":"text-secondary"),children:(a.off-a.lg_avg_ortg>0?"+":"")+de(a.off-a.lg_avg_ortg)})]}):e.jsx("div",{className:"relative",children:e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",d==="relative"?a.off-(a.lg_avg_ortg||0)<0?"text-secondary":"text-primary":a.off<110?"text-primary":"text-secondary"),children:de(d==="relative"?a.off-(a.lg_avg_ortg||0):a.off)})})]}),!C&&e.jsx("div",{className:"absolute bottom-[2px] left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"text-[0.6rem] text-muted-foreground/60",children:a.off_3p_pct!==void 0?qe(a.off_3p_pct):a.total_fg3a>0?qe(a.total_fg3m/a.total_fg3a*100):"-"})})]})}case"def":{const q=Re(a,"def"),u=H&&B(q),w=h(b&&g>=3&&g<=5&&l==="expanded"?"text-[10px]":"text-[11px]","leading-tight text-muted-foreground font-numeric");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[u&&e.jsx("span",{className:w,children:Ft(q)}),d==="raw"?e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense"||l==="expanded")&&"text-[11px]"),children:de(a.def)}),a.lg_avg_ortg!==void 0&&a.def!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense"||l==="expanded")?"text-[10px]":"text-[11px]","leading-tight",b?"font-medium":"font-bold",a.def-a.lg_avg_ortg<0?"text-primary":"text-secondary"),children:(a.def-a.lg_avg_ortg>0?"+":"")+de(a.def-a.lg_avg_ortg)})]}):e.jsx("div",{className:"relative",children:e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",d==="relative"?a.rel_def<0?"text-secondary":"text-primary":a.def<110?"text-secondary":"text-primary"),children:de(d==="relative"?a.rel_def:a.def)})})]}),!C&&e.jsx("div",{className:"absolute bottom-[2px] left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"text-[0.6rem] text-muted-foreground/60",children:a.total_d_fg3a>0&&a.fg3_pct!==void 0?`${de(a.fg3_pct)}%`:"-"})})]})}case"net":{const q=Re(a,"net"),u=H&&B(q),w=d==="raw"||d==="relative"?a.off-(a.lg_avg_ortg||0)+(a.def-(a.lg_avg_ortg||0))*-1:a.net;return e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[u&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&l==="expanded"?"text-[10px]":"text-[11px]","leading-tight text-muted-foreground font-numeric"),children:Ft(q)}),e.jsx("span",{className:h("font-semibold whitespace-nowrap tracking-tight",b?"text-[15px] max-[380px]:text-[13px]":"text-[17px]",d==="raw"||d==="relative"?a.off-(a.lg_avg_ortg||0)+(a.def-(a.lg_avg_ortg||0))*-1<0?"text-secondary":"text-primary":a.net<0?"text-secondary":"text-primary"),children:(()=>{if(w===void 0)return"-";const L=de(w);return w>0?`+${L}`:L})()}),u&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&l==="expanded"?"text-[10px]":"text-[11px]","leading-tight text-transparent select-none"),"aria-hidden":"true",children:"Â "})]})}case"ts_pct":if(d==="raw"){const q=a.ts_pct,u=a.lg_avg_ts,w=B(q)&&B(u)?q-u:void 0;let L="text-muted-foreground/60";return w!==void 0&&(L=w>0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",(a.ts_pct||0)-(a.lg_avg_ts||0)>0?"text-primary":"text-secondary"),children:Pe((a.ts_pct||0)-(a.lg_avg_ts||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.ts_pct)});case"tov_pct":if(d==="raw"){const q=a.tov_pct,u=a.lg_avg_tov,w=B(q)&&B(u)?q-u:void 0;
41let L="text-muted-foreground/60";return w!==void 0&&(L=w<0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",(a.tov_pct||0)-(a.lg_avg_tov||0)<0?"text-primary":"text-secondary"),children:Pe((a.tov_pct||0)-(a.lg_avg_tov||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.tov_pct)});case"orb_pct":if(d==="raw"){const q=a.orb_pct,u=a.lg_avg_orb,w=B(q)&&B(u)?q-u:void 0;let L="text-muted-foreground/60";return w!==void 0&&(L=w>0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",(a.orb_pct||0)-(a.lg_avg_orb||0)>0?"text-primary":"text-secondary"),children:Pe((a.orb_pct||0)-(a.lg_avg_orb||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.orb_pct)});case"opp_ts_pct":if(d==="raw"){const q=a.opp_ts_pct,u=a.lg_avg_ts,w=B(q)&&B(u)?q-u:void 0;let L="text-muted-foreground/60";return w!==void 0&&(L=w<0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",a.opp_ts_pct-(a.lg_avg_ts||0)<0?"text-primary":"text-secondary"),children:Pe(a.opp_ts_pct-(a.lg_avg_ts||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.opp_ts_pct)});case"opp_tov_pct":if(d==="raw"){const q=a.opp_tov_pct,u=a.lg_avg_tov,w=B(q)&&B(u)?q-u:void 0;let L="text-muted-foreground/60";return w!==void 0&&(L=w>0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",(a.opp_tov_pct||0)-(a.lg_avg_tov||0)>0?"text-primary":"text-secondary"),children:Pe((a.opp_tov_pct||0)-(a.lg_avg_tov||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.opp_tov_pct)});case"opp_orb_pct":if(d==="raw"){const q=a.opp_orb_pct,u=a.lg_avg_orb,w=B(q)&&B(u)?q-u:void 0;let L="text-muted-foreground/60";return w!==void 0&&(L=w<0?"text-primary":"text-secondary"),e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-0.5",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold",b&&g>=3&&g<=5&&(l==="offense"||l==="defense")&&"text-[11px]"),children:de(q)}),u!==void 0&&w!==void 0&&e.jsx("span",{className:h(b&&g>=3&&g<=5&&(l==="offense"||l==="defense")?"text-[10px]":"text-[11px]","leading-tight",L),children:Pe(w)})]})}else return d==="relative"?e.jsx("span",{className:h("whitespace-nowrap",b?"font-medium":"font-bold",(a.opp_orb_pct||0)-(a.lg_avg_orb||0)<0?"text-primary":"text-secondary"),children:Pe((a.opp_orb_pct||0)-(a.lg_avg_orb||0))}):e.jsx("span",{className:h("whitespace-nowrap text-foreground",b?"font-medium":"font-bold"),children:de(a.opp_orb_pct)});case"off_rim_profile":case"off_mid_profile":case"off_3p_profile":case"off_arc3_profile":case"off_corner3_profile":case"def_r
41im_profile":case"def_mid_profile":case"def_3p_profile":case"def_arc3_profile":case"def_corner3_profile":return v(x);default:return null}},Ke=e.jsxs("div",{ref:ce,className:`mx-auto rounded-lg border border-border shadow-sm bg-card w-full overflow-hidden wowy-${p}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 md:py-3 border-b border-border",children:[e.jsx(St,{className:Wr(K)}),e.jsxs("div",{className:"flex flex-col items-end gap-0.5 ml-4",children:[e.jsxs("p",{className:"text-xs max-[500px]:text-[9px] text-muted-foreground leading-tight",children:[$e()," ⢠",We()," ⢠",ke()]}),e.jsxs("p",{className:"text-xs max-[500px]:text-[9px] text-muted-foreground leading-tight",children:[j!==void 0&&j!==0&&T==="wowy"&&e.jsxs(e.Fragment,{children:[Math.round(Math.abs(j)),"% O-3P-Luck ⢠"]}),S!==void 0&&S!==0&&T==="wowy"&&e.jsxs(e.Fragment,{children:[Math.round(Math.abs(S)),"% D-3P-Luck ⢠"]}),te&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-primary",children:"Padded"})," â¢"," "]}),n==="high"?"Low Leverage Removed":"All Leverage"]})]})]}),d==="relative"&&e.jsx("div",{className:"w-full py-1 border-b border-border",children:e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Values relative to league average"})}),e.jsx("div",{className:"relative font-numeric",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Tr,{className:h(`${I?"w-fit":"w-full"} border-collapse ${b?"table-compact":""}`,P&&"table-fixed",I&&"table-fixed"),style:ee?{minWidth:ee}:void 0,children:[e.jsx(Ss,{className:h("sticky top-0 z-20 bg-card",l==="expanded"&&"z-[30]"),children:e.jsx(cr,{children:e.jsx(Pt,{children:(()=>{const x=I?`calc((100% - 160px) / ${Math.max(fe.length-1,1)})`:void 0;return fe.map(a=>{let v={};if(a.id==="lineup")if(ye)v={minWidth:ye,width:ye,maxWidth:ye};else{const u=O();if(u&&l==="overview")v={...u};else{let w="auto",L="auto",be;g===1?(w=b?"90px":"160px",L=b?"90px":"160px",be=b?"100px":void 0):b?(he?g===2?w="140px":g===3?w="142px":g===4?w="146px":w=V<400?"150px":"158px":g===2||g===3||g===4?w="155px":w=V<400?"155px":"170px",L=w):he?g===2?(w="150px",L="150px",be="185px"):g===3?(w="158px",L="auto"):g===4?(w="172px",L="auto"):(w="194px",L="auto"):g===2?(w="160px",L="160px",be="200px"):g===3?(w="160px",L="auto"):g===4?(w="180px",L="auto"):(w="210px",L="auto"),v={minWidth:w,...l==="expanded"?{}:{width:L},...be&&{maxWidth:be}}}}else if(a.id==="minutes")Te?v={minWidth:Te,width:Te,maxWidth:Te}:x?v={minWidth:"90px",width:x}:b&&g>1?v={minWidth:"35px",width:"35px"}:g===1?b&&l==="overview"?v={minWidth:"40px",width:"40px"}:v=b?{minWidth:"32px",width:"32px"}:{minWidth:"55px",width:"55px"}:v=l==="expanded"?{minWidth:"55px"}:{minWidth:"55px",width:"55px"};else if(!!x)v={minWidth:"90px",width:x};else if(l==="expanded")v={};else if(Te)v={minWidth:Te,width:Te,maxWidth:Te};else{const w=wo.includes(a.id),L=he&&w?b?"72px":g===1?void 0:"98px":void 0,be=g===1&&b&&l==="overview"?"40px":void 0;v={minWidth:be??(g===1?L??void 0:L??(l==="overview"&&b?"40px":l==="overview"?"60px":b?"40px":"60px")),width:be??(g===1?L??void 0:L??(l==="overview"&&b?"40px":l==="overview"?"70px":b?"40px":"65px"))}}const C=a.id!=="lineup"?Z(a.id,d):null,q=C&&C.title;return e.jsx(Xe.th,{className:h("h-8 py-1 text-center text-foreground font-semibold whitespace-nowrap cursor-pointer select-none",a.frozen&&"sticky left-0 z-20 bg-card shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]",g===3&&V<640&&(l==="offense"||l==="defense"||l==="expanded")?"text-[10px]":(g===2||g===3)&&V<640?"text-[11px]":g>=4&&V<640?"text-[10px]":"max-[400px]:text-[10px]",(a.id==="net"||a.id==="orb_pct")&&l==="expanded"&&"border-r border-border",_s.includes(a.id)&&"border-l border-border/60",a.id==="lineup"||b?"px-1":"px-2"),style:v,onClick:()=>a.id!=="lineup"&&R(a.id),"aria-sort":a.id===z?le==="asc"?"ascending":"descending":void 0,"aria-label":a.id!=="lineup"?`Sort by ${a.header}${a.id===z?le==="asc"?", sorted ascending":", sorted descending":""}`:void 0,children:q&&!b?e.jsxs(fr,{delayDuration:300,children:[e.jsx(mr,{asChild:!0,children:e.jsx("div",{className:"w-full h-full",children:a.header.includes(` 42`)?e.jsx("div",{className:"h-full flex flex-col items-center justify-center leading-[1.14] sm:leading-[1.16]",children:a.header.split(` 43`).map((u,w)=>e.jsx("div",{className:w===0?"text-[10px] text-foreground":"text-[9px] sm:text-[10px]",children:w===1&&u.includes("FREQ | FG%")?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"FREQ"}),e.jsx("span",{className:"text-foreground",children:" | "}),e.jsx("span",{className:"text-muted-foreground",children:"FG%"})]}):u},w))}):e.jsx("div",{className:"h-full flex flex-col items-center justify-center",children:e.jsxs("div",{className:h(a.id==="lineup"&&J&&"inline-flex items-center gap-1"),children:[a.id==="lineup"&&J&&e.jsx("img",{src:J,alt:`${A} logo`,className:"h-5 w-5 sm:h-6 sm:w-6 object-contain"}),e.jsx("span",{children:a.header}),te&&["off","def","net"].includes(a.id)&&e.jsx("span",{className:"text-primary text-[10px] sm:text-xs -top-1 relative ml-0.5 font-bold",children:"P"})]})})})}),e.jsx(pr,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-semibold text-sm whitespace-normal break-words",children:C.title}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-normal break-words",children:C.description}),C.sortHint&&e.jsx("p",{className:"text-xs italic whitespace-normal break-words",children:C.sortHint})]})})]}):e.jsx(e.Fragment,{children:a.header.includes(` 44`)?e.jsx("div",{className:"h-full flex flex-col items-center justify-center leading-[1.14] sm:leading-[1.16]",children:a.header.split(` 45`).map((u,w)=>e.jsx("div",{className:w===0?"text-[10px] text-foreground":"text-[9px] sm:text-[10px]",children:w===1&&u.includes("FREQ | FG%")?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"FREQ"}),e.jsx("span",{className:"text-foreground",children:" | "}),e.jsx("span",{className:"text-muted-foreground",children:"FG%"})]}):u},w))}):e.jsx("div",{className:"h-full flex flex-col items-center justify-center",children:e.jsxs("div",{className:h(a.id==="lineup"&&J&&"inline-flex items-center gap-1"),children:[a.id==="lineup"&&J&&e.jsx("img",{src:J,alt:`${A} logo`,className:"h-5 w-5 sm:h-6 sm:w-6 object-contain"}),e.jsx("span",{children:a.header}),te&&["off","def","net"].includes(a.id)&&e.jsx("span",{className:"text-primary text-[10px] sm:text-xs -top-1 relative ml-0.5 font-bold",children:"P"})]})})})},a.id)})})()})})}),e.jsx(Er,{children:e.jsx(cr,{children:ue.map((x,a)=>e.jsx(Pt,{className:h("bg-card",b?"hover:bg-card":"hover:bg-accent/20",x.id===lt&&"bg-card border-t-2 border-border"),children:fe.map((v,C)=>e.jsx(Be,{className:h("py-0.5 text-center align-middle",v.id==="lineup"?"px-1 text-sm":b?"text-sm":"text-base",v.id==="lineup"?"px-1":v.id==="minutes"||v.id==="off"||v.id==="def"?b?"px-0.5 relative":"px-1 relative":b?"px-1":"px-2",v.frozen&&"sticky left-0 z-10 bg-card",v.frozen&&(a%2===0,"bg-card"),v.frozen&&x.id===lt&&"bg-card",v.id==="lineup"?"text-left pt-1 pb-0":"font-numeric",(v.id==="net"||v.id==="orb_pct")&&l==="expanded"&&"border-r border-border",_s.includes(v.id)&&"border-l border-border/60",l!=="overview"&&v.id!=="lineup"&&"max-[500px]:text-xs",a===ue.length-1&&C===0&&"rounded-bl-lg",a===ue.length-1&&C===fe.length-1&&"rounded-br-lg"),children:v.id==="lineup"?x.id===lt?e.jsx("div",{className:"w-full flex justify-center items-center h-[3.5rem] sm:h-[4.55rem] py-2",children:e.jsx("span",{className:"text-xs sm:text-sm font-semibold tracking-wider text-foreground uppercase whitespace-nowrap",children:"On - Off"})}):(()=>{const q=he&&b&&g>1&&g<4,u=he&&!b&&g>1&&g<4,w=e.jsx(Xe.div,{className:h("relative flex items-center justify-evenly cursor-pointer hover:bg-secondary/50 rounded-md p-1 transition-colors",b&&g===5?"gap-1":"gap-2"),onClick:()=>we(x),role:"button",tabIndex:0,"aria-label":`View lineup details for ${T==="wowy"?`${x.on_players.map(L=>L.name).join(", ")} ${x.off_players.length>0?"without "+x.off_players.map(L=>L.name).join(", "):""}`:x.players.map(L=>L.name).join(", ")}`,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),we(x))},children:T!=="wowy"?x.players.map(L=>e.jsx(bt,{player:L,isOn:x.on_players.some(be=>be.id===L.id),isLarge:Me,compact:q,locationDesktopTight:u,teamLogoAbbr:A??void 0,numPlayers:g,lineupMode:T},L.nba_id)):e.jsxs(e.Fragment,{children:[x.on_players.map(L=>e.jsx(bt,{player:L,isOn:!0,isLarge:Me,compact:q,locationDesktopTight:u,teamLogoAbbr:A??void 0,numPlayers:g,lineupMode:T},L.nba_id)),x.off_players.map(L=>e.jsx(bt,{player:L,isOn:!1,isLarge:Me,compact:q,locationDesktopTight:u,teamLogoAbbr:A??void 0,numPlayers:g,lineupMode:T},L.nba_id))]})});return b?w:e.jsxs(fr,{delayDuration:200,children:[e.jsx(mr,{asChild:!0,children:w}),e.jsx(pr,{side:"right",className:"z-[9999] max-w-xs",children:e.jsx("p",{className:"text-xs whitespace-normal break-words",children:"Click for lineup composition"})})]})})():Le(v.id,x)},`${x.id}-${v.id}`))},x.id))})})]})})})]}),Ye=()=>b?"w-full":l==="expanded"?"w-full max-w-[95%] overflow-x-auto":"w-fit min-w-[576
45px] max-w-full";return e.jsxs("div",{className:`overflow-hidden font-numeric ${Ye()} mx-auto`,children:[e.jsx(wr,{mode:"wait",children:o?e.jsx(Xe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"mx-auto rounded-lg border border-border shadow-sm bg-card min-h-[400px] flex items-center justify-center w-full max-w-xl",children:e.jsx("div",{className:"text-muted-foreground",children:"Loading combinations..."})},"loading"):r.length===0?e.jsxs(Xe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"mx-auto rounded-lg border border-border shadow-sm bg-card min-h-[400px] flex flex-col items-center justify-center gap-2 w-full max-w-xl",children:[e.jsxs("p",{className:"text-muted-foreground text-center px-4",children:[T==="wowy"?`No combinations found for these players in ${ke().toLowerCase()}`:`${bn(K,T)} found in ${ke().toLowerCase()}`,n==="high"?" with high leverage":"","."]}),e.jsx("p",{className:"text-xs text-muted-foreground/80",children:T==="wowy"?"Try selecting different players or adjusting the filters.":"Try selecting different players or changing the lineup size."})]},"empty"):e.jsxs(Xe.div,{initial:{opacity:0}
45,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"w-full flex flex-col gap-2",children:[Ke,e.jsxs("p",{className:"text-xs text-muted-foreground",children:[D," a lineup cell for detailed information about that lineup combination"]})]},"content")}),Y&&e.jsx(Ys,{isOpen:Oe,onClose:()=>{k(!1),Fe(null)},onPlayers:Y.on_players,offPlayers:Y.off_players,partners:(pe==null?void 0:pe.partners)||[],partnersWithMetrics:(pe==null?void 0:pe.partnersWithMetrics)||[],teammateHelp:pe==null?void 0:pe.teammateHelp,startYear:m,endYear:i,teamAbbr:A,ratings:{off:Y.off,def:Y.def,net:Y.net,rel_off:Y.rel_off,rel_def:Y.rel_def,rel_net:Y.rel_net,minutes:Y.minutes,ts_pct:Y.ts_pct,tov_pct:Y.tov_pct,orb_pct:Y.orb_pct,opp_ts_pct:Y.opp_ts_pct,opp_tov_pct:Y.opp_tov_pct,opp_orb_pct:Y.opp_orb_pct,total_fg3a:Y.total_fg3a,total_fg3m:Y.total_fg3m,total_d_fg3a:Y.total_d_fg3a,total_d_fg3m:Y.total_d_fg3m,fg3_pct:Y.fg3_pct,lg_avg_ts:Y.lg_avg_ts,lg_avg_tov:Y.lg_avg_tov,lg_avg_orb:Y.lg_avg_orb,lg_avg_ortg:Y.lg_avg_ortg,off_rim_freq:Y.off_rim_freq,off_rim_fg_pct:Y.off_rim_fg_pct,off_mid_freq:Y.off_mid_freq,off_mid_fg_pct:Y.off_mid_fg_pct,off_3p_freq:Y.off_3p_freq,off_3p_pct:Y.off_3p_pct,off_corner3_freq:Y.off_corner3_freq,off_corner3_fg_pct:Y.off_corner3_fg_pct,def_rim_freq:Y.def_rim_freq,def_rim_fg_pct:Y.def_rim_fg_pct,def_mid_freq:Y.def_mid_freq,def_mid_fg_pct:Y.def_mid_fg_pct,def_3p_freq:Y.def_3p_freq,def_3p_pct:Y.def_3p_pct,def_corner3_freq:Y.def_corner3_freq,def_corner3_fg_pct:Y.def_corner3_fg_pct,lg_avg_rim_freq:Y.lg_avg_rim_freq,lg_avg_rim_acc:Y.lg_avg_rim_acc,lg_avg_mid_freq:Y.lg_avg_mid_freq,lg_avg_mid_acc:Y.lg_avg_mid_acc,lg_avg_3p_freq:Y.lg_avg_3p_freq,lg_avg_three:Y.lg_avg_three,lg_avg_fg2_pct:Y.lg_avg_fg2_pct,lg_avg_corner_freq:Y.lg_avg_corner_freq,lg_avg_corner:Y.lg_avg_corner},isPaddingEnabled:te})]})})),Oo="min(0.5rem, 4%)",vs=(t,r,o)=>Math.min(o,Math.max(r,t)),Po=(t,r)=>t>=5?r<400?24:28:t===4&&r<400?24:r<410?40:48,Co=t=>t>=5?10:14,So=t=>t>=5?{minGap:2,minSpacing:-3,maxSpacing:7}:{minGap:3,minSpacing:-4,maxSpacing:10};function To({players:t,teamLogoAbbr:r,isMobile:o}){const f=_.useRef(null),[m,i]=_.useState(0),[l,s]=_.useState(typeof window<"u"?window.innerWidth:1280),d=o&&(t.length===4||t.length===5);_.useEffect(()=>{if(!d||typeof window>"u")return;const N=()=>{var W;s(window.innerWidth),i(((W=f.current)==null?void 0:W.getBoundingClientRect().width)??0)};N();const y=typeof ResizeObserver<"u"?new ResizeObserver(()=>{N()}):null;return y&&f.current&&y.observe(f.current),window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N),y==null||y.disconnect()}},[d,t.length]);const c=_.useMemo(()=>{if(!d||m<=0||t.length<2)return null;const N=Po(t.length,l),y=N+Co(t.length),{minGap:W,minSpacing:E,maxSpacing:S}=So(t.length),j=(m-W*(t.length-1))/t.length,A=vs(Math.min(y,j),N,y),T=(m-A*t.length)/(t.length-1),p=vs(T,E,S);return{slotWidth:A,gap:Math.max(p,0),overlap:Math.min(p,0)}},[m,t.length,d,l]),n=d&&c;return e.jsx("div",{ref:f,className:"relative z-10 flex w-full items-center justify-center",children:e.jsx("div",{className:n?"flex w-full items-start justify-center":"inline-grid",style:n?{gap:`${c.gap}px`,maxWidth:"100%"}:{gridTemplateColumns:`repeat(${t.length}, auto)`,justifyContent:"center",columnGap:Oo,maxWidth:"100%"},children:t.map((N,y)=>e.jsx("div",{style:n?{width:`${c.slotWidth}px`,flex:"0 0 auto",marginLeft:y===0?void 0:`${c.overlap}px`}:void 0,children:e.jsx(cn,{player:N,teamLogoAbbr:r,isLarge:t.length<=2,numPlayers:t.length,slotWidthPx:n?c.slotWidth:void 0})},`${r}-${N.nba_id}`))})})}const Gs="calc(100vh - 18rem)",Eo=6,$t=7,qo="#1A2438",yr=t=>t.toFixed(1),ko=t=>t.toFixed(0),Mo=t=>t==="regular"?"Regular Season":t==="playoffs"?"Playoffs":"All Games",Wo=t=>t==="high"?"Medium/High Leverage":"All Leverage",ar=t=>`${t>0?"+":""}${yr(t)}`,br=t=>t==="raw"?"Raw":t==="no_help_padded"?"No Help Padded":"Padded",ys=(t,r=!1)=>t===0?"text-muted-foreground/70":r?t<0?"text-primary":"text-secondary":t>0?"text-primary":"text-secondary",bs=t=>t==="rank"||t==="team"||t==="def"?"asc":"desc",Ut=t=>Number(t.charAt(0)),Hs=t=>{const r=Ut(t);return r>=5?"840px":r===4?"824px":"800px"},Lo=t=>{const r=Ut(t);return r>=5?{rank:"52px",team:"72px",lineup:"348px",minutes:"82px",off:"86px",def:"86px",net:"88px"}:r===4?{rank:"54px",team:"78px",lineup:"332px",minutes:"84px",off:"88px",def:"88px",net:"90px"}:{rank:"56px",team:"92px",lineup:"300px",minutes:"86px",off:"92px",def:"92px",net:"94px"}},Ao=t=>Ut(t)<=2?"45%":"54%",Do=t=>Ut(t)<=2?"13%":"10%",$o=(t,r="nba")=>{if(!t)return;const o=nn(t,r);return{...qr(t,r),...kr(t,r),borderColor:on(o,.6)}},Ro=({isActive:t,isMobile:r=!1})=>h("whitespace-nowrap px-3 py-1.5 rounded-md font-medium border transition-colors duration-200",r?"text-[10px]":"text-xs",t?"border-primary/60 bg-primary/10 text-primary":"border-border bg-background/30 text-muted-foreground hover:bg-accent hover:text-foreground"),Io=t=>{const r=t.player_names||[];return t.player_ids.map((o,f)=>({id:o,nba_id:String(o),name:r[f]||`Player ${f+1}`}))},Ns=(t,r)=>r==="no_help_padded"?t.padded_rank_no_help??null:r==="padded"?t.padded_rank??null:null,ht=(t,r)=>r==="raw"?t.off:r==="no_help_padded"?t.paddedOffNoHelp??t.paddedOff:t.paddedOff,vt=(t,r)=>r==="raw"?t.def:r==="no_help_padded"?t.paddedDefNoHelp??t.paddedDef:t.paddedDef,nt=(t,r)=>r==="raw"?t.net:r==="no_help_padded"?t.paddedNetNoHelp??t.paddedNet:t.paddedNet,Nt=t=>t.map(r=>Number(r)).filter(r=>Number.isFinite(r)).sort((r,o)=>r-o).join("-"),nr=(t,r,o,f,m)=>[t.team_abbreviation,r,o,f,m,Nt(t.player_ids)].join("|"),Bo=t=>{const r={};return t.forEach(o=>{const f=Number(o.year);if(!Number.isFinite(f))return;const m=o.nba_id.toString();r[m]||(r[m]={}),r[m][f]={dpm:o.dpm??null,o_dpm:o.o_dpm??null,d_dpm:o.d_dpm??null}}),r},Us=(t,r)=>t.lg_avg_ortg!=null?{rel_off:t.paddedOff-t.lg_avg_ortg,rel_def:t.paddedDef-t.lg_avg_ortg,rel_net:t.paddedNet}:{rel_off:r==null?void 0:r.rel_off,rel_def:r==null?void 0:r.rel_def,rel_net:r==null?void 0:r.rel_net},Ko=t=>{const r=Us(t);return{off:t.paddedOff,def:t.paddedDef,net:t.paddedNet,raw_off:t.off,raw_def:t.def,raw_net:t.net,...r,minutes:t.minutes,ts_pct:t.ts_pct??void 0,tov_pct:t.tov_pct??void 0,orb_pct:t.orb_pct??void 0,opp_ts_pct:t.opp_ts_pct??void 0,opp_tov_pct:t.opp_tov_pct??void 0,opp_orb_pct:t.opp_orb_pct??void 0,total_fg3a:t.total_fg3a??void 0,total_fg3m:t.total_fg3m??void 0,total_d_fg3a:t.total_d_fg3a??void 0,total_d_fg3m:t.total_d_fg3m??void 0,fg3_pct:t.total_d_fg3a&&t.total_d_fg3a>0&&t.total_d_fg3m!=null?t.total_d_fg3m/t.total_d_fg3a*100:void 0,lg_avg_ts:t.lg_avg_ts??void 0,lg_avg_tov:t.lg_avg_tov??void 0,lg_avg_orb:t.lg_avg_orb??void 0,lg_avg_ortg:t.lg_avg_ortg??void 0}},Yo=(t,r)=>{const o=Us(t,r);return{off:t.paddedOff,def:t.paddedDef,net:t.paddedNet,raw_off:r.off,raw_def:r.def,raw_net:r.net,...o,minutes:r.minutes,ts_pct:r.ts_pct,tov_pct:r.tov_pct,orb_pct:r.orb_pct,opp_ts_pct:r.opp_ts_pct,opp_tov_pct:r.opp_tov_pct,opp_orb_pct:r.opp_orb_pct,total_fg3a:r.total_fg3a,total_fg3m:r.total_fg3m,total_d_fg3a:r.total_d_fg3a,total_d_fg3m:r.total_d_fg3m,fg3_pct:r.fg3_pct,lg_avg_ts:r.lg_avg_ts,lg_avg_tov:r.lg_avg_tov,lg_avg_orb:r.lg_avg_orb,lg_avg_ortg:r.lg_avg_ortg,off_rim_freq:r.off_rim_freq,off_rim_fg_pct:r.off_rim_fg_pct,off_mid_freq:r.off_mid_freq,off_mid_fg_pct:r.off_mid_fg_pct,off_3p_freq:r.off_3p_freq,off_3p_pct:r.off_3p_pct,off_corner3_freq:r.off_corner3_freq,off_corner3_fg_pct:r.off_corner3_fg_pct,def_r
45im_freq:r.def_rim_freq,def_rim_fg_pct:r.def_rim_fg_pct,def_mid_freq:r.def_mid_freq,def_mid_fg_pct:r.def_mid_fg_pct,def_3p_freq:r.def_3p_freq,def_3p_pct:r.def_3p_pct,def_corner3_freq:r.def_corner3_freq,def_corner3_fg_pct:r.def_corner3_fg_pct,lg_avg_rim_freq:r.lg_avg_rim_freq,lg_avg_rim_acc:r.lg_avg_rim_acc,lg_avg_mid_freq:r.lg_avg_mid_freq,lg_avg_mid_acc:r.lg_avg_mid_acc,lg_avg_3p_freq:r.lg_avg_3p_freq,lg_avg_three:r.lg_avg_three,lg_avg_fg2_pct:r.lg_avg_fg2_pct,lg_avg_corner_freq:r.lg_avg_corner_freq,lg_avg_corner:r.lg_avg_corner}},Go=t=>t<=2?"max-[410px]:h-[3.6rem] max-[410px]:w-[3.6rem] h-[4.1rem] w-[4.1rem] sm:h-[4.55rem] sm:w-[4.55rem]":t>=5?"max-[400px]:h-9 max-[400px]:w-6 h-10 w-7 sm:h-14 sm:w-14":t===4?"max-[400px]:h-9 max-[400px]:w-6 max-[410px]:h-10 max-[410px]:w-10 h-12 w-12 sm:h-14 sm:w-14":"max-[410px]:h-10 max-[410px]:w-10 h-12 w-12 sm:h-14 sm:w-14",zs=t=>t<=2?"h-[4.1rem] w-[4.1rem] sm:h-[4.55rem] sm:w-[4.55rem]":"h-12 w-12 sm:h-14 sm:w-14",Ho=t=>t>=5?"h-10 w-10 sm:h-12 sm:w-12":t===4?"h-11 w-11 sm:h-[3.15rem] sm:w-[3.15rem]":zs(t);function Vs({league:t,selectedYear:r,seasonType:o,leverageFilter:f,lineupMode:m,metricMode:i,leaderCountLabel:l}){return e.jsxs("div",{"data-export-match-row-bg":"true",className:"flex items-center justify-between border-b border-border bg-card/95 px-4 py-2 md:py-3",children:[e.jsx(St,{className:Wr(t)}),e.jsxs("div",{className:"ml-4 flex flex-col items-end gap-0.5",children:[e.jsxs("p",{className:"text-right text-xs leading-tight text-muted-foreground max-[500px]:text-[9px]",children:[jt(t,m)," League Leaders ⢠",r," â¢"," ",Mo(o)]}),e.jsxs("p",{className:"text-right text-xs leading-tight text-muted-foreground max-[500px]:text-[9px]",children:[e.jsx("span",{className:"text-primary",children:br(i)})," â¢"," ",Wo(f)," ⢠",l]})]})]})}function Qs({league:t,isMobile:r,lineupMode:o,metricMode:f,sortColumn:m,sortDirection:i,onSort:l}){const s=Lo(o),d=Ao(o),c=Do(o),n=y=>r||m!==y?null:i==="asc"?e.jsx(fn,{className:"h-3 w-3 text-primary","aria-hidden":"true"}):e.jsx(ya,{className:"h-3 w-3 text-primary","aria-hidden":"true"}),N=(y,W,E=!1)=>e.jsxs("button",{type:"button",className:"flex w-full items-center justify-center gap-0.5 transition-colors hover:text-foreground",onClick:()=>l(W),"aria-label":`Sort by ${y}${m===W?`, sorted ${i}`:""}`,"aria-sort":m===W?i==="asc"?"ascending":"descending":"none",children:[e.jsx("span",{children:y}),E&&f!=="raw"&&e.jsx("span",{className:"relative -top-1 text-[10px] font-bold text-primary sm:text-xs",children:"P"}),n(W)]});return e.jsx(Ss,{children:e.jsxs(Pt,{"data-export-match-row-bg":"true",className:h("border-border [&>th]:sticky [&>th]:top-0 [&>th]:z-20 [&>th]:border-b [&>th]:border-border [&>th]:bg-card"),children:[e.jsx(st,{className:h("px-0.5 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:"6%"}:{width:s.rank},children:N("#","rank")}),!r&&e.jsx(st,{className:"px-1 text-center text-sm font-semibold text-foreground",style:{width:s.team},children:N("TEAM","team")}),e.jsx(st,{className:h("px-1 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:d}:{width:s.lineup,minWidth:s.lineup},children:yn(t,o)}),e.jsx(st,{className:h("px-1 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:"10%"}:{width:s.minutes},children:N("MIN","minutes")}),e.jsx(st,{className:h("px-1 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:"10%"}:{width:s.off},children:N("OFF","off",!0)}),e.jsx(st,{className:h("px-1 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:"10%"}:{width:s.def},children:N("DEF","def",!0)}),e.jsx(st,{className:h("px-1 text-center font-semibold",r?"text-xs text-muted-foreground":"text-sm text-foreground"),style:r?{width:c}:{width:s.net},children:N("NET","net",!0)})]})})}function Uo({teamAbbreviation:t,numPlayers:r,isFiltered:o}){const f=Ze(),m=Mr(t,f);return e.jsx("div",{className:h("relative flex items-center justify-center transition-transform duration-200",o&&"scale-[1.06]",Ho(r)),"aria-hidden":"true",children:e.jsx("img",{src:Tt(t,f),alt:"",className:"z-[1] h-full w-full scale-[1.22] object-contain select-none",style:{...m,opacity:.98,filter:"drop-shadow(0 3px 10px rgba(15, 23, 42, 0.32))"},draggable:"false",onDragStart:i=>{i.preventDefault()},onError:i=>{i.currentTarget.style.display="none"}})})}function zo({isMobile:t,selectedYear:r,seasonType:o,leverageFilter:f,lineupMode:m}){const i=Ze(),l=Number(m.charAt(0)),s=Hs(m);return e.jsxs("div",{className:"mx-auto w-full overflow-visible rounded-lg border border-border bg-card shadow-lg md:overflow-hidden",style:t?void 0:{maxWidth:s},children:[e.jsx(Vs,{league:i,selectedYear:r,seasonType:o,leverageFilter:f,lineupMode:m,metricMode:"padded",leaderCountLabel:"Top 200"}),e.jsx("div",{className:h("font-numeric",t?"[&>div]:max-h-[80vh] [&>div]:overflow-y-auto [&>div]:overflow-x-hidden [&>div]:overscroll-contain [&>div]:scrollbar-thin-hidden":"[&>div]:max-h-[var(--leaders-scroll-max-height)] [&>div]:!overflow-auto [&>div]:scrollbar-hide"),style:t?void 0:{"--leaders-scroll-max-height":Gs},children:e.jsxs(Tr,{className:h("w-full border-collapse",t&&"table-fixed table-compact"),children:[e.jsx(Qs,{league:i,isMobile:t,lineupMode:m,metricMode:"padded",sortColumn:"net",sortDirection:"desc",onSort:()=>{}}),e.jsx(Er,{children:Array.from({length:Eo},(d,c)=>e.jsxs(Pt,{className:"border-border/70",children:[e.jsx(Be,{className:"px-0.5 pt-2 pb-0 md:py-2 text-center",children:e.jsx(ne,{className:"mx-auto h-4 w-4 roun
45ded-sm md:h-6 md:w-5"})}),!t&&e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(ne,{className:h("rounded-full",zs(l))})})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsx("div",{className:"flex w-full items-center justify-center",children:e.jsx("div",{className:"inline-grid",style:{gridTemplateColumns:`repeat(${l}, auto)`,justifyContent:"center",columnGap:"min(0.5rem, 4%)",maxWidth:"100%"},children:Array.from({length:l},(n,N)=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ne,{className:h("rounded-full",Go(l))}),e.jsx(ne,{className:h("rounded-sm",t?"h-2 w-8 max-[400px]:w-6":"h-3 w-12")})]},`leaders-skeleton-${c}-player-${N}`))})})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1",children:[e.jsx(ne,{className:h("rounded-sm",t?"h-4 w-8":"h-6 w-12")}),e.jsx(ne,{className:h("rounded-sm opacity-60",t?"h-2 w-6":"h-3 w-9")})]})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1",children:[e.jsx(ne,{className:h("rounded-sm",t?"h-4 w-9":"h-6 w-14")}),e.jsx(ne,{className:h("rounded-sm opacity-70",t?"h-2 w-7":"h-3 w-10")})]})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1",children:[e.jsx(ne,{className:h("rounded-sm",t?"h-4 w-9":"h-6 w-14")}),e.jsx(ne,{className:h("rounded-sm opacity-70",t?"h-2 w-7":"h-3 w-10")})]})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(ne,{className:h("rounded-sm",t?"h-4 w-10":"h-5 w-16")})})})]},`leaders-skeleton-${c}`))})]})}),e.jsx("div",{className:"border-t border-border px-4 py-2",children:e.jsx(ne,{className:"h-3 w-40 rounded-sm md:w-52"})})]})}function Vo({leaders:t,isLoading:r,selectedYear:o,seasonType:f,leverageFilter:m,lineupMode:i}){const l=Ze(),s=va(),{toast:d}=Fr(),c=_.useRef(null),n=_.useRef(new Map),N=_.useRef(null),[y,W]=_.useState(null),[E,S]=_.useState(null),[j,A]=_.useState(!1),[T,p]=_.useState(null),[F,ie]=_.useState("padded"),[$,G]=_.useState(null),[M,ge]=_.useState("net"),[te,oe]=_.useState("desc"),[ce,K]=_.useState(!1),b=Hs(i),X=_.useMemo(()=>Or(l),[l]),V=_.useMemo(()=>t.map(k=>{const H=Ds({off:k.off,def:k.def,offPossessions:k.off_possessions,defPossessions:k.def_possessions,lgAvgOrtg:k.lg_avg_ortg});return H?{...k,paddedOff:k.padded_off_rating??H.paddedOff,paddedDef:k.padded_def_rating??H.paddedDef,paddedNet:k.padded_net_rating??H.paddedNet,paddedOffNoHelp:k.padded_off_rating_no_help??null,paddedDefNoHelp:k.padded_def_rating_no_help??null,paddedNetNoHelp:k.padded_net_rating_no_help??null,players:Io(k)}:null}).filter(k=>k!==null),[t]),me=_.useMemo(()=>$?V.filter(k=>k.team_abbreviation===$):V,[$,V]),ve=_.useMemo(()=>{const k=[...me].sort((_e,J)=>nt(J,"raw")-nt(_e,"raw")),H=new Map(k.map((_e,J)=>[Nt(_e.player_ids),J+1]));return me.map(_e=>({row:_e,rawRank:H.get(Nt(_e.player_ids))??Number.POSITIVE_INFINITY}))},[me]),z=_.useMemo(()=>{const k=[...ve];return k.sort(({row:H,rawRank:_e},{row:J,rawRank:D})=>{switch(M){case"rank":{const g=F==="raw"?_e:Ns(H,F)??Number.POSITIVE_INFINITY,O=F==="raw"?D:Ns(J,F)??Number.POSITIVE_INFINITY;return te==="asc"?g-O:O-g}case"team":{const g=H.team_abbreviation.localeCompare(J.team_abbreviation);return te==="asc"?g:-g}case"minutes":return te==="asc"?H.minutes-J.minutes:J.minutes-H.minutes;case"off":return te==="asc"?ht(H,F)-ht(J,F):ht(J,F)-ht(H,F);case"def":return te==="asc"?vt(H,F)-vt(J,F):vt(J,F)-vt(H,F);case"net":default:return te==="asc"?nt(H,F)-nt(J,F):nt(J,F)-nt(H,F)}}),k.map(({row:H})=>H)},[F,ve,M,te]),Ce=_.useMemo(()=>ce?z.slice(0,$t):z,[ce,z]),le=async k=>{const H=nr(k,o,f,m,i);W(k);const _e=n.current.get(H);if(_e){S(_e),A(!0);return}N.current=H,S(null),A(!0),p(H);try{const[J,D]=await Promise.all([dr(k.team_abbreviation,o,f,l),Ps(o,k.team_id,f,m,void 0,l)]),g=new Map(J.map(he=>[he.nba_id.toString(),he])),O=k.player_ids.map((he,P)=>{const I=g.get(String(he));return I||(k.players[P]??{id:he,nba_id:String(he),name:k.player_names[P]||`Player ${P+1}`})}),Z=await Dr(D,O,0,0,i,J),R=Nt(k.player_ids),U=Z.find(he=>he.off_players.length===0&&Nt(he.on_players.map(P=>P.nba_id))===R);if(!U)throw new Error(`Unable to locate lineup details for ${k.player_names.join(", ")}`);const ue=Bo(J),re=hr(D,U.on_players,U.off_players,J),we=vr({partners:re,onPlayers:U.on_players,playerMetricsByYear:ue}),fe={onPlayers:U.on_players,offPlayers:U.off_players,partners:re,partnersWithMetrics:we.partnersWithMetrics,teammateHelp:we.teammateHelp,ratings:Yo(k,U)};if(n.current.set(H,fe),N.current!==H)return;S(fe),A(!0)}catch(J){if(console.error("[WowyLeadersTable] Failed to hydrate lineup dialog:",J),N.current!==H)return;S(null),A(!0),d({title:"Loaded partial lineup card",description:"Full teammate details were unavailable for this leaders lineup.",duration:2400})}finally{N.current===H&&(N.current=null),p(J=>J===H?null:J)}},je=()=>{N.current=null,p(null),A(!1),W(null),S(null)},Y=k=>{G(H=>H===k?null:k)},xe=k=>{if(M===k){oe(H=>H==="asc"?"desc":"asc");return}ge(k),oe(bs(k))},pe=k=>{if(F!==k){if(ie(k),M==="rank"){oe("asc");return}(M==="off"||M==="def"||M==="net")&&oe(bs(M))}},Fe=async()=>
45{if(!c.current||ce)return;K(!0);const k=[c.current,...Array.from(c.current.querySelectorAll('[data-export-match-row-bg="true"], [data-export-match-row-bg="true"] th'))],H=Array.from(c.current.querySelectorAll('button[data-export-clear-hover="true"], [data-export-clear-hover="true"] button')),_e=k.map(O=>({element:O,backgroundColor:O.style.backgroundColor,backgroundImage:O.style.backgroundImage})),J=H.map(O=>({element:O,backgroundColor:O.style.backgroundColor,boxShadow:O.style.boxShadow,filter:O.style.filter,pointerEvents:O.style.pointerEvents,transform:O.style.transform})),D=c.current.querySelector(".leaders-table-scroll-region > div"),g=D instanceof HTMLElement?{scrollTop:D.scrollTop,maxHeight:D.style.maxHeight,overflow:D.style.overflow,overflowX:D.style.overflowX,overflowY:D.style.overflowY,height:D.style.height}:null;try{const O=document.activeElement;O instanceof HTMLElement&&c.current.contains(O)&&O.blur(),await new Promise(U=>requestAnimationFrame(()=>U())),await new Promise(U=>requestAnimationFrame(()=>U())),D instanceof HTMLElement&&(D.scrollTop=0,D.style.maxHeight="none",D.style.height="auto",D.style.overflow="visible",D.style.overflowX="visible",D.style.overflowY="visible"),k.forEach(U=>{U.style.backgroundImage="none",U.style.backgroundColor=qo}),H.forEach(U=>{U.style.backgroundColor="transparent",U.style.boxShadow="none",U.style.filter="none",U.style.pointerEvents="none",U.style.transform="none"}),await new Promise(U=>requestAnimationFrame(()=>U()));const Z=await Ts(c.current);if(!Z)throw new Error("Export returned empty");const R=document.createElement("a");R.download=`wowy-leaders-top-${Math.min(z.length,$t)}-${i}-${F}.png`,R.href=Z,R.click(),d({title:"Image downloaded",description:`Exported the top ${Math.min(z.length,$t)} ${dt(l,i)} ${br(F).toLowerCase()} lineups.`,duration:2200})}catch(O){console.error("[WowyLeadersTable] Export failed:",O),d({title:"Export failed",description:"Please try again.",variant:"destructive",duration:2200})}finally{_e.forEach(({element:O,backgroundColor:Z,backgroundImage:R})=>{O.style.backgroundColor=Z,O.style.backgroundImage=R}),J.forEach(({element:O,backgroundColor:Z,boxShadow:R,filter:U,pointerEvents:ue,transform:re})=>{O.style.backgroundColor=Z,O.style.boxShadow=R,O.style.filter=U,O.style.pointerEvents=ue,O.style.transform=re}),D instanceof HTMLElement&&g&&(D.scrollTop=g.scrollTop,D.style.maxHeight=g.maxHeight,D.style.height=g.height,D.style.overflow=g.overflow,D.style.overflowX=g.overflowX,D.style.overflowY=g.overflowY),K(!1)}},Oe=e.jsx("div",{className:"flex items-center justify-center mb-4",children:e.jsx("div",{className:"flex items-center gap-1",children:[{value:"padded",label:"Padded"},{value:"raw",label:"Raw"}].map(k=>e.jsx("button",{type:"button",onClick:()=>pe(k.value),className:Ro({isActive:F===k.value,isMobile:s}),"aria-pressed":F===k.value,children:k.label},k.value))})});return r?e.jsxs(e.Fragment,{children:[Oe,e.jsx(zo,{isMobile:s,selectedYear:o,seasonType:f,leverageFilter:m,lineupMode:i})]}):z.length===0?e.jsxs(e.Fragment,{children:[Oe,e.jsxs("div",{className:"rounded-lg border border-border bg-card px-6 py-10 text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"No leaderboard rows found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Once `wowy_stats_leaders` is populated for ",o,", the top"," ",br(F).toLowerCase()," ",dt(l,i),"lineups will appear here."]})]})]}):e.jsxs(e.Fragment,{children:[Oe,e.jsxs("div",{ref:c,className:"mx-auto w-full rounded-lg border border-border bg-card overflow-visible shadow-lg md:overflow-hidden",style:s?void 0:{maxWidth:b},children:[e.jsx(Vs,{league:l,selectedYear:o,seasonType:f,leverageFilter:m,lineupMode:i,metricMode:F,leaderCountLabel:$?`Top ${z.length} ⢠${$}`:`Top ${z.length}`}),$&&e.jsxs("div",{"data-export-match-row-bg":"true",className:"flex items-center justify-between gap-3 border-b border-border/70 bg-card/95 px-4 py-2 text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Filtering leaders for"," ",e.jsx("span",{className:"font-semibold text-foreground",children:X[$]||$})]}),e.jsx(Qe,{type:"button",variant:"ghost",size:"sm",onClick:()=>G(null),className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Clear team filter"})]}),e.jsx("div",{className:h("leaders-table-scroll-region font-numeric",s?"[&>div]:max-h-[80vh] [&>div]:overflow-y-auto [&>div]:overflow-x-hidden [&>div]:overscroll-contain [&>div]:scrollbar-thin-hidden":"[&>div]:max-h-[var(--leaders-scroll-max-height)] [&>div]:!overflow-auto [&>div]:scrollbar-hide"),style:s?void 0:{"--leaders-scroll-max-height":Gs},children:e.jsxs(Tr,{className:h("w-full border-collapse",s&&"table-fixed table-compact"),children:[e.jsx(Qs,{league:l,isMobile:s,lineupMode:i,metricMode:F,sortColumn:M,sortDirection:te,onSort:xe}),e.jsx(Er,{children:Ce.map((k,H)=>{const _e=k.players.length,J=nr(k,o,f,m,i),D=T===J,g=ht(k,F),O=vt(k,F),Z=nt(k,F),R=k.lg_avg_ortg==null?null:g-k.lg_avg_ortg,U=k.lg_avg_ortg==null?null:O-k.lg_avg_ortg;return e.jsxs(Pt,{className:"border-border/70 transition-colors",children:[e.jsx(Be,{className:"px-0.5 pt-2 pb-0 md:py-2 text-center font-semibold max-md:text-sm max-md:text-muted-foreground md:text-2xl md:text-foreground",children:H+1}),!s&&e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsx("button",{type:"button",className:h("mx-auto flex items-center justify-center rounded-md p-1 transition-colors hover:bg-secondary/35",$===k.team_abbreviation&&"text-foreground"),"data-export-clear-hover":$===k.team_abbreviation?void 0:"true",style:$===k.team_abbreviation?$o(k.team_abbreviation,l):void 0,title:`Filter leaders for ${X[k.team_abbreviation]||k.team_abbreviation}`,"aria-label":`Filter leaders for ${X[k.team_abbreviation]||k.team_abbreviation}`,"aria-pressed":$===k.team_abbreviation,onClick:()=>Y(k.team_abbreviation),children:e.jsx(Uo,{teamAbbreviation:k.team_abbreviation,numPlayers:_e,isFiltered:$===k.team_abbreviation})})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2",children:e.jsx("button",{type:"button",className:h("w-full rounded-md p-1 transition-colors hover:bg-secondary/50",D&&"cursor-progress opacity-70"),"data-export-clear-hover":"true",disabled:D,onClick:()=>le(k),"aria-busy":D,"aria-label":`View ${k.team_abbreviation} lineup card for ${k.player_names.join(", ")}`,title:X[k.team_abbreviation]||k.team_abbreviation,children:e.jsx("div",{className:"relative isolate flex w-full items-center justify-center",children:e.jsx(To,{players:k.players,teamLogoAbbr:k.team_abbreviation,isMobile:s})})})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2 text-center align-middle",children:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("span",{className:h("whitespace-nowrap text-foreground",s?"text-[12px] font-medium":"text-lg font-bold"),children:ko(k.minutes)})})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2 text-center align-middle",children:e.jsxs("div",{className:"flex flex-col items-center justify-center leading-tight",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",s?"text-[12px] font-medium":"text-lg font-bold"),children:yr(g)}),e.jsx("span",{className:h(s?"text-[10px]":"text-sm","font-semibold",R==null?"text-transparent":ys(R)),children:R==null?"0.0":ar(R)})]})}),e.jsx(Be,{className:"px-1 pt-2 pb-0 md:py-2 text-center align-middle",children:e.jsxs("div",{className:"flex flex-col items-center justify-center leading-tight",children:[e.jsx("span",{className:h("whitespace-nowrap text-foreground",s?"text-[12px] font-medium":"text-lg font-bold"),children:yr(O)}),e.jsx("span",{className:h(s?"text-[10px]":"text-sm","font-semibold",U==null?"text-transparent":ys(U,!0)),children:U==null?"0.0":ar(U)})]})}),e.jsx(Be,{className:h("px-1 pt-2 pb-0 md:py-2 text-center align-middle",Z>=0?"text-primary":"text-secondary"),children:e.jsx("span",{className:h("font-semibold whitespace-nowrap tracking-tight",s?"text-[12px]":"text-xl"),children:ar(Z)})})]},`${k.team_abbreviation}-${k.player_ids.join("-")}-${H}`)})})]})}),ce&&e.jsx("div",{"aria-hidden":"true","data-export-match-row-bg":"true",className:"h-3 border-t border-border/70 bg-card"}),e.jsxs("div",{"data-export-match-row-bg":"true",className:"export-hide flex items-center justify-between gap-3 border-t border-border px-4 py-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:s?"Click a lineup to open the lineup card. Click a stat header to sort.":"Click a team icon to filter. Click a lineup to open the lineup card. Click a stat header to sort."}),e.jsxs(Qe,{type:"button",variant:"outline",size:"sm",onClick:Fe,disabled:ce,className:"export-hide h-8 shrink-0 gap-1.5 border-border bg-card text-foreground hover:bg-accent",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),ce?"Exporting...":`Export Top ${Math.min(z.length,$t)}`]})]}),y&&e.jsx(Ys,{isOpen:j,onClose:je,onPlayers:(E==null?void 0:E.onPlayers)||y.players,offPlayers:(E==null?void 0:E.offPlayers)||[],partners:(E==null?void 0:E.partners)||[],partnersWithMetrics:(E==null?void 0:E.partnersWithMetrics)||[],teammateHelp:E==null?void 0:E.teammateHelp,startYear:o,endYear:o,teamAbbr:y.team_abbreviation,ratings:(E==null?void 0:E.ratings)||Ko(y),isPaddingEnabled:!0,isLoadingDetails:T===nr(y,o,f,m,i)})]})]})}async function Qo(t){var s;const{toPng:r}=await ba(async()=>{const{toPng:d}=await import("./index-6sdqbm2o.js");return{toPng:d}},[]);await document.fonts.ready;const o=t.cloneNode(!0),f=[t,...Array.from(t.querySelectorAll("*"))],m=[o,...Array.from(o.querySelectorAll("*"))];f.forEach((d,c)=>{const n=m[c],N=getComputedStyle(d);for(const y of Array.from(N))n.style.setProperty(y,N.getPropertyValue(y));
45n.style.animation="none",n.style.transition="none",N.position==="sticky"&&(n.style.position="relative",n.style.inset="auto"),n.removeAttribute("id"),d.matches('.export-hide, [data-export-hide="true"]')&&(n.style.display="none"),(N.overflowX==="auto"||N.overflowY==="auto"||N.overflowY==="scroll")&&(n.style.overflow="visible",n.style.maxHeight="none",n.style.height="auto",n.style.width=`${Math.max(d.clientWidth,d.scrollWidth)}px`)}),o.querySelectorAll("[data-export-player-name]").forEach(d=>{d.textContent=d.dataset.exportPlayerName||d.textContent,d.style.width="100%",d.style.maxWidth="none",d.style.height="auto",d.style.whiteSpace="normal",d.style.overflow="visible",d.style.textOverflow="clip",d.style.overflowWrap="anywhere",d.style.flexShrink="0"}),(s=o.firstElementChild)==null||s.querySelectorAll("p").forEach(d=>{d.style.whiteSpace="nowrap",d.style.width="auto",d.style.maxWidth="none"});const i=Math.ceil(Math.max(t.getBoundingClientRect().width,t.scrollWidth,...Array.from(t.querySelectorAll("table")).map(d=>d.scrollWidth+2))),l=document.createElement("div");l.setAttribute("aria-hidden","true"),l.style.cssText="position:fixed;left:-100000px;top:0;pointer-events:none;",o.style.width=`${i}px`,o.style.minWidth=`${i}px`,o.style.maxWidth="none",o.style.height="auto",o.style.maxHeight="none",o.style.overflow="visible",o.style.margin="0",o.style.transform="none",l.append(o),document.body.append(l);try{await Promise.all(Array.from(o.querySelectorAll("img")).map(async N=>{const y=N.currentSrc||N.src;if(N.removeAttribute("srcset"),N.removeAttribute("sizes"),N.removeAttribute("crossorigin"),N.loading="eager",mn(y))N.src=await pn({currentSrc:y,nbaId:un(y),playerName:N.alt||"Player"});else if(!y.startsWith("data:")){const W=await fetch(y);if(!W.ok)throw new Error("Could not load an export image");const E=await W.blob();N.src=await new Promise((S,j)=>{const A=new FileReader;A.onload=()=>S(String(A.result)),A.onerror=j,A.readAsDataURL(E)})}await N.decode()}));const d=Math.ceil(Math.max(o.scrollHeight,o.getBoundingClientRect().height)),c=Math.min(2,Math.sqrt(8e6/(i*d)),8192/Math.max(i,d)),n=getComputedStyle(t).backgroundColor;return await r(o,{width:i,height:d,pixelRatio:c,backgroundColor:n==="rgba(0, 0, 0, 0)"?"#1b212c":n,preferredFontFormat:"woff2",cacheBust:!1})}finally{l.remove()}}function Xo({tableRef:t,disabled:r=!1}){var ie;const{toast:o}=Fr(),[f,m]=_.useState(!1),[i,l]=_.useState(!1),[s,d]=_.useState(!1),[c,n]=_.useState(!1),[N,y]=_.useState(null),[W,E]=_.useState(null);_.useEffect(()=>{typeof window<"u"&&(d(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),n("share"in navigator&&"canShare"in navigator))},[]);const S=async()=>{if(!t.current)return o({title:"Export failed",description:"Table element not found",variant:"destructive",duration:2e3}),null;l(!0);try{const $=await Qo(t.current),G=await(await fetch($)).blob();return E(new File([G],`wowy-table-${Date.now()}.png`,{type:"image/png"})),$}catch($){return console.error("Failed to generate image:",$),o({title:"Export failed",description:"Failed to generate image. Please try again.",variant:"destructive"}),null}finally{l(!1)}},j=$=>{const G=document.createElement("a");G.download=`wowy-table-${Date.now()}.png`,G.href=$,document.body.append(G),G.click(),G.remove()},A=async()=>{const $=await S();if($)try{j($),o({title:"Image downloaded!",description:"Your WOWY table has been saved as an image",duration:2e3}),m(!1)}catch(G){console.error("Failed to download:",G),o({title:"Download failed",description:"Please try again",variant:"destructive",duration:2e3})}},T=async()=>{const $=await S();if($)try{const M=await(await fetch($)).blob();await navigator.clipboard.write([new ClipboardItem({"image/png":M})]),o({title:"Image copied!",description:"Paste the table image anywhere",duration:2e3}),m(!1)}catch(G){console.error("Failed to copy to clipboard:",G),o({title:"Copy failed",description:"Your browser may not support copying images to clipboard",variant:"destructive",duration:2e3})}},p=async()=>{const $=await S();if($)try{if(s&&c){const M=await(await fetch($)).blob(),ge=`wowy-table-${new Date().getTime()}.png`,te=new File([M],ge,{type:"image/png"});if(navigator.canShare&&navigator.canShare({files:[te]}))try{await navigator.share({files:[te],title:"WOWY Table"}),o({title:"Shared",description:"Use 'Save to Photos' to save the image.",duration:2e3}),m(!1);return}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError"){m(!1);return}console.log("Web Share needs a fresh tap:",oe),y($),m(!1);return}}j($),m(!1)}catch(G){console.error("Failed to save to photos:",G),o({title:"Save failed",description:"Please try downloading the image instead",variant:"destructive",duration:2e3})}},F=async()=>{const $=await S();$&&(y($),m(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Na,{open:f,onOpenChange:m,children:[e.jsx(ja,{asChild:!0,children:e.jsxs(Qe,{variant:"outline",size:"sm",className:"gap-2","aria-label":"Export table as image",disabled:r||i,children:[e.jsx(qs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:i?"Exporting...":"Export"})]})}),e.jsxs(wa,{align:"end",className:"w-48",children:[s&&c&&e.jsxs(Mt,{onClick:p,className:"gap-2 cursor-pointer",children:[e.jsx(Hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Save to Photos"})]}),e.jsxs(Mt,{onClick:F,className:"gap-2 cursor-pointer",children:[e.jsx(Hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview PNG"})]}),e.jsxs(Mt,{onClick:A,className:"gap-2 cursor-pointer",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{children:"Download PNG"})]}),e.jsxs(Mt,{onClick:T,className:"gap-2 cursor-pointer",children:[e.jsx(Es,{className:"h-4 w-4"}),e.jsx("span",{children:"Copy to Clipboard"})]})]})]}),e.jsx(ct,{open:!!N,onOpenChange:$=>{$||y(null)},children:e.jsxs(ft,{className:"max-w-3xl max-h-[90dvh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsx(pt,{children:"WOWY image"}),e.jsx(Ct,{children:"Save or share this table image."})]}),N&&e.jsx("img",{src:N,alt:"WOWY table export preview",className:"max-h-[65dvh] w-full object-contain"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[W&&c&&((ie=navigator.canShare)==null?void 0:ie.call(navigator,{files:[W]}))&&e.jsx(Qe,{onClick:()=>{navigator.share({files:[W],title:"WOWY Table"}).catch($=>{$.name!=="AbortError"&&o({title:"Share failed",description:"Please try downloading the image instead",variant:"destructive"})})},children:"Share image"}),e.jsxs(Qe,{onClick:()=>{N&&j(N)},children:[e.jsx(ir,{className:"mr-2 h-4 w-4"}),"Download PNG"]})]})]})})]})}const Jo=[{value:"regular",label:"Regular Season"},{value:"playoffs",label:"Playoffs"},{value:"all",label:"All Games"}],Zo=({isOpen:t,onClose:r,currentSeasonType:o,onSeasonTypeChange:f})=>{const m=i=>{o!==i&&f(i),r()};return e.jsx(ct,{open:t,onOpenChange:i=>!i&&r(),children:e.jsxs(ft,{className:"sm:max-w-[380px] bg-card text-card-foreground border-border",children:[e.jsxs(mt,{children:[e.jsx(pt,{children:"Select Season Type"}),e.jsx(Ct,{className:"text-muted-foreground",children:"Choose the part of the season to analyze."})]}),e.jsx("div",{className:"grid gap-3 py-4",children:Jo.map(i=>e.jsx(Qe,{variant:o===i.value?"secondary":"outline",onClick:()=>
45m(i.value),className:h("w-full justify-center text-center py-3 text-sm font-medium",o===i.value?"bg-primary/15 text-primary border border-primary/50 hover:bg-primary/25":"hover:bg-accent"),children:i.label},i.value))})]})})},ei=[{value:"high",label:"Medium/High Leverage",description:"Exclude low-leverage possessions for more meaningful analysis."},{value:"all",label:"All Leverage",description:"Include all possessions including garbage time and low-leverage situations."}],ti=({isOpen:t,onClose:r,currentLeverage:o,onLeverageChange:f,league:m="nba"})=>{const i=ka(m),l=s=>{s==="high"&&!i||(o!==s&&f(s),r())};return e.jsx(ct,{open:t,onOpenChange:s=>!s&&r(),children:e.jsxs(ft,{className:"sm:max-w-md bg-card text-card-foreground border-border",children:[e.jsxs(mt,{children:[e.jsx(pt,{children:"Select Leverage Filter"}),e.jsx(Ct,{className:"text-muted-foreground",children:"Choose which possessions to include in the analysis."})]}),e.jsx("div",{className:"grid gap-3 py-4",children:ei.map(s=>{const d=s.value==="high"&&!i;return e.jsx(Qe,{variant:o===s.value?"secondary":"outline",disabled:d,onClick:()=>l(s.value),className:h("w-full h-auto justify-start text-left py-3 px-4",d&&"cursor-not-allowed opacity-50",o===s.value?"bg-primary/15 text-primary border border-primary/50 hover:bg-primary/25":"hover:bg-accent"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground/90 dark:text-muted-foreground/80 mt-1 text-wrap",children:d?"Not available â WNBA samples are too small for medium/high leverage filtering":s.description})]})},s.value)})})]})})},ri=["overview","offense","defense","expanded"],si=t=>t.charAt(0).toUpperCase()+t.slice(1),Xs=({isActive:t,isDisabled:r=!1,isMobile:o=!1})=>h("px-3 py-1.5 rounded-md font-medium border transition-colors duration-200",o?"text-[10px]":"text-xs",t?"border-primary/60 bg-primary/10 text-primary":r?"cursor-not-allowed border-border bg-background/20 text-muted-foreground opacity-50":"border-border bg-background/30 text-muted-foreground hover:bg-accent hover:text-foreground");function ai({mode:t,onModeChange:r}){return e.jsx("nav",{"aria-label":"WOWY pages",className:"flex items-center gap-1",children:["team","leaders"].map(o=>e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":t===o,className:h("h-8 whitespace-nowrap border-b-2 px-2 text-xs font-medium transition-colors",t===o?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"),children:o==="team"?"Team":"League Leaders"},o))})}function Js({mode:t,onModeChange:r,hideNav:o=!1,subtitle:f,description:m,bottomSpaceClass:i,meta:l,league:s="nba",children:d}){const c=s==="wnba";return e.jsxs(Oa,{hideNav:o,children:[l,e.jsxs("div",{className:h("container mx-auto px-2 sm:px-4 py-8 space-y-2",i),children:[e.jsxs("header",{className:"mx-auto max-w-xl pb-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:[e.jsx(js,{className:h("h-5 w-5",c?"text-pink-400":"text-primary")}),c?"WNBA WOWY Lineups":"WOWY Lineups"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ai,{mode:t,onModeChange:r}),e.jsx(Jn,{triggerMode:"icon",className:"h-7 w-7 rounded-md border border-border bg-transparent text-sm text-muted-foreground shadow-none hover:bg-accent"})]})]}),f&&e.jsx("p",{className:"mt-2 hidden text-xs text-muted-foreground sm:block",children:f}),e.jsx("p",{className:"sr-only",children:m})]}),e.jsx(La,{league:s,children:e.jsx("div",{className:"min-h-[640px] sm:min-h-[620px]",children:d})}),e.jsx(Xn,{league:s,mode:t})]})]})}function Zs({league:t="nba"}){const r=Nr(),o=t==="wnba"?"/wnba/wowy":"/wowy",f=`${o}/leaders`,m=Or(t),{state:i,actions:l}=An({league:t,basePath:o}),[s,d]=_.useState("overview"),[c,n]=_.useState("raw"),[N,y]=_.useState("efficiency"),[W,E]=_.useState("efficiency"),[S,j]=_.useState("onoff"),[A,T]=_.useState(0),[p,F]=_.useState(!1),[ie,$]=_.useState(!1),[G,M]=_.useState(!1),[ge,te]=_.useState(()=>window.innerWidth<640),[oe,ce]=_.useState(!1),[K,b]=_.useState(!1),[X,V]=_.useState(!1),[me,ve]=_.useState(()=>typeof window<"u"&&localStorage.getItem("wowy-theme")||"dark"),z=_.useRef(null),Ce=_.useRef(""),le=_.useRef(null);_.useEffect(()=>{const D=()=>te(window.innerWidth<640);return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),_.useEffect(()=>{const D=g=>{const O=g.target;if(!(O&&(O.isContentEditable||O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.tagName==="SELECT"))&&(g.code==="Digit3"||g.code==="Numpad3"||g.key==="3")){if(i.isTeamSelectorOpen){l.setIsTeamSelectorOpen(!1),T(R=>R+1);return}T(R=>R+1)}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[l,i.isTeamSelectorOpen]),_.useEffect(()=>{localStorage.setItem("wowy-theme",me)},[me]),_.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]);const je=D=>{const g=i.selectedPlayers.length;return D==="wowy"?!1:D==="2man"&&g>2||D==="3man"&&g>3||D==="4man"&&g>4},Y=D=>{if(je(D))return;if(D==="wowy"&&i.lineupMode!=="wowy"&&i.selectedPlayers.length===0){l.setLineupMode("wowy"),l.setIsPanelOpen(!0);return}l.setLineupMode(D);const g=`${D}-${Date.now()}`;Ce.current=g,z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{Ce.current===g&&i.selectedTeam&&l.fetchCombinations(i.defLuckValue,i.offLuckValue,D).catch(O=>{console.error(`[WowyPage] Error fetching combinations for ${D} mode:`,O)})},300)},xe=i.lineupMode==="wowy"&&i.selectedPlayers.length===0,pe=(s==="offense"||s==="defense")&&(!xe||S==="onoff"),Fe=s==="offense"?N:W,{setIsPanelOpen:Oe,setIsTeamSelectorOpen:k}=l,H=_.useCallback(()=>{Oe(!i.isPanelOpen)},[Oe,i.isPanelOpen]),_e=_.useCallback(()=>{k(!0),Oe(!1)},[Oe,k]),J=_.useCallback(()=>{T(D=>D+1)},[]);return e.jsxs(Js,{mode:"team",onModeChange:D=>{D==="leaders"&&r(f)},hideNav:i.isTeamSelectorOpen,subtitle:i.selectedTeam?`${m[i.selectedTeam]||i.selectedTeam} ${t.toUpperCase()} lineup plus minus stats`:void 0,description:"Analyze how players perform together and apart with advanced lineup statistics",bottomSpaceClass:"mb-[400px]",meta:e.jsx(Ks,{selectedTeam:i.selectedTeam,selectedPlayers:i.selectedPlayers,startYear:i.startYear,endYear:i.endYear,seasonType:i.seasonType,leverageFilter:i.leverageFilter,lineupMode:i.lineupMode,league:t}),league:t,children:[e.jsx("div",{className:"max-w-xl mx-auto",children:e.jsx(Cs,{className:"mb-2",onPlayersOpen:()=>{l.setIsTeamSelectorOpen(!1),l.setIsPanelOpen(!0)},playerCount:i.selectedPlayers.length,lineupControls:i.selectedTeam?e.jsx("div",{role:"group","aria-label":"Lineup mode",className:"flex items-center gap-0.5",children:["wowy","2man","3man","4man","5man"].map(D=>{const g=je(D);return e.jsx("button",{onClick:()=>Y(D),className:Xs({isActive:i.lineupMode===D,isDisabled:g,isMobile:ge}),disabled:g,"aria-pressed":i.lineupMode===D,"aria-label":`Show ${ur(t,D)} lineups${g?" (disabled)":""}`,children:ur(t,D)},D)})}
45):null,startYear:i.startYear,endYear:i.endYear,onYearRangeChange:l.setYearRange,selectedTeam:i.selectedTeam,onTeamSelectorOpen:()=>{l.setIsTeamSelectorOpen(!0),l.setIsPanelOpen(!1)},leverageFilter:i.leverageFilter,onLeverageFilterChange:()=>l.setLeverageFilter(i.leverageFilter==="high"?"all":"high"),seasonType:i.seasonType,onSeasonTypeChange:l.setSeasonType,isTeamSelectorOpen:i.isTeamSelectorOpen,onPanelOpen:()=>{l.setAllowDataFetch(!1),M(!0)},onPanelClose:()=>{l.setAllowDataFetch(!0),M(!1)},yearSelectorToggleSignal:A,league:t})}),e.jsx(wr,{mode:"wait",children:i.isTeamSelectorOpen&&e.jsx(za,{isOpen:i.isTeamSelectorOpen,onClose:()=>l.setIsTeamSelectorOpen(!1),onTeamSelect:l.handleTeamSelect,selectedTeam:i.selectedTeam,onLeagueLeadersSelect:()=>r(f),onLeagueSwitch:void 0,league:t},"team-selector")}),i.error&&e.jsx("div",{className:"text-center text-destructive mb-4",children:i.error}),i.selectedTeam?e.jsxs(e.Fragment,{children:[e.jsx(Fa,{children:e.jsxs("div",{className:"max-w-xl mx-auto border-b border-border mt-3 mb-2 pb-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:"flex items-center gap-0.5 sm:gap-1",role:"tablist","aria-label":"View options",children:ri.map(D=>e.jsxs("button",{role:"tab","aria-selected":s===D,onClick:()=>d(D),className:h("relative h-7 px-1.5 sm:h-8 sm:px-2 text-xs transition-colors bg-transparent pb-1",s===D?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx("span",{className:"text-[13px]",children:D==="expanded"&&ge?"Exp":si(D)}),s===D&&e.jsx(Xe.div,{layoutId:"wowy-view-underline",className:"absolute bottom-0 left-0 right-0 h-[2px] bg-secondary rounded-full",transition:{type:"spring",stiffness:500,damping:30}})]},D))}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("button",{type:"button",onClick:()=>b(!K),className:h("h-8 px-2 rounded-md text-[11px] sm:text-xs font-semibold transition-all duration-200",K?"bg-primary/20 text-primary border border-primary/40":"text-foreground border border-border hover:bg-accent"),"aria-pressed":K,"aria-label":"Toggle padding adjustment",children:"Pad"}),e.jsxs(Pa,{children:[e.jsx(Ca,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":"Luck adjustments",className:h("h-8 w-8 sm:w-auto sm:px-2 flex items-center justify-center gap-1.5 rounded-md border text-xs transition-colors",i.offLuckValue||i.defLuckValue||X?"border-primary/50 bg-primary/15 text-primary":"border-border text-foreground hover:bg-accent"),children:[e.jsx("span",{className:"hidden sm:inline",children:"Luck"}),e.jsx(gn,{className:"h-4 w-4"})]})}),e.jsxs(Sa,{align:"end",className:"w-[340px] max-w-[calc(100vw-24px)] p-3 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Lineup adjustments"}),e.jsx("button",{type:"button",className:"text-xs text-primary",onClick:()=>{l.setOffLuckValue(0),l.setDefLuckValue(0),V(!1)},children:"Reset"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Qa,{value:i.offLuckValue,onValueChange:l.setOffLuckValue}),e.jsx(Xa,{value:i.defLuckValue,onValueChange:l.setDefLuckValue})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>V(!X),className:h("h-7 sm:h-8 px-2.5 rounded-md text-[11px] sm:text-xs font-semibold transition-all duration-200",X?"bg-primary/20 text-primary border border-primary/40":"bg-accent text-foreground border border-border hover:bg-accent/80"),"aria-pressed":X,"aria-label":"Toggle expected lineup metrics",children:"X"}),e.jsx("button",{type:"button",onClick:()=>ce(!0),className:"h-7 w-7 sm:h-8 sm:w-8 rounded-full border border-border text-sm font-semibold text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center","aria-label":"Pad and X help",children:"?"})]})]})]}),e.jsx(Xo,{tableRef:le,disabled:i.isLoading||i.isRefreshing})]})]}),pe&&e.jsx("div",{className:"flex items-center mt-1",children:["efficiency","location"].map(D=>e.jsxs("button",{type:"button",onClick:()=>{y(D),E(D)},className:h("relative h-7 px-1.5 sm:h-8 sm:px-2 text-xs transition-colors bg-transparent pb-1",Fe===D?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx("span",{className:"text-[13px]",children:D.charAt(0).toUpperCase()+D.slice(1)}),Fe===D&&e.jsx(Xe.div,{layoutId:"wowy-detail-underline",className:"absolute bottom-0 left-0 right-0 h-[2px] bg-primary rounded-full",transition:{type:"spring",stiffness:500,damping:30}})]},D))})]})}),e.jsxs("div",{className:h("mx-auto flex max-w-xl items-center justify-between gap-2 px-1 text-[11px] text-muted-foreground",i.offLuckValue||i.defLuckValue||X||i.isRefreshing?"min-h-5 mb-1":"h-0 overflow-hidden"),"aria-live":"polite",children:[e.jsx("span",{children:[i.offLuckValue?`Off 3P ${Math.round(i.offLuckValue)}%`:"",i.defLuckValue?`Def 3P ${Math.round(i.defLuckValue)}
45%`:"",X?"X":""].filter(Boolean).join(" · ")}),e.jsx("span",{children:i.isRefreshing?"Updatingâ¦":""})]}),e.jsx("div",{className:"bg-inherit rounded-lg min-h-[420px]",children:xe?e.jsx(uo,{ref:le,selectedTeam:i.selectedTeam,seasonType:i.seasonType,startYear:i.startYear,endYear:i.endYear,leverageFilter:i.leverageFilter,lineupMode:i.lineupMode,activeView:s,wowyStats:i.wowyStats,availablePlayers:i.availablePlayers,timedecayRapmRows:i.timedecayRapm,defLuckAdjustment:i.defLuckValue,offLuckAdjustment:i.offLuckValue,isLoading:i.isLoading,isTimedecayRapmLoading:i.isTimedecayRapmLoading,onPlayerSelect:D=>{l.setSelectedPlayers([D]),l.setIsPanelOpen(!1)},theme:me,offenseDetailMode:N,defenseDetailMode:W,onTableModeChange:j}):e.jsx(Fo,{ref:le,combinations:i.combinations,isLoading:i.isLoading,seasonType:i.seasonType,startYear:i.startYear,endYear:i.endYear,activeView:s,setActiveView:d,dataView:c,setDataView:n,leverageFilter:i.leverageFilter,stats:i.wowyStats,availablePlayers:i.availablePlayers,allYearsPlayers:i.allYearsPlayers,playerMetricsByYear:i.playerMetricsByYear,defLuckAdjustment:i.defLuckValue,offLuckAdjustment:i.offLuckValue,selectedTeam:i.selectedTeam,lineupMode:i.lineupMode,theme:me,offenseDetailMode:N,defenseDetailMode:W,isPaddingEnabled:K,showExpectedMetrics:X})}),i.lineupMode!=="wowy"&&!i.isLoading&&i.combinations.length>0&&i.allNManCombinations&&i.displayedNManCount<i.allNManCombinations.length&&e.jsx("div",{className:"mt-6 text-center",children:e.jsx(Qe,{variant:"outline",onClick:l.showMoreNManLineups,children:"Show 5 More Lineups"})})]}):e.jsx("div",{className:"text-center text-muted-foreground mt-8",children:"Select a team to begin"}),e.jsx(Va,{isOpen:i.isPanelOpen,onToggle:H,selectedPlayers:i.selectedPlayers,onPlayerSelect:l.handlePlayerClick,availablePlayers:i.availablePlayers,allYearsPlayers:i.allYearsPlayers,selectedTeam:i.selectedTeam,onTeamSelectorOpen:_e,pageContext:"wowy",onOpenYearDialog:J,onOpenSeasonTypeDialog:()=>F(!0),onOpenLeverageDialog:()=>$(!0),isYearSelectorSubPanelOpen:G,startYear:i.startYear,endYear:i.endYear,currentSeasonType:i.seasonType,currentLeverageFilter:i.leverageFilter,league:t}),e.jsx(Zo,{isOpen:p,onClose:()=>F(!1),currentSeasonType:i.seasonType,onSeasonTypeChange:l.setSeasonType}),e.jsx(ti,{isOpen:ie,onClose:()=>$(!1),currentLeverage:i.leverageFilter,onLeverageChange:l.setLeverageFilter,league:t}),e.jsx(ct,{open:oe,onOpenChange:ce,children:e.jsxs(ft,{className:"sm:max-w-md bg-card text-card-foreground border-border",children:[e.jsxs(mt,{children:[e.jsx(pt,{children:"What do Pad and X do?"}),e.jsx(Ct,{children:"Pad stabilizes noisy lineup ratings. X shows expected lineup impact based on DARKO predictive player impact ratings."})]}),e.jsxs("div",{className:"space-y-3 text-sm text-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-semibold",children:"X (Expected)"}),e.jsx("p",{className:"text-muted-foreground",children:"X is expected lineup impact based on DARKO predictive player impact ratings."}),e.jsxs("p",{className:"text-muted-foreground",children:["When enabled, it adds muted expected values above"," ",e.jsx("span",{className:"text-foreground font-medium",children:"OFF"}),","," ",e.jsx("span",{className:"text-foreground font-medium",children:"DEF"}),", and"," ",e.jsx("span",{className:"text-foreground font-medium",children:"NET"})," in Overview and Expanded views."]})]}),e.jsx("div",{className:"border-t border-border"}),e.jsx("p",{className:"font-semibold",children:"Pad (Padding)"}),e.jsxs("p",{className:"text-muted-foreground",children:["A lineup that plays 50 possessions and posts a +20 NET rating probably isn't actually that good â it's a tiny sample dominated by randomness. Padded ratings regress toward the league average, and"," ",e.jsx("span",{className:"text-foreground font-medium",children:"on average, they will outperform raw ratings at predicting how a lineup will play in the future."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-semibold",children:"How it works"}),e.jsx("p",{className:"text-muted-foreground",children:"We add hypothetical possessions of league-average performance to the lineup's actual results, then recalculate the rating. This pulls extreme values toward the middle â more for small samples, less for large ones. The result is a rating that better reflects true talent rather than noise."}),e.jsxs("p",{className:"text-muted-foreground",children:["Only ",e.jsx("span",{className:"text-foreground font-medium",children:"OFF"}),","," ",e.jsx("span",{className:"text-foreground font-medium",children:"DEF"}),", and"," ",e.jsx("span",{className:"text-foreground font-medium",children:"NET"})," are padded."]}),e.jsxs("p",{className:"text-muted-foreground",children:["A ",e.jsx("span",{className:"text-primary font-bold",children:"P"})," next to a column label means that column is currently padded."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-semibold",children:"The values"}),e.jsxs("div",{className:"text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-foreground font-medium",children:"Offense:"})," +550 possessions of league-average OffRtg"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-foreground font-medium",children:"Defense:"})," +850 possessions of league-average DefRtg"]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Defense requires more padding because defensive rating is noisier and takes longer to stabilize."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-semibold",children:"When to use it"}),e.jsx("p",{className:"text-muted-foreground",children:"Turn padding on when comparing lineups â especially ones with low minutes. The less data a lineup has, the more padding corrects for noise. Lineups with large samples will barely change."})]}
45),e.jsxs("p",{className:"text-xs text-muted-foreground/70 pt-1 border-t border-border",children:["Based on the stabilization rate / padding approach described by"," ",e.jsx("a",{href:"https://kmedved.com/2020/08/06/nba-stabilization-rates-and-the-padding-approach/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Kostya Medvedovsky"}),"."]})]})]})})]})}function ea({league:t="nba"}){const r=Nr(),o=t==="wnba"?"/wnba/wowy":"/wowy",{state:f,actions:m}=Kn(t);return _.useEffect(()=>(document.documentElement.classList.add("scrollbar-hide"),document.body.classList.add("scrollbar-hide"),()=>{document.documentElement.classList.remove("scrollbar-hide"),document.body.classList.remove("scrollbar-hide")}),[]),e.jsxs(Js,{mode:"leaders",onModeChange:i=>{i==="team"&&r(o)},subtitle:`${t.toUpperCase()} league-wide padded ${As(t)} lineup leaderboard`,description:"Compare the best padded lineups from across the league and drill directly into team WOWY pages.",bottomSpaceClass:"mb-24",meta:e.jsx(Ks,{selectedTeam:null,selectedPlayers:[],startYear:f.selectedYear,endYear:f.selectedYear,seasonType:f.seasonType,leverageFilter:f.leverageFilter,lineupMode:f.lineupMode,isLeadersMode:!0,league:t}),league:t,children:[e.jsxs("div",{className:"max-w-xl mx-auto",children:[e.jsx(Cs,{className:"mb-3",startYear:f.selectedYear,endYear:f.selectedYear,onYearRangeChange:i=>m.setSelectedYear(i),selectedTeam:null,onTeamSelectorOpen:()=>{},leverageFilter:f.leverageFilter,onLeverageFilterChange:()=>m.setLeverageFilter(f.leverageFilter==="high"?"all":"high"),seasonType:f.seasonType,onSeasonTypeChange:m.setSeasonType,showTeamButton:!1,singleYearMode:!0,league:t}),e.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap mb-4",children:["2man","3man","4man","5man"].map(i=>e.jsx("button",{type:"button",onClick:()=>m.setLineupMode(i),className:Xs({isActive:f.lineupMode===i}),"aria-pressed":f.lineupMode===i,children:ur(t,i)},i))})]}),f.error&&e.jsx("div",{className:"text-center text-destructive mb-4",children:f.error}),e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsx(Vo,{leaders:f.leaders,isLoading:f.isLoading,selectedYear:f.selectedYear,seasonType:f.seasonType,leverageFilter:f.leverageFilter,lineupMode:f.lineupMode})})]})}function tl(){return jr().pathname==="/wowy/leaders"?e.jsx(ea,{}):e.jsx(Zs,{})}function rl(){return jr().pathname==="/wnba/wowy/leaders"?e.jsx(ea,{league:"wnba"}):e.jsx(Zs,{league:"wnba"})}export{rl as WnbaWowyPage,tl 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.