@frameset/plex-player 2.0.2 → 2.0.4
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.
- package/dist/index.d.ts +7 -10
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
2
|
|
|
3
|
-
interface PlaylistItem {
|
|
4
|
-
id: string;
|
|
5
|
-
src: string;
|
|
6
|
-
title: string;
|
|
7
|
-
poster?: string;
|
|
8
|
-
duration?: number;
|
|
9
|
-
artist?: string;
|
|
10
|
-
album?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
interface VideoSource {
|
|
14
4
|
src: string;
|
|
15
5
|
type?: string;
|
|
@@ -202,6 +192,13 @@ interface UsePlayerReturn {
|
|
|
202
192
|
togglePip: () => Promise<void>;
|
|
203
193
|
}
|
|
204
194
|
|
|
195
|
+
interface PlaylistItem {
|
|
196
|
+
id: string;
|
|
197
|
+
src: string;
|
|
198
|
+
title: string;
|
|
199
|
+
poster?: string;
|
|
200
|
+
duration?: number;
|
|
201
|
+
}
|
|
205
202
|
interface ExtendedPlayerProps extends PlexVideoPlayerProps {
|
|
206
203
|
playlist?: PlaylistItem[];
|
|
207
204
|
onPlaylistItemChange?: (index: number, item: PlaylistItem) => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{useRef as l,useState as r,useCallback as i,useEffect as a,forwardRef as s,useMemo as o,useImperativeHandle as c}from"react";const d=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),n=Math.floor(e%3600/60),l=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${n}:${l.toString().padStart(2,"0")}`},u=e=>{const t=e.split(":").map(Number);return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:t[0]||0},p=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),h=(e,t,n)=>Math.min(n,Math.max(t,e)),m=(e,t)=>{let n=!1;return(...l)=>{n||(e(...l),n=!0,setTimeout(()=>n=!1,t))}},v=(e,t)=>{let n=null;return(...l)=>{n&&clearTimeout(n),n=setTimeout(()=>e(...l),t)}},g=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),y=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,w=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,x=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},f=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},b=e=>{const t=e.split("?")[0].split(".").pop()?.toLowerCase();return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska"}[t||""]||"video/mp4"},k=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),_=()=>`plex-${Math.random().toString(36).substring(2,11)}`,N=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),E=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,C=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let n=0;n<e.buffered.length;n++)if(e.buffered.start(n)<=t&&e.buffered.end(n)>=t)return e.buffered.end(n);return e.buffered.end(e.buffered.length-1)},z=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},P=({currentTime:n,duration:s,buffered:o,onSeek:c,thumbnailPreview:u,disabled:m=!1})=>{const v=l(null),[g,y]=r(!1),[w,x]=r(null),[f,b]=r(0),k=p(n,s),_=p(o,s),N=i(e=>{if(!v.current)return 0;const t=v.current.getBoundingClientRect();return h((e-t.left)/t.width,0,1)*s},[s]),E=i(e=>{if(!v.current)return;const t=v.current.getBoundingClientRect(),n="clientX"in e?e.clientX:0,l=h(n-t.left,0,t.width),r=N(n);b(l),x(r),g&&c(r)},[g,N,c]),C=i(e=>{if(m)return;e.preventDefault(),y(!0);const t=N(e.clientX);c(t)},[m,N,c]),z=i(()=>{y(!1)},[]),P=i(e=>{const t=N(e.clientX);x(t)},[N]),T=i(()=>{x(null)},[]);a(()=>{if(g){const e=e=>E(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",z),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",z)}}},[g,E,z]);const L=i(e=>{if(m)return;e.preventDefault();const t=e.touches[0],n=N(t.clientX);y(!0),c(n)},[m,N,c]),S=i(e=>{if(!g)return;const t=e.touches[0],n=N(t.clientX);c(n)},[g,N,c]),A=i(()=>{y(!1)},[]);return e("div",{ref:v,className:"plex-video-player__progress-container",onMouseDown:C,onMouseEnter:P,onMouseLeave:T,onMouseMove:e=>E(e.nativeEvent),onTouchStart:L,onTouchMove:S,onTouchEnd:A,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":n,"aria-valuetext":d(n),tabIndex:0,children:[e("div",{className:"plex-video-player__progress",children:[t("div",{className:"plex-video-player__progress-buffered",style:{width:`${_}%`}}),t("div",{className:"plex-video-player__progress-played",style:{width:`${k}%`}}),t("div",{className:"plex-video-player__progress-handle",style:{left:`${k}%`}})]}),u?.enabled&&null!==w&&e("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${f}px`,width:u.width||160,height:u.height||90},children:[u.sprites&&t("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${u.sprites})`,backgroundPosition:M(w,s,u.interval||10,u.width||160,u.height||90),backgroundSize:"cover"}}),t("div",{className:"plex-video-player__thumbnail-time",children:d(w)})]}),null!==w&&!u?.enabled&&t("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${f}px`,width:"auto",height:"auto",padding:"4px 8px"},children:t("span",{style:{color:"white",fontSize:"12px"},children:d(w)})})]})},M=(e,t,n,l,r)=>{const i=Math.floor(e/n);return`-${i%10*l}px -${Math.floor(i/10)*r}px`},T=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M8 5v14l11-7z"})}),L=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),S=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),A=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"})}),F=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),V=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),R=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),B=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),H=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),q=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14zM5 7h8v6H5z"})}),I=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),D=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"})}),$=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),O=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7.5 13h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2zM7.5 9h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2z"})}),U=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),Q=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),X=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),j=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),K=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),G=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"})}),W=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),Y=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),J=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),Z=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"})}),ee=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),te=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}),ne=({className:e,size:n=24})=>t("svg",{className:e,width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M4 10h12v2H4zm0-4h12v2H4zm0 8h8v2H4zm10 0v6l5-3z"})}),le=({volume:n,muted:l,onVolumeChange:r,onToggleMute:a})=>{const s=i(e=>{const t=parseFloat(e.target.value);r(t)},[r]);return e("div",{className:"plex-video-player__volume-container",children:[t("button",{className:"plex-video-player__btn",onClick:a,"aria-label":l?"Unmute":"Mute",title:l?"Unmute (M)":"Mute (M)",type:"button",children:t(l||0===n?V:n<.33?F:n<.66?A:S,{})}),t("div",{className:"plex-video-player__volume-slider-container",children:t("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:l?0:n,onChange:s,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(l?0:n)}%, var(--plex-progress-bg) ${100*(l?0:n)}%, var(--plex-progress-bg) 100%)`}})})]})},re=({playbackRate:s,playbackSpeeds:o,onPlaybackRateChange:c,qualityEnabled:d,sources:u,currentQuality:p,onQualityChange:h,captionsEnabled:m,textTracks:v,currentTrack:g,onTrackChange:y})=>{const[w,x]=r(!1),[f,b]=r("main"),k=l(null);a(()=>{const e=e=>{k.current&&!k.current.contains(e.target)&&(x(!1),b("main"))};if(w)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[w]);const _=i(()=>{x(e=>!e),b("main")},[]),N=i(e=>{c(e),b("main")},[c]),E=i(e=>{h?.(e),b("main")},[h]),C=i(e=>{y?.(e),b("main")},[y]);return e("div",{className:"plex-video-player__settings-container",ref:k,children:[t("button",{className:"plex-video-player__btn",onClick:_,"aria-label":"Settings","aria-expanded":w,title:"Settings",type:"button",children:t(I,{})}),w&&e("div",{className:"plex-video-player__settings-menu "+(w?"plex-video-player__settings-menu--open":""),children:["main"===f&&e(n,{children:[t("div",{className:"plex-video-player__settings-title",children:"Settings"}),e("button",{className:"plex-video-player__settings-item",onClick:()=>b("speed"),type:"button",children:[t("span",{children:"Playback Speed"}),t("span",{children:1===s?"Normal":`${s}x`})]}),d&&u&&u.length>1&&e("button",{className:"plex-video-player__settings-item",onClick:()=>b("quality"),type:"button",children:[t("span",{children:"Quality"}),t("span",{children:p||"Auto"})]}),m&&v&&v.length>0&&e("button",{className:"plex-video-player__settings-item",onClick:()=>b("captions"),type:"button",children:[t("span",{children:"Captions"}),t("span",{children:g||"Off"})]})]}),"speed"===f&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Playback Speed"}),t("div",{className:"plex-video-player__speed-menu",children:o.map(e=>t("button",{className:"plex-video-player__speed-btn "+(s===e?"plex-video-player__speed-btn--active":""),onClick:()=>N(e),type:"button",children:1===e?"Normal":`${e}x`},e))})]}),"quality"===f&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Quality"}),t("div",{className:"plex-video-player__quality-menu",children:u?.map(n=>e("button",{className:"plex-video-player__settings-item "+(p===n.quality?"plex-video-player__settings-item--active":""),onClick:()=>E(n.quality||n.src),type:"button",children:[t("span",{children:n.label||n.quality||"Unknown"}),p===n.quality&&t(W,{size:16})]},n.quality||n.src))})]}),"captions"===f&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Captions"}),e("div",{className:"plex-video-player__quality-menu",children:[e("button",{className:"plex-video-player__settings-item "+(g?"":"plex-video-player__settings-item--active"),onClick:()=>C(null),type:"button",children:[t("span",{children:"Off"}),!g&&t(W,{size:16})]}),v?.map(n=>e("button",{className:"plex-video-player__settings-item "+(g===n.srclang?"plex-video-player__settings-item--active":""),onClick:()=>C(n.srclang),type:"button",children:[t("span",{children:n.label}),g===n.srclang&&t(W,{size:16})]},n.srclang))]})]})]})]})},ie=({ad:n,timeRemaining:l,canSkip:r,onSkip:i,onClick:a})=>{const s=r?"Skip Ad":`Skip in ${Math.ceil(l)}s`;return e("div",{className:"plex-video-player__ad-overlay",onClick:a,children:[e("div",{className:"plex-video-player__ad-info",children:[t("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e("span",{children:[d(l)," remaining"]})]}),n.clickThrough&&e("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),a()},type:"button",children:[t(G,{size:16}),"Learn More"]}),t("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),r&&i()},disabled:!r,type:"button",children:s})]})},ae={1:"The video playback was aborted.",2:"A network error occurred while loading the video.",3:"The video format is not supported or cannot be decoded.",4:"The video source is not supported."},se=({error:n,onRetry:l})=>{const r=n?.code||0,i=ae[r]||"An unknown error occurred.";return e("div",{className:"plex-video-player__error",children:[t(K,{className:"plex-video-player__error-icon",size:60}),t("div",{className:"plex-video-player__error-message",children:i}),r>0&&e("div",{className:"plex-video-player__error-code",children:["Error Code: ",r]}),t("button",{className:"plex-video-player__error-retry",onClick:l,type:"button",children:"Try Again"})]})},oe=({visible:e})=>e?t("div",{className:"plex-video-player__loader",children:t("div",{className:"plex-video-player__loader-spinner"})}):null,ce=({x:n,y:r,isVisible:i,onClose:s,isPlaying:o,isMuted:c,isLoop:d,playbackRate:u,onTogglePlay:p,onToggleMute:h,onToggleLoop:m,onToggleFullscreen:v,onTogglePip:g,onCopyUrl:y,onPlaybackRateChange:w,pipEnabled:x})=>{const f=l(null);if(a(()=>{const e=e=>{f.current&&!f.current.contains(e.target)&&s()},t=e=>{"Escape"===e.key&&s()};return i&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",t)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[i,s]),a(()=>{if(i&&f.current){const e=f.current,t=e.getBoundingClientRect(),l=window.innerWidth,i=window.innerHeight;let a=n,s=r;n+t.width>l&&(a=l-t.width-10),r+t.height>i&&(s=i-t.height-10),e.style.left=`${a}px`,e.style.top=`${s}px`}},[i,n,r]),!i)return null;const b=[{id:"play",label:o?"Pause":"Play",icon:t(o?L:T,{}),shortcut:"Space",onClick:()=>{p(),s()}},{id:"mute",label:c?"Unmute":"Mute",icon:t(c?S:V,{}),shortcut:"M",onClick:()=>{h(),s()}},{id:"divider1",label:"",divider:!0},{id:"loop",label:d?"Disable Loop":"Enable Loop",icon:t(Y,{}),onClick:()=>{m(),s()}},{id:"speed",label:`Speed: ${u}x`,icon:t($,{}),onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=(e.indexOf(u)+1)%e.length;w(e[t])}},{id:"divider2",label:"",divider:!0},{id:"pip",label:"Picture in Picture",icon:t(H,{}),shortcut:"P",disabled:!x,onClick:()=>{g(),s()}},{id:"fullscreen",label:"Fullscreen",icon:t(R,{}),shortcut:"F",onClick:()=>{v(),s()}},{id:"divider3",label:"",divider:!0},{id:"copy",label:"Copy Video URL",icon:t(J,{}),onClick:()=>{y(),s()}}];return e("div",{ref:f,className:"plex-video-player__context-menu",style:{left:n,top:r},children:[b.map(n=>n.divider?t("div",{className:"plex-video-player__context-menu-divider"},n.id):e("button",{className:"plex-video-player__context-menu-item "+(n.disabled?"plex-video-player__context-menu-item--disabled":""),onClick:n.onClick,disabled:n.disabled,type:"button",children:[t("span",{className:"plex-video-player__context-menu-icon",children:n.icon}),t("span",{className:"plex-video-player__context-menu-label",children:n.label}),n.shortcut&&t("span",{className:"plex-video-player__context-menu-shortcut",children:n.shortcut})]},n.id)),t("div",{className:"plex-video-player__context-menu-footer",children:"PlexVideo Player © FRAMESET STUDIO"})]})},de=({items:n,currentIndex:s,isPlaying:o,isExpanded:c,onItemSelect:u,onToggleExpand:p,onClose:h,onNext:m,onPrevious:v,loop:g=!1,shuffle:y=!1,onShuffleToggle:w,onLoopToggle:x})=>{const f=l(null),[b,k]=r(null),[_,N]=r(null);a(()=>{if(f.current&&c){const e=f.current.querySelector(`[data-index="${s}"]`);e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[s,c]);const E=i((e,t)=>{k(t),e.dataTransfer.effectAllowed="move"},[]),C=i((e,t)=>{e.preventDefault(),N(t)},[]),z=i(()=>{k(null),N(null)},[]),P=n[s];return e("div",{className:"plex-video-player__playlist "+(c?"plex-video-player__playlist--expanded":""),children:[e("div",{className:"plex-video-player__playlist-header",children:[e("button",{className:"plex-video-player__playlist-toggle",onClick:p,type:"button","aria-label":c?"Collapse playlist":"Expand playlist",children:[t(c?ee:Z,{}),e("span",{className:"plex-video-player__playlist-title",children:["Playlist (",s+1,"/",n.length,")"]})]}),e("div",{className:"plex-video-player__playlist-controls",children:[w&&t("button",{className:"plex-video-player__playlist-btn "+(y?"plex-video-player__playlist-btn--active":""),onClick:w,type:"button","aria-label":"Shuffle",title:"Shuffle",children:t(ue,{})}),x&&t("button",{className:"plex-video-player__playlist-btn "+(g?"plex-video-player__playlist-btn--active":""),onClick:x,type:"button","aria-label":"Loop",title:"Loop playlist",children:t(pe,{})}),t("button",{className:"plex-video-player__playlist-btn",onClick:v,disabled:0===s&&!g,type:"button","aria-label":"Previous",title:"Previous",children:t(he,{})}),t("button",{className:"plex-video-player__playlist-btn",onClick:m,disabled:s===n.length-1&&!g,type:"button","aria-label":"Next",title:"Next",children:t(me,{})}),t("button",{className:"plex-video-player__playlist-btn plex-video-player__playlist-btn--close",onClick:h,type:"button","aria-label":"Close playlist",children:t(te,{})})]})]}),!c&&P&&e("div",{className:"plex-video-player__playlist-current",children:[P.poster&&t("img",{src:P.poster,alt:P.title,className:"plex-video-player__playlist-current-thumb"}),e("div",{className:"plex-video-player__playlist-current-info",children:[t("div",{className:"plex-video-player__playlist-current-title",children:P.title}),P.artist&&t("div",{className:"plex-video-player__playlist-current-artist",children:P.artist})]}),t(o?L:T,{})]}),c&&t("div",{ref:f,className:"plex-video-player__playlist-items",children:n.map((n,l)=>e("div",{"data-index":l,className:`plex-video-player__playlist-item ${l===s?"plex-video-player__playlist-item--active":""} ${b===l?"plex-video-player__playlist-item--dragging":""} ${_===l?"plex-video-player__playlist-item--drag-over":""}`,draggable:!0,onDragStart:e=>E(e,l),onDragOver:e=>C(e,l),onDragEnd:z,onClick:()=>u(l),children:[t("div",{className:"plex-video-player__playlist-item-number",children:l===s&&o?e("div",{className:"plex-video-player__playlist-playing-indicator",children:[t("span",{}),t("span",{}),t("span",{})]}):l+1}),n.poster&&t("img",{src:n.poster,alt:n.title,className:"plex-video-player__playlist-item-thumb"}),e("div",{className:"plex-video-player__playlist-item-info",children:[t("div",{className:"plex-video-player__playlist-item-title",children:n.title}),n.artist&&t("div",{className:"plex-video-player__playlist-item-artist",children:n.artist})]}),n.duration&&t("div",{className:"plex-video-player__playlist-item-duration",children:d(n.duration)})]},n.id))})]})},ue=()=>t("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t("path",{d:"M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z"})}),pe=()=>t("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),he=()=>t("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t("path",{d:"M6 6h2v12H6V6zm3.5 6l8.5 6V6l-8.5 6z"})}),me=()=>t("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t("path",{d:"M6 18l8.5-6L6 6v12zm2-8.14L11.03 12 8 14.14V9.86zM16 6h2v12h-2V6z"})}),ve={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"},ge=({enabled:e,hotkeys:t={},onPlay:n,onMute:l,onFullscreen:r,onPip:s,onSeek:o,onVolume:c,containerRef:d})=>{const u={...ve,...t},p=i(t=>{if(!e)return;const i=t.target;if("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)return;const a=d.current;if(!a||!a.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),n();break;case u.mute:case"M":t.preventDefault(),l();break;case u.fullscreen:case"F":t.preventDefault(),r();break;case u.pip:case"P":t.preventDefault(),s();break;case u.seekForward:t.preventDefault(),o(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),o(t.shiftKey?-30:-10);break;case u.volumeUp:t.preventDefault(),c(.1);break;case u.volumeDown:t.preventDefault(),c(-.1);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.preventDefault(),o(-1/0)}},[e,u,n,l,r,s,o,c,d]);a(()=>{if(e)return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[e,p])},ye=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const n=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const l=e.getAttribute("id")||"",r=t.querySelector("AdTitle")?.textContent||"",i=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let s,o,c=0;const d=[],u=[],p={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const n=t.querySelector("Duration")?.textContent;n&&(c=we(n));const l=t.getAttribute("skipoffset");l&&(s=we(l));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&u.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const r=t.querySelector("VideoClicks");r&&(o=r.querySelector("ClickThrough")?.textContent?.trim(),r.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&d.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),n=e.textContent?.trim();t&&n&&(p[t]||(p[t]=[]),p[t].push(n))})});const h=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&h.push(t)}),u.length>0&&n.push({id:l,title:r,description:i,duration:c,skipOffset:s,clickThrough:o,clickTracking:d,impressionUrls:h,mediaFiles:u,trackingEvents:p})}),{ads:n}},we=e=>{if(e.includes("%"))return-1;const t=e.split(":");if(3!==t.length)return 0;return 3600*parseInt(t[0],10)+60*parseInt(t[1],10)+parseFloat(t[2])},xe=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const n=await t.text(),l=ye(n);if(l.error||0===l.ads.length)return null;const r=l.ads[0];return void 0!==e.skipDelay&&void 0===r.skipOffset&&(r.skipOffset=e.skipDelay),r}catch(e){return null}},fe=e=>{if(0===e.length)return null;const t=document.createElement("video"),n=e.filter(e=>""!==t.canPlayType(e.type));if(0===n.length)return null;n.sort((e,t)=>{const n=e.width*e.height,l=t.width*t.height;return n!==l?l-n:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&n.length>1?n[n.length-1]:n[0]},be=e=>{(new Image).src=e},ke=e=>{e.forEach(be)},_e=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),Ne=({vastConfig:e,videoRef:t,onAdStart:n,onAdEnd:s,onAdSkip:o,onAdError:c})=>{const[d,u]=r(!1),[p,h]=r(null),[m,v]=r(0),[g,y]=r(!1),w=l(null),x=l(""),f=l(0),b=l(new Set),k=l(null),_=Array.isArray(e)?e:e?[e]:[],N=i(async e=>{const l=t.current;if(l&&!d)try{const t=await xe(e);if(!t)return void c?.(new Error("Failed to fetch VAST ad"));const r=fe(t.mediaFiles);if(!r)return void c?.(new Error("No compatible media file found"));x.current=l.currentSrc,f.current=l.currentTime,ke(t.impressionUrls),w.current=t,h(_e(t)),u(!0),v(t.duration),y(void 0===t.skipOffset||0===t.skipOffset),l.src=r.url,l.currentTime=0,await l.play(),t.trackingEvents.start&&ke(t.trackingEvents.start),n?.(_e(t)),k.current=window.setInterval(()=>{const e=Math.max(0,t.duration-l.currentTime);v(e),t.skipOffset&&l.currentTime>=t.skipOffset&&y(!0);const n=l.currentTime/t.duration*100;n>=25&&t.trackingEvents.firstQuartile&&ke(t.trackingEvents.firstQuartile),n>=50&&t.trackingEvents.midpoint&&ke(t.trackingEvents.midpoint),n>=75&&t.trackingEvents.thirdQuartile&&ke(t.trackingEvents.thirdQuartile)},250);const i=()=>{t.trackingEvents.complete&&ke(t.trackingEvents.complete),E()};l.addEventListener("ended",i,{once:!0})}catch(e){c?.(e instanceof Error?e:new Error("Ad playback failed")),E()}},[t,d,n,c]),E=i(()=>{const e=t.current;e&&(k.current&&(clearInterval(k.current),k.current=null),x.current&&(e.src=x.current,e.currentTime=f.current,e.play().catch(()=>{})),u(!1),h(null),v(0),y(!1),w.current=null,s?.())},[t,s]),C=i(()=>{if(!g||!w.current)return;const e=w.current;e.trackingEvents.skip&&ke(e.trackingEvents.skip),o?.(),E()},[g,E,o]),z=i(()=>{if(!w.current)return;const e=w.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&ke(e.clickTracking)},[]),P=i((e,t)=>{d||0===_.length||_.forEach(n=>{const l=n.position||"preroll",r=`${l}-${n.midrollTime||0}`;if(b.current.has(r))return;let i=!1;switch(l){case"preroll":i=0===e;break;case"midroll":n.midrollTime&&e>=n.midrollTime&&(i=!0);break;case"postroll":i=e>=t-.5}i&&(b.current.add(r),N(n))})},[_,d,N]);return a(()=>()=>{k.current&&clearInterval(k.current)},[]),{isAdPlaying:d,currentAd:p,adTimeRemaining:m,canSkip:g,skipAd:C,handleAdClick:z,checkForAd:P}},Ee=s((n,s)=>{const{src:u,poster:p,autoPlay:h=!1,muted:v=!1,loop:g=!1,controls:y=!0,width:w="100%",className:x="",style:f={},pip:b=!0,fullscreen:k=!0,playbackSpeed:_=!0,playbackSpeeds:N=[.25,.5,.75,1,1.25,1.5,1.75,2],volume:E=!0,initialVolume:C=1,progressBar:z=!0,timeDisplay:M=!0,qualitySelector:S=!0,textTracks:A=[],vast:F,keyboard:V=!0,hotkeys:q,accentColor:I="#f5c518",controlsTimeout:D=3e3,doubleClickFullscreen:$=!0,clickToPlay:O=!0,preload:U="metadata",playlist:Q=[],onPlay:X,onPause:j,onEnded:K,onTimeUpdate:G,onProgress:W,onVolumeChange:Y,onFullscreenChange:J,onPipChange:Z,onQualityChange:ee,onError:te,onAdStart:ae,onAdEnd:ue,onAdSkip:pe,onAdError:he,onReady:me,onPlaylistItemChange:ve}=n,ye=l(null),we=l(null),xe=l(null),fe=l(0),[be,ke]=r(!1),[_e,Ee]=r(0),[Ce,ze]=r(0),[Pe,Me]=r(0),[Te,Le]=r(v?0:C),[Se,Ae]=r(v),[Fe,Ve]=r(!1),[Re,Be]=r(!1),[He,qe]=r(!0),[Ie,De]=r(null),[$e,Oe]=r(!0),[Ue,Qe]=r(1),[Xe,je]=r("auto"),[Ke,Ge]=r(null),[We,Ye]=r(g),[Je,Ze]=r({x:0,y:0,visible:!1}),[et,tt]=r(!1),[nt,lt]=r(!0),[rt,it]=r(0),[at,st]=r(!1),[ot,ct]=r(!1),dt=o(()=>"string"==typeof u?[{src:u,type:"video/mp4"}]:u,[u]),ut=o(()=>Q.length>0&&Q[rt]?Q[rt].src:dt[0]?.src||"",[Q,rt,dt]),pt=o(()=>Q.length>0&&Q[rt]?.poster?Q[rt].poster:p,[Q,rt,p]),{currentAd:ht,isAdPlaying:mt,adTimeRemaining:vt,canSkip:gt,skipAd:yt,handleAdClick:wt,checkForAd:xt}=Ne({vastConfig:F,videoRef:ye,onAdStart:ae,onAdEnd:ue,onAdSkip:pe,onAdError:he}),ft=i(async()=>{const e=ye.current;if(e)try{await e.play()}catch(e){}},[]),bt=i(()=>{const e=ye.current;e&&e.pause()},[]),kt=i(()=>{const e=ye.current;e&&(e.pause(),e.currentTime=0)},[]),_t=i(()=>{const e=ye.current;e&&(e.paused?ft():bt())},[ft,bt]),Nt=i(e=>{const t=ye.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),Et=i(e=>{const t=ye.current;if(!t)return;const n=Math.max(0,Math.min(1,e));t.volume=n,t.muted=0===n,Le(n),Ae(0===n)},[]),Ct=i(()=>{const e=ye.current;e&&(e.muted=!0,Ae(!0))},[]),zt=i(()=>{const e=ye.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,Le(.5)),Ae(!1))},[]),Pt=i(()=>{const e=ye.current;e&&(e.muted?zt():Ct())},[Ct,zt]),Mt=i(()=>{const e=ye.current;e&&(e.loop=!e.loop,Ye(e.loop))},[]),Tt=i(async()=>{const e=we.current;if(e)try{await e.requestFullscreen(),Ve(!0)}catch(e){}},[]),Lt=i(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),Ve(!1))}catch(e){}},[]),St=i(async()=>{document.fullscreenElement?await Lt():await Tt()},[Tt,Lt]),At=i(async()=>{const e=ye.current;if(e&&document.pictureInPictureEnabled)try{await e.requestPictureInPicture(),Be(!0)}catch(e){}},[]),Ft=i(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),Be(!1))}catch(e){}},[]),Vt=i(async()=>{document.pictureInPictureElement?await Ft():await At()},[At,Ft]),Rt=i(e=>{const t=ye.current;t&&(t.playbackRate=e,Qe(e))},[]),Bt=i(e=>{const t=dt.find(t=>t.label===e||t.quality===e);if(t&&ye.current){const n=ye.current,l=!n.paused,r=n.currentTime;n.src=t.src,n.currentTime=r,l&&n.play(),je(e),ee?.(e)}},[dt,ee]),Ht=i(e=>{const t=ye.current;if(t){for(let n=0;n<t.textTracks.length;n++){const l=t.textTracks[n];l.mode=l.label===e?"showing":"hidden"}Ge(e)}},[]),qt=i(e=>{e>=0&&e<Q.length&&(it(e),ve?.(e,Q[e]),setTimeout(()=>ft(),100))},[Q,ve,ft]),It=i(()=>{if(0===Q.length)return;let e=rt+1;if(e>=Q.length){if(!at)return;e=0}ot&&(e=Math.floor(Math.random()*Q.length)),qt(e)},[rt,Q.length,at,ot,qt]),Dt=i(()=>{if(0===Q.length)return;let e=rt-1;if(e<0){if(!at)return;e=Q.length-1}qt(e)},[rt,Q.length,at,qt]),$t=i(e=>{e.preventDefault(),Ze({x:e.clientX,y:e.clientY,visible:!0})},[]),Ot=i(()=>{Ze(e=>({...e,visible:!1}))},[]),Ut=i(()=>{navigator.clipboard.writeText(ut)},[ut]),Qt=i(()=>{be&&Oe(!1)},[be]),Xt=i(()=>{Oe(!0),xe.current&&clearTimeout(xe.current),be&&(xe.current=setTimeout(Qt,D))},[be,D,Qt]),jt=o(()=>m(Xt,200),[Xt]),Kt=i(()=>{if(!O)return;const e=Date.now();$&&e-fe.current<300?St():_t(),fe.current=e},[O,$,_t,St]);a(()=>{const e=ye.current;if(!e)return;const t=()=>{ke(!0),X?.()},n=()=>{ke(!1),j?.()},l=()=>{ke(!1),K?.(),Q.length>0&&It()},r=()=>{Ee(e.currentTime),G?.(e.currentTime),xt(e.currentTime,e.duration)},i=()=>{ze(e.duration)},a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1)/e.duration*100;Me(t),W?.(t)}},s=()=>{Le(e.volume),Ae(e.muted),Y?.(e.volume,e.muted)},o=()=>{ze(e.duration),qe(!1),me?.()},c=()=>{qe(!0)},d=()=>{qe(!1)},u=()=>{qe(!1)},p=()=>{De(e.error),qe(!1),te?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",n),e.addEventListener("ended",l),e.addEventListener("timeupdate",r),e.addEventListener("durationchange",i),e.addEventListener("progress",a),e.addEventListener("volumechange",s),e.addEventListener("loadedmetadata",o),e.addEventListener("waiting",c),e.addEventListener("playing",d),e.addEventListener("canplay",u),e.addEventListener("error",p),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",n),e.removeEventListener("ended",l),e.removeEventListener("timeupdate",r),e.removeEventListener("durationchange",i),e.removeEventListener("progress",a),e.removeEventListener("volumechange",s),e.removeEventListener("loadedmetadata",o),e.removeEventListener("waiting",c),e.removeEventListener("playing",d),e.removeEventListener("canplay",u),e.removeEventListener("error",p)}},[X,j,K,G,W,Y,me,te,xt,Q.length,It]),a(()=>{const e=()=>{const e=!!document.fullscreenElement;Ve(e),J?.(e)};return document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[J]),a(()=>{const e=ye.current;if(!e)return;const t=()=>{Be(!0),Z?.(!0)},n=()=>{Be(!1),Z?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",n),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",n)}},[Z]),ge({enabled:V,containerRef:we,hotkeys:q,onPlay:_t,onMute:Pt,onFullscreen:St,onPip:Vt,onSeek:e=>Nt(_e+e),onVolume:e=>Et(Te+e)}),a(()=>()=>{xe.current&&clearTimeout(xe.current)},[]);const Gt=i(()=>{De(null),ye.current?.load()},[]);c(s,()=>({play:ft,pause:bt,stop:kt,seek:Nt,setVolume:Et,mute:Ct,unmute:zt,toggleMute:Pt,enterFullscreen:Tt,exitFullscreen:Lt,toggleFullscreen:St,enterPip:At,exitPip:Ft,togglePip:Vt,setPlaybackRate:Rt,setQuality:Bt,getCurrentTime:()=>ye.current?.currentTime||0,getDuration:()=>ye.current?.duration||0,getVolume:()=>ye.current?.volume||0,isMuted:()=>ye.current?.muted??!0,isPlaying:()=>!ye.current?.paused,isFullscreen:()=>Fe,isPip:()=>Re,getVideoElement:()=>ye.current}),[ft,bt,kt,Nt,Et,Ct,zt,Pt,Tt,Lt,St,At,Ft,Vt,Rt,Bt,Fe,Re]);return e("div",{ref:we,className:`plex-video-player ${Fe?"plex-video-player--fullscreen":""} ${x}`,style:{...{"--plex-accent-color":I,"--plex-primary":I},width:w,...f},onMouseMove:jt,onMouseLeave:()=>be&&Oe(!1),onContextMenu:$t,tabIndex:0,children:[e("video",{ref:ye,className:"plex-video-player__video",src:ut,poster:pt,autoPlay:h,muted:v,loop:We,preload:U,playsInline:!0,onClick:Kt,children:[dt.slice(1).map((e,n)=>t("source",{src:e.src,type:e.type},n)),A.map((e,n)=>t("track",{kind:e.kind,src:e.src,srcLang:e.srclang,label:e.label,default:e.default},n))]}),t(oe,{visible:He&&!Ie}),Ie&&t(se,{error:Ie,onRetry:Gt}),mt&&ht&&t(ie,{ad:ht,timeRemaining:vt,canSkip:gt,onSkip:yt,onClick:wt}),t(ce,{x:Je.x,y:Je.y,isVisible:Je.visible,onClose:Ot,isPlaying:be,isMuted:Se,isLoop:We,playbackRate:Ue,onTogglePlay:_t,onToggleMute:Pt,onToggleLoop:Mt,onToggleFullscreen:St,onTogglePip:Vt,onCopyUrl:Ut,onPlaybackRateChange:Rt,pipEnabled:document.pictureInPictureEnabled,videoUrl:ut}),Q.length>0&&et&&t(de,{items:Q,currentIndex:rt,isPlaying:be,isExpanded:nt,onItemSelect:qt,onToggleExpand:()=>lt(!nt),onClose:()=>tt(!1),onNext:It,onPrevious:Dt,loop:at,shuffle:ot,onLoopToggle:()=>st(!at),onShuffleToggle:()=>ct(!ot)}),y&&!mt&&e("div",{className:"plex-video-player__controls "+($e?"plex-video-player__controls--visible":""),children:[z&&t(P,{currentTime:_e,duration:Ce,buffered:Pe,onSeek:Nt}),e("div",{className:"plex-video-player__controls-bottom",children:[e("div",{className:"plex-video-player__controls-left",children:[t("button",{className:"plex-video-player__btn",onClick:_t,"aria-label":be?"Pause":"Play",type:"button",children:t(be?L:T,{})}),E&&t(le,{volume:Te,muted:Se,onVolumeChange:Et,onToggleMute:Pt}),M&&e("div",{className:"plex-video-player__time",children:[t("span",{children:d(_e)}),t("span",{children:" / "}),t("span",{children:d(Ce)})]})]}),e("div",{className:"plex-video-player__controls-right",children:[Q.length>0&&t("button",{className:"plex-video-player__btn "+(et?"plex-video-player__btn--active":""),onClick:()=>tt(!et),"aria-label":"Playlist",type:"button",children:t(ne,{})}),_&&t(re,{playbackRate:Ue,playbackSpeeds:N,onPlaybackRateChange:Rt,qualityEnabled:S&&dt.length>1,sources:dt,currentQuality:Xe,onQualityChange:Bt,captionsEnabled:A.length>0,textTracks:A,currentTrack:Ke??void 0,onTrackChange:Ht}),b&&document.pictureInPictureEnabled&&t("button",{className:"plex-video-player__btn",onClick:Vt,"aria-label":Re?"Exit Picture in Picture":"Picture in Picture",type:"button",children:t(H,{})}),k&&t("button",{className:"plex-video-player__btn",onClick:St,"aria-label":Fe?"Exit Fullscreen":"Fullscreen",type:"button",children:t(Fe?B:R,{})})]})]})]}),!be&&!He&&!Ie&&!mt&&t("button",{className:"plex-video-player__big-play",onClick:_t,"aria-label":"Play",type:"button",children:t(T,{})})]})});Ee.displayName="PlexVideoPlayer";const Ce={isPlaying:!1,isPaused:!0,isEnded:!1,isBuffering:!1,isSeeking:!1,isFullscreen:!1,isPip:!1,isMuted:!1,isAdPlaying:!1,volume:1,currentTime:0,duration:0,buffered:0,playbackRate:1,currentQuality:null,error:null},ze=(e={})=>{const{autoPlay:t=!1,muted:n=!1,loop:s=!1,volume:o=1,playbackRate:c=1}=e,d=l(null),u=l(null),[p,h]=r({...Ce,volume:o,isMuted:n,playbackRate:c}),m=i(e=>{h(t=>({...t,...e}))},[]),v=i(async()=>{const e=d.current;if(e)try{await e.play(),m({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[m]),g=i(()=>{const e=d.current;e&&(e.pause(),m({isPlaying:!1,isPaused:!0}))},[m]),b=i(()=>{p.isPlaying?g():v()},[p.isPlaying,v,g]),k=i(e=>{const t=d.current;if(!t)return;const n=Math.max(0,Math.min(e,t.duration||0));t.currentTime=n,m({currentTime:n})},[m]),_=i(e=>{const t=d.current;if(!t)return;const n=Math.max(0,Math.min(1,e));t.volume=n,t.muted=0===n,m({volume:n,isMuted:0===n})},[m]),N=i(()=>{const e=d.current;e&&(e.muted=!e.muted,m({isMuted:e.muted}))},[m]),E=i(e=>{const t=d.current;t&&(t.playbackRate=e,m({playbackRate:e}))},[m]),z=i(async()=>{const e=u.current;if(e)try{await x(e),m({isFullscreen:!0})}catch(e){}},[m]),P=i(async()=>{try{await f(),m({isFullscreen:!1})}catch(e){}},[m]),M=i(async()=>{p.isFullscreen?await P():await z()},[p.isFullscreen,z,P]),T=i(async()=>{const e=d.current;if(e&&y())try{await e.requestPictureInPicture(),m({isPip:!0})}catch(e){}},[m]),L=i(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),m({isPip:!1})}catch(e){}},[m]),S=i(async()=>{p.isPip?await L():await T()},[p.isPip,T,L]);return a(()=>{const e=d.current;if(!e)return;e.muted=n,e.volume=o,e.playbackRate=c,e.loop=s;const l={loadedmetadata:()=>{m({duration:e.duration})},timeupdate:()=>{m({currentTime:e.currentTime,buffered:C(e)})},play:()=>{m({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{m({isPlaying:!1,isPaused:!0})},ended:()=>{m({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{m({isBuffering:!0})},canplay:()=>{m({isBuffering:!1})},seeking:()=>{m({isSeeking:!0})},seeked:()=>{m({isSeeking:!1})},volumechange:()=>{m({volume:e.volume,isMuted:e.muted})},ratechange:()=>{m({playbackRate:e.playbackRate})},error:()=>{m({error:e.error})},enterpictureinpicture:()=>{m({isPip:!0})},leavepictureinpicture:()=>{m({isPip:!1})}};return Object.entries(l).forEach(([t,n])=>{e.addEventListener(t,n)}),t&&v(),()=>{Object.entries(l).forEach(([t,n])=>{e.removeEventListener(t,n)})}},[t,n,s,o,c,v,m]),a(()=>{const e=()=>{const e=!!w();m({isFullscreen:e})};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}},[m]),{state:p,videoRef:d,containerRef:u,play:v,pause:g,togglePlay:b,seek:k,setVolume:_,toggleMute:N,setPlaybackRate:E,enterFullscreen:z,exitFullscreen:P,toggleFullscreen:M,enterPip:T,exitPip:L,togglePip:S}};export{ie as AdOverlay,D as CaptionsIcon,W as CheckIcon,se as ErrorDisplay,K as ErrorIcon,G as ExternalLinkIcon,U as ForwardIcon,B as FullscreenExitIcon,R as FullscreenIcon,oe as Loader,L as PauseIcon,q as PipExitIcon,H as PipIcon,T as PlayIcon,Ee as PlexVideoPlayer,P as ProgressBar,O as QualityIcon,Q as RewindIcon,I as SettingsIcon,re as SettingsMenu,X as SkipNextIcon,j as SkipPrevIcon,$ as SpeedIcon,le as VolumeControl,S as VolumeHighIcon,F as VolumeLowIcon,A as VolumeMediumIcon,V as VolumeMuteIcon,z as canPlayType,h as clamp,_e as convertToAdInfo,v as debounce,Ee as default,b as detectVideoType,f as exitFullscreen,xe as fetchVastAd,be as fireTrackingPixel,ke as fireTrackingPixels,d as formatTime,_ as generateId,C as getBufferedEnd,w as getFullscreenElement,g as isFullscreenSupported,k as isHlsNativelySupported,N as isMobile,y as isPipSupported,E as isTouchDevice,u as parseTime,ye as parseVastXml,p as percentage,x as requestFullscreen,fe as selectBestMediaFile,m as throttle,ge as useKeyboard,ze as usePlayer,Ne as useVast};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{useState as n,useRef as l,useCallback as i,useEffect as a,forwardRef as s,useMemo as c,useImperativeHandle as o}from"react";const u=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const r=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const n=e.getAttribute("id")||"",l=t.querySelector("AdTitle")?.textContent||"",i=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let s,c,o=0;const u=[],h=[],m={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const r=t.querySelector("Duration")?.textContent;r&&(o=d(r));const n=t.getAttribute("skipoffset");n&&(s=d(n));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&h.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const l=t.querySelector("VideoClicks");l&&(c=l.querySelector("ClickThrough")?.textContent?.trim(),l.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&u.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),r=e.textContent?.trim();t&&r&&(m[t]||(m[t]=[]),m[t].push(r))})});const p=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&p.push(t)}),h.length>0&&r.push({id:n,title:l,description:i,duration:o,skipOffset:s,clickThrough:c,clickTracking:u,impressionUrls:p,mediaFiles:h,trackingEvents:m})}),{ads:r}},d=e=>{if(e.includes("%"))return-1;const t=e.split(":");if(3!==t.length)return 0;return 3600*parseInt(t[0],10)+60*parseInt(t[1],10)+parseFloat(t[2])},h=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const r=await t.text(),n=u(r);if(n.error||0===n.ads.length)return null;const l=n.ads[0];return void 0!==e.skipDelay&&void 0===l.skipOffset&&(l.skipOffset=e.skipDelay),l}catch(e){return null}},m=e=>{if(0===e.length)return null;const t=document.createElement("video"),r=e.filter(e=>""!==t.canPlayType(e.type));if(0===r.length)return null;r.sort((e,t)=>{const r=e.width*e.height,n=t.width*t.height;return r!==n?n-r:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&r.length>1?r[r.length-1]:r[0]},p=e=>{(new Image).src=e},v=e=>{e.forEach(p)},g=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),w=({vastConfig:e,videoRef:t,onAdStart:r,onAdEnd:s,onAdSkip:c,onAdError:o})=>{const[u,d]=n(!1),[p,w]=n(null),[f,x]=n(0),[y,b]=n(!1),k=l(null),N=l(""),E=l(0),z=l(new Set),C=l(null),M=Array.isArray(e)?e:e?[e]:[],P=i(async e=>{const n=t.current;if(n&&!u)try{const t=await h(e);if(!t)return void o?.(new Error("Failed to fetch VAST ad"));const l=m(t.mediaFiles);if(!l)return void o?.(new Error("No compatible media file found"));N.current=n.currentSrc,E.current=n.currentTime,v(t.impressionUrls),k.current=t,w(g(t)),d(!0),x(t.duration),b(void 0===t.skipOffset||0===t.skipOffset),n.src=l.url,n.currentTime=0,await n.play(),t.trackingEvents.start&&v(t.trackingEvents.start),r?.(g(t)),C.current=window.setInterval(()=>{const e=Math.max(0,t.duration-n.currentTime);x(e),t.skipOffset&&n.currentTime>=t.skipOffset&&b(!0);const r=n.currentTime/t.duration*100;r>=25&&t.trackingEvents.firstQuartile&&v(t.trackingEvents.firstQuartile),r>=50&&t.trackingEvents.midpoint&&v(t.trackingEvents.midpoint),r>=75&&t.trackingEvents.thirdQuartile&&v(t.trackingEvents.thirdQuartile)},250);const i=()=>{t.trackingEvents.complete&&v(t.trackingEvents.complete),_()};n.addEventListener("ended",i,{once:!0})}catch(e){o?.(e instanceof Error?e:new Error("Ad playback failed")),_()}},[t,u,r,o]),_=i(()=>{const e=t.current;e&&(C.current&&(clearInterval(C.current),C.current=null),N.current&&(e.src=N.current,e.currentTime=E.current,e.play().catch(()=>{})),d(!1),w(null),x(0),b(!1),k.current=null,s?.())},[t,s]),L=i(()=>{if(!y||!k.current)return;const e=k.current;e.trackingEvents.skip&&v(e.trackingEvents.skip),c?.(),_()},[y,_,c]),T=i(()=>{if(!k.current)return;const e=k.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&v(e.clickTracking)},[]),A=i((e,t)=>{u||0===M.length||M.forEach(r=>{const n=r.position||"preroll",l=`${n}-${r.midrollTime||0}`;if(z.current.has(l))return;let i=!1;switch(n){case"preroll":i=0===e;break;case"midroll":r.midrollTime&&e>=r.midrollTime&&(i=!0);break;case"postroll":i=e>=t-.5}i&&(z.current.add(l),P(r))})},[M,u,P]);return a(()=>()=>{C.current&&clearInterval(C.current)},[]),{isAdPlaying:u,currentAd:p,adTimeRemaining:f,canSkip:y,skipAd:L,handleAdClick:T,checkForAd:A}},f=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60);return t>0?`${t}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r}:${n.toString().padStart(2,"0")}`},x=e=>{const t=e.split(":").map(Number);return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:t[0]||0},y=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),b=(e,t,r)=>Math.min(r,Math.max(t,e)),k=(e,t)=>{let r=!1;return(...n)=>{r||(e(...n),r=!0,setTimeout(()=>r=!1,t))}},N=(e,t)=>{let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...n),t)}},E=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),z=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,C=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,M=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},P=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},_=e=>{const t=e.split("?")[0].split(".").pop()?.toLowerCase();return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska"}[t||""]||"video/mp4"},L=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),T=()=>`plex-${Math.random().toString(36).substring(2,11)}`,A=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),S=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,V=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let r=0;r<e.buffered.length;r++)if(e.buffered.start(r)<=t&&e.buffered.end(r)>=t)return e.buffered.end(r);return e.buffered.end(e.buffered.length-1)},F=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},H=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M8 5v14l11-7z"})}),B=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),R=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),q=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),D=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),$=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),I=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),O=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:t("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),U=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:t("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),j=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:t("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),Q=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:t("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),X=s((r,s)=>{const{src:u,poster:d,autoPlay:h=!1,muted:m=!1,loop:p=!1,controls:v=!0,width:g="100%",className:x="",style:y={},pip:b=!0,fullscreen:N=!0,playbackSpeed:E=!0,playbackSpeeds:z=[.5,.75,1,1.25,1.5,2],volume:C=!0,initialVolume:M=1,textTracks:P=[],vast:_,accentColor:L="#f5c518",controlsTimeout:T=3e3,doubleClickFullscreen:A=!0,clickToPlay:S=!0,preload:V="metadata",playlist:F=[],onPlay:X,onPause:K,onEnded:G,onTimeUpdate:Y,onProgress:J,onVolumeChange:W,onFullscreenChange:Z,onPipChange:ee,onQualityChange:te,onError:re,onAdStart:ne,onAdEnd:le,onAdSkip:ie,onAdError:ae,onReady:se,onPlaylistItemChange:ce}=r,oe=l(null),ue=l(null),de=l(null),he=l(null),me=l(0),[pe,ve]=n(!1),[ge,we]=n(0),[fe,xe]=n(0),[ye,be]=n(0),[ke,Ne]=n(m?0:M),[Ee,ze]=n(m),[Ce,Me]=n(!1),[Pe,_e]=n(!1),[Le,Te]=n(!0),[Ae,Se]=n(null),[Ve,Fe]=n(!0),[He,Be]=n(1),[Re,qe]=n(p),[De,$e]=n(!1),[Ie,Oe]=n({x:0,y:0,visible:!1}),[Ue,je]=n(0),Qe=c(()=>"string"==typeof u?[{src:u,type:"video/mp4"}]:u,[u]),Xe=c(()=>F.length>0&&F[Ue]?F[Ue].src:Qe[0]?.src||"",[F,Ue,Qe]),Ke=c(()=>F.length>0&&F[Ue]?.poster?F[Ue].poster:d,[F,Ue,d]),{currentAd:Ge,isAdPlaying:Ye,adTimeRemaining:Je,canSkip:We,skipAd:Ze,handleAdClick:et,checkForAd:tt}=w({vastConfig:_,videoRef:oe,onAdStart:ne,onAdEnd:le,onAdSkip:ie,onAdError:ae}),rt=i(async()=>{const e=oe.current;if(e)try{await e.play()}catch(e){}},[]),nt=i(()=>{oe.current?.pause()},[]),lt=i(()=>{const e=oe.current;e&&(e.pause(),e.currentTime=0)},[]),it=i(()=>{oe.current?.paused?rt():nt()},[rt,nt]),at=i(e=>{const t=oe.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),st=i(e=>{const t=oe.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,Ne(r),ze(0===r)},[]),ct=i(()=>{oe.current&&(oe.current.muted=!0,ze(!0))},[]),ot=i(()=>{const e=oe.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,Ne(.5)),ze(!1))},[]),ut=i(()=>{oe.current?.muted?ot():ct()},[ct,ot]),dt=i(()=>{oe.current&&(oe.current.loop=!oe.current.loop,qe(oe.current.loop))},[]),ht=i(async()=>{try{await(ue.current?.requestFullscreen()),Me(!0)}catch(e){}},[]),mt=i(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),Me(!1))}catch(e){}},[]),pt=i(async()=>{document.fullscreenElement?await mt():await ht()},[ht,mt]),vt=i(async()=>{try{await(oe.current?.requestPictureInPicture()),_e(!0)}catch(e){}},[]),gt=i(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),_e(!1))}catch(e){}},[]),wt=i(async()=>{document.pictureInPictureElement?await gt():await vt()},[vt,gt]),ft=i(e=>{oe.current&&(oe.current.playbackRate=e,Be(e),$e(!1))},[]),xt=i(e=>{const t=Qe.find(t=>t.label===e||t.quality===e);if(t&&oe.current){const r=oe.current,n=!r.paused,l=r.currentTime;r.src=t.src,r.currentTime=l,n&&r.play(),te?.(e)}},[Qe,te]),yt=i(()=>{if(0===F.length)return;const e=(Ue+1)%F.length;je(e),ce?.(e,F[e]),setTimeout(()=>rt(),100)},[Ue,F,ce,rt]),bt=i(e=>{e.preventDefault();const t=ue.current?.getBoundingClientRect();t&&Oe({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),kt=i(()=>{Oe(e=>({...e,visible:!1}))},[]),Nt=i(()=>{navigator.clipboard.writeText(Xe),kt()},[Xe,kt]),Et=i(e=>{const t=de.current?.getBoundingClientRect();if(t&&fe){const r=(e.clientX-t.left)/t.width;at(r*fe)}},[fe,at]),zt=i(()=>{pe&&!De&&Fe(!1)},[pe,De]),Ct=i(()=>{Fe(!0),he.current&&clearTimeout(he.current),pe&&(he.current=setTimeout(zt,T))},[pe,T,zt]),Mt=c(()=>k(Ct,200),[Ct]),Pt=i(()=>{if(kt(),!S)return;const e=Date.now();A&&e-me.current<300?pt():it(),me.current=e},[S,A,it,pt,kt]);a(()=>{const e=oe.current;if(!e)return;const t=()=>{ve(!0),X?.()},r=()=>{ve(!1),K?.()},n=()=>{ve(!1),G?.(),F.length>0&&yt()},l=()=>{we(e.currentTime),Y?.(e.currentTime),tt(e.currentTime,e.duration)},i=()=>xe(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);be(t/e.duration*100),J?.(t/e.duration*100)}},s=()=>{Ne(e.volume),ze(e.muted),W?.(e.volume,e.muted)},c=()=>{xe(e.duration),Te(!1),se?.()},o=()=>Te(!0),u=()=>Te(!1),d=()=>Te(!1),h=()=>{Se(e.error),Te(!1),re?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",n),e.addEventListener("timeupdate",l),e.addEventListener("durationchange",i),e.addEventListener("progress",a),e.addEventListener("volumechange",s),e.addEventListener("loadedmetadata",c),e.addEventListener("waiting",o),e.addEventListener("playing",u),e.addEventListener("canplay",d),e.addEventListener("error",h),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",r),e.removeEventListener("ended",n),e.removeEventListener("timeupdate",l),e.removeEventListener("durationchange",i),e.removeEventListener("progress",a),e.removeEventListener("volumechange",s),e.removeEventListener("loadedmetadata",c),e.removeEventListener("waiting",o),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",h)}},[X,K,G,Y,J,W,se,re,tt,F.length,yt]),a(()=>{const e=()=>{const e=!!document.fullscreenElement;Me(e),Z?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[Z]),a(()=>{const e=oe.current;if(!e)return;const t=()=>{_e(!0),ee?.(!0)},r=()=>{_e(!1),ee?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",r),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",r)}},[ee]),a(()=>{const e=e=>{if(ue.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),it();break;case"m":e.preventDefault(),ut();break;case"f":e.preventDefault(),pt();break;case"ArrowLeft":e.preventDefault(),at(ge-10);break;case"ArrowRight":e.preventDefault(),at(ge+10);break;case"ArrowUp":e.preventDefault(),st(ke+.1);break;case"ArrowDown":e.preventDefault(),st(ke-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[it,ut,pt,at,st,ge,ke]),a(()=>()=>{he.current&&clearTimeout(he.current)},[]),a(()=>{const e=()=>kt();if(Ie.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Ie.visible,kt]),o(s,()=>({play:rt,pause:nt,stop:lt,seek:at,setVolume:st,mute:ct,unmute:ot,toggleMute:ut,enterFullscreen:ht,exitFullscreen:mt,toggleFullscreen:pt,enterPip:vt,exitPip:gt,togglePip:wt,setPlaybackRate:ft,setQuality:xt,getCurrentTime:()=>oe.current?.currentTime||0,getDuration:()=>oe.current?.duration||0,getVolume:()=>oe.current?.volume||0,isMuted:()=>oe.current?.muted??!0,isPlaying:()=>!oe.current?.paused,isFullscreen:()=>Ce,isPip:()=>Pe,getVideoElement:()=>oe.current}),[rt,nt,lt,at,st,ct,ot,ut,ht,mt,pt,vt,gt,wt,ft,xt,Ce,Pe]);const _t=fe?ge/fe*100:0;return e("div",{ref:ue,className:`relative bg-black overflow-hidden select-none ${Ce?"fixed inset-0 z-[9999]":""} ${x}`,style:{width:g,aspectRatio:Ce?"unset":"16/9","--accent":L,...y},onMouseMove:Mt,onMouseLeave:()=>pe&&Fe(!1),onContextMenu:bt,tabIndex:0,children:[t("video",{ref:oe,className:"w-full h-full object-contain",src:Xe,poster:Ke,autoPlay:h,muted:m,loop:Re,preload:V,playsInline:!0,onClick:Pt,children:P.map((e,r)=>t("track",{kind:e.kind,src:e.src,srcLang:e.srclang,label:e.label,default:e.default},r))}),Le&&!Ae&&t("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:t("div",{className:"w-12 h-12 border-4 border-transparent rounded-full animate-spin",style:{borderTopColor:L}})}),Ae&&e("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/90 text-white",children:[t("svg",{className:"w-16 h-16 mb-4",fill:L,viewBox:"0 0 24 24",children:t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),t("p",{className:"text-lg mb-2",children:"Error loading video"}),t("button",{className:"px-6 py-2 rounded text-black font-medium",style:{backgroundColor:L},onClick:()=>{Se(null),oe.current?.load()},children:"Retry"})]}),Ye&&Ge&&e("div",{className:"absolute inset-0 z-20",children:[e("div",{className:"absolute top-4 left-4 flex items-center gap-3 px-3 py-2 bg-black/70 rounded text-white text-sm",children:[t("span",{className:"px-2 py-0.5 rounded text-xs font-bold",style:{backgroundColor:L,color:"#000"},children:"AD"}),e("span",{children:[f(Je)," remaining"]})]}),t("button",{className:"absolute bottom-20 right-4 px-5 py-2 border border-white rounded text-white "+(We?"hover:bg-white hover:text-black cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:We?Ze:void 0,disabled:!We,children:We?"Skip Ad":`Skip in ${Math.ceil(Je)}s`})]}),Ie.visible&&e("div",{className:"absolute z-50 min-w-[200px] bg-[#1a1a1a]/95 backdrop-blur-md rounded-lg shadow-xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{left:Ie.x,top:Ie.y},onClick:e=>e.stopPropagation(),children:[e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{it(),kt()},children:[t(pe?B:H,{}),t("span",{className:"flex-1 text-left",children:pe?"Pause":"Play"}),t("span",{className:"text-white/50 text-xs",children:"Space"})]}),e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{ut(),kt()},children:[t(Ee?q:R,{}),t("span",{className:"flex-1 text-left",children:Ee?"Unmute":"Mute"}),t("span",{className:"text-white/50 text-xs",children:"M"})]}),t("div",{className:"h-px bg-white/10 my-1"}),e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{dt(),kt()},children:[t(U,{}),t("span",{className:"flex-1 text-left",children:Re?"Disable Loop":"Enable Loop"}),Re&&t("span",{style:{color:L},children:"✓"})]}),e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(He);ft(e[(t+1)%e.length]),kt()},children:[t(Q,{}),e("span",{className:"flex-1 text-left",children:["Speed: ",He,"x"]})]}),t("div",{className:"h-px bg-white/10 my-1"}),b&&document.pictureInPictureEnabled&&e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{wt(),kt()},children:[t(I,{}),t("span",{className:"flex-1 text-left",children:"Picture in Picture"}),t("span",{className:"text-white/50 text-xs",children:"P"})]}),e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{pt(),kt()},children:[t(D,{}),t("span",{className:"flex-1 text-left",children:"Fullscreen"}),t("span",{className:"text-white/50 text-xs",children:"F"})]}),t("div",{className:"h-px bg-white/10 my-1"}),e("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:Nt,children:[t(j,{}),t("span",{className:"flex-1 text-left",children:"Copy Video URL"})]}),t("div",{className:"px-4 py-2 text-[10px] text-white/40 text-center border-t border-white/10",children:"PlexVideo Player © FRAMESET STUDIO"})]}),v&&!Ye&&e("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent p-4 transition-opacity duration-300 "+(Ve?"opacity-100":"opacity-0 pointer-events-none"),children:[e("div",{ref:de,className:"relative h-[6px] bg-white/30 rounded-full mb-4 cursor-pointer group hover:h-[10px] transition-all",onClick:Et,children:[t("div",{className:"absolute top-0 left-0 h-full bg-white/40 rounded-full transition-all",style:{width:`${ye}%`}}),t("div",{className:"absolute top-0 left-0 h-full rounded-full transition-all",style:{width:`${_t}%`,backgroundColor:L}}),t("div",{className:"absolute top-1/2 w-4 h-4 rounded-full scale-0 group-hover:scale-100 transition-transform shadow-lg",style:{left:`${_t}%`,transform:"translate(-50%, -50%)",backgroundColor:L}})]}),e("div",{className:"flex items-center gap-2",children:[t("button",{className:"w-10 h-10 flex items-center justify-center rounded-full hover:bg-white/10 text-white transition-colors",onClick:it,"aria-label":pe?"Pause":"Play",children:t(pe?B:H,{})}),C&&e("div",{className:"flex items-center gap-2 group",children:[t("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:ut,"aria-label":Ee?"Unmute":"Mute",children:t(Ee||0===ke?q:R,{})}),t("input",{type:"range",min:"0",max:"1",step:"0.01",value:Ee?0:ke,onChange:e=>st(parseFloat(e.target.value)),className:"w-0 group-hover:w-20 h-1 rounded-full appearance-none cursor-pointer transition-all overflow-hidden",style:{background:`linear-gradient(to right, ${L} 0%, ${L} ${100*(Ee?0:ke)}%, rgba(255,255,255,0.3) ${100*(Ee?0:ke)}%)`}})]}),e("div",{className:"text-white text-sm font-mono ml-2",children:[f(ge)," / ",f(fe)]}),t("div",{className:"flex-1"}),E&&e("div",{className:"relative",children:[t("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:()=>$e(!De),"aria-label":"Settings",children:t(O,{})}),De&&e("div",{className:"absolute bottom-full right-0 mb-3 min-w-[160px] bg-[#1a1a1a] backdrop-blur-md rounded-lg shadow-2xl overflow-hidden z-[100] border border-white/10",children:[t("div",{className:"px-4 py-2 text-white/60 text-xs font-semibold uppercase tracking-wide border-b border-white/10",children:"Playback Speed"}),z.map(r=>e("button",{className:"w-full px-4 py-2.5 text-left text-sm hover:bg-white/10 transition-colors flex items-center justify-between "+(He===r?"":"text-white"),style:He===r?{color:L}:{},onClick:()=>ft(r),children:[t("span",{children:1===r?"Normal":`${r}x`}),He===r&&t("span",{children:"✓"})]},r))]})]}),b&&document.pictureInPictureEnabled&&t("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:wt,"aria-label":"Picture in Picture",children:t(I,{})}),N&&t("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:pt,"aria-label":Ce?"Exit Fullscreen":"Fullscreen",children:t(Ce?$:D,{})})]})]}),!pe&&!Le&&!Ae&&!Ye&&t("button",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-20 h-20 rounded-full flex items-center justify-center hover:scale-110 transition-transform shadow-2xl",style:{backgroundColor:L},onClick:it,"aria-label":"Play",children:t("svg",{viewBox:"0 0 24 24",fill:"white",className:"w-8 h-8 ml-1",children:t("path",{d:"M8 5v14l11-7z"})})})]})});X.displayName="PlexVideoPlayer";const K=({currentTime:r,duration:s,buffered:c,onSeek:o,thumbnailPreview:u,disabled:d=!1})=>{const h=l(null),[m,p]=n(!1),[v,g]=n(null),[w,x]=n(0),k=y(r,s),N=y(c,s),E=i(e=>{if(!h.current)return 0;const t=h.current.getBoundingClientRect();return b((e-t.left)/t.width,0,1)*s},[s]),z=i(e=>{if(!h.current)return;const t=h.current.getBoundingClientRect(),r="clientX"in e?e.clientX:0,n=b(r-t.left,0,t.width),l=E(r);x(n),g(l),m&&o(l)},[m,E,o]),C=i(e=>{if(d)return;e.preventDefault(),p(!0);const t=E(e.clientX);o(t)},[d,E,o]),M=i(()=>{p(!1)},[]),P=i(e=>{const t=E(e.clientX);g(t)},[E]),_=i(()=>{g(null)},[]);a(()=>{if(m){const e=e=>z(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",M)}}},[m,z,M]);const L=i(e=>{if(d)return;e.preventDefault();const t=e.touches[0],r=E(t.clientX);p(!0),o(r)},[d,E,o]),T=i(e=>{if(!m)return;const t=e.touches[0],r=E(t.clientX);o(r)},[m,E,o]),A=i(()=>{p(!1)},[]);return e("div",{ref:h,className:"plex-video-player__progress-container",onMouseDown:C,onMouseEnter:P,onMouseLeave:_,onMouseMove:e=>z(e.nativeEvent),onTouchStart:L,onTouchMove:T,onTouchEnd:A,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":r,"aria-valuetext":f(r),tabIndex:0,children:[e("div",{className:"plex-video-player__progress",children:[t("div",{className:"plex-video-player__progress-buffered",style:{width:`${N}%`}}),t("div",{className:"plex-video-player__progress-played",style:{width:`${k}%`}}),t("div",{className:"plex-video-player__progress-handle",style:{left:`${k}%`}})]}),u?.enabled&&null!==v&&e("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${w}px`,width:u.width||160,height:u.height||90},children:[u.sprites&&t("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${u.sprites})`,backgroundPosition:G(v,s,u.interval||10,u.width||160,u.height||90),backgroundSize:"cover"}}),t("div",{className:"plex-video-player__thumbnail-time",children:f(v)})]}),null!==v&&!u?.enabled&&t("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${w}px`,width:"auto",height:"auto",padding:"4px 8px"},children:t("span",{style:{color:"white",fontSize:"12px"},children:f(v)})})]})},G=(e,t,r,n,l)=>{const i=Math.floor(e/r);return`-${i%10*n}px -${Math.floor(i/10)*l}px`},Y=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M8 5v14l11-7z"})}),J=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),W=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),Z=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"})}),ee=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),te=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),re=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),ne=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),le=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),ie=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14zM5 7h8v6H5z"})}),ae=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),se=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"})}),ce=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),oe=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7.5 13h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2zM7.5 9h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2z"})}),ue=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),de=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),he=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),me=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),pe=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),ve=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"})}),ge=({className:e,size:r=24})=>t("svg",{className:e,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),we=({volume:r,muted:n,onVolumeChange:l,onToggleMute:a})=>{const s=i(e=>{const t=parseFloat(e.target.value);l(t)},[l]);return e("div",{className:"plex-video-player__volume-container",children:[t("button",{className:"plex-video-player__btn",onClick:a,"aria-label":n?"Unmute":"Mute",title:n?"Unmute (M)":"Mute (M)",type:"button",children:t(n||0===r?te:r<.33?ee:r<.66?Z:W,{})}),t("div",{className:"plex-video-player__volume-slider-container",children:t("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:n?0:r,onChange:s,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(n?0:r)}%, var(--plex-progress-bg) ${100*(n?0:r)}%, var(--plex-progress-bg) 100%)`}})})]})},fe=({playbackRate:s,playbackSpeeds:c,onPlaybackRateChange:o,qualityEnabled:u,sources:d,currentQuality:h,onQualityChange:m,captionsEnabled:p,textTracks:v,currentTrack:g,onTrackChange:w})=>{const[f,x]=n(!1),[y,b]=n("main"),k=l(null);a(()=>{const e=e=>{k.current&&!k.current.contains(e.target)&&(x(!1),b("main"))};if(f)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]);const N=i(()=>{x(e=>!e),b("main")},[]),E=i(e=>{o(e),b("main")},[o]),z=i(e=>{m?.(e),b("main")},[m]),C=i(e=>{w?.(e),b("main")},[w]);return e("div",{className:"plex-video-player__settings-container",ref:k,children:[t("button",{className:"plex-video-player__btn",onClick:N,"aria-label":"Settings","aria-expanded":f,title:"Settings",type:"button",children:t(ae,{})}),f&&e("div",{className:"plex-video-player__settings-menu "+(f?"plex-video-player__settings-menu--open":""),children:["main"===y&&e(r,{children:[t("div",{className:"plex-video-player__settings-title",children:"Settings"}),e("button",{className:"plex-video-player__settings-item",onClick:()=>b("speed"),type:"button",children:[t("span",{children:"Playback Speed"}),t("span",{children:1===s?"Normal":`${s}x`})]}),u&&d&&d.length>1&&e("button",{className:"plex-video-player__settings-item",onClick:()=>b("quality"),type:"button",children:[t("span",{children:"Quality"}),t("span",{children:h||"Auto"})]}),p&&v&&v.length>0&&e("button",{className:"plex-video-player__settings-item",onClick:()=>b("captions"),type:"button",children:[t("span",{children:"Captions"}),t("span",{children:g||"Off"})]})]}),"speed"===y&&e(r,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Playback Speed"}),t("div",{className:"plex-video-player__speed-menu",children:c.map(e=>t("button",{className:"plex-video-player__speed-btn "+(s===e?"plex-video-player__speed-btn--active":""),onClick:()=>E(e),type:"button",children:1===e?"Normal":`${e}x`},e))})]}),"quality"===y&&e(r,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Quality"}),t("div",{className:"plex-video-player__quality-menu",children:d?.map(r=>e("button",{className:"plex-video-player__settings-item "+(h===r.quality?"plex-video-player__settings-item--active":""),onClick:()=>z(r.quality||r.src),type:"button",children:[t("span",{children:r.label||r.quality||"Unknown"}),h===r.quality&&t(ge,{size:16})]},r.quality||r.src))})]}),"captions"===y&&e(r,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>b("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Captions"}),e("div",{className:"plex-video-player__quality-menu",children:[e("button",{className:"plex-video-player__settings-item "+(g?"":"plex-video-player__settings-item--active"),onClick:()=>C(null),type:"button",children:[t("span",{children:"Off"}),!g&&t(ge,{size:16})]}),v?.map(r=>e("button",{className:"plex-video-player__settings-item "+(g===r.srclang?"plex-video-player__settings-item--active":""),onClick:()=>C(r.srclang),type:"button",children:[t("span",{children:r.label}),g===r.srclang&&t(ge,{size:16})]},r.srclang))]})]})]})]})},xe=({ad:r,timeRemaining:n,canSkip:l,onSkip:i,onClick:a})=>{const s=l?"Skip Ad":`Skip in ${Math.ceil(n)}s`;return e("div",{className:"plex-video-player__ad-overlay",onClick:a,children:[e("div",{className:"plex-video-player__ad-info",children:[t("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e("span",{children:[f(n)," remaining"]})]}),r.clickThrough&&e("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),a()},type:"button",children:[t(ve,{size:16}),"Learn More"]}),t("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),l&&i()},disabled:!l,type:"button",children:s})]})},ye={1:"The video playback was aborted.",2:"A network error occurred while loading the video.",3:"The video format is not supported or cannot be decoded.",4:"The video source is not supported."},be=({error:r,onRetry:n})=>{const l=r?.code||0,i=ye[l]||"An unknown error occurred.";return e("div",{className:"plex-video-player__error",children:[t(pe,{className:"plex-video-player__error-icon",size:60}),t("div",{className:"plex-video-player__error-message",children:i}),l>0&&e("div",{className:"plex-video-player__error-code",children:["Error Code: ",l]}),t("button",{className:"plex-video-player__error-retry",onClick:n,type:"button",children:"Try Again"})]})},ke=({visible:e})=>e?t("div",{className:"plex-video-player__loader",children:t("div",{className:"plex-video-player__loader-spinner"})}):null,Ne={isPlaying:!1,isPaused:!0,isEnded:!1,isBuffering:!1,isSeeking:!1,isFullscreen:!1,isPip:!1,isMuted:!1,isAdPlaying:!1,volume:1,currentTime:0,duration:0,buffered:0,playbackRate:1,currentQuality:null,error:null},Ee=(e={})=>{const{autoPlay:t=!1,muted:r=!1,loop:s=!1,volume:c=1,playbackRate:o=1}=e,u=l(null),d=l(null),[h,m]=n({...Ne,volume:c,isMuted:r,playbackRate:o}),p=i(e=>{m(t=>({...t,...e}))},[]),v=i(async()=>{const e=u.current;if(e)try{await e.play(),p({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[p]),g=i(()=>{const e=u.current;e&&(e.pause(),p({isPlaying:!1,isPaused:!0}))},[p]),w=i(()=>{h.isPlaying?g():v()},[h.isPlaying,v,g]),f=i(e=>{const t=u.current;if(!t)return;const r=Math.max(0,Math.min(e,t.duration||0));t.currentTime=r,p({currentTime:r})},[p]),x=i(e=>{const t=u.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,p({volume:r,isMuted:0===r})},[p]),y=i(()=>{const e=u.current;e&&(e.muted=!e.muted,p({isMuted:e.muted}))},[p]),b=i(e=>{const t=u.current;t&&(t.playbackRate=e,p({playbackRate:e}))},[p]),k=i(async()=>{const e=d.current;if(e)try{await M(e),p({isFullscreen:!0})}catch(e){}},[p]),N=i(async()=>{try{await P(),p({isFullscreen:!1})}catch(e){}},[p]),E=i(async()=>{h.isFullscreen?await N():await k()},[h.isFullscreen,k,N]),_=i(async()=>{const e=u.current;if(e&&z())try{await e.requestPictureInPicture(),p({isPip:!0})}catch(e){}},[p]),L=i(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),p({isPip:!1})}catch(e){}},[p]),T=i(async()=>{h.isPip?await L():await _()},[h.isPip,_,L]);return a(()=>{const e=u.current;if(!e)return;e.muted=r,e.volume=c,e.playbackRate=o,e.loop=s;const n={loadedmetadata:()=>{p({duration:e.duration})},timeupdate:()=>{p({currentTime:e.currentTime,buffered:V(e)})},play:()=>{p({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{p({isPlaying:!1,isPaused:!0})},ended:()=>{p({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{p({isBuffering:!0})},canplay:()=>{p({isBuffering:!1})},seeking:()=>{p({isSeeking:!0})},seeked:()=>{p({isSeeking:!1})},volumechange:()=>{p({volume:e.volume,isMuted:e.muted})},ratechange:()=>{p({playbackRate:e.playbackRate})},error:()=>{p({error:e.error})},enterpictureinpicture:()=>{p({isPip:!0})},leavepictureinpicture:()=>{p({isPip:!1})}};return Object.entries(n).forEach(([t,r])=>{e.addEventListener(t,r)}),t&&v(),()=>{Object.entries(n).forEach(([t,r])=>{e.removeEventListener(t,r)})}},[t,r,s,c,o,v,p]),a(()=>{const e=()=>{const e=!!C();p({isFullscreen:e})};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}},[p]),{state:h,videoRef:u,containerRef:d,play:v,pause:g,togglePlay:w,seek:f,setVolume:x,toggleMute:y,setPlaybackRate:b,enterFullscreen:k,exitFullscreen:N,toggleFullscreen:E,enterPip:_,exitPip:L,togglePip:T}},ze={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"},Ce=({enabled:e,hotkeys:t={},onPlay:r,onMute:n,onFullscreen:l,onPip:s,onSeek:c,onVolume:o,containerRef:u})=>{const d={...ze,...t},h=i(t=>{if(!e)return;const i=t.target;if("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)return;const a=u.current;if(!a||!a.contains(document.activeElement))return;switch(t.key){case d.play:case" ":t.preventDefault(),r();break;case d.mute:case"M":t.preventDefault(),n();break;case d.fullscreen:case"F":t.preventDefault(),l();break;case d.pip:case"P":t.preventDefault(),s();break;case d.seekForward:t.preventDefault(),c(t.shiftKey?30:10);break;case d.seekBackward:t.preventDefault(),c(t.shiftKey?-30:-10);break;case d.volumeUp:t.preventDefault(),o(.1);break;case d.volumeDown:t.preventDefault(),o(-.1);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.preventDefault(),c(-1/0)}},[e,d,r,n,l,s,c,o,u]);a(()=>{if(e)return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[e,h])};export{xe as AdOverlay,se as CaptionsIcon,ge as CheckIcon,be as ErrorDisplay,pe as ErrorIcon,ve as ExternalLinkIcon,ue as ForwardIcon,ne as FullscreenExitIcon,re as FullscreenIcon,ke as Loader,J as PauseIcon,ie as PipExitIcon,le as PipIcon,Y as PlayIcon,X as PlexVideoPlayer,K as ProgressBar,oe as QualityIcon,de as RewindIcon,ae as SettingsIcon,fe as SettingsMenu,he as SkipNextIcon,me as SkipPrevIcon,ce as SpeedIcon,we as VolumeControl,W as VolumeHighIcon,ee as VolumeLowIcon,Z as VolumeMediumIcon,te as VolumeMuteIcon,F as canPlayType,b as clamp,g as convertToAdInfo,N as debounce,X as default,_ as detectVideoType,P as exitFullscreen,h as fetchVastAd,p as fireTrackingPixel,v as fireTrackingPixels,f as formatTime,T as generateId,V as getBufferedEnd,C as getFullscreenElement,E as isFullscreenSupported,L as isHlsNativelySupported,A as isMobile,z as isPipSupported,S as isTouchDevice,x as parseTime,u as parseVastXml,y as percentage,M as requestFullscreen,m as selectBestMediaFile,k as throttle,Ce as useKeyboard,Ee as usePlayer,w as useVast};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|