PageSourceSearch

https://club.touchtight.com/assets/index-Br7it_tE.js

js touchtight.com collected 2026-10-02 00:02:02 UTC 32,924 bytes, 1 lines download raw bytes

1import{j as t,a as r}from"./react-vendor-DJtAp8P_.js";import{z as E,aW as U,E as _,aP as $t,T as f,aQ as Rt,aR as Bt,a8 as Lt,J as Qe,u as Ns,j as Mt,aM as Os,aN as Ps,C as $s,aC as Rs}from"./mui-DvP2hOwX.js";import{h as O}from"./moment-Bj79pgB5.js";import{V as Bs,e as Dt,g as Ls,u as Ae,c as Ws,d as Us,i as Gs,F as zs,x as Hs,ab as Vs,a0 as qs,ac as Js,m as Q,ad as Ys,U as It,z as Qs,D as Zs,w as Xs,aA as Ks}from"./app-DT7WuczB.js";import{s as Ft,w as eo}from"./teamActions-BwC441Ib.js";import{S as qe}from"./Add-DRSElN7O.js";import{t as to}from"./teams-import-rbjkohqZ.js";import{S as so}from"./Manage-BcZiAr0H.js";import{S as oo}from"./Copy-Bx2E8fMZ.js";import{S as no}from"./DeleteGray-K_LbbGcc.js";import{b as ao,T as fe,s as ro,D as io,I as lo}from"./swiper-react-DcF17yCe.js";import{B as vt}from"./Button-C4goEOKP.js";import{T as co,S as uo}from"./Search-BEYvHCFs.js";import{o as mo,aj as po,ak as xo}from"./query-CcmDMjHA.js";import{co as ho,bZ as Wt,bC as Ze,aT as fo,bi as go,aW as Z,cp as So,cq as yo,bI as bo}from"./index-CyS3LFy6.js";import{aH as Co,aI as To,aJ as jo}from"./mutation--iSLlBrt.js";import"./dayjs-CFxoC4n5.js";import{D as _o}from"./DeleteModal-BX6BaNP3.js";import{c as wo,d as Eo,u as Mo}from"./index.esm-CWqXbt53.js";import{M as Je}from"./SessionPlannerMobile-85wkJ1ZS.js";import{G as Do}from"./GridCardView-DEqv0l0G.js";import{M as Io}from"./Modal-BzPnYVEi.js";import{S as Fo}from"./SecondaryHeader-CQ32PoR-.js";import{T as vo}from"./ToggleButton-mhLknYBH.js";import{U as Ao}from"./UpgradePlanModal-Cx-12O2U.js";import{S as ko}from"./SortMenu-CjsJdGGV.js";import{S as No,M as Oo}from"./MultiSelectMenu-T4g75gFl.js";import{u as Po}from"./auth-DECj28bo.js";import{u as $o,a as Ro}from"./s3FileHandler-Bp64keCt.js";import{e as At}from"./evictClubTeamsLite-CvhAN8cV.js";import{ImportTeamsModal as Bo}from"./importTeamsModal-DiMbkOmx.js";import{ManageTeamModal as Lo}from"./ManageTeamModal-Dl7uN3U1.js";import{g as Wo}from"./teamInsights-Bo5tltaR.js";import{f as Uo}from"./findKey-Gt-tDAVi.js";import{f as kt}from"./filter-D-vVnHLs.js";import{n as Ye,u as Go,e as zo}from"./apollo-DL0KWP0Y.js";import"./mui-styles-C9F12l22.js";import"./babel-helpers-D2wBBc1I.js";import"./_baseDifference-BHjDay7E.js";import"./_arrayIncludes-DFQcso6E.js";import"./_baseIndexOf-DqPIyCu4.js";import"./isArrayLikeObject-CcVCHQro.js";import"./imageOptimization-zUL1CBPb.js";import"./lodash-icp7yO-G.js";import"./merge-TfBrBrIh.js";import"./_baseAssignValue-CjtYt4eh.js";import"./_baseClone-DByvJCmO.js";import"./map-BI8CQ8np.js";import"./browser-B3fhYDhb.js";import"./hello-pangea-dnd-1bhs5THC.js";import"./some-YFJAbcVi.js";import"./values-DeBIqcD0.js";import"./index-B79atc36.js";import"./omit-BaIHraq0.js";import"./index-bEsv4Yks.js";import"./mui-x-DMY3qA32.js";import"./compact-DZdspzxW.js";import"./cloneDeep-mVQ3twB2.js";import"./ArrowRightUp-CfAFwt7J.js";import"./Graphic-BzX0DM42.js";import"./Filter-vdZeYdaV.js";import"./SearchBlue-Cq--C03-.js";import"./xlsx-DFCG_uyv.js";import"./DatePicker-BFwkswR8.js";import"./UploadImage-DM9jg--i.js";import"./AlertModal-CGXcj45Q.js";import"./isEqual-SawseRfU.js";import"./isNil-R7kYXCYw.js";try{let u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},R=new u.Error().stack;R&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[R]="73e0ec76-5449-4225-8384-67838de4fe8b",u._sentryDebugIdIdentifier="sentry-dbid-73e0ec76-5449-4225-8384-67838de4fe8b")}catch{}const Ho=({open:u,title:R,handleClose:ne,handleApplyFilters:q,loading:d,filters:ae,handleSetFilters:C,cellId:T})=>{const n=wo({value:Eo().required("Value is required")}),j=Mo({initialValues:{operator:"contains",value:""},enableReinitialize:!0,validationSchema:n,onSubmit:X=>{const F={...ae,[T]:X};C({...F}),q(F),M()}}),M=()=>{ne(),j.resetForm()};return t.jsx(Io,{open:u,title:`${R} Filter`,actionBtnTitle:"Apply Filter",handleClose:M,actionHandler:j.handleSubmit,disabledBtn:Bs(j.touched,j.errors),loading:d,dialogMaxWidth:"xs",children:t.jsxs(E,{container:!0,spacing:3,children:[t.jsx(E,{size:12,children:t.jsx(ao,{label:"Operator",name:"operator",value:j.values.operator,options:[{id:"contains",name:"Contains"},{id:"equals",name:"Equals"},{id:"startsWith",name:"Starts With"},{id:"endsWith",name:"Ends With"},{id:"isEmpty",name:"Is Empty"},{id:"isNotEmpty",name:"Is Not Empty"},{id:"isAnyOf",name:"Is Any Of"}],onChange:j.handleChange})}),t.jsx(E,{size:12,children:t.jsx(co,{label:"Value",name:"value",value:j.values.value,handleChange:j.handleChange,error:j.touched.value&&!!j.errors.value,helperText:j.touched.value&&j.errors.value})})]})})},Nt=u=>r.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},r.createElement("g",{id:"icons/ic_info_outline"},r.createElement("g",{id:"shape"},r.createElement("path",{d:"M7.00008 1.16699C5.84636 1.16699 4.71854 1.50911 3.75926 2.15009C2.79997 2.79106 2.0523 3.7021 1.61079 4.76801C1.16928 5.83391 1.05376 7.0068 1.27884 8.13835C1.50392 9.26991 2.05949 10.3093 2.87529 11.1251C3.6911 11.9409 4.7305 12.4965 5.86206 12.7216C6.99361 12.9467 8.1665 12.8311 9.2324 12.3896C10.2983 11.9481 11.2093 11.2004 11.8503 10.2412C12.4913 9.28187 12.8334 8.15405 12.8334 7.00033C12.8334 6.23428 12.6825 5.47574 12.3894 4.76801C12.0962 4.06027 11.6665 3.41721 11.1249 2.87554C10.5832 2.33386 9.94014 1.90418 9.2324 1.61103C8.52467 1.31788 7.76613 1.16699 7.00008 1.16699ZM7.00008 11.667C6.0771 11.66
17 5.17485 11.3933 4.40742 10.8805C3.63999 10.3677 3.04186 9.6389 2.68865 8.78618C2.33544 7.93346 2.24302 6.99515 2.42309 6.0899C2.60315 5.18466 3.04761 4.35314 3.70025 3.70049C4.3529 3.04785 5.18442 2.60339 6.08966 2.42333C6.99491 2.24326 7.93322 2.33568 8.78594 2.68889C9.63866 3.0421 10.3675 3.64023 10.8803 4.40766C11.3931 5.17509 11.6667 6.07735 11.6667 7.00033C11.6667 8.238 11.1751 9.42499 10.2999 10.3002C9.42475 11.1753 8.23776 11.667 7.00008 11.667Z",fill:"#637381"}),r.createElement("path",{d:"M7.00008 5.25033C7.32225 5.25033 7.58342 4.98916 7.58342 4.66699C7.58342 4.34483 7.32225 4.08366 7.00008 4.08366C6.67792 4.08366 6.41675 4.34483 6.41675 4.66699C6.41675 4.98916 6.67792 5.25033 7.00008 5.25033Z",fill:"#637381"}),r.createElement("path",{d:"M7.00008 5.83366C6.84537 5.83366 6.697 5.89512 6.5876 6.00451C6.47821 6.11391 6.41675 6.26228 6.41675 6.41699V9.33366C6.41675 9.48837 6.47821 9.63674 6.5876 9.74614C6.697 9.85553 6.84537 9.91699 7.00008 9.91699C7.15479 9.91699 7.30317 9.85553 7.41256 9.74614C7.52196 9.63674 7.58342 9.48837 7.58342 9.33366V6.41699C7.58342 6.26228 7.52196 6.11391 7.41256 6.00451C7.30317 5.89512 7.15479 5.83366 7.00008 5.83366Z",fill:"#637381"})))),G={icon:{width:"18px",height:"18px",color:"text.secondary"}},Vo=u=>[{id:"name",label:u("teams.columns.name"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"age_group",label:u("teams.columns.ageGroup"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"gender",label:u("teams.columns.gender"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"formation_name",label:u("teams.columns.formation"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"record",label:u("teams.columns.record"),sort:!1},{id:"nextFixture",label:u("teams.columns.nextFixture"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"nextSession",label:u("teams.columns.nextSession"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"playerCount",label:u("teams.columns.players"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"coachCount",label:u("teams.columns.coaches"),sort:!0,icon:t.jsx(U,{sx:G.icon})},{id:"league",label:u("teams.columns.league"),sort:!0,icon:t.jsx(U,{sx:G.icon})}],Ot={name:!1,age_group:!1,gender:!1,formation_name:!1,nextFixture:!1,nextSession:!1,playerCount:!1,coachCount:!1,league:!1},qo={tooltip:{sx:{maxWidth:360,backgroundColor:"#1A2027",borderRadius:"10px",px:1.5,py:1}},arrow:{sx:{color:"#1A2027"}}},I={numericText:{fontSize:"14px",color:"text.primary",textAlign:"center"},avatar:{fontSize:"14px"},cellText:{fontSize:"13px",color:"text.primary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},secondaryText:{fontSize:"12px",color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},Jo=(u,R,ne,q={})=>u==null?void 0:u.map(d=>{var re,ge,Se,ye,ie;const ae=(re=d==null?void 0:d.player_names)==null?void 0:re.map(D=>({name:D})),C=(ge=d==null?void 0:d.coach_names)==null?void 0:ge.map(D=>({name:D})),n=(d.fixtureResults||[]).slice(-6),h=d.nextFixture,j=d.nextSession,M=(Se=ho.find(D=>D.id===d.gender))==null?void 0:Se.name,X=(ye=Wt.find(D=>D.id===d.age_group))==null?void 0:ye.label,F=q[d.id],z=F?F.noData?t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",gap:.75,py:.25},children:[t.jsx($t,{sx:{fontSize:16,mt:"2px",flexShrink:0}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:F.text})]}):t.jsxs(_,{sx:{display:"flex",flexDirection:"column",gap:1,py:.25},children:[F.strength&&t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",gap:.75},children:[t.jsx(Rt,{sx:{fontSize:16,mt:"2px",flexShrink:0,color:"#FFD54F"}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:F.strength})]}),F.improve&&t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",gap:.75},children:[t.jsx(Bt,{sx:{fontSize:16,mt:"2px",flexShrink:0,color:"#90CAF9"}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:F.improve})]})]}):null,J=t.jsxs(E,{container:!0,gap:2,wrap:"nowrap",alignItems:"center",children:[t.jsx(E,{children:t.jsx(Lt,{sx:I.avatar,src:d.logo?`${Ze}/${d.logo}`:"",alt:d.name,height:"40px",width:"40px",slotProps:{img:{loading:"lazy",decoding:"async"}},children:(ie=d==null?void 0:d.name)==null?void 0:ie.split(" ").slice(0,2).map(D=>D[0]).join("").toUpperCase()})}),t.jsx(E,{flex:1,sx:{width:"100px"},children:t.jsx(f,{fontSize:14,fontWeight:600,color:"text.primary",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.name})})]});return{id:d.id,locked:!!(R.planId===1&&O().isSameOrAfter(O(R.endDate),"day")&&d.id!==ne),name:z?t.jsx(Qe,{title:z,arrow:!0,placement:"top-start",enterDelay:400,slotProps:qo,children:J}):J,age_group:t.jsx(f,{sx:I.cellText,children:X||"—"}),gender:t.jsx(f,{sx:I.cellText,children:M||"—"}),formation_name:t.jsx(f,{sx:I.cellText,children:d.formation_name||"—"}),record:n.length>0?t.jsx(E,{container:!0,gap:.5,flexWrap:"nowrap",children:n.map((D,H)=>{const le=D.result===1,g=D.result===2;return t.jsx(_,{sx:{width:"22px",height:"22px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,backgroundColor:le?"#E8F5E9":g?"#FFEBEE":"#FFF3E0",color:le?"#2E7D32":g?"#C62828":"#E65100"},children:le?"W":g?"L":"D"},H)})}):t.jsx(f,{sx:I.secondaryText,children:"—"}),nextFixture:h?t.jsxs(_,{sx:{maxWidth:"180px"},children:[t.jsxs(f,{sx:I.cellText,children:["vs ",h.opposition]}),t.jsx(f,{sx:I.secondaryText,children:O(Number(h.date)).format("ddd D MMM, h:mma")})]}):t.jsx(f,{sx:I.secondaryText,children:"—"}),nextSession:j?t.jsxs(_,{sx:{maxWidth:"180px"},children:[t.jsx(f,{sx:I.cellText,children:j.name||"Session"}),t.jsx(f,{sx:I.secondaryText,children:O(Number(j.date)).format("ddd D MMM, h:mma")})]}):t.jsx(f,{sx:I.secondaryText,children:"—"}),playerCount:t.jsx(fe,{data:ae,children:t.jsx(f,{sx:I.numericText,children:d.playerCount})}),coachCount:t.jsx(fe,{data:C,children:t.jsx(f,{sx:I.numericText,children:d.coachCount})}),league:t.jsx(f,{sx:I.cellText,children:d.league||"—"})}}),Pt={searchContainer:{padding:2,gap:1,background:u=>u.palette.common.white,borderBottom:u=>`1px solid ${u.palette.divider}`,alignItems:"center"},searchCustomStyles:{maxWidth:{xs:"100%",sm:"320px"}}},ma=()=>{var jt,_t,wt;const{t:u}=Dt("common"),{t:R}=Dt("dugout"),ne=Vo(R),q=fo(),d=Ls(),ae=go(),C=Ae(e=>{var s;
1return(s=e==null?void 0:e.teams)==null?void 0:s.team}),T=Ae(e=>e.club),n=Ws(),{currentSeason:h,isAllSeasonSelected:j,isReadOnlyMode:M}=Us(),{isPlaymaker:X,openUpgradeModal:F}=Gs(),z=Ae(e=>e.user.userPermission),J=Ae(e=>{var s,i;return((i=(s=e==null?void 0:e.app)==null?void 0:s.dataViews)==null?void 0:i.teams)||"grid"}),{getClubDetails:re}=Po(),[ge]=Ye(Co,{update:At}),[Se]=Ye(To,{update:At}),[ye]=Ye(jo),[ie,D]=r.useState(""),[H,le]=r.useState(""),[g,Xe]=r.useState([]),[K,ke]=r.useState(-1),[P,ce]=r.useState({}),[Ne,Ut]=r.useState([]),[be,Gt]=r.useState(Ot),[Ce,zt]=r.useState("asc"),[Te,Oe]=r.useState(0),[Pe,Ke]=r.useState(0),[de,Ht]=r.useState(50),[Vt,et]=r.useState(null),[qt,tt]=r.useState(null),[st,Jt]=r.useState({}),[Yt,ue]=r.useState(((jt=q==null?void 0:q.state)==null?void 0:jt.openManageModal)||!1),[Qt,Zt]=r.useState(!1),[Xt,$e]=r.useState(!1),[Kt,Re]=r.useState(!1),[ee,ot]=r.useState(!1),[Be,te]=r.useState(!1),[Le,We]=r.useState(!1),A=r.useRef(null),se=r.useRef(0),[es,ts]=r.useState({}),[je]=zs(),[nt,Ue]=r.useState({}),$=Object.keys(nt).map(Number),[ss,Ge]=r.useState(null),[at,os]=r.useState(!1),rt=Go(),ns=Hs(),{selectedFiles:as,setSelectedFiles:rs,startUploadOnS3:is,s3UploadInProgress:ls}=$o(),{removeFilesFromS3:cs,setDeletedFileNames:it,deletedFileNames:ds}=Ro(),lt=bo.S3_GENERAL_ASSETS_BUCKET,oe=Ns(e=>e.breakpoints.down("md")),[ct,ze]=r.useState(null),[us,ms]=r.useState([]),[dt,ps]=r.useState({}),[xs,He]=r.useState(null),[_e,hs]=r.useState({value:null,order:"ASC"}),me=z.planId===1&&O().isSameOrAfter(O(z.endDate),"day"),ut=z.planId===1&&T.teamsCount>=z.permission.teams,Y=(_t=n==null?void 0:n.userRolesPermissions)==null?void 0:_t.permissions.dugout.teams,fs={...Y,isReadOnlySeason:M},mt=({target:{value:e}})=>{gs(e),D(e)},gs=r.useCallback(Vs(e=>{Oe(0),Xe([]),Ke(0),le(e)},1e3),[]),pt=(e,s)=>{s&&d(Ys({teams:s}))},{data:we}=zo(mo,{variables:{coachListInput:{club_id:n!=null&&n.club_id?n==null?void 0:n.club_id:T!=null&&T.club_id?T==null?void 0:T.club_id:0}},fetchPolicy:"no-cache"});r.useEffect(()=>{var e;if(we){const{success:s}=we.coachListNew;if(s){const i=(e=we.coachListNew)==null?void 0:e.data.map(({id:a,username:p,lastname:S,profile_image:o,roles:l})=>({id:a,name:`${p} ${S}`,avatar:o?`${Ze}/${o}`:`${p} ${S}`,roles:l}));Ut([...i])}}},[we]);const Ee=async()=>{var a,p,S;A.current&&(A.current.abort(),A.current=null),se.current+=1;const e=se.current,s=JSON.stringify(C!=null&&C.length?C:[]),i=new AbortController;A.current=i,We(!0);try{const o=await rt.query({query:po,variables:{getTeamsInput:{club_id:n!=null&&n.club_id?n==null?void 0:n.club_id:T!=null&&T.club_id?T==null?void 0:T.club_id:0,limit:de,offset:Te*de,team_ids:C,search:H,sortBy:oe?_e.value:Uo(be,y=>y===!0),sortOrder:oe?_e.order:Ce,filter:dt,...j?{}:{season_id:h==null?void 0:h.id}}},skip:!(n!=null&&n.club_id)||!(h!=null&&h.id),fetchPolicy:"no-cache",context:{fetchOptions:{signal:i.signal}}}),l=JSON.stringify(C!=null&&C.length?C:[]);if(se.current!==e||i.signal.aborted||s!==l)return;const m=o==null?void 0:o.data;if(m!=null&&m.getTeams){const{success:y}=m.getTeams;if(y&&se.current===e&&!i.signal.aborted){const x=(a=m==null?void 0:m.getTeams)==null?void 0:a.data,b=(S=(p=m==null?void 0:m.getTeams)==null?void 0:p.metadata)==null?void 0:S.count;Ke(b),Xe(x),b===1&&Ss()}}}catch(o){if(o.name==="AbortError"||i.signal.aborted)return;se.current===e&&console.error("Error fetching teams list:",o)}finally{se.current===e&&A.current===i&&(We(!1),A.current=null)}},Ss=async()=>{var a,p;const e=await rt.query({query:xo,fetchPolicy:"no-cache",variables:{id:n==null?void 0:n.id}}),s=(p=(a=e==null?void 0:e.data)==null?void 0:a.userDetails)==null?void 0:p.data,i=JSON.parse(s).primary_team;d(Ks({primary_team:i}))};r.useEffect(()=>(A.current&&(A.current.abort(),A.current=null,We(!1)),n!=null&&n.club_id&&(h!=null&&h.id)&&Ee(),()=>{A.current&&(A.current.abort(),A.current=null)}),[Te,de,C==null?void 0:C.length,H,Ce,be,_e,dt,h==null?void 0:h.id]);const xt=(e,s)=>{Oe(s)},ht=({target:{value:e}})=>{Ht(e),Oe(0)},ys=e=>{const i=be[e]&&Ce==="asc"?"desc":"asc";zt(i),Gt({...Ot,[e]:!0})},Me=()=>{me&&!Pe?ue(!0):me||ut?Re(!0):ue(!0)},ft=()=>{ue(!1),ke(-1),ce({}),ot(!1)},bs=()=>{},Cs=()=>{Zt(!1)},gt=()=>{if($.length===1){const e=g.find(s=>
1$.includes(s.id));ce(e),$e(!0)}else $e(!0)},St=()=>{$e(!1),ke(-1),Ue({}),ce({})},Ts=()=>{const{id:e,name:s,description:i,league:a,ground_name:p,age_group:S,team_coaches:o,logo:l,formatId:m,formationId:y,matchDuration:x,periods:b,session_duration:v,number_of_practices:B,session_focus:L,session_breakdown:k,pitch_area:V,session_per_week:w,training_days:N,training_times:pe,default_objective_start_date:xe,default_objective_duration_weeks:Ie,gender:W,type:Ve,age_group_max:Fe}=g[K];ce({id:e,name:s,description:i,league:a,gender:W||"",groundName:p,ageGroup:S,ageGroupMax:Fe||"",teamType:Ve||"team",coaches:kt(Ne,({id:ve})=>o==null?void 0:o.includes(ve)),profileImage:l,format:m,formation:y,matchDuration:x,periods:b,sessionDuration:v,numberOfPractices:B,sessionFocus:L,sessionBreakdown:k,pitchArea:V,sessionPerWeek:w,trainingDays:(N==null?void 0:N.split(","))||[],trainingTimes:pe||[],defaultObjectiveStartDate:xe||""}),ue(!0)},js=()=>{if(ut||me)Re(!0);else{const{id:e,name:s,description:i,league:a,ground_name:p,age_group:S,team_coaches:o,formatId:l,formationId:m,matchDuration:y,periods:x,session_duration:b,number_of_practices:v,session_focus:B,session_breakdown:L,pitch_area:k,session_per_week:V,training_days:w,gender:N,type:pe,age_group_max:xe}=g[K];ce({id:e,name:s,description:i,league:a,gender:N||"",groundName:p,ageGroup:S,ageGroupMax:xe||"",teamType:pe||"team",coaches:kt(Ne,({id:Ie})=>o==null?void 0:o.includes(Ie)),profileImage:"",format:l,formation:m,matchDuration:y,periods:x,sessionDuration:b,numberOfPractices:v,sessionFocus:B,sessionBreakdown:L,pitchArea:k,sessionPerWeek:V,trainingDays:(w==null?void 0:w.split(","))||[]}),ot(!0),ue(!0)}},_s=async(e,s)=>{var o,l,m,y;if(te(!0),e.uploadImage)if(await is("",lt))e.profileImage=(o=as[0])==null?void 0:o.name;else{je({msg:"Unable to upload file at the moment",variant:"error"}),te(!1);return}if(ds.length>0&&!await cs(lt)){je({msg:"Unable to delete file at the moment",variant:"error"}),te(!1);return}const i={name:e.name,ground_name:e.groundName,league:e.league,admin:n.id,gender:e.gender||null,description:e.description,age_group:e.ageGroup,logo:e.profileImage||"",team_coaches:Qs(e.coaches),team_players:Q(P)?[]:g[K].team_players||[],club_id:n.club_id?n.club_id:T.club_id?T.club_id:0,edit:Q(P)?!1:!ee,id:Q(P)||ee?0:P.id,formatId:e.format,formationId:e.formation,matchDuration:e.matchDuration,periods:e.periods,session_duration:e.sessionDuration,number_of_practices:e.numberOfPractices,session_focus:e.sessionFocus,session_breakdown:e.sessionBreakdown,pitch_area:e.pitchArea,session_structure_type_ids:e.selectedSessionStructureType.map(x=>+x.id),session_per_week:e.sessionPerWeek,training_days:e.trainingDays.join(","),training_times:e.trainingTimes,default_objective_start_date:e.defaultObjectiveStartDate?(()=>{const x=new Date(e.defaultObjectiveStartDate);return Number.isNaN(x.getTime())?null:x.toISOString().slice(0,10)})():null,season_id:h==null?void 0:h.id,type:e.teamType||"team",age_group_max:e.ageGroupMax||null},{data:{createTeam:a}}=await ge({variables:i});if(a.success&&e.teamType==="group"&&((l=e.subgroups)==null?void 0:l.length)>0&&(h!=null&&h.id)){const x=Q(P)||ee?a.id:P.id;await ye({variables:{team_id:x,season_id:h.id,subgroups:e.subgroups.map((b,v)=>({...b.id&&!ee&&!Q(P)?{id:b.id}:{},name:b.name,color:b.color||null,order:v+1}))}})}a.success&&(Q(P)||ee)&&!me?(ns.capture(Zs.DUGOUT_ADDED_TEAM,{customData:{teamId:a==null?void 0:a.id,userId:n==null?void 0:n.id,email:n==null?void 0:n.email,clubId:n==null?void 0:n.club_id,roles:(y=(m=n==null?void 0:n.userRolesPermissions)==null?void 0:m.roles)==null?void 0:y.map(x=>x.name)}}),d(Ft([...C,a.id]))):Ee(),it([]);const{success:p,message:S}=a;p&&(je({msg:S||"Team created. Add players to get started",variant:"success"}),ft(),s(),re(n.club_id),te(!1))},ws=async()=>{te(!0);const e=($==null?void 0:$.length)>0?$:[g[K].id],{data:s}=await Se({variables:{team_ids:e,season_id:h==null?void 0:h.id}}),{success:i,message:a}=s.deleteTeams;i&&!me?(d(Ft([...eo(C,e)])),re(n.club_id),je({msg:a||"Team Deleted",variant:"success"})):Ee(),St(),te(!1),Ue({})},De=e=>{if(X){F(It.dugoutTeams);return}ae(`/dugout/team/${g[e].id}`)},Es=e=>{},yt=()=>{os(!at)},bt=()=>{Ge(null)},Ms=async()=>
1{if(X){bt(),F(It.dugoutTeams);return}const s=await(await fetch(to)).blob(),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download="touchtight-teams-template.xlsx",document.body.appendChild(a),a.click(),document.body.removeChild(a)},Ds=(e,s)=>e.filter(i=>Xs(i.name)==="downloadTemplate"?s.manage===Z.YES:s.add===Z.YES),Is=(e,s,i)=>{ps(a=>{const p=a[e]||[],S=i.every(o=>p.includes(o));return{...a,[e]:S?p.filter(o=>!i.includes(o)):[...p,...i.filter(o=>!p.includes(o))]}}),ms(a=>a.some(p=>p===s)?a.filter(p=>p!==s):[...a,s])},Fs=e=>{hs(s=>s.value===e?{value:e,order:s.order==="ASC"?"DESC":"ASC"}:{value:e,order:"DESC"})},vs=[{name:"View",icon:Rs,iconCustomStyles:{width:"20px",height:"20px"},onClick:()=>De(K)},{name:"Manage",icon:so,onClick:Ts},{name:"Duplicate",icon:oo,onClick:js},{name:"Delete",icon:no,onClick:gt}],As=[{name:"Download Template",onClick:Ms},...M?[]:[{name:"Import Teams",onClick:yt}]],Ct=r.useMemo(()=>{if(!(g!=null&&g.length))return[];const e=[],s=g.filter(o=>(o.matchesPlayed||0)>0);if(s.length>0){const o=[...s].sort((l,m)=>{const y=(l.winCount||0)/l.matchesPlayed,x=(m.winCount||0)/m.matchesPlayed;return x!==y?x-y:(m.winCount||0)-(l.winCount||0)})[0];e.push({key:"bestRecord",label:"Best Record",team:o,value:`W${o.winCount||0} D${o.drawCount||0} L${o.lossCount||0}`,color:"#2E7D32",bg:"#E8F5E9"})}const i=g.filter(o=>(o.goalsScored||0)>0);if(i.length>0){const o=[...i].sort((l,m)=>(m.goalsScored||0)-(l.goalsScored||0))[0];e.push({key:"topGoals",label:"Top Goals",team:o,value:`${o.goalsScored} goals`,color:"#E53935",bg:"#FFEBEE"})}const a=g.filter(o=>(o.fixtureResults||[]).length>0);if(a.length>0){const o=[...a].sort((x,b)=>{const v=k=>(k||[]).slice(-6).reduce((V,w)=>V+(w.result===1?3:w.result===3?1:0),0),B=v(x.fixtureResults),L=v(b.fixtureResults);return L!==B?L-B:(b.fixtureResults||[]).slice(-6).filter(k=>k.result===1).length-(x.fixtureResults||[]).slice(-6).filter(k=>k.result===1).length})[0],l=(o.fixtureResults||[]).slice(-6),m=l.map(x=>x.result===1?"W":x.result===2?"L":"D").join(""),y=l.reduce((x,b)=>x+(b.result===1?3:b.result===3?1:0),0);e.push({key:"bestForm",label:"Best Form",team:o,value:`${m} (${y}pts)`,color:"#F9A825",bg:"#FFF8E1"})}const p=g.filter(o=>{var l;return(l=o.nextFixture)==null?void 0:l.date}).sort((o,l)=>Number(o.nextFixture.date)-Number(l.nextFixture.date));if(p.length>0){const o=p[0];e.push({key:"nextFixture",label:"Next Fixture",team:o,value:`vs ${o.nextFixture.opposition} · ${O(Number(o.nextFixture.date)).format("ddd D MMM")}`,color:"#2E7D32",bg:"#E8F5E914"}),p.slice(1,4).forEach((l,m)=>{e.push({key:`nextFixture-${m+1}`,label:"",team:l,value:`vs ${l.nextFixture.opposition} · ${O(Number(l.nextFixture.date)).format("ddd D MMM")}`,color:"#2E7D32",bg:"#2e7d3208"})})}const S=g.filter(o=>{var l;return(l=o.nextSession)==null?void 0:l.date}).sort((o,l)=>Number(o.nextSession.date)-Number(l.nextSession.date));if(S.length>0){const o=S[0];e.push({key:"nextSession",label:"Next Session",team:o,value:`${o.nextSession.name||"Session"} · ${O(Number(o.nextSession.date)).format("ddd D MMM")}`,color:"#2F80ED",bg:"#E3F2FD"}),S.slice(1,4).forEach((l,m)=>{e.push({key:`nextSession-${m+1}`,label:"",team:l,value:`${l.nextSession.name||"Session"} · ${O(Number(l.nextSession.date)).format("ddd D MMM")}`,color:"#2F80ED",bg:"#2f80ed08"})})}return e},[g]),Tt=r.useMemo(()=>{const e={};return(g||[]).forEach(s=>{e[s.id]=Wo(s)}),e},[g]),ks=e=>e.map((s,i)=>{var Fe,ve,Et;const a=(Fe=s==null?void 0:s.player_names)==null?void 0:Fe.map(c=>({name:c})),p=(ve=s==null?void 0:s.coach_names)==null?void 0:ve.map(c=>({name:c})),S=(Et=Wt.find(c=>c.id===s.age_group))==null?void 0:Et.label,o=s.winCount||0,l=s.lossCount||0,m=s.drawCount||0,y=s.fixtureResults||[],x=c=>{if(!c)return"";const he=new Date(Number(c));return`${String(he.getDate()).padStart(2,"0")} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][he.getMonth()]}`},b=c=>c===1?"Win":c===2?"Loss":"Draw",v=c=>({name:`${c.date?`${x(c.date)}: `:""}${c.name} (${c.score} ${b(c.result)})`}),B=y.filter(c=>c.result===1).map(v),L=y.filter(c=>c.result===3).map(v),k=y.filter(c=>c.result===2).map(v),V=y.slice(-5).map(c=>({label:c.result===1?"W":c.result===2?"L":"D",colorType:c.result===1?"win":c.result===2?"loss":"yellow",tooltipData:[v(c)]})),w=s.nextFixture,N=s.nextSession,pe=w?`vs ${w.opposition} · ${O(Number(w.date)).format("ddd D MMM, h:mma")}`:null,xe=N?`${N.name||"Session"} · ${O(Number(N.date)).format("ddd D MMM, h:mma")}`:null,Ie=[...s.type==="group"?[{id:`type-${s.id}`,label:"Training Group",colorType:"yellow"}]:[],...s.formation_name?[{id:`formation-${s.id}`,label:s.formation_name,colorType:"gray"}]:[],...S?[{id:`age-${s.id}`,label:S,colorType:"blue"}]:[]],W=Tt[s.id],Ve=W?W.noData?t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",ga
1p:.75,py:.25},children:[t.jsx($t,{sx:{fontSize:16,mt:"2px",flexShrink:0}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:W.text})]}):t.jsxs(_,{sx:{display:"flex",flexDirection:"column",gap:1,py:.25},children:[W.strength&&t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",gap:.75},children:[t.jsx(Rt,{sx:{fontSize:16,mt:"2px",flexShrink:0,color:"#FFD54F"}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:W.strength})]}),W.improve&&t.jsxs(_,{sx:{display:"flex",alignItems:"flex-start",gap:.75},children:[t.jsx(Bt,{sx:{fontSize:16,mt:"2px",flexShrink:0,color:"#90CAF9"}}),t.jsx(f,{component:"span",sx:{fontSize:"13px",lineHeight:1.4},children:W.improve})]})]}):null;return{id:s.id,primaryAvatarName:s.name,primaryAvatar:s.logo,primaryText:s.name,primaryTooltipOverride:Ve,chips:Ie,footer:[{heading:"W",text:`${o}`,tooltipTitle:B.length?B:void 0},{heading:"L",text:`${l}`,tooltipTitle:k.length?k:void 0},{heading:"D",text:`${m}`,tooltipTitle:L.length?L:void 0}],secondaryTextElement:t.jsxs(E,{container:!0,direction:"column",gap:1,justifyContent:"center",alignItems:"center",sx:{overflow:"hidden",width:"100%"},children:[t.jsxs(E,{container:!0,justifyContent:"center",alignItems:"center",gap:2,children:[t.jsxs(E,{container:!0,gap:"4px",alignItems:"center",sx:{width:"auto"},children:[t.jsxs(f,{sx:{fontSize:"13px",color:"text.secondary"},children:["Players: ",s.playerCount||"0"]}),t.jsx(fe,{data:a,children:t.jsx(Nt,{})})]}),t.jsxs(E,{container:!0,gap:"4px",alignItems:"center",sx:{width:"auto"},children:[t.jsxs(f,{sx:{fontSize:"13px",color:"text.secondary"},children:["Coaches: ",s.coachCount||"0"]}),t.jsx(fe,{data:p,children:t.jsx(Nt,{})})]})]}),t.jsxs(_,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:.5,overflow:"hidden"},children:[t.jsxs(_,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1,px:1.5,py:.5,borderRadius:"8px",backgroundColor:w?"#2e7d3214":"#919EAB14",overflow:"hidden"},children:[t.jsx(f,{sx:{fontSize:"11px",fontWeight:700,color:w?"#2E7D32":"#919EAB",whiteSpace:"nowrap",flexShrink:0},children:"NEXT FIXTURE:"}),t.jsx(f,{sx:{fontSize:"12px",color:w?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:pe||"None scheduled"})]}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1,px:1.5,py:.5,borderRadius:"8px",backgroundColor:N?"#2f80ed14":"#919EAB14",overflow:"hidden"},children:[t.jsx(f,{sx:{fontSize:"11px",fontWeight:700,color:N?"#2F80ED":"#919EAB",whiteSpace:"nowrap",flexShrink:0},children:"NEXT SESSION:"}),t.jsx(f,{sx:{fontSize:"12px",color:N?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:xe||"None scheduled"})]})]}),V.length>0&&t.jsx(E,{container:!0,gap:.5,justifyContent:"center",alignItems:"center",children:V.map((c,he)=>t.jsx(fe,{data:c.tooltipData,children:t.jsx("span",{children:t.jsx(lo,{label:c.label,colorType:c.colorType})})},he))})]}),handleOnClick:()=>De(i)}});return t.jsxs(t.Fragment,{children:[t.jsx(Fo,{title:u("team.teams"),showPrimaryBtn:oe?!1:Y.add===Z.YES&&!M,showSecondaryBtn:oe?!1:n==null?void 0:n.isAdmin,primaryBtnText:"Add Team",secondaryBtnText:M?"Export":"Import / Export",primaryBtnIcon:t.jsx(qe,{}),primaryBtnHandler:Me,secondaryBtnHandler:e=>{Ge(e.currentTarget)}}),oe?t.jsx(No,{view:J,search:ie,showImportAndExportBtn:!0,primaryBtnText:"Add Team",handleChangeView:pt,handleChangeSearch:mt,primaryBtnHandler:Me,showPrimaryBtn:Y.add===Z.YES&&!M,handleOpenFilterMenu:e=>ze(e.currentTarget),handleOpenSortMenu:e=>He(e.currentTarget),handleOpenExportAndImportMenu:e=>{Ge(e.currentTarget)}}):t.jsxs(E,{container:!0,sx:Pt.searchContainer,alignItems:"center",children:[t.jsx(E,{flex:1,children:t.jsx(uo,{name:"search",value:ie,onChange:mt,customStyles:Pt.searchCustomStyles})}),t.jsxs(E,{container:!0,gap:.5,alignItems:"center",width:"auto",children:[t.jsx(Qe,{title:"Sort",children:t.jsx(Mt,{onClick:e=>He(e.currentTarget),size:"small",children:t.jsx(Os,{})})}),t.jsx(Qe,{title:"Filter",children:t.jsx(Mt,{onClick:e=>ze(e.currentTarget),size:"small",children:t.jsx(Ps,{})})}),t.jsx(vo,{value:J,handleChange:pt,iconHeight:16,iconWidth:16,customStyles:{borderRadius:"8px",height:"32px",padding:"2px","& .MuiToggleButtonGroup-root":{height:"100%"},"& .MuiToggleButtonGroup-root .MuiButtonBase-root":{height:"100%"}}})]})]}),$.length>0&&t.jsx(ro,{items:$,title:"Teams",deleteBtnText:"Teams",handleDeleteMultiple:gt}),Ct.length>0&&!Le&&t.jsx(_,{sx:{display:"flex",gap:1,px:2,py:{xs:1,sm:1.5},overflowX:"auto",backgroundColor:"common.white",position:"relative",zIndex:1,"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:Ct.map(e=>{var s;return t.jsx($s,{avatar:t.jsx(Lt,{src:e.team.logo?`${Ze}/${e.team.logo}`:"",sx:{width:24,height:24},children:(s=e.team.name)==null?void 0:s[0]}),label:`${e.label?`${e.label}: `:""}${e.team.name} (${e.value})`,onClick:()=>{const i=g.findIndex(a=>a.id===e.team.id);i>=0&&De(i)},sx:{height:32,borderRadius:"16px",fontSize:"12px",fontWeight:600,backgroundColor:e.bg,border:"1px solid",borderColor:`${e.color}40`,color:e.color,cursor:"pointer",flexShrink:0,"& .MuiChip-label":{color:"text.primary"},"&:hover":{backgroundColor:`${e.color}30`,borderColor:e.color,boxShadow:`0 0 0 1px ${e.color}40`}}},e.key)})}),t.jsx(_,{height:{xs:"unset",lg:J==="gird"?"unset":$.length?"calc(100% - 255px)":"calc(100% - 185px)"},children:Le?t.jsx(qs,{}):J==="list"?t.jsx(io,{isSelectable:!M&&Y.delete!==Z.NO,selected:nt,setSelected:Ue,isRowClickable:!0,handleRowClick:e=>De(e),page:Te,count:Pe,data:Jo(g,z,n.primary_team,Tt),headCells:ne.map(e=>({...e,sort:oe?!1:e.sort})),rowsPerPage:de,handleChangePage:xt,handleChangeRowsPerPage:ht,sortOrder:Ce,sort:be,sortHandler:ys,setAnchorEl:(e,s,i,a)=>{i?(tt(e),Jt({...a})):(et(e),ke(s))},stickyPagination:!0,canEdit:!M,emptyContentTitle:"No Teams Found",emptyContentDescription:H?"No teams match your search. Try a different search term.":"Create your first team to start organising players and fixtures.",emptyContentAction:!H&&Y.add===Z.YES&&!M?t.jsx(vt,{text:"Add Team",startIcon:t.jsx(qe,{}),onClick:Me}):null}
1):t.jsx(Do,{cards:ks(g),loading:Le,page:Te,count:Pe,rowsPerPage:de,handleChangePage:xt,handleChangeRowsPerPage:ht,emptyContentTitle:"No Teams Found",emptyContentDescription:H?"No teams match your search. Try a different search term.":"Create your first team to start organising players and fixtures.",emptyContentAction:!H&&Y.add===Z.YES&&!M?t.jsx(vt,{text:"Add Team",startIcon:t.jsx(qe,{}),onClick:Me}):null})}),t.jsx(Je,{items:Js(vs,fs),anchorEl:Vt,handleClose:()=>et(null),enableDividers:!1,itemHeight:"54px",itemPadding:"22px 24px"}),t.jsx(Je,{items:[{name:"Filter",onClick:bs},{name:"Hide",onClick:()=>{}}],anchorEl:qt,handleClose:()=>tt(null),enableDividers:!1,itemHeight:"54px",itemPadding:"22px 24px"}),t.jsx(Lo,{open:Yt,actionBtnTitle:Q(P)?"Save Team":ee?"Duplicate Team":"Update Team",handleClose:ft,coachList:Ne,handleSubmitTeam:_s,selectedTeam:P,loading:Be||ls,setSelectedFiles:rs,setDeletedFileNames:it}),t.jsx(Ho,{open:Qt,handleClose:Cs,loading:Be,title:st.label,cellId:st.id,filters:es,handleSetFilters:ts,handleApplyFilters:Es}),t.jsx(_o,{handleClose:St,open:Xt,handleDelete:ws,title:"Delete Team?",actionBtnTitle:"Delete Team",entityName:$.length<2?P.name||((wt=g[K])==null?void 0:wt.name):"Teams",loading:Be}),t.jsx(Ao,{open:Kt,handleClose:()=>Re(!1),heading:"Unlock the Teams With a Pro Plan",mainHeading:"Access to Unlimited Teams & Overview Stats",description:"To access more than one team, you must upgrade your subscription plan."}),t.jsx(Je,{width:"160px",items:Ds(As,Y),anchorEl:ss,enableDividers:!1,handleClose:bt}),t.jsx(Bo,{open:at,handleCloseModal:yt,refetch:Ee}),t.jsx(Oo,{anchorEl:ct,open:!!ct,onClose:()=>ze(null),menuData:So,selected:us,handleSelectMenu:Is,maxWidthMenu:"270px"}),t.jsx(ko,{sortMenuAnchor:xs,menuItems:yo,sort:_e,handleChangeSortBy:Fs,setSortMenuAnchor:He})]})};export{ma 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.