@frameset/plex-player 2.0.5 → 2.0.7

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.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{useState as r,useRef as i,useCallback as l,useEffect as a,forwardRef as o,useMemo as s,useImperativeHandle as c}from"react";const d=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 r=e.getAttribute("id")||"",i=t.querySelector("AdTitle")?.textContent||"",l=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let o,s,c=0;const d=[],p=[],h={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const n=t.querySelector("Duration")?.textContent;n&&(c=u(n));const r=t.getAttribute("skipoffset");r&&(o=u(r));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&p.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 i=t.querySelector("VideoClicks");i&&(s=i.querySelector("ClickThrough")?.textContent?.trim(),i.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&&(h[t]||(h[t]=[]),h[t].push(n))})});const m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),p.length>0&&n.push({id:r,title:i,description:l,duration:c,skipOffset:o,clickThrough:s,clickTracking:d,impressionUrls:m,mediaFiles:p,trackingEvents:h})}),{ads:n}},u=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])},p=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(),r=d(n);if(r.error||0===r.ads.length)return null;const i=r.ads[0];return void 0!==e.skipDelay&&void 0===i.skipOffset&&(i.skipOffset=e.skipDelay),i}catch(e){return null}},h=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,r=t.width*t.height;return n!==r?r-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]},m=e=>{(new Image).src=e},v=e=>{e.forEach(m)},g=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),f=({vastConfig:e,videoRef:t,onAdStart:n,onAdEnd:o,onAdSkip:s,onAdError:c})=>{const[d,u]=r(!1),[m,f]=r(null),[y,b]=r(0),[w,x]=r(!1),k=i(null),z=i(""),E=i(0),C=i(new Set),M=i(null),N=Array.isArray(e)?e:e?[e]:[],S=l(async e=>{const r=t.current;if(r&&!d)try{const t=await p(e);if(!t)return void c?.(new Error("Failed to fetch VAST ad"));const i=h(t.mediaFiles);if(!i)return void c?.(new Error("No compatible media file found"));z.current=r.currentSrc,E.current=r.currentTime,v(t.impressionUrls),k.current=t,f(g(t)),u(!0),b(t.duration),x(void 0===t.skipOffset||0===t.skipOffset),r.src=i.url,r.currentTime=0,await r.play(),t.trackingEvents.start&&v(t.trackingEvents.start),n?.(g(t)),M.current=window.setInterval(()=>{const e=Math.max(0,t.duration-r.currentTime);b(e),t.skipOffset&&r.currentTime>=t.skipOffset&&x(!0);const n=r.currentTime/t.duration*100;n>=25&&t.trackingEvents.firstQuartile&&v(t.trackingEvents.firstQuartile),n>=50&&t.trackingEvents.midpoint&&v(t.trackingEvents.midpoint),n>=75&&t.trackingEvents.thirdQuartile&&v(t.trackingEvents.thirdQuartile)},250);const l=()=>{t.trackingEvents.complete&&v(t.trackingEvents.complete),P()};r.addEventListener("ended",l,{once:!0})}catch(e){c?.(e instanceof Error?e:new Error("Ad playback failed")),P()}},[t,d,n,c]),P=l(()=>{const e=t.current;e&&(M.current&&(clearInterval(M.current),M.current=null),z.current&&(e.src=z.current,e.currentTime=E.current,e.play().catch(()=>{})),u(!1),f(null),b(0),x(!1),k.current=null,o?.())},[t,o]),_=l(()=>{if(!w||!k.current)return;const e=k.current;e.trackingEvents.skip&&v(e.trackingEvents.skip),s?.(),P()},[w,P,s]),L=l(()=>{if(!k.current)return;const e=k.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&v(e.clickTracking)},[]),A=l((e,t)=>{d||0===N.length||N.forEach(n=>{const r=n.position||"preroll",i=`${r}-${n.midrollTime||0}`;if(C.current.has(i))return;let l=!1;switch(r){case"preroll":l=0===e;break;case"midroll":n.midrollTime&&e>=n.midrollTime&&(l=!0);break;case"postroll":l=e>=t-.5}l&&(C.current.add(i),S(n))})},[N,d,S]);return a(()=>()=>{M.current&&clearInterval(M.current)},[]),{isAdPlaying:d,currentAd:m,adTimeRemaining:y,canSkip:w,skipAd:_,handleAdClick:L,checkForAd:A}},y=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${n}:${r.toString().padStart(2,"0")}`},b=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},w=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),x=(e,t,n)=>Math.min(n,Math.max(t,e)),k=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>n=!1,t))}},z=(e,t)=>{let n=null;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}},E=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),C=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,M=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,N=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},S=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},P=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"},_=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),L=()=>`plex-${Math.random().toString(36).substring(2,11)}`,A=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),T=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,V=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)},F=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},R=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M8 5v14l11-7z"})}),I=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),B=()=>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"})}),H=()=>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"})}),q=()=>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"})}),D=()=>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"})}),$=()=>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"})}),X=()=>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"})}),Q=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:20,height:20},children:t("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"})}),W=o((n,o)=>{const{src:d,poster:u,autoPlay:p=!1,muted:h=!1,loop:m=!1,controls:v=!0,width:g="100%",className:b="",style:w={},pip:x=!0,fullscreen:z=!0,playbackSpeed:E=!0,playbackSpeeds:C=[.5,.75,1,1.25,1.5,2],volume:M=!0,initialVolume:N=1,textTracks:S=[],vast:P,accentColor:_="#f5c518",controlsTimeout:L=3e3,doubleClickFullscreen:A=!0,clickToPlay:T=!0,preload:V="metadata",playlist:F=[],onPlay:W,onPause:K,onEnded:Y,onTimeUpdate:G,onProgress:J,onVolumeChange:Z,onFullscreenChange:ee,onPipChange:te,onQualityChange:ne,onError:re,onAdStart:ie,onAdEnd:le,onAdSkip:ae,onAdError:oe,onReady:se,onPlaylistItemChange:ce}=n,de=i(null),ue=i(null),pe=i(null),he=i(null),me=i(0),[ve,ge]=r(!1),[fe,ye]=r(0),[be,we]=r(0),[xe,ke]=r(0),[ze,Ee]=r(h?0:N),[Ce,Me]=r(h),[Ne,Se]=r(!1),[Pe,_e]=r(!1),[Le,Ae]=r(!0),[Te,Ve]=r(null),[Fe,Re]=r(!0),[Ie,Be]=r(1),[He,qe]=r(m),[De,$e]=r(!1),[Oe,Ue]=r(!1),[je,Xe]=r(null),[Qe,We]=r({x:0,y:0,visible:!1}),[Ke,Ye]=r(0),Ge=s(()=>"string"==typeof d?[{src:d,type:"video/mp4"}]:d,[d]),Je=s(()=>F.length>0&&F[Ke]?F[Ke].src:Ge[0]?.src||"",[F,Ke,Ge]),Ze=s(()=>F.length>0&&F[Ke]?.poster?F[Ke].poster:u,[F,Ke,u]),{currentAd:et,isAdPlaying:tt,adTimeRemaining:nt,canSkip:rt,skipAd:it,handleAdClick:lt,checkForAd:at}=f({vastConfig:P,videoRef:de,onAdStart:ie,onAdEnd:le,onAdSkip:ae,onAdError:oe}),ot=l(async()=>{const e=de.current;if(e)try{await e.play()}catch(e){}},[]),st=l(()=>{de.current?.pause()},[]),ct=l(()=>{const e=de.current;e&&(e.pause(),e.currentTime=0)},[]),dt=l(()=>{de.current?.paused?ot():st()},[ot,st]),ut=l(e=>{const t=de.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),pt=l(e=>{const t=de.current;if(!t)return;const n=Math.max(0,Math.min(1,e));t.volume=n,t.muted=0===n,Ee(n),Me(0===n)},[]),ht=l(()=>{de.current&&(de.current.muted=!0,Me(!0))},[]),mt=l(()=>{const e=de.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,Ee(.5)),Me(!1))},[]),vt=l(()=>{de.current?.muted?mt():ht()},[ht,mt]),gt=l(()=>{de.current&&(de.current.loop=!de.current.loop,qe(de.current.loop))},[]),ft=l(async()=>{try{await(ue.current?.requestFullscreen()),Se(!0)}catch(e){}},[]),yt=l(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),Se(!1))}catch(e){}},[]),bt=l(async()=>{document.fullscreenElement?await yt():await ft()},[ft,yt]),wt=l(async()=>{try{await(de.current?.requestPictureInPicture()),_e(!0)}catch(e){}},[]),xt=l(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),_e(!1))}catch(e){}},[]),kt=l(async()=>{document.pictureInPictureElement?await xt():await wt()},[wt,xt]),zt=l(e=>{de.current&&(de.current.playbackRate=e,Be(e),$e(!1))},[]),Et=l(e=>{const t=Ge.find(t=>t.label===e||t.quality===e);if(t&&de.current){const n=de.current,r=!n.paused,i=n.currentTime;n.src=t.src,n.currentTime=i,r&&n.play(),ne?.(e)}},[Ge,ne]),Ct=l(()=>{if(0===F.length)return;const e=(Ke+1)%F.length;Ye(e),ce?.(e,F[e]),setTimeout(()=>ot(),100)},[Ke,F,ce,ot]),Mt=l(e=>{e.preventDefault();const t=ue.current?.getBoundingClientRect();t&&We({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),Nt=l(()=>{We(e=>({...e,visible:!1}))},[]),St=l(()=>{navigator.clipboard.writeText(Je),Nt()},[Je,Nt]),Pt=l(e=>{const t=pe.current?.getBoundingClientRect();if(t&&be){const n=(e.clientX-t.left)/t.width;ut(n*be)}},[be,ut]),_t=l(e=>{const t=pe.current?.getBoundingClientRect();if(t&&be){const n=(e.clientX-t.left)/t.width*be;Xe({time:Math.max(0,Math.min(be,n)),x:e.clientX-t.left})}},[be]),Lt=l(()=>{Xe(null)},[]),At=l(()=>{ve&&!De&&Re(!1)},[ve,De]),Tt=l(()=>{Re(!0),he.current&&clearTimeout(he.current),ve&&(he.current=setTimeout(At,L))},[ve,L,At]),Vt=s(()=>k(Tt,200),[Tt]),Ft=l(()=>{if(Nt(),!T)return;const e=Date.now();A&&e-me.current<300?bt():dt(),me.current=e},[T,A,dt,bt,Nt]);a(()=>{const e=de.current;if(!e)return;const t=()=>{ge(!0),W?.()},n=()=>{ge(!1),K?.()},r=()=>{ge(!1),Y?.(),F.length>0&&Ct()},i=()=>{ye(e.currentTime),G?.(e.currentTime),at(e.currentTime,e.duration)},l=()=>we(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);ke(t/e.duration*100),J?.(t/e.duration*100)}},o=()=>{Ee(e.volume),Me(e.muted),Z?.(e.volume,e.muted)},s=()=>{we(e.duration),Ae(!1),se?.()},c=()=>Ae(!0),d=()=>Ae(!1),u=()=>Ae(!1),p=()=>{Ve(e.error),Ae(!1),re?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",n),e.addEventListener("ended",r),e.addEventListener("timeupdate",i),e.addEventListener("durationchange",l),e.addEventListener("progress",a),e.addEventListener("volumechange",o),e.addEventListener("loadedmetadata",s),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",r),e.removeEventListener("timeupdate",i),e.removeEventListener("durationchange",l),e.removeEventListener("progress",a),e.removeEventListener("volumechange",o),e.removeEventListener("loadedmetadata",s),e.removeEventListener("waiting",c),e.removeEventListener("playing",d),e.removeEventListener("canplay",u),e.removeEventListener("error",p)}},[W,K,Y,G,J,Z,se,re,at,F.length,Ct]),a(()=>{const e=()=>{const e=!!document.fullscreenElement;Se(e),ee?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[ee]),a(()=>{const e=de.current;if(!e)return;const t=()=>{_e(!0),te?.(!0)},n=()=>{_e(!1),te?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",n),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",n)}},[te]),a(()=>{const e=e=>{if(ue.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),dt();break;case"m":e.preventDefault(),vt();break;case"f":e.preventDefault(),bt();break;case"ArrowLeft":e.preventDefault(),ut(fe-10);break;case"ArrowRight":e.preventDefault(),ut(fe+10);break;case"ArrowUp":e.preventDefault(),pt(ze+.1);break;case"ArrowDown":e.preventDefault(),pt(ze-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[dt,vt,bt,ut,pt,fe,ze]),a(()=>()=>{he.current&&clearTimeout(he.current)},[]),a(()=>{const e=()=>Nt();if(Qe.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Qe.visible,Nt]),c(o,()=>({play:ot,pause:st,stop:ct,seek:ut,setVolume:pt,mute:ht,unmute:mt,toggleMute:vt,enterFullscreen:ft,exitFullscreen:yt,toggleFullscreen:bt,enterPip:wt,exitPip:xt,togglePip:kt,setPlaybackRate:zt,setQuality:Et,getCurrentTime:()=>de.current?.currentTime||0,getDuration:()=>de.current?.duration||0,getVolume:()=>de.current?.volume||0,isMuted:()=>de.current?.muted??!0,isPlaying:()=>!de.current?.paused,isFullscreen:()=>Ne,isPip:()=>Pe,getVideoElement:()=>de.current}),[ot,st,ct,ut,pt,ht,mt,vt,ft,yt,bt,wt,xt,kt,zt,Et,Ne,Pe]);const Rt=be?fe/be*100:0;return e("div",{ref:ue,className:b,style:{position:Ne?"fixed":"relative",inset:Ne?0:void 0,zIndex:Ne?9999:void 0,width:g,aspectRatio:Ne?"unset":"16/9",height:Ne?"100%":void 0,backgroundColor:"#000",overflow:"hidden",userSelect:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...w},onMouseMove:Vt,onMouseLeave:()=>ve&&Re(!1),onContextMenu:Mt,tabIndex:0,children:[t("video",{ref:de,style:{width:"100%",height:"100%",objectFit:"contain"},src:Je,poster:Ze,autoPlay:p,muted:h,loop:He,preload:V,playsInline:!0,onClick:Ft,children:S.map((e,n)=>t("track",{kind:e.kind,src:e.src,srcLang:e.srclang,label:e.label,default:e.default},n))}),Le&&!Te&&t("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:t("div",{style:{width:48,height:48,border:"4px solid transparent",borderTopColor:_,borderRadius:"50%",animation:"spin 1s linear infinite"}})}),t("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),Te&&e("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.9)",color:"#fff"},children:[t("svg",{style:{width:64,height:64,marginBottom:16},fill:_,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",{style:{fontSize:18,marginBottom:8},children:"Error loading video"}),t("button",{onClick:()=>{Ve(null),de.current?.load()},style:{padding:"8px 24px",borderRadius:4,border:"none",backgroundColor:_,color:"#000",fontWeight:500,cursor:"pointer"},children:"Retry"})]}),tt&&et&&e("div",{style:{position:"absolute",inset:0,zIndex:20},children:[e("div",{style:{position:"absolute",top:16,left:16,display:"flex",alignItems:"center",gap:12,padding:"8px 12px",background:"rgba(0,0,0,0.7)",borderRadius:4,color:"#fff",fontSize:14},children:[t("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700,backgroundColor:_,color:"#000"},children:"AD"}),e("span",{children:[y(nt)," remaining"]})]}),t("button",{onClick:rt?it:void 0,disabled:!rt,style:{position:"absolute",bottom:80,right:16,padding:"8px 20px",border:"1px solid #fff",borderRadius:4,background:"transparent",color:"#fff",cursor:rt?"pointer":"not-allowed",opacity:rt?1:.5},children:rt?"Skip Ad":`Skip in ${Math.ceil(nt)}s`})]}),Qe.visible&&e("div",{style:{position:"absolute",left:Qe.x,top:Qe.y,zIndex:50,minWidth:200,background:"rgba(26,26,26,0.95)",backdropFilter:"blur(8px)",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",overflow:"hidden"},onClick:e=>e.stopPropagation(),children:[e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{dt(),Nt()},children:[t(ve?I:R,{}),t("span",{style:{flex:1},children:ve?"Pause":"Play"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"Space"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{vt(),Nt()},children:[t(Ce?H:B,{}),t("span",{style:{flex:1},children:Ce?"Unmute":"Mute"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"M"})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{gt(),Nt()},children:[t(U,{}),t("span",{style:{flex:1},children:He?"Disable Loop":"Enable Loop"}),He&&t("span",{style:{color:_},children:"✓"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(Ie);zt(e[(t+1)%e.length]),Nt()},children:[t(X,{}),e("span",{style:{flex:1},children:["Speed: ",Ie,"x"]})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),x&&document.pictureInPictureEnabled&&e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{kt(),Nt()},children:[t($,{}),t("span",{style:{flex:1},children:"Picture in Picture"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"P"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{bt(),Nt()},children:[t(q,{}),t("span",{style:{flex:1},children:"Fullscreen"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"F"})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:St,children:[t(j,{}),t("span",{style:{flex:1},children:"Copy Video URL"})]}),t("div",{style:{padding:"8px 16px",fontSize:10,color:"rgba(255,255,255,0.4)",textAlign:"center",borderTop:"1px solid rgba(255,255,255,0.1)"},children:"PlexVideo Player © FRAMESET STUDIO"})]}),v&&!tt&&e("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",padding:16,transition:"opacity 0.3s",opacity:Fe?1:0,pointerEvents:Fe?"auto":"none"},children:[e("div",{ref:pe,onClick:Pt,onMouseMove:_t,onMouseLeave:Lt,style:{position:"relative",height:8,background:"rgba(255,255,255,0.3)",borderRadius:4,marginBottom:16,cursor:"pointer"},children:[t("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${xe}%`,background:"rgba(255,255,255,0.5)",borderRadius:4}}),t("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${Rt}%`,background:_,borderRadius:4}}),t("div",{style:{position:"absolute",top:"50%",left:`${Rt}%`,transform:"translate(-50%, -50%)",width:16,height:16,borderRadius:"50%",background:_,boxShadow:"0 2px 8px rgba(0,0,0,0.5)"}}),je&&t("div",{style:{position:"absolute",bottom:"100%",left:je.x,transform:"translateX(-50%)",marginBottom:8,padding:"4px 8px",background:"rgba(0,0,0,0.9)",color:"#fff",fontSize:12,borderRadius:4,whiteSpace:"nowrap",pointerEvents:"none"},children:y(je.time)})]}),e("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t("button",{onClick:dt,"aria-label":ve?"Pause":"Play",style:{width:44,height:44,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"transparent",border:"none",color:"#fff",cursor:"pointer"},children:t(ve?I:R,{})}),M&&e("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t("button",{onClick:vt,"aria-label":Ce?"Unmute":"Mute",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer"},children:t(Ce||0===ze?H:B,{})}),t("input",{type:"range",min:"0",max:"1",step:"0.01",value:Ce?0:ze,onChange:e=>pt(parseFloat(e.target.value)),style:{width:70,height:4,cursor:"pointer",accentColor:_}})]}),e("div",{style:{color:"#fff",fontSize:13,fontFamily:"monospace",marginLeft:8},children:[y(fe)," / ",y(be)]}),t("div",{style:{flex:1}}),F.length>0&&e("div",{style:{position:"relative"},children:[t("button",{onClick:()=>Ue(!Oe),"aria-label":"Playlist",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:Oe?"rgba(255,255,255,0.2)":"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:t(Q,{})}),Oe&&e("div",{style:{position:"absolute",bottom:48,right:0,width:280,maxHeight:300,overflowY:"auto",background:"#1a1a1a",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",border:"1px solid rgba(255,255,255,0.1)",zIndex:100},children:[e("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",fontSize:12,fontWeight:600,textTransform:"uppercase"},children:["Playlist (",F.length," items)"]}),F.map((n,r)=>e("button",{onClick:()=>{Ye(r),ce?.(r,n),Ue(!1),setTimeout(()=>ot(),100)},style:{width:"100%",padding:"10px 16px",display:"flex",alignItems:"center",gap:12,background:Ke===r?"rgba(255,255,255,0.1)":"transparent",border:"none",color:Ke===r?_:"#fff",cursor:"pointer",textAlign:"left",fontSize:14},children:[t("span",{style:{width:24,color:"rgba(255,255,255,0.5)"},children:r+1}),t("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.title}),Ke===r&&t("span",{children:"▶"})]},n.id))]})]}),E&&e("div",{style:{position:"relative"},children:[t("button",{onClick:()=>$e(!De),"aria-label":"Settings",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:De?"rgba(255,255,255,0.2)":"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:t(O,{})}),De&&e("div",{style:{position:"absolute",bottom:48,right:0,minWidth:160,background:"#1a1a1a",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",border:"1px solid rgba(255,255,255,0.1)",zIndex:100,overflow:"hidden"},children:[t("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:"Playback Speed"}),C.map(n=>e("button",{onClick:()=>zt(n),style:{width:"100%",padding:"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",background:"transparent",border:"none",color:Ie===n?_:"#fff",cursor:"pointer",fontSize:14},children:[t("span",{children:1===n?"Normal":`${n}x`}),Ie===n&&t("span",{children:"✓"})]},n))]})]}),x&&document.pictureInPictureEnabled&&t("button",{onClick:kt,"aria-label":"Picture in Picture",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:t($,{})}),z&&t("button",{onClick:bt,"aria-label":Ne?"Exit Fullscreen":"Fullscreen",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:t(Ne?D:q,{})})]})]}),!ve&&!Le&&!Te&&!tt&&t("button",{onClick:dt,"aria-label":"Play",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:80,height:80,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",backgroundColor:_,boxShadow:"0 8px 32px rgba(0,0,0,0.4)",transition:"transform 0.2s"},children:t("svg",{viewBox:"0 0 24 24",fill:"white",style:{width:32,height:32,marginLeft:4},children:t("path",{d:"M8 5v14l11-7z"})})})]})});W.displayName="PlexVideoPlayer";const K=({currentTime:n,duration:o,buffered:s,onSeek:c,thumbnailPreview:d,disabled:u=!1})=>{const p=i(null),[h,m]=r(!1),[v,g]=r(null),[f,b]=r(0),k=w(n,o),z=w(s,o),E=l(e=>{if(!p.current)return 0;const t=p.current.getBoundingClientRect();return x((e-t.left)/t.width,0,1)*o},[o]),C=l(e=>{if(!p.current)return;const t=p.current.getBoundingClientRect(),n="clientX"in e?e.clientX:0,r=x(n-t.left,0,t.width),i=E(n);b(r),g(i),h&&c(i)},[h,E,c]),M=l(e=>{if(u)return;e.preventDefault(),m(!0);const t=E(e.clientX);c(t)},[u,E,c]),N=l(()=>{m(!1)},[]),S=l(e=>{const t=E(e.clientX);g(t)},[E]),P=l(()=>{g(null)},[]);a(()=>{if(h){const e=e=>C(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",N)}}},[h,C,N]);const _=l(e=>{if(u)return;e.preventDefault();const t=e.touches[0],n=E(t.clientX);m(!0),c(n)},[u,E,c]),L=l(e=>{if(!h)return;const t=e.touches[0],n=E(t.clientX);c(n)},[h,E,c]),A=l(()=>{m(!1)},[]);return e("div",{ref:p,className:"plex-video-player__progress-container",onMouseDown:M,onMouseEnter:S,onMouseLeave:P,onMouseMove:e=>C(e.nativeEvent),onTouchStart:_,onTouchMove:L,onTouchEnd:A,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":n,"aria-valuetext":y(n),tabIndex:0,children:[e("div",{className:"plex-video-player__progress",children:[t("div",{className:"plex-video-player__progress-buffered",style:{width:`${z}%`}}),t("div",{className:"plex-video-player__progress-played",style:{width:`${k}%`}}),t("div",{className:"plex-video-player__progress-handle",style:{left:`${k}%`}})]}),d?.enabled&&null!==v&&e("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${f}px`,width:d.width||160,height:d.height||90},children:[d.sprites&&t("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${d.sprites})`,backgroundPosition:Y(v,o,d.interval||10,d.width||160,d.height||90),backgroundSize:"cover"}}),t("div",{className:"plex-video-player__thumbnail-time",children:y(v)})]}),null!==v&&!d?.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:y(v)})})]})},Y=(e,t,n,r,i)=>{const l=Math.floor(e/n);return`-${l%10*r}px -${Math.floor(l/10)*i}px`},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:"M8 5v14l11-7z"})}),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 19h4V5H6v14zm8-14v14h4V5h-4z"})}),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:"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"})}),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:"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"})}),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:"M7 9v6h4l5 5V4l-5 5H7z"})}),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:"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: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"})}),ie=({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"})}),le=({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"})}),ae=({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"})}),oe=({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"})}),se=({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"})}),ce=({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"})}),de=({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"})}),ue=({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"})}),pe=({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"})}),he=({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"})}),me=({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"})}),ve=({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"})}),ge=({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"})}),fe=({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"})}),ye=({volume:n,muted:r,onVolumeChange:i,onToggleMute:a})=>{const o=l(e=>{const t=parseFloat(e.target.value);i(t)},[i]);return e("div",{className:"plex-video-player__volume-container",children:[t("button",{className:"plex-video-player__btn",onClick:a,"aria-label":r?"Unmute":"Mute",title:r?"Unmute (M)":"Mute (M)",type:"button",children:t(r||0===n?ne:n<.33?te:n<.66?ee:Z,{})}),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:r?0:n,onChange:o,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(r?0:n)}%, var(--plex-progress-bg) ${100*(r?0:n)}%, var(--plex-progress-bg) 100%)`}})})]})},be=({playbackRate:o,playbackSpeeds:s,onPlaybackRateChange:c,qualityEnabled:d,sources:u,currentQuality:p,onQualityChange:h,captionsEnabled:m,textTracks:v,currentTrack:g,onTrackChange:f})=>{const[y,b]=r(!1),[w,x]=r("main"),k=i(null);a(()=>{const e=e=>{k.current&&!k.current.contains(e.target)&&(b(!1),x("main"))};if(y)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[y]);const z=l(()=>{b(e=>!e),x("main")},[]),E=l(e=>{c(e),x("main")},[c]),C=l(e=>{h?.(e),x("main")},[h]),M=l(e=>{f?.(e),x("main")},[f]);return e("div",{className:"plex-video-player__settings-container",ref:k,children:[t("button",{className:"plex-video-player__btn",onClick:z,"aria-label":"Settings","aria-expanded":y,title:"Settings",type:"button",children:t(oe,{})}),y&&e("div",{className:"plex-video-player__settings-menu "+(y?"plex-video-player__settings-menu--open":""),children:["main"===w&&e(n,{children:[t("div",{className:"plex-video-player__settings-title",children:"Settings"}),e("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[t("span",{children:"Playback Speed"}),t("span",{children:1===o?"Normal":`${o}x`})]}),d&&u&&u.length>1&&e("button",{className:"plex-video-player__settings-item",onClick:()=>x("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:()=>x("captions"),type:"button",children:[t("span",{children:"Captions"}),t("span",{children:g||"Off"})]})]}),"speed"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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:s.map(e=>t("button",{className:"plex-video-player__speed-btn "+(o===e?"plex-video-player__speed-btn--active":""),onClick:()=>E(e),type:"button",children:1===e?"Normal":`${e}x`},e))})]}),"quality"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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:()=>C(n.quality||n.src),type:"button",children:[t("span",{children:n.label||n.quality||"Unknown"}),p===n.quality&&t(fe,{size:16})]},n.quality||n.src))})]}),"captions"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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:()=>M(null),type:"button",children:[t("span",{children:"Off"}),!g&&t(fe,{size:16})]}),v?.map(n=>e("button",{className:"plex-video-player__settings-item "+(g===n.srclang?"plex-video-player__settings-item--active":""),onClick:()=>M(n.srclang),type:"button",children:[t("span",{children:n.label}),g===n.srclang&&t(fe,{size:16})]},n.srclang))]})]})]})]})},we=({ad:n,timeRemaining:r,canSkip:i,onSkip:l,onClick:a})=>{const o=i?"Skip Ad":`Skip in ${Math.ceil(r)}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:[y(r)," remaining"]})]}),n.clickThrough&&e("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),a()},type:"button",children:[t(ge,{size:16}),"Learn More"]}),t("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),i&&l()},disabled:!i,type:"button",children:o})]})},xe={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."},ke=({error:n,onRetry:r})=>{const i=n?.code||0,l=xe[i]||"An unknown error occurred.";return e("div",{className:"plex-video-player__error",children:[t(ve,{className:"plex-video-player__error-icon",size:60}),t("div",{className:"plex-video-player__error-message",children:l}),i>0&&e("div",{className:"plex-video-player__error-code",children:["Error Code: ",i]}),t("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},ze=({visible:e})=>e?t("div",{className:"plex-video-player__loader",children:t("div",{className:"plex-video-player__loader-spinner"})}):null,Ee={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},Ce=(e={})=>{const{autoPlay:t=!1,muted:n=!1,loop:o=!1,volume:s=1,playbackRate:c=1}=e,d=i(null),u=i(null),[p,h]=r({...Ee,volume:s,isMuted:n,playbackRate:c}),m=l(e=>{h(t=>({...t,...e}))},[]),v=l(async()=>{const e=d.current;if(e)try{await e.play(),m({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[m]),g=l(()=>{const e=d.current;e&&(e.pause(),m({isPlaying:!1,isPaused:!0}))},[m]),f=l(()=>{p.isPlaying?g():v()},[p.isPlaying,v,g]),y=l(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]),b=l(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]),w=l(()=>{const e=d.current;e&&(e.muted=!e.muted,m({isMuted:e.muted}))},[m]),x=l(e=>{const t=d.current;t&&(t.playbackRate=e,m({playbackRate:e}))},[m]),k=l(async()=>{const e=u.current;if(e)try{await N(e),m({isFullscreen:!0})}catch(e){}},[m]),z=l(async()=>{try{await S(),m({isFullscreen:!1})}catch(e){}},[m]),E=l(async()=>{p.isFullscreen?await z():await k()},[p.isFullscreen,k,z]),P=l(async()=>{const e=d.current;if(e&&C())try{await e.requestPictureInPicture(),m({isPip:!0})}catch(e){}},[m]),_=l(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),m({isPip:!1})}catch(e){}},[m]),L=l(async()=>{p.isPip?await _():await P()},[p.isPip,P,_]);return a(()=>{const e=d.current;if(!e)return;e.muted=n,e.volume=s,e.playbackRate=c,e.loop=o;const r={loadedmetadata:()=>{m({duration:e.duration})},timeupdate:()=>{m({currentTime:e.currentTime,buffered:V(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(r).forEach(([t,n])=>{e.addEventListener(t,n)}),t&&v(),()=>{Object.entries(r).forEach(([t,n])=>{e.removeEventListener(t,n)})}},[t,n,o,s,c,v,m]),a(()=>{const e=()=>{const e=!!M();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:f,seek:y,setVolume:b,toggleMute:w,setPlaybackRate:x,enterFullscreen:k,exitFullscreen:z,toggleFullscreen:E,enterPip:P,exitPip:_,togglePip:L}},Me={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"},Ne=({enabled:e,hotkeys:t={},onPlay:n,onMute:r,onFullscreen:i,onPip:o,onSeek:s,onVolume:c,containerRef:d})=>{const u={...Me,...t},p=l(t=>{if(!e)return;const l=t.target;if("INPUT"===l.tagName||"TEXTAREA"===l.tagName||l.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(),r();break;case u.fullscreen:case"F":t.preventDefault(),i();break;case u.pip:case"P":t.preventDefault(),o();break;case u.seekForward:t.preventDefault(),s(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),s(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(),s(-1/0)}},[e,u,n,r,i,o,s,c,d]);a(()=>{if(e)return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[e,p])};export{we as AdOverlay,se as CaptionsIcon,fe as CheckIcon,ke as ErrorDisplay,ve as ErrorIcon,ge as ExternalLinkIcon,ue as ForwardIcon,ie as FullscreenExitIcon,re as FullscreenIcon,ze as Loader,J as PauseIcon,ae as PipExitIcon,le as PipIcon,G as PlayIcon,W as PlexVideoPlayer,K as ProgressBar,de as QualityIcon,pe as RewindIcon,oe as SettingsIcon,be as SettingsMenu,he as SkipNextIcon,me as SkipPrevIcon,ce as SpeedIcon,ye as VolumeControl,Z as VolumeHighIcon,te as VolumeLowIcon,ee as VolumeMediumIcon,ne as VolumeMuteIcon,F as canPlayType,x as clamp,g as convertToAdInfo,z as debounce,W as default,P as detectVideoType,S as exitFullscreen,p as fetchVastAd,m as fireTrackingPixel,v as fireTrackingPixels,y as formatTime,L as generateId,V as getBufferedEnd,M as getFullscreenElement,E as isFullscreenSupported,_ as isHlsNativelySupported,A as isMobile,C as isPipSupported,T as isTouchDevice,b as parseTime,d as parseVastXml,w as percentage,N as requestFullscreen,h as selectBestMediaFile,k as throttle,Ne as useKeyboard,Ce as usePlayer,f as useVast};
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{useState as r,useRef as i,useCallback as l,useEffect as a,forwardRef as o,useMemo as s,useImperativeHandle as c}from"react";const d=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 r=e.getAttribute("id")||"",i=t.querySelector("AdTitle")?.textContent||"",l=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let o,s,c=0;const d=[],h=[],p={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const n=t.querySelector("Duration")?.textContent;n&&(c=u(n));const r=t.getAttribute("skipoffset");r&&(o=u(r));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 i=t.querySelector("VideoClicks");i&&(s=i.querySelector("ClickThrough")?.textContent?.trim(),i.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 m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),h.length>0&&n.push({id:r,title:i,description:l,duration:c,skipOffset:o,clickThrough:s,clickTracking:d,impressionUrls:m,mediaFiles:h,trackingEvents:p})}),{ads:n}},u=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 n=await t.text(),r=d(n);if(r.error||0===r.ads.length)return null;const i=r.ads[0];return void 0!==e.skipDelay&&void 0===i.skipOffset&&(i.skipOffset=e.skipDelay),i}catch(e){return null}},p=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,r=t.width*t.height;return n!==r?r-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]},m=e=>{(new Image).src=e},v=e=>{e.forEach(m)},g=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),f=({vastConfig:e,videoRef:t,onAdStart:n,onAdEnd:o,onAdSkip:s,onAdError:c})=>{const[d,u]=r(!1),[m,f]=r(null),[b,y]=r(0),[w,x]=r(!1),k=i(null),z=i(""),C=i(0),E=i(new Set),M=i(null),S=Array.isArray(e)?e:e?[e]:[],N=l(async e=>{const r=t.current;if(r&&!d)try{const t=await h(e);if(!t)return void c?.(new Error("Failed to fetch VAST ad"));const i=p(t.mediaFiles);if(!i)return void c?.(new Error("No compatible media file found"));z.current=r.currentSrc,C.current=r.currentTime,v(t.impressionUrls),k.current=t,f(g(t)),u(!0),y(t.duration),x(void 0===t.skipOffset||0===t.skipOffset),r.src=i.url,r.currentTime=0,await r.play(),t.trackingEvents.start&&v(t.trackingEvents.start),n?.(g(t)),M.current=window.setInterval(()=>{const e=Math.max(0,t.duration-r.currentTime);y(e),t.skipOffset&&r.currentTime>=t.skipOffset&&x(!0);const n=r.currentTime/t.duration*100;n>=25&&t.trackingEvents.firstQuartile&&v(t.trackingEvents.firstQuartile),n>=50&&t.trackingEvents.midpoint&&v(t.trackingEvents.midpoint),n>=75&&t.trackingEvents.thirdQuartile&&v(t.trackingEvents.thirdQuartile)},250);const l=()=>{t.trackingEvents.complete&&v(t.trackingEvents.complete),P()};r.addEventListener("ended",l,{once:!0})}catch(e){c?.(e instanceof Error?e:new Error("Ad playback failed")),P()}},[t,d,n,c]),P=l(()=>{const e=t.current;e&&(M.current&&(clearInterval(M.current),M.current=null),z.current&&(e.src=z.current,e.currentTime=C.current,e.play().catch(()=>{})),u(!1),f(null),y(0),x(!1),k.current=null,o?.())},[t,o]),L=l(()=>{if(!w||!k.current)return;const e=k.current;e.trackingEvents.skip&&v(e.trackingEvents.skip),s?.(),P()},[w,P,s]),_=l(()=>{if(!k.current)return;const e=k.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&v(e.clickTracking)},[]),T=l((e,t)=>{d||0===S.length||S.forEach(n=>{const r=n.position||"preroll",i=`${r}-${n.midrollTime||0}`;if(E.current.has(i))return;let l=!1;switch(r){case"preroll":l=0===e;break;case"midroll":n.midrollTime&&e>=n.midrollTime&&(l=!0);break;case"postroll":l=e>=t-.5}l&&(E.current.add(i),N(n))})},[S,d,N]);return a(()=>()=>{M.current&&clearInterval(M.current)},[]),{isAdPlaying:d,currentAd:m,adTimeRemaining:b,canSkip:w,skipAd:L,handleAdClick:_,checkForAd:T}},b=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${n}:${r.toString().padStart(2,"0")}`},y=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},w=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),x=(e,t,n)=>Math.min(n,Math.max(t,e)),k=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>n=!1,t))}},z=(e,t)=>{let n=null;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}},C=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),E=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,M=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,S=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},N=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},P=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"),_=()=>`plex-${Math.random().toString(36).substring(2,11)}`,T=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),A=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,R=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)},V=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},F=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M8 5v14l11-7z"})}),I=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:t("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),B=()=>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"})}),H=()=>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"})}),q=()=>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"})}),$=()=>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"})}),j=()=>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"})}),W=()=>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"})}),X=()=>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"})}),O=()=>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"})}),U=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:20,height:20},children:t("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"})}),Q=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:20,height:20},children:t("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v3h2V5h18v14h-7v2h7c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM1 18v3h3c0-1.66-1.34-3-3-3zm0-4v2c2.76 0 5 2.24 5 5h2c0-3.87-3.13-7-7-7zm0-4v2c4.97 0 9 4.03 9 9h2c0-6.08-4.93-11-11-11z"})}),Y=()=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:20,height:20},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"})}),K=o((n,o)=>{const{src:d,poster:u,autoPlay:h=!1,muted:p=!1,loop:m=!1,controls:v=!0,width:g="100%",className:y="",style:w={},pip:x=!0,fullscreen:z=!0,playbackSpeed:C=!0,playbackSpeeds:E=[.5,.75,1,1.25,1.5,2],volume:M=!0,initialVolume:S=1,textTracks:N=[],vast:P,accentColor:L="#f5c518",controlsTimeout:_=3e3,doubleClickFullscreen:T=!0,clickToPlay:A=!0,preload:R="metadata",playlist:V=[],onPlay:K,onPause:G,onEnded:J,onTimeUpdate:Z,onProgress:ee,onVolumeChange:te,onFullscreenChange:ne,onPipChange:re,onQualityChange:ie,onError:le,onAdStart:ae,onAdEnd:oe,onAdSkip:se,onAdError:ce,onReady:de,onPlaylistItemChange:ue}=n,he=i(null),pe=i(null),me=i(null),ve=i(null),ge=i(0),[fe,be]=r(!1),[ye,we]=r(0),[xe,ke]=r(0),[ze,Ce]=r(0),[Ee,Me]=r(p?0:S),[Se,Ne]=r(p),[Pe,Le]=r(!1),[_e,Te]=r(!1),[Ae,Re]=r(!0),[Ve,Fe]=r(null),[Ie,Be]=r(!0),[He,De]=r(1),[qe,$e]=r(m),[je,We]=r(!1),[Xe,Oe]=r(!1),[Ue,Qe]=r(null),[Ye,Ke]=r(null),[Ge,Je]=r(!1),[Ze,et]=r(!1),tt=i(null),nt=i(null),rt=i(null);a(()=>{const e=()=>{const e=window.matchMedia("(max-width: 768px)").matches||window.matchMedia("(pointer: coarse)").matches||"ontouchstart"in window;Je(e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[it,lt]=r({x:0,y:0,visible:!1}),[at,ot]=r(0),st=s(()=>"string"==typeof d?[{src:d,type:"video/mp4"}]:d,[d]),ct=s(()=>V.length>0&&V[at]?V[at].src:st[0]?.src||"",[V,at,st]),dt=s(()=>V.length>0&&V[at]?.poster?V[at].poster:u,[V,at,u]),{currentAd:ut,isAdPlaying:ht,adTimeRemaining:pt,canSkip:mt,skipAd:vt,handleAdClick:gt,checkForAd:ft}=f({vastConfig:P,videoRef:he,onAdStart:ae,onAdEnd:oe,onAdSkip:se,onAdError:ce}),bt=l(async()=>{const e=he.current;if(e)try{await e.play()}catch(e){}},[]),yt=l(()=>{he.current?.pause()},[]),wt=l(()=>{const e=he.current;e&&(e.pause(),e.currentTime=0)},[]),xt=l(()=>{he.current?.paused?bt():yt()},[bt,yt]),kt=l(e=>{const t=he.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),zt=l(e=>{const t=he.current;if(!t)return;const n=Math.max(0,Math.min(1,e));t.volume=n,t.muted=0===n,Me(n),Ne(0===n)},[]),Ct=l(()=>{he.current&&(he.current.muted=!0,Ne(!0))},[]),Et=l(()=>{const e=he.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,Me(.5)),Ne(!1))},[]),Mt=l(()=>{he.current?.muted?Et():Ct()},[Ct,Et]),St=l(()=>{he.current&&(he.current.loop=!he.current.loop,$e(he.current.loop))},[]),Nt=l(async()=>{try{await(pe.current?.requestFullscreen()),Le(!0)}catch(e){}},[]),Pt=l(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),Le(!1))}catch(e){}},[]),Lt=l(async()=>{document.fullscreenElement?await Pt():await Nt()},[Nt,Pt]),_t=l(async()=>{try{await(he.current?.requestPictureInPicture()),Te(!0)}catch(e){}},[]),Tt=l(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),Te(!1))}catch(e){}},[]),At=l(async()=>{document.pictureInPictureElement?await Tt():await _t()},[_t,Tt]),Rt=l(e=>{he.current&&(he.current.playbackRate=e,De(e),We(!1))},[]),Vt=l(e=>{const t=st.find(t=>t.label===e||t.quality===e);if(t&&he.current){const n=he.current,r=!n.paused,i=n.currentTime;n.src=t.src,n.currentTime=i,r&&n.play(),ie?.(e)}},[st,ie]),Ft=l(()=>{if(0===V.length)return;const e=(at+1)%V.length;ot(e),ue?.(e,V[e]),setTimeout(()=>bt(),100)},[at,V,ue,bt]),It=l(e=>{e.preventDefault();const t=pe.current?.getBoundingClientRect();t&&lt({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),Bt=l(()=>{lt(e=>({...e,visible:!1}))},[]),Ht=l(()=>{navigator.clipboard.writeText(ct),Bt()},[ct,Bt]),Dt=l(e=>{const t=me.current?.getBoundingClientRect();if(t&&xe){const n=(e.clientX-t.left)/t.width;kt(n*xe)}},[xe,kt]),qt=l(e=>{const t=me.current?.getBoundingClientRect();if(t&&xe){const n=(e.clientX-t.left)/t.width,r=Math.max(0,Math.min(xe,n*xe));if(Qe({time:r,x:e.clientX-t.left}),rt.current&&nt.current){const e=rt.current,t=nt.current,n=t.getContext("2d");Math.abs(e.currentTime-r)>1&&(e.currentTime=r),e.onseeked=()=>{n&&(t.width=160,t.height=90,n.drawImage(e,0,0,160,90),Ke(t.toDataURL("image/jpeg",.5)))}}}},[xe]),$t=l(()=>{Qe(null),Ke(null)},[]),jt=l(()=>{!fe||je||Xe||Be(!1)},[fe,je,Xe]),Wt=l(()=>{Be(!0),ve.current&&clearTimeout(ve.current),fe&&(ve.current=setTimeout(jt,Ge?4e3:_))},[fe,_,jt,Ge]),Xt=s(()=>k(Wt,200),[Wt]),Ot=l(e=>{const t=e.touches[0];tt.current={x:t.clientX,y:t.clientY,time:Date.now()},et(!0),Wt()},[Wt]),Ut=l(e=>{if(!tt.current)return;const t=e.touches[0],n=t.clientX-tt.current.x,r=t.clientY-tt.current.y;if(Math.abs(n)>2*Math.abs(r)&&Math.abs(n)>30){e.preventDefault();const r=n/window.innerWidth*xe*.5,i=Math.max(0,Math.min(xe,ye+r));Qe({time:i,x:t.clientX})}},[xe,ye]),Qt=l(e=>{if(!tt.current)return;const t=Date.now()-tt.current.time,n=e.changedTouches[0],r=n.clientX-tt.current.x,i=n.clientY-tt.current.y;if(t<200&&Math.abs(r)<10&&Math.abs(i)<10)Ie?xt():Wt();else if(Math.abs(r)>2*Math.abs(i)&&Math.abs(r)>50){const e=r/window.innerWidth*xe*.5;kt(ye+e)}else if(t<300){const e=pe.current?.getBoundingClientRect();if(e){const t=n.clientX-e.left;t<.3*e.width?kt(ye-10):t>.7*e.width&&kt(ye+10)}}tt.current=null,et(!1),Qe(null)},[Ie,xt,Wt,xe,ye,kt]),Yt=l(()=>{if(Bt(),Ge)return;if(!A)return;const e=Date.now();T&&e-ge.current<300?Lt():xt(),ge.current=e},[A,T,xt,Lt,Bt,Ge]);a(()=>{const e=he.current;if(!e)return;const t=()=>{be(!0),K?.()},n=()=>{be(!1),G?.()},r=()=>{be(!1),J?.(),V.length>0&&Ft()},i=()=>{we(e.currentTime),Z?.(e.currentTime),ft(e.currentTime,e.duration)},l=()=>ke(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);Ce(t/e.duration*100),ee?.(t/e.duration*100)}},o=()=>{Me(e.volume),Ne(e.muted),te?.(e.volume,e.muted)},s=()=>{ke(e.duration),Re(!1),de?.()},c=()=>Re(!0),d=()=>Re(!1),u=()=>Re(!1),h=()=>{Fe(e.error),Re(!1),le?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",n),e.addEventListener("ended",r),e.addEventListener("timeupdate",i),e.addEventListener("durationchange",l),e.addEventListener("progress",a),e.addEventListener("volumechange",o),e.addEventListener("loadedmetadata",s),e.addEventListener("waiting",c),e.addEventListener("playing",d),e.addEventListener("canplay",u),e.addEventListener("error",h),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",n),e.removeEventListener("ended",r),e.removeEventListener("timeupdate",i),e.removeEventListener("durationchange",l),e.removeEventListener("progress",a),e.removeEventListener("volumechange",o),e.removeEventListener("loadedmetadata",s),e.removeEventListener("waiting",c),e.removeEventListener("playing",d),e.removeEventListener("canplay",u),e.removeEventListener("error",h)}},[K,G,J,Z,ee,te,de,le,ft,V.length,Ft]),a(()=>{const e=()=>{const e=!!document.fullscreenElement;Le(e),ne?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[ne]),a(()=>{const e=he.current;if(!e)return;const t=()=>{Te(!0),re?.(!0)},n=()=>{Te(!1),re?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",n),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",n)}},[re]),a(()=>{const e=e=>{if(pe.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),xt();break;case"m":e.preventDefault(),Mt();break;case"f":e.preventDefault(),Lt();break;case"ArrowLeft":e.preventDefault(),kt(ye-10);break;case"ArrowRight":e.preventDefault(),kt(ye+10);break;case"ArrowUp":e.preventDefault(),zt(Ee+.1);break;case"ArrowDown":e.preventDefault(),zt(Ee-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[xt,Mt,Lt,kt,zt,ye,Ee]),a(()=>()=>{ve.current&&clearTimeout(ve.current)},[]),a(()=>{const e=()=>Bt();if(it.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[it.visible,Bt]),c(o,()=>({play:bt,pause:yt,stop:wt,seek:kt,setVolume:zt,mute:Ct,unmute:Et,toggleMute:Mt,enterFullscreen:Nt,exitFullscreen:Pt,toggleFullscreen:Lt,enterPip:_t,exitPip:Tt,togglePip:At,setPlaybackRate:Rt,setQuality:Vt,getCurrentTime:()=>he.current?.currentTime||0,getDuration:()=>he.current?.duration||0,getVolume:()=>he.current?.volume||0,isMuted:()=>he.current?.muted??!0,isPlaying:()=>!he.current?.paused,isFullscreen:()=>Pe,isPip:()=>_e,getVideoElement:()=>he.current}),[bt,yt,wt,kt,zt,Ct,Et,Mt,Nt,Pt,Lt,_t,Tt,At,Rt,Vt,Pe,_e]);const Kt=xe?ye/xe*100:0;return e("div",{ref:pe,className:y,style:{position:Pe?"fixed":"relative",inset:Pe?0:void 0,zIndex:Pe?9999:void 0,width:g,aspectRatio:Pe?"unset":"16/9",height:Pe?"100%":void 0,backgroundColor:"#000",overflow:"hidden",userSelect:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',WebkitTapHighlightColor:"transparent",touchAction:"manipulation",...w},onMouseMove:Ge?void 0:Xt,onMouseLeave:()=>!Ge&&fe&&Be(!1),onTouchStart:Ot,onTouchMove:Ut,onTouchEnd:Qt,onContextMenu:It,tabIndex:0,children:[t("video",{ref:he,style:{width:"100%",height:"100%",objectFit:"contain"},src:ct,poster:dt,autoPlay:h,muted:p,loop:qe,preload:R,playsInline:!0,onClick:Yt,children:N.map((e,n)=>t("track",{kind:e.kind,src:e.src,srcLang:e.srclang,label:e.label,default:e.default},n))}),Ae&&!Ve&&t("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:t("div",{style:{width:48,height:48,border:"4px solid transparent",borderTopColor:L,borderRadius:"50%",animation:"spin 1s linear infinite"}})}),t("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),Ve&&e("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.9)",color:"#fff"},children:[t("svg",{style:{width:64,height:64,marginBottom:16},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",{style:{fontSize:18,marginBottom:8},children:"Error loading video"}),t("button",{onClick:()=>{Fe(null),he.current?.load()},style:{padding:"8px 24px",borderRadius:4,border:"none",backgroundColor:L,color:"#000",fontWeight:500,cursor:"pointer"},children:"Retry"})]}),ht&&ut&&e("div",{style:{position:"absolute",inset:0,zIndex:20},children:[e("div",{style:{position:"absolute",top:16,left:16,display:"flex",alignItems:"center",gap:12,padding:"8px 12px",background:"rgba(0,0,0,0.7)",borderRadius:4,color:"#fff",fontSize:14},children:[t("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700,backgroundColor:L,color:"#000"},children:"AD"}),e("span",{children:[b(pt)," remaining"]})]}),t("button",{onClick:mt?vt:void 0,disabled:!mt,style:{position:"absolute",bottom:80,right:16,padding:"8px 20px",border:"1px solid #fff",borderRadius:4,background:"transparent",color:"#fff",cursor:mt?"pointer":"not-allowed",opacity:mt?1:.5},children:mt?"Skip Ad":`Skip in ${Math.ceil(pt)}s`})]}),it.visible&&e("div",{style:{position:"absolute",left:it.x,top:it.y,zIndex:50,minWidth:200,background:"rgba(26,26,26,0.95)",backdropFilter:"blur(8px)",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",overflow:"hidden"},onClick:e=>e.stopPropagation(),children:[e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{xt(),Bt()},children:[t(fe?I:F,{}),t("span",{style:{flex:1},children:fe?"Pause":"Play"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"Space"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{Mt(),Bt()},children:[t(Se?H:B,{}),t("span",{style:{flex:1},children:Se?"Unmute":"Mute"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"M"})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{St(),Bt()},children:[t(W,{}),t("span",{style:{flex:1},children:qe?"Disable Loop":"Enable Loop"}),qe&&t("span",{style:{color:L},children:"✓"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(He);Rt(e[(t+1)%e.length]),Bt()},children:[t(O,{}),e("span",{style:{flex:1},children:["Speed: ",He,"x"]})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),x&&document.pictureInPictureEnabled&&e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{At(),Bt()},children:[t($,{}),t("span",{style:{flex:1},children:"Picture in Picture"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"P"})]}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{Lt(),Bt()},children:[t(D,{}),t("span",{style:{flex:1},children:"Fullscreen"}),t("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"F"})]}),t("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:Ht,children:[t(X,{}),t("span",{style:{flex:1},children:"Copy Video URL"})]}),t("div",{style:{padding:"8px 16px",fontSize:10,color:"rgba(255,255,255,0.4)",textAlign:"center",borderTop:"1px solid rgba(255,255,255,0.1)"},children:"PlexVideo Player © FRAMESET STUDIO"})]}),v&&!ht&&e("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",padding:Ge?"12px 12px 16px":16,paddingTop:Ge?40:16,transition:"opacity 0.3s",opacity:Ie?1:0,pointerEvents:Ie?"auto":"none"},children:[e("div",{ref:me,onClick:Dt,onMouseMove:Ge?void 0:qt,onMouseLeave:Ge?void 0:$t,onTouchMove:e=>{if(Ge){const t=me.current?.getBoundingClientRect();if(t&&xe){const n=e.touches[0],r=Math.max(0,Math.min(1,(n.clientX-t.left)/t.width));Qe({time:r*xe,x:n.clientX-t.left})}}},onTouchEnd:e=>{Ge&&Ue&&(kt(Ue.time),Qe(null))},style:{position:"relative",height:Ge?12:8,background:"rgba(255,255,255,0.3)",borderRadius:Ge?6:4,marginBottom:Ge?12:16,cursor:"pointer"},children:[t("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${ze}%`,background:"rgba(255,255,255,0.5)",borderRadius:Ge?6:4}}),t("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${Kt}%`,background:L,borderRadius:Ge?6:4}}),t("div",{style:{position:"absolute",top:"50%",left:`${Kt}%`,transform:"translate(-50%, -50%)",width:Ge?20:16,height:Ge?20:16,borderRadius:"50%",background:L,boxShadow:"0 2px 8px rgba(0,0,0,0.5)"}}),Ue&&e("div",{style:{position:"absolute",bottom:"100%",left:Ue.x,transform:"translateX(-50%)",marginBottom:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none"},children:[Ye&&t("div",{style:{width:160,height:90,borderRadius:6,overflow:"hidden",marginBottom:4,boxShadow:"0 4px 16px rgba(0,0,0,0.6)",border:`2px solid ${L}`},children:t("img",{src:Ye,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),t("div",{style:{padding:"4px 10px",background:"rgba(0,0,0,0.9)",color:"#fff",fontSize:12,fontWeight:600,borderRadius:4,whiteSpace:"nowrap"},children:b(Ue.time)})]})]}),e("div",{style:{display:"flex",alignItems:"center",gap:Ge?4:8,flexWrap:"wrap"},children:[t("button",{onClick:xt,"aria-label":fe?"Pause":"Play",style:{width:Ge?48:44,height:Ge?48:44,minWidth:Ge?48:44,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"transparent",border:"none",color:"#fff",cursor:"pointer",padding:0},children:t(fe?I:F,{})}),M&&!Ge&&e("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t("button",{onClick:Mt,"aria-label":Se?"Unmute":"Mute",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer"},children:t(Se||0===Ee?H:B,{})}),t("input",{type:"range",min:"0",max:"1",step:"0.01",value:Se?0:Ee,onChange:e=>zt(parseFloat(e.target.value)),style:{width:70,height:4,cursor:"pointer",accentColor:L}})]}),M&&Ge&&t("button",{onClick:Mt,"aria-label":Se?"Unmute":"Mute",style:{width:44,height:44,minWidth:44,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",padding:0},children:t(Se||0===Ee?H:B,{})}),e("div",{style:{color:"#fff",fontSize:Ge?11:13,fontFamily:"monospace",marginLeft:Ge?4:8,whiteSpace:"nowrap"},children:[b(ye),!Ge&&` / ${b(xe)}`]}),t("div",{style:{flex:1}}),V.length>0&&t("button",{onClick:()=>Oe(!Xe),"aria-label":"Playlist",style:{width:Ge?44:36,height:Ge?44:36,minWidth:Ge?44:36,display:"flex",alignItems:"center",justifyContent:"center",background:Xe?"rgba(255,255,255,0.2)":"transparent",border:"none",color:L,cursor:"pointer",borderRadius:4,padding:0},children:t(U,{})}),!Ge&&t("button",{onClick:()=>{const e=he.current;e&&"remote"in e?e.remote.prompt().catch(()=>{alert("No casting devices found")}):alert("Casting not supported")},"aria-label":"Cast",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4,padding:0},children:t(Q,{})}),C&&e("div",{style:{position:"relative"},children:[t("button",{onClick:()=>We(!je),"aria-label":"Settings",style:{width:Ge?44:36,height:Ge?44:36,minWidth:Ge?44:36,display:"flex",alignItems:"center",justifyContent:"center",background:je?"rgba(255,255,255,0.2)":"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4,padding:0},children:t(j,{})}),je&&e("div",{style:{position:Ge?"fixed":"absolute",bottom:Ge?0:48,right:0,left:Ge?0:void 0,minWidth:Ge?"100%":160,maxHeight:Ge?"50vh":void 0,background:"#1a1a1a",borderRadius:Ge?"16px 16px 0 0":8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",border:Ge?"none":"1px solid rgba(255,255,255,0.1)",zIndex:100,overflow:"hidden"},children:[t("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:"Playback Speed"}),E.map(n=>e("button",{onClick:()=>Rt(n),style:{width:"100%",padding:Ge?"16px 20px":"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",background:"transparent",border:"none",color:He===n?L:"#fff",cursor:"pointer",fontSize:Ge?16:14},children:[t("span",{children:1===n?"Normal":`${n}x`}),He===n&&t("span",{children:"✓"})]},n))]})]}),x&&!Ge&&document.pictureInPictureEnabled&&t("button",{onClick:At,"aria-label":"Picture in Picture",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4,padding:0},children:t($,{})}),z&&t("button",{onClick:Lt,"aria-label":Pe?"Exit Fullscreen":"Fullscreen",style:{width:Ge?44:36,height:Ge?44:36,minWidth:Ge?44:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4,padding:0},children:t(Pe?q:D,{})})]})]}),Ge&&Ze&&Ue&&t("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",padding:"12px 24px",background:"rgba(0,0,0,0.8)",borderRadius:8,color:"#fff",fontSize:18,fontWeight:600,pointerEvents:"none"},children:b(Ue.time)}),!fe&&!Ae&&!Ve&&!ht&&t("button",{onClick:xt,"aria-label":"Play",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:Ge?70:80,height:Ge?70:80,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",backgroundColor:L,boxShadow:"0 8px 32px rgba(0,0,0,0.4)",transition:"transform 0.2s",padding:0},children:t("svg",{viewBox:"0 0 24 24",fill:"white",style:{width:Ge?28:32,height:Ge?28:32,marginLeft:4},children:t("path",{d:"M8 5v14l11-7z"})})}),V.length>0&&e("div",{style:{position:"absolute",top:Ge?"auto":0,bottom:Ge?0:void 0,right:0,left:Ge?0:void 0,width:Ge?"100%":320,height:Ge?"70%":"100%",maxHeight:Ge?"70vh":void 0,background:Ge?"linear-gradient(to top, rgba(0,0,0,0.98) 0%, rgba(0,0,0,0.95) 100%)":"linear-gradient(to left, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.85) 100%)",backdropFilter:"blur(10px)",transform:Xe?"translateY(0)":Ge?"translateY(100%)":"translateX(100%)",transition:"transform 0.3s ease-out",zIndex:60,display:"flex",flexDirection:"column",borderLeft:Ge?"none":"1px solid rgba(255,255,255,0.1)",borderTop:Ge?"1px solid rgba(255,255,255,0.1)":"none",borderRadius:Ge?"20px 20px 0 0":0},children:[Ge&&t("div",{style:{width:40,height:4,background:"rgba(255,255,255,0.3)",borderRadius:2,margin:"12px auto 8px"}}),e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:Ge?"12px 20px 16px":"16px 20px",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:[e("div",{children:[t("div",{style:{color:L,fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:1,marginBottom:2},children:"Playlist"}),e("div",{style:{color:"#fff",fontSize:16,fontWeight:600},children:[V.length," videos"]})]}),t("button",{onClick:()=>Oe(!1),style:{width:Ge?44:36,height:Ge?44:36,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.1)",border:"none",borderRadius:"50%",color:"#fff",cursor:"pointer"},children:t(Y,{})})]}),t("div",{style:{flex:1,overflowY:"auto",padding:"8px 0"},children:V.map((n,r)=>e("button",{onClick:()=>{ot(r),ue?.(r,n),setTimeout(()=>bt(),100)},style:{width:"100%",padding:"12px 20px",display:"flex",alignItems:"center",gap:12,background:at===r?`${L}20`:"transparent",border:"none",borderLeft:at===r?`3px solid ${L}`:"3px solid transparent",cursor:"pointer",textAlign:"left",transition:"background 0.2s"},children:[e("div",{style:{width:100,height:56,borderRadius:6,overflow:"hidden",background:"#333",flexShrink:0,position:"relative"},children:[n.poster?t("img",{src:n.poster,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):t("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(255,255,255,0.3)"},children:t("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:24,height:24},children:t("path",{d:"M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z"})})}),at===r&&t("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center"},children:t("div",{style:{color:L,fontSize:20},children:"▶"})}),n.duration&&t("div",{style:{position:"absolute",bottom:4,right:4,padding:"2px 6px",background:"rgba(0,0,0,0.8)",borderRadius:3,fontSize:10,color:"#fff",fontWeight:500},children:b(n.duration)})]}),e("div",{style:{flex:1,minWidth:0},children:[t("div",{style:{color:at===r?L:"#fff",fontSize:14,fontWeight:at===r?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:4},children:n.title}),e("div",{style:{color:"rgba(255,255,255,0.5)",fontSize:12},children:["Video ",r+1]})]})]},n.id))})]}),t("video",{ref:rt,src:ct,style:{display:"none"},muted:!0,preload:"metadata"}),t("canvas",{ref:nt,style:{display:"none"}})]})});K.displayName="PlexVideoPlayer";const G=({currentTime:n,duration:o,buffered:s,onSeek:c,thumbnailPreview:d,disabled:u=!1})=>{const h=i(null),[p,m]=r(!1),[v,g]=r(null),[f,y]=r(0),k=w(n,o),z=w(s,o),C=l(e=>{if(!h.current)return 0;const t=h.current.getBoundingClientRect();return x((e-t.left)/t.width,0,1)*o},[o]),E=l(e=>{if(!h.current)return;const t=h.current.getBoundingClientRect(),n="clientX"in e?e.clientX:0,r=x(n-t.left,0,t.width),i=C(n);y(r),g(i),p&&c(i)},[p,C,c]),M=l(e=>{if(u)return;e.preventDefault(),m(!0);const t=C(e.clientX);c(t)},[u,C,c]),S=l(()=>{m(!1)},[]),N=l(e=>{const t=C(e.clientX);g(t)},[C]),P=l(()=>{g(null)},[]);a(()=>{if(p){const e=e=>E(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",S)}}},[p,E,S]);const L=l(e=>{if(u)return;e.preventDefault();const t=e.touches[0],n=C(t.clientX);m(!0),c(n)},[u,C,c]),_=l(e=>{if(!p)return;const t=e.touches[0],n=C(t.clientX);c(n)},[p,C,c]),T=l(()=>{m(!1)},[]);return e("div",{ref:h,className:"plex-video-player__progress-container",onMouseDown:M,onMouseEnter:N,onMouseLeave:P,onMouseMove:e=>E(e.nativeEvent),onTouchStart:L,onTouchMove:_,onTouchEnd:T,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":n,"aria-valuetext":b(n),tabIndex:0,children:[e("div",{className:"plex-video-player__progress",children:[t("div",{className:"plex-video-player__progress-buffered",style:{width:`${z}%`}}),t("div",{className:"plex-video-player__progress-played",style:{width:`${k}%`}}),t("div",{className:"plex-video-player__progress-handle",style:{left:`${k}%`}})]}),d?.enabled&&null!==v&&e("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${f}px`,width:d.width||160,height:d.height||90},children:[d.sprites&&t("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${d.sprites})`,backgroundPosition:J(v,o,d.interval||10,d.width||160,d.height||90),backgroundSize:"cover"}}),t("div",{className:"plex-video-player__thumbnail-time",children:b(v)})]}),null!==v&&!d?.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:b(v)})})]})},J=(e,t,n,r,i)=>{const l=Math.floor(e/n);return`-${l%10*r}px -${Math.floor(l/10)*i}px`},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:"M8 5v14l11-7z"})}),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:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),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:"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"})}),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:"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"})}),re=({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"})}),ie=({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"})}),le=({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"})}),ae=({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"})}),oe=({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"})}),se=({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"})}),ce=({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"})}),de=({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"})}),ue=({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"})}),he=({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"})}),pe=({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"})}),me=({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"})}),ve=({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"})}),ge=({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"})}),fe=({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"})}),be=({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"})}),ye=({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"})}),we=({volume:n,muted:r,onVolumeChange:i,onToggleMute:a})=>{const o=l(e=>{const t=parseFloat(e.target.value);i(t)},[i]);return e("div",{className:"plex-video-player__volume-container",children:[t("button",{className:"plex-video-player__btn",onClick:a,"aria-label":r?"Unmute":"Mute",title:r?"Unmute (M)":"Mute (M)",type:"button",children:t(r||0===n?ie:n<.33?re:n<.66?ne:te,{})}),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:r?0:n,onChange:o,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(r?0:n)}%, var(--plex-progress-bg) ${100*(r?0:n)}%, var(--plex-progress-bg) 100%)`}})})]})},xe=({playbackRate:o,playbackSpeeds:s,onPlaybackRateChange:c,qualityEnabled:d,sources:u,currentQuality:h,onQualityChange:p,captionsEnabled:m,textTracks:v,currentTrack:g,onTrackChange:f})=>{const[b,y]=r(!1),[w,x]=r("main"),k=i(null);a(()=>{const e=e=>{k.current&&!k.current.contains(e.target)&&(y(!1),x("main"))};if(b)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]);const z=l(()=>{y(e=>!e),x("main")},[]),C=l(e=>{c(e),x("main")},[c]),E=l(e=>{p?.(e),x("main")},[p]),M=l(e=>{f?.(e),x("main")},[f]);return e("div",{className:"plex-video-player__settings-container",ref:k,children:[t("button",{className:"plex-video-player__btn",onClick:z,"aria-label":"Settings","aria-expanded":b,title:"Settings",type:"button",children:t(ce,{})}),b&&e("div",{className:"plex-video-player__settings-menu "+(b?"plex-video-player__settings-menu--open":""),children:["main"===w&&e(n,{children:[t("div",{className:"plex-video-player__settings-title",children:"Settings"}),e("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[t("span",{children:"Playback Speed"}),t("span",{children:1===o?"Normal":`${o}x`})]}),d&&u&&u.length>1&&e("button",{className:"plex-video-player__settings-item",onClick:()=>x("quality"),type:"button",children:[t("span",{children:"Quality"}),t("span",{children:h||"Auto"})]}),m&&v&&v.length>0&&e("button",{className:"plex-video-player__settings-item",onClick:()=>x("captions"),type:"button",children:[t("span",{children:"Captions"}),t("span",{children:g||"Off"})]})]}),"speed"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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:s.map(e=>t("button",{className:"plex-video-player__speed-btn "+(o===e?"plex-video-player__speed-btn--active":""),onClick:()=>C(e),type:"button",children:1===e?"Normal":`${e}x`},e))})]}),"quality"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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 "+(h===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"}),h===n.quality&&t(ye,{size:16})]},n.quality||n.src))})]}),"captions"===w&&e(n,{children:[t("button",{className:"plex-video-player__settings-title",onClick:()=>x("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:()=>M(null),type:"button",children:[t("span",{children:"Off"}),!g&&t(ye,{size:16})]}),v?.map(n=>e("button",{className:"plex-video-player__settings-item "+(g===n.srclang?"plex-video-player__settings-item--active":""),onClick:()=>M(n.srclang),type:"button",children:[t("span",{children:n.label}),g===n.srclang&&t(ye,{size:16})]},n.srclang))]})]})]})]})},ke=({ad:n,timeRemaining:r,canSkip:i,onSkip:l,onClick:a})=>{const o=i?"Skip Ad":`Skip in ${Math.ceil(r)}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:[b(r)," remaining"]})]}),n.clickThrough&&e("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),a()},type:"button",children:[t(be,{size:16}),"Learn More"]}),t("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),i&&l()},disabled:!i,type:"button",children:o})]})},ze={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."},Ce=({error:n,onRetry:r})=>{const i=n?.code||0,l=ze[i]||"An unknown error occurred.";return e("div",{className:"plex-video-player__error",children:[t(fe,{className:"plex-video-player__error-icon",size:60}),t("div",{className:"plex-video-player__error-message",children:l}),i>0&&e("div",{className:"plex-video-player__error-code",children:["Error Code: ",i]}),t("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},Ee=({visible:e})=>e?t("div",{className:"plex-video-player__loader",children:t("div",{className:"plex-video-player__loader-spinner"})}):null,Me={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},Se=(e={})=>{const{autoPlay:t=!1,muted:n=!1,loop:o=!1,volume:s=1,playbackRate:c=1}=e,d=i(null),u=i(null),[h,p]=r({...Me,volume:s,isMuted:n,playbackRate:c}),m=l(e=>{p(t=>({...t,...e}))},[]),v=l(async()=>{const e=d.current;if(e)try{await e.play(),m({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[m]),g=l(()=>{const e=d.current;e&&(e.pause(),m({isPlaying:!1,isPaused:!0}))},[m]),f=l(()=>{h.isPlaying?g():v()},[h.isPlaying,v,g]),b=l(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]),y=l(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]),w=l(()=>{const e=d.current;e&&(e.muted=!e.muted,m({isMuted:e.muted}))},[m]),x=l(e=>{const t=d.current;t&&(t.playbackRate=e,m({playbackRate:e}))},[m]),k=l(async()=>{const e=u.current;if(e)try{await S(e),m({isFullscreen:!0})}catch(e){}},[m]),z=l(async()=>{try{await N(),m({isFullscreen:!1})}catch(e){}},[m]),C=l(async()=>{h.isFullscreen?await z():await k()},[h.isFullscreen,k,z]),P=l(async()=>{const e=d.current;if(e&&E())try{await e.requestPictureInPicture(),m({isPip:!0})}catch(e){}},[m]),L=l(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),m({isPip:!1})}catch(e){}},[m]),_=l(async()=>{h.isPip?await L():await P()},[h.isPip,P,L]);return a(()=>{const e=d.current;if(!e)return;e.muted=n,e.volume=s,e.playbackRate=c,e.loop=o;const r={loadedmetadata:()=>{m({duration:e.duration})},timeupdate:()=>{m({currentTime:e.currentTime,buffered:R(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(r).forEach(([t,n])=>{e.addEventListener(t,n)}),t&&v(),()=>{Object.entries(r).forEach(([t,n])=>{e.removeEventListener(t,n)})}},[t,n,o,s,c,v,m]),a(()=>{const e=()=>{const e=!!M();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:h,videoRef:d,containerRef:u,play:v,pause:g,togglePlay:f,seek:b,setVolume:y,toggleMute:w,setPlaybackRate:x,enterFullscreen:k,exitFullscreen:z,toggleFullscreen:C,enterPip:P,exitPip:L,togglePip:_}},Ne={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"},Pe=({enabled:e,hotkeys:t={},onPlay:n,onMute:r,onFullscreen:i,onPip:o,onSeek:s,onVolume:c,containerRef:d})=>{const u={...Ne,...t},h=l(t=>{if(!e)return;const l=t.target;if("INPUT"===l.tagName||"TEXTAREA"===l.tagName||l.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(),r();break;case u.fullscreen:case"F":t.preventDefault(),i();break;case u.pip:case"P":t.preventDefault(),o();break;case u.seekForward:t.preventDefault(),s(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),s(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(),s(-1/0)}},[e,u,n,r,i,o,s,c,d]);a(()=>{if(e)return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[e,h])};export{ke as AdOverlay,de as CaptionsIcon,ye as CheckIcon,Ce as ErrorDisplay,fe as ErrorIcon,be as ExternalLinkIcon,pe as ForwardIcon,ae as FullscreenExitIcon,le as FullscreenIcon,Ee as Loader,ee as PauseIcon,se as PipExitIcon,oe as PipIcon,Z as PlayIcon,K as PlexVideoPlayer,G as ProgressBar,he as QualityIcon,me as RewindIcon,ce as SettingsIcon,xe as SettingsMenu,ve as SkipNextIcon,ge as SkipPrevIcon,ue as SpeedIcon,we as VolumeControl,te as VolumeHighIcon,re as VolumeLowIcon,ne as VolumeMediumIcon,ie as VolumeMuteIcon,V as canPlayType,x as clamp,g as convertToAdInfo,z as debounce,K as default,P as detectVideoType,N as exitFullscreen,h as fetchVastAd,m as fireTrackingPixel,v as fireTrackingPixels,b as formatTime,_ as generateId,R as getBufferedEnd,M as getFullscreenElement,C as isFullscreenSupported,L as isHlsNativelySupported,T as isMobile,E as isPipSupported,A as isTouchDevice,y as parseTime,d as parseVastXml,w as percentage,S as requestFullscreen,p as selectBestMediaFile,k as throttle,Pe as useKeyboard,Se as usePlayer,f as useVast};
2
2
  //# sourceMappingURL=index.esm.js.map