1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/athleteService-D_MLebI7.js","assets/index-CF0J1Hw3.js","assets/mui-CoQp20c8.js","assets/react-i37NAuIb.js","assets/charts-CEYd91Cd.js","assets/stream-m8mhgDqQ.js","assets/firebase-CqKLq4KR.js","assets/index-BQ144ltB.css","assets/bulkDeleteService-CO6G3l43.js"])))=>i.map(i=>d[i]); 2import{D as t,K as tt,u as oo,G as Xo,C as Vo,ad as Yo,b as Jo,d as M,Q as Je,X as Wt,ae as Zo,af as er,J as Ot,ag as tr,ah as Lt,ai as Mt,aj as Y,P as D,a6 as ge,a8 as Ze,ak as fe,al as or,a1 as q,E as et,am as rr}from"./index-CF0J1Hw3.js";import{j as e,a2 as nr,B as c,I as H,T as x,a3 as sr,aj as ro,g as no,ak as so,al as io,am as ae,an as l,ao as Oe,ap as ao,A as ot,d as ke,G as ir,L as B,Q as ar,e as Dt,f as Fe,z as rt,H as lr,aq as cr,ar as Bt,C as dr}from"./mui-CoQp20c8.js";import{r as a,d as xr,k as mr,f as ur}from"./react-i37NAuIb.js";import{S as hr,a as pr,A as Ht}from"./card_view-DFSuPS-E.js";import{S as gr}from"./file-export-Big0M0vu.js";import{P as Pe}from"./index-BWH6siT0.js";import"./index-efo9okeK.js";import{u as fr,a as br}from"./useTeams-B_9MHPG-.js";import{u as Gt}from"./useMutation-CL-wQGOp.js";import{u as Ut}from"./useDebounce-DURvHNuq.js";import{g as Sr}from"./roleScopeConstants-BXcYtezH.js";import{T as $t,a as We,C as Kt,b as yr}from"./CreateTeamForm-BVG86FIF.js";import{u as vr}from"./useTeamChoices-D7QdG7rK.js";import{updateAthleteProfile as jr,deleteTeamMembership as Ir}from"./athleteService-D_MLebI7.js";import{T as wr}from"./TeamsGrid-BkB-6eJW.js";import{u as Cr}from"./useTeamMemberships-BjL7N-on.js";import{u as Ar,a as Tr,I as _r}from"./useAthleteProfileData-B3NGS-4q.js";import{A as Er}from"./AthleteCard-CnF9E23M.js";import{S as be}from"./StatusDialog-D-TCUTmI.js";import{C as Qt,p as Rr,v as Nr,c as zr,B as kr}from"./bulkInviteService-CF26l1bp.js";import{B as qt}from"./BaseButton-BZb9p-7c.js";import{g as nt,r as Fr}from"./avatarUtils--lxbQhCu.js";import{f as lo,n as Pr}from"./dateUtils-DcO8AqlJ.js";import{I as co}from"./IconArrowLeft-B4VaEPm4.js";import"./ReactCrop-dGqCplZ5.js";import{A as Wr}from"./ActionMenu-BKjPc8ky.js";import{A as Or,C as Lr,a as Mr,g as Xt}from"./athletesConstants-BTE4hecU.js";import{u as Dr}from"./useRoles-BCM2U70u.js";import{g as Br}from"./useFocusFirstInvalid-CUvFaLjG.js";import{t as Vt}from"./inputMasking-eNngIeZd.js";import{I as Hr}from"./IconEdit-Bsq0lnPY.js";import{I as Gr}from"./IconUserMinus-CxHuSIPb.js";import{I as Yt}from"./IconTrash-CWmozDpp.js";import{I as Jt}from"./IconPlus-RLAJuko7.js";import{I as Ur}from"./IconDotsVertical-Cx3oAEgn.js";import"./charts-CEYd91Cd.js";import"./stream-m8mhgDqQ.js";import"./firebase-CqKLq4KR.js";import"./useOrganizations-BTc7rf-v.js";import"./bulkDeleteService-CO6G3l43.js";import"./textNormalization-BlSi0CQw.js";import"./useCoachesStaff-D8EdDtej.js";import"./fieldMaxLengths-BrD61_5O.js";import"./ImageCropDialog-B4TPyc-m.js";import"./IconPhotoUp-BKUS90_u.js";import"./index-BGcGNfFx.js";import"./useOrganizationAthletes-DfujhYrY.js";import"./IconDownload-B70aSE_C.js";import"./uiConstants-mLZpv7pU.js";import"./useAccountMembers-5lxDUhGm.js";import"./useOrganizationCoaches-9PuXPVT6.js";import"./InviteStaffDialog-B4LOWZlB.js";import"./IconChevronRight-qrokcIUi.js";import"./CommonSvgIcon-CiNrNPpq.js";import"./emptyStateMessages-B-YV3RMm.js";import"./searchUtils-CfmYnNZd.js";import"./goalsService-CCsVCX1k.js";import"./shotsService-D9Hf0J1X.js";import"./layoutBackgroundUtils-BL6cCkJX.js";import"./LabelValueRow-DNPoskgN.js";import"./coachFormConstants-BlhH6jej.js";import"./IconCheck-CR0gkTHR.js";import"./DatePickerInput-7VZXLZO0.js";const Zt=({open:d,onClose:b,onBack:g,onUpload:T,file:y,csvData:m,contextTeamDisplayName:s})=>{const[p,_]=a.useState(new Set);a.useEffect(()=>{if(d){const i=m.map((C,w)=>w);_(new Set(i))}},[d,m]);const R=i=>{i.target.checked?_(new Set(m.map((C,w)=>w))):_(new Set)},I=i=>{const C=new Set(p);C.has(i)?C.delete(i):C.add(i),_(C)},P=m.length>0&&p.size===m.length,W=p.size>0&&p.size<m.length,G=()=>{const i=m.filter((C,w)=>p.has(w));T(i)},v=()=>{_(new Set),b()};return e.jsxs(nr,{open:d,onClose:(i,C)=>{C!=="backdropClick"&&v()},maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{borderRadius:t.card.borderRadius.default,boxShadow:t.shadow.lg,maxWidth:"1200px",maxHeight:"90vh",overflow:"hidden",display:"flex",flexDirection:"column"}},children:[e.jsxs(c,{sx:{px:3,pt:3,pb:2,position:"relative",borderBottom:`1px solid ${t.border.default}`},children:[e.jsx(H,{onClick:v,size:"small",sx:{position:"absolute",top:16,right:16,color:"text.secondary",bgcolor:t.background.hover,"&:hover":{bgcolor:t.background.hoverDark}},children:e.jsx(tt,{size:18})}),e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[e.jsx(H,{onClick:g,size:"small",sx:{color:t.gray[700],"&:hover":{bgcolor:t.background.hover}},children:e.jsx(co,{size:20})}),e.jsx(x,{variant:"h5",sx:{fontFamily:"Inter",fontWeight:600,fontSize:{xs:"20px",sm:"24px"}},children:(y==null?void 0:y.name)||"CSV Review"})]})]}),e.jsx(sr,{sx:{px:0,pb:0,flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}
2,children:e.jsx(ro,{component:no,sx:{boxShadow:"none",border:"none",flex:1,overflow:"auto","& .MuiTableHead-root":{position:"sticky",top:0,zIndex:10}},children:e.jsxs(so,{stickyHeader:!0,sx:{minWidth:1100},children:[e.jsx(io,{children:e.jsxs(ae,{sx:{bgcolor:t.background.tableHeader},children:[e.jsxs(l,{padding:"checkbox",sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5},minWidth:160},children:[e.jsx(Oe,{checked:P,indeterminate:W,onChange:R,sx:{color:t.text.secondaryLight,"&.Mui-checked":{color:t.organization[500]},"&.MuiCheckbox-indeterminate":{color:t.organization[500]}}}),"Athlete Name"]}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5},minWidth:200},children:"Email"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Mobile Number"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Preferred Name"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Jersey Number"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"USA Hockey Number"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Age Group"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"League"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Country"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Gender"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Date of Birth"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Guardian Name"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Guardian Number"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5},minWidth:200},children:"Guardian Email"}),e.jsx(l,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,bgcolor:t.background.tableHeader,whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:"Team Name"})]})}),e.jsx(ao,{children:m.length===0?e.jsx(ae,{children:e.jsx(l,{colSpan:15,align:"center",sx:{py:4},children:e.jsx(x,{color:"text.secondary",sx:{fontFamily:"Inter"},children:"No data is available yet."})})}):m.map((i,C)=>{const w=i.name||`${i.firstName||""} ${i.lastName||""}`.trim()||"";return e.jsxs(ae,{hover:!0,sx:{"&:hover":{bgcolor:t.gradient.blueFaded,"& .MuiTypography-root":{color:`${t.button.primary} !important`}}},children:[e.jsx(l,{padding:"checkbox",sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[e.jsx(Oe,{checked:p.has(C),onChange:()=>I(C),sx:{color:t.text.secondaryLight,"&.Mui-checked":{color:t.organization[500]}}}),e.jsx(ot,{sx:{width:32,height:32,borderRadius:t.card.borderRadius.default,bgcolor:t.button.primary,color:t.base.white,fontSize:"12px",fontWeight:600,flexShrink:0},children:nt(w)}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0,flex:1,color:"text.primary"},children:w||"-"})]})}),e.jsx(l,{sx:{minWidth:200,px:{xs:1,sm:1.5},verticalAlign:"top"},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary",whiteSpace:"normal",wordBreak:"break-all",overflowWrap:"break-word"},children:i.email||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.phoneNumber||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.preferredName||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.playerNumber?`#${i.playerNumber.padStart(2,"0")}`:"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.usaHockeyNumber||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.ageGroup||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.league||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.country||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.gender||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.dateOfBirth?lo(i.dateOfBirth):"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.guardianName||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:i.guardianNumber||"-"})}),e.jsx(l,{sx:{minWidth:200,px:{xs:1,sm:1.5},verticalAlign:"top"},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary",whiteSpace:"normal",wordBreak:"break-all",overflowWrap:"break-word"},children:i.guardianEmail||"-"})}),e.jsx(l,{sx:{whiteSpace:"nowrap",px:{xs:1,sm:1.5}},children:e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},color:"text.primary"},children:(i.teamName||"").trim()||(s||"").trim()||"-"})})]},C)})})]})})}),e.jsxs(c,{sx:{px:3,pb:3,pt:2,borderTop:`1px solid ${t.border.default}`,display:"flex",justifyContent:"flex-end",gap:1.5},children:[e.jsx(qt,{variant:"cancel",size:"small",onClick:v,sx:{minWidth:"120px",fontWeight:500},children:"Cancel"}),e.jsx(qt,{variant:"primary",size:"small",onClick:G,disabled:p.size===0,sx:{minWidth:"120px",fontWeight:500,bgcolor:t.button.primary,color:t.base.white,"&:hover":{bgcolor:t.button.primaryHover},"&:disabled":{bgcolor:t.gray[400],color:t.base.white}},children:"Upload"})]})]})},$r=()=>{const{accountSlug:d}=xr(),{organizationAccountId:b,userData:g}=oo();return Xo(),a.useMemo(()=>{var m;
2if(!d||!(g!=null&&g.memberships))return b;const y=g.memberships.find(s=>{var p;return((p=s.account)==null?void 0:p.slug)===d});return((m=y==null?void 0:y.account)==null?void 0:m.id)??b},[d,g==null?void 0:g.memberships,b])},Kr=d=>{const{team:b,teamLogo:g}=d,T=b.id||null,{data:y}=Ar(T),m=y==null?void 0:y.current_season,s=m&&Number.parseInt(m.split("-")[0],10)||void 0,{data:p}=Tr(T,m,s),_=a.useMemo(()=>({...b,season:m||void 0,playerStats:p?{gamesPlayed:p.gp??0,goals:p.g??0,assists:p.a??0,points:p.p??0}:void 0}),[b,m,p]);return e.jsx(Er,{...d,team:_,teamLogo:g})};function eo({title:d,cellSx:b,children:g}){const T=a.useRef(null),[y,m]=a.useState(!1);return a.useEffect(()=>{const s=T.current;if(!s)return;const p=()=>m(s.scrollWidth>s.clientWidth);p();const _=new ResizeObserver(p);return _.observe(s),()=>_.disconnect()},[g]),e.jsx(rt,{title:y?d:"",placement:"top",enterDelay:300,children:e.jsx(l,{sx:{overflow:"hidden",minWidth:0,verticalAlign:"middle",...b},children:e.jsx(c,{ref:T,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"Inter",fontSize:{xs:"13px",sm:"14px"},lineHeight:1.5,minHeight:"1.5em",minWidth:0,py:"3px",boxSizing:"border-box"},children:g})})})}const to=(d,b=[])=>{const g=d.head_coaches??[],T=g.length>0?g[0].name:d.headCoachName||d.headCoach||d.head_coach||null,y=d.athletesCount??d.athletes_count??0,m=d.ageGroup??d.age_group??null;let s="";if(m!=null&&typeof m=="number")if(b&&b.length>0){const i=b.find(C=>C.value===m);s=(i==null?void 0:i.label)||`Age Group ${m}`}else s=`Age Group ${m}`;const p=d.logo||d.logo||null;let _;p&&(typeof p=="string"&&p.startsWith("data:image/")||typeof p=="string"&&p.length>0)&&(_=p);const R=d.leagueName||d.league_name||null,I=d.leagueAbbreviation||d.league_abbreviation||null,P=d.groupTeam
2Logo??d.group_team_logo??null,W=d.teamCode||d.slug||null,G=(d.name??"").trim(),v=W&&String(W).trim()!==G?String(W).trim():String(d.id);return{id:String(d.id),name:d.name,logo:_,groupTeamLogo:P&&typeof P=="string"?P:null,ageGroup:s||"N/A",headCoach:T?String(T):"",headCoaches:g,athletesCount:typeof y=="number"?y:0,teamId:v,leagueName:R?String(R):null,leagueAbbreviation:I?String(I):null,status:d.isActive?"active":"inactive"}},ns=()=>{var kt;const{isLayout:d}=Vo(),b=mr(),g=Yo(),[T,y]=ur(),m=T.get("action"),s=T.get("teamId"),p=T.get("highlightKey"),_=T.get("highlightValue"),R=p==="team_id"?_:null,{accountSlug:I,isHeadCoach:P,isAssistantCoach:W,activeMembership:G}=oo(),v=$r(),{showToast:i}=Jo(),{data:C=[]}=Dr(),[w,xo]=a.useState({status:"all",search:"",ageGroup:null,skillLevel:null,season:null,leagueId:null,headCoachId:null,ordering:"name"}),Le=(r,o)=>{xo(n=>({...n,[r]:o}))},{data:le=[]}=vr(),[Me,mo]=a.useState(!1),st=a.useRef(null),[De,uo]=a.useState("newest"),[J,ho]=a.useState(""),[Se,ye]=a.useState(0),[X,po]=a.useState($t.DEFAULT_ROWS_PER_PAGE),[ve,Be]=a.useState(""),[k,it]=a.useState("cards"),[He,Ge]=a.useState(0),[V,go]=a.use
2State(10),je=Ut(w.search??""),at=Ut(ve),fo=a.useMemo(()=>({...w,search:je||void 0}),[w,je]);a.useEffect(()=>{ye(0)},[je,w.status,J]);const bo=Sr({isHeadCoach:P,isAssistantCoach:W}),So=String(je||"").trim().length>0,yo=R!=null&&String(R).trim()!=="",Z=So||yo,vo=Z?1:Se+1,jo=Z?500:X,{data:ee,isLoading:Io,isFetching:lt}=fr(v??null,{...fo,assignedOnly:!0,roleScope:bo,activeMembershipId:(G==null?void 0:G.id)??null,page:vo,pageSize:jo,ageGroup:J===""?void 0:J}),Ie=(ee==null?void 0:ee.teams)??[],Ue=ee==null?void 0:ee.pagination,wo=br(v??null);a.useEffect(()=>{Ie.length>0&&!Me&&mo(!0)},[Ie,Me]),a.useEffect(()=>{W&&(m==="create"||m==="edit"&&s)&&b(M(I??"",D.TEAMS))},[W,m,s,b,I]);const[ct,dt]=a.useState(null),[U,we]=a.useState(new Set),[xt,$e]=a.useState(!1),[mt,ce]=a.useState(!1),[ut,Ke]=a.useState(!1),[Ce,ht]=a.useState(null),[pt,gt]=a.useState([]),[ft,Ae]=a.useState(!1),[A,Qe]=a.useState(null),[Te,_e]=a.useState(null),[Co,bt]=a.useState(!1),[St,yt]=a.useState(null),[E,vt]=a.useState(null),[jt,te]=a.useState(!1),[$,oe]=a.useState(null),[It,re]=a.useState(!1),[K,ne]=a.useState(null),[Ao,qe]=a.useState(!1),[de,Xe]=a.useState(null),To=()=>{Ae(!1),_e(null),Qe(null)},Ve=()=>{Ke(!1),ht(null),gt([])},z=a.useMemo(()=>{const o=[...Ie??[]].sort((n,u)=>{const f=new Date(n.createdAt||0).getTime(),j=new Date(u.createdAt||0).getTime();return De==="newest"?j-f:f-j});return!le||le.length===0?o.map(n=>{const u=to(n,[]);return!u.ageGroup&&n.ageGroup!==null&&n.ageGroup!==void 0&&(u.ageGroup=`Age Group ${n.ageGroup}`),u}):o.map(n=>to(n,le))},[Ie,le,De]),h=a.useMemo(()=>{if(!s)return null;const r=z.find(o=>String(o.id)===s);return r?{id:String(r.id),name:r.name,logo:r.logo??null,groupTeamLogo:r.groupTeamLogo??null,athletes:r.athletesCount||0,ageGroup:r.ageGroup,headCoach:r.headCoach,headCoaches:r.headCoaches,teamId:r.teamId,leagueName:r.leagueName}:null},[s,z]),{data:se,isLoading:_o}=Cr(s?Number.parseInt(s,10):null,1,100),Q=a.useMemo(()=>!(se!=null&&se.results)||se.results.length===0?[]:se.results.map(r=>{var N;const o=`${r.user_first_name||""} ${r.user_last_name||""}`.trim()||r.user_email,n=r.usa_hockey_number,u=typeof n=="string"&&n.trim()?n.trim():"NA",f=r.is_active===!0&&r.status===1,j=r.avatar??r.profile_photo??r.user_profile_photo??((N=r.user)==null?void 0:N.profile_photo)??null,S=r.date_of_birth??(typeof(r==null?void 0:r.dateOfBirth)=="string"?r.dateOfBirth:void 0),O=S&&String(S).trim()?String(S).trim():void 0;return{id:String(r.user_id),name:(h==null?void 0:h.name)||r.team_name||"Team",playerName:o,playerId:u,playerAvatar:Fr(j),groups:[(h==null?void 0:h.name)||r.team_name||"Team"],status:f?"active":"inactive",league:void 0,season:void 0,position:void 0,dob:O,playerStats:void 0,historicalGoalPercentage:void 0}}).filter(r=>r.status==="active"),[se,h]),F=a.useMemo(()=>{const r=(at??"").trim().toLowerCase();return r?Q.filter(o=>(o.playerName||o.name||"").toLowerCase().includes(r)||(o.playerId??"").toLowerCase().includes(r)||(o.league??"").toLowerCase().includes(r)):Q},[Q,at]),ie=a.useMemo(()=>{if(k!=="table")return F;const r=He*V;return F.slice(r,r+V)},[F,k,He,V]);a.useEffect(()=>{Ge(0)},[F.length,k]);const Eo=(r,o)=>{Ge(o)},Ro=r=>{go(Number(r.target.value)),Ge(0)},No=a.useMemo(()=>{if(!Z)return z;const r=Se*X;return z.slice(r,r+X)},[Z,z,Se,X]),wt=Z?z.length:(Ue==null?void 0:Ue.count)??0,Ye=a.useRef(null);a.useEffect(()=>{if(!R||z.length===0)return;const r=String(R);if(Ye.current===r)return;const o=z.findIndex(n=>String(n.id)===r||String(n.teamId)===r);o>=0&&(ye(Math.floor(o/X)),Ye.current=r)},[R,z,X]),a.useEffect(()=>{R||(Ye.current=null)},[R]);const zo=(r,o)=>{ye(o)},ko=r=>{po(Number(r.target.value)),ye(0)},Fo=r=>{const o=I?M(I,`${D.TEAMS}?teamId=${r}`):void 0;b(M(I??"",D.TEAM_DETAIL(r)),{state:o?{returnTo:o}:void 0})},Po=r=>{y({teamId:r})},Wo=()=>{y({}),Be("")},Oo=()=>{s&&Fo(s)},Lo=()=>{s&&y({action:"edit",teamId:s})},Mo=r=>{const o=z.find(n=>String(n.id)===r||n.teamId===r);o&&(Xe(o),qe(!0))},Do=async()=>{if(!de)return;const r=de.name;try{await wo.mutateAsync(de.id),qe(!1),Xe(null),i==null||i(yr.DELETED(r),{variant:"success"})}
2catch{i==null||i(q.ERROR.FAILED_DELETE_TEAM,{variant:"error"})}},Ct=()=>{qe(!1),Xe(null)},Bo=r=>{dt(r.currentTarget)},Ee=()=>{dt(null)},Ho=()=>{if(s){const r=z.find(o=>String(o.id)===s);if(r&&r.status==="inactive"){i(q.ERROR.CANNOT_ADD_ATHLETE_TO_INACTIVE_TEAM,{variant:"error"}),Ee();return}}$e(!0),Ee()},Go=()=>{ce(!0),Ee()},At=async r=>{try{const o=await Rr(r);ht(r),gt(o),ce(!1),Ke(!0)}catch(o){i(Xt(o,"parse"),{variant:"error"})}},Tt=()=>{Ke(!1),ce(!0)},_t=async r=>{if(!v||!Ce){i==null||i(et.FORM.ORGANIZATION_ACCOUNT_TYPE_ERROR,{variant:"error"});return}if(r.length===0){i==null||i(q.INFO.NO_ATHLETES_SELECTED,{variant:"info"});return}const o=Br(C);if(!o){i==null||i(rr.ATHLETE_ROLE_NOT_FOUND,{variant:"error"});return}try{const n=s?Number.parseInt(s,10):void 0,u=n!=null&&(h!=null&&h.name)?h.name.trim():void 0,f=Nr(r,{fixedTeamId:n});if(!f.ok){i==null||i(f.errors.slice(0,5).join(" "),{variant:"error"});return}const j=zr(r,Ce.name,{contextTeamName:u||void 0});await kr.createBulkInvites(j,o,v,n),i==null||i(q.SUCCESS.BULK_INVITE_STARTED,{variant:"success"}),Ve(),s&&g.invalidateQueries({queryKey:["teamAthletes",Number.parseInt(s,10)]}),g.invalidateQueries({queryKey:["teams",v]})}catch(n){i==null||i(Xt(n,"api"),{variant:"error"})}},Et=()=>{const r=!!s,o=r?Lr:Mr,n=new Blob([o],{type:"text/csv"}),u=globalThis.URL.createObjectURL(n),f=document.createElement("a");f.href=u,f.download=r?"sample_bulk_invite_team_athletes.csv":"sample_bulk_invite_athletes.csv",document.body.appendChild(f),f.click(),f.remove(),globalThis.URL.revokeObjectURL(u)},Uo=r=>{if(r.target.checked)we(new Set(ie.map(o=>o.id)));else{const o=new Set(ie.map(n=>n.id));we(n=>new Set([...n].filter(u=>!o.has(u))))}},$o=r=>{const o=new Set(U);o.has(r)?o.delete(r):o.add(r),we(o)},Ko=()=>{we(new Set)},Rt=(r,o)=>{yt(r.currentTarget),vt(o)},Re=()=>{yt(null),vt(null)},Ne=Gt({mutationFn:async r=>{var o,n,u,f,j,S,O,N,L;if(!v)throw new Error(et.INLINE.API_ORG_ACCOUNT_REQUIRED);return jr(String(v),r.athleteId,{team_id:r.team_id,first_name:r.first_name,last_name:r.last_name,email:r.email,phone_number:((o=r.phone_number)==null?void 0:o.trim())||void 0,player_number:((n=r.player_number)==null?void 0:n.trim())||void 0,usa_hockey_number:r.usa_hockey_number||void 0,preferred_name:((u=r.preferred_name)==null?void 0:u.trim())||void 0,guardian_name:((f=r.guardian_name)==null?void 0:f.trim())||void 0,guardian_number:((j=r.guardian_number)==null?void 0:j.trim())||void 0,guardian_email:((S=r.guardian_email)==null?void 0:S.trim())||void 0,gender:((O=r.gender)==null?void 0:O.trim())||void 0,country:((N=r.country)==null?void 0:N.trim())||void 0,date_of_birth:((L=r.date_of_birth)==null?void 0:L.trim())||void 0})},onSuccess:()=>{s&&g.invalidateQueries({queryKey:["teamAthletes",Number.parseInt(s,10)]}),g.invalidateQueries({queryKey:["accountAthletes"]}),Ae(!1),_e(null),Qe(null),i(q.SUCCESS.ATHLETE_UPDATED,{variant:"success"})},onError:r=>{i(q.ERROR.TRY_AGAIN,{variant:"error"})}}),ze=Gt({mutationFn:async({teamId:r,userId:o})=>{if(!r)throw new Error(et.INLINE.API_REQUIRED_PARAMS);return Ir(r,o)},onSuccess:()=>{if(s){const r=Number.parseInt(s,10);g.invalidateQueries({queryKey:["teamAthletes",r]})}g.invalidateQueries({queryKey:["accountAthletes"]}),g.invalidateQueries({queryKey:["teams",v]}),te(!1),oe(null),re(!1),ne(null),i(q.SUCCESS.ATHLETE_REMOVED,{variant:"success"})},onError:r=>{i(q.ERROR.TRY_AGAIN,{variant:"error"})}}),Nt=async()=>{if(!E||!v)return;const r=Q.find(o=>o.id===E)||F.find(o=>o.id===E)||null;if(r){Qe(r),bt(!0),Re();try{const{getAthleteProfile:o}=await or(async()=>{const{getAthleteProfile:u}=await import("./athleteService-D_MLebI7.js");return{getAthleteProfile:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),n=await o(String(v),E);_e(n??null),Ae(!0)}catch{_e(null),Ae(!0)}finally{bt(!1)}}},Qo=a.useMemo(()=>{const r=E?Q.find(n=>n.id===E)||F.find(n=>n.id===E):null,o=(r==null?void 0:r.status)==="active";return[{label:"Edit",onClick:Nt,icon:e.jsx(Hr,{size:18})},{label:"Chat",onClick:()=>{E&&(Re(),I&&b(`${M(I,D.CHAT)}?userId=${E}`))},icon:e.jsx(_r,{size:18})},{label:o?"Remove From Team":"Delete",onClick:()=>
2{if(!E||!s)return;const n=Q.find(u=>u.id===E)||F.find(u=>u.id===E);n&&(o?(ne({id:E,name:n.playerName||n.name||"this athlete"}),re(!0)):(oe({id:E,name:n.playerName||n.name||"this athlete"}),te(!0))),Re()},icon:o?e.jsx(Gr,{size:18}):e.jsx(Yt,{size:18})}]},[E,Q,F,s,Nt,G,b]),zt=ie.length>0&&ie.every(r=>U.has(r.id)),qo=U.size>0&&ie.some(r=>U.has(r.id))&&!zt;if(W&&(m==="create"||m==="edit"&&!!s))return e.jsx(Je,{minHeight:Wt,message:"Redirecting..."});if(m==="create")return e.jsx(Pe,{title:We.TITLE.ADD_NEW_TEAM,description:We.DESCRIPTION.CREATE_TEAM,disablePadding:!0,children:e.jsx(Kt,{})});if(m==="edit"&&s)return e.jsx(Pe,{title:We.TITLE.EDIT_TEAM,description:We.DESCRIPTION.EDIT_TEAM,disablePadding:!0,children:e.jsx(Kt,{teamId:s,isEditMode:!0})});if(!Me&&Io&&z.length===0)return e.jsx(Je,{minHeight:Wt,message:"Loading teams..."});if(s){const r=Q.length||0;return e.jsxs(Pe,{title:"Teams",description:"Manage the team assigned to you",children:[e.jsxs(c,{sx:{...d==="boxed"&&{maxWidth:{xs:"100%",lg:"1400px",xl:"1600px"},mx:"auto"},...d==="full"&&{width:"100%",maxWidth:"100%"},width:"100%",boxSizing:"border-box"},children:[e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:2,mb:3},children:[e.jsx(H,{onClick:Wo,sx:{color:t.gray[700],"&:hover":{bgcolor:t.background.hover}},children:e.jsx(co,{size:20})}),e.jsxs(c,{sx:{flex:1},children:[e.jsx(x,{variant:"h4",sx:{fontFamily:"Inter",fontWeight:600,fontSize:{xs:"20px",sm:"24px",md:"28px"},mb:"8px",color:t.gray[900]},children:(h==null?void 0:h.name)||"Team Details"}),e.jsx(x,{variant:"body2",sx:{fontFamily:"Inter",color:t.text.secondary,fontSize:{xs:"14px",sm:"16px"}},children:"Manage the team assigned to you"})]}),e.jsxs(c,{sx:{display:"flex",gap:1.5,flexDirection:{xs:"column",sm:"row"},width:{xs:"100%",sm:"auto"}},children:[e.jsx(ke,{variant:"outlined",startIcon:e.jsx(Zo,{size:18}),onClick:Oo,sx:{borderRadius:t.card.borderRadius.default,textTransform:"none",fontFamily:"Inter",bgcolor:t.base.white,color:t.button.primary,borderColor:t.button.primary,borderWidth:"1px",borderStyle:"solid",px:{xs:1.5,sm:2},py:{xs:.75,sm:1},fontWeight:400,fontSize:{xs:"12px",sm:"14px"},"&:hover":{borderColor:t.button.primary,bgcolor:t.gradient.blueFaded,color:t.button.primary}},children:"Team Details"}),P&&e.jsx(ke,{variant:"outlined",startIcon:void 0,onClick:Lo,sx:{borderRadius:t.card.borderRadius.default,textTransform:"none",fontFamily:"Inter",bgcolor:t.base.white,color:t.button.primary,borderColor:t.button.primary,borderWidth:"1px",borderStyle:"solid",px:{xs:1.5,sm:2},py:{xs:.75,sm:1},fontWeight:400,fontSize:{xs:"12px",sm:"14px"},"&:hover":{borderColor:t.button.primary,bgcolor:t.gradient.blueFaded,color:t.button.primary}},children:"Edit Team"}),e.jsx(ke,{variant:"contained",startIcon:e.jsx(er,{size:18}),onClick:Bo,sx:{borderRadius:t.card.borderRadius.default,textTransform:"none",fontFamily:"Inter",bgcolor:t.organization[500],color:t.base.white,px:{xs:1.5,sm:2},py:{xs:.75,sm:1},fontWeight:400,fontSize:{xs:"12px",sm:"14px"},"&:hover":{bgcolor:t.organization[600]}},children:"Add Athletes"}),e.jsxs(ir,{anchorEl:ct,open:!!ct,onClose:Ee,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{borderRadius:t.card.borderRadius.default,boxShadow:t.shadow.md,border:"1px solid",borderColor:t.border.default,minWidth:"180px",mt:.5,p:0,overflow:"hidden"}}},children:[e.jsx(B,{onClick:Ho,sx:{fontFamily:"Inter",fontSize:"14px",color:t.gray[900],py:1.5,px:1.5,borderRadius:0,bgcolor:"transparent","&:hover":{bgcolor:t.gradient.blueFadedLight,color:t.button.primary,"& .MuiTypography-root":{color:t.button.primary},"& svg":{color:t.button.primary}}},children:e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(Jt,{size:18,color:t.gray[700]}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:"14px",color:t.gray[900]},children:"Add Athlete"})]})}),e.jsx(B,{onClick:Go,sx:{fontFamily:"Inter",fontSize:"14px",color:t.gray[900],py:1.5,px:1.5,borderRadius:0,bgcolor:"transparent","&:hover":{bgcolor:t.gradient.blueFadedLight,color:t.button.primary,"& .MuiTypography-root":{color:t.button.primary},"& svg":{color:t.button.primary}}},children:e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(gr,{width:18,height:18,style:{color:t.gray[700]}}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:"14px",color:t.gray[900]},children:"CSV Upload"})]})})]})]})]}),e.jsx(ar,{sx:{mb:2,borderColor:t.border.default}}),e.jsxs(c,{children:[e.jsxs(c,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",md:"center"},mb:2,gap:2},children:[e.jsxs(x,{variant:"h5",sx:{fontFamily:"Inter",fontWeight:600,fontSize:"18px",color:t.gray[900]},children:["Athletes"," ",e.jsxs(c,{component:"span",sx:{color:t.button.primary},children:["(",r,")"]})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:2,width:{xs:"100%",md:"auto"},alignItems:{xs:"stretch",md:"center"}},children:[e.jsx(Dt,{placeholder:"Search athletes...",value:ve,inputRef:st,onChange:o=>{var n;Be(o.target.value),(n=st.current)==null||n.focus()},sx:{width:{xs:"100%",md:"300px"},"& .MuiOutlinedInput-root":{borderRadius:t.card.borderRadius.default,bgcolor:t.base.white,"& fieldset":{borderColor:t.border.default},"&:hover fieldset":{borderColor:t.gray[300]},"&.Mui-focused fieldset":{borderColor:t.button.primary}}},InputProps:{startAdornment:e.jsx(Fe,{position:"start",children:e.jsx(Ot,{size:20})}),endAdornment:ve?e.jsx(Fe,{position:"end",children:e.jsx(H,{size:"small","aria-label":"Clear search",onClick:()=>Be(""),sx:{color:t.gray[500],"&:hover":{color:t.button.primary}},children:e.jsx(tt,{size:16})})}):void 0}}),e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:0,bgcolor:t.gradient.blueFaded,border:"1px solid",borderColor:t.button.primary,borderRadius:t.card.borderRadius.default,p:.5},children:[e.jsx(rt,{title:"Table view â See athletes in a table with rows and columns",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(H,{onClick:()=>it("table"),sx:{bgcolor:k==="table"?t.button.primary:"transparent",minWidth:"auto",width:"32px",height:"32px",p:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:t.card.borderRadius.default,"&:hover":{bgcolor:k==="table"?t.button.primary:"transparent"},"& svg":{width:"11px",height:"8px",display:"block"},"& path":{fill:k==="table"?t.base.white:t.black.pure}},children:e.jsx(hr,{})})})}),e.jsx(rt,{title:"Card view â See athletes as cards in a list",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(H,{onClick:()=>it("cards"),sx:{bgcolor:k==="cards"?t.button.primary:"transparent",minWidth:"auto",width:"32px",height:"32px",p:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:t.card.borderRadius.default,"&:hover":{bgcolor:k==="cards"?t.button.primary:"transparent"},"& svg":{width:"14px",height:"10px",display:"block"},"& path":{fill:k==="cards"?t.base.white:t.black.pure}},children:e.jsx(pr,{})})})})]})]})]}),U.size>0&&k==="table"&&e.jsxs(c,{sx:{mb:2,display:"flex",alignItems:"center",gap:2},children:[e.jsx(H,{onClick:Ko,sx:{color:"error.main","&:hover":{bgcolor:t.status.error.hoverBg}},children:e.jsx(Yt,{size:18})}),e.jsxs(x,{variant:"body2",color:"text.secondary",sx:{fontFamily:"Inter"},children:[U.size," ",U.size===1?"athlete":"athletes"," selected"]})]}),_o?e.jsx(Je,{minHeight:300,message:"Loading athletes..."}):F.length===0?e.jsx(c,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",pt:4,pb:4,width:"100%"},children:e.jsx(x,{color:"text.secondary",sx:{fontFamily:"Inter",fontSize:"14px",textAlign:"center"},children:ve?"No athletes match your search.":"This team has no active athletes yet. Add athletes or ask invited athletes to accept their invites."})}
2):k==="cards"?e.jsx(c,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(3, 1fr)"},gap:2},children:F.map(o=>e.jsx(Kr,{team:o,teamLogo:(h==null?void 0:h.logo)??null,showMenu:!0,onMenuClick:(n,u)=>Rt(n,u),onToggle:n=>{if(!((typeof n=="string"?parseInt(n,10):Number(n))<0||o.status!=="active")&&o.status==="active"&&I){const j=M(I,D.TEAMS),S=s?`${j}?teamId=${s}`:j;b(M(I,`${D.ATHLETES}/${n}`),{state:{returnTo:S}})}}},o.id))}):e.jsx(c,{sx:{boxShadow:"none",border:"1px solid",borderColor:t.border.default,borderRadius:t.card.borderRadius.default,display:"flex",flexDirection:"column",overflow:"hidden",width:"100%"},children:e.jsx(ro,{component:no,sx:{boxShadow:"none",border:"none",borderRadius:"8px 8px 0 0",flex:1,minWidth:0,width:"100%",maxWidth:"100%",overflowX:"auto",overflowY:V<=5?"hidden":"scroll",maxHeight:V<=5?"none":"560px",scrollbarGutter:V<=5?void 0:"stable","& .MuiTableHead-root":{position:"sticky",top:0,zIndex:10},scrollbarWidth:"thin",scrollbarColor:`${t.background.scrollbarThumb} ${t.background.scrollbarTrack}`,...tr(6),"&::-webkit-scrollbar-thumb:hover":{backgroundColor:t.gray[400]}},children:e.jsxs(so,{stickyHeader:!0,sx:{width:"100%",minWidth:770},children:[e.jsx(io,{children:e.jsxs(ae,{sx:Lt,children:[e.jsx(l,{padding:"checkbox",sx:{...Lt,width:"3%",minWidth:48},children:e.jsx(Oe,{checked:zt,indeterminate:qo,onChange:Uo,sx:Mt})}),e.jsx(l,{sx:{...Y,minWidth:140},children:"Athlete Name"}),e.jsx(l,{sx:{...Y,minWidth:100},children:"USA Hockey Number"}),e.jsx(l,{sx:{...Y,minWidth:110},children:"Date of Birth"}),e.jsx(l,{sx:{...Y,minWidth:80},children:"Status"}),e.jsx(l,{colSpan:5,sx:{...Y,minWidth:180},children:"Stats"}),e.jsx(l,{sx:{...Y,minWidth:100},children:"Groups"}),e.jsx(l,{align:"center",sx:{...Y,minWidth:80,pr:2,pl:1,whiteSpace:"nowrap"},children:"Actions"})]})}),e.jsx(ao,{children:ie.map(o=>{var n,u,f,j;return e.jsxs(ae,{hover:!0,sx:{cursor:o.status==="active"?"pointer":"default"},onClick:()=>{if(!((typeof o.id=="string"?parseInt(o.id,10):Number(o.id))<0||o.status!=="active")&&o.status==="active"&&I){const N=M(I,D.TEAMS),L=s?`${N}?teamId=${s}`:N;b(M(I,`${D.ATHLETES}/${o.id}`),{state:{returnTo:L}})}},children:[e.jsx(l,{padding:"checkbox",sx:{width:"3%",minWidth:48},children:e.jsx(Oe,{checked:U.has(o.id),onChange:()=>$o(o.id),onClick:S=>S.stopPropagation(),sx:Mt})}),e.jsx(eo,{title:Vt(o.playerName||o.name),cellSx:{whiteSpace:"nowrap"},children:e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:{xs:1,sm:1.5},minWidth:0,overflow:"hidden"},children:[e.jsx(ot,{src:o.playerAvatar,sx:{width:{xs:32,sm:40},height:{xs:32,sm:40},flexShrink:0,borderRadius:t.card.borderRadius.default,bgcolor:o.playerAvatar?void 0:t.button.primary,color:o.playerAvatar?void 0:t.base.white,fontSize:{xs:"12px",sm:"14px"},fontWeight:600},children:o.playerAvatar?null:nt(o.playerName||o.name)}),e.jsx(x,{component:"span",sx:{fontFamily:"Inter",fontSize:{xs:"13px",sm:"14px"},lineHeight:1.35,cursor:o.status==="active"?"pointer":"default",color:o.status==="active"?t.button.primary:t.gray[900],whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0,"&:hover":{textDecoration:o.status==="active"?"underline":"none"}},children:Vt(o.playerName||o.name)})]})}),e.jsx(l,{sx:{overflow:"hidden",minWidth:0,verticalAlign:"middle"},children:e.jsx(c,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},lineHeight:1.35,color:t.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:o.playerId||"-"})}),e.jsx(l,{sx:{overflow:"hidden",minWidth:0,verticalAlign:"middle"},children:e.jsx(c,{sx:{fontFamily:"Inter",fontSize:{xs:"13px",sm:"15px"},lineHeight:1.35,color:t.gray[900],overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:o.dob?lo(o.dob):"-"})}),e.jsx(l,{sx:{overflow:"hidden",minWidth:0,verticalAlign:"middle"},children:e.jsx(lr,{label:o.status==="active"?"Active":"Inactive",size:"small",sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},fontWeight:500,bgcolor:o.status==="active"?t.status.success.bg:t.status.error.bg,color:o.status==="active"?t.status.success.text:t.status.error.text,height:"24px","& .MuiChip-label":{px:1}}})}),e.jsx(l,{colSpan:5,sx:{whiteSpace:"nowrap",overflow:"hidden",minWidth:0,verticalAlign:"middle"},children:e.jsxs(c,{sx:{border:`1px solid ${t.border.default}`,borderRadius:t.card.borderRadius.default,p:{xs:1,sm:1.25},pl:{xs:1.25,sm:1.5},pr:{xs:1.25,sm:1.5},display:"inline-flex",gap:{xs:.5,sm:.75}
2,alignItems:"flex-start",whiteSpace:"nowrap",width:"fit-content"},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:.5,width:"fit-content",flexShrink:0},children:[e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},color:t.text.secondary,whiteSpace:"nowrap"},children:"Season"}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,color:t.gray[900],whiteSpace:"nowrap"},children:o.season||"2025-26"})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:.5,minWidth:{xs:"35px",sm:"40px"},alignItems:"flex-end",flexShrink:0},children:[e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},color:t.text.secondary,whiteSpace:"nowrap"},children:"GP"}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,color:t.gray[900],whiteSpace:"nowrap"},children:((n=o.playerStats)==null?void 0:n.gamesPlayed)||0})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:.5,minWidth:{xs:"35px",sm:"40px"},alignItems:"flex-end",flexShrink:0},children:[e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},color:t.text.secondary,whiteSpace:"nowrap"},children:"G"}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,color:t.gray[900],whiteSpace:"nowrap"},children:((u=o.playerStats)==null?void 0:u.goals)||0})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:.5,minWidth:{xs:"35px",sm:"40px"},alignItems:"flex-end",flexShrink:0},children:[e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},color:t.text.secondary,whiteSpace:"nowrap"},children:"A"}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,color:t.gray[900],whiteSpace:"nowrap"},children:((f=o.playerStats)==null?void 0:f.assists)||0})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:.5,minWidth:{xs:"35px",sm:"40px"},alignItems:"flex-end",flexShrink:0},children:[e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},color:t.text.secondary,whiteSpace:"nowrap"},children:"P"}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"12px",sm:"14px"},fontWeight:600,color:t.gray[900],whiteSpace:"nowrap"},children:((j=o.playerStats)==null?void 0:j.points)||0})]})]})}),e.jsx(eo,{title:o.groups&&o.groups.length>0?o.groups.join(", "):"",cellSx:{verticalAlign:"middle",minWidth:120},children:e.jsx(c,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"nowrap",maxWidth:"100%",overflow:"hidden",minWidth:0},children:o.groups&&o.groups.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.5,borderRadius:t.card.borderRadius.default,bgcolor:t.base.white,border:`1px solid ${t.border.default}`,height:"24px",minWidth:0,maxWidth:"100%",overflow:"hidden"},children:[e.jsx(ot,{sx:{width:16,height:16,bgcolor:t.button.primary,color:t.base.white,fontSize:"10px",fontWeight:600,flexShrink:0},children:nt(o.groups[0])}),e.jsx(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},fontWeight:500,lineHeight:1.35,color:t.gray[900],whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0,flex:1},children:o.groups[0]})]}),o.groups.length>1&&e.jsx(c,{sx:{display:"flex",alignItems:"center",px:.75,py:.5,borderRadius:t.card.borderRadius.default,bgcolor:t.background.hover,height:"24px",flexShrink:0},children:e.jsxs(x,{sx:{fontFamily:"Inter",fontSize:{xs:"11px",sm:"12px"},fontWeight:500,color:t.gray[700],whiteSpace:"nowrap"},children:["+",o.groups.length-1]})})]})})}),e.jsx(l,{align:"center",sx:{pr:2,pl:1,width:52,minWidth:52,whiteSpace:"nowrap",verticalAlign:"middle"},children:e.jsx(c,{sx:{display:"flex",justifyContent:"center",width:"100%"},children:e.jsx(H,{size:"small",sx:{color:"text.secondary",p:.5,"&:hover":{bgcolor:t.background.hover}},onClick:S=>{S.stopPropagation(),Rt(S,o.id)},children:e.jsx(Ur,{size:20})})})})]},o.id)})}),e.jsx(cr,{children:e.jsx(ae,{children:e.jsx(Bt,{component:"td",rowsPerPageOptions:[10,25,50],colSpan:12,count:F.length,rowsPerPage:V,page:He,onPageChange:Eo,onRowsPerPageChange:Ro,sx:{"& .MuiTablePagination-toolbar":{fontFamily:"Inter",justifyContent:"flex-end"},"& .MuiTablePagination-selectLabel":{fontFamily:"Inter"},"& .MuiTablePagination-displayedRows":{fontFamily:"Inter"}}})})})]})})})]})]}),e.jsx(Wr,{anchorEl:St,open:!!St,onClose:Re,items:Qo}),ft&&e.jsx(Or,{open:ft,mode:"edit",title:"Edit Athlete",subtitle:"Update details and guardian information.",disableTeamField:!!s,teams:s&&h?[{id:s,name:h.name}]:(Te==null?void 0:Te.teams)||((kt=A==null?void 0:A.groups)==null?void 0:kt.map((o,n)=>({id:String(n),name:o})))||[],initialValues:(()=>{var L,xe,me,ue,he,pe;const o=Te,n=o==null?void 0:o.profile,f=((A==null?void 0:A.playerName)||(A==null?void 0:A.name)||"").split(" "),j=(n==null?void 0:n.date_of_birth)??(typeof(o==null?void 0:o.dateOfBirth)=="string"?o.dateOfBirth:void 0),S=typeof j=="string"?j:(A==null?void 0:A.dob)??"",O=Pr(S)||S||"",N=s&&h?s:((me=(xe=(L=o==null?void 0:o.teams)==null?void 0:L[0])==null?void 0:xe.id)==null?void 0:me.toString())??((ue=A==null?void 0:A.groups)!=null&&ue.length?"0":"");return{firstName:(o==null?void 0:o.first_name)??f[0]??"",lastName:(o==null?void 0:o.last_name)??f.slice(1).join(" ")??"",email:(o==null?void 0:o.email)??"",preferredName:(n==null?void 0:n.preferred_name)??"",playerNumber:(((pe=(he=o==null?void 0:o.teams)==null?void 0:he[0])==null?void 0:pe.player_number)!=null?String(o.teams[0].player_number):"")??"",gender:(n==null?void 0:n.gender)??"",phoneNumber:(n==null?void 0:n.phone_number)??"",dateOfBirth:O,teamId:N,usaHockeyNumber:(o==null?void 0:o.usa_hockey_number)??"",guardianName:(o==null?void 0:o.guardian_name)??"",guardianPhoneNumber:(o==null?void 0:o.guardian_number)??"",guardianEmail:(o==null?void 0:o.guardian_email)??"",country:(n==null?void 0:n.country_name)??""}})(),loading:Ne.status==="pending"||Co,saving:Ne.status==="pending",submitLabel:"Save Changes",onClose:()=>{Ne.status!=="pending"&&To()},onSubmit:o=>{var O,N,L,xe,me,ue,he,pe,Ft,Pt;if(!A)return;const u=`${o.firstName.trim()} ${o.lastName.trim()}`.trim().split(" "),f=u[0]||"",j=u.slice(1).join(" ")||"",S=o.teamId?Number.parseInt(o.teamId,10):s?Number.parseInt(s,10):void 0;
2Ne.mutate({athleteId:String(A.id),team_id:S&&!Number.isNaN(S)?S:void 0,first_name:f,last_name:j,email:o.email.trim(),phone_number:((O=o.phoneNumber)==null?void 0:O.trim())||void 0,player_number:((N=o.playerNumber)==null?void 0:N.trim())||void 0,usa_hockey_number:((L=o.usaHockeyNumber)==null?void 0:L.trim())||void 0,preferred_name:((xe=o.preferredName)==null?void 0:xe.trim())||void 0,guardian_name:((me=o.guardianName)==null?void 0:me.trim())||void 0,guardian_number:((ue=o.guardianPhoneNumber)==null?void 0:ue.trim())||void 0,guardian_email:((he=o.guardianEmail)==null?void 0:he.trim())||void 0,gender:((pe=o.gender)==null?void 0:pe.trim())||void 0,country:((Ft=o.country)==null?void 0:Ft.trim())||void 0,date_of_birth:((Pt=o.dateOfBirth)==null?void 0:Pt.trim())||void 0})}}),e.jsx(Ht,{open:xt,onClose:()=>$e(!1),accountId:v,teamId:s,teamName:h==null?void 0:h.name,onSuccess:()=>{s&&g.invalidateQueries({queryKey:["teamAthletes",Number.parseInt(s,10)]}),g.invalidateQueries({queryKey:["teams",v]})},title:"Invite Athlete"}),e.jsx(Qt,{open:mt,onClose:()=>ce(!1),onNext:At,onDownloadSample:Et}),e.jsx(Zt,{open:ut,onClose:Ve,onBack:Tt,onUpload:_t,file:Ce,csvData:pt,contextTeamDisplayName:(h==null?void 0:h.name)??null}),e.jsx(be,{open:jt,type:"confirm",title:$?`Are you sure you want to remove ${$.name} from this team?`:"Delete Athlete from Team",subtitle:"Removing them can't be undone.",confirmText:"Delete",cancelText:"Cancel",onConfirm:()=>{$&&s&&ze.mutate({teamId:s,userId:$.id})},onCancel:()=>{te(!1),oe(null)},onClose:()=>{te(!1),oe(null)},showCancelButton:!0,confirmButtonColor:t.button.primarySolid,confirmButtonHoverColor:t.button.primaryHoverSolid,cancelButtonBorderColor:t.button.primarySolid,cancelButtonTextColor:t.button.primarySolid,illustration:e.jsx(c,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:t.status.error.bg,display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(ge,{size:38,style:{color:t.status.error.text}})})}),e.jsx(be,{open:It,type:"confirm",title:K?`Are you sure you want to remove ${K.name} from this team?`:"Remove Athlete from Team",subtitle:"They'll be removed from this team's roster but stay in your organization.",confirmText:"Remove",cancelText:"Cancel",onConfirm:()=>{K&&s&&ze.mutate({teamId:s,userId:K.id})},onCancel:()=>{re(!1),ne(null)},onClose:()=>{re(!1),ne(null)},showCancelButton:!0,confirmButtonColor:t.button.primarySolid,confirmButtonHoverColor:t.button.primaryHoverSolid,cancelButtonBorderColor:t.button.primarySolid,cancelButtonTextColor:t.button.primarySolid,illustration:e.jsx(c,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:t.status.error.bg,display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(ge,{size:38,style:{color:t.status.error.text}})})})]})}return e.jsxs(Pe,{title:"Teams",description:"Manage the team assigned to you",children:[e.jsxs(c,{sx:{...d==="boxed"&&{maxWidth:{xs:"100%",lg:"1400px",xl:"1600px"},mx:"auto"},...d==="full"&&{width:"100%",maxWidth:"100%"},width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:"calc(100vh - 170px)"},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"flex-start"},mb:3,gap:{xs:2,sm:0}},children:[e.jsxs(c,{sx:{flex:1},children:[e.jsx(x,{variant:"h4",sx:{fontFamily:"Inter",fontWeight:600,fontSize:{xs:"20px",sm:"24px",md:"28px"},mb:"14px"},children:"Teams"}),e.jsx(x,{variant:"body2",sx:{fontFamily:"Inter",color:t.text.secondary,fontSize:{xs:"14px",sm:"16px"}},children:"Manage the team assigned to you"})]}),P&&e.jsx(ke,{variant:"contained",startIcon:e.jsx(Jt,{size:18}),onClick:()=>{b(`${M(I??"",D.TEAMS)}?action=create`)},sx:{borderRadius:t.card.borderRadius.default,textTransform:"none",fontFamily:"Inter",bgcolor:t.organization[500],color:t.base.white,px:{xs:1.5,sm:2},py:{xs:.75,sm:1},fontWeight:400,fontSize:{xs:"12px",sm:"14px"},"&:hover":{bgcolor:t.organization[600]},alignSelf:{xs:"stretch",sm:"flex-start"}},children:"Create New Team"})]}),e.jsxs(c,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:{xs:2,md:1.5},mb:3,alignItems:{xs:"stretch",md:"flex-end"},flexWrap:"wrap"},children:[e.jsx(Dt,{placeholder:"Search teams...",value:w.search??"",onChange:r=>Le("search",r.target.value),size:"small",sx:{flex:1,minWidth:{xs:"100%",md:200},"& .MuiOutlinedInput-root":{borderRadius:t.card.borderRadius.default,he
2ight:40,bgcolor:t.base.white,"& fieldset":{borderColor:t.border.default},"&:hover fieldset":{borderColor:t.gray[300]},"&.Mui-focused fieldset":{borderColor:t.button.primary}}},InputProps:{startAdornment:e.jsx(Fe,{position:"start",children:e.jsx(Ot,{size:20})}),endAdornment:e.jsxs(Fe,{position:"end",children:[w.search?e.jsx(H,{size:"small","aria-label":"Clear search",onClick:()=>Le("search",""),sx:{color:t.gray[500],"&:hover":{color:t.button.primary},mr:lt?.5:0},children:e.jsx(tt,{size:16})}):null,lt?e.jsx(dr,{size:16,thickness:4}):null]})}}),e.jsxs(Ze,{label:"Status",value:w.status||"all",onChange:r=>Le("status",r.target.value),sx:{"& .MuiOutlinedInput-root":{height:40,borderRadius:"8px"}},children:[e.jsx(B,{value:"all",children:"All"}),e.jsx(B,{value:"active",children:"Active"}),e.jsx(B,{value:"inactive",children:"Inactive"})]}),e.jsxs(Ze,{label:"Sort by",value:De,onChange:r=>uo(r.target.value),sx:{"& .MuiOutlinedInput-root":{height:40,borderRadius:"8px"}},children:[e.jsx(B,{value:"newest",children:"Newest to Oldest"}),e.jsx(B,{value:"oldest",children:"Oldest to Newest"})]}),e.jsxs(Ze,{label:"Age Group",value:J===""?"all":J,onChange:r=>{const o=r.target.value;ho(o==="all"?"":Number(o))},sx:{"& .MuiOutlinedInput-root":{height:40,borderRadius:"8px"}},children:[e.jsx(B,{value:"all",children:"All"}),le.map(r=>e.jsx(B,{value:r.value,children:r.label},r.value))]})]}),e.jsx(c,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:e.jsx(c,{sx:{flex:1},children:e.jsx(wr,{teams:No.map(r=>({...r,athletes:r.athletesCount})),searchQuery:w.search??"",teamsPreFiltered:Z,hasActiveFilters:!!(w.status&&w.status!=="all"||J!==""),showAddButton:!1,highlightedTeamId:R,onTeamClick:Po,variant:"organization",onDelete:P?Mo:void 0,deleteInTopRight:!0,showToast:i})})}),wt>0&&e.jsx(c,{sx:{mt:"auto",borderTop:"1px solid",borderColor:t.border.default,bgcolor:"background.paper",display:"flex",justifyContent:"flex-end",width:"100%"},children:e.jsx(Bt,{component:"div",labelRowsPerPage:"Items per page",rowsPerPageOptions:[...$t.ROWS_PER_PAGE_OPTIONS],count:wt,rowsPerPage:X,page:Se,onPageChange:zo,onRowsPerPageChange:ko,sx:{border:"none","& .MuiTablePagination-toolbar":{fontFamily:"Inter",justifyContent:"flex-end"},"& .MuiTablePagination-selectLabel":{fontFamily:"Inter"},"& .MuiTablePagination-displayedRows":{fontFamily:"Inter"}}})})]}),e.jsx(Ht,{open:xt,onClose:()=>$e(!1),accountId:v,teamId:s,teamName:h==null?void 0:h.name,onSuccess:()=>{g.invalidateQueries({queryKey:["teams",v]})},title:"Invite Athlete"}),e.jsx(Qt,{open:mt,onClose:()=>ce(!1),onNext:At,onDownloadSample:Et}),e.jsx(Zt,{open:ut,onClose:Ve,onBack:Tt,onUpload:_t,file:Ce,csvData:pt,contextTeamDisplayName:(h==null?void 0:h.name)??null}),e.jsx(be,{open:jt,type:"confirm",title:$?`Are you sure you want to remove ${$.name} from this team?`:"Delete Athlete from Team",subtitle:"Removing them can't be undone.",confirmText:"Delete",cancelText:"Cancel",onConfirm:()=>{$&&s&&ze.mutate({teamId:s,userId:$.id})},onCancel:()=>{te(!1),oe(null)},onClose:()=>{te(!1),oe(null)},showCancelButton:!0,confirmButtonColor:t.button.primarySolid,confirmButtonHoverColor:t.button.primaryHoverSolid,cancelButtonBorderColor:t.button.primarySolid,cancelButtonTextColor:t.button.primarySolid,illustration:e.jsx(c,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:t.status.error.bg,display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(ge,{size:38,style:{color:t.status.error.text}})})}),e.jsx(be,{open:It,type:"confirm",title:K?`Are you sure you want to remove ${K.name} from this team?`:"Remove Athlete from Team",subtitle:"They'll be removed from this team's roster but stay in your organization.",confirmText:"Remove",cancelText:"Cancel",onConfirm:()=>{K&&s&&ze.mutate({teamId:s,userId:K.id})},onCancel:()=>{re(!1),ne(null)},onClose:()=>{re(!1),ne(null)},showCancelButton:!0,confirmButtonColor:t.button.primarySolid,confirmButtonHoverColor:t.button.primaryHoverSolid,cancelButtonBorderColor:t.button.primarySolid,cancelButtonTextColor:t.button.primarySolid,illustration:e.jsx(c,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:t.status.error.bg,display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(ge,{size:38,style:{color:t.status.error.text}})})}),e.jsx(be,{open:Ao,type:"confirm",title:de?fe.TITLE(de.name):fe.TITLE_FALLBACK,subtitle:fe.SUBTITLE,confirmText:fe.CONFIRM_TEXT,cancelText:fe.CANCEL_TEXT,onConfirm:()=>{Do()},onCancel:Ct,onClose:Ct,showCancelButton:!0,confirmButtonColor:t.button.primarySolid,confirmButtonHoverColor:t.button.primaryHoverSolid,cancelButtonBorderColor:t.button.primarySolid,cancelButtonTextColor:t.button.primarySolid,illustration:e.jsx(c,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:t.status.error.bg,display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(ge,{size:38,style:{color:t.status.error.text}})})})]})};export{ns 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.