PageSourceSearch

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

js touchtight.com collected 2026-10-02 00:02:56 UTC 47,742 bytes, 1 lines download raw bytes

1import{j as e,a}from"./react-vendor-DJtAp8P_.js";import{e as pa,F as Ua,g as ha,d as za,c as Va,u as st,p as Ya,j as Wa,x as Ns,w as Ka,D as Ls,m as de,ck as Ft,a0 as Qa,o as se,cl as Fs,cm as Gs,W as Fa,aA as $s,T as Hs}from"./app-DT7WuczB.js";import{D as Us}from"./hello-pangea-dnd-1bhs5THC.js";import{s as ma}from"./drawer-CKgR88Nl.js";import{b as Nt,a9 as zs,aA as Vs,aq as Ys,ao as Ws,s as qa,aN as Ja,E as Xa,V as Za,aF as es,aH as Ks}from"./swiper-react-DcF17yCe.js";import"./query-CcmDMjHA.js";import{bm as ts,bi as as,aW as re,bB as ra,bI as ot,bK as nt,dp as ss,cj as os,dc as Qs,aT as qs,bX as Js,cn as Xs,bA as Zs}from"./index-CyS3LFy6.js";import{at as ns,ar as is,bg as eo}from"./mutation--iSLlBrt.js";import"./dayjs-CFxoC4n5.js";import"./moment-Bj79pgB5.js";import{u as to}from"./index.esm-CWqXbt53.js";import{M as da}from"./SessionPlannerMobile-85wkJ1ZS.js";import{T as ao}from"./Tabs-lVcpmzV2.js";import{U as Gt}from"./UpgradePlanModal-Cx-12O2U.js";import{I as so}from"./InlineHint-BwtPd7HF.js";import{P as oo,M as no}from"./Gate-DNpeketG.js";import{g as Ga}from"./token-j6514cz0.js";import{S as $t}from"./DugoutSession-CuhTFEh0.js";import{S as ca}from"./SessionPlannerGraphic-DlW27AdK.js";import{S as $a}from"./SessionTemplate-CclCxoG6.js";import{S as ua}from"./Manage-BcZiAr0H.js";import{S as ls}from"./Copy-Bx2E8fMZ.js";import{S as rs}from"./DeleteGray-K_LbbGcc.js";import{S as io}from"./Download-Bk4TTf4W.js";import{S as ds}from"./Share-AFIreKiA.js";import{B as cs}from"./index-_emSioTI.js";import{S as us}from"./AddToGlobalLibrary-D0Dz9Ui3.js";import{B as Le}from"./Button-C4goEOKP.js";import{s as ps}from"./imageOptimization-zUL1CBPb.js";import{D as hs}from"./DeleteModal-BX6BaNP3.js";import{S as ms}from"./SearchHeader-BOq_PWig.js";import{A as Ht}from"./AlertModal-CGXcj45Q.js";import{D as fs}from"./DroppableWrapper-BV3SYTIO.js";import{D as Ss}from"./DraggableWrapper-C7z6XFG8.js";import{A as gs}from"./AddPracticeToSessionModalGate-BB6n61YO.js";import{A as lo}from"./AddPracticeToSessionTemplateModal-LyU9_1Zk.js";import{T as ro,g as co}from"./ToolChooserModal-Bja6F0-n.js";import{D as uo,Q as po,a as ho}from"./QuickPreviewSessionDrawer-FdfS-nq9.js";import{M as mo}from"./ManagePracticeModal-CuLKk-Zk.js";import{M as fo}from"./Modal-BzPnYVEi.js";import{z as I,u as it,b5 as So,w as Ut,j as Se,bB as zt,R as ys,E as ce,cO as go,S as yo,a7 as bo,T as Qe}from"./mui-DvP2hOwX.js";import{o as bs}from"./omitBy-CVfI2Mdq.js";import{n as lt}from"./apollo-DL0KWP0Y.js";import{P as xo}from"./PlaylistThumbnail-BQGQtBTO.js";import{S as Co}from"./PDFGray-nAIXNVuQ.js";import{G as Eo}from"./GeneratePdfModal-DqRQcpgJ.js";import{c as Ha}from"./compact-DZdspzxW.js";import{o as _o}from"./omit-BaIHraq0.js";import{g as vo}from"./groupBy-BsGpKOH5.js";import{m as wo}from"./mapKeys-BOig4Tgf.js";import{S as To}from"./SideDrawer-BEXrdiXt.js";import"./mui-styles-C9F12l22.js";import"./babel-helpers-D2wBBc1I.js";import"./Search-BEYvHCFs.js";import"./lodash-icp7yO-G.js";import"./merge-TfBrBrIh.js";import"./_baseAssignValue-CjtYt4eh.js";import"./_baseClone-DByvJCmO.js";import"./isArrayLikeObject-CcVCHQro.js";import"./map-BI8CQ8np.js";import"./browser-B3fhYDhb.js";import"./_arrayIncludes-DFQcso6E.js";import"./_baseIndexOf-DqPIyCu4.js";import"./some-YFJAbcVi.js";import"./values-DeBIqcD0.js";import"./index-B79atc36.js";import"./_baseDifference-BHjDay7E.js";import"./index-bEsv4Yks.js";import"./mui-x-DMY3qA32.js";import"./s3FileHandler-Bp64keCt.js";import"./cloneDeep-mVQ3twB2.js";import"./ArrowRightUp-CfAFwt7J.js";import"./Graphic-BzX0DM42.js";import"./select-BkBd-IXy.js";import"./index-DbR5jsy0.js";import"./index-C53T7JDS.js";import"./floating-ui.dom-CpqR1Q5s.js";import"./index-CMsqgI2o.js";import"./chevron-down-D9vZfud1.js";import"./check-njpSxvzl.js";import"./chevron-up-Cdk80VBZ.js";import"./Filter-vdZeYdaV.js";import"./SearchBlue-Cq--C03-.js";import"./seededSessionFill-BljGszd4.js";import"./popover-DQmY_bgT.js";import"./index-CrwW5ro-.js";import"./subMonths-CpZP7vPB.js";import"./chevron-left-hHkvU2-n.js";import"./chevron-right-Bx281FLM.js";import"./sessionSections-a-lprBoU.js";import"./index-CvVUxn0l.js";import"./index-Cor9x_UP.js";import"./checkbox-BCFY1QRf.js";
1import"./input-CuTRSUQZ.js";import"./editable-input-BbmoAFqJ.js";import"./label-DlgL8a7V.js";import"./plus-jTnJ9Ylg.js";import"./arrow-right-CPcr9UUY.js";import"./funnel-CHKnj2yC.js";import"./Checkbox-BfyNlPRU.js";import"./ToggleButton-mhLknYBH.js";import"./startCase-BXgY2jSl.js";import"./ClubNotes-CwYSQnQ2.js";import"./CoachNotesNew-Bns5SEHM.js";import"./TeamSession-D26LimVZ.js";import"./TextareaAutosize-t2TCv3sg.js";import"./SwiperSlider-DSKI-lr8.js";import"./UnChecked-CFhuOM22.js";/* empty css                   */import"./joi-browser.min-DZtZ1q_t.js";import"./isNumber-C5LS83rw.js";import"./_basePickBy-jHhPNsuZ.js";import"./FileSaver.min-CVXvx7px.js";import"./FullDescriptionHorizontal-BNtxhPy5.js";try{let i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new i.Error().stack;d&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[d]="f04b7935-a72d-4f88-b743-0daf36d16381",i._sentryDebugIdIdentifier="sentry-dbid-f04b7935-a72d-4f88-b743-0daf36d16381")}catch{}const Po=i=>async d=>{try{return await d({type:"SET_SESSION_PLANNER_PRACTICE_MODAL_OPEN",payload:i})}catch{}},xs=({open:i,handleClose:d,actionHandler:m,selectedFilters:b={},showPractice:E=!1,showSession:k=!1})=>{const _=to({initialValues:b,enableReinitialize:!0,onSubmit:P=>{m(P)}});return e.jsx(fo,{open:i,title:"Filters",handleClose:d,actionHandler:_.handleSubmit,actionBtnTitle:"Apply Filters",dialogMaxWidth:"md",children:e.jsxs(I,{container:!0,spacing:3,children:[E&&e.jsx(I,{size:{xs:6,md:4},children:e.jsx(Nt,{multiple:!0,name:"practice_type_id",label:"Practice Type",options:zs,value:_.values.practice_type_id||[],onChange:_.handleChange})}),k&&e.jsx(I,{size:{xs:6,md:4},children:e.jsx(Nt,{multiple:!0,name:"session_type_id",label:"Session Type",options:Vs,value:_.values.session_type_id||[],onChange:_.handleChange})}),e.jsx(I,{size:{xs:6,md:4},children:e.jsx(Nt,{multiple:!0,name:"language",label:"Language",options:Ys,value:_.values.language||[],onChange:_.handleChange})}),e.jsx(I,{size:{xs:6,md:4},children:e.jsx(Nt,{multiple:!0,name:"age_group_id",label:"Difficulty (Age Group)",options:Ws,value:_.values.age_group_id||[],onChange:_.handleChange})})]})})},Mo=[{key:"actions",title:"Actions",names:["Manage","Edit Animation","Duplicate","Share","Save for Later"]},{key:"add",title:"Add to…",names:["Add to Session","Add to Dugout Session","Add to Session Template","Add to Global Library"]},{key:"export",title:"Export",names:["Download"]},{key:"danger",title:"",names:["Delete"]}],Io=i=>{if(!Array.isArray(i)||i.length===0)return i||[];const d=new Map(i.map(E=>[E.name,E])),m=new Set,b=[];return Mo.forEach((E,k)=>{const _=E.names.map(P=>d.get(P)).filter(Boolean);_.length&&(b.length?b.push({id:`__divider_${E.key}`,disabled:!0,menuItemCustomStyles:{height:"auto",p:0,borderTop:"1px solid",borderColor:"divider",opacity:1,pointerEvents:"none"},component:e.jsx(ce,{sx:{width:"100%",py:.75,px:2},children:E.title&&e.jsx(Qe,{sx:{fontSize:"11px",fontWeight:600,color:"text.secondary",letterSpacing:"0.4px",textTransform:"uppercase"},children:E.title})})}
1):E.title&&b.push({id:`__header_${E.key}`,disabled:!0,menuItemCustomStyles:{height:"auto",p:0,opacity:1,pointerEvents:"none"},component:e.jsx(ce,{sx:{width:"100%",py:.75,px:2},children:e.jsx(Qe,{sx:{fontSize:"11px",fontWeight:600,color:"text.secondary",letterSpacing:"0.4px",textTransform:"uppercase"},children:E.title})})}),_.forEach(P=>{b.push(E.key==="danger"?{...P,color:"#B62916"}:P),m.add(P.name)}))}),i.forEach(E=>{m.has(E.name)||b.push(E)}),b},V={container:{padding:"24px",borderRadius:"0px 0px 16px 16px",backgroundColor:i=>i.palette.common.white},iconBtn:{"& svg":{width:"22px"}},deleteBtn:{color:i=>i.availability.unavailable},btn:{height:"36px",color:"text.primary",textTransform:"none","& svg":{width:"20px",fontSize:"20px !important"},borderColor:i=>i.border,"&:hover":{borderColor:i=>i.border}},divider:{color:i=>i.divider},btnSelect:{maxHeight:{xs:"40px",md:"unset"}},filterBtn:{maxHeight:{xs:"40px",md:"unset"},p:{xs:1,md:"11px 16px"}},menuIcon:{color:"#454F5B",height:"20px",width:"20px"}},Do=({createSessionDrawer:i,currentLibrary:d,currentLibraryType:m,draggedPracticeId:b,setDraggedPractices:E,setDraggedTargetType:k=()=>{}})=>{var xa,Ca,Ea,_a,va,wa,Ta,Pa,Ma,Ia,Da,ja,ka,Aa,Oa;const{t:_}=pa("sessionPlanner"),[P]=Ua(),we=ha(),{isReadOnlyMode:ue,currentSeason:Z}=za(),r=Va(),R=st(t=>{var o;return(o=t==null?void 0:t.user)==null?void 0:o.userPermission}),ge=a.useRef(null),Q=a.useRef(null),{type:pe}=ts(),[H,W]=a.useState(""),[ye,Te]=a.useState(null),Pe=it(t=>t.breakpoints.down("md")),[Fe,Me]=a.useState(null),[be,Ie]=a.useState(null),[Ge,xe]=a.useState(!1),[$e]=lt(ns),[B]=lt(is),q=as(),[oe,G]=a.useState(!1),[qe,ne]=a.useState(null),[ie,De]=a.useState(!1),[Ce,Ee]=a.useState(!1),[He,je]=a.useState(!1),[N,J]=a.useState(!1),[ke,ee]=a.useState(!1),[Ue,p]=a.useState(!1),[f,U]=a.useState(!1),[j,_e]=a.useState([]),[M,K]=a.useState([]),[c,Je]=a.useState({}),[Ae,rt]=a.useState([]),[v,L]=a.useState([]),[le,Vt]=a.useState(!1),[ze,dt]=a.useState(!1),[Ve,Yt]=a.useState(0),[X,ct]=a.useState(!1),[ut,pt]=a.useState(!1),[he,Oe]=a.useState({}),[ht,Xe]=a.useState(!1),[Wt,Be]=a.useState(!1),[x,Kt]=a.useState(!1),[Qt,mt]=a.useState(!1),[qt,Jt]=a.useState(),[ft,St]=a.useState(!1),[Xt,me]=a.useState(!1),[gt,yt]=a.useState(!1),Re=it("(max-width:1250px)"),bt=it("(max-width:600px)"),xt=`${ot.CLOUDFRONT_DOMAIN}/${nt.IMAGES.SESSION_PLANNER.THUMBNAILS}`,Ze=`${ot.CLOUDFRONT_DOMAIN}/${nt.VIDEOS.SESSION_PLANNER.TRANSCODED}`,Ct=`${ot.CLOUDFRONT_DOMAIN}/${nt.IMAGES.SESSION_PLANNER.FRAMES}`,[$,z]=a.useState({page:0,sortBy:"updated_at",sortOrder:"DESC",selectedSortBy:"2",mediaType:"",selectedMediaType:"1"}),[Zt,Et]=a.useState(!1),fe=Ya(),Ye=Wa(),ea=R.planId>=4||fe,ta=Ns(),u={...(Ea=(Ca=(xa=r==null?void 0:r.userRolesPermissions)==null?void 0:xa.permissions)==null?void 0:Ca.sessionPlanner)==null?void 0:Ea[Ka(d==="shared"?"clubLibrary":d)],...d!=="draft"?{share:(Ta=(wa=(va=(_a=r==null?void 0:r.userRolesPermissions)==null?void 0:_a.permissions)==null?void 0:va.sessionPlanner)==null?void 0:wa.mediaSharing)==null?void 0:Ta.share}:{},...d==="draft"?{editAnimation:(Da=(Ia=(Ma=(Pa=r==null?void 0:r.userRolesPermissions)==null?void 0:Pa.permissions)==null?void 0:Ma.sessionPlanner)==null?void 0:Ia.general)==null?void 0:Da.animationTool}:{},...R.planId===4&&!fe?{addToGlobalLibrary:(Oa=(Aa=(ka=(ja=r==null?void 0:r.userRolesPermissions)==null?void 0:ja.permissions)==null?void 0:ka.globalLibrary)==null?void 0:Aa.general)==null?void 0:Oa.add}:{}},_t=r.id===(c==null?void 0:c.user_id),aa=u.share===re.YES,vt=(u==null?void 0:u.delete)===re.YES,sa=(u==null?void 0:u.addToGlobalLibrary)===re.YES&&R.planId===4&&!fe,oa=(u==null?void 0:u.delete)===re.YES||(u==null?void 0:u.delete)===re.LIMITED&&_t,na=(u==null?void 0:u.addToSessionTemplate)===re.YES,ia=t=>{Jt(t),mt(!0)},wt=()=>{mt(!1)},Tt=()=>{ee(!0)},et=()=>{ee(!1)},Pt=()=>{xe(!0)},Mt=()=>{xe(!1)},It=t=>{Oe(bs(t,de)),xe(!1),z(o=>({...o,page:0}))},Dt=(t,o,n)=>{z(S=>({...S,selectedSortBy:t,sortBy:o,sortOrder:n,page:0}))},jt=(t,o)=>{z(n=>({...n,page:0,mediaType:o,selectedMediaType:t}))},kt=(t,o)=>{_e(o==null?void 0:o.dugout_session_practices.map(n=>({id:n.training_session_id}))),Je(o),Te(t.currentTarget)},At=()=>{Te(null)},Ot=()=>{Me(ye),Ie(c),Te(null)},tt=()=>{Me(null),Ie(null)},Bt=t=>{be&&(i||we(ma(!0)),E([be]),k(t),tt(),P({msg:`Added to ${t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}`,variant:"success"}))},Rt=()=>{De(!0)},s=()=>{Je({}),Vt(!1),De(!1)},l=()=>{G(!0)},h=()=>{G(!1),ne(null)},g=()=>{p(!0)},C=()=>{p(!1)},w=()=>{U(!0)},F=()=>{U(!1)},A=()=>{J(!0)},at=()=>{J(!1),Je({}),L([])},We=()=>{L([])},ve=()=>{const t=M.map(o=>o.id);L(t)},O=(t,o,n)=>{o?(v.includes(t)||L([...v,t]),rt([...Ae,{practiceId:t,practiceUserId:n}])):(L(v.filter(S=>S!==t)),rt(Ae.filter(S=>S.practiceId!==t)))},Cs=()=>{Xe(!0)};a.useEffect(()=>{Xe(!1)},[]);const Es=async()=>
1{if(c!=null&&c.cloud_id){const t=`${Ze}/${c.cloud_id}.mp4`,o=`${c==null?void 0:c.work_title}.mp4`;Be(!0),await Fs(t,o),setTimeout(()=>{Be(!1)},1e3)}},_s=async()=>{var t;if(c!=null&&c.session_planner_work_image){const o=(t=c==null?void 0:c.session_planner_work_image)==null?void 0:t.images,n=c==null?void 0:c.work_title;Be(!0),await Gs(o,Ct,n),setTimeout(()=>{Be(!1)},1e3)}},vs=()=>{Be(!1)},ws=async()=>{var o;if(ze)return;const t={work_id:c.id};dt(!0);try{const n=await se({url:"/duplicate-work",method:"POST",data:t});P({msg:"Practice duplicated",variant:"success"});const S=((o=n==null?void 0:n.data)==null?void 0:o.data)||(n==null?void 0:n.data);S!=null&&S.id&&ne({id:S.id,tool_version:S.tool_version??(c==null?void 0:c.tool_version)}),l(),q("/session-planner/drafts")}finally{dt(!1)}},fa=t=>{if(!(t!=null&&t.id))return;const o=t.tool_version==="v2"?"https://studio.touchtight.com":"https://tool.touchtight.com",n=document.cookie.match(/(?:^|;\s*)accessToken=([^;]*)/),S=Ga()||(n?decodeURIComponent(n[1]):null),y=r==null?void 0:r.club_id,T=Z==null?void 0:Z.id,te=r==null?void 0:r.primary_team,ae=new 
1URLSearchParams;ae.set("id",t.id),S&&ae.set("token",S),y&&ae.set("clubId",y),T&&ae.set("seasonId",T),te&&ae.set("teamId",te),window.open(`${o}?${ae.toString()}`,"_blank")},Sa=()=>{fa(qe||c),oe&&(G(!1),ne(null))},Ts=async()=>{const{data:{createSaveForLaterEntry:{success:t,message:o,status:n}}}=await B({variables:{createSaveForLaterItemInput:{type:os.SESSION_PLANNER_PRACTICE,item_id:c.id}}});t?P({msg:o||"Item saved successfully.",variant:"success"}):!t&&n===409&&P({msg:o||"This item has already been saved.",variant:"success"})},la=[...fe?[]:[{name:"Add to Dugout Session",icon:ra,onClick:()=>{ea?g():Cs()}}],{name:"Add to Session Template",icon:So,iconCustomStyles:V.menuIcon,onClick:()=>{w()}},...!fe&&(d==="my-library"||d==="club-library"||d==="shared")?[{name:"Add to Global Library",icon:us,onClick:()=>me(!0)}]:[],{name:"Manage",icon:ua,onClick:()=>{Rt()}},{name:"Edit Animation",icon:ua,onClick:()=>{Sa()}},...d==="my-library"||d==="club-library"||d==="shared"?[{name:"Download",icon:io,onClick:()=>{c.media_type==="video"?Es():_s()}}]:[],{name:"Duplicate",icon:ls,onClick:()=>{ws()}},{name:"Save for Later",icon:cs,iconCustomStyles:V.menuIcon,onClick:()=>{Ts()}},{name:"Share",icon:ds,onClick:()=>{Tt()}},{name:"Delete",icon:rs,onClick:()=>{A()}}],ga=d==="my-library"?la.filter(t=>t.name!=="Edit Animation"):["club-library","shared"].includes(d)?la.filter(t=>t.name!=="Edit Animation"):la.filter(t=>t.name==="Delete"||t.name==="Edit Animation"),Ne=async(t,o)=>{var T,te,ae,Ba,Ra,Na,La;ct(!0);const n=t==="Shared"?await se({url:`/get-shared-practice-list?limit=12&&offset=${$.page*12}&&sortBy=${$.sortBy}&&sortOrder=${$.sortOrder}&&searchQuery=${o||H}&&mediaType=${$.mediaType}&&filters=${JSON.stringify(he)}`,method:"GET"}):await se({url:`/work-list?type=${t}&&limit=12&&offset=${$.page*12}&&sortBy=${$.sortBy}&&sortOrder=${$.sortOrder}&&searchQuery=${o||H}&&mediaType=${$.mediaType}&&filters=${JSON.stringify(he)}`,method:"GET"}),S=(T=n==null?void 0:n.data)==null?void 0:T.success,y=t==="Shared"?{count:(ae=(te=n==null?void 0:n.data)==null?void 0:te.data)==null?void 0:ae.count,rows:(Ra=(Ba=n==null?void 0:n.data)==null?void 0:Ba.data)==null?void 0:Ra.rows.map(Ke=>({...Ke.session_planner_work,sharedPracticeId:Ke.id,User:Ke.User}))}:(Na=n==null?void 0:n.data)==null?void 0:Na.data;if(S){const Ke=(La=y==null?void 0:y.rows)==null?void 0:La.map(D=>({...D,practiceType:D.practice_type_id||"",difficultyAgeGroup:D.age_group_id||"",visibility:D.type||"",language:D.language||"",practiceOrganization:D.work_description||"",keyCoachingPoints:D.key_coaching_points||"",progressions:D.progressions||"",technical:D.technical_id||"",tactical:D.tactical_id||"",physical:D.physical||"",social:D.social||"",psychologicalSocialFocus:D.psychological_social_focus||"",unitRelationShip:D.unit_relationship||"",durationMins:D.duration||"",sets:D.sets||"",activeMins:D.active_mins||"",restMins:D.rest_mins||"",areaWidth:D.area_width||"",areaLength:D.area_length||"",additionalComments:D.additional_comments||""}));$.page===0?K(Ke):K(D=>[...D,...Ke]),Yt(y.count),ct(!1)}},Ps=async(t,o)=>{pt(!0);const{data:n}=await se({url:"/share-practice",method:"POST",data:t});n!=null&&n.success&&(P({msg:(n==null?void 0:n.message)||"Practice successfully shared",variant:"success"}),et(),o()),L([]),pt(!1)},Ms=async()=>{const t=oa?v:Ae.filter(y=>y.practiceUserId===r.id).map(y=>y.practiceId);Et(!0);let o="",n="";if(m==="Shared"){const y=v.length?t:[c.id];o="/delete-shared-media",n={ids:M.filter(T=>y.includes(T.id)).map(T=>T.sharedPracticeId)}}else o="/delete-work",n={ids:v.length?d==="draft"?v:t:[c.id]};const{data:{success:S}}=await se({url:o,data:n,method:"DELETE"});S&&(K([]),Ne(m),z(y=>({...y,page:0}))),at(),Et(!1)};a.useEffect(()=>{Ne(m)},[pe,$.selectedSortBy,$.selectedMediaType,$.page,he]),a.useEffect(()=>{const t=()=>{K([]),z(y=>({...y,page:0})),Ne(m)},o=y=>{y.key==="dugout_session_planner_saved"&&y.newValue&&t()},n=y=>{var T,te;((T=y.data)==null?void 0:T.source)==="dugout-animation"&&((te=y.data)==null?void 0:te.type)==="saved"&&t()};let S;try{typeof BroadcastChannel<"u"&&(S=new BroadcastChannel("dugout-session-planner"),S.onmessage=y=>{var T;((T=y.data)==null?void 0:T.type)==="saved"&&t()})}catch{}return window.addEventListener("storage",o),window.addEventListener("message",n),(
1)=>{window.removeEventListener("storage",o),window.removeEventListener("message",n);try{S&&S.close()}catch{}}},[m,pe]),a.useEffect(()=>{K([]),L([]),z(t=>({...t,page:0}))},[pe]);const ya=a.useCallback(t=>{const o=t[0];M.length&&o.isIntersecting&&!X&&Ve>M.length&&z(n=>({...n,page:n.page+1}))},[X,Ve,M]);a.useEffect(()=>{let t=null;const o={root:null,rootMargin:"0px",threshold:1},n=new IntersectionObserver(ya,o);return Q.current&&(n.observe(Q.current),t=Q.current),()=>{t&&n.unobserve(t)}},[ya]);const Is=()=>{K([]),z(t=>({...t,page:0,sortBy:"updated_at",sortOrder:"DESC",selectedSortBy:"2"})),W(""),Oe({})},Ds=()=>m!=="Private"?!((u==null?void 0:u.addToDugoutSession)==="no"&&(u==null?void 0:u.addToSessionTemplate)==="no"&&(u==null?void 0:u.share)==="no"&&(u==null?void 0:u.delete)==="no"):!0;a.useEffect(()=>{var t;ta.capture(Ls.SESSION_PLANNER_ACCESSED,{customData:{userId:r==null?void 0:r.id,email:r==null?void 0:r.email,clubId:r==null?void 0:r.club_id,roles:(t=r==null?void 0:r.userRolesPermissions)==null?void 0:t.roles.map(o=>o.name)}})},[]),a.useEffect(()=>{if(b&&M.length){const t=M.find(o=>o.id===b);E([t])}},[b]),a.useEffect(()=>{z(t=>({...t,page:0,selectedSortBy:"2",sortOrder:"DESC"})),K([]),Ne(m,H)},[H]);const js=t=>{Kt(t)},ks=()=>{switch(d){case"club-library":return _("library.practices.noClubContent");case"shared":return _("library.practices.noShared");case"draft":return _("library.practices.noDrafts");default:return _("library.practices.needFirstPractice")}},As=()=>{switch(d){case"club-library":return _("library.practices.noClubContentDesc");case"shared":return _("library.practices.noSharedDesc");case"draft":return"";default:return _("library.practices.buildingHint")}};a.useEffect(()=>{const t=document.querySelector("main");ge.current=t},[]);const Os=async()=>{var n,S;if(v.length>5){me(!1),yt(!0);return}St(!0);const t={type:"SESSION_PLANNER_PRACTICE",item_ids:v.length?v:[c.id]},{data:o}=await $e({variables:{createGlobalLibraryItemInput:t}});(n=o==null?void 0:o.createGlobalLibraryEntry)!=null&&n.success?P({msg:"Practice added to Global Library successfully",variant:"success"}):P({msg:((S=o==null?void 0:o.createGlobalLibraryEntry)==null?void 0:S.message)||"Failed to add practice to Global Library",variant:"error"}),St(!1),me(!1),L([])},ba=t=>{const o=Ga(),n=r==null?void 0:r.club_id,S=Z==null?void 0:Z.id,y=r==null?void 0:r.primary_team,T=new URLSearchParams;o&&T.set("token",o),n&&T.set("clubId",n),S&&T.set("seasonId",S),y&&T.set("teamId",y);const te=T.toString(),ae=t==="legacy"?"https://tool.touchtight.com":"https://studio.touchtight.com";window.open(`${ae}${te?`?${te}`:""}`,"_blank")},Bs=async()=>{var o;if(Ye)try{const n=await se({url:"/playmaker-free-counts",method:"GET"}),{animationCount:S,animationLimit:y}=((o=n==null?void 0:n.data)==null?void 0:o.data)||{};if((S??0)>=(y??5)){je(!0);return}}catch{}const t=co();t?ba(t):Ee(!0)},Rs=t=>{Ee(!1),ba(t)};return a.useEffect(()=>{i&&wt()},[i]),e.jsxs(e.Fragment,{children:[e.jsx(ms,{hideEndIconFilterBtn:!0,totalRecordsCount:Ve||0,customStyle:{borderTop:"none"},onChangeParentCallback:W,handleOpenFilter:Pt,handleChangeBtnSelect:Dt,handleChangeMediaFilter:jt,btnSelectSelectId:$.selectedSortBy,handleClearFilter:Is,isFilterApplied:!de(he),showMediaFilterBtn:!0,btnMediaFilterSelectId:$.selectedMediaType,showSearchIcon:!0,handleToggleSearchBar:js,showSearchBar:x,btnSelectCustomStyles:V.btnSelect,filterBtnCustomStyles:V.filterBtn}),v.length>0&&e.jsx(qa,{showSelectable:!0,totalCount:M.length,items:v,deleteBtnText:"Practices",handleDeleteMultiple:()=>{},handleSelectAll:ve,handleDeselectAll:We,rightElement:e.jsxs(I,{container:!0,alignItems:"center",children:[d!=="draft"&&e.jsxs(e.Fragment,{children:[e.jsx(Ut,{flexItem:!0,sx:{...V.divider,display:Re?"block":"none"},orientation:"vertical"}),e.jsxs(I,{container:!0,gap:Re?0:2,children:[sa&&e.jsx(e.Fragment,{children:Re?e.jsx(Se,{onClick:()=>me(!0),children:e.jsx(zt,{color:"primary"})}):e.jsx(Le,{onClick:()=>me(!0),text:"Add to Global Library",variant:"outlined",customStyles:V.btn,startIcon:e.jsx(zt,{color:"primary",fontSize:"20px"})})}),(u==null?void 0:u.addToDugoutSession)==="yes"&&!fe&&e.jsx(e.Fragment,{children:Re?e.jsx(Se,{onClick:g,sx:V.iconBtn,children:e.jsx($t,{})}):e.jsx(Le,{onClick:g,text:"Add to Dugout",variant:"outlined",customStyles:V.btn,startIcon:e.jsx($t,{})})}),(u==null?void 0:u.addToSessionTemplate)==="yes"&&e.jsx(e.Fragment,{children:Re?e.jsx(Se,{onClick:w,children:e.jsx($a,{})}):e.jsx(Le,{onClick:w,text:"Add to Session Template",variant:"outlined",customStyles:V.btn,startIcon:e.jsx($a,{})})}),e.jsx(Ut,{flexItem:!0,sx:V.divider,orientation:"vertical"})]})]}),e.jsxs(I,{container:!0,children:[aa&&e.jsx(Se,{onClick:Tt,sx:V.iconBtn,children:e.jsx(ys,{})}),(vt||d==="my-library"||d==="draft")&&e.jsx(Se,{onClick:A,sx:{...V.deleteBtn,...V.iconBtn},children:e.jsx(Ja,{})})]})]})}),!(M!=null&&M.length)&&!X?e.jsx(ce,{sx:{height:"100%",borderRadius:"0px 0px 16px 16px",backgroundColor:t=>t.palette.common.white},children:e.jsx(Xa,{title:H||!de(he)?"No content found...":ks(),description:As(),action:["my-library","club-library"].includes(d)&&!H&&de(he)&&!ue&&e.jsx(Le,{disabled:bt,text:"Create First Practice",onClick:Bs})})}):e.jsxs(I,{container:!0,sx:V.container,children:[e.jsx(I,{size:12,children:e.jsx(fs,{droppableId:"practice-droppable",children:e.jsx(I,{container:!0,spacing:5,height:"fit-content",width:"100%",children:M.map((t,o)=>{var S,y;const n=Pe||Ft(ga,u,r.id===(t==null?void 0:t.user_id)).length>0;return e.jsx(I,{size:{xs:12,md:i?12:6,lg:i?6:4,xl:i?4:3},children:e.jsx(Ss,{index:o,draggableId:`practice-${t.id}`,isDragDisabled:d==="draft"||!i,children:e.jsx(Za,{parentContainerRef:ge,parentContainerRootMargin:"-25% 0% -25% 0%",id:d==="draft"||t.media_type==="image"?void 0:t.id,createSessionDrawer:i,title:d==="draft"?t.work_title:void 0,secondaryTitle:t.work_title,showCardDetail
1s:d!=="draft",showRatings:!1,showVisitsAndLikes:!1,canEdit:d==="my-library"&&n||d==="draft"||d==="club-library"&&n||d==="shared"&&n,imageUrl:t.thumbnail_signed_url||ps(xt,t.thumbnail),handleMenuClick:T=>kt(T,t),handleClick:i?null:d==="draft"?()=>fa(t):()=>ia(t.id),handleChangeCheckbox:T=>O(t.id,T,t.user_id),checked:v.includes(t.id),cardType:d==="draft"?void 0:"session-planner",isVideoAvailable:d==="draft"?void 0:t.available,mediaType:t==null?void 0:t.media_type,iconBtn:!v.length,hoverGradient:(t==null?void 0:t.media_type)==="video",videoUrl:`${Ze}/${t.cloud_id}.mp4`,dragMediaType:"practice",showCheckbox:Ds(),totalRatings:t.totalRatings,averageRating:t.average_rating,visits:t.visits,creatorName:`By ${(S=t==null?void 0:t.User)==null?void 0:S.username} ${(y=t==null?void 0:t.User)==null?void 0:y.lastname}`})},`${t.id}-${o}`)},t.id)})})})}),X&&e.jsx(I,{container:!0,justifyContent:"center",alignItems:"center",height:"50vh",width:"100%",children:e.jsx(Qa,{})}),e.jsx(ce,{ref:Q,sx:{margin:"4px"}})]}),e.jsx(go,{open:ze,sx:t=>({zIndex:t.zIndex.modal+1,color:"#fff",backgroundColor:"rgba(0, 0, 0, 0.55)"}),children:e.jsxs(yo,{alignItems:"center",gap:2,children:[e.jsx(bo,{color:"inherit"}),e.jsx(Qe,{color:"inherit",sx:{fontSize:"16px",fontWeight:500},children:"Duplicating practice…"})]})}),e.jsx(mo,{open:ie,handleClose:s,practice:c,isDuplicate:le,getWorkList:t=>Ne(t)}),e.jsxs(hs,{loading:Zt,title:v.length>1?"Delete Practices":"Delete Practice",actionBtnTitle:v.length>1?"Delete Practices":"Delete Practice",open:N,handleClose:at,handleDelete:Ms,children:[e.jsx(Qe,{sx:{fontSize:"16px",lineHeight:"24px",color:"text.primary"},children:v.length>1?`Are you sure you want to delete ${v.length} practices? This action cannot be undone.`:"Are you sure you want to delete this practice? This action cannot be undone."}),e.jsx(Qe,{sx:{fontSize:"13px",lineHeight:"20px",color:"text.secondary",mt:1},children:"If this practice is part of a session, it will also be removed from that session. Any session left with no activities will be deleted too."})]}
1),e.jsx(da,{itemHeight:"44px",itemPadding:"10px 16px",width:"240px",checked:!0,items:Io([{name:"Add to Session",icon:ra,onClick:Ot},...Ft(ga,u,_t)]),anchorEl:ye,enableDividers:!1,handleClose:At}),e.jsx(da,{itemHeight:"44px",itemPadding:"10px 16px",width:"240px",items:Object.values(ss).map(t=>({name:t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),onClick:()=>Bt(t)})),anchorEl:Fe,enableDividers:!1,handleClose:tt}),e.jsx(xs,{open:Ge,handleClose:Mt,actionHandler:It,selectedFilters:he,showPractice:!0}),e.jsx(gs,{open:Ue,handleClose:C,trainingSession:j,videoIds:de(c)?v:[c.id],handleOpenAddPracticeToSessionModal:g,fetchData:()=>Ne(m),handleDeselectAll:We,workflow:"SESSION_PLANNER"}),e.jsx(lo,{open:f,handleClose:F,selectedPracticeId:c.id,selectedPracticeIds:v,handleDeselectAll:We,multiAddToSessionPermission:na,selectedPracticeUserIds:Ae}),e.jsx(Gt,{modalBackgroundImage:ca,open:ht,handleClose:()=>Xe(!1),heading:"Unlock the session planner with Coach Bundle Max",mainHeading:"Create Animated Sessions and Build Session Plans",description:"The time has come to integrate our Touchtight Animation tool with our Session Planner, making coaches lives that little bit easier."}),e.jsx(Gt,{modalBackgroundImage:ca,open:He,handleClose:()=>je(!1),heading:"Animation limit reached",mainHeading:"You've used all 5 of your free animations",description:"Upgrade to Coach Studio Pro to create unlimited animations."}),e.jsx(uo,{open:oe,handleClose:h,handleOpenPractice:Sa}),e.jsx(ro,{open:Ce,handleClose:()=>Ee(!1),onChoose:Rs}),e.jsx(oo,{open:Wt,handleCloseDialog:vs,progressText:c.media_type==="video"?"Downloading video...":"Downloading images..."}),e.jsx(es,{loading:ut,open:ke,mediaType:"practice",media_ids:v.length?v:[c.id],title:"Share Practice(s)",currentLibrary:d,handleSubmit:Ps,handleClose:et}),e.jsx(po,{open:Qt,selectedPracticeId:qt,handleClose:wt,getWorkList:Ne,setFilters:z,setPracticeList:K,trainingSession:j,currentLibrary:d}),e.jsx(Ht,{title:"Add to Global Library",loading:ft,description:v.length?"Would you like to add multiple items to the Global Library?":"Are you sure you want to add the selected content in the Global Library?",open:Xt,handleClose:()=>me(!1),actionHandler:Os}),e.jsx(Ht,{title:"Maximum Export Exceeded",actionBtnTitle:"Try Again",description:"The most items you can add to the Global Library at any one time is 5.Please select the media you would like to submit.",open:gt,actionHandler:()=>yt(!1),cancelBtn:!1})]})},Y={container:{padding:"24px",borderRadius:"0px 0px 16px 16px",backgroundColor:i=>i.palette.common.white},emptyContentContainer:{height:"100%",borderRadius:"0px 0px 16px 16px",backgroundColor:i=>i.palette.common.white},iconBtn:{"& svg":{width:"22px"}},deleteBtn:{height:"36px",borderColor:i=>i.availability.unavailable,color:i=>i.availability.unavailable,"&:hover":{borderColor:i=>i.availability.unavailable}},btn:{height:"36px",color:"text.primary",borderColor:i=>i.border,textTransform:"none","& svg":{width:"20px",fontSize:"20px !important"},"&:hover":{borderColor:i=>i.border}},divider:{color:i=>i.divider},btnSelect:{maxHeight:{xs:"40px",md:"unset"}},filterBtn:{maxHeight:{xs:"40px",md:"unset"},p:{xs:1,md:"11px 16px"}},menuIcon:{color:"#454F5B",height:"20px",width:"20px"}},jo=({fetchSessions:i,setFetchSessions:d,createSessionDrawer:m,currentLibrary:b,currentLibraryType:E,selectedSession:k,setSelectedSession:_,setDuplicateSession:P,draggedSessionId:we,setDraggedSessionPractices:ue,beforeOpenSessionDrawer:Z})=>{var et,Pt,Mt,It,Dt,jt,kt,At,Ot,tt,Bt,Rt;const{t:r}=pa("sessionPlanner"),R=Va(),{isReadOnlyMode:ge}=za(),Q=st(s=>{var l;return(l=s==null?void 0:s.user)==null?void 0:l.userPermission});as();const pe=ha(),H=a.useRef(null),[W]=Ua(),{type:ye}=ts(),[Te]=a.useState({}),[Pe,Fe]=a.useState(null),[Me,be]=a.useState(!1),[Ie,Ge]=a.useState(!1),[xe,$e]=a.useState(!1),[B,q]=a.useState([]),[oe,G]=a.useState({}),[qe,ne]=a.useState([]),[ie,De]=a.useState(0),[Ce,Ee]=a.useState(!1),[He,je]=a.useState(!1),N=Object.keys(oe).map(Number),[J,ke]=a.useState(""),[ee,Ue]=a.useState({}
1),[p,f]=a.useState(!1),[U,j]=a.useState(!1),[_e,M]=a.useState(!1),[K,c]=a.useState(!1),[Je,Ae]=a.useState(!1),[rt,v]=a.useState(),[L,le]=a.useState({page:0,sortBy:"updated_at",sortOrder:"DESC",selectedSortBy:"2"}),[Vt,ze]=a.useState(!1),[dt,Ve]=a.useState(!1),[Yt,X]=a.useState(!1),[ct,ut]=a.useState(!1),[pt]=lt(ns),[he]=lt(is),Oe=it("(max-width:1100px)"),ht=a.useRef(null),Xe=Q.planId>=4,Wt=`${ot.CLOUDFRONT_DOMAIN}/${nt.IMAGES.SESSION_PLANNER.THUMBNAILS}`,Be=`${ot.CLOUDFRONT_DOMAIN}/${nt.VIDEOS.SESSION_PLANNER.TRANSCODED}`,x={...(Mt=(Pt=(et=R==null?void 0:R.userRolesPermissions)==null?void 0:et.permissions)==null?void 0:Pt.sessionPlanner)==null?void 0:Mt[Ka(b)],share:(kt=(jt=(Dt=(It=R==null?void 0:R.userRolesPermissions)==null?void 0:It.permissions)==null?void 0:Dt.sessionPlanner)==null?void 0:jt.mediaSharing)==null?void 0:kt.share,...Q.planId===4?{addToGlobalLibrary:(Bt=(tt=(Ot=(At=R==null?void 0:R.userRolesPermissions)==null?void 0:At.permissions)==null?void 0:Ot.globalLibrary)==null?void 0:tt.general)==null?void 0:Bt.add}:{}},Kt=(x==null?void 0:x.share)===re.YES,Qt=R.id===(k==null?void 0:k.user_id),mt=(x==null?void 0:x.addToGlobalLibrary)===re.YES&&Q.planId===4,qt=s=>{const l=R.id===s;return(x==null?void 0:x.delete)===re.YES||(x==null?void 0:x.delete)===re.LIMITED&&l||l},Jt=s=>{v(s),Ae(!0)},ft=()=>{Ae(!1)},St=()=>{be(!0)},Xt=()=>{be(!1)},me=()=>{j(!0)},gt=()=>{j(!1)},yt=s=>{Ue(bs(s,de)),be(!1),le(l=>({...l,page:0}))},Re=(s,l)=>{const h=vo(l.session_planner_works,"session_planner_session_work.practice_type"),g=wo(h,(C,w)=>Qs[w]||w);_({...l,practices:g}),Fe(s.currentTarget)},bt=()=>{Fe(null)},xt=()=>{Ge(!0)},Ze=()=>{Ge(!1),_({}),G({})},Ct=()=>{G({}),ne([])},$=(s,l)=>{let h={};l?h={...oe,[s]:l}:h=_o(oe,s);const g=Object.keys(h).map(Number),C=[];B.filter(w=>g.some(F=>F===w.id)).forEach(w=>{const F=w.practices.map(A=>A.id);C.push(...F)}),G(h),ne(C)},z=async()=>{Z&&!await Z()||pe(ma(!0))},Zt=()=>{ze(!0)};a.useEffect(()=>{ze(!1)},[]);const Et=async()=>{const{data:{createSaveForLaterEntry:{success:s,message:l,status:h}}}=await he({variables:{createSaveForLaterItemInput:{type:os.SESSION_PLANNER_SESSION,item_id:k.id}}});s?W({msg:l||"Item saved successfully.",variant:"success"}):!s&&h===409&&W({msg:l||"This item has already been added to your saved content list.",variant:"success"})},fe=[{name:"Add to Dugout Session",icon:ra,onClick:()=>{Xe?Ye():Zt()}},{name:"Manage",icon:ua,onClick:()=>{z()}},...b==="my-library"||b==="club-library"||b==="shared"?[{name:"Add to Global Library",icon:us,onClick:()=>X(!0)}]:[],{name:"Duplicate",icon:ls,onClick:()=>{P(!0),z()}},{name:"Export PDF",icon:Co,onClick:()=>{M(!0),bt()}},{name:"Save for Later",icon:cs,iconCustomStyles:Y.menuIcon,onClick:()=>{Et()}},{name:"Share",icon:ds,onClick:()=>{me()}},{name:"Delete",icon:rs,onClick:()=>{xt()}}],Ye=()=>{$e(!0)},ea=()=>{$e(!1)},ta=(s,l,h)=>{le({selectedSortBy:s,sortBy:l,sortOrder:h,page:0})},u=async s=>{var C,w,F,A,at,We;Ee(!0);const l=E==="Shared"?await se({url:`/get-shared-session-list?limit=12&&offset=${L.page*12}&&sortBy=${L.sortBy}&&sortOrder=${L.sortOrder}&&searchQuery=${s||J}&&filters=${JSON.stringify(ee)}`,method:"GET"}):await se({url:`/session-list?type=${E}&&limit=12&&offset=${L.page*12}&&sortBy=${L.sortBy}&&sortOrder=${L.sortOrder}&&searchQuery=${s||J}&&filters=${JSON.stringify(ee)}`,method:"GET"}),h=(C=l==null?void 0:l.data)==null?void 0:C.success,g=E==="Shared"?{count:(F=(w=l==null?void 0:l.data)==null?void 0:w.data)==null?void 0:F.count,rows:(at=(A=l==null?void 0:l.data)==null?void 0:A.data)==null?void 0:at.rows.map(ve=>({...ve.session_planner_session,sharedSessionId:ve.id,User:ve.User}))}:(We=l==null?void 0:l.data)==null?void 0:We.data;if(h){const ve=g==null?void 0:g.rows.map(O=>({...O,sessionName:O.session_name,visibility:O.type,sessionType:O.session_type_id,noOfPlayers:O.no_of_players,difficultyAgeGroup:O.age_group_id,language:O.language,sessionObjective:O.session_objective,technical:O.technical_id,tactical:O.tactical_id,physical:O.physical,social:O.social,psychological:O.psychological,unitRelationShip:O.unit_relationship,duration:O.duration,coachNotes:O.coach_notes,practices:O.session_planner_works}));L.page===0?q(ve):q(O=>[...O,...ve]),De(g.count),Ee(!1)}},_t=async()=>{f(!0);let s="",l="";if(E==="Shared"){const g=N.length?N:[k.id];s="/delete-shared-media",l={ids:B.filter(C=>g.includes(C.id)).map(C=>C.sharedSessionId)}}else s="/delete-session",l={ids:N.length?N:[k.id]};const{data:{success:h}}=await se({url:s,data:l,method:"DELETE"});h&&(q([]),u(),le(g=>({...g,page:0}))),Ze(),f(!1)},aa=async(s,l)=>{je(!0);const{data:h}=await se({url:"/share-session",method:"POST",data:s});h!=null&&h.success&&(W({msg:(h==null?void 0:h.message)||"Session successfully shared",variant:"success"}),gt(),l()),G({}),je(!1)};a.useEffect(()=>{u()},[ye,L.selectedSortBy,L.page,ee]),a.useEffect(()=>
1{i&&(q([]),u(),le(s=>({...s,page:0})),d(!1))},[i]),a.useEffect(()=>{const s=()=>{q([]),le(C=>({...C,page:0})),u()},l=C=>{C.key==="dugout_session_planner_saved"&&C.newValue&&s()},h=C=>{var w,F;((w=C.data)==null?void 0:w.source)==="dugout-animation"&&((F=C.data)==null?void 0:F.type)==="saved"&&s()};let g;try{typeof BroadcastChannel<"u"&&(g=new BroadcastChannel("dugout-session-planner"),g.onmessage=C=>{var w;((w=C.data)==null?void 0:w.type)==="saved"&&s()})}catch{}return window.addEventListener("storage",l),window.addEventListener("message",h),()=>{window.removeEventListener("storage",l),window.removeEventListener("message",h);try{g&&g.close()}catch{}}},[ye]);const vt=a.useCallback(s=>{const l=s[0];B.length&&l.isIntersecting&&!Ce&&ie>B.length&&le(h=>({...h,page:h.page+1}))},[Ce,ie,B]);a.useEffect(()=>{let s=null;const l={root:null,rootMargin:"0px",threshold:1},h=new IntersectionObserver(vt,l);return H.current&&(h.observe(H.current),s=H.current),()=>{s&&h.unobserve(s)}},[vt]);const sa=()=>{q([]),le(s=>({...s,page:0,sortBy:"updated_at",sortOrder:"DESC",selectedSortBy:"2"})),ke(""),Ue({})},oa=()=>E!=="Private"?!((x==null?void 0:x.addToDugoutSession)==="no"&&(x==null?void 0:x.addToSessionTemplate)==="no"&&(x==null?void 0:x.share)==="no"&&(x==null?void 0:x.delete)==="no"):!0;a.useEffect(()=>{if(we&&B.length){const s=B.find(l=>l.id===we);ue(s.practices)}},[we]),a.useEffect(()=>{const s=document.querySelector("main");ht.current=s},[]),a.useEffect(()=>{le(s=>({...s,page:0})),q([]),u(J)},[J]);const na=()=>{switch(b){case"club-library":return r("library.sessions.noClubSessions");case"shared":return r("library.sessions.noShared");default:return r("library.sessions.readyToBuild")}},ia=()=>{switch(b){case"club-library":return r("library.sessions.noClubSessionsDesc");case"shared":return r("library.sessions.noSharedDesc");default:return r("library.sessions.buildingHint")}},wt=async()=>{var C,w;if(N.length>5){X(!1),ut(!0);return}if((N.length?N.map(F=>B.find(A=>A.id===F)).filter(Boolean):[k]).some(F=>F.session_planner_works.length>6)){W({msg:"You can only add sessions that contain up to 6 practices.",variant:"error"}),X(!1);return}Ve(!0);const h={type:"SESSION_PLANNER_SESSION",item_ids:N.length?N:[k.id]},{data:g}=await pt({variables:{createGlobalLibraryItemInput:h}});(C=g==null?void 0:g.createGlobalLibraryEntry)!=null&&C.success?W({msg:"Practice added to Global Library successfully",variant:"success"}):W({msg:((w=g==null?void 0:g.createGlobalLibraryEntry)==null?void 0:w.message)||"Failed to add practice to Global Library",variant:"error"}),Ve(!1),X(!1)},Tt=()=>{const s={};B.forEach(l=>{s[l.id]=!0}),G(s)};return a.useEffect(()=>{m&&ft()},[m]),e.jsxs(e.Fragment,{children:[e.jsx(ms,{hideEndIconFilterBtn:!0,totalRecordsCount:ie||0,customStyle:{borderTop:"none"},onChangeParentCallback:ke,handleOpenFilter:St,handleChangeBtnSelect:ta,btnSelectSelectId:L.selectedSortBy,handleClearFilter:sa,isFilterApplied:!de(ee),showSearchIcon:!1,flexWrap:"nowrap",btnSelectCustomStyles:Y.btnSelect,filterBtnCustomStyles:Y.filterBtn,searchCustomStyles:Y.search}),!!N.length&&e.jsx(qa,{showSelectable:!0,totalCount:B.length,items:N,title:"Session",deleteBtnText:"Sessions",handleDeleteMultiple:()=>{},handleDeselectAll:Ct,handleSelectAll:Tt,rightElement:e.jsxs(I,{container:!0,children:[e.jsx(Ut,{flexItem:!0,sx:{...Y.divider,display:Oe?"block":"none"},orientation:"vertical"}),e.jsxs(I,{container:!0,gap:Oe?0:2,children:[mt&&e.jsx(e.Fragment,{children:Oe?e.jsx(Se,{onClick:()=>X(!0),children:e.jsx(zt,{color:"primary"})}):e.jsx(Le,{onClick:()=>X(!0),text:"Add to Global Library",variant:"outlined",customStyles:Y.btn,startIcon:e.jsx(zt,{color:"primary"})})}),x.addToDugoutSession==="yes"&&e.jsx(e.Fragment,{children:Oe?e.jsx(Se,{onClick:Ye,sx:Y.iconBtn,children:e.jsx($t,{})}):e.jsx(Le,{onClick:Ye,text:"Add to Dugout",variant:"outlined",customStyles:Y.btn,startIcon:e.jsx($t,{})})}),e.jsx(Ut,{flexItem:!0,sx:Y.divider,orientation:"vertical"})]}),e.jsxs(I,{container:!0,children:[Kt&&e.jsx(Se,{onClick:me,sx:Y.iconBtn,children:e.jsx(ys,{})}),(x.delete==="yes"||b==="my-library")&&e.jsx(Se,{onClick:xt,sx:{...Y.deleteBtn,...Y.iconBtn},children:e.jsx(Ja,{})})]})]})}),!(B!=null&&B.length)&&!Ce?e.jsx(ce,{sx:Y.emptyContentContainer,children:e.jsx(Xa,{title:J||!de(ee)?"No content found...":na(),description:ia(),action:["my-library","club-library"].includes(b)&&!J&&de(ee)&&!ge&&e.jsx(Le,{text:"Create First Session",onClick:z})})}):e.jsxs(I,{container:!0,sx:Y.container,children:[e.jsx(I,{size:12,children:e.jsx(fs,{droppableId:"session-droppable",children:e.jsx(I,{container:!0,spacing:5,height:"fit-content",width:"100%",children:B.map((s,l)=>{var C,w,F;const h=(C=s.session_planner_works.find(A=>A.media_type==="video"))==null?void 0:C.cloud_id,g=Ft(Ha(fe),x,R.id===(s==null?void 0:s.user_id
1)).length>0;return e.jsx(I,{size:{xs:12,md:m?12:6,lg:m?6:4,xl:m?4:3},children:e.jsx(Ss,{index:l,draggableId:`session-${s.id}`,isDragDisabled:!m,children:e.jsx(Za,{iconBtn:!N.length,parentContainerRef:ht,parentContainerRootMargin:"0% 0% -30% 0%",secondaryTitle:s.sessionName,showCardDetails:b!=="draft",showRatings:!1,showVisitsAndLikes:!1,creatorName:`By ${(w=s==null?void 0:s.User)==null?void 0:w.username} ${(F=s==null?void 0:s.User)==null?void 0:F.lastname}`,collectionVideosCount:s.practices.length,createSessionDrawer:m,imageUrl:(()=>{const A=s.practices[0];return A!=null&&A.thumbnail?A.thumbnail_signed_url||ps(Wt,A.thumbnail):xo})(),videoUrl:`${Be}/${h}.mp4`,mediaType:h?"video":"image",canEdit:b==="my-library"&&g||b==="club-library"&&g||b==="shared"&&g,handleMenuClick:A=>Re(A,s),handleClick:b==="draft"||m?null:()=>Jt(s.id),handleChangeCheckbox:A=>$(s.id,A),checked:oe[s.id],hoverGradient:!0,dragMediaType:"session",cardType:"session-planner",showCheckbox:oa()||qt(s.user_id),totalRatings:s.totalRatings,averageRating:s.average_rating,visits:s.visits,practiceTypeTags:s.practiceCategories})},`${s.id}-${l}`)},`${l}`)})})})}),Ce&&e.jsx(I,{container:!0,justifyContent:"center",alignItems:"center",width:"100%",height:"50vh",children:e.jsx(Qa,{})}),e.jsx(ce,{ref:H,sx:{margin:"4px"}})]}),e.jsx(da,{itemHeight:"52px",width:"240px",items:Ft(Ha(fe),x,Qt),anchorEl:Pe,enableDividers:!1,itemPadding:"14px 24px",handleClose:bt}),e.jsx(xs,{open:Me,handleClose:Xt,actionHandler:yt,selectedTags:Te,showSession:!0}),e.jsx(gs,{open:xe,handleClose:ea,videoIds:de(k)?qe:[...(Rt=k==null?void 0:k.session_planner_works)==null?void 0:Rt.map(s=>s.id)],handleOpenAddPracticeToSessionModal:Ye,handleDeselectAll:Ct,workflow:"SESSION_PLANNER",importedAsSession:!0}),e.jsx(hs,{loading:p,title:"Delete Session",actionBtnTitle:"Delete Session",open:Ie,handleClose:Ze,handleDelete:_t}),e.jsx(Gt,{modalBackgroundImage:ca,open:Vt,handleClose:()=>ze(!1),heading:"Unlock the session planner with Coach Bundle Max",mainHeading:"Create Animated Sessions and Build Session Plans",description:"The time has come to integrate our Touchtight Animation tool with our Session Planner, making coaches lives that little bit easier."}),e.jsx(es,{loading:He,mediaType:"session",open:U,media_ids:N.length?N:[k.id],title:"Share Session(s)",currentLibrary:b,handleSubmit:aa,handleClose:gt}),e.jsx(Eo,{open:_e,handleCloseModal:()=>M(!1),session:k,setPdfAddedAsDocument:c}),e.jsx(Ht,{title:"Add to Global Library",loading:dt,description:N.length?"Would you like to add multiple items to the Global Library?":"Are you sure you want to add the selected content in the Global Library?",open:Yt,handleClose:()=>X(!1),actionHandler:wt}),e.jsx(Ht,{title:"Maximum Export Exceeded",actionBtnTitle:"Try Again",description:"The most items you can add to the Global Library at any one time is 5.Please select the media you would like to submit.",open:ct,actionHandler:()=>ut(!1),cancelBtn:!1}),e.jsx(ho,{open:Je,handleClose:ft,selectedSessionId:rt,currentLibrary:b,refetchSessionsList:u,setSelectedSession:_,setDuplicateSession:P})]})},ko=[{path:"global-library",titleKey:"library.titles.globalLibrary",tabKeys:["library.tabs.practices","library.tabs.sessions"]},{path:"club-library",titleKey:"library.titles.clubLibrary",tabKeys:["library.tabs.clubPractices","library.tabs.clubSessions"]},{path:"my-library",titleKey:"library.titles.myLibrary",tabKeys:["library.tabs.myPractices","library.tabs.mySessions"]},{path:"shared",titleKey:"library.titles.sharedWithMe",tabKeys:["library.tabs.sharedPractices","library.tabs.sharedSessions"]},{path:"draft",titleKey:"library.titles.drafts",tabKeys:[]}],Lt={container:{height:"fit-content",borderRadius:"16px 16px 0px 0px",backgroundColor:i=>i.palette.common.white,borderBottom:i=>`1px solid ${i.palette.divider}`},heading:{fontSize:{xs:"20px",md:"32px"},fontWeight:"700",lineHeight:{xs:"24px",md:"48px"}},tab:{px:1,borderRadius:2,"&:hover":{backgroundColor:i=>`${i.palette.text.secondary}14`}},tabs:{"& .MuiTabs-flexContainer":{gap:1}}},Gi=()=>{const{t:i}=pa("sessionPlanner"),d=ko.map(p=>({...p,title:i(p.titleKey),tabs:p.tabKeys.map(f=>i(f))})),m=qs(),[b,E]=Js(),[k,_]=a.useState(0),[P,we]=a.useState(d[0]),{createSession:ue=!1}=st(p=>p.drawer.sessionPlanner),{createPractice:Z=!1}=st(p=>
1p.practice.createPractice),[r,R]=a.useState({}),[ge,Q]=a.useState([]),[pe,H]=a.useState(0),[W,ye]=a.useState(0),[Te,Pe]=a.useState(null),[Fe,Me]=a.useState(!1),[be,Ie]=a.useState({}),[Ge,xe]=a.useState(!1),[$e,B]=a.useState(!1),q=a.useRef(!1),oe=it(p=>p.breakpoints.down("md")),G=ha(),qe=Ya(),ne=Wa();st(p=>{var f;return(f=p.user.userDetail)==null?void 0:f.id});const[ie,De]=a.useState({open:!1,heading:"",mainHeading:"",description:""}),[Ce]=lt(eo),Ee=a.useCallback(async()=>{var p;if(!ne)return!0;try{const f=await se({url:"/playmaker-free-counts",method:"GET"}),{sessionCount:U,sessionLimit:j}=((p=f==null?void 0:f.data)==null?void 0:p.data)||{};if((U??0)>=(j??10))return De({open:!0,heading:"Session limit reached",mainHeading:"You've reached your 10 session plan limit",description:"Upgrade to Coach Studio Pro to unlock unlimited session plans."}),!1}catch{}return!0},[ne]);a.useEffect(()=>{const p=b.get("session_id");b.get("setup")==="true"&&!q.current&&(q.current=!0,p?(async()=>{try{const j=await Ce({variables:{sessionId:p}}),{success:_e,data:M}=j.data.retrieveCheckoutSession;_e&&(M!=null&&M.userPermissions)&&G(Fa(M.userPermissions));const{data:K}=await Zs(),c=K==null?void 0:K.user;c&&(G($s(c)),c.UserActivePlan&&G(Fa(c.UserActivePlan)),c.clubDetails&&G(Hs(c.clubDetails)))}catch(j){console.error("[Library] Checkout return handling error:",j)}finally{B(!0)}})():B(!0))},[b]);const He=()=>{B(!1),E(p=>(p.delete("session_id"),p.delete("setup"),p))},je=(p,f)=>{_(f)},N=()=>{R({}),G(ma(!1)),Me(!1)},J=()=>{var f;const p=m.pathname;return(f=d.find(U=>p.includes(U.path)))==null?void 0:f.path},ke=()=>{var U;const p=m.pathname;switch((U=d.find(j=>p.includes(j.path)))==null?void 0:U.path.split("-")[0]){case"club":return"Club";case"my":return"Private";case"shared":return"Shared";case"draft":return"Draft";default:return"Public"}},ee=p=>{const{destination:f,source:U,draggableId:j}=p;if(!f||(f==null?void 0:f.droppableId)==="practice-droppable"||(f==null?void 0:f.droppableId)==="session-droppable")return;if(U.droppableId===f.droppableId){Ie(p);return}const _e=f==null?void 0:f.droppableId.split("-")[1];if(Object.values(ss).includes(_e)&&ue){if(Pe(_e),j!=null&&j.includes("session")){const M=+j.split("-")[1];H(M)}else if(j!=null&&j.includes("practice")){const M=+j.split("-")[1];ye(M)}}};a.useEffect(()=>{localStorage.setItem("visited-session-planner","true")},[]),a.useEffect(()=>{const p=d.find(f=>m.pathname.includes(f.path));we(p),_(m!=null&&m.state?m==null?void 0:m.state.tab:0)},[m.pathname]);const Ue=()=>{G(Po(!1))};return a.useEffect(()=>{!ge.length&&(pe||W)&&(H(0),ye(0))},[pe,W,ge]),e.jsxs(e.Fragment,{children:[e.jsxs(Us,{onDragEnd:ee,children:[e.jsxs(I,{container:!0,padding:{xs:0,md:"16px"},height:"100%",alignContent:"flex-start",width:ue?`calc(100% - ${Xs})`:"100%",children:[e.jsxs(ce,{width:"100%",children:[ne&&!1,e.jsx(so,{id:"session-planner-rate-tip",message:i("library.rateHint"),sx:{mt:1,mb:1}})]}),!oe&&e.jsx(I,{flex:1,container:!0,p:{xs:"8px 24px",md:3},sx:Lt.container,children:e.jsx(I,{children:e.jsx(Qe,{sx:Lt.heading,children:P.title})})}),e.jsx(ce,{width:"100%",children:e.jsx(ao,{padding:0,tabHeaderPadding:oe?"0 24px":void 0,labels:P.tabs,selectedTab:k,handleTabChange:je,showTabs:!!(P!=null&&P.tabs.length),contentContainerCustomStyles:{overflow:"unset"}
1,customTabsStyles:Lt.tabs,customTabStyles:Lt.tab,components:[e.jsx(ce,{height:"100%",children:e.jsx(Do,{createSessionDrawer:ue,currentLibrary:J(),draggedPracticeId:W,setDraggedPractices:Q,setDraggedTargetType:Pe,currentLibraryType:ke()})},"practice"),e.jsx(ce,{height:"100%",children:e.jsx(jo,{fetchSessions:Ge,setFetchSessions:xe,createSessionDrawer:ue,currentLibrary:J(),currentLibraryType:ke(),selectedSession:r,setSelectedSession:R,setDuplicateSession:Me,draggedSessionId:pe,setDraggedSessionPractices:Q,beforeOpenSessionDrawer:Ee})},"session")]})})]}),e.jsx(To,{open:ue,handleCloseDrawer:N,session:r,isDuplicate:Fe,draggedPractices:ge,setDraggedPractices:Q,draggedTargetType:Te,setDraggedTargetType:Pe,sideDrawerDraggedResult:be,setSideDrawerDraggedResult:Ie,setFetchSessions:xe}),e.jsx(no,{open:Z,handleClose:Ue})]}),e.jsx(Gt,{open:ie.open,handleClose:()=>De(p=>({...p,open:!1})),heading:ie.heading,mainHeading:ie.mainHeading,description:ie.description}),e.jsx(Ks,{open:$e,onClose:He,onSuccess:He,isPlaymaker:qe})]})};export{Gi 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.