1import{a as u,j as t}from"./react-vendor-DJtAp8P_.js";import{z as C,E as V,T as M,u as G,ad as N}from"./mui-DM4FB6Od.js";import{b as H}from"./swiper-react-BdHqbMUq.js";import{d as Y,T as z,a$ as $,g as Q}from"./index-D7JOLfRZ.js";import{B as F}from"./Button-C12sdXE_.js";import{S as q}from"./Search-DtNbnsKK.js";import"./query-C7Xvvnmk.js";import"./mutation-CBAS9dQ5.js";import"./dayjs-CeefjyDY.js";import"./moment-Bj79pgB5.js";import"./index.esm-M6qXUo6E.js";import"./SessionPlannerMobile-btstsT3g.js";import{S as J}from"./Filter-D0LZmDHe.js";import{T as K}from"./ToggleButton-DmIh7_Y6.js";import{M as X}from"./Modal-BMf2ZRZ1.js";import{a as R,b as W,c as Z}from"./replayQuery-BUCYuV9K.js";import{j as L,e as P,n as ee}from"./apollo-WxVwhmyD.js";import{u as O}from"./useReplayProcessingPoll-B5g-iF0c.js";import{V as A}from"./VideoGrid-JCnTFueR.js";import{D as te}from"./replayMutation-2dbQMdqR.js";import{D as oe}from"./DeleteModal-DGIY4vv1.js";import{E as se}from"./EditVideoModal-Bx0VLYD5.js";import{U as re}from"./UploadModal-CH076zz_.js";import"./mui-styles-Cs1eTw1A.js";import"./babel-helpers-GYAhpWPp.js";import"./imageOptimization-zUL1CBPb.js";import"./lodash-CKgJFN-2.js";import"./merge-BSbDH-s2.js";import"./_baseAssignValue-DA5RZPFC.js";import"./_baseClone-CI_UATaE.js";import"./isArrayLikeObject-BWZNxdtJ.js";import"./map-DazS0jXn.js";import"./browser-CbB-A17s.js";import"./hello-pangea-dnd-V9uYMV7h.js";import"./some-DWTvIxlZ.js";import"./_baseIndexOf-DqPIyCu4.js";import"./values-KC-0YRfW.js";import"./index-DCj5Y0Ve.js";import"./_baseDifference-DAp4QVb4.js";import"./_arrayIncludes-Ck-iFXGO.js";import"./omit-BVrVjzv1.js";import"./index-DH6i3Hvs.js";import"./mui-x-YwRs-dk2.js";import"./s3FileHandler-C17YuASz.js";import"./_baseUniq-CmchZ_xr.js";import"./compact-DZdspzxW.js";import"./cloneDeep-DBd8ERDR.js";import"./Manage-BVQNLVR9.js";import"./DeleteGray-Dm8DTCln.js";try{let e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="77941d42-c711-4a5f-b19b-b1f22c563df3",e._sentryDebugIdIdentifier="sentry-dbid-77941d42-c711-4a5f-b19b-b1f22c563df3")}catch{}const U=[{key:"team",label:"Team"},{key:"fixture",label:"Fixture"},{key:"session",label:"Session"}],ie={team:[],fixture:[],session:[]},k={team:[],fixture:[],session:[]},ae=({open:e,onClose:i,filters:h,onChange:n})=>{const[o,p]=u.useState(h),[s,m]=u.useState(ie),[f]=L(R),[g]=L(R),[y]=L(R);u.useEffect(()=>{if(!e)return;p(h),[{key:"team",fetch:f},{key:"fixture",fetch:g},{key:"session",fetch:y}].forEach(({key:r,fetch:c})=>{c({variables:{getTagsByCategoryInput:{category:r}}}).then(T=>{var I,B;const _=((B=(I=T.data)==null?void 0:I.getReplayTagsByCategory)==null?void 0:B.data)||[];m(D=>({...D,[r]:_.map(j=>({id:j.context_id,name:j.name}))}))})})},[e]);const l=(x,r)=>{p(c=>({...c,[x]:r}))},a=()=>{n(o),i()},d=()=>{p(k),n(k),i()},v=U.some(x=>(o[x.key]||[]).length>0);return t.jsx(X,{open:e,title:"Filter Videos",handleClose:i,actionBtnTitle:"Apply Filters",actionHandler:a,secondaryBtnTitle:"Clear",secondaryBtnHandler:d,secondaryBtnStyle:{opacity:v?1:.4,pointerEvents:v?"auto":"none"},dialogMaxWidth:"md",children:t.jsx(C,{container:!0,spacing:3,children:U.map(({key:x,label:r})=>t.jsx(C,{size:{xs:12,md:4},children:t.jsx(H,{multiple:!0,name:x,label:r,options:s[x],value:o[x]||[],onChange:c=>l(x,c.target.value)})},x))})})},ne=(e,i)=>{const h=e.replay_video_contexts||[];for(const[n,o]of Object.entries(i))if(o.length>0&&!h.some(s=>s.context_type===n&&o.includes(s.context_id)))return!1;return!0},le=({viewMode:e="grid",filters:i={},search:h=""})=>{var y,l;const[n,o]=u.useState(0),{data:p,loading:s}=P(W,{variables:{getReplayVideosInput:{limit:100,offset:0,sortBy:"createdAt",sortOrder:"DESC",filter:{library_scope:"club_library"}}},pollInterval:n}),m=((l=(y=p==null?void 0:p.getReplayVideos)==null?void 0:y.data)==null?void 0:l.rows)||[];O(m.map(a=>a.status),o);const f=h.trim().toLowerCase(),g=m.filter(a=>ne(a,i)).filter(a=>{var d;return!f||((d=a.title)==null?void 0:d.toLowerCase().includes(f))});return t.jsx(V,{children:t.jsx(A,{videos:g,loading:s,viewMode:e,nullTitle:"Club library is empty",nullDescription:"Videos shared to the club library will appear here. Upload a video and set visibility to Club Library."})})},de=(e,i)=>{const h=e.replay_video_contexts||[];for(const[n,o]of Object.entries(i))if(o.length>0&&!h.some(s=>s.context_type===n&&o.includes(s.context_id)))return!1;return!0}
1,ce=({viewMode:e="grid",filters:i={},search:h="",onOpenUpload:n})=>{var D,j;const o=Y(),[p,s]=u.useState(null),[m,f]=u.useState(null),[g,y]=u.useState(()=>new Set),[l]=z(),[a,d]=u.useState(0),{data:v,loading:x,refetch:r}=P(W,{variables:{getReplayVideosInput:{limit:100,offset:0,sortBy:"createdAt",sortOrder:"DESC",filter:{uploaded_by:o==null?void 0:o.id}}},skip:!(o!=null&&o.id),pollInterval:a}),[c]=ee(te),T=((j=(D=v==null?void 0:v.getReplayVideos)==null?void 0:D.data)==null?void 0:j.rows)||[];O(T.map(b=>b.status),d);const _=h.trim().toLowerCase(),I=T.filter(b=>!g.has(b.id)).filter(b=>de(b,i)).filter(b=>{var S;return!_||((S=b.title)==null?void 0:S.toLowerCase().includes(_))}),B=async()=>{if(!m)return;const b=m;y(S=>{const E=new Set(S);return E.add(b.id),E}),f(null);try{await c({variables:{deleteReplayVideosInput:{ids:[b.id]}}}),await r()}catch(S){l({msg:(S==null?void 0:S.message)||`Could not delete â${b.title}â. Please try again.`,variant:"error",autoHideDuration:4e3})}finally{y(S=>{const E=new Set(S);return E.delete(b.id),E})}};return t.jsxs(V,{children:[t.jsx(A,{videos:I,loading:x,viewMode:e,nullTitle:"No uploads yet",nullDescription:"Upload your first match or training video to get started.",nullCtaLabel:"Upload Video",onNullCta:n,onEdit:s,onDelete:f}),t.jsx(se,{open:!!p,onClose:()=>s(null),video:p,onSuccess:r}),t.jsx(oe,{open:!!m,title:"Delete Video",actionBtnTitle:"Delete",handleDelete:B,handleClose:()=>f(null),children:t.jsxs(M,{sx:{fontSize:"16px",lineHeight:"24px",color:"text.primary",overflowWrap:"anywhere"},children:["Delete"," ",t.jsxs(M,{component:"span",sx:{fontSize:"18px",fontWeight:700,lineHeight:"28px",overflowWrap:"anywhere",display:"-webkit-inline-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",maxWidth:"100%",verticalAlign:"bottom"},children:["â",m==null?void 0:m.title,"â"]}),"? Comments, reactions, and clips made from this video will also be deleted. This cannot be undone."]})})]})},pe=({viewMode:e="grid",search:i=""})=>{var y,l;const[h,n]=u.useState(0),{data:o,loading:p}=P(Z,{variables:{getSharedVideosInput:{limit:100,offset:0}},pollInterval:h}),s=((l=(y=o==null?void 0:o.getSharedReplayVideos)==null?void 0:y.data)==null?void 0:l.rows)||[];O(s.map(a=>{var d;return(d=a.replay_video)==null?void 0:d.status}),n);const m=s.map(a=>({...a.replay_video,shared_by:a.sharer,permission:a.permission})),f=i.trim().toLowerCase(),g=f?m.filter(a=>{var d;return(d=a.title)==null?void 0:d.toLowerCase().includes(f)}):m;return t.jsx(V,{children:t.jsx(A,{videos:g,loading:p,viewMode:e,nullTitle:"Nothing shared with you yet",nullDescription:"Videos shared with you by coaches or teammates will appear here."})})},me={team:[],fixture:[],session:[]},ue={home:"My Uploads",shared:"Shared With Me",library:"Club Library"},he=()=>{try{return localStorage.getItem("replay_view_mode")||"grid"}catch{return"grid"}},fe=e=>e.includes("/replay/shared")?"shared":e.includes("/replay/library")?"library":"home",w={titleContainer:{height:"fit-content",borderRadius:"16px 16px 0px 0px",backgroundColor:e=>e.palette.common.white,borderBottom:e=>`1px solid ${e.palette.divider}`},heading:{fontSize:{xs:"20px",md:"32px"},fontWeight:"700",lineHeight:{xs:"24px",md:"48px"}},searchContainer:{padding:2,gap:1,width:"100%",backgroundColor:e=>e.palette.common.white,borderBottom:e=>`1px solid ${e.palette.divider}`,alignItems:"center",justifyContent:"space-between",flexWrap:"wrap"},toggleButton:{borderRadius:"8px",height:"32px",padding:"2px","& .MuiToggleButtonGroup-root":{height:"100%"},"& .MuiToggleButtonGroup-root .MuiButtonBase-root":{height:"100%"}},uploadBtn:{fontWeight:700,fontSize:"15px",lineHeight:"26px"},filterBtn:{height:"32px",padding:"4px 12px",color:"text.primary",border:e=>`1px solid ${e.border||e.palette.divider}`,"&:hover":{border:e=>`1px solid ${e.border||e.palette.divider}`,backgroundColor:"rgba(145, 158, 171, 0.08)"},"& .MuiButton-startIcon":{marginRight:"6px"}},searchBox:{width:{xs:"100%",md:320}}},pt=()=>{const[e,i]=$(),h=Q();G(r=>r.breakpoints.down("md"));const[n,o]=u.useState(he),[p,s]=u.useState(!1),[m,f]=u.useState(!1),[g,y]=u.useState(""),[l,a]=u.useState(()=>
1{try{return{team:e.getAll("team").map(Number).filter(Boolean),fixture:e.getAll("fixture").map(Number).filter(Boolean),session:e.getAll("session").map(Number).filter(Boolean)}}catch{return me}}),d=fe(h.pathname);u.useEffect(()=>{const r=new URLSearchParams;l.team.forEach(c=>r.append("team",c)),l.fixture.forEach(c=>r.append("fixture",c)),l.session.forEach(c=>r.append("session",c)),i(r,{replace:!0})},[l,i]);const v=(r,c)=>{if(c){o(c);try{localStorage.setItem("replay_view_mode",c)}catch{}}},x=r=>a(r);return t.jsxs(C,{container:!0,padding:{xs:0,md:"16px"},height:"100%",alignContent:"flex-start",children:[t.jsxs(C,{container:!0,flex:1,gap:{xs:1,md:2},p:{xs:2,md:3},sx:w.titleContainer,justifyContent:"space-between",alignItems:"center",children:[t.jsx(C,{children:t.jsx(M,{sx:w.heading,children:ue[d]})}),t.jsx(C,{container:!0,gap:{xs:1,md:2},alignItems:"center",children:t.jsx(F,{text:"Upload Video",startIcon:t.jsx(N,{}),customStyles:w.uploadBtn,onClick:()=>s(!0)})})]}),t.jsxs(C,{container:!0,sx:w.searchContainer,children:[t.jsx(C,{sx:w.searchBox,children:t.jsx(q,{value:g,onChange:r=>y(r.target.value),placeholder:"Search videosâ¦",size:"small"})}),t.jsxs(C,{container:!0,gap:{xs:1,md:2},alignItems:"center",sx:{width:"auto",ml:"auto"},children:[t.jsx(F,{text:"Filter",variant:"outlined",startIcon:t.jsx(J,{}),customStyles:w.filterBtn,onClick:()=>f(!0)}),t.jsx(K,{value:n,handleChange:v,iconHeight:16,iconWidth:16,customStyles:w.toggleButton})]})]}),t.jsxs(V,{width:"100%",children:[d==="home"&&t.jsx(ce,{viewMode:n,filters:l,search:g,onOpenUpload:()=>s(!0),onUploadComplete:()=>s(!1)}),d==="shared"&&t.jsx(pe,{viewMode:n,search:g}),d==="library"&&t.jsx(le,{viewMode:n,filters:l,search:g})]}),t.jsx(re,{open:p,handleClose:()=>s(!1),onUploadComplete:()=>s(!1)}),t.jsx(ae,{open:m,onClose:()=>f(!1),filters:l,onChange:x})]})};export{pt 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.