@halibegic/react-video-player 0.0.47 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,5 +13,5 @@ React keys must be passed directly to JSX without using spread:
13
13
  let props = %s;
14
14
  <%s key={someKey} {...props} />`,Ge,ce,ao,ce),qt[ce+Ge]=!0}}return r===o?no(U):to(U),U}}function ro(r,p,m){return $t(r,p,m,!0)}function oo(r,p,m){return $t(r,p,m,!1)}var io=oo,so=ro;we.Fragment=o,we.jsx=io,we.jsxs=so})()),we}var it;function hn(){return it||(it=1,process.env.NODE_ENV==="production"?Re.exports=dn():Re.exports=fn()),Re.exports}var s=hn();const oe={playerNotice:"_playerNotice_x3acc_1",playerNoticeTitle:"_playerNoticeTitle_x3acc_19",playerNoticeText:"_playerNoticeText_x3acc_28",playerNoticeLowZIndex:"_playerNoticeLowZIndex_x3acc_37"},st=typeof window!="undefined"?f.useLayoutEffect:f.useEffect;function be(e,t){const n=f.useRef(e);st(()=>{n.current=e},[e]),f.useEffect(()=>{if(t===null)return;const o=setInterval(()=>{n.current()},t);return()=>{clearInterval(o)}},[t])}function pn(e){const[,t]=f.useState(0);be(()=>t(n=>n+1),e)}const mn=()=>B.create(e=>({delay:0,startDate:null,viewerCount:null,setDelay:t=>e({delay:t}),setStartDate:t=>e({startDate:t}),setViewerCount:t=>e({viewerCount:t})})),at=f.createContext(null),vn=({children:e})=>{const t=f.useRef(null);return t.current||(t.current=mn()),s.jsx(at.Provider,{value:t.current,children:e})},N=e=>{const t=f.useContext(at);if(!t)throw new Error("usePlayerStore must be used within PlayerStoreProvider");return B.useStore(t,e)};function yn(e,t,n){const o={days:86400,hours:3600,minutes:60,seconds:1,milliseconds:.001};return e*(o[t]/o[n])}function gn(e){return yn(e,"milliseconds","seconds")}const Ce=e=>{if(isNaN(e)||e===1/0)return"0:00";const t=l=>(l<10?"0":"")+l,n=Math.floor(e/3600),o=Math.floor(e%3600/60),a=Math.floor(e%60);return n===0?`${o}:${t(a)}`:`${n}:${t(o)}:${t(a)}`};function wn(e,t){var n,o,a,l,u,i;if(typeof Intl!="undefined"&&Intl.DateTimeFormat)try{const d=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),y=parseInt(((n=d.find(P=>P.type==="year"))==null?void 0:n.value)||"0",10),g=parseInt(((o=d.find(P=>P.type==="month"))==null?void 0:o.value)||"0",10)-1,w=parseInt(((a=d.find(P=>P.type==="day"))==null?void 0:a.value)||"0",10),k=parseInt(((l=d.find(P=>P.type==="hour"))==null?void 0:l.value)||"0",10),M=parseInt(((u=d.find(P=>P.type==="minute"))==null?void 0:u.value)||"0",10),T=parseInt(((i=d.find(P=>P.type==="second"))==null?void 0:i.value)||"0",10);return new Date(y,g,w,k,M,T)}catch(c){return console.warn(`Failed to convert date to timezone ${t}, returning original date:`,c),e}return console.warn("Intl.DateTimeFormat not available, timezone conversion may be inaccurate"),e}function lt(e){var n;const t=typeof window!="undefined"&&((n=window.navigator)==null?void 0:n.userAgent)||"";return e.test(t)}const ct=lt(/iPhone|iPad|iPod/i),Cn=lt(/Tizen/i);function xn(){const e=document;return!!(e.fullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||e.msFullscreenElement)}function Tn(e){e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.webkitEnterFullScreen?e.webkitEnterFullScreen():e.mozRequestFullScreen&&e.mozRequestFullScreen()}function _n(e){e.exitFullscreen?e.exitFullscreen():e.msExitFullscreen?e.msExitFullscreen():e.webkitExitFullscreen?e.webkitExitFullscreen():e.mozCancelFullScreen&&e.mozCancelFullScreen()}function En(e,t){return e.addEventListener("fullscreenchange",t),e.addEventListener("webkitfullscreenchange",t),e.addEventListener("mozfullscreenchange",t),e.addEventListener("MSFullscreenChange",t),()=>{e.removeEventListener("fullscreenchange",t),e.removeEventListener("webkitfullscreenchange",t),e.removeEventListener("mozfullscreenchange",t),e.removeEventListener("MSFullscreenChange",t)}}const Rn=()=>ee(),bn=(e,t)=>({currentTime:0,duration:0,isEnded:!1,isLoading:!1,isLoop:!1,isMetaLoaded:!1,isPlaying:!1,isReady:!1,isStarted:!1,pauseTime:0,seekTime:-1,startTime:-1,volume:100,destroy:()=>{},handleDurationChange:()=>{const n=t().techRef.current;n&&e({duration:n.duration})},handleEnd:()=>{t().techRef.current&&(t().eventEmitter.emit("ended"),e({isEnded:!0,isLoading:!1,isMetaLoaded:!1,isPlaying:!1}))},handleLoadedMetadata:()=>{const n=t().techRef.current;n&&(t().eventEmitter.emit("loadedMetadata",{duration:n.duration}),n.loop=t().isLoop,n.volume=n.muted?0:1,t().startTime!==-1&&(n.currentTime=t().startTime),e({currentTime:t().startTime!==-1?t().startTime:n.currentTime,duration:n.duration,startTime:-1,isMetaLoaded:!0,volume:n.muted?0:100}))},handleLoadStart:()=>{const n=t().techRef.current;n&&(t().eventEmitter.emit("loadStart"),e({isReady:!0}),n.play().then(()=>{e({isEnded:!1,isLoading:!1,isPlaying:!0,isStarted:!0,pauseTime:0})}).catch(()=>{e({isStarted:!1,isEnded:!1,isLoading:!1,isPlaying:!1})}))},handlePause:()=>{t().techRef.current&&(t().eventEmitter.emit("pause"),e({isPlaying:!1,pauseTime:Date.now()}))},handlePlay:()=>{t().techRef.current&&(t().eventEmitter.emit("play"),e({isPlaying:!0,pauseTime:0}))},handlePlaying:()=>{t().techRef.current&&(t().eventEmitter.emit("playing"),e({isLoading:!1}))},handleSeeked:()=>{t().techRef.current&&(t().eventEmitter.emit("seeked"),e({isLoading:!1}))},handleSeeking:()=>{t().techRef.current&&(t().eventEmitter.emit("seeking"),e({isLoading:!0}))},handleTimeUpdate:()=>{const n=t().techRef.current;n&&(t().eventEmitter.emit("timeUpdate",{currentTime:n.currentTime,duration:n.duration}),e({currentTime:n.currentTime}))},handleWaiting:()=>{t().techRef.current&&(t().eventEmitter.emit("waiting"),e({isLoading:!0}))},handleVolumeChange:()=>{const n=t().techRef.current;n&&t().eventEmitter.emit("volumeChange",{volume:n.volume})},handleError:n=>{const o=t().techRef.current;if(!o)return;t().eventEmitter.emit("error",n);const a=o.error;if(!a)return;const l=`${a.code}`,u=a.message||"Unknown error occurred";e({error:{message:u,code:l,tech:"native"}})},pause:()=>{const n=t().techRef.current;n&&(n.pause(),e({isEnded:!1,isPlaying:!1,pauseTime:Date.now()}))},getPauseTimeDiff:()=>!t().isStarted||!t().pauseTime?0:parseInt(gn(Date.now()-t().pauseTime).toFixed(0)),play:()=>{const n=t().techRef.current;n&&n.play().then(()=>{e({isEnded:!1,isLoading:!1,isPlaying:!0,isStarted:!0,pauseTime:0})}).catch(()=>{e({isStarted:!1,isEnded:!1,isLoading:!1,isPlaying:!1})})},seek:n=>{const o=t().techRef.current;o&&(o.currentTime=n,(o.paused||o.ended)&&o.play(),e({seekTime:-1,currentTime:n,isStarted:!0,isEnded:!1,isPlaying:!0}))},setIsLoading:n=>e({isLoading:n}),setIsLoop:n=>{const o=t().techRef.current;o&&(o.loop=n,e({isLoop:n}))},setStartTime:n=>e({startTime:n}),setVolume:n=>{const o=t().techRef.current;o&&(o.muted=n===0,o.volume=n/100,e({volume:n}))},stop:()=>{t().techRef.current&&e({isPlaying:!1,isLoading:!1})}}),Sn=(e,t)=>({isIdle:!1,setIsIdle:n=>e({isIdle:n}),resetIdle:()=>t().eventEmitter.emit("resetIdle")}),jn=e=>({idleLocks:new Set,addIdleLock:t=>e(n=>({idleLocks:new Set(n.idleLocks).add(t)})),removeIdleLock:t=>e(n=>{const o=new Set(n.idleLocks);return o.delete(t),{idleLocks:o}})}),Pn=(e,t)=>({level:null,levels:null,setLevels:n=>e({levels:n}),setLevel:n=>{n&&t().eventEmitter.emit("qualityChange",{level:n}),e({level:n})}}),Ln=(e,t)=>({isFullscreen:!1,isFullscreenReady:!1,exitFullscreen:()=>{t().eventEmitter.emit("fullscreenChange",{isFullscreen:!1}),_n(document),e({isFullscreen:!1})},requestFullscreen:()=>{const n=t().techRef.current,o=t().containerRef.current;if(!n||!o)return;t().eventEmitter.emit("fullscreenChange",{isFullscreen:!0});const a=ct?n:o;a&&Tn(a),e({isFullscreen:!0})},setIsFullscreen:n=>e({isFullscreen:n}),setIsFullscreenReady:n=>e({isFullscreenReady:n})}),kn=e=>({error:null,setError:t=>e({error:t})}),In=()=>({eventEmitter:Rn()}),Dn=e=>()=>L({},e),Mn=(e,t)=>B.create()((...n)=>L(L(L(L(L(L(L(L({},bn(...n)),Sn(...n)),jn(...n)),Ln(...n)),Pn(...n)),kn(...n)),In(...n)),Dn({techRef:e,containerRef:t})(...n))),ut=f.createContext(null);function Fn({children:e}){const t=f.useRef(null),n=f.useRef(null),o=f.useRef(null);return t.current||(t.current=Mn(n,o)),s.jsx(ut.Provider,{value:t.current,children:e})}const h=e=>{const t=f.useContext(ut);if(!t)throw new Error("usePlayerStore must be used within PlayerStoreProvider");return B.useStore(t,e)};function Vn(e){const t=e.split(`
15
15
  `);for(const n of t){const o=n.trim();if(o.startsWith("#EXT-X-PROGRAM-DATE-TIME:")){const a=o.replace("#EXT-X-PROGRAM-DATE-TIME:","").trim(),l=new Date(a);if(!isNaN(l.getTime()))return wn(l,"Europe/Sarajevo")}}return null}function Nn(e,t){const n=e.split(`
16
- `);let o=!1;for(const a of n){const l=a.trim();if(l.startsWith("#EXT-X-STREAM-INF:")){o=!0;continue}if(o&&!l.startsWith("#")){if(l.startsWith("http"))return l;{const u=new URL(t);return new URL(l,u.origin+u.pathname.substring(0,u.pathname.lastIndexOf("/"))+"/").toString()}}}return null}function An(e){return e.replace("playlist.m3u8","playlist_fmp4_dvr.m3u8")}async function On(e){try{const t=An(e);console.log("Converting to DVR URL:",t);const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch master playlist: ${n.status} ${n.statusText}`);const o=await n.text(),a=Nn(o,t);if(!a)throw new Error("No chunklist URL found in master playlist");console.log("Found chunklist URL:",a);const l=await fetch(a);if(!l.ok)throw new Error(`Failed to fetch chunklist: ${l.status} ${l.statusText}`);const u=await l.text(),i=Vn(u);return i?console.log("Successfully detected start time:",i.toISOString()):console.log(" No start time found in chunklist"),i}catch(t){return console.error("Error getting start time from HLS URL:",t),null}}function Hn(n){var o=n,{url:e}=o,t=re(o,["url"]);const[a,l]=f.useState(!0),u=N(d=>d.startDate),i=N(d=>d.setStartDate),c=f.useCallback(async()=>{const d=await On(e);d&&i(d)},[e,i]);return f.useEffect(()=>{(async()=>{l(!0),await c(),l(!1)})()},[c]),be(c,u?null:5e3),a?null:s.jsx(Un,L({},t))}function Un({children:e,messages:t={}}){var u,i,c;const n=N(d=>d.startDate),o=h(d=>d.isStarted);return pn(o?null:5e3),n?Date.now()<n.getTime()?s.jsx(Bn,{startDate:n,title:(i=t==null?void 0:t.eventNotStarted)!=null?i:"Event has not started yet.",message:(c=t==null?void 0:t.eventStartingSoon)!=null?c:"Starting in few seconds..."}):s.jsx(s.Fragment,{children:e}):s.jsx("div",{className:oe.playerNotice,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:(u=t==null?void 0:t.unableToPlay)!=null?u:"Unable to play the video. Please try again later."})})}function Bn({startDate:e,title:t,message:n}){const o=e.getTime()-Date.now(),a=Math.floor(o/(1e3*60*60)),l=Math.floor(o%(1e3*60*60)/(1e3*60));return a||l?s.jsxs("div",{className:oe.playerNotice,children:[s.jsx("h3",{className:oe.playerNoticeTitle,children:t}),s.jsxs("p",{className:oe.playerNoticeText,children:["(",a>0?`${a}h ${l}m`:`${l}m`,")"]})]}):s.jsx("div",{className:oe.playerNotice,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:n})})}function dt({callback:e}){const t=h(n=>n.eventEmitter);return f.useEffect(()=>{const n=()=>e("play",void 0),o=()=>e("pause",void 0),a=()=>e("ended",void 0),l=()=>e("seeking",void 0),u=()=>e("seeked",void 0),i=T=>e("volumeChange",T),c=T=>e("fullscreenChange",T),d=T=>e("qualityChange",T),y=T=>e("loadedMetadata",T),g=()=>e("loadStart",void 0),w=()=>e("playing",void 0),k=()=>e("waiting",void 0),M=()=>e("error",void 0);return t.on("play",n),t.on("pause",o),t.on("ended",a),t.on("seeking",l),t.on("seeked",u),t.on("volumeChange",i),t.on("fullscreenChange",c),t.on("qualityChange",d),t.on("loadedMetadata",y),t.on("loadStart",g),t.on("playing",w),t.on("waiting",k),t.on("error",M),()=>{t.off("play",n),t.off("pause",o),t.off("ended",a),t.off("seeking",l),t.off("seeked",u),t.off("volumeChange",i),t.off("fullscreenChange",c),t.off("qualityChange",d),t.off("loadedMetadata",y),t.off("loadStart",g),t.off("playing",w),t.off("waiting",k),t.off("error",M)}},[e,t]),null}const ft=(e,t=0)=>parseInt(Math.max(0,(Date.now()-(e+t*1e3))/1e3).toFixed(0)),ht=(e,t)=>Math.max(0,(Date.now()-e-t*1e3)/1e3),zn=(e,t)=>Math.max(0,(t-e)/1e3),Wn=(e,t=0)=>{const o=t<0?0:t,a=["bytes","kb","mb","gb","tb","pb","eb","zb","yb"],l=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,l)).toFixed(o))}${a[l]}`};function Zn({isAuto:e,level:t,levels:n}){const o=n.length,a=[];return o>1&&a.push({sid:"quality-level-auto",label:"Auto",value:-1,selected:e||t===-1}),n.sort(function(l,u){const i=l.height||l.bitrate||0,c=u.height||u.bitrate||0;return i===c?0:i>c?1:-1}),n.map(l=>{const{bitrate:u,height:i,index:c}=l;a.push({sid:`quality-level-${c}`,label:i?`${i}p`:Wn(u),value:c,selected:o===1||!e&&c===t})}),a}function Kn({callback:e}){const t=N(l=>l.delay),n=N(l=>l.startDate),o=n?n.getTime():0,a=h(l=>l.eventEmitter);return f.useEffect(()=>{const l=()=>e("timeUpdate",{currentTime:ht(o,t),duration:-1});return a.on("timeUpdate",l),()=>{a.off("timeUpdate",l)}},[e,a]),s.jsx(dt,{callback:e})}function pt(){const e=h(i=>i.exitFullscreen),t=h(i=>i.isFullscreen),n=h(i=>i.isFullscreenReady),o=h(i=>i.requestFullscreen),a=h(i=>i.setVolume),l=h(i=>i.volume),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowUp":a(l+10<100?l+10:100),c=!0;break;case"ArrowDown":a(l-10>0?l-10:0),c=!0;break;case"KeyM":a(l===0?100:0),c=!0;break;case"KeyF":n&&(t?e():o(),c=!0);break}c&&i.preventDefault()}},[e,t,n,o,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),null}function Yn(){const e=N(i=>i.delay),t=h(i=>i.isPlaying),n=h(i=>i.pause),o=h(i=>i.getPauseTimeDiff),a=h(i=>i.play),l=N(i=>i.setDelay),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowLeft":l(e+10),c=!0;break;case"ArrowRight":l(e-10>0?e-10:0),c=!0;break;case"Space":if(t)n();else{const d=o();d&&l(e+d),a()}c=!0;break}c&&i.preventDefault()}},[e,o,t,n,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),s.jsx(pt,{})}function mt({children:e}){return s.jsx(Fn,{children:e})}function Xn({children:e}){return s.jsx(vn,{children:s.jsx(mt,{children:e})})}function Gn({url:e,isLive:t,messages:n}){const o=f.useRef(null),a=h(x=>x.level),l=h(x=>x.levels),u=h(x=>x.setLevel),i=h(x=>x.setLevels),c=h(x=>x.techRef),d=h(x=>x.setError),y=f.useRef(0),g=f.useRef(null),w=50,k=1e4,M=f.useCallback(x=>{if(o.current&&(o.current.nextLevel=x,u(null),l)){const V=l.map(v=>me(L({},v),{selected:v.value===x}));i(V)}},[l,u,i,o]),T=f.useCallback(()=>{o.current&&(console.log("[Player][HLS] MEDIA_ATTACHED"),o.current.loadSource(e))},[e]),P=f.useCallback(()=>{if(!o.current)return;console.log("[Player][HLS] MANIFEST_LOADED"),d(null),g.current&&(clearTimeout(g.current),g.current=null),y.current=0;const x=o.current.levels,V=o.current.currentLevel,v=o.current.autoLevelEnabled;i(Zn({levels:x.map((W,G)=>{const{bitrate:Z,height:O,width:D}=W;return{bitrate:Z,height:O,index:G,width:D}}),level:V,isAuto:v}))},[d,i]),A=f.useCallback((x,V)=>{var v;if(o.current&&V.fatal)switch(V.type){case te.ErrorTypes.NETWORK_ERROR:let W=(v=n==null?void 0:n.unableToPlay)!=null?v:"Unable to play the video. Please try again later.",G="NETWORK_ERROR";console.log("[Player][HLS] NETWORK_ERROR",V),t?(y.current<w&&(g.current&&clearTimeout(g.current),y.current+=1,g.current=setTimeout(()=>{if(o.current)try{console.log("[Player][HLS] Retrying stream..."),o.current.loadSource(e)}catch(Z){console.error("[Player][HLS] Retry failed:",Z)}},k)),G="LIVE_MANIFEST_LOAD_ERROR"):o.current.startLoad(),d({message:W,code:G,tech:"hls"});break;case te.ErrorTypes.MEDIA_ERROR:o.current.recoverMediaError();break}},[t,e,d]),S=f.useCallback(()=>{if(!c.current)return;let x={startLevel:-1,maxBufferSize:30*1024*1024};Cn?(x.backBufferLength=-1,x.enableWorker=!1):t?x.backBufferLength=10:x.backBufferLength=60;try{console.log("[Player][HLS] URL",e),console.log("[Player][HLS] Config",JSON.stringify(x)),console.log("[Player][HLS] Version",te.version),o.current=new te(x),o.current.attachMedia(c.current),o.current.on(te.Events.MEDIA_ATTACHED,T),o.current.on(te.Events.MANIFEST_LOADED,P),o.current.on(te.Events.ERROR,A)}catch(V){throw new Error(`Error initializing Hls: ${V}`)}},[P,T,A,t,c,e]),I=f.useCallback(()=>{o.current&&(o.current.off(te.Events.MEDIA_ATTACHED,T),o.current.off(te.Events.MANIFEST_LOADED,P),o.current.off(te.Events.ERROR,A),o.current.destroy(),o.current=null),g.current&&(clearTimeout(g.current),g.current=null),y.current=0},[P,T,A]);return f.useEffect(()=>{a!==null&&M(a)},[a,M]),f.useEffect(()=>(te.isSupported()&&S(),I),[I,S]),null}const Jn={playerVideo:"_playerVideo_wc0sm_1"};function vt({url:e,isLive:t,isMuted:n=!1,messages:o={}}){const a=h(v=>v.handleDurationChange),l=h(v=>v.handleEnd),u=h(v=>v.handleLoadedMetadata),i=h(v=>v.handleLoadStart),c=h(v=>v.handlePause),d=h(v=>v.handlePlay),y=h(v=>v.handlePlaying),g=h(v=>v.handleSeeked),w=h(v=>v.handleSeeking),k=h(v=>v.handleTimeUpdate),M=h(v=>v.handleWaiting),T=h(v=>v.handleVolumeChange),P=h(v=>v.handleError),A=h(v=>v.techRef),S=f.useRef(null),I=()=>t?{onTimeUpdate:x}:{onDurationChange:a,onSeeked:g,onSeeking:w,onTimeUpdate:x},x=()=>{(!S.current||Date.now()-S.current>=1e3)&&(k(),S.current=Date.now())},V=I();return s.jsxs(s.Fragment,{children:[s.jsx(Gn,{isLive:t,url:e,messages:o}),s.jsx("video",L({ref:A,className:Jn.playerVideo,playsInline:!0,autoPlay:!0,controls:!1,muted:n,preload:"auto",crossOrigin:"anonymous",onEnded:l,onError:P,onLoadedMetadata:u,onLoadStart:i,onPause:c,onPlay:d,onPlaying:y,onWaiting:M,onVolumeChange:T,tabIndex:-1},V))]})}function Qn({url:e,messages:t={}}){const[n,o]=f.useState(null),a=N(u=>u.delay),l=f.useCallback(async()=>{o(a?e.replace("-live","-catchup").replace("playlist.m3u8",`playlist_fmp4_dvr_timeshift-${a}.m3u8`):e)},[a,e]);return f.useEffect(()=>{l()},[l]),n?s.jsx(vt,{url:n,isLive:!0,messages:t}):null}function qn({url:e}){return h(n=>n.isStarted)?s.jsx($n,{url:e}):null}function $n({url:e}){const t=N(l=>l.setViewerCount),n=f.useRef(null),o=l=>{try{return new URL(l).pathname.split("/").filter(d=>d.length>0)[0]||null}catch(u){return console.error("Failed to extract URI from player URL:",u),null}},a=async()=>{var c;const l=o(e);if(!l){console.error("Could not extract URI from URL:",e);return}n.current&&n.current.abort(),n.current=new AbortController;const i=`https://${e.includes("staging")?"stg":"prd"}-fitnessanny.spectar.tv/analytics-api/v1/token-info/uri/${l}`;try{const d=await fetch(i,{signal:n.current.signal});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);const g=(c=(await d.json()).count)!=null?c:0;t(g)}catch(d){if(d.name==="AbortError")return;console.error("Failed to fetch viewer count:",d),t(null)}};return f.useEffect(()=>(a(),()=>{n.current&&n.current.abort()}),[e]),be(a,15e3),null}function er(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const o=i=>typeof window=="undefined"?t:window.matchMedia(i).matches,[a,l]=f.useState(()=>n?o(e):t);function u(){l(o(e))}return st(()=>{if(typeof window=="undefined")return;const i=window.matchMedia(e);return u(),i.addListener?i.addListener(u):i.addEventListener("change",u),()=>{i.removeListener?i.removeListener(u):i.removeEventListener("change",u)}},[e]),a}const ue={playbackButton:"_playbackButton_lgsgw_1",seekIndicator:"_seekIndicator_lgsgw_23",seekIndicatorLeft:"_seekIndicatorLeft_lgsgw_49",seekIndicatorRight:"_seekIndicatorRight_lgsgw_53",seekIndicatorVisible:"_seekIndicatorVisible_lgsgw_57"},tr=10;function yt(i){var c=i,{className:e,onClick:t,onForwardSeek:n,onBackwardSeek:o,maxForwardTime:a,maxBackwardTime:l}=c,u=re(c,["className","onClick","onForwardSeek","onBackwardSeek","maxForwardTime","maxBackwardTime"]);return er("(min-width: 1024px)")?s.jsx(nr,L({className:e,onClick:t},u)):s.jsx(rr,L({className:e,maxForwardTime:a,maxBackwardTime:l,onForwardSeek:n,onBackwardSeek:o},u))}function nr(o){var a=o,{className:e,onClick:t}=a,n=re(a,["className","onClick"]);const l=f.useRef(null),u=h(T=>T.exitFullscreen),i=h(T=>T.isFullscreen),c=h(T=>T.requestFullscreen),d=h(T=>T.resetIdle),y=T=>{k()?(w(),i?u():c()):g(T)},g=T=>{l.current=window.setTimeout(()=>{t==null||t(T),w()},200)},w=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},k=()=>l.current!==null,M=()=>{d()};return f.useEffect(()=>()=>{w()},[]),s.jsx("button",L({onClick:y,onMouseMove:M,className:[ue.playbackButton,e].filter(Boolean).join(" "),"aria-label":"Player gestures"},n))}function rr(u){var i=u,{className:e,maxForwardTime:t,maxBackwardTime:n,onForwardSeek:o,onBackwardSeek:a}=i,l=re(i,["className","maxForwardTime","maxBackwardTime","onForwardSeek","onBackwardSeek"]);const c=f.useRef(null),d=f.useRef({single:null,indicator:null,accumulate:null}),y=f.useRef(null),g=f.useRef(0),w=f.useRef(null),[k,M]=f.useState({visible:!1,direction:null,time:0}),T=h(v=>v.isIdle),P=h(v=>v.setIsIdle),A=h(v=>v.resetIdle),S=(v,W)=>v<W/2?"backward":"forward",I=v=>{if(!y.current)return;const W=v.changedTouches[0];if(!W)return;const G=Date.now(),Z=y.current.getBoundingClientRect(),O=W.clientX-Z.left,D=W.clientY-Z.top;if(O<0||O>Z.width||D<0||D>Z.height)return;const q=c.current,X=q?G-q.time:1/0,K=S(O,Z.width),se=w.current!==null&&w.current===K&&q!==null&&X<700&&Math.abs(O-q.x)<100;if(q!==null&&w.current===null&&X<300&&Math.abs(O-q.x)<50||se){v.preventDefault(),v.stopPropagation(),d.current.single&&(window.clearTimeout(d.current.single),d.current.single=null),A(),(w.current===null||w.current!==K)&&(g.current=0,w.current=K);const ne=K==="backward"?n:t;g.current=Math.min(g.current+tr,ne!=null?ne:1/0),x(K,g.current),d.current.accumulate&&window.clearTimeout(d.current.accumulate),d.current.accumulate=window.setTimeout(()=>{const Y=g.current;Y>0&&(w.current==="backward"?a==null||a(Y):o==null||o(Y),A()),g.current=0,w.current=null,c.current=null,V(),d.current.accumulate=null},500),c.current={time:G,x:O}}else{c.current={time:G,x:O},d.current.single&&window.clearTimeout(d.current.single);const ne=w.current!==null?700:350;d.current.single=window.setTimeout(()=>{if(w.current===null){d.current.single=null;const Y=T;P(!Y),Y&&A()}c.current=null},ne)}},x=(v,W)=>{W!==0&&(M({visible:!0,direction:v,time:W}),d.current.indicator&&window.clearTimeout(d.current.indicator),d.current.indicator=window.setTimeout(()=>{V()},700))},V=()=>{M({visible:!1,direction:null,time:0}),d.current.indicator&&(window.clearTimeout(d.current.indicator),d.current.indicator=null)};return f.useEffect(()=>()=>{d.current.single&&window.clearTimeout(d.current.single),d.current.indicator&&window.clearTimeout(d.current.indicator),d.current.accumulate&&window.clearTimeout(d.current.accumulate)},[]),s.jsxs(s.Fragment,{children:[s.jsx("button",L({ref:y,onTouchEnd:I,className:[ue.playbackButton,e].filter(Boolean).join(" "),"aria-label":"Player gestures"},l)),k.visible&&s.jsxs("div",{className:`${ue.seekIndicator} ${ue.seekIndicatorVisible} ${k.direction==="backward"?ue.seekIndicatorLeft:ue.seekIndicatorRight}`,children:[k.direction==="backward"?"-":"+",Ce(k.time)]})]})}function or(){const e=h(c=>c.isPlaying),t=h(c=>c.pause),n=h(c=>c.getPauseTimeDiff),o=h(c=>c.play),a=N(c=>c.delay),l=N(c=>c.setDelay),u=N(c=>c.startDate),i=u?u.getTime():0;return s.jsx(yt,{onClick:()=>{if(e)t();else{const c=n();c&&l(a+c),o()}},onBackwardSeek:c=>{const d=a+c;l(d)},onForwardSeek:c=>{const d=Math.max(0,a-c);l(d)},maxBackwardTime:Math.floor(i),maxForwardTime:Math.floor(a)})}const gt={playerButton:"_playerButton_izwqq_1",playerButtonCircle:"_playerButtonCircle_izwqq_42"},le=f.forwardRef((a,o)=>{var l=a,{shape:e="circle",className:t}=l,n=re(l,["shape","className"]);const u=e==="circle"?gt.playerButtonCircle:"",i=[gt.playerButton,u,t].filter(Boolean).join(" ");return s.jsx("button",L({ref:o,className:i},n))});le.displayName="PlayerButton";const Se={liveIndicator:"_liveIndicator_1jczn_1",liveIndicatorHasDelay:"_liveIndicatorHasDelay_1jczn_9",liveIndicatorNoDelay:"_liveIndicatorNoDelay_1jczn_13"};function ir(n){var o=n,{message:e}=o,t=re(o,["message"]);const a=N(c=>c.delay),l=N(c=>c.setDelay),u=()=>{a&&l(0)},i=a?`${Se.liveIndicator} ${Se.liveIndicatorHasDelay}`:`${Se.liveIndicator} ${Se.liveIndicatorNoDelay}`;return s.jsxs(le,me(L({onClick:u,shape:"square"},t),{children:[s.jsx("div",{className:i}),e||"Live"]}))}function wt(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6 5H8V19H6V5ZM16 5H18V19H16V5Z"})})}function Ct(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M19.376 12.4161L8.77735 19.4818C8.54759 19.635 8.23715 19.5729 8.08397 19.3432C8.02922 19.261 8 19.1645 8 19.0658V4.93433C8 4.65818 8.22386 4.43433 8.5 4.43433C8.59871 4.43433 8.69522 4.46355 8.77735 4.5183L19.376 11.584C19.6057 11.7372 19.6678 12.0477 19.5146 12.2774C19.478 12.3323 19.4309 12.3795 19.376 12.4161Z"})})}function sr(){const e=h(i=>i.isPlaying),t=h(i=>i.pause),n=h(i=>i.getPauseTimeDiff),o=h(i=>i.play),a=N(i=>i.delay),l=N(i=>i.setDelay),u=()=>{if(e)t();else{const i=n();i&&l(a+i),o()}};return s.jsx(le,{onClick:u,children:e?s.jsx(wt,{}):s.jsx(Ct,{})})}const ie={progressSlider:"_progressSlider_hwzgf_1",tipContainer:"_tipContainer_hwzgf_7",tipContainerVisible:"_tipContainerVisible_hwzgf_17",tipContainerHidden:"_tipContainerHidden_hwzgf_22",tipContent:"_tipContent_hwzgf_27"},je={sliderRoot:"_sliderRoot_aeak6_1",sliderTrack:"_sliderTrack_aeak6_18",sliderRange:"_sliderRange_aeak6_28",sliderThumb:"_sliderThumb_aeak6_37"},Pe=f.forwardRef((l,a)=>{var u=l,{max:e=100,min:t=0,className:n}=u,o=re(u,["max","min","className"]);return s.jsxs(_e.Root,me(L({ref:a,min:t,max:e,"aria-label":"Player progress",className:[je.sliderRoot,n].filter(Boolean).join(" "),onKeyDown:i=>i.preventDefault()},o),{children:[s.jsx(_e.Track,{className:je.sliderTrack,children:s.jsx(_e.Range,{className:je.sliderRange})}),s.jsx(_e.Thumb,{className:je.sliderThumb})]}))});Pe.displayName="PlayerSlider";function Le(e){const t=e.getBoundingClientRect();return e.offsetWidth/e.offsetHeight>e.clientWidth/e.clientHeight?{left:t.left*100,right:t.right*100,top:t.top*100,bottom:t.bottom*100,width:t.width*100,height:t.height*100}:t}const xt="vod-player-progress-bar";function ar(){const e=f.useRef(null),t=f.useRef(null),[n,o]=f.useState(0),[a,l]=f.useState(0),[u,i]=f.useState(!1),[c,d]=f.useState(-1),[y,g]=f.useState(-1),w=N(D=>D.delay),k=N(D=>D.startDate),M=k?k.getTime():0,T=new Date().getTime(),P=N(D=>D.setDelay),A=h(D=>D.isPlaying),S=h(D=>D.addIdleLock),I=h(D=>D.removeIdleLock),x=f.useCallback(()=>{o(ht(M,w)),l(zn(M,T))},[w,T,M]),V=parseFloat((a?(y!==-1?y:n)/a*100:0).toFixed(1)),v=D=>{g(a*(D[0]/100)),S(xt)},W=()=>{if(y!==-1){const D=ft(M,y);P(D),g(-1),I(xt)}},G=()=>i(!0),Z=()=>i(!1),O=f.useCallback(D=>{const q=e.current,X=t.current;if(q&&X){const K=Le(q),se=Le(X),fe=(D.pageX||D.clientX)-K.left,ne=fe/K.width;if(ne<0)return;let Y=fe-se.width/2;Y<0&&(Y=0),Y>K.width-se.width&&(Y=-1),X.style.left=Y>-1?`${Y}px`:"auto",X.style.right=Y>-1?"auto":"0px";const xe=a-ne*a;d(xe>0?xe:0)}G()},[a]);return be(()=>x(),A?1e3:null),f.useEffect(()=>{x()},[x]),s.jsxs("div",{className:ie.progressSlider,children:[s.jsx(Pe,{ref:e,value:[V],onPointerLeave:Z,onPointerDown:Z,onPointerMove:O,onValueChange:v,onValueCommit:W,step:.1}),s.jsx("div",{ref:t,className:`${ie.tipContainer} ${u?ie.tipContainerVisible:ie.tipContainerHidden}`,children:s.jsx("p",{className:ie.tipContent,children:`-${Ce(c)}`})})]})}function lr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 12C22 17.5228 17.5229 22 12 22C6.4772 22 2 17.5228 2 12C2 6.47715 6.4772 2 12 2V4C7.5817 4 4 7.58172 4 12C4 16.4183 7.5817 20 12 20C16.4183 20 20 16.4183 20 12C20 9.53614 18.8862 7.33243 17.1346 5.86492L15 8V2L21 2L18.5535 4.44656C20.6649 6.28002 22 8.9841 22 12Z"})})}function cr(){const e=N(a=>a.startDate),t=N(a=>a.setDelay),n=e?e.getTime():0,o=()=>t(ft(n));return s.jsx(le,{onClick:o,children:s.jsx(lr,{})})}const ke={viewersContainer:"_viewersContainer_z1ihz_1",viewersIndicator:"_viewersIndicator_z1ihz_16",viewersIcon:"_viewersIcon_z1ihz_24",viewersCount:"_viewersCount_z1ihz_28"};function ur(){const e=N(t=>t.viewerCount);return e?s.jsxs("div",{className:ke.viewersContainer,children:[s.jsx("span",{className:ke.viewersIndicator}),s.jsxs("svg",{className:ke.viewersIcon,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M8 7C9.10457 7 10 6.10457 10 5C10 3.89543 9.10457 3 8 3C6.89543 3 6 3.89543 6 5C6 6.10457 6.89543 7 8 7Z",fill:"currentColor"}),s.jsx("path",{d:"M8 8C5.79086 8 4 9.79086 4 12V13H12V12C12 9.79086 10.2091 8 8 8Z",fill:"currentColor"})]}),s.jsx("span",{className:ke.viewersCount,children:e.toLocaleString()})]}):null}function Tt(){const e=h(n=>n.error);if(!e)return null;const t=e.code==="LIVE_MANIFEST_LOAD_ERROR";return s.jsx("div",{className:`${oe.playerNotice} ${t?oe.playerNoticeLowZIndex:""}`,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:e.message})})}const z={playerContainer:"_playerContainer_146tx_1",controlsTop:"_controlsTop_146tx_12",controlsBottom:"_controlsBottom_146tx_29",controlsContainer:"_controlsContainer_146tx_45",controlsRow:"_controlsRow_146tx_61",controlsSection:"_controlsSection_146tx_68",controlsSectionStart:"_controlsSectionStart_146tx_78",controlsSectionEnd:"_controlsSectionEnd_146tx_82"};function dr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M16 3H22V9H20V5H16V3ZM2 3H8V5H4V9H2V3ZM20 19V15H22V21H16V19H20ZM4 19H8V21H2V15H4V19Z"})})}function fr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18 7H22V9H16V3H18V7ZM8 9H2V7H6V3H8V9ZM18 17V21H16V15H22V17H18ZM8 15V21H6V17H2V15H8Z"})})}function _t(){const e=h(d=>d.containerRef),t=h(d=>d.exitFullscreen),n=h(d=>d.isFullscreen),o=h(d=>d.requestFullscreen),a=h(d=>d.setIsFullscreen),l=h(d=>d.setIsFullscreenReady),u=h(d=>d.techRef),i=f.useCallback(d=>{d.stopPropagation(),a(xn())},[a]),c=()=>{n?t():o()};return f.useEffect(()=>{const d=ct?u.current:e.current;if(d)return En(d,i)},[e,i,u]),f.useEffect(()=>{l(!0)},[l]),s.jsx(le,{onClick:c,children:n?s.jsx(fr,{}):s.jsx(dr,{})})}const Ue={idleCheckContainer:"_idleCheckContainer_crh2s_1",idleCheckContainerIdle:"_idleCheckContainerIdle_crh2s_5",idleCheckContainerActive:"_idleCheckContainerActive_crh2s_11"},hr=5*1e3;function Et({children:e}){const t=f.useRef(null),n=h(w=>w.isIdle),o=h(w=>w.setIsIdle),a=f.useRef(null),u=h(w=>w.idleLocks).size,i=h(w=>w.eventEmitter),c=f.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),d=f.useCallback(()=>{c(),a.current=window.setTimeout(()=>o(!0),hr)},[c]);f.useEffect(()=>(o(!1),d(),()=>{c()}),[c,d]),f.useEffect(()=>{const w=()=>{o(!1),d()};return i.on("resetIdle",w),()=>{i.off("resetIdle",w)}},[i,o,d]);const y=n&&!u,g=`${Ue.idleCheckContainer} ${y?Ue.idleCheckContainerIdle:Ue.idleCheckContainerActive}`;return s.jsx("div",{ref:t,className:g,children:e})}const pr={spinner:"_spinner_oo4hi_10"};function mr(e){return s.jsx("div",L({className:pr.spinner},e))}function vr(e,t=500){const[n,o]=f.useState(e);return f.useEffect(()=>{const a=window.setTimeout(()=>o(e),t);return()=>{window.clearTimeout(a)}},[e,t]),n}const yr={loadingContainer:"_loadingContainer_v9v7r_1"};function Rt(n){var o=n,{style:e}=o,t=re(o,["style"]);const a=h(u=>u.isLoading);return vr(a,100)?s.jsx("div",me(L({className:yr.loadingContainer,style:e},t),{children:s.jsx(mr,{})})):null}function gr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"})})}function wr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M4 5V19H20V5H4ZM3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM7.5 11.25H9.5V9H11V15H9.5V12.75H7.5V15H6V9H7.5V11.25ZM14.5 10.5V13.5H16C16.2761 13.5 16.5 13.2761 16.5 13V11C16.5 10.7239 16.2761 10.5 16 10.5H14.5ZM13 9H16C17.1046 9 18 9.89543 18 11V13C18 14.1046 17.1046 15 16 15H13V9Z"})})}const de={dropdownMenuContent:"_dropdownMenuContent_b7j6b_1",dropdownMenuItem:"_dropdownMenuItem_b7j6b_83",scrollAreaRoot:"_scrollAreaRoot_b7j6b_125",scrollAreaViewport:"_scrollAreaViewport_b7j6b_133",scrollAreaScrollbar:"_scrollAreaScrollbar_b7j6b_141",scrollAreaThumb:"_scrollAreaThumb_b7j6b_168"},Cr=ve.Root,xr=ve.Trigger,Tr=ve.Portal,bt=f.forwardRef((l,a)=>{var u=l,{sideOffset:e=4,className:t,children:n}=u,o=re(u,["sideOffset","className","children"]);return s.jsx(ve.Content,me(L({ref:a,sideOffset:e,className:[de.dropdownMenuContent,t].filter(Boolean).join(" "),onOpenAutoFocus:i=>{i.preventDefault()},onCloseAutoFocus:i=>{i.preventDefault()}},o),{children:s.jsxs(Ee.Root,{className:de.scrollAreaRoot,type:"always",scrollHideDelay:0,children:[s.jsx(Ee.Viewport,{className:de.scrollAreaViewport,children:n}),s.jsx(Ee.Scrollbar,{className:de.scrollAreaScrollbar,orientation:"vertical",children:s.jsx(Ee.Thumb,{className:de.scrollAreaThumb})})]})}))});bt.displayName="PlayerMenuContent";const St=f.forwardRef((a,o)=>{var l=a,{className:e,onClick:t}=l,n=re(l,["className","onClick"]);const u=c=>{t==null||t(c)},i=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t==null||t(c))};return s.jsx(ve.Close,{asChild:!0,children:s.jsx("div",L({ref:o,className:[de.dropdownMenuItem,e].filter(Boolean).join(" "),role:"menuitem",tabIndex:0,onClick:u,onKeyDown:i},n))})});St.displayName="PlayerMenuItem";const jt="settings";function Pt(){const[e,t]=f.useState(!1),n=h(c=>c.containerRef),o=h(c=>c.addIdleLock),a=h(c=>c.removeIdleLock),l=h(c=>c.levels),u=h(c=>c.setLevel),i=f.useCallback(c=>{t(c),c?o(jt):a(jt)},[o,a]);return s.jsxs(Cr,{open:e,onOpenChange:i,children:[s.jsx(xr,{asChild:!0,children:s.jsx(le,{children:s.jsx(wr,{})})}),s.jsx(Tr,{container:n.current,children:s.jsx(bt,{side:"top",align:"end",children:l==null?void 0:l.map(c=>s.jsxs(St,{onClick:()=>u(c.value),children:[c.label,c.selected&&s.jsx(gr,{})]},c.sid))})})]})}function _r(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"})})}function Er(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M13 7.22056L9.60282 10.0001H6V14.0001H9.60282L13 16.7796V7.22056ZM8.88889 16.0001H5C4.44772 16.0001 4 15.5524 4 15.0001V9.00007C4 8.44778 4.44772 8.00007 5 8.00007H8.88889L14.1834 3.66821C14.3971 3.49335 14.7121 3.52485 14.887 3.73857C14.9601 3.8279 15 3.93977 15 4.05519V19.9449C15 20.2211 14.7761 20.4449 14.5 20.4449C14.3846 20.4449 14.2727 20.405 14.1834 20.3319L8.88889 16.0001ZM18.8631 16.5911L17.4411 15.1691C18.3892 14.4376 19 13.2902 19 12.0001C19 10.5697 18.2493 9.31476 17.1203 8.60766L18.5589 7.16906C20.0396 8.26166 21 10.0187 21 12.0001C21 13.8422 20.1698 15.4905 18.8631 16.5911Z"})})}function Rr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 7.22056L6.60282 10.0001H3V14.0001H6.60282L10 16.7796V7.22056ZM5.88889 16.0001H2C1.44772 16.0001 1 15.5524 1 15.0001V9.00007C1 8.44778 1.44772 8.00007 2 8.00007H5.88889L11.1834 3.66821C11.3971 3.49335 11.7121 3.52485 11.887 3.73857C11.9601 3.8279 12 3.93977 12 4.05519V19.9449C12 20.2211 11.7761 20.4449 11.5 20.4449C11.3846 20.4449 11.2727 20.405 11.1834 20.3319L5.88889 16.0001ZM20.4142 12.0001L23.9497 15.5356L22.5355 16.9498L19 13.4143L15.4645 16.9498L14.0503 15.5356L17.5858 12.0001L14.0503 8.46454L15.4645 7.05032L19 10.5859L22.5355 7.05032L23.9497 8.46454L20.4142 12.0001Z"})})}const Lt={volumeContainer:"_volumeContainer_4d6jg_1",volumeSlider:"_volumeSlider_4d6jg_8"},kt="volume";function It(){const e=h(i=>i.setVolume),t=h(i=>i.volume),n=h(i=>i.addIdleLock),o=h(i=>i.removeIdleLock),a=i=>{e(i[0]),n(kt)},l=()=>{o(kt)},u=()=>e(t?0:100);return s.jsxs("div",{className:Lt.volumeContainer,children:[s.jsx(le,{onClick:u,className:"shrink-0",children:t?t>50?s.jsx(_r,{}):s.jsx(Er,{}):s.jsx(Rr,{})}),s.jsx("div",{className:Lt.volumeSlider,children:s.jsx(Pe,{value:[t],onValueChange:a,onValueCommit:l})})]})}const Dt={version:"0.0.47"};function br(e){return s.jsx(Xn,{children:s.jsx(Sr,L({},e))})}function Sr({url:e,messages:t,onEvent:n}){const o=h(a=>a.containerRef);return f.useEffect(()=>{console.log(`[Player][Live] Version: ${Dt.version}`)},[]),s.jsxs("div",{ref:o,className:z.playerContainer,children:[s.jsxs(Hn,{url:e,messages:{eventNotStarted:t==null?void 0:t.eventNotStarted,eventStartingSoon:t==null?void 0:t.eventStartingSoon,unableToPlay:t==null?void 0:t.unableToPlay},children:[s.jsx(Qn,{url:e,messages:{eventFinished:t==null?void 0:t.eventFinished,unableToPlay:t==null?void 0:t.unableToPlay}}),s.jsx(Tt,{}),s.jsx(Rt,{}),s.jsx(or,{}),s.jsxs(Et,{children:[s.jsx("div",{className:z.controlsTop,children:s.jsx("div",{className:z.controlsContainer,children:s.jsx("div",{className:z.controlsRow,children:s.jsx(ur,{})})})}),s.jsx("div",{className:z.controlsBottom,children:s.jsxs("div",{className:z.controlsContainer,children:[s.jsx(ar,{}),s.jsxs("div",{className:z.controlsRow,children:[s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionStart}`,children:[s.jsx(sr,{}),s.jsx(cr,{}),s.jsx(It,{})]}),s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionEnd}`,children:[s.jsx(ir,{message:t==null?void 0:t.live}),s.jsx(Pt,{}),s.jsx(_t,{})]})]})]})})]})]}),s.jsx(Yn,{}),s.jsx(qn,{url:e}),n&&s.jsx(Kn,{callback:n})]})}function jr(){const e=h(u=>u.isPlaying),t=h(u=>u.pause),n=h(u=>u.play),o=h(u=>u.currentTime),a=h(u=>u.duration),l=h(u=>u.seek);return s.jsx(yt,{onClick:()=>{e?t():n()},onBackwardSeek:u=>{const i=Math.max(0,o-u);l(i)},onForwardSeek:u=>{const i=Math.min(o+u,a);l(i)},maxBackwardTime:Math.floor(o),maxForwardTime:Math.floor(a-o)})}function Pr(){const e=h(a=>a.isPlaying),t=h(a=>a.pause),n=h(a=>a.play),o=()=>{e?t():n()};return s.jsx(le,{onClick:o,children:e?s.jsx(wt,{}):s.jsx(Ct,{})})}const Mt="vod-player-progress-bar";function Lr(){const e=f.useRef(null),t=f.useRef(null),[n,o]=f.useState(!1),[a,l]=f.useState(-1),[u,i]=f.useState(-1),c=h(I=>I.currentTime),d=h(I=>I.duration),y=h(I=>I.seek),g=h(I=>I.addIdleLock),w=h(I=>I.removeIdleLock),k=parseFloat((d?(u!==-1?u:c)/d*100:0).toFixed(1)),M=I=>{i(d*(I[0]/100)),g(Mt)},T=()=>{u!==-1&&(y(u),i(-1),w(Mt))},P=()=>o(!0),A=()=>o(!1),S=f.useCallback(I=>{const x=e.current,V=t.current;if(x&&V){const v=Le(x),W=Le(V),G=(I.pageX||I.clientX)-v.left,Z=G/v.width;if(Z<0)return;let O=G-W.width/2;O<0&&(O=0),O>v.width-W.width&&(O=-1),V.style.left=O>-1?`${O}px`:"auto",V.style.right=O>-1?"auto":"0px",l(Z*d)}P()},[d]);return s.jsxs("div",{className:ie.progressSlider,children:[s.jsx(Pe,{ref:e,value:[k],onPointerLeave:A,onPointerDown:A,onPointerMove:S,onValueChange:M,onValueCommit:T,step:.1}),s.jsx("div",{ref:t,className:`${ie.tipContainer} ${n?ie.tipContainerVisible:ie.tipContainerHidden}`,children:s.jsx("p",{className:ie.tipContent,children:Ce(a)})})]})}const Ie={remainingTimeContainer:"_remainingTimeContainer_1yyhb_1",remainingTime:"_remainingTime_1yyhb_1",remainingSeparator:"_remainingSeparator_1yyhb_17"};function kr(){const e=h(n=>n.currentTime),t=h(n=>n.duration);return s.jsxs("div",{className:Ie.remainingTimeContainer,children:[s.jsx("p",{className:Ie.remainingTime,children:Ce(e)}),s.jsx("p",{className:Ie.remainingSeparator}),s.jsx("p",{className:Ie.remainingTime,children:Ce(t)})]})}function Ir({callback:e}){const t=h(n=>n.eventEmitter);return f.useEffect(()=>{const n=o=>e("timeUpdate",o);return t.on("timeUpdate",n),()=>{t.off("timeUpdate",n)}},[e,t]),s.jsx(dt,{callback:e})}function Dr(){const e=h(i=>i.currentTime),t=h(i=>i.duration),n=h(i=>i.isPlaying),o=h(i=>i.pause),a=h(i=>i.play),l=h(i=>i.seek),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowLeft":l(e-10>=0?e-10:0),c=!0;break;case"ArrowRight":l(e+10<t?e+10:t),c=!0;break;case"Space":n?o():a(),c=!0;break}c&&i.preventDefault()}},[e,t,n,o,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),s.jsx(pt,{})}function Mr(e){return s.jsx(mt,{children:s.jsx(Fr,L({},e))})}function Fr({url:e,messages:t,onEvent:n,startTime:o}){const a=h(u=>u.setStartTime),l=h(u=>u.containerRef);return f.useEffect(()=>{o&&a(o)},[o,a]),f.useEffect(()=>{console.log(`[Player][VOD] Version: ${Dt.version}`)},[]),s.jsxs("div",{ref:l,className:z.playerContainer,children:[s.jsx(vt,{url:e,isLive:!1,messages:t}),s.jsx(Tt,{}),s.jsx(Rt,{}),s.jsx(jr,{}),s.jsx(Et,{children:s.jsx("div",{className:z.controlsBottom,children:s.jsxs("div",{className:z.controlsContainer,children:[s.jsx(Lr,{}),s.jsxs("div",{className:z.controlsRow,children:[s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionStart}`,children:[s.jsx(Pr,{}),s.jsx(It,{}),s.jsx(kr,{})]}),s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionEnd}`,children:[s.jsx(Pt,{}),s.jsx(_t,{})]})]})]})})}),s.jsx(Dr,{}),n&&s.jsx(Ir,{callback:n})]})}R.LivePlayer=br,R.VodPlayer=Mr,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
16
+ `);let o=!1;for(const a of n){const l=a.trim();if(l.startsWith("#EXT-X-STREAM-INF:")){o=!0;continue}if(o&&!l.startsWith("#")){if(l.startsWith("http"))return l;{const u=new URL(t);return new URL(l,u.origin+u.pathname.substring(0,u.pathname.lastIndexOf("/"))+"/").toString()}}}return null}function An(e){return e.replace("playlist.m3u8","playlist_fmp4_dvr.m3u8")}async function On(e){try{const t=An(e);console.log("Converting to DVR URL:",t);const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch master playlist: ${n.status} ${n.statusText}`);const o=await n.text(),a=Nn(o,t);if(!a)throw new Error("No chunklist URL found in master playlist");console.log("Found chunklist URL:",a);const l=await fetch(a);if(!l.ok)throw new Error(`Failed to fetch chunklist: ${l.status} ${l.statusText}`);const u=await l.text(),i=Vn(u);return i?console.log("Successfully detected start time:",i.toISOString()):console.log(" No start time found in chunklist"),i}catch(t){return console.error("Error getting start time from HLS URL:",t),null}}function Hn(n){var o=n,{url:e}=o,t=re(o,["url"]);const[a,l]=f.useState(!0),u=N(d=>d.startDate),i=N(d=>d.setStartDate),c=f.useCallback(async()=>{const d=await On(e);d&&i(d)},[e,i]);return f.useEffect(()=>{(async()=>{l(!0),await c(),l(!1)})()},[c]),be(c,u?null:5e3),a?null:s.jsx(Un,L({},t))}function Un({children:e,messages:t={}}){var u,i,c;const n=N(d=>d.startDate),o=h(d=>d.isStarted);return pn(o?null:5e3),n?Date.now()<n.getTime()?s.jsx(Bn,{startDate:n,title:(i=t==null?void 0:t.eventNotStarted)!=null?i:"Event has not started yet.",message:(c=t==null?void 0:t.eventStartingSoon)!=null?c:"Starting in few seconds..."}):s.jsx(s.Fragment,{children:e}):s.jsx("div",{className:oe.playerNotice,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:(u=t==null?void 0:t.unableToPlay)!=null?u:"Unable to play the video. Please try again later."})})}function Bn({startDate:e,title:t,message:n}){const o=e.getTime()-Date.now(),a=Math.floor(o/(1e3*60*60)),l=Math.floor(o%(1e3*60*60)/(1e3*60));return a||l?s.jsxs("div",{className:oe.playerNotice,children:[s.jsx("h3",{className:oe.playerNoticeTitle,children:t}),s.jsxs("p",{className:oe.playerNoticeText,children:["(",a>0?`${a}h ${l}m`:`${l}m`,")"]})]}):s.jsx("div",{className:oe.playerNotice,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:n})})}function dt({callback:e}){const t=h(n=>n.eventEmitter);return f.useEffect(()=>{const n=()=>e("play",void 0),o=()=>e("pause",void 0),a=()=>e("ended",void 0),l=()=>e("seeking",void 0),u=()=>e("seeked",void 0),i=T=>e("volumeChange",T),c=T=>e("fullscreenChange",T),d=T=>e("qualityChange",T),y=T=>e("loadedMetadata",T),g=()=>e("loadStart",void 0),w=()=>e("playing",void 0),k=()=>e("waiting",void 0),M=()=>e("error",void 0);return t.on("play",n),t.on("pause",o),t.on("ended",a),t.on("seeking",l),t.on("seeked",u),t.on("volumeChange",i),t.on("fullscreenChange",c),t.on("qualityChange",d),t.on("loadedMetadata",y),t.on("loadStart",g),t.on("playing",w),t.on("waiting",k),t.on("error",M),()=>{t.off("play",n),t.off("pause",o),t.off("ended",a),t.off("seeking",l),t.off("seeked",u),t.off("volumeChange",i),t.off("fullscreenChange",c),t.off("qualityChange",d),t.off("loadedMetadata",y),t.off("loadStart",g),t.off("playing",w),t.off("waiting",k),t.off("error",M)}},[e,t]),null}const ft=(e,t=0)=>parseInt(Math.max(0,(Date.now()-(e+t*1e3))/1e3).toFixed(0)),ht=(e,t)=>Math.max(0,(Date.now()-e-t*1e3)/1e3),zn=(e,t)=>Math.max(0,(t-e)/1e3),Wn=(e,t=0)=>{const o=t<0?0:t,a=["bytes","kb","mb","gb","tb","pb","eb","zb","yb"],l=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,l)).toFixed(o))}${a[l]}`};function Zn({isAuto:e,level:t,levels:n}){const o=n.length,a=[];return o>1&&a.push({sid:"quality-level-auto",label:"Auto",value:-1,selected:e||t===-1}),n.sort(function(l,u){const i=l.height||l.bitrate||0,c=u.height||u.bitrate||0;return i===c?0:i>c?1:-1}),n.map(l=>{const{bitrate:u,height:i,index:c}=l;a.push({sid:`quality-level-${c}`,label:i?`${i}p`:Wn(u),value:c,selected:o===1||!e&&c===t})}),a}function Kn({callback:e}){const t=N(l=>l.delay),n=N(l=>l.startDate),o=n?n.getTime():0,a=h(l=>l.eventEmitter);return f.useEffect(()=>{const l=()=>e("timeUpdate",{currentTime:ht(o,t),duration:-1});return a.on("timeUpdate",l),()=>{a.off("timeUpdate",l)}},[e,a]),s.jsx(dt,{callback:e})}function pt(){const e=h(i=>i.exitFullscreen),t=h(i=>i.isFullscreen),n=h(i=>i.isFullscreenReady),o=h(i=>i.requestFullscreen),a=h(i=>i.setVolume),l=h(i=>i.volume),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowUp":a(l+10<100?l+10:100),c=!0;break;case"ArrowDown":a(l-10>0?l-10:0),c=!0;break;case"KeyM":a(l===0?100:0),c=!0;break;case"KeyF":n&&(t?e():o(),c=!0);break}c&&i.preventDefault()}},[e,t,n,o,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),null}function Yn(){const e=N(i=>i.delay),t=h(i=>i.isPlaying),n=h(i=>i.pause),o=h(i=>i.getPauseTimeDiff),a=h(i=>i.play),l=N(i=>i.setDelay),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowLeft":l(e+10),c=!0;break;case"ArrowRight":l(e-10>0?e-10:0),c=!0;break;case"Space":if(t)n();else{const d=o();d&&l(e+d),a()}c=!0;break}c&&i.preventDefault()}},[e,o,t,n,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),s.jsx(pt,{})}function mt({children:e}){return s.jsx(Fn,{children:e})}function Xn({children:e}){return s.jsx(vn,{children:s.jsx(mt,{children:e})})}function Gn({url:e,isLive:t,messages:n}){const o=f.useRef(null),a=h(x=>x.level),l=h(x=>x.levels),u=h(x=>x.setLevel),i=h(x=>x.setLevels),c=h(x=>x.techRef),d=h(x=>x.setError),y=f.useRef(0),g=f.useRef(null),w=50,k=1e4,M=f.useCallback(x=>{if(o.current&&(o.current.nextLevel=x,u(null),l)){const V=l.map(v=>me(L({},v),{selected:v.value===x}));i(V)}},[l,u,i,o]),T=f.useCallback(()=>{o.current&&(console.log("[Player][HLS] MEDIA_ATTACHED"),o.current.loadSource(e))},[e]),P=f.useCallback(()=>{if(!o.current)return;console.log("[Player][HLS] MANIFEST_LOADED"),d(null),g.current&&(clearTimeout(g.current),g.current=null),y.current=0;const x=o.current.levels,V=o.current.currentLevel,v=o.current.autoLevelEnabled;i(Zn({levels:x.map((W,G)=>{const{bitrate:Z,height:O,width:D}=W;return{bitrate:Z,height:O,index:G,width:D}}),level:V,isAuto:v}))},[d,i]),A=f.useCallback((x,V)=>{var v;if(o.current&&V.fatal)switch(V.type){case te.ErrorTypes.NETWORK_ERROR:let W=(v=n==null?void 0:n.unableToPlay)!=null?v:"Unable to play the video. Please try again later.",G="NETWORK_ERROR";console.log("[Player][HLS] NETWORK_ERROR",V),t?(y.current<w&&(g.current&&clearTimeout(g.current),y.current+=1,g.current=setTimeout(()=>{if(o.current)try{console.log("[Player][HLS] Retrying stream..."),o.current.loadSource(e)}catch(Z){console.error("[Player][HLS] Retry failed:",Z)}},k)),G="LIVE_MANIFEST_LOAD_ERROR"):o.current.startLoad(),d({message:W,code:G,tech:"hls"});break;case te.ErrorTypes.MEDIA_ERROR:o.current.recoverMediaError();break}},[t,e,d]),S=f.useCallback(()=>{if(!c.current)return;let x={startLevel:-1,maxBufferSize:30*1024*1024};Cn?(x.backBufferLength=-1,x.enableWorker=!1):t?x.backBufferLength=10:x.backBufferLength=60;try{console.log("[Player][HLS] URL",e),console.log("[Player][HLS] Config",JSON.stringify(x)),console.log("[Player][HLS] Version",te.version),o.current=new te(x),o.current.attachMedia(c.current),o.current.on(te.Events.MEDIA_ATTACHED,T),o.current.on(te.Events.MANIFEST_LOADED,P),o.current.on(te.Events.ERROR,A)}catch(V){throw new Error(`Error initializing Hls: ${V}`)}},[P,T,A,t,c,e]),I=f.useCallback(()=>{o.current&&(o.current.off(te.Events.MEDIA_ATTACHED,T),o.current.off(te.Events.MANIFEST_LOADED,P),o.current.off(te.Events.ERROR,A),o.current.destroy(),o.current=null),g.current&&(clearTimeout(g.current),g.current=null),y.current=0},[P,T,A]);return f.useEffect(()=>{a!==null&&M(a)},[a,M]),f.useEffect(()=>(te.isSupported()&&S(),I),[I,S]),null}const Jn={playerVideo:"_playerVideo_wc0sm_1"};function vt({url:e,isLive:t,isMuted:n=!1,messages:o={}}){const a=h(v=>v.handleDurationChange),l=h(v=>v.handleEnd),u=h(v=>v.handleLoadedMetadata),i=h(v=>v.handleLoadStart),c=h(v=>v.handlePause),d=h(v=>v.handlePlay),y=h(v=>v.handlePlaying),g=h(v=>v.handleSeeked),w=h(v=>v.handleSeeking),k=h(v=>v.handleTimeUpdate),M=h(v=>v.handleWaiting),T=h(v=>v.handleVolumeChange),P=h(v=>v.handleError),A=h(v=>v.techRef),S=f.useRef(null),I=()=>t?{onTimeUpdate:x}:{onDurationChange:a,onSeeked:g,onSeeking:w,onTimeUpdate:x},x=()=>{(!S.current||Date.now()-S.current>=1e3)&&(k(),S.current=Date.now())},V=I();return s.jsxs(s.Fragment,{children:[s.jsx(Gn,{isLive:t,url:e,messages:o}),s.jsx("video",L({ref:A,className:Jn.playerVideo,playsInline:!0,autoPlay:!0,controls:!1,muted:n,preload:"auto",crossOrigin:"anonymous",onEnded:l,onError:P,onLoadedMetadata:u,onLoadStart:i,onPause:c,onPlay:d,onPlaying:y,onWaiting:M,onVolumeChange:T,tabIndex:-1},V))]})}function Qn({url:e,messages:t={}}){const[n,o]=f.useState(null),a=N(u=>u.delay),l=f.useCallback(async()=>{o(a?e.replace("-live","-catchup").replace("playlist.m3u8",`playlist_fmp4_dvr_timeshift-${a}.m3u8`):e)},[a,e]);return f.useEffect(()=>{l()},[l]),n?s.jsx(vt,{url:n,isLive:!0,messages:t}):null}function qn({url:e}){return h(n=>n.isStarted)?s.jsx($n,{url:e}):null}function $n({url:e}){const t=N(l=>l.setViewerCount),n=f.useRef(null),o=l=>{try{return new URL(l).pathname.split("/").filter(d=>d.length>0)[0]||null}catch(u){return console.error("Failed to extract URI from player URL:",u),null}},a=async()=>{var c;const l=o(e);if(!l){console.error("Could not extract URI from URL:",e);return}n.current&&n.current.abort(),n.current=new AbortController;const i=`https://${e.includes("staging")?"stg":"prd"}-fitnessanny.spectar.tv/analytics-api/v1/token-info/uri/${l}`;try{const d=await fetch(i,{signal:n.current.signal});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);const g=(c=(await d.json()).count)!=null?c:0;t(g)}catch(d){if(d.name==="AbortError")return;console.error("Failed to fetch viewer count:",d),t(null)}};return f.useEffect(()=>(a(),()=>{n.current&&n.current.abort()}),[e]),be(a,15e3),null}function er(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const o=i=>typeof window=="undefined"?t:window.matchMedia(i).matches,[a,l]=f.useState(()=>n?o(e):t);function u(){l(o(e))}return st(()=>{if(typeof window=="undefined")return;const i=window.matchMedia(e);return u(),i.addListener?i.addListener(u):i.addEventListener("change",u),()=>{i.removeListener?i.removeListener(u):i.removeEventListener("change",u)}},[e]),a}const ue={playbackButton:"_playbackButton_lgsgw_1",seekIndicator:"_seekIndicator_lgsgw_23",seekIndicatorLeft:"_seekIndicatorLeft_lgsgw_49",seekIndicatorRight:"_seekIndicatorRight_lgsgw_53",seekIndicatorVisible:"_seekIndicatorVisible_lgsgw_57"},tr=10;function yt(i){var c=i,{className:e,onClick:t,onForwardSeek:n,onBackwardSeek:o,maxForwardTime:a,maxBackwardTime:l}=c,u=re(c,["className","onClick","onForwardSeek","onBackwardSeek","maxForwardTime","maxBackwardTime"]);return er("(min-width: 1024px)")?s.jsx(nr,L({className:e,onClick:t},u)):s.jsx(rr,L({className:e,maxForwardTime:a,maxBackwardTime:l,onForwardSeek:n,onBackwardSeek:o},u))}function nr(o){var a=o,{className:e,onClick:t}=a,n=re(a,["className","onClick"]);const l=f.useRef(null),u=h(T=>T.exitFullscreen),i=h(T=>T.isFullscreen),c=h(T=>T.requestFullscreen),d=h(T=>T.resetIdle),y=T=>{k()?(w(),i?u():c()):g(T)},g=T=>{l.current=window.setTimeout(()=>{t==null||t(T),w()},200)},w=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},k=()=>l.current!==null,M=()=>{d()};return f.useEffect(()=>()=>{w()},[]),s.jsx("button",L({onClick:y,onMouseEnter:M,className:[ue.playbackButton,e].filter(Boolean).join(" "),"aria-label":"Player gestures"},n))}function rr(u){var i=u,{className:e,maxForwardTime:t,maxBackwardTime:n,onForwardSeek:o,onBackwardSeek:a}=i,l=re(i,["className","maxForwardTime","maxBackwardTime","onForwardSeek","onBackwardSeek"]);const c=f.useRef(null),d=f.useRef({single:null,indicator:null,accumulate:null}),y=f.useRef(null),g=f.useRef(0),w=f.useRef(null),[k,M]=f.useState({visible:!1,direction:null,time:0}),T=h(v=>v.isIdle),P=h(v=>v.setIsIdle),A=h(v=>v.resetIdle),S=(v,W)=>v<W/2?"backward":"forward",I=v=>{if(!y.current)return;const W=v.changedTouches[0];if(!W)return;const G=Date.now(),Z=y.current.getBoundingClientRect(),O=W.clientX-Z.left,D=W.clientY-Z.top;if(O<0||O>Z.width||D<0||D>Z.height)return;const q=c.current,X=q?G-q.time:1/0,K=S(O,Z.width),se=w.current!==null&&w.current===K&&q!==null&&X<700&&Math.abs(O-q.x)<100;if(q!==null&&w.current===null&&X<300&&Math.abs(O-q.x)<50||se){v.preventDefault(),v.stopPropagation(),d.current.single&&(window.clearTimeout(d.current.single),d.current.single=null),A(),(w.current===null||w.current!==K)&&(g.current=0,w.current=K);const ne=K==="backward"?n:t;g.current=Math.min(g.current+tr,ne!=null?ne:1/0),x(K,g.current),d.current.accumulate&&window.clearTimeout(d.current.accumulate),d.current.accumulate=window.setTimeout(()=>{const Y=g.current;Y>0&&(w.current==="backward"?a==null||a(Y):o==null||o(Y),A()),g.current=0,w.current=null,c.current=null,V(),d.current.accumulate=null},500),c.current={time:G,x:O}}else{c.current={time:G,x:O},d.current.single&&window.clearTimeout(d.current.single);const ne=w.current!==null?700:350;d.current.single=window.setTimeout(()=>{if(w.current===null){d.current.single=null;const Y=T;P(!Y),Y&&A()}c.current=null},ne)}},x=(v,W)=>{W!==0&&(M({visible:!0,direction:v,time:W}),d.current.indicator&&window.clearTimeout(d.current.indicator),d.current.indicator=window.setTimeout(()=>{V()},700))},V=()=>{M({visible:!1,direction:null,time:0}),d.current.indicator&&(window.clearTimeout(d.current.indicator),d.current.indicator=null)};return f.useEffect(()=>()=>{d.current.single&&window.clearTimeout(d.current.single),d.current.indicator&&window.clearTimeout(d.current.indicator),d.current.accumulate&&window.clearTimeout(d.current.accumulate)},[]),s.jsxs(s.Fragment,{children:[s.jsx("button",L({ref:y,onTouchEnd:I,className:[ue.playbackButton,e].filter(Boolean).join(" "),"aria-label":"Player gestures"},l)),k.visible&&s.jsxs("div",{className:`${ue.seekIndicator} ${ue.seekIndicatorVisible} ${k.direction==="backward"?ue.seekIndicatorLeft:ue.seekIndicatorRight}`,children:[k.direction==="backward"?"-":"+",Ce(k.time)]})]})}function or(){const e=h(c=>c.isPlaying),t=h(c=>c.pause),n=h(c=>c.getPauseTimeDiff),o=h(c=>c.play),a=N(c=>c.delay),l=N(c=>c.setDelay),u=N(c=>c.startDate),i=u?u.getTime():0;return s.jsx(yt,{onClick:()=>{if(e)t();else{const c=n();c&&l(a+c),o()}},onBackwardSeek:c=>{const d=a+c;l(d)},onForwardSeek:c=>{const d=Math.max(0,a-c);l(d)},maxBackwardTime:Math.floor(i),maxForwardTime:Math.floor(a)})}const gt={playerButton:"_playerButton_izwqq_1",playerButtonCircle:"_playerButtonCircle_izwqq_42"},le=f.forwardRef((a,o)=>{var l=a,{shape:e="circle",className:t}=l,n=re(l,["shape","className"]);const u=e==="circle"?gt.playerButtonCircle:"",i=[gt.playerButton,u,t].filter(Boolean).join(" ");return s.jsx("button",L({ref:o,className:i},n))});le.displayName="PlayerButton";const Se={liveIndicator:"_liveIndicator_1jczn_1",liveIndicatorHasDelay:"_liveIndicatorHasDelay_1jczn_9",liveIndicatorNoDelay:"_liveIndicatorNoDelay_1jczn_13"};function ir(n){var o=n,{message:e}=o,t=re(o,["message"]);const a=N(c=>c.delay),l=N(c=>c.setDelay),u=()=>{a&&l(0)},i=a?`${Se.liveIndicator} ${Se.liveIndicatorHasDelay}`:`${Se.liveIndicator} ${Se.liveIndicatorNoDelay}`;return s.jsxs(le,me(L({onClick:u,shape:"square"},t),{children:[s.jsx("div",{className:i}),e||"Live"]}))}function wt(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6 5H8V19H6V5ZM16 5H18V19H16V5Z"})})}function Ct(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M19.376 12.4161L8.77735 19.4818C8.54759 19.635 8.23715 19.5729 8.08397 19.3432C8.02922 19.261 8 19.1645 8 19.0658V4.93433C8 4.65818 8.22386 4.43433 8.5 4.43433C8.59871 4.43433 8.69522 4.46355 8.77735 4.5183L19.376 11.584C19.6057 11.7372 19.6678 12.0477 19.5146 12.2774C19.478 12.3323 19.4309 12.3795 19.376 12.4161Z"})})}function sr(){const e=h(i=>i.isPlaying),t=h(i=>i.pause),n=h(i=>i.getPauseTimeDiff),o=h(i=>i.play),a=N(i=>i.delay),l=N(i=>i.setDelay),u=()=>{if(e)t();else{const i=n();i&&l(a+i),o()}};return s.jsx(le,{onClick:u,children:e?s.jsx(wt,{}):s.jsx(Ct,{})})}const ie={progressSlider:"_progressSlider_hwzgf_1",tipContainer:"_tipContainer_hwzgf_7",tipContainerVisible:"_tipContainerVisible_hwzgf_17",tipContainerHidden:"_tipContainerHidden_hwzgf_22",tipContent:"_tipContent_hwzgf_27"},je={sliderRoot:"_sliderRoot_aeak6_1",sliderTrack:"_sliderTrack_aeak6_18",sliderRange:"_sliderRange_aeak6_28",sliderThumb:"_sliderThumb_aeak6_37"},Pe=f.forwardRef((l,a)=>{var u=l,{max:e=100,min:t=0,className:n}=u,o=re(u,["max","min","className"]);return s.jsxs(_e.Root,me(L({ref:a,min:t,max:e,"aria-label":"Player progress",className:[je.sliderRoot,n].filter(Boolean).join(" "),onKeyDown:i=>i.preventDefault()},o),{children:[s.jsx(_e.Track,{className:je.sliderTrack,children:s.jsx(_e.Range,{className:je.sliderRange})}),s.jsx(_e.Thumb,{className:je.sliderThumb})]}))});Pe.displayName="PlayerSlider";function Le(e){const t=e.getBoundingClientRect();return e.offsetWidth/e.offsetHeight>e.clientWidth/e.clientHeight?{left:t.left*100,right:t.right*100,top:t.top*100,bottom:t.bottom*100,width:t.width*100,height:t.height*100}:t}const xt="vod-player-progress-bar";function ar(){const e=f.useRef(null),t=f.useRef(null),[n,o]=f.useState(0),[a,l]=f.useState(0),[u,i]=f.useState(!1),[c,d]=f.useState(-1),[y,g]=f.useState(-1),w=N(D=>D.delay),k=N(D=>D.startDate),M=k?k.getTime():0,T=new Date().getTime(),P=N(D=>D.setDelay),A=h(D=>D.isPlaying),S=h(D=>D.addIdleLock),I=h(D=>D.removeIdleLock),x=f.useCallback(()=>{o(ht(M,w)),l(zn(M,T))},[w,T,M]),V=parseFloat((a?(y!==-1?y:n)/a*100:0).toFixed(1)),v=D=>{g(a*(D[0]/100)),S(xt)},W=()=>{if(y!==-1){const D=ft(M,y);P(D),g(-1),I(xt)}},G=()=>i(!0),Z=()=>i(!1),O=f.useCallback(D=>{const q=e.current,X=t.current;if(q&&X){const K=Le(q),se=Le(X),fe=(D.pageX||D.clientX)-K.left,ne=fe/K.width;if(ne<0)return;let Y=fe-se.width/2;Y<0&&(Y=0),Y>K.width-se.width&&(Y=-1),X.style.left=Y>-1?`${Y}px`:"auto",X.style.right=Y>-1?"auto":"0px";const xe=a-ne*a;d(xe>0?xe:0)}G()},[a]);return be(()=>x(),A?1e3:null),f.useEffect(()=>{x()},[x]),s.jsxs("div",{className:ie.progressSlider,children:[s.jsx(Pe,{ref:e,value:[V],onPointerLeave:Z,onPointerDown:Z,onPointerMove:O,onValueChange:v,onValueCommit:W,step:.1}),s.jsx("div",{ref:t,className:`${ie.tipContainer} ${u?ie.tipContainerVisible:ie.tipContainerHidden}`,children:s.jsx("p",{className:ie.tipContent,children:`-${Ce(c)}`})})]})}function lr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 12C22 17.5228 17.5229 22 12 22C6.4772 22 2 17.5228 2 12C2 6.47715 6.4772 2 12 2V4C7.5817 4 4 7.58172 4 12C4 16.4183 7.5817 20 12 20C16.4183 20 20 16.4183 20 12C20 9.53614 18.8862 7.33243 17.1346 5.86492L15 8V2L21 2L18.5535 4.44656C20.6649 6.28002 22 8.9841 22 12Z"})})}function cr(){const e=N(a=>a.startDate),t=N(a=>a.setDelay),n=e?e.getTime():0,o=()=>t(ft(n));return s.jsx(le,{onClick:o,children:s.jsx(lr,{})})}const ke={viewersContainer:"_viewersContainer_z1ihz_1",viewersIndicator:"_viewersIndicator_z1ihz_16",viewersIcon:"_viewersIcon_z1ihz_24",viewersCount:"_viewersCount_z1ihz_28"};function ur(){const e=N(t=>t.viewerCount);return e?s.jsxs("div",{className:ke.viewersContainer,children:[s.jsx("span",{className:ke.viewersIndicator}),s.jsxs("svg",{className:ke.viewersIcon,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M8 7C9.10457 7 10 6.10457 10 5C10 3.89543 9.10457 3 8 3C6.89543 3 6 3.89543 6 5C6 6.10457 6.89543 7 8 7Z",fill:"currentColor"}),s.jsx("path",{d:"M8 8C5.79086 8 4 9.79086 4 12V13H12V12C12 9.79086 10.2091 8 8 8Z",fill:"currentColor"})]}),s.jsx("span",{className:ke.viewersCount,children:e.toLocaleString()})]}):null}function Tt(){const e=h(n=>n.error);if(!e)return null;const t=e.code==="LIVE_MANIFEST_LOAD_ERROR";return s.jsx("div",{className:`${oe.playerNotice} ${t?oe.playerNoticeLowZIndex:""}`,children:s.jsx("h3",{className:oe.playerNoticeTitle,children:e.message})})}const z={playerContainer:"_playerContainer_146tx_1",controlsTop:"_controlsTop_146tx_12",controlsBottom:"_controlsBottom_146tx_29",controlsContainer:"_controlsContainer_146tx_45",controlsRow:"_controlsRow_146tx_61",controlsSection:"_controlsSection_146tx_68",controlsSectionStart:"_controlsSectionStart_146tx_78",controlsSectionEnd:"_controlsSectionEnd_146tx_82"};function dr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M16 3H22V9H20V5H16V3ZM2 3H8V5H4V9H2V3ZM20 19V15H22V21H16V19H20ZM4 19H8V21H2V15H4V19Z"})})}function fr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18 7H22V9H16V3H18V7ZM8 9H2V7H6V3H8V9ZM18 17V21H16V15H22V17H18ZM8 15V21H6V17H2V15H8Z"})})}function _t(){const e=h(d=>d.containerRef),t=h(d=>d.exitFullscreen),n=h(d=>d.isFullscreen),o=h(d=>d.requestFullscreen),a=h(d=>d.setIsFullscreen),l=h(d=>d.setIsFullscreenReady),u=h(d=>d.techRef),i=f.useCallback(d=>{d.stopPropagation(),a(xn())},[a]),c=()=>{n?t():o()};return f.useEffect(()=>{const d=ct?u.current:e.current;if(d)return En(d,i)},[e,i,u]),f.useEffect(()=>{l(!0)},[l]),s.jsx(le,{onClick:c,children:n?s.jsx(fr,{}):s.jsx(dr,{})})}const Ue={idleCheckContainer:"_idleCheckContainer_crh2s_1",idleCheckContainerIdle:"_idleCheckContainerIdle_crh2s_5",idleCheckContainerActive:"_idleCheckContainerActive_crh2s_11"},hr=5*1e3;function Et({children:e}){const t=f.useRef(null),n=h(w=>w.isIdle),o=h(w=>w.setIsIdle),a=f.useRef(null),u=h(w=>w.idleLocks).size,i=h(w=>w.eventEmitter),c=f.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),d=f.useCallback(()=>{c(),a.current=window.setTimeout(()=>o(!0),hr)},[c]);f.useEffect(()=>(o(!1),d(),()=>{c()}),[c,d]),f.useEffect(()=>{const w=()=>{o(!1),d()};return i.on("resetIdle",w),()=>{i.off("resetIdle",w)}},[i,o,d]);const y=n&&!u,g=`${Ue.idleCheckContainer} ${y?Ue.idleCheckContainerIdle:Ue.idleCheckContainerActive}`;return s.jsx("div",{ref:t,className:g,children:e})}const pr={spinner:"_spinner_oo4hi_10"};function mr(e){return s.jsx("div",L({className:pr.spinner},e))}function vr(e,t=500){const[n,o]=f.useState(e);return f.useEffect(()=>{const a=window.setTimeout(()=>o(e),t);return()=>{window.clearTimeout(a)}},[e,t]),n}const yr={loadingContainer:"_loadingContainer_v9v7r_1"};function Rt(n){var o=n,{style:e}=o,t=re(o,["style"]);const a=h(u=>u.isLoading);return vr(a,100)?s.jsx("div",me(L({className:yr.loadingContainer,style:e},t),{children:s.jsx(mr,{})})):null}function gr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"})})}function wr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M4 5V19H20V5H4ZM3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM7.5 11.25H9.5V9H11V15H9.5V12.75H7.5V15H6V9H7.5V11.25ZM14.5 10.5V13.5H16C16.2761 13.5 16.5 13.2761 16.5 13V11C16.5 10.7239 16.2761 10.5 16 10.5H14.5ZM13 9H16C17.1046 9 18 9.89543 18 11V13C18 14.1046 17.1046 15 16 15H13V9Z"})})}const de={dropdownMenuContent:"_dropdownMenuContent_b7j6b_1",dropdownMenuItem:"_dropdownMenuItem_b7j6b_83",scrollAreaRoot:"_scrollAreaRoot_b7j6b_125",scrollAreaViewport:"_scrollAreaViewport_b7j6b_133",scrollAreaScrollbar:"_scrollAreaScrollbar_b7j6b_141",scrollAreaThumb:"_scrollAreaThumb_b7j6b_168"},Cr=ve.Root,xr=ve.Trigger,Tr=ve.Portal,bt=f.forwardRef((l,a)=>{var u=l,{sideOffset:e=4,className:t,children:n}=u,o=re(u,["sideOffset","className","children"]);return s.jsx(ve.Content,me(L({ref:a,sideOffset:e,className:[de.dropdownMenuContent,t].filter(Boolean).join(" "),onOpenAutoFocus:i=>{i.preventDefault()},onCloseAutoFocus:i=>{i.preventDefault()}},o),{children:s.jsxs(Ee.Root,{className:de.scrollAreaRoot,type:"always",scrollHideDelay:0,children:[s.jsx(Ee.Viewport,{className:de.scrollAreaViewport,children:n}),s.jsx(Ee.Scrollbar,{className:de.scrollAreaScrollbar,orientation:"vertical",children:s.jsx(Ee.Thumb,{className:de.scrollAreaThumb})})]})}))});bt.displayName="PlayerMenuContent";const St=f.forwardRef((a,o)=>{var l=a,{className:e,onClick:t}=l,n=re(l,["className","onClick"]);const u=c=>{t==null||t(c)},i=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t==null||t(c))};return s.jsx(ve.Close,{asChild:!0,children:s.jsx("div",L({ref:o,className:[de.dropdownMenuItem,e].filter(Boolean).join(" "),role:"menuitem",tabIndex:0,onClick:u,onKeyDown:i},n))})});St.displayName="PlayerMenuItem";const jt="settings";function Pt(){const[e,t]=f.useState(!1),n=h(c=>c.containerRef),o=h(c=>c.addIdleLock),a=h(c=>c.removeIdleLock),l=h(c=>c.levels),u=h(c=>c.setLevel),i=f.useCallback(c=>{t(c),c?o(jt):a(jt)},[o,a]);return s.jsxs(Cr,{open:e,onOpenChange:i,children:[s.jsx(xr,{asChild:!0,children:s.jsx(le,{children:s.jsx(wr,{})})}),s.jsx(Tr,{container:n.current,children:s.jsx(bt,{side:"top",align:"end",children:l==null?void 0:l.map(c=>s.jsxs(St,{onClick:()=>u(c.value),children:[c.label,c.selected&&s.jsx(gr,{})]},c.sid))})})]})}function _r(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"})})}function Er(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M13 7.22056L9.60282 10.0001H6V14.0001H9.60282L13 16.7796V7.22056ZM8.88889 16.0001H5C4.44772 16.0001 4 15.5524 4 15.0001V9.00007C4 8.44778 4.44772 8.00007 5 8.00007H8.88889L14.1834 3.66821C14.3971 3.49335 14.7121 3.52485 14.887 3.73857C14.9601 3.8279 15 3.93977 15 4.05519V19.9449C15 20.2211 14.7761 20.4449 14.5 20.4449C14.3846 20.4449 14.2727 20.405 14.1834 20.3319L8.88889 16.0001ZM18.8631 16.5911L17.4411 15.1691C18.3892 14.4376 19 13.2902 19 12.0001C19 10.5697 18.2493 9.31476 17.1203 8.60766L18.5589 7.16906C20.0396 8.26166 21 10.0187 21 12.0001C21 13.8422 20.1698 15.4905 18.8631 16.5911Z"})})}function Rr(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 7.22056L6.60282 10.0001H3V14.0001H6.60282L10 16.7796V7.22056ZM5.88889 16.0001H2C1.44772 16.0001 1 15.5524 1 15.0001V9.00007C1 8.44778 1.44772 8.00007 2 8.00007H5.88889L11.1834 3.66821C11.3971 3.49335 11.7121 3.52485 11.887 3.73857C11.9601 3.8279 12 3.93977 12 4.05519V19.9449C12 20.2211 11.7761 20.4449 11.5 20.4449C11.3846 20.4449 11.2727 20.405 11.1834 20.3319L5.88889 16.0001ZM20.4142 12.0001L23.9497 15.5356L22.5355 16.9498L19 13.4143L15.4645 16.9498L14.0503 15.5356L17.5858 12.0001L14.0503 8.46454L15.4645 7.05032L19 10.5859L22.5355 7.05032L23.9497 8.46454L20.4142 12.0001Z"})})}const Lt={volumeContainer:"_volumeContainer_4d6jg_1",volumeSlider:"_volumeSlider_4d6jg_8"},kt="volume";function It(){const e=h(i=>i.setVolume),t=h(i=>i.volume),n=h(i=>i.addIdleLock),o=h(i=>i.removeIdleLock),a=i=>{e(i[0]),n(kt)},l=()=>{o(kt)},u=()=>e(t?0:100);return s.jsxs("div",{className:Lt.volumeContainer,children:[s.jsx(le,{onClick:u,className:"shrink-0",children:t?t>50?s.jsx(_r,{}):s.jsx(Er,{}):s.jsx(Rr,{})}),s.jsx("div",{className:Lt.volumeSlider,children:s.jsx(Pe,{value:[t],onValueChange:a,onValueCommit:l})})]})}const Dt={version:"0.0.48"};function br(e){return s.jsx(Xn,{children:s.jsx(Sr,L({},e))})}function Sr({url:e,messages:t,onEvent:n}){const o=h(a=>a.containerRef);return f.useEffect(()=>{console.log(`[Player][Live] Version: ${Dt.version}`)},[]),s.jsxs("div",{ref:o,className:z.playerContainer,children:[s.jsxs(Hn,{url:e,messages:{eventNotStarted:t==null?void 0:t.eventNotStarted,eventStartingSoon:t==null?void 0:t.eventStartingSoon,unableToPlay:t==null?void 0:t.unableToPlay},children:[s.jsx(Qn,{url:e,messages:{eventFinished:t==null?void 0:t.eventFinished,unableToPlay:t==null?void 0:t.unableToPlay}}),s.jsx(Tt,{}),s.jsx(Rt,{}),s.jsx(or,{}),s.jsxs(Et,{children:[s.jsx("div",{className:z.controlsTop,children:s.jsx("div",{className:z.controlsContainer,children:s.jsx("div",{className:z.controlsRow,children:s.jsx(ur,{})})})}),s.jsx("div",{className:z.controlsBottom,children:s.jsxs("div",{className:z.controlsContainer,children:[s.jsx(ar,{}),s.jsxs("div",{className:z.controlsRow,children:[s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionStart}`,children:[s.jsx(sr,{}),s.jsx(cr,{}),s.jsx(It,{})]}),s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionEnd}`,children:[s.jsx(ir,{message:t==null?void 0:t.live}),s.jsx(Pt,{}),s.jsx(_t,{})]})]})]})})]})]}),s.jsx(Yn,{}),s.jsx(qn,{url:e}),n&&s.jsx(Kn,{callback:n})]})}function jr(){const e=h(u=>u.isPlaying),t=h(u=>u.pause),n=h(u=>u.play),o=h(u=>u.currentTime),a=h(u=>u.duration),l=h(u=>u.seek);return s.jsx(yt,{onClick:()=>{e?t():n()},onBackwardSeek:u=>{const i=Math.max(0,o-u);l(i)},onForwardSeek:u=>{const i=Math.min(o+u,a);l(i)},maxBackwardTime:Math.floor(o),maxForwardTime:Math.floor(a-o)})}function Pr(){const e=h(a=>a.isPlaying),t=h(a=>a.pause),n=h(a=>a.play),o=()=>{e?t():n()};return s.jsx(le,{onClick:o,children:e?s.jsx(wt,{}):s.jsx(Ct,{})})}const Mt="vod-player-progress-bar";function Lr(){const e=f.useRef(null),t=f.useRef(null),[n,o]=f.useState(!1),[a,l]=f.useState(-1),[u,i]=f.useState(-1),c=h(I=>I.currentTime),d=h(I=>I.duration),y=h(I=>I.seek),g=h(I=>I.addIdleLock),w=h(I=>I.removeIdleLock),k=parseFloat((d?(u!==-1?u:c)/d*100:0).toFixed(1)),M=I=>{i(d*(I[0]/100)),g(Mt)},T=()=>{u!==-1&&(y(u),i(-1),w(Mt))},P=()=>o(!0),A=()=>o(!1),S=f.useCallback(I=>{const x=e.current,V=t.current;if(x&&V){const v=Le(x),W=Le(V),G=(I.pageX||I.clientX)-v.left,Z=G/v.width;if(Z<0)return;let O=G-W.width/2;O<0&&(O=0),O>v.width-W.width&&(O=-1),V.style.left=O>-1?`${O}px`:"auto",V.style.right=O>-1?"auto":"0px",l(Z*d)}P()},[d]);return s.jsxs("div",{className:ie.progressSlider,children:[s.jsx(Pe,{ref:e,value:[k],onPointerLeave:A,onPointerDown:A,onPointerMove:S,onValueChange:M,onValueCommit:T,step:.1}),s.jsx("div",{ref:t,className:`${ie.tipContainer} ${n?ie.tipContainerVisible:ie.tipContainerHidden}`,children:s.jsx("p",{className:ie.tipContent,children:Ce(a)})})]})}const Ie={remainingTimeContainer:"_remainingTimeContainer_1yyhb_1",remainingTime:"_remainingTime_1yyhb_1",remainingSeparator:"_remainingSeparator_1yyhb_17"};function kr(){const e=h(n=>n.currentTime),t=h(n=>n.duration);return s.jsxs("div",{className:Ie.remainingTimeContainer,children:[s.jsx("p",{className:Ie.remainingTime,children:Ce(e)}),s.jsx("p",{className:Ie.remainingSeparator}),s.jsx("p",{className:Ie.remainingTime,children:Ce(t)})]})}function Ir({callback:e}){const t=h(n=>n.eventEmitter);return f.useEffect(()=>{const n=o=>e("timeUpdate",o);return t.on("timeUpdate",n),()=>{t.off("timeUpdate",n)}},[e,t]),s.jsx(dt,{callback:e})}function Dr(){const e=h(i=>i.currentTime),t=h(i=>i.duration),n=h(i=>i.isPlaying),o=h(i=>i.pause),a=h(i=>i.play),l=h(i=>i.seek),u=f.useCallback(i=>{let c=!1;if(!(i.target instanceof HTMLInputElement||i.ctrlKey)){switch(i.code){case"ArrowLeft":l(e-10>=0?e-10:0),c=!0;break;case"ArrowRight":l(e+10<t?e+10:t),c=!0;break;case"Space":n?o():a(),c=!0;break}c&&i.preventDefault()}},[e,t,n,o,a,l]);return f.useEffect(()=>(document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}),[u]),s.jsx(pt,{})}function Mr(e){return s.jsx(mt,{children:s.jsx(Fr,L({},e))})}function Fr({url:e,messages:t,onEvent:n,startTime:o}){const a=h(u=>u.setStartTime),l=h(u=>u.containerRef);return f.useEffect(()=>{o&&a(o)},[o,a]),f.useEffect(()=>{console.log(`[Player][VOD] Version: ${Dt.version}`)},[]),s.jsxs("div",{ref:l,className:z.playerContainer,children:[s.jsx(vt,{url:e,isLive:!1,messages:t}),s.jsx(Tt,{}),s.jsx(Rt,{}),s.jsx(jr,{}),s.jsx(Et,{children:s.jsx("div",{className:z.controlsBottom,children:s.jsxs("div",{className:z.controlsContainer,children:[s.jsx(Lr,{}),s.jsxs("div",{className:z.controlsRow,children:[s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionStart}`,children:[s.jsx(Pr,{}),s.jsx(It,{}),s.jsx(kr,{})]}),s.jsxs("div",{className:`${z.controlsSection} ${z.controlsSectionEnd}`,children:[s.jsx(Pt,{}),s.jsx(_t,{})]})]})]})})}),s.jsx(Dr,{}),n&&s.jsx(Ir,{callback:n})]})}R.LivePlayer=br,R.VodPlayer=Mr,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
17
17
  //# sourceMappingURL=react-video-player.umd.js.map