@frameset/plex-player 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const r=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const r=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const n=e.getAttribute("id")||"",l=t.querySelector("AdTitle")?.textContent||"",a=t.querySelector("Description")?.textContent||void 0,i=t.querySelectorAll("Creative");let c,o,u=0;const d=[],h=[],p={};i.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const r=t.querySelector("Duration")?.textContent;r&&(u=s(r));const n=t.getAttribute("skipoffset");n&&(c=s(n));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&h.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const l=t.querySelector("VideoClicks");l&&(o=l.querySelector("ClickThrough")?.textContent?.trim(),l.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&d.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),r=e.textContent?.trim();t&&r&&(p[t]||(p[t]=[]),p[t].push(r))})});const m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),h.length>0&&r.push({id:n,title:l,description:a,duration:u,skipOffset:c,clickThrough:o,clickTracking:d,impressionUrls:m,mediaFiles:h,trackingEvents:p})}),{ads:r}},s=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])},n=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const s=await t.text(),n=r(s);if(n.error||0===n.ads.length)return null;const l=n.ads[0];return void 0!==e.skipDelay&&void 0===l.skipOffset&&(l.skipOffset=e.skipDelay),l}catch(e){return null}},l=e=>{if(0===e.length)return null;const t=document.createElement("video"),r=e.filter(e=>""!==t.canPlayType(e.type));if(0===r.length)return null;r.sort((e,t)=>{const r=e.width*e.height,s=t.width*t.height;return r!==s?s-r:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&r.length>1?r[r.length-1]:r[0]},a=e=>{(new Image).src=e},i=e=>{e.forEach(a)},c=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),o=({vastConfig:e,videoRef:r,onAdStart:s,onAdEnd:a,onAdSkip:o,onAdError:u})=>{const[d,h]=t.useState(!1),[p,m]=t.useState(null),[v,x]=t.useState(0),[g,f]=t.useState(!1),w=t.useRef(null),b=t.useRef(""),y=t.useRef(0),k=t.useRef(new Set),j=t.useRef(null),C=Array.isArray(e)?e:e?[e]:[],N=t.useCallback(async e=>{const t=r.current;if(t&&!d)try{const r=await n(e);if(!r)return void u?.(new Error("Failed to fetch VAST ad"));const a=l(r.mediaFiles);if(!a)return void u?.(new Error("No compatible media file found"));b.current=t.currentSrc,y.current=t.currentTime,i(r.impressionUrls),w.current=r,m(c(r)),h(!0),x(r.duration),f(void 0===r.skipOffset||0===r.skipOffset),t.src=a.url,t.currentTime=0,await t.play(),r.trackingEvents.start&&i(r.trackingEvents.start),s?.(c(r)),j.current=window.setInterval(()=>{const e=Math.max(0,r.duration-t.currentTime);x(e),r.skipOffset&&t.currentTime>=r.skipOffset&&f(!0);const s=t.currentTime/r.duration*100;s>=25&&r.trackingEvents.firstQuartile&&i(r.trackingEvents.firstQuartile),s>=50&&r.trackingEvents.midpoint&&i(r.trackingEvents.midpoint),s>=75&&r.trackingEvents.thirdQuartile&&i(r.trackingEvents.thirdQuartile)},250);const o=()=>{r.trackingEvents.complete&&i(r.trackingEvents.complete),E()};t.addEventListener("ended",o,{once:!0})}catch(e){u?.(e instanceof Error?e:new Error("Ad playback failed")),E()}},[r,d,s,u]),E=t.useCallback(()=>{const e=r.current;e&&(j.current&&(clearInterval(j.current),j.current=null),b.current&&(e.src=b.current,e.currentTime=y.current,e.play().catch(()=>{})),h(!1),m(null),x(0),f(!1),w.current=null,a?.())},[r,a]),z=t.useCallback(()=>{if(!g||!w.current)return;const e=w.current;e.trackingEvents.skip&&i(e.trackingEvents.skip),o?.(),E()},[g,E,o]),M=t.useCallback(()=>{if(!w.current)return;const e=w.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&i(e.clickTracking)},[]),P=t.useCallback((e,t)=>{d||0===C.length||C.forEach(r=>{const s=r.position||"preroll",n=`${s}-${r.midrollTime||0}`;if(k.current.has(n))return;let l=!1;switch(s){case"preroll":l=0===e;break;case"midroll":r.midrollTime&&e>=r.midrollTime&&(l=!0);break;case"postroll":l=e>=t-.5}l&&(k.current.add(n),N(r))})},[C,d,N]);return t.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]),{isAdPlaying:d,currentAd:p,adTimeRemaining:v,canSkip:g,skipAd:z,handleAdClick:M,checkForAd:P}},u=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),r=Math.floor(e%3600/60),s=Math.floor(e%60);return t>0?`${t}:${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${r}:${s.toString().padStart(2,"0")}`},d=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),h=(e,t,r)=>Math.min(r,Math.max(t,e)),p=(e,t)=>{let r=!1;return(...s)=>{r||(e(...s),r=!0,setTimeout(()=>r=!1,t))}},m=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,v=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,x=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},g=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},f=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let r=0;r<e.buffered.length;r++)if(e.buffered.start(r)<=t&&e.buffered.end(r)>=t)return e.buffered.end(r);return e.buffered.end(e.buffered.length-1)},w=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),b=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),y=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),k=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),j=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),C=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),N=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),E=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),z=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),M=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("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"})}),P=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("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"})}),S=t.forwardRef((r,s)=>{const{src:n,poster:l,autoPlay:a=!1,muted:i=!1,loop:c=!1,controls:d=!0,width:h="100%",className:m="",style:v={},pip:x=!0,fullscreen:g=!0,playbackSpeed:f=!0,playbackSpeeds:S=[.5,.75,1,1.25,1.5,2],volume:_=!0,initialVolume:L=1,textTracks:T=[],vast:A,accentColor:V="#f5c518",controlsTimeout:F=3e3,doubleClickFullscreen:R=!0,clickToPlay:I=!0,preload:H="metadata",playlist:B=[],onPlay:q,onPause:D,onEnded:$,onTimeUpdate:O,onProgress:U,onVolumeChange:Q,onFullscreenChange:X,onPipChange:K,onQualityChange:G,onError:Y,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee,onReady:te,onPlaylistItemChange:re}=r,se=t.useRef(null),ne=t.useRef(null),le=t.useRef(null),ae=t.useRef(null),ie=t.useRef(0),[ce,oe]=t.useState(!1),[ue,de]=t.useState(0),[he,pe]=t.useState(0),[me,ve]=t.useState(0),[xe,ge]=t.useState(i?0:L),[fe,we]=t.useState(i),[be,ye]=t.useState(!1),[ke,je]=t.useState(!1),[Ce,Ne]=t.useState(!0),[Ee,ze]=t.useState(null),[Me,Pe]=t.useState(!0),[Se,_e]=t.useState(1),[Le,Te]=t.useState(c),[Ae,Ve]=t.useState(!1),[Fe,Re]=t.useState({x:0,y:0,visible:!1}),[Ie,He]=t.useState(0),Be=t.useMemo(()=>"string"==typeof n?[{src:n,type:"video/mp4"}]:n,[n]),qe=t.useMemo(()=>B.length>0&&B[Ie]?B[Ie].src:Be[0]?.src||"",[B,Ie,Be]),De=t.useMemo(()=>B.length>0&&B[Ie]?.poster?B[Ie].poster:l,[B,Ie,l]),{currentAd:$e,isAdPlaying:Oe,adTimeRemaining:Ue,canSkip:Qe,skipAd:Xe,handleAdClick:Ke,checkForAd:Ge}=o({vastConfig:A,videoRef:se,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee}),Ye=t.useCallback(async()=>{const e=se.current;if(e)try{await e.play()}catch(e){}},[]),Je=t.useCallback(()=>{se.current?.pause()},[]),We=t.useCallback(()=>{const e=se.current;e&&(e.pause(),e.currentTime=0)},[]),Ze=t.useCallback(()=>{se.current?.paused?Ye():Je()},[Ye,Je]),et=t.useCallback(e=>{const t=se.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),tt=t.useCallback(e=>{const t=se.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,ge(r),we(0===r)},[]),rt=t.useCallback(()=>{se.current&&(se.current.muted=!0,we(!0))},[]),st=t.useCallback(()=>{const e=se.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,ge(.5)),we(!1))},[]),nt=t.useCallback(()=>{se.current?.muted?st():rt()},[rt,st]),lt=t.useCallback(()=>{se.current&&(se.current.loop=!se.current.loop,Te(se.current.loop))},[]),at=t.useCallback(async()=>{try{await(ne.current?.requestFullscreen()),ye(!0)}catch(e){}},[]),it=t.useCallback(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),ye(!1))}catch(e){}},[]),ct=t.useCallback(async()=>{document.fullscreenElement?await it():await at()},[at,it]),ot=t.useCallback(async()=>{try{await(se.current?.requestPictureInPicture()),je(!0)}catch(e){}},[]),ut=t.useCallback(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),je(!1))}catch(e){}},[]),dt=t.useCallback(async()=>{document.pictureInPictureElement?await ut():await ot()},[ot,ut]),ht=t.useCallback(e=>{se.current&&(se.current.playbackRate=e,_e(e),Ve(!1))},[]),pt=t.useCallback(e=>{const t=Be.find(t=>t.label===e||t.quality===e);if(t&&se.current){const r=se.current,s=!r.paused,n=r.currentTime;r.src=t.src,r.currentTime=n,s&&r.play(),G?.(e)}},[Be,G]),mt=t.useCallback(()=>{if(0===B.length)return;const e=(Ie+1)%B.length;He(e),re?.(e,B[e]),setTimeout(()=>Ye(),100)},[Ie,B,re,Ye]),vt=t.useCallback(e=>{e.preventDefault();const t=ne.current?.getBoundingClientRect();t&&Re({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),xt=t.useCallback(()=>{Re(e=>({...e,visible:!1}))},[]),gt=t.useCallback(()=>{navigator.clipboard.writeText(qe),xt()},[qe,xt]),ft=t.useCallback(e=>{const t=le.current?.getBoundingClientRect();if(t&&he){const r=(e.clientX-t.left)/t.width;et(r*he)}},[he,et]),wt=t.useCallback(()=>{ce&&!Ae&&Pe(!1)},[ce,Ae]),bt=t.useCallback(()=>{Pe(!0),ae.current&&clearTimeout(ae.current),ce&&(ae.current=setTimeout(wt,F))},[ce,F,wt]),yt=t.useMemo(()=>p(bt,200),[bt]),kt=t.useCallback(()=>{if(xt(),!I)return;const e=Date.now();R&&e-ie.current<300?ct():Ze(),ie.current=e},[I,R,Ze,ct,xt]);t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{oe(!0),q?.()},r=()=>{oe(!1),D?.()},s=()=>{oe(!1),$?.(),B.length>0&&mt()},n=()=>{de(e.currentTime),O?.(e.currentTime),Ge(e.currentTime,e.duration)},l=()=>pe(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);ve(t/e.duration*100),U?.(t/e.duration*100)}},i=()=>{ge(e.volume),we(e.muted),Q?.(e.volume,e.muted)},c=()=>{pe(e.duration),Ne(!1),te?.()},o=()=>Ne(!0),u=()=>Ne(!1),d=()=>Ne(!1),h=()=>{ze(e.error),Ne(!1),Y?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",s),e.addEventListener("timeupdate",n),e.addEventListener("durationchange",l),e.addEventListener("progress",a),e.addEventListener("volumechange",i),e.addEventListener("loadedmetadata",c),e.addEventListener("waiting",o),e.addEventListener("playing",u),e.addEventListener("canplay",d),e.addEventListener("error",h),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",r),e.removeEventListener("ended",s),e.removeEventListener("timeupdate",n),e.removeEventListener("durationchange",l),e.removeEventListener("progress",a),e.removeEventListener("volumechange",i),e.removeEventListener("loadedmetadata",c),e.removeEventListener("waiting",o),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",h)}},[q,D,$,O,U,Q,te,Y,Ge,B.length,mt]),t.useEffect(()=>{const e=()=>{const e=!!document.fullscreenElement;ye(e),X?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[X]),t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{je(!0),K?.(!0)},r=()=>{je(!1),K?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",r),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",r)}},[K]),t.useEffect(()=>{const e=e=>{if(ne.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),Ze();break;case"m":e.preventDefault(),nt();break;case"f":e.preventDefault(),ct();break;case"ArrowLeft":e.preventDefault(),et(ue-10);break;case"ArrowRight":e.preventDefault(),et(ue+10);break;case"ArrowUp":e.preventDefault(),tt(xe+.1);break;case"ArrowDown":e.preventDefault(),tt(xe-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Ze,nt,ct,et,tt,ue,xe]),t.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]),t.useEffect(()=>{const e=()=>xt();if(Fe.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Fe.visible,xt]),t.useImperativeHandle(s,()=>({play:Ye,pause:Je,stop:We,seek:et,setVolume:tt,mute:rt,unmute:st,toggleMute:nt,enterFullscreen:at,exitFullscreen:it,toggleFullscreen:ct,enterPip:ot,exitPip:ut,togglePip:dt,setPlaybackRate:ht,setQuality:pt,getCurrentTime:()=>se.current?.currentTime||0,getDuration:()=>se.current?.duration||0,getVolume:()=>se.current?.volume||0,isMuted:()=>se.current?.muted??!0,isPlaying:()=>!se.current?.paused,isFullscreen:()=>be,isPip:()=>ke,getVideoElement:()=>se.current}),[Ye,Je,We,et,tt,rt,st,nt,at,it,ct,ot,ut,dt,ht,pt,be,ke]);const jt=he?ue/he*100:0;return e.jsxs("div",{ref:ne,className:`relative bg-black overflow-hidden select-none ${be?"fixed inset-0 z-[9999]":""} ${m}`,style:{width:h,aspectRatio:be?"unset":"16/9","--accent":V,...v},onMouseMove:yt,onMouseLeave:()=>ce&&Pe(!1),onContextMenu:vt,tabIndex:0,children:[e.jsx("video",{ref:se,className:"w-full h-full object-contain",src:qe,poster:De,autoPlay:a,muted:i,loop:Le,preload:H,playsInline:!0,onClick:kt,children:T.map((t,r)=>e.jsx("track",{kind:t.kind,src:t.src,srcLang:t.srclang,label:t.label,default:t.default},r))}),Ce&&!Ee&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"w-12 h-12 border-4 border-transparent rounded-full animate-spin",style:{borderTopColor:V}})}),Ee&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/90 text-white",children:[e.jsx("svg",{className:"w-16 h-16 mb-4",fill:V,viewBox:"0 0 24 24",children:e.jsx("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"})}),e.jsx("p",{className:"text-lg mb-2",children:"Error loading video"}),e.jsx("button",{className:"px-6 py-2 rounded text-black font-medium",style:{backgroundColor:V},onClick:()=>{ze(null),se.current?.load()},children:"Retry"})]}),Oe&&$e&&e.jsxs("div",{className:"absolute inset-0 z-20",children:[e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-3 px-3 py-2 bg-black/70 rounded text-white text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-bold",style:{backgroundColor:V,color:"#000"},children:"AD"}),e.jsxs("span",{children:[u(Ue)," remaining"]})]}),e.jsx("button",{className:"absolute bottom-20 right-4 px-5 py-2 border border-white rounded text-white "+(Qe?"hover:bg-white hover:text-black cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:Qe?Xe:void 0,disabled:!Qe,children:Qe?"Skip Ad":`Skip in ${Math.ceil(Ue)}s`})]}),Fe.visible&&e.jsxs("div",{className:"absolute z-50 min-w-[200px] bg-[#1a1a1a]/95 backdrop-blur-md rounded-lg shadow-xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{left:Fe.x,top:Fe.y},onClick:e=>e.stopPropagation(),children:[e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{Ze(),xt()},children:[ce?e.jsx(b,{}):e.jsx(w,{}),e.jsx("span",{className:"flex-1 text-left",children:ce?"Pause":"Play"}),e.jsx("span",{className:"text-white/50 text-xs",children:"Space"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{nt(),xt()},children:[fe?e.jsx(k,{}):e.jsx(y,{}),e.jsx("span",{className:"flex-1 text-left",children:fe?"Unmute":"Mute"}),e.jsx("span",{className:"text-white/50 text-xs",children:"M"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{lt(),xt()},children:[e.jsx(z,{}),e.jsx("span",{className:"flex-1 text-left",children:Le?"Disable Loop":"Enable Loop"}),Le&&e.jsx("span",{style:{color:V},children:"✓"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(Se);ht(e[(t+1)%e.length]),xt()},children:[e.jsx(P,{}),e.jsxs("span",{className:"flex-1 text-left",children:["Speed: ",Se,"x"]})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),x&&document.pictureInPictureEnabled&&e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{dt(),xt()},children:[e.jsx(N,{}),e.jsx("span",{className:"flex-1 text-left",children:"Picture in Picture"}),e.jsx("span",{className:"text-white/50 text-xs",children:"P"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{ct(),xt()},children:[e.jsx(j,{}),e.jsx("span",{className:"flex-1 text-left",children:"Fullscreen"}),e.jsx("span",{className:"text-white/50 text-xs",children:"F"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:gt,children:[e.jsx(M,{}),e.jsx("span",{className:"flex-1 text-left",children:"Copy Video URL"})]}),e.jsx("div",{className:"px-4 py-2 text-[10px] text-white/40 text-center border-t border-white/10",children:"PlexVideo Player © FRAMESET STUDIO"})]}),d&&!Oe&&e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent p-4 transition-opacity duration-300 "+(Me?"opacity-100":"opacity-0 pointer-events-none"),children:[e.jsxs("div",{ref:le,className:"relative h-1 bg-white/30 rounded-full mb-4 cursor-pointer group",onClick:ft,children:[e.jsx("div",{className:"absolute h-full bg-white/50 rounded-full",style:{width:`${me}%`}}),e.jsx("div",{className:"absolute h-full rounded-full",style:{width:`${jt}%`,backgroundColor:V}}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-3 h-3 rounded-full opacity-0 group-hover:opacity-100 transition-opacity shadow-lg",style:{left:`${jt}%`,transform:"translate(-50%, -50%)",backgroundColor:V}})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"w-10 h-10 flex items-center justify-center rounded-full hover:bg-white/10 text-white transition-colors",onClick:Ze,"aria-label":ce?"Pause":"Play",children:ce?e.jsx(b,{}):e.jsx(w,{})}),_&&e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:nt,"aria-label":fe?"Unmute":"Mute",children:fe||0===xe?e.jsx(k,{}):e.jsx(y,{})}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:fe?0:xe,onChange:e=>tt(parseFloat(e.target.value)),className:"w-0 group-hover:w-20 h-1 rounded-full appearance-none cursor-pointer transition-all overflow-hidden",style:{background:`linear-gradient(to right, ${V} 0%, ${V} ${100*(fe?0:xe)}%, rgba(255,255,255,0.3) ${100*(fe?0:xe)}%)`}})]}),e.jsxs("div",{className:"text-white text-sm font-mono ml-2",children:[u(ue)," / ",u(he)]}),e.jsx("div",{className:"flex-1"}),f&&e.jsxs("div",{className:"relative",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:()=>Ve(!Ae),"aria-label":"Settings",children:e.jsx(E,{})}),Ae&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 min-w-[150px] bg-[#1a1a1a]/95 backdrop-blur-md rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 text-white/60 text-xs font-medium border-b border-white/10",children:"Playback Speed"}),S.map(t=>e.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-white/10 transition-colors "+(Se===t?"text-[var(--accent)]":"text-white"),style:Se===t?{color:V}:{},onClick:()=>ht(t),children:1===t?"Normal":`${t}x`},t))]})]}),x&&document.pictureInPictureEnabled&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:dt,"aria-label":"Picture in Picture",children:e.jsx(N,{})}),g&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:ct,"aria-label":be?"Exit Fullscreen":"Fullscreen",children:be?e.jsx(C,{}):e.jsx(j,{})})]})]}),!ce&&!Ce&&!Ee&&!Oe&&e.jsx("button",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-20 h-20 rounded-full flex items-center justify-center hover:scale-110 transition-transform shadow-2xl",style:{backgroundColor:V},onClick:Ze,"aria-label":"Play",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"white",className:"w-8 h-8 ml-1",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})]})});S.displayName="PlexVideoPlayer";const _=(e,t,r,s,n)=>{const l=Math.floor(e/r);return`-${l%10*s}px -${Math.floor(l/10)*n}px`},L=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),T=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),A=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),V=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),F=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),R=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),I=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),H=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),B={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."},q={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},D={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"};exports.AdOverlay=({ad:t,timeRemaining:r,canSkip:s,onSkip:n,onClick:l})=>{const a=s?"Skip Ad":`Skip in ${Math.ceil(r)}s`;return e.jsxs("div",{className:"plex-video-player__ad-overlay",onClick:l,children:[e.jsxs("div",{className:"plex-video-player__ad-info",children:[e.jsx("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e.jsxs("span",{children:[u(r)," remaining"]})]}),t.clickThrough&&e.jsxs("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),l()},type:"button",children:[e.jsx(I,{size:16}),"Learn More"]}),e.jsx("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),s&&n()},disabled:!s,type:"button",children:a})]})},exports.CaptionsIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.CheckIcon=H,exports.ErrorDisplay=({error:t,onRetry:r})=>{const s=t?.code||0,n=B[s]||"An unknown error occurred.";return e.jsxs("div",{className:"plex-video-player__error",children:[e.jsx(R,{className:"plex-video-player__error-icon",size:60}),e.jsx("div",{className:"plex-video-player__error-message",children:n}),s>0&&e.jsxs("div",{className:"plex-video-player__error-code",children:["Error Code: ",s]}),e.jsx("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},exports.ErrorIcon=R,exports.ExternalLinkIcon=I,exports.ForwardIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),exports.FullscreenExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),exports.FullscreenIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),exports.Loader=({visible:t})=>t?e.jsx("div",{className:"plex-video-player__loader",children:e.jsx("div",{className:"plex-video-player__loader-spinner"})}):null,exports.PauseIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),exports.PipExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.PipIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.PlayIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),exports.PlexVideoPlayer=S,exports.ProgressBar=({currentTime:r,duration:s,buffered:n,onSeek:l,thumbnailPreview:a,disabled:i=!1})=>{const c=t.useRef(null),[o,p]=t.useState(!1),[m,v]=t.useState(null),[x,g]=t.useState(0),f=d(r,s),w=d(n,s),b=t.useCallback(e=>{if(!c.current)return 0;const t=c.current.getBoundingClientRect();return h((e-t.left)/t.width,0,1)*s},[s]),y=t.useCallback(e=>{if(!c.current)return;const t=c.current.getBoundingClientRect(),r="clientX"in e?e.clientX:0,s=h(r-t.left,0,t.width),n=b(r);g(s),v(n),o&&l(n)},[o,b,l]),k=t.useCallback(e=>{if(i)return;e.preventDefault(),p(!0);const t=b(e.clientX);l(t)},[i,b,l]),j=t.useCallback(()=>{p(!1)},[]),C=t.useCallback(e=>{const t=b(e.clientX);v(t)},[b]),N=t.useCallback(()=>{v(null)},[]);t.useEffect(()=>{if(o){const e=e=>y(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",j)}}},[o,y,j]);const E=t.useCallback(e=>{if(i)return;e.preventDefault();const t=e.touches[0],r=b(t.clientX);p(!0),l(r)},[i,b,l]),z=t.useCallback(e=>{if(!o)return;const t=e.touches[0],r=b(t.clientX);l(r)},[o,b,l]),M=t.useCallback(()=>{p(!1)},[]);return e.jsxs("div",{ref:c,className:"plex-video-player__progress-container",onMouseDown:k,onMouseEnter:C,onMouseLeave:N,onMouseMove:e=>y(e.nativeEvent),onTouchStart:E,onTouchMove:z,onTouchEnd:M,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":r,"aria-valuetext":u(r),tabIndex:0,children:[e.jsxs("div",{className:"plex-video-player__progress",children:[e.jsx("div",{className:"plex-video-player__progress-buffered",style:{width:`${w}%`}}),e.jsx("div",{className:"plex-video-player__progress-played",style:{width:`${f}%`}}),e.jsx("div",{className:"plex-video-player__progress-handle",style:{left:`${f}%`}})]}),a?.enabled&&null!==m&&e.jsxs("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:a.width||160,height:a.height||90},children:[a.sprites&&e.jsx("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${a.sprites})`,backgroundPosition:_(m,s,a.interval||10,a.width||160,a.height||90),backgroundSize:"cover"}}),e.jsx("div",{className:"plex-video-player__thumbnail-time",children:u(m)})]}),null!==m&&!a?.enabled&&e.jsx("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:"auto",height:"auto",padding:"4px 8px"},children:e.jsx("span",{style:{color:"white",fontSize:"12px"},children:u(m)})})]})},exports.QualityIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.RewindIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),exports.SettingsIcon=F,exports.SettingsMenu=({playbackRate:r,playbackSpeeds:s,onPlaybackRateChange:n,qualityEnabled:l,sources:a,currentQuality:i,onQualityChange:c,captionsEnabled:o,textTracks:u,currentTrack:d,onTrackChange:h})=>{const[p,m]=t.useState(!1),[v,x]=t.useState("main"),g=t.useRef(null);t.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(m(!1),x("main"))};if(p)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const f=t.useCallback(()=>{m(e=>!e),x("main")},[]),w=t.useCallback(e=>{n(e),x("main")},[n]),b=t.useCallback(e=>{c?.(e),x("main")},[c]),y=t.useCallback(e=>{h?.(e),x("main")},[h]);return e.jsxs("div",{className:"plex-video-player__settings-container",ref:g,children:[e.jsx("button",{className:"plex-video-player__btn",onClick:f,"aria-label":"Settings","aria-expanded":p,title:"Settings",type:"button",children:e.jsx(F,{})}),p&&e.jsxs("div",{className:"plex-video-player__settings-menu "+(p?"plex-video-player__settings-menu--open":""),children:["main"===v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"plex-video-player__settings-title",children:"Settings"}),e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[e.jsx("span",{children:"Playback Speed"}),e.jsx("span",{children:1===r?"Normal":`${r}x`})]}),l&&a&&a.length>1&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("quality"),type:"button",children:[e.jsx("span",{children:"Quality"}),e.jsx("span",{children:i||"Auto"})]}),o&&u&&u.length>0&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("captions"),type:"button",children:[e.jsx("span",{children:"Captions"}),e.jsx("span",{children:d||"Off"})]})]}),"speed"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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"}),e.jsx("div",{className:"plex-video-player__speed-menu",children:s.map(t=>e.jsx("button",{className:"plex-video-player__speed-btn "+(r===t?"plex-video-player__speed-btn--active":""),onClick:()=>w(t),type:"button",children:1===t?"Normal":`${t}x`},t))})]}),"quality"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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"}),e.jsx("div",{className:"plex-video-player__quality-menu",children:a?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(i===t.quality?"plex-video-player__settings-item--active":""),onClick:()=>b(t.quality||t.src),type:"button",children:[e.jsx("span",{children:t.label||t.quality||"Unknown"}),i===t.quality&&e.jsx(H,{size:16})]},t.quality||t.src))})]}),"captions"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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.jsxs("div",{className:"plex-video-player__quality-menu",children:[e.jsxs("button",{className:"plex-video-player__settings-item "+(d?"":"plex-video-player__settings-item--active"),onClick:()=>y(null),type:"button",children:[e.jsx("span",{children:"Off"}),!d&&e.jsx(H,{size:16})]}),u?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(d===t.srclang?"plex-video-player__settings-item--active":""),onClick:()=>y(t.srclang),type:"button",children:[e.jsx("span",{children:t.label}),d===t.srclang&&e.jsx(H,{size:16})]},t.srclang))]})]})]})]})},exports.SkipNextIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),exports.SkipPrevIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),exports.SpeedIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.VolumeControl=({volume:r,muted:s,onVolumeChange:n,onToggleMute:l})=>{const a=t.useCallback(e=>{const t=parseFloat(e.target.value);n(t)},[n]);return e.jsxs("div",{className:"plex-video-player__volume-container",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:l,"aria-label":s?"Unmute":"Mute",title:s?"Unmute (M)":"Mute (M)",type:"button",children:s||0===r?e.jsx(V,{}):r<.33?e.jsx(A,{}):r<.66?e.jsx(T,{}):e.jsx(L,{})}),e.jsx("div",{className:"plex-video-player__volume-slider-container",children:e.jsx("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:s?0:r,onChange:a,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(s?0:r)}%, var(--plex-progress-bg) ${100*(s?0:r)}%, var(--plex-progress-bg) 100%)`}})})]})},exports.VolumeHighIcon=L,exports.VolumeLowIcon=A,exports.VolumeMediumIcon=T,exports.VolumeMuteIcon=V,exports.canPlayType=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},exports.clamp=h,exports.convertToAdInfo=c,exports.debounce=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},exports.default=S,exports.detectVideoType=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"},exports.exitFullscreen=g,exports.fetchVastAd=n,exports.fireTrackingPixel=a,exports.fireTrackingPixels=i,exports.formatTime=u,exports.generateId=()=>`plex-${Math.random().toString(36).substring(2,11)}`,exports.getBufferedEnd=f,exports.getFullscreenElement=v,exports.isFullscreenSupported=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),exports.isHlsNativelySupported=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),exports.isMobile=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),exports.isPipSupported=m,exports.isTouchDevice=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,exports.parseTime=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},exports.parseVastXml=r,exports.percentage=d,exports.requestFullscreen=x,exports.selectBestMediaFile=l,exports.throttle=p,exports.useKeyboard=({enabled:e,hotkeys:r={},onPlay:s,onMute:n,onFullscreen:l,onPip:a,onSeek:i,onVolume:c,containerRef:o})=>{const u={...D,...r},d=t.useCallback(t=>{if(!e)return;const r=t.target;if("INPUT"===r.tagName||"TEXTAREA"===r.tagName||r.isContentEditable)return;const d=o.current;if(!d||!d.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),s();break;case u.mute:case"M":t.preventDefault(),n();break;case u.fullscreen:case"F":t.preventDefault(),l();break;case u.pip:case"P":t.preventDefault(),a();break;case u.seekForward:t.preventDefault(),i(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),i(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(),i(-1/0)}},[e,u,s,n,l,a,i,c,o]);t.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[e,d])},exports.usePlayer=(e={})=>{const{autoPlay:r=!1,muted:s=!1,loop:n=!1,volume:l=1,playbackRate:a=1}=e,i=t.useRef(null),c=t.useRef(null),[o,u]=t.useState({...q,volume:l,isMuted:s,playbackRate:a}),d=t.useCallback(e=>{u(t=>({...t,...e}))},[]),h=t.useCallback(async()=>{const e=i.current;if(e)try{await e.play(),d({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[d]),p=t.useCallback(()=>{const e=i.current;e&&(e.pause(),d({isPlaying:!1,isPaused:!0}))},[d]),w=t.useCallback(()=>{o.isPlaying?p():h()},[o.isPlaying,h,p]),b=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(e,t.duration||0));t.currentTime=r,d({currentTime:r})},[d]),y=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,d({volume:r,isMuted:0===r})},[d]),k=t.useCallback(()=>{const e=i.current;e&&(e.muted=!e.muted,d({isMuted:e.muted}))},[d]),j=t.useCallback(e=>{const t=i.current;t&&(t.playbackRate=e,d({playbackRate:e}))},[d]),C=t.useCallback(async()=>{const e=c.current;if(e)try{await x(e),d({isFullscreen:!0})}catch(e){}},[d]),N=t.useCallback(async()=>{try{await g(),d({isFullscreen:!1})}catch(e){}},[d]),E=t.useCallback(async()=>{o.isFullscreen?await N():await C()},[o.isFullscreen,C,N]),z=t.useCallback(async()=>{const e=i.current;if(e&&m())try{await e.requestPictureInPicture(),d({isPip:!0})}catch(e){}},[d]),M=t.useCallback(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),d({isPip:!1})}catch(e){}},[d]),P=t.useCallback(async()=>{o.isPip?await M():await z()},[o.isPip,z,M]);return t.useEffect(()=>{const e=i.current;if(!e)return;e.muted=s,e.volume=l,e.playbackRate=a,e.loop=n;const t={loadedmetadata:()=>{d({duration:e.duration})},timeupdate:()=>{d({currentTime:e.currentTime,buffered:f(e)})},play:()=>{d({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{d({isPlaying:!1,isPaused:!0})},ended:()=>{d({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{d({isBuffering:!0})},canplay:()=>{d({isBuffering:!1})},seeking:()=>{d({isSeeking:!0})},seeked:()=>{d({isSeeking:!1})},volumechange:()=>{d({volume:e.volume,isMuted:e.muted})},ratechange:()=>{d({playbackRate:e.playbackRate})},error:()=>{d({error:e.error})},enterpictureinpicture:()=>{d({isPip:!0})},leavepictureinpicture:()=>{d({isPip:!1})}};return Object.entries(t).forEach(([t,r])=>{e.addEventListener(t,r)}),r&&h(),()=>{Object.entries(t).forEach(([t,r])=>{e.removeEventListener(t,r)})}},[r,s,n,l,a,h,d]),t.useEffect(()=>{const e=()=>{const e=!!v();d({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)}},[d]),{state:o,videoRef:i,containerRef:c,play:h,pause:p,togglePlay:w,seek:b,setVolume:y,toggleMute:k,setPlaybackRate:j,enterFullscreen:C,exitFullscreen:N,toggleFullscreen:E,enterPip:z,exitPip:M,togglePip:P}},exports.useVast=o;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const r=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const r=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const n=e.getAttribute("id")||"",l=t.querySelector("AdTitle")?.textContent||"",a=t.querySelector("Description")?.textContent||void 0,i=t.querySelectorAll("Creative");let c,o,u=0;const d=[],h=[],p={};i.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const r=t.querySelector("Duration")?.textContent;r&&(u=s(r));const n=t.getAttribute("skipoffset");n&&(c=s(n));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&h.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const l=t.querySelector("VideoClicks");l&&(o=l.querySelector("ClickThrough")?.textContent?.trim(),l.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&d.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),r=e.textContent?.trim();t&&r&&(p[t]||(p[t]=[]),p[t].push(r))})});const m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),h.length>0&&r.push({id:n,title:l,description:a,duration:u,skipOffset:c,clickThrough:o,clickTracking:d,impressionUrls:m,mediaFiles:h,trackingEvents:p})}),{ads:r}},s=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])},n=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const s=await t.text(),n=r(s);if(n.error||0===n.ads.length)return null;const l=n.ads[0];return void 0!==e.skipDelay&&void 0===l.skipOffset&&(l.skipOffset=e.skipDelay),l}catch(e){return null}},l=e=>{if(0===e.length)return null;const t=document.createElement("video"),r=e.filter(e=>""!==t.canPlayType(e.type));if(0===r.length)return null;r.sort((e,t)=>{const r=e.width*e.height,s=t.width*t.height;return r!==s?s-r:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&r.length>1?r[r.length-1]:r[0]},a=e=>{(new Image).src=e},i=e=>{e.forEach(a)},c=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),o=({vastConfig:e,videoRef:r,onAdStart:s,onAdEnd:a,onAdSkip:o,onAdError:u})=>{const[d,h]=t.useState(!1),[p,m]=t.useState(null),[v,x]=t.useState(0),[g,f]=t.useState(!1),w=t.useRef(null),b=t.useRef(""),y=t.useRef(0),k=t.useRef(new Set),j=t.useRef(null),C=Array.isArray(e)?e:e?[e]:[],N=t.useCallback(async e=>{const t=r.current;if(t&&!d)try{const r=await n(e);if(!r)return void u?.(new Error("Failed to fetch VAST ad"));const a=l(r.mediaFiles);if(!a)return void u?.(new Error("No compatible media file found"));b.current=t.currentSrc,y.current=t.currentTime,i(r.impressionUrls),w.current=r,m(c(r)),h(!0),x(r.duration),f(void 0===r.skipOffset||0===r.skipOffset),t.src=a.url,t.currentTime=0,await t.play(),r.trackingEvents.start&&i(r.trackingEvents.start),s?.(c(r)),j.current=window.setInterval(()=>{const e=Math.max(0,r.duration-t.currentTime);x(e),r.skipOffset&&t.currentTime>=r.skipOffset&&f(!0);const s=t.currentTime/r.duration*100;s>=25&&r.trackingEvents.firstQuartile&&i(r.trackingEvents.firstQuartile),s>=50&&r.trackingEvents.midpoint&&i(r.trackingEvents.midpoint),s>=75&&r.trackingEvents.thirdQuartile&&i(r.trackingEvents.thirdQuartile)},250);const o=()=>{r.trackingEvents.complete&&i(r.trackingEvents.complete),E()};t.addEventListener("ended",o,{once:!0})}catch(e){u?.(e instanceof Error?e:new Error("Ad playback failed")),E()}},[r,d,s,u]),E=t.useCallback(()=>{const e=r.current;e&&(j.current&&(clearInterval(j.current),j.current=null),b.current&&(e.src=b.current,e.currentTime=y.current,e.play().catch(()=>{})),h(!1),m(null),x(0),f(!1),w.current=null,a?.())},[r,a]),z=t.useCallback(()=>{if(!g||!w.current)return;const e=w.current;e.trackingEvents.skip&&i(e.trackingEvents.skip),o?.(),E()},[g,E,o]),M=t.useCallback(()=>{if(!w.current)return;const e=w.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&i(e.clickTracking)},[]),P=t.useCallback((e,t)=>{d||0===C.length||C.forEach(r=>{const s=r.position||"preroll",n=`${s}-${r.midrollTime||0}`;if(k.current.has(n))return;let l=!1;switch(s){case"preroll":l=0===e;break;case"midroll":r.midrollTime&&e>=r.midrollTime&&(l=!0);break;case"postroll":l=e>=t-.5}l&&(k.current.add(n),N(r))})},[C,d,N]);return t.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]),{isAdPlaying:d,currentAd:p,adTimeRemaining:v,canSkip:g,skipAd:z,handleAdClick:M,checkForAd:P}},u=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),r=Math.floor(e%3600/60),s=Math.floor(e%60);return t>0?`${t}:${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${r}:${s.toString().padStart(2,"0")}`},d=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),h=(e,t,r)=>Math.min(r,Math.max(t,e)),p=(e,t)=>{let r=!1;return(...s)=>{r||(e(...s),r=!0,setTimeout(()=>r=!1,t))}},m=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,v=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,x=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},g=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},f=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let r=0;r<e.buffered.length;r++)if(e.buffered.start(r)<=t&&e.buffered.end(r)>=t)return e.buffered.end(r);return e.buffered.end(e.buffered.length-1)},w=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),b=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),y=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),k=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),j=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),C=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),N=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),E=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("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"})}),z=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),M=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("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"})}),P=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("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"})}),S=t.forwardRef((r,s)=>{const{src:n,poster:l,autoPlay:a=!1,muted:i=!1,loop:c=!1,controls:d=!0,width:h="100%",className:m="",style:v={},pip:x=!0,fullscreen:g=!0,playbackSpeed:f=!0,playbackSpeeds:S=[.5,.75,1,1.25,1.5,2],volume:_=!0,initialVolume:L=1,textTracks:T=[],vast:A,accentColor:V="#f5c518",controlsTimeout:F=3e3,doubleClickFullscreen:R=!0,clickToPlay:I=!0,preload:H="metadata",playlist:B=[],onPlay:q,onPause:D,onEnded:$,onTimeUpdate:O,onProgress:U,onVolumeChange:Q,onFullscreenChange:X,onPipChange:K,onQualityChange:G,onError:Y,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee,onReady:te,onPlaylistItemChange:re}=r,se=t.useRef(null),ne=t.useRef(null),le=t.useRef(null),ae=t.useRef(null),ie=t.useRef(0),[ce,oe]=t.useState(!1),[ue,de]=t.useState(0),[he,pe]=t.useState(0),[me,ve]=t.useState(0),[xe,ge]=t.useState(i?0:L),[fe,we]=t.useState(i),[be,ye]=t.useState(!1),[ke,je]=t.useState(!1),[Ce,Ne]=t.useState(!0),[Ee,ze]=t.useState(null),[Me,Pe]=t.useState(!0),[Se,_e]=t.useState(1),[Le,Te]=t.useState(c),[Ae,Ve]=t.useState(!1),[Fe,Re]=t.useState({x:0,y:0,visible:!1}),[Ie,He]=t.useState(0),Be=t.useMemo(()=>"string"==typeof n?[{src:n,type:"video/mp4"}]:n,[n]),qe=t.useMemo(()=>B.length>0&&B[Ie]?B[Ie].src:Be[0]?.src||"",[B,Ie,Be]),De=t.useMemo(()=>B.length>0&&B[Ie]?.poster?B[Ie].poster:l,[B,Ie,l]),{currentAd:$e,isAdPlaying:Oe,adTimeRemaining:Ue,canSkip:Qe,skipAd:Xe,handleAdClick:Ke,checkForAd:Ge}=o({vastConfig:A,videoRef:se,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee}),Ye=t.useCallback(async()=>{const e=se.current;if(e)try{await e.play()}catch(e){}},[]),Je=t.useCallback(()=>{se.current?.pause()},[]),We=t.useCallback(()=>{const e=se.current;e&&(e.pause(),e.currentTime=0)},[]),Ze=t.useCallback(()=>{se.current?.paused?Ye():Je()},[Ye,Je]),et=t.useCallback(e=>{const t=se.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),tt=t.useCallback(e=>{const t=se.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,ge(r),we(0===r)},[]),rt=t.useCallback(()=>{se.current&&(se.current.muted=!0,we(!0))},[]),st=t.useCallback(()=>{const e=se.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,ge(.5)),we(!1))},[]),nt=t.useCallback(()=>{se.current?.muted?st():rt()},[rt,st]),lt=t.useCallback(()=>{se.current&&(se.current.loop=!se.current.loop,Te(se.current.loop))},[]),at=t.useCallback(async()=>{try{await(ne.current?.requestFullscreen()),ye(!0)}catch(e){}},[]),it=t.useCallback(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),ye(!1))}catch(e){}},[]),ct=t.useCallback(async()=>{document.fullscreenElement?await it():await at()},[at,it]),ot=t.useCallback(async()=>{try{await(se.current?.requestPictureInPicture()),je(!0)}catch(e){}},[]),ut=t.useCallback(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),je(!1))}catch(e){}},[]),dt=t.useCallback(async()=>{document.pictureInPictureElement?await ut():await ot()},[ot,ut]),ht=t.useCallback(e=>{se.current&&(se.current.playbackRate=e,_e(e),Ve(!1))},[]),pt=t.useCallback(e=>{const t=Be.find(t=>t.label===e||t.quality===e);if(t&&se.current){const r=se.current,s=!r.paused,n=r.currentTime;r.src=t.src,r.currentTime=n,s&&r.play(),G?.(e)}},[Be,G]),mt=t.useCallback(()=>{if(0===B.length)return;const e=(Ie+1)%B.length;He(e),re?.(e,B[e]),setTimeout(()=>Ye(),100)},[Ie,B,re,Ye]),vt=t.useCallback(e=>{e.preventDefault();const t=ne.current?.getBoundingClientRect();t&&Re({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),xt=t.useCallback(()=>{Re(e=>({...e,visible:!1}))},[]),gt=t.useCallback(()=>{navigator.clipboard.writeText(qe),xt()},[qe,xt]),ft=t.useCallback(e=>{const t=le.current?.getBoundingClientRect();if(t&&he){const r=(e.clientX-t.left)/t.width;et(r*he)}},[he,et]),wt=t.useCallback(()=>{ce&&!Ae&&Pe(!1)},[ce,Ae]),bt=t.useCallback(()=>{Pe(!0),ae.current&&clearTimeout(ae.current),ce&&(ae.current=setTimeout(wt,F))},[ce,F,wt]),yt=t.useMemo(()=>p(bt,200),[bt]),kt=t.useCallback(()=>{if(xt(),!I)return;const e=Date.now();R&&e-ie.current<300?ct():Ze(),ie.current=e},[I,R,Ze,ct,xt]);t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{oe(!0),q?.()},r=()=>{oe(!1),D?.()},s=()=>{oe(!1),$?.(),B.length>0&&mt()},n=()=>{de(e.currentTime),O?.(e.currentTime),Ge(e.currentTime,e.duration)},l=()=>pe(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);ve(t/e.duration*100),U?.(t/e.duration*100)}},i=()=>{ge(e.volume),we(e.muted),Q?.(e.volume,e.muted)},c=()=>{pe(e.duration),Ne(!1),te?.()},o=()=>Ne(!0),u=()=>Ne(!1),d=()=>Ne(!1),h=()=>{ze(e.error),Ne(!1),Y?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",s),e.addEventListener("timeupdate",n),e.addEventListener("durationchange",l),e.addEventListener("progress",a),e.addEventListener("volumechange",i),e.addEventListener("loadedmetadata",c),e.addEventListener("waiting",o),e.addEventListener("playing",u),e.addEventListener("canplay",d),e.addEventListener("error",h),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",r),e.removeEventListener("ended",s),e.removeEventListener("timeupdate",n),e.removeEventListener("durationchange",l),e.removeEventListener("progress",a),e.removeEventListener("volumechange",i),e.removeEventListener("loadedmetadata",c),e.removeEventListener("waiting",o),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",h)}},[q,D,$,O,U,Q,te,Y,Ge,B.length,mt]),t.useEffect(()=>{const e=()=>{const e=!!document.fullscreenElement;ye(e),X?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[X]),t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{je(!0),K?.(!0)},r=()=>{je(!1),K?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",r),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",r)}},[K]),t.useEffect(()=>{const e=e=>{if(ne.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),Ze();break;case"m":e.preventDefault(),nt();break;case"f":e.preventDefault(),ct();break;case"ArrowLeft":e.preventDefault(),et(ue-10);break;case"ArrowRight":e.preventDefault(),et(ue+10);break;case"ArrowUp":e.preventDefault(),tt(xe+.1);break;case"ArrowDown":e.preventDefault(),tt(xe-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Ze,nt,ct,et,tt,ue,xe]),t.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]),t.useEffect(()=>{const e=()=>xt();if(Fe.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Fe.visible,xt]),t.useImperativeHandle(s,()=>({play:Ye,pause:Je,stop:We,seek:et,setVolume:tt,mute:rt,unmute:st,toggleMute:nt,enterFullscreen:at,exitFullscreen:it,toggleFullscreen:ct,enterPip:ot,exitPip:ut,togglePip:dt,setPlaybackRate:ht,setQuality:pt,getCurrentTime:()=>se.current?.currentTime||0,getDuration:()=>se.current?.duration||0,getVolume:()=>se.current?.volume||0,isMuted:()=>se.current?.muted??!0,isPlaying:()=>!se.current?.paused,isFullscreen:()=>be,isPip:()=>ke,getVideoElement:()=>se.current}),[Ye,Je,We,et,tt,rt,st,nt,at,it,ct,ot,ut,dt,ht,pt,be,ke]);const jt=he?ue/he*100:0;return e.jsxs("div",{ref:ne,className:`relative bg-black overflow-hidden select-none ${be?"fixed inset-0 z-[9999]":""} ${m}`,style:{width:h,aspectRatio:be?"unset":"16/9","--accent":V,...v},onMouseMove:yt,onMouseLeave:()=>ce&&Pe(!1),onContextMenu:vt,tabIndex:0,children:[e.jsx("video",{ref:se,className:"w-full h-full object-contain",src:qe,poster:De,autoPlay:a,muted:i,loop:Le,preload:H,playsInline:!0,onClick:kt,children:T.map((t,r)=>e.jsx("track",{kind:t.kind,src:t.src,srcLang:t.srclang,label:t.label,default:t.default},r))}),Ce&&!Ee&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"w-12 h-12 border-4 border-transparent rounded-full animate-spin",style:{borderTopColor:V}})}),Ee&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/90 text-white",children:[e.jsx("svg",{className:"w-16 h-16 mb-4",fill:V,viewBox:"0 0 24 24",children:e.jsx("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"})}),e.jsx("p",{className:"text-lg mb-2",children:"Error loading video"}),e.jsx("button",{className:"px-6 py-2 rounded text-black font-medium",style:{backgroundColor:V},onClick:()=>{ze(null),se.current?.load()},children:"Retry"})]}),Oe&&$e&&e.jsxs("div",{className:"absolute inset-0 z-20",children:[e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-3 px-3 py-2 bg-black/70 rounded text-white text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-bold",style:{backgroundColor:V,color:"#000"},children:"AD"}),e.jsxs("span",{children:[u(Ue)," remaining"]})]}),e.jsx("button",{className:"absolute bottom-20 right-4 px-5 py-2 border border-white rounded text-white "+(Qe?"hover:bg-white hover:text-black cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:Qe?Xe:void 0,disabled:!Qe,children:Qe?"Skip Ad":`Skip in ${Math.ceil(Ue)}s`})]}),Fe.visible&&e.jsxs("div",{className:"absolute z-50 min-w-[200px] bg-[#1a1a1a]/95 backdrop-blur-md rounded-lg shadow-xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{left:Fe.x,top:Fe.y},onClick:e=>e.stopPropagation(),children:[e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{Ze(),xt()},children:[ce?e.jsx(b,{}):e.jsx(w,{}),e.jsx("span",{className:"flex-1 text-left",children:ce?"Pause":"Play"}),e.jsx("span",{className:"text-white/50 text-xs",children:"Space"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{nt(),xt()},children:[fe?e.jsx(k,{}):e.jsx(y,{}),e.jsx("span",{className:"flex-1 text-left",children:fe?"Unmute":"Mute"}),e.jsx("span",{className:"text-white/50 text-xs",children:"M"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{lt(),xt()},children:[e.jsx(z,{}),e.jsx("span",{className:"flex-1 text-left",children:Le?"Disable Loop":"Enable Loop"}),Le&&e.jsx("span",{style:{color:V},children:"✓"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(Se);ht(e[(t+1)%e.length]),xt()},children:[e.jsx(P,{}),e.jsxs("span",{className:"flex-1 text-left",children:["Speed: ",Se,"x"]})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),x&&document.pictureInPictureEnabled&&e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{dt(),xt()},children:[e.jsx(N,{}),e.jsx("span",{className:"flex-1 text-left",children:"Picture in Picture"}),e.jsx("span",{className:"text-white/50 text-xs",children:"P"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{ct(),xt()},children:[e.jsx(j,{}),e.jsx("span",{className:"flex-1 text-left",children:"Fullscreen"}),e.jsx("span",{className:"text-white/50 text-xs",children:"F"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:gt,children:[e.jsx(M,{}),e.jsx("span",{className:"flex-1 text-left",children:"Copy Video URL"})]}),e.jsx("div",{className:"px-4 py-2 text-[10px] text-white/40 text-center border-t border-white/10",children:"PlexVideo Player © FRAMESET STUDIO"})]}),d&&!Oe&&e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent p-4 transition-opacity duration-300 "+(Me?"opacity-100":"opacity-0 pointer-events-none"),children:[e.jsxs("div",{ref:le,className:"relative h-[6px] bg-white/30 rounded-full mb-4 cursor-pointer group hover:h-[10px] transition-all",onClick:ft,children:[e.jsx("div",{className:"absolute top-0 left-0 h-full bg-white/40 rounded-full transition-all",style:{width:`${me}%`}}),e.jsx("div",{className:"absolute top-0 left-0 h-full rounded-full transition-all",style:{width:`${jt}%`,backgroundColor:V}}),e.jsx("div",{className:"absolute top-1/2 w-4 h-4 rounded-full scale-0 group-hover:scale-100 transition-transform shadow-lg",style:{left:`${jt}%`,transform:"translate(-50%, -50%)",backgroundColor:V}})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"w-10 h-10 flex items-center justify-center rounded-full hover:bg-white/10 text-white transition-colors",onClick:Ze,"aria-label":ce?"Pause":"Play",children:ce?e.jsx(b,{}):e.jsx(w,{})}),_&&e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:nt,"aria-label":fe?"Unmute":"Mute",children:fe||0===xe?e.jsx(k,{}):e.jsx(y,{})}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:fe?0:xe,onChange:e=>tt(parseFloat(e.target.value)),className:"w-0 group-hover:w-20 h-1 rounded-full appearance-none cursor-pointer transition-all overflow-hidden",style:{background:`linear-gradient(to right, ${V} 0%, ${V} ${100*(fe?0:xe)}%, rgba(255,255,255,0.3) ${100*(fe?0:xe)}%)`}})]}),e.jsxs("div",{className:"text-white text-sm font-mono ml-2",children:[u(ue)," / ",u(he)]}),e.jsx("div",{className:"flex-1"}),f&&e.jsxs("div",{className:"relative",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:()=>Ve(!Ae),"aria-label":"Settings",children:e.jsx(E,{})}),Ae&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-3 min-w-[160px] bg-[#1a1a1a] backdrop-blur-md rounded-lg shadow-2xl overflow-hidden z-[100] border border-white/10",children:[e.jsx("div",{className:"px-4 py-2 text-white/60 text-xs font-semibold uppercase tracking-wide border-b border-white/10",children:"Playback Speed"}),S.map(t=>e.jsxs("button",{className:"w-full px-4 py-2.5 text-left text-sm hover:bg-white/10 transition-colors flex items-center justify-between "+(Se===t?"":"text-white"),style:Se===t?{color:V}:{},onClick:()=>ht(t),children:[e.jsx("span",{children:1===t?"Normal":`${t}x`}),Se===t&&e.jsx("span",{children:"✓"})]},t))]})]}),x&&document.pictureInPictureEnabled&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:dt,"aria-label":"Picture in Picture",children:e.jsx(N,{})}),g&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:ct,"aria-label":be?"Exit Fullscreen":"Fullscreen",children:be?e.jsx(C,{}):e.jsx(j,{})})]})]}),!ce&&!Ce&&!Ee&&!Oe&&e.jsx("button",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-20 h-20 rounded-full flex items-center justify-center hover:scale-110 transition-transform shadow-2xl",style:{backgroundColor:V},onClick:Ze,"aria-label":"Play",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"white",className:"w-8 h-8 ml-1",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})]})});S.displayName="PlexVideoPlayer";const _=(e,t,r,s,n)=>{const l=Math.floor(e/r);return`-${l%10*s}px -${Math.floor(l/10)*n}px`},L=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),T=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),A=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),V=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),F=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),R=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),I=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),H=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),B={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."},q={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},D={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"};exports.AdOverlay=({ad:t,timeRemaining:r,canSkip:s,onSkip:n,onClick:l})=>{const a=s?"Skip Ad":`Skip in ${Math.ceil(r)}s`;return e.jsxs("div",{className:"plex-video-player__ad-overlay",onClick:l,children:[e.jsxs("div",{className:"plex-video-player__ad-info",children:[e.jsx("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e.jsxs("span",{children:[u(r)," remaining"]})]}),t.clickThrough&&e.jsxs("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),l()},type:"button",children:[e.jsx(I,{size:16}),"Learn More"]}),e.jsx("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),s&&n()},disabled:!s,type:"button",children:a})]})},exports.CaptionsIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.CheckIcon=H,exports.ErrorDisplay=({error:t,onRetry:r})=>{const s=t?.code||0,n=B[s]||"An unknown error occurred.";return e.jsxs("div",{className:"plex-video-player__error",children:[e.jsx(R,{className:"plex-video-player__error-icon",size:60}),e.jsx("div",{className:"plex-video-player__error-message",children:n}),s>0&&e.jsxs("div",{className:"plex-video-player__error-code",children:["Error Code: ",s]}),e.jsx("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},exports.ErrorIcon=R,exports.ExternalLinkIcon=I,exports.ForwardIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),exports.FullscreenExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),exports.FullscreenIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),exports.Loader=({visible:t})=>t?e.jsx("div",{className:"plex-video-player__loader",children:e.jsx("div",{className:"plex-video-player__loader-spinner"})}):null,exports.PauseIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),exports.PipExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.PipIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.PlayIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),exports.PlexVideoPlayer=S,exports.ProgressBar=({currentTime:r,duration:s,buffered:n,onSeek:l,thumbnailPreview:a,disabled:i=!1})=>{const c=t.useRef(null),[o,p]=t.useState(!1),[m,v]=t.useState(null),[x,g]=t.useState(0),f=d(r,s),w=d(n,s),b=t.useCallback(e=>{if(!c.current)return 0;const t=c.current.getBoundingClientRect();return h((e-t.left)/t.width,0,1)*s},[s]),y=t.useCallback(e=>{if(!c.current)return;const t=c.current.getBoundingClientRect(),r="clientX"in e?e.clientX:0,s=h(r-t.left,0,t.width),n=b(r);g(s),v(n),o&&l(n)},[o,b,l]),k=t.useCallback(e=>{if(i)return;e.preventDefault(),p(!0);const t=b(e.clientX);l(t)},[i,b,l]),j=t.useCallback(()=>{p(!1)},[]),C=t.useCallback(e=>{const t=b(e.clientX);v(t)},[b]),N=t.useCallback(()=>{v(null)},[]);t.useEffect(()=>{if(o){const e=e=>y(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",j)}}},[o,y,j]);const E=t.useCallback(e=>{if(i)return;e.preventDefault();const t=e.touches[0],r=b(t.clientX);p(!0),l(r)},[i,b,l]),z=t.useCallback(e=>{if(!o)return;const t=e.touches[0],r=b(t.clientX);l(r)},[o,b,l]),M=t.useCallback(()=>{p(!1)},[]);return e.jsxs("div",{ref:c,className:"plex-video-player__progress-container",onMouseDown:k,onMouseEnter:C,onMouseLeave:N,onMouseMove:e=>y(e.nativeEvent),onTouchStart:E,onTouchMove:z,onTouchEnd:M,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":r,"aria-valuetext":u(r),tabIndex:0,children:[e.jsxs("div",{className:"plex-video-player__progress",children:[e.jsx("div",{className:"plex-video-player__progress-buffered",style:{width:`${w}%`}}),e.jsx("div",{className:"plex-video-player__progress-played",style:{width:`${f}%`}}),e.jsx("div",{className:"plex-video-player__progress-handle",style:{left:`${f}%`}})]}),a?.enabled&&null!==m&&e.jsxs("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:a.width||160,height:a.height||90},children:[a.sprites&&e.jsx("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${a.sprites})`,backgroundPosition:_(m,s,a.interval||10,a.width||160,a.height||90),backgroundSize:"cover"}}),e.jsx("div",{className:"plex-video-player__thumbnail-time",children:u(m)})]}),null!==m&&!a?.enabled&&e.jsx("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:"auto",height:"auto",padding:"4px 8px"},children:e.jsx("span",{style:{color:"white",fontSize:"12px"},children:u(m)})})]})},exports.QualityIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.RewindIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),exports.SettingsIcon=F,exports.SettingsMenu=({playbackRate:r,playbackSpeeds:s,onPlaybackRateChange:n,qualityEnabled:l,sources:a,currentQuality:i,onQualityChange:c,captionsEnabled:o,textTracks:u,currentTrack:d,onTrackChange:h})=>{const[p,m]=t.useState(!1),[v,x]=t.useState("main"),g=t.useRef(null);t.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(m(!1),x("main"))};if(p)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const f=t.useCallback(()=>{m(e=>!e),x("main")},[]),w=t.useCallback(e=>{n(e),x("main")},[n]),b=t.useCallback(e=>{c?.(e),x("main")},[c]),y=t.useCallback(e=>{h?.(e),x("main")},[h]);return e.jsxs("div",{className:"plex-video-player__settings-container",ref:g,children:[e.jsx("button",{className:"plex-video-player__btn",onClick:f,"aria-label":"Settings","aria-expanded":p,title:"Settings",type:"button",children:e.jsx(F,{})}),p&&e.jsxs("div",{className:"plex-video-player__settings-menu "+(p?"plex-video-player__settings-menu--open":""),children:["main"===v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"plex-video-player__settings-title",children:"Settings"}),e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[e.jsx("span",{children:"Playback Speed"}),e.jsx("span",{children:1===r?"Normal":`${r}x`})]}),l&&a&&a.length>1&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("quality"),type:"button",children:[e.jsx("span",{children:"Quality"}),e.jsx("span",{children:i||"Auto"})]}),o&&u&&u.length>0&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("captions"),type:"button",children:[e.jsx("span",{children:"Captions"}),e.jsx("span",{children:d||"Off"})]})]}),"speed"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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"}),e.jsx("div",{className:"plex-video-player__speed-menu",children:s.map(t=>e.jsx("button",{className:"plex-video-player__speed-btn "+(r===t?"plex-video-player__speed-btn--active":""),onClick:()=>w(t),type:"button",children:1===t?"Normal":`${t}x`},t))})]}),"quality"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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"}),e.jsx("div",{className:"plex-video-player__quality-menu",children:a?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(i===t.quality?"plex-video-player__settings-item--active":""),onClick:()=>b(t.quality||t.src),type:"button",children:[e.jsx("span",{children:t.label||t.quality||"Unknown"}),i===t.quality&&e.jsx(H,{size:16})]},t.quality||t.src))})]}),"captions"===v&&e.jsxs(e.Fragment,{children:[e.jsx("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.jsxs("div",{className:"plex-video-player__quality-menu",children:[e.jsxs("button",{className:"plex-video-player__settings-item "+(d?"":"plex-video-player__settings-item--active"),onClick:()=>y(null),type:"button",children:[e.jsx("span",{children:"Off"}),!d&&e.jsx(H,{size:16})]}),u?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(d===t.srclang?"plex-video-player__settings-item--active":""),onClick:()=>y(t.srclang),type:"button",children:[e.jsx("span",{children:t.label}),d===t.srclang&&e.jsx(H,{size:16})]},t.srclang))]})]})]})]})},exports.SkipNextIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),exports.SkipPrevIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),exports.SpeedIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("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"})}),exports.VolumeControl=({volume:r,muted:s,onVolumeChange:n,onToggleMute:l})=>{const a=t.useCallback(e=>{const t=parseFloat(e.target.value);n(t)},[n]);return e.jsxs("div",{className:"plex-video-player__volume-container",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:l,"aria-label":s?"Unmute":"Mute",title:s?"Unmute (M)":"Mute (M)",type:"button",children:s||0===r?e.jsx(V,{}):r<.33?e.jsx(A,{}):r<.66?e.jsx(T,{}):e.jsx(L,{})}),e.jsx("div",{className:"plex-video-player__volume-slider-container",children:e.jsx("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:s?0:r,onChange:a,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(s?0:r)}%, var(--plex-progress-bg) ${100*(s?0:r)}%, var(--plex-progress-bg) 100%)`}})})]})},exports.VolumeHighIcon=L,exports.VolumeLowIcon=A,exports.VolumeMediumIcon=T,exports.VolumeMuteIcon=V,exports.canPlayType=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},exports.clamp=h,exports.convertToAdInfo=c,exports.debounce=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},exports.default=S,exports.detectVideoType=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"},exports.exitFullscreen=g,exports.fetchVastAd=n,exports.fireTrackingPixel=a,exports.fireTrackingPixels=i,exports.formatTime=u,exports.generateId=()=>`plex-${Math.random().toString(36).substring(2,11)}`,exports.getBufferedEnd=f,exports.getFullscreenElement=v,exports.isFullscreenSupported=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),exports.isHlsNativelySupported=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),exports.isMobile=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),exports.isPipSupported=m,exports.isTouchDevice=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,exports.parseTime=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},exports.parseVastXml=r,exports.percentage=d,exports.requestFullscreen=x,exports.selectBestMediaFile=l,exports.throttle=p,exports.useKeyboard=({enabled:e,hotkeys:r={},onPlay:s,onMute:n,onFullscreen:l,onPip:a,onSeek:i,onVolume:c,containerRef:o})=>{const u={...D,...r},d=t.useCallback(t=>{if(!e)return;const r=t.target;if("INPUT"===r.tagName||"TEXTAREA"===r.tagName||r.isContentEditable)return;const d=o.current;if(!d||!d.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),s();break;case u.mute:case"M":t.preventDefault(),n();break;case u.fullscreen:case"F":t.preventDefault(),l();break;case u.pip:case"P":t.preventDefault(),a();break;case u.seekForward:t.preventDefault(),i(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),i(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(),i(-1/0)}},[e,u,s,n,l,a,i,c,o]);t.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[e,d])},exports.usePlayer=(e={})=>{const{autoPlay:r=!1,muted:s=!1,loop:n=!1,volume:l=1,playbackRate:a=1}=e,i=t.useRef(null),c=t.useRef(null),[o,u]=t.useState({...q,volume:l,isMuted:s,playbackRate:a}),d=t.useCallback(e=>{u(t=>({...t,...e}))},[]),h=t.useCallback(async()=>{const e=i.current;if(e)try{await e.play(),d({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[d]),p=t.useCallback(()=>{const e=i.current;e&&(e.pause(),d({isPlaying:!1,isPaused:!0}))},[d]),w=t.useCallback(()=>{o.isPlaying?p():h()},[o.isPlaying,h,p]),b=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(e,t.duration||0));t.currentTime=r,d({currentTime:r})},[d]),y=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,d({volume:r,isMuted:0===r})},[d]),k=t.useCallback(()=>{const e=i.current;e&&(e.muted=!e.muted,d({isMuted:e.muted}))},[d]),j=t.useCallback(e=>{const t=i.current;t&&(t.playbackRate=e,d({playbackRate:e}))},[d]),C=t.useCallback(async()=>{const e=c.current;if(e)try{await x(e),d({isFullscreen:!0})}catch(e){}},[d]),N=t.useCallback(async()=>{try{await g(),d({isFullscreen:!1})}catch(e){}},[d]),E=t.useCallback(async()=>{o.isFullscreen?await N():await C()},[o.isFullscreen,C,N]),z=t.useCallback(async()=>{const e=i.current;if(e&&m())try{await e.requestPictureInPicture(),d({isPip:!0})}catch(e){}},[d]),M=t.useCallback(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),d({isPip:!1})}catch(e){}},[d]),P=t.useCallback(async()=>{o.isPip?await M():await z()},[o.isPip,z,M]);return t.useEffect(()=>{const e=i.current;if(!e)return;e.muted=s,e.volume=l,e.playbackRate=a,e.loop=n;const t={loadedmetadata:()=>{d({duration:e.duration})},timeupdate:()=>{d({currentTime:e.currentTime,buffered:f(e)})},play:()=>{d({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{d({isPlaying:!1,isPaused:!0})},ended:()=>{d({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{d({isBuffering:!0})},canplay:()=>{d({isBuffering:!1})},seeking:()=>{d({isSeeking:!0})},seeked:()=>{d({isSeeking:!1})},volumechange:()=>{d({volume:e.volume,isMuted:e.muted})},ratechange:()=>{d({playbackRate:e.playbackRate})},error:()=>{d({error:e.error})},enterpictureinpicture:()=>{d({isPip:!0})},leavepictureinpicture:()=>{d({isPip:!1})}};return Object.entries(t).forEach(([t,r])=>{e.addEventListener(t,r)}),r&&h(),()=>{Object.entries(t).forEach(([t,r])=>{e.removeEventListener(t,r)})}},[r,s,n,l,a,h,d]),t.useEffect(()=>{const e=()=>{const e=!!v();d({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)}},[d]),{state:o,videoRef:i,containerRef:c,play:h,pause:p,togglePlay:w,seek:b,setVolume:y,toggleMute:k,setPlaybackRate:j,enterFullscreen:C,exitFullscreen:N,toggleFullscreen:E,enterPip:z,exitPip:M,togglePip:P}},exports.useVast=o;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|