strataplayer 1.2.15 → 1.2.18
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.
|
@@ -270,6 +270,7 @@ export declare class StrataCore {
|
|
|
270
270
|
toggleLoop(): void;
|
|
271
271
|
setFlip(direction: 'horizontal' | 'vertical'): void;
|
|
272
272
|
setAspectRatio(ratio: string): void;
|
|
273
|
+
private updateAspectRatio;
|
|
273
274
|
private initCast;
|
|
274
275
|
requestCast(): void;
|
|
275
276
|
private loadMediaToCast;
|
package/dist/strataplayer.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var ts=Object.defineProperty;var ss=(s,t,i)=>t in s?ts(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var
|
|
2
|
-
`),c=[];let h=null,b=null;const j=s.substring(0,s.lastIndexOf("/")+1),g=u=>{const w=u.split(":");let x=0;return w.length===3?(x+=parseFloat(w[0])*3600,x+=parseFloat(w[1])*60,x+=parseFloat(w[2])):(x+=parseFloat(w[0])*60,x+=parseFloat(w[1])),x};for(let u of o)if(u=u.trim(),u.includes("-->")){const w=u.split("-->");h=g(w[0].trim()),b=g(w[1].trim())}else if(h!==null&&b!==null&&u.length>0){let[w,x]=u.split("#");!w.match(/^https?:\/\//)&&!w.startsWith("data:")&&(w=j+w);let C=0,R=0,p=0,D=0;if(x&&x.startsWith("xywh=")){const q=x.replace("xywh=","").split(",");q.length===4&&(C=parseInt(q[0]),R=parseInt(q[1]),p=parseInt(q[2]),D=parseInt(q[3]))}p>0&&D>0&&c.push({start:h,end:b,url:w,x:C,y:R,w:p,h:D}),h=null,b=null}return c}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},ds=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const s=document.createElement("link");s.rel="preconnect",s.href="https://fonts.googleapis.com",document.head.appendChild(s);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const i=document.createElement("link");i.id="strata-fonts",i.rel="stylesheet",i.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(i)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const s=document.createElement("script");s.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(s)}}},Ee={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},St="strata-settings",B={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:Ee,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",isAutoSized:!1,isLooping:!1,controlsVisible:!0},Ct=(s={})=>{let t={};if(!s.disablePersistence&&typeof window<"u")try{const r=localStorage.getItem(St);r&&(t=JSON.parse(r))}catch{}const i={...Ee,...t.subtitleSettings||{},...s.subtitleSettings||{}};return{...B,...t,volume:s.volume??t.volume??B.volume,isMuted:s.muted??t.isMuted??B.isMuted,playbackRate:s.playbackRate??t.playbackRate??B.playbackRate,audioGain:s.audioGain??t.audioGain??B.audioGain,theme:s.theme??t.theme??B.theme,themeColor:s.themeColor??t.themeColor??B.themeColor,iconSize:s.iconSize??t.iconSize??B.iconSize,subtitleSettings:i,isAutoSized:s.autoSize??B.isAutoSized,isLive:s.isLive??t.isLive??B.isLive,isLooping:s.loop??t.isLooping??B.isLooping,sourceStatuses:{}}};class Nt{constructor(t={},i){S(this,"video");S(this,"container",null);S(this,"events");S(this,"store");S(this,"plugins",new Map);S(this,"audioEngine");S(this,"config");S(this,"resizeObserver",null);S(this,"retryCount",0);S(this,"maxRetries",5);S(this,"retryTimer",null);S(this,"currentSource",null);S(this,"currentSrc","");S(this,"currentTracks",[]);S(this,"castInitialized",!1);S(this,"boundCueChange");S(this,"boundFullscreenChange");ds(),this.config=t,this.config.autoOrientation=this.config.autoOrientation??!0,this.config.fetchTimeout=this.config.fetchTimeout??3e4,this.config.centerControls=this.config.centerControls??!0,this.config.gestureSeek=this.config.gestureSeek??!1,this.video=i||document.createElement("video"),this.video.crossOrigin="anonymous",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new rs;const r=Ct(t);this.store=new as(r),this.audioEngine=new os(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const o=!!document.fullscreenElement;if(this.store.setState({isFullscreen:o}),this.emit("resize"),this.emit(o?"fullscreen":"fullscreen_exit"),o&&this.config.autoOrientation&&screen.orientation&&"lock"in screen.orientation){const h=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(h).catch(()=>{})}catch{}}else!o&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=r.volume,this.video.muted=r.isMuted,this.video.playbackRate=r.playbackRate,this.video.loop=r.isLooping,r.audioGain>1&&this.audioEngine.setGain(r.audioGain),r.isAutoSized&&(this.video.style.objectFit="cover"),this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(o=>{const c={volume:o.volume,isMuted:o.isMuted,playbackRate:o.playbackRate,subtitleSettings:o.subtitleSettings,iconSize:o.iconSize,themeColor:o.themeColor,theme:o.theme,isLive:o.isLive,isLooping:o.isLooping};localStorage.setItem(St,JSON.stringify(c))})}get playing(){return!this.video.paused&&!this.video.ended&&this.video.readyState>2}get currentTime(){return this.video.currentTime}set currentTime(t){this.seek(t)}get duration(){return this.video.duration||0}get paused(){return this.video.paused}get volume(){return this.video.volume}set volume(t){this.setVolume(t)}get muted(){return this.video.muted}set muted(t){this.video.muted=t,this.store.setState({isMuted:t})}get playbackRate(){return this.video.playbackRate}set playbackRate(t){this.video.playbackRate=t}get loop(){return this.video.loop}set loop(t){this.video.loop=t,this.store.setState({isLooping:t})}forward(t=10){this.skip(t)}backward(t=10){this.skip(-t)}on(t,i){return this.events.on(t,i)}off(t,i){return this.events.off(t,i)}emit(t,i){return this.events.emit(t,i)}initVideoListeners(){const t=r=>this.store.setState(r);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(r=>{this.video.addEventListener(r,o=>{switch(this.emit(`video:${r}`,o),r==="play"&&this.emit("play"),r==="pause"&&this.emit("pause"),r==="ended"&&this.emit("ended"),r==="error"&&this.emit("error",this.video.error),r==="seeked"&&this.emit("seek"),r){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),document.addEventListener("fullscreenchange",this.boundFullscreenChange),this.video.textTracks.addEventListener("addtrack",this.updateSubtitles.bind(this)),this.video.textTracks.addEventListener("removetrack",this.updateSubtitles.bind(this))}updateSourceStatus(t){const i=this.store.get().currentSourceIndex;i!==-1&&this.store.setState(r=>({sourceStatuses:{...r.sourceStatuses,[i]:t}}))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",i=>this.skip(i.seekOffset?-i.seekOffset:-10)),t.setActionHandler("seekforward",i=>this.skip(i.seekOffset||10)),t.setActionHandler("seekto",i=>{i.seekTime!==void 0&&this.seek(i.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const i=this.store.get().currentSourceIndex;i>0&&this.switchSource(i-1)}),t.setActionHandler("nexttrack",()=>{const i=this.store.get().currentSourceIndex,r=this.store.get().sources.length;i<r-1&&this.switchSource(i+1)})}updateMediaSessionMetadata(){var r,o;if(!("mediaSession"in navigator))return;const t=((r=this.currentSource)==null?void 0:r.name)||((o=this.currentSource)==null?void 0:o.url.split("/").pop())||"Video",i=[];this.config.poster&&i.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),i.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:i})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,i=this.video.currentTime,r=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(i))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:r,position:Math.max(0,Math.min(i,t))})}catch(o){console.warn("MediaSession Position Error:",o)}}triggerError(t,i=!1){i?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const i=this.video.error,r=t||(i==null?void 0:i.message)||(i?`Code ${i.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",i),this.retryCount<this.maxRetries){this.retryCount++;const o=Math.pow(2,this.retryCount-1)*1500;this.notify({id:"retry",type:"loading",message:`Error: ${r}. Retrying (${this.retryCount}/${this.maxRetries})...`}),console.warn(`[StrataPlayer] Error: ${r}. Retrying in ${o}ms...`),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.currentSource){this.load(this.currentSource,this.currentTracks,!0);const c=this.store.get().currentTime;if(c>0){const h=()=>{this.video.currentTime=c,this.video.removeEventListener("canplay",h)};this.video.addEventListener("canplay",h)}}},o)}else{this.removeNotification("retry");const o=`Failed to play after ${this.maxRetries} attempts: ${r}`;this.store.setState({error:o}),this.emit("error",o),this.updateSourceStatus("error")}}updateBuffer(){const t=[];for(let i=0;i<this.video.buffered.length;i++)t.push({start:this.video.buffered.start(i),end:this.video.buffered.end(i)});this.store.setState({buffered:t})}updateSubtitles(){setTimeout(()=>{const t=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions").map((r,o)=>({label:r.label||r.language||`Track ${o+1}`,language:r.language,index:o}));this.store.setState({subtitleTracks:t});const i=this.store.get();i.currentSubtitle!==-1&&t.length>0&&i.currentSubtitle<t.length&&this.setSubtitle(i.currentSubtitle)},50)}async fetchWithRetry(t,i=3,r){const o=r??this.config.fetchTimeout??3e4;for(let c=0;c<i;c++){const h=new AbortController,b=setTimeout(()=>h.abort(),o);try{const j=await fetch(t,{signal:h.signal});if(clearTimeout(b),!j.ok)throw new Error(`HTTP ${j.status}`);return j}catch(j){if(clearTimeout(b),c===i-1)throw j;j.name==="AbortError"&&console.warn(`Fetch timeout (${o}ms) for ${t}`),await new Promise(g=>setTimeout(g,1e3*Math.pow(2,c)))}}throw new Error("Fetch failed")}attach(t){this.container=t,this.container.contains(this.video)||(this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().isAutoSized?"cover":"contain",this.video.style.backgroundColor="black",this.container.appendChild(this.video)),this.resizeObserver=new ResizeObserver(i=>{for(const r of i)this.emit("resize",{width:r.contentRect.width,height:r.contentRect.height})}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,i=[]){this.store.setState({sources:t}),this.currentTracks=i,t.length>0&&this.load(t[0],i)}switchSource(t){const i=this.store.get().sources;if(t>=0&&t<i.length){const r=this.video.currentTime,o=!this.video.paused;this.load(i[t],this.currentTracks);const c=()=>{this.video.currentTime=r,o&&this.video.play(),this.video.removeEventListener("canplay",c)};this.video.addEventListener("canplay",c)}}load(t,i=[],r=!1){this.retryTimer&&clearTimeout(this.retryTimer);const o=typeof t=="string"?{url:t,type:"auto"}:t;r||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=o.url,this.currentSource=o,this.currentTracks=i;const h=this.store.get().sources.findIndex(g=>g.url===o.url);this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,currentSourceIndex:h}),this.updateMediaSessionMetadata();let b=o.type||"auto";b==="auto"&&(o.url.includes(".m3u8")?b="hls":o.url.includes(".mpd")?b="dash":o.url.includes(".flv")||o.url.includes(".ts")?b="mpegts":o.url.startsWith("magnet:")||o.url.includes(".torrent")?b="webtorrent":b="mp4"),this.events.emit("load",{url:o.url,type:b});const j=this.video.getElementsByTagName("track");for(;j.length>0;)j[0].remove();i.length>0&&i.forEach(g=>{this.fetchWithRetry(g.src).then(()=>{this.addTextTrackInternal(g.src,g.label,g.srcLang,g.default)}).catch(u=>{this.notify({type:"warning",message:`Failed to load subtitle: ${g.label}`,duration:4e3})})}),(b==="mp4"||b==="webm"||b==="ogg")&&(this.video.src=o.url)}loadSubtitle(t,i="Subtitle"){this.addTextTrackInternal(t,i,void 0,!0)}addTextTrack(t,i){const r=new FileReader;r.onload=o=>{var j;if(!((j=o.target)!=null&&j.result))return;let c=o.target.result;(t.name.toLowerCase().endsWith(".srt")||!c.trim().startsWith("WEBVTT"))&&(c=c.replace(/(\d{2}:\d{2}:\d{2}),(\d{3})/g,"$1.$2"),c.trim().startsWith("WEBVTT")||(c=`WEBVTT
|
|
1
|
+
"use strict";var ts=Object.defineProperty;var ss=(s,t,i)=>t in s?ts(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var C=(s,t,i)=>ss(s,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),is=require("react-dom/client"),e=require("react/jsx-runtime"),ns=require("react-dom");class rs{constructor(){C(this,"events");this.events=new Map}on(t,i){var r;return this.events.has(t)||this.events.set(t,[]),(r=this.events.get(t))==null||r.push(i),()=>this.off(t,i)}off(t,i){const r=this.events.get(t);r&&this.events.set(t,r.filter(l=>l!==i))}emit(t,i){const r=this.events.get(t);r&&r.forEach(l=>l(i))}destroy(){this.events.clear()}}class os{constructor(t){C(this,"state");C(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const i=this.state,r=typeof t=="function"?t(i):t;this.state={...i,...r},this.listeners.forEach(l=>l(this.state,i))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class as{constructor(t){C(this,"context",null);C(this,"source",null);C(this,"gainNode",null);C(this,"video");C(this,"isInitialized",!1);this.video=t}init(){if(!(this.isInitialized||!(window.AudioContext||window.webkitAudioContext))){this.context=new AudioContext,this.gainNode=this.context.createGain();try{this.source=this.context.createMediaElementSource(this.video),this.source.connect(this.gainNode),this.gainNode.connect(this.context.destination),this.isInitialized=!0}catch(i){console.warn("StrataPlayer: Failed to initialize AudioEngine",i)}}}setGain(t){this.isInitialized||this.init(),this.gainNode&&this.context&&(this.gainNode.gain.value=t,this.context.state==="suspended"&&this.context.resume())}destroy(){this.context&&this.context.close(),this.isInitialized=!1}}const ze=s=>{if(isNaN(s))return"00:00";const t=Math.floor(s/3600),i=Math.floor(s%3600/60),r=Math.floor(s%60);return t>0?`${t}:${i.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${i}:${r.toString().padStart(2,"0")}`},ls=async(s,t=3,i=2e4)=>{for(let r=0;r<t;r++){const l=new AbortController,u=setTimeout(()=>l.abort(),i);try{const d=await fetch(s,{signal:l.signal});if(clearTimeout(u),!d.ok)throw new Error(`HTTP ${d.status}`);return await d.text()}catch(d){if(clearTimeout(u),r===t-1)throw d;await new Promise(g=>setTimeout(g,1e3))}}throw new Error("Failed")},cs=async(s,t,i=2e4)=>{try{const l=(await ls(s,3,i)).split(`
|
|
2
|
+
`),u=[];let d=null,g=null;const w=s.substring(0,s.lastIndexOf("/")+1),f=h=>{const j=h.split(":");let x=0;return j.length===3?(x+=parseFloat(j[0])*3600,x+=parseFloat(j[1])*60,x+=parseFloat(j[2])):(x+=parseFloat(j[0])*60,x+=parseFloat(j[1])),x};for(let h of l)if(h=h.trim(),h.includes("-->")){const j=h.split("-->");d=f(j[0].trim()),g=f(j[1].trim())}else if(d!==null&&g!==null&&h.length>0){let[j,x]=h.split("#");!j.match(/^https?:\/\//)&&!j.startsWith("data:")&&(j=w+j);let N=0,P=0,b=0,q=0;if(x&&x.startsWith("xywh=")){const _=x.replace("xywh=","").split(",");_.length===4&&(N=parseInt(_[0]),P=parseInt(_[1]),b=parseInt(_[2]),q=parseInt(_[3]))}b>0&&q>0&&u.push({start:d,end:g,url:j,x:N,y:P,w:b,h:q}),d=null,g=null}return u}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},us=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const s=document.createElement("link");s.rel="preconnect",s.href="https://fonts.googleapis.com",document.head.appendChild(s);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const i=document.createElement("link");i.id="strata-fonts",i.rel="stylesheet",i.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(i)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const s=document.createElement("script");s.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(s)}}},$e={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},Nt="strata-settings",V={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:$e,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",isAutoSized:!1,isLooping:!1,controlsVisible:!0},Mt=(s={})=>{let t={};if(!s.disablePersistence&&typeof window<"u")try{const r=localStorage.getItem(Nt);r&&(t=JSON.parse(r))}catch{}const i={...$e,...t.subtitleSettings||{},...s.subtitleSettings||{}};return{...V,...t,volume:s.volume??t.volume??V.volume,isMuted:s.muted??t.isMuted??V.isMuted,playbackRate:s.playbackRate??t.playbackRate??V.playbackRate,audioGain:s.audioGain??t.audioGain??V.audioGain,theme:s.theme??t.theme??V.theme,themeColor:s.themeColor??t.themeColor??V.themeColor,iconSize:s.iconSize??t.iconSize??V.iconSize,subtitleSettings:i,isAutoSized:s.autoSize??V.isAutoSized,isLive:s.isLive??t.isLive??V.isLive,isLooping:s.loop??t.isLooping??V.isLooping,sourceStatuses:{}}};class Tt{constructor(t={},i){C(this,"video");C(this,"container",null);C(this,"events");C(this,"store");C(this,"plugins",new Map);C(this,"audioEngine");C(this,"config");C(this,"resizeObserver",null);C(this,"retryCount",0);C(this,"maxRetries",5);C(this,"retryTimer",null);C(this,"currentSource",null);C(this,"currentSrc","");C(this,"currentTracks",[]);C(this,"castInitialized",!1);C(this,"boundCueChange");C(this,"boundFullscreenChange");us(),this.config=t,this.config.autoOrientation=this.config.autoOrientation??!0,this.config.fetchTimeout=this.config.fetchTimeout??3e4,this.config.centerControls=this.config.centerControls??!0,this.config.gestureSeek=this.config.gestureSeek??!1,this.video=i||document.createElement("video"),this.video.crossOrigin="anonymous",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new rs;const r=Mt(t);this.store=new os(r),this.audioEngine=new as(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const l=!!document.fullscreenElement;if(this.store.setState({isFullscreen:l}),this.emit("resize"),this.emit(l?"fullscreen":"fullscreen_exit"),l&&this.config.autoOrientation&&screen.orientation&&"lock"in screen.orientation){const d=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(d).catch(()=>{})}catch{}}else!l&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=r.volume,this.video.muted=r.isMuted,this.video.playbackRate=r.playbackRate,this.video.loop=r.isLooping,r.audioGain>1&&this.audioEngine.setGain(r.audioGain),r.isAutoSized&&(this.video.style.objectFit="cover"),this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(l=>{const u={volume:l.volume,isMuted:l.isMuted,playbackRate:l.playbackRate,subtitleSettings:l.subtitleSettings,iconSize:l.iconSize,themeColor:l.themeColor,theme:l.theme,isLive:l.isLive,isLooping:l.isLooping};localStorage.setItem(Nt,JSON.stringify(u))})}get playing(){return!this.video.paused&&!this.video.ended&&this.video.readyState>2}get currentTime(){return this.video.currentTime}set currentTime(t){this.seek(t)}get duration(){return this.video.duration||0}get paused(){return this.video.paused}get volume(){return this.video.volume}set volume(t){this.setVolume(t)}get muted(){return this.video.muted}set muted(t){this.video.muted=t,this.store.setState({isMuted:t})}get playbackRate(){return this.video.playbackRate}set playbackRate(t){this.video.playbackRate=t}get loop(){return this.video.loop}set loop(t){this.video.loop=t,this.store.setState({isLooping:t})}forward(t=10){this.skip(t)}backward(t=10){this.skip(-t)}on(t,i){return this.events.on(t,i)}off(t,i){return this.events.off(t,i)}emit(t,i){return this.events.emit(t,i)}initVideoListeners(){const t=r=>this.store.setState(r);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(r=>{this.video.addEventListener(r,l=>{switch(this.emit(`video:${r}`,l),r==="play"&&this.emit("play"),r==="pause"&&this.emit("pause"),r==="ended"&&this.emit("ended"),r==="error"&&this.emit("error",this.video.error),r==="seeked"&&this.emit("seek"),r){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),document.addEventListener("fullscreenchange",this.boundFullscreenChange),this.video.textTracks.addEventListener("addtrack",this.updateSubtitles.bind(this)),this.video.textTracks.addEventListener("removetrack",this.updateSubtitles.bind(this))}updateSourceStatus(t){const i=this.store.get().currentSourceIndex;i!==-1&&this.store.setState(r=>({sourceStatuses:{...r.sourceStatuses,[i]:t}}))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",i=>this.skip(i.seekOffset?-i.seekOffset:-10)),t.setActionHandler("seekforward",i=>this.skip(i.seekOffset||10)),t.setActionHandler("seekto",i=>{i.seekTime!==void 0&&this.seek(i.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const i=this.store.get().currentSourceIndex;i>0&&this.switchSource(i-1)}),t.setActionHandler("nexttrack",()=>{const i=this.store.get().currentSourceIndex,r=this.store.get().sources.length;i<r-1&&this.switchSource(i+1)})}updateMediaSessionMetadata(){var r,l;if(!("mediaSession"in navigator))return;const t=((r=this.currentSource)==null?void 0:r.name)||((l=this.currentSource)==null?void 0:l.url.split("/").pop())||"Video",i=[];this.config.poster&&i.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),i.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:i})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,i=this.video.currentTime,r=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(i))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:r,position:Math.max(0,Math.min(i,t))})}catch(l){console.warn("MediaSession Position Error:",l)}}triggerError(t,i=!1){i?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const i=this.video.error,r=t||(i==null?void 0:i.message)||(i?`Code ${i.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",i),this.retryCount<this.maxRetries){this.retryCount++;const l=Math.pow(2,this.retryCount-1)*1500;this.notify({id:"retry",type:"loading",message:`Error: ${r}. Retrying (${this.retryCount}/${this.maxRetries})...`}),console.warn(`[StrataPlayer] Error: ${r}. Retrying in ${l}ms...`),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.currentSource){this.load(this.currentSource,this.currentTracks,!0);const u=this.store.get().currentTime;if(u>0){const d=()=>{this.video.currentTime=u,this.video.removeEventListener("canplay",d)};this.video.addEventListener("canplay",d)}}},l)}else{this.removeNotification("retry");const l=`Failed to play after ${this.maxRetries} attempts: ${r}`;this.store.setState({error:l}),this.emit("error",l),this.updateSourceStatus("error")}}updateBuffer(){const t=[];for(let i=0;i<this.video.buffered.length;i++)t.push({start:this.video.buffered.start(i),end:this.video.buffered.end(i)});this.store.setState({buffered:t})}updateSubtitles(){setTimeout(()=>{const t=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions").map((r,l)=>({label:r.label||r.language||`Track ${l+1}`,language:r.language,index:l}));this.store.setState({subtitleTracks:t});const i=this.store.get();i.currentSubtitle!==-1&&t.length>0&&i.currentSubtitle<t.length&&this.setSubtitle(i.currentSubtitle)},50)}async fetchWithRetry(t,i=3,r){const l=r??this.config.fetchTimeout??3e4;for(let u=0;u<i;u++){const d=new AbortController,g=setTimeout(()=>d.abort(),l);try{const w=await fetch(t,{signal:d.signal});if(clearTimeout(g),!w.ok)throw new Error(`HTTP ${w.status}`);return w}catch(w){if(clearTimeout(g),u===i-1)throw w;w.name==="AbortError"&&console.warn(`Fetch timeout (${l}ms) for ${t}`),await new Promise(f=>setTimeout(f,1e3*Math.pow(2,u)))}}throw new Error("Fetch failed")}attach(t){this.resizeObserver&&this.resizeObserver.disconnect(),this.container=t,this.container.appendChild(this.video),this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().isAutoSized?"cover":"contain",this.video.style.backgroundColor="black",this.updateAspectRatio(),this.resizeObserver=new ResizeObserver(i=>{for(const r of i)this.emit("resize",{width:r.contentRect.width,height:r.contentRect.height}),this.updateAspectRatio()}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,i=[]){this.store.setState({sources:t}),this.currentTracks=i,t.length>0&&this.load(t[0],i)}switchSource(t){const i=this.store.get().sources;if(t>=0&&t<i.length){const r=this.video.currentTime,l=!this.video.paused;this.load(i[t],this.currentTracks);const u=()=>{this.video.currentTime=r,l&&this.video.play(),this.video.removeEventListener("canplay",u)};this.video.addEventListener("canplay",u)}}load(t,i=[],r=!1){this.retryTimer&&clearTimeout(this.retryTimer);const l=typeof t=="string"?{url:t,type:"auto"}:t;r||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=l.url,this.currentSource=l,this.currentTracks=i;const d=this.store.get().sources.findIndex(f=>f.url===l.url);this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,currentSourceIndex:d}),this.updateMediaSessionMetadata();let g=l.type||"auto";g==="auto"&&(l.url.includes(".m3u8")?g="hls":l.url.includes(".mpd")?g="dash":l.url.includes(".flv")||l.url.includes(".ts")?g="mpegts":l.url.startsWith("magnet:")||l.url.includes(".torrent")?g="webtorrent":g="mp4"),this.events.emit("load",{url:l.url,type:g});const w=this.video.getElementsByTagName("track");for(;w.length>0;)w[0].remove();i.length>0&&i.forEach(f=>{this.fetchWithRetry(f.src).then(()=>{this.addTextTrackInternal(f.src,f.label,f.srcLang,f.default)}).catch(h=>{this.notify({type:"warning",message:`Failed to load subtitle: ${f.label}`,duration:4e3})})}),(g==="mp4"||g==="webm"||g==="ogg")&&(this.video.src=l.url)}loadSubtitle(t,i="Subtitle"){this.addTextTrackInternal(t,i,void 0,!0)}addTextTrack(t,i){const r=new FileReader;r.onload=l=>{var w;if(!((w=l.target)!=null&&w.result))return;let u=l.target.result;(t.name.toLowerCase().endsWith(".srt")||!u.trim().startsWith("WEBVTT"))&&(u=u.replace(/(\d{2}:\d{2}:\d{2}),(\d{3})/g,"$1.$2"),u.trim().startsWith("WEBVTT")||(u=`WEBVTT
|
|
3
3
|
|
|
4
|
-
`+c));const h=new Blob([c],{type:"text/vtt"}),b=URL.createObjectURL(h);this.addTextTrackInternal(b,i,"user",!0),setTimeout(()=>{const u=this.store.get().subtitleTracks.findIndex(w=>w.label===i);u!==-1&&(this.setSubtitle(u),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3}))},200)},r.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},r.readAsText(t)}addTextTrackInternal(t,i,r="",o=!1){const c=document.createElement("track");c.kind="subtitles",c.label=i,c.src=t,c.srclang=r,o&&(c.default=!0),this.video.appendChild(c),this.updateSubtitles()}play(){return this.video.play()}pause(){return this.video.pause()}togglePlay(){this.video.paused?this.play():this.pause()}seek(t){if(isNaN(t))return;const i=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:i}),this.video.currentTime=i}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const i=Math.max(0,Math.min(t,1));this.video.volume=i,i>0&&this.video.muted&&(this.video.muted=!1),i===0&&(this.video.muted=!0)}toggleMute(){this.video.muted=!this.video.muted}setAudioGain(t){this.store.setState({audioGain:t}),this.audioEngine.setGain(t)}setQuality(t){this.store.setState({currentQuality:t}),this.events.emit("quality-request",t)}setAudioTrack(t){this.store.setState({currentAudioTrack:t}),this.events.emit("audio-track-request",t)}setControlsVisible(t){this.store.get().controlsVisible!==t&&(this.store.setState({controlsVisible:t}),this.emit("control",t))}async toggleFullscreen(){if(this.container)try{document.fullscreenElement?await document.exitFullscreen():await this.container.requestFullscreen()}catch(t){console.error("Fullscreen toggle failed",t)}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen;document.fullscreenElement&&document.exitFullscreen().catch(()=>{});const i=!t;this.store.setState({isWebFullscreen:i}),typeof document<"u"&&(document.body.style.overflow=i?"hidden":""),this.emit("webfullscreen",i)}togglePip(){document.pictureInPictureElement?document.exitPictureInPicture():this.video!==document.pictureInPictureElement&&this.video.requestPictureInPicture&&this.video.requestPictureInPicture()}screenshot(){const t=document.createElement("canvas");t.width=this.video.videoWidth,t.height=this.video.videoHeight;const i=t.getContext("2d");if(i){i.drawImage(this.video,0,0,t.width,t.height);try{const r=t.toDataURL("image/png"),o=document.createElement("a");o.download=`screenshot-${new Date().toISOString()}.png`,o.href=r,o.click(),this.notify({type:"success",message:"Screenshot saved",duration:2e3})}catch{this.notify({type:"error",message:"Failed to take screenshot",duration:3e3})}}}toggleLock(){this.store.setState(t=>({isLocked:!t.isLocked}))}toggleLoop(){this.video.loop=!this.video.loop,this.store.setState({isLooping:this.video.loop}),this.notify({type:"info",message:`Loop: ${this.video.loop?"On":"Off"}`,duration:1500})}setFlip(t){const i=this.store.get().flipState,r={...i,[t]:!i[t]};this.store.setState({flipState:r});const o=r.horizontal?-1:1,c=r.vertical?-1:1;this.video.style.transform=`scale(${o}, ${c})`}setAspectRatio(t){if(this.store.setState({aspectRatio:t}),t==="default"){this.video.style.objectFit=this.store.get().isAutoSized?"cover":"contain",this.video.style.width="100%",this.video.style.height="100%";return}this.video.style.objectFit="contain",this.notify({type:"info",message:`Aspect Ratio: ${t} (CSS support limited)`,duration:2e3})}initCast(){const t=window,i=()=>{if(!this.castInitialized)try{t.cast&&t.cast.framework&&t.chrome&&t.chrome.cast&&(t.cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:t.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:t.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),this.castInitialized=!0)}catch(r){console.warn("Cast Init Error or already initialized",r)}};t.cast&&t.cast.framework?i():t.__onGCastApiAvailable=r=>{r&&i()}}requestCast(){const t=window;if(t.cast&&t.cast.framework)try{this.castInitialized||this.initCast(),t.cast.framework.CastContext.getInstance().requestSession().then(()=>{this.loadMediaToCast()}).catch(i=>{i!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+i,duration:3e3})})}catch{this.notify({type:"warning",message:"Cast not available yet",duration:3e3})}else this.notify({type:"warning",message:"Cast API not loaded",duration:3e3})}loadMediaToCast(){const t=window;try{const i=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!i)return;const r=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),o=new t.chrome.cast.media.LoadRequest(r);i.loadMedia(o).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(c=>console.error("Cast load error",c))}catch(i){console.error("Failed to load media into Cast session",i)}}handleCueChange(){const t=this.store.get();if(t.currentSubtitle===-1){this.store.setState({activeCues:[]});return}const r=Array.from(this.video.textTracks).filter(o=>o.kind==="subtitles"||o.kind==="captions")[t.currentSubtitle];if(r&&r.activeCues){const o=Array.from(r.activeCues).map(c=>c.text);this.store.setState({activeCues:o})}else this.store.setState({activeCues:[]})}setSubtitle(t){if(Array.from(this.video.textTracks).forEach(i=>{i.removeEventListener("cuechange",this.boundCueChange),i.mode="hidden"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t!==-1){const r=Array.from(this.video.textTracks).filter(o=>o.kind==="subtitles"||o.kind==="captions")[t];if(r){const o=this.store.get().subtitleSettings;r.mode=o.useNative?"showing":"hidden",r.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}}updateSubtitleSettings(t){const r={...this.store.get().subtitleSettings,...t};this.store.setState({subtitleSettings:r}),t.useNative!==void 0&&this.setSubtitle(this.store.get().currentSubtitle)}resetSubtitleSettings(){this.store.setState({subtitleSettings:Ee}),this.setSubtitle(this.store.get().currentSubtitle)}setSubtitleOffset(t){const i=this.store.get().subtitleOffset,r=t-i;Math.abs(r)<.001||(Array.from(this.video.textTracks).forEach(o=>{(o.mode==="showing"||o.mode==="hidden")&&o.cues&&Array.from(o.cues).forEach(c=>{c.startTime+=r,c.endTime+=r})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}async download(){var r;if(!this.video.src)return;const t=this.video.src;if(t.includes("blob:")||t.includes(".m3u8")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}const i=this.notify({type:"loading",message:"Preparing download...",progress:0});try{const o=await this.fetchWithRetry(t);if(!o.body)throw new Error("No body");const c=o.body.getReader(),h=o.headers.get("Content-Length"),b=h?parseInt(h,10):0;let j=0;const g=[];for(;;){const{done:C,value:R}=await c.read();if(C)break;if(g.push(R),j+=R.length,b){const p=Math.round(j/b*100);this.notify({id:i,type:"loading",message:`Downloading... ${p}%`,progress:p})}}const u=new Blob(g),w=window.URL.createObjectURL(u),x=document.createElement("a");x.style.display="none",x.href=w,x.download=((r=t.split("/").pop())==null?void 0:r.split("?")[0])||"video.mp4",document.body.appendChild(x),x.click(),window.URL.revokeObjectURL(w),document.body.removeChild(x),this.notify({id:i,type:"success",message:"Saved!",duration:3e3})}catch{this.notify({id:i,type:"error",message:"Download failed.",duration:4e3}),window.open(t,"_blank")}}notify(t){const i=t.id||Math.random().toString(36).substr(2,9),r={...t,id:i};return this.store.setState({notifications:[r]}),t.duration&&setTimeout(()=>this.removeNotification(i),t.duration),i}removeNotification(t){const i=this.store.get().notifications;this.store.setState({notifications:i.filter(r=>r.id!==t)})}setAppearance(t){this.store.setState(i=>({...i,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),document.removeEventListener("fullscreenchange",this.boundFullscreenChange),this.video.pause(),this.video.src="";const t=this.video.getElementsByTagName("track");for(;t.length>0;)t[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(i=>i.destroy&&i.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const Ie=(s,t=200)=>{const[i,r]=m.useState(s),[o,c]=m.useState(!1);return m.useEffect(()=>{if(s)r(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(!0)})});else{c(!1);const h=setTimeout(()=>{r(!1)},t);return()=>clearTimeout(h)}},[s,t]),{isMounted:i,isVisible:o}},v=({className:s,children:t,fill:i="none",strokeWidth:r=2,viewBox:o="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:o,fill:i,stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round",className:s,children:t}),vt=({className:s})=>e.jsx(v,{className:s,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),jt=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"4",height:"16",x:"6",y:"4",rx:"1"}),e.jsx("rect",{width:"4",height:"16",x:"14",y:"4",rx:"1"})]}),us=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),hs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),xs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("line",{x1:"23",x2:"17",y1:"9",y2:"15"}),e.jsx("line",{x1:"17",x2:"23",y1:"9",y2:"15"})]}),ms=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]}),fs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),e.jsx("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),e.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),e.jsx("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}),ps=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Pe=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),bs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),e.jsx("rect",{x:"12",y:"13",width:"10",height:"7",rx:"2"})]}),gs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 15h4"}),e.jsx("path",{d:"M15 15h2"}),e.jsx("path",{d:"M7 11h2"}),e.jsx("path",{d:"M13 11h4"})]}),vs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),js=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),ws=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Le=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ys=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M2 16.1A5 5 0 0 1 5.9 20"}),e.jsx("path",{d:"M2 12.05A9 9 0 0 1 9.95 20"}),e.jsx("path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"}),e.jsx("line",{x1:"2",x2:"2.01",y1:"20",y2:"20"})]}),ks=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Ss=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),Cs=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M5 12h14"})}),Ns=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),Ms=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M4 21v-7"}),e.jsx("path",{d:"M4 10V3"}),e.jsx("path",{d:"M12 21v-9"}),e.jsx("path",{d:"M12 8V3"}),e.jsx("path",{d:"M20 21v-5"}),e.jsx("path",{d:"M20 12V3"}),e.jsx("path",{d:"M1 14h6"}),e.jsx("path",{d:"M9 8h6"}),e.jsx("path",{d:"M17 16h6"})]}),Ts=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e.jsx("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}),Mt=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]}),zs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Is=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"8 18 12 22 16 18"}),e.jsx("polyline",{points:"8 6 12 2 16 6"}),e.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"})]}),Rs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),Ls=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),$s=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m3 17 4-10 4 10"}),e.jsx("path",{d:"M4 13h6"}),e.jsx("path",{d:"M15 12h4.5a2.5 2.5 0 0 1 0 5H15V7h4a2.5 2.5 0 0 1 0 5h-4"})]}),Es=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"})}),Ps=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),Fs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),As=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}),Bs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),Vs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"13 19 22 12 13 5 13 19"}),e.jsx("polygon",{points:"2 19 11 12 2 5 2 19"})]}),Os=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Hs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]}),Ws=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),Ds=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),e.jsx("polyline",{points:"2 17 12 22 22 17"}),e.jsx("polyline",{points:"2 12 12 17 22 12"})]}),qs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),_s=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),Gs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),Us=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),Qs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"16 16 12 20 8 16"}),e.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),e.jsx("path",{d:"M12 4a8 8 0 0 1 8 8"}),e.jsx("path",{d:"M20 4v8"}),e.jsx("path",{d:"M4 4v8"}),e.jsx("path",{d:"M4 12a8 8 0 0 1 8-8"})]}),Xs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),Js=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),wt=({className:s})=>e.jsxs("div",{className:`relative flex items-center justify-center ${s}`,children:[e.jsxs(v,{className:"w-full h-full",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),yt=({className:s})=>e.jsxs("div",{className:`relative flex items-center justify-center ${s}`,children:[e.jsxs(v,{className:"w-full h-full",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),Ks=({notifications:s})=>e.jsx("div",{className:"absolute top-4 left-4 z-25 flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[320px]",children:s.map(t=>e.jsxs("div",{className:`
|
|
4
|
+
`+u));const d=new Blob([u],{type:"text/vtt"}),g=URL.createObjectURL(d);this.addTextTrackInternal(g,i,"user",!0),setTimeout(()=>{const h=this.store.get().subtitleTracks.findIndex(j=>j.label===i);h!==-1&&(this.setSubtitle(h),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3}))},200)},r.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},r.readAsText(t)}addTextTrackInternal(t,i,r="",l=!1){const u=document.createElement("track");u.kind="subtitles",u.label=i,u.src=t,u.srclang=r,l&&(u.default=!0),this.video.appendChild(u),this.updateSubtitles()}play(){return this.video.play()}pause(){return this.video.pause()}togglePlay(){this.video.paused?this.play():this.pause()}seek(t){if(isNaN(t))return;const i=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:i}),this.video.currentTime=i}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const i=Math.max(0,Math.min(t,1));this.video.volume=i,i>0&&this.video.muted&&(this.video.muted=!1),i===0&&(this.video.muted=!0)}toggleMute(){this.video.muted=!this.video.muted}setAudioGain(t){this.store.setState({audioGain:t}),this.audioEngine.setGain(t)}setQuality(t){this.store.setState({currentQuality:t}),this.events.emit("quality-request",t)}setAudioTrack(t){this.store.setState({currentAudioTrack:t}),this.events.emit("audio-track-request",t)}setControlsVisible(t){this.store.get().controlsVisible!==t&&(this.store.setState({controlsVisible:t}),this.emit("control",t))}async toggleFullscreen(){if(this.container){if(document.fullscreenElement){await document.exitFullscreen().catch(()=>{});return}if(this.store.get().isWebFullscreen){this.toggleWebFullscreen();return}try{await this.container.requestFullscreen()}catch(t){console.warn("Native fullscreen failed, falling back to Web Fullscreen",t),this.toggleWebFullscreen()}}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen;document.fullscreenElement&&document.exitFullscreen().catch(()=>{});const i=!t;this.store.setState({isWebFullscreen:i}),typeof document<"u"&&(document.body.style.overflow=i?"hidden":""),this.emit("webfullscreen",i)}togglePip(){document.pictureInPictureElement?document.exitPictureInPicture():this.video!==document.pictureInPictureElement&&this.video.requestPictureInPicture&&this.video.requestPictureInPicture()}screenshot(){const t=document.createElement("canvas");t.width=this.video.videoWidth,t.height=this.video.videoHeight;const i=t.getContext("2d");if(i){i.drawImage(this.video,0,0,t.width,t.height);try{const r=t.toDataURL("image/png"),l=document.createElement("a");l.download=`screenshot-${new Date().toISOString()}.png`,l.href=r,l.click(),this.notify({type:"success",message:"Screenshot saved",duration:2e3})}catch{this.notify({type:"error",message:"Failed to take screenshot",duration:3e3})}}}toggleLock(){this.store.setState(t=>({isLocked:!t.isLocked}))}toggleLoop(){this.video.loop=!this.video.loop,this.store.setState({isLooping:this.video.loop}),this.notify({type:"info",message:`Loop: ${this.video.loop?"On":"Off"}`,duration:1500})}setFlip(t){const i=this.store.get().flipState,r={...i,[t]:!i[t]};this.store.setState({flipState:r});const l=r.horizontal?-1:1,u=r.vertical?-1:1;this.video.style.transform=`scale(${l}, ${u})`}setAspectRatio(t){this.store.setState({aspectRatio:t}),this.updateAspectRatio(),t!=="default"&&this.notify({type:"info",message:`Aspect Ratio: ${t}`,duration:2e3})}updateAspectRatio(){if(!this.container)return;const{aspectRatio:t,isAutoSized:i}=this.store.get();if(t==="default"){this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=i?"cover":"contain";return}const[r,l]=t.split(":").map(Number);if(!r||!l)return;const u=r/l,d=this.container.getBoundingClientRect();if(d.width===0||d.height===0)return;const g=d.width/d.height;let w,f;g>u?(f=d.height,w=f*u):(w=d.width,f=w/u),this.video.style.width=`${w}px`,this.video.style.height=`${f}px`,this.video.style.objectFit="fill"}initCast(){const t=window,i=()=>{if(!this.castInitialized)try{t.cast&&t.cast.framework&&t.chrome&&t.chrome.cast&&(t.cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:t.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:t.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),this.castInitialized=!0)}catch(r){console.warn("Cast Init Error or already initialized",r)}};t.cast&&t.cast.framework?i():t.__onGCastApiAvailable=r=>{r&&i()}}requestCast(){const t=window;if(t.cast&&t.cast.framework)try{this.castInitialized||this.initCast(),t.cast.framework.CastContext.getInstance().requestSession().then(()=>{this.loadMediaToCast()}).catch(i=>{i!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+i,duration:3e3})})}catch{this.notify({type:"warning",message:"Cast not available yet",duration:3e3})}else this.notify({type:"warning",message:"Cast API not loaded",duration:3e3})}loadMediaToCast(){const t=window;try{const i=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!i)return;const r=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),l=new t.chrome.cast.media.LoadRequest(r);i.loadMedia(l).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(u=>console.error("Cast load error",u))}catch(i){console.error("Failed to load media into Cast session",i)}}handleCueChange(){const t=this.store.get();if(t.currentSubtitle===-1){this.store.setState({activeCues:[]});return}const r=Array.from(this.video.textTracks).filter(l=>l.kind==="subtitles"||l.kind==="captions")[t.currentSubtitle];if(r&&r.activeCues){const l=Array.from(r.activeCues).map(u=>u.text);this.store.setState({activeCues:l})}else this.store.setState({activeCues:[]})}setSubtitle(t){if(Array.from(this.video.textTracks).forEach(i=>{i.removeEventListener("cuechange",this.boundCueChange),i.mode="hidden"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t!==-1){const r=Array.from(this.video.textTracks).filter(l=>l.kind==="subtitles"||l.kind==="captions")[t];if(r){const l=this.store.get().subtitleSettings;r.mode=l.useNative?"showing":"hidden",r.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}}updateSubtitleSettings(t){const r={...this.store.get().subtitleSettings,...t};this.store.setState({subtitleSettings:r}),t.useNative!==void 0&&this.setSubtitle(this.store.get().currentSubtitle)}resetSubtitleSettings(){this.store.setState({subtitleSettings:$e}),this.setSubtitle(this.store.get().currentSubtitle)}setSubtitleOffset(t){const i=this.store.get().subtitleOffset,r=t-i;Math.abs(r)<.001||(Array.from(this.video.textTracks).forEach(l=>{(l.mode==="showing"||l.mode==="hidden")&&l.cues&&Array.from(l.cues).forEach(u=>{u.startTime+=r,u.endTime+=r})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}async download(){var r;if(!this.video.src)return;const t=this.video.src;if(t.includes("blob:")||t.includes(".m3u8")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}const i=this.notify({type:"loading",message:"Preparing download...",progress:0});try{const l=await this.fetchWithRetry(t);if(!l.body)throw new Error("No body");const u=l.body.getReader(),d=l.headers.get("Content-Length"),g=d?parseInt(d,10):0;let w=0;const f=[];for(;;){const{done:N,value:P}=await u.read();if(N)break;if(f.push(P),w+=P.length,g){const b=Math.round(w/g*100);this.notify({id:i,type:"loading",message:`Downloading... ${b}%`,progress:b})}}const h=new Blob(f),j=window.URL.createObjectURL(h),x=document.createElement("a");x.style.display="none",x.href=j,x.download=((r=t.split("/").pop())==null?void 0:r.split("?")[0])||"video.mp4",document.body.appendChild(x),x.click(),window.URL.revokeObjectURL(j),document.body.removeChild(x),this.notify({id:i,type:"success",message:"Saved!",duration:3e3})}catch{this.notify({id:i,type:"error",message:"Download failed.",duration:4e3}),window.open(t,"_blank")}}notify(t){const i=t.id||Math.random().toString(36).substr(2,9),r={...t,id:i};return this.store.setState({notifications:[r]}),t.duration&&setTimeout(()=>this.removeNotification(i),t.duration),i}removeNotification(t){const i=this.store.get().notifications;this.store.setState({notifications:i.filter(r=>r.id!==t)})}setAppearance(t){this.store.setState(i=>({...i,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),document.removeEventListener("fullscreenchange",this.boundFullscreenChange),this.video.pause(),this.video.src="";const t=this.video.getElementsByTagName("track");for(;t.length>0;)t[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(i=>i.destroy&&i.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const Re=(s,t=200)=>{const[i,r]=p.useState(s),[l,u]=p.useState(!1);return p.useEffect(()=>{if(s)r(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{u(!0)})});else{u(!1);const d=setTimeout(()=>{r(!1)},t);return()=>clearTimeout(d)}},[s,t]),{isMounted:i,isVisible:l}},v=({className:s,children:t,fill:i="none",strokeWidth:r=2,viewBox:l="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:l,fill:i,stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round",className:s,children:t}),jt=({className:s})=>e.jsx(v,{className:s,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),yt=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"4",height:"16",x:"6",y:"4",rx:"1"}),e.jsx("rect",{width:"4",height:"16",x:"14",y:"4",rx:"1"})]}),ds=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),hs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),ps=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("line",{x1:"23",x2:"17",y1:"9",y2:"15"}),e.jsx("line",{x1:"17",x2:"23",y1:"9",y2:"15"})]}),xs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]}),ms=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),e.jsx("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),e.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),e.jsx("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}),fs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Ee=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),bs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),e.jsx("rect",{x:"12",y:"13",width:"10",height:"7",rx:"2"})]}),gs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 15h4"}),e.jsx("path",{d:"M15 15h2"}),e.jsx("path",{d:"M7 11h2"}),e.jsx("path",{d:"M13 11h4"})]}),vs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),ws=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),js=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Pe=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ys=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M2 16.1A5 5 0 0 1 5.9 20"}),e.jsx("path",{d:"M2 12.05A9 9 0 0 1 9.95 20"}),e.jsx("path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"}),e.jsx("line",{x1:"2",x2:"2.01",y1:"20",y2:"20"})]}),ks=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Ss=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),Cs=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M5 12h14"})}),Ns=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),Ms=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M4 21v-7"}),e.jsx("path",{d:"M4 10V3"}),e.jsx("path",{d:"M12 21v-9"}),e.jsx("path",{d:"M12 8V3"}),e.jsx("path",{d:"M20 21v-5"}),e.jsx("path",{d:"M20 12V3"}),e.jsx("path",{d:"M1 14h6"}),e.jsx("path",{d:"M9 8h6"}),e.jsx("path",{d:"M17 16h6"})]}),Ts=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e.jsx("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}),zt=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]}),zs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Rs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"8 18 12 22 16 18"}),e.jsx("polyline",{points:"8 6 12 2 16 6"}),e.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"})]}),Is=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),Ps=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),Ls=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m3 17 4-10 4 10"}),e.jsx("path",{d:"M4 13h6"}),e.jsx("path",{d:"M15 12h4.5a2.5 2.5 0 0 1 0 5H15V7h4a2.5 2.5 0 0 1 0 5h-4"})]}),$s=({className:s})=>e.jsx(v,{className:s,children:e.jsx("path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"})}),Es=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),Fs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),As=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}),Bs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),Vs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"13 19 22 12 13 5 13 19"}),e.jsx("polygon",{points:"2 19 11 12 2 5 2 19"})]}),Os=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Hs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]}),Ws=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),Ds=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),e.jsx("polyline",{points:"2 17 12 22 22 17"}),e.jsx("polyline",{points:"2 12 12 17 22 12"})]}),qs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),_s=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),Gs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),Us=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),Qs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("polyline",{points:"16 16 12 20 8 16"}),e.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),e.jsx("path",{d:"M12 4a8 8 0 0 1 8 8"}),e.jsx("path",{d:"M20 4v8"}),e.jsx("path",{d:"M4 4v8"}),e.jsx("path",{d:"M4 12a8 8 0 0 1 8-8"})]}),Xs=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),Js=({className:s})=>e.jsxs(v,{className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),kt=({className:s})=>e.jsxs("div",{className:`relative flex items-center justify-center ${s}`,children:[e.jsxs(v,{className:"w-full h-full",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),St=({className:s})=>e.jsxs("div",{className:`relative flex items-center justify-center ${s}`,children:[e.jsxs(v,{className:"w-full h-full",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),Ks=({notifications:s})=>e.jsx("div",{className:"absolute top-4 left-4 z-25 flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[320px]",children:s.map(t=>e.jsxs("div",{className:`
|
|
5
5
|
bg-zinc-950/90 backdrop-blur-md border border-white/10 text-white px-3 py-2 rounded-lg shadow-xl text-xs font-medium flex items-start gap-2.5 animate-in slide-in-from-left-2 fade-in duration-300 pointer-events-auto
|
|
6
6
|
w-fit max-w-full
|
|
7
7
|
${t.type==="error"?"border-red-500/50 text-red-100":""}
|
|
8
8
|
${t.type==="warning"?"border-amber-500/50 text-amber-100":""}
|
|
9
|
-
`,children:[t.type==="loading"&&e.jsx(
|
|
9
|
+
`,children:[t.type==="loading"&&e.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)] shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"break-words line-clamp-4 leading-relaxed whitespace-pre-wrap",children:t.message}),typeof t.progress=="number"&&e.jsx("div",{className:"h-0.5 w-full bg-white/10 rounded-full overflow-hidden mt-1.5",children:e.jsx("div",{className:"h-full bg-[var(--accent)] transition-all duration-300",style:{width:`${t.progress}%`}})})]})]},t.id))}),Ys=({cues:s,settings:t})=>{if(t.useNative||s.length===0)return null;const i=()=>{switch(t.textStyle){case"outline":return"0px 0px 4px black, 0px 0px 4px black";case"raised":return"0 -1px 1px black, 0 -2px 2px black";case"depressed":return"0 1px 1px white, 0 2px 2px black";case"shadow":return"2px 2px 2px rgba(0,0,0,0.8)";default:return"none"}};return e.jsx("div",{className:"absolute inset-x-0 flex flex-col items-center justify-end text-center z-10 pointer-events-none transition-all duration-200",style:{bottom:`${t.verticalOffset}px`},children:s.map((r,l)=>e.jsx("div",{className:"mb-1 inline-block max-w-[80%]",style:{fontSize:`${t.textSize}%`,color:t.textColor,fontWeight:t.isBold?"bold":"normal",textTransform:t.fixCapitalization?"capitalize":"none",textShadow:i(),lineHeight:1.4},children:e.jsx("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`rgba(0, 0, 0, ${t.backgroundOpacity/100})`,backdropFilter:t.backgroundBlur?`blur(${t.backgroundBlurAmount}px)`:"none"},dangerouslySetInnerHTML:{__html:r}})},l))})},de=({content:s})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:s}}):e.jsx("span",{children:s}):e.jsx(e.Fragment,{children:s}),D=({label:s,checked:t,onChange:i,icon:r,tooltip:l})=>e.jsxs("div",{className:"flex items-center justify-between py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(de,{content:r})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm text-zinc-300 font-medium group-hover:text-white transition-colors flex items-center",children:e.jsx(de,{content:s})}),l&&e.jsx("span",{className:"text-[10px] text-zinc-500",children:l})]})]}),e.jsx("button",{onClick:()=>i(!t),className:`w-11 h-6 shrink-0 transition-colors relative focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-zinc-900 ${t?"bg-[var(--accent)]":"bg-zinc-700"}`,style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius-full)",borderWidth:"var(--border-width)",borderColor:"rgba(255,255,255,0.1)"},children:e.jsx("div",{className:`absolute top-1/2 -translate-y-1/2 left-1 w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)",backgroundColor:t?"var(--accent-contrast)":"#ffffff"}})})]}),ne=({label:s,value:t,min:i,max:r,step:l,onChange:u,formatValue:d,icon:g})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(de,{content:g})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:s})]}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-zinc-300 bg-white/10 px-1.5 py-0.5 tabular-nums",style:{borderRadius:"var(--radius-sm)"},children:d?d(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:i,max:r,step:l,value:t,onChange:w=>u(parseFloat(w.target.value)),className:"w-full h-1.5 appearance-none cursor-pointer focus:outline-none focus:ring-2 strata-range-input",style:{borderRadius:"var(--radius-full)",background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${(t-i)/(r-i)*100}%, #3f3f46 ${(t-i)/(r-i)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
|
|
10
10
|
.strata-range-input::-webkit-slider-thumb {
|
|
11
11
|
-webkit-appearance: none;
|
|
12
12
|
height: 14px;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
transform: scale(1.1);
|
|
23
23
|
}
|
|
24
24
|
/* Pixel theme specific overrides are handled by global css */
|
|
25
|
-
`})]})]}),Zs=({label:s,value:t,options:i,onChange:r,icon:o})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[o&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(ue,{content:o})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:s})]}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:c=>r(c.target.value),className:"w-full bg-zinc-800 border-[length:var(--border-width)] border-white/10 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:ring-2 appearance-none hover:bg-zinc-700 transition-colors cursor-pointer",style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius)"},children:i.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-400",children:e.jsx("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1 1L5 5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),K=({title:s,children:t})=>e.jsxs("div",{className:"py-2",children:[s&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:s}),e.jsx("div",{className:"space-y-0.5",children:t})]}),Fe=({children:s,onClose:t,align:i="right",maxHeight:r,className:o})=>{const c=m.useRef(null),h=m.useRef(null),[b,j]=m.useState("auto"),g=i==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";m.useLayoutEffect(()=>{if(!h.current)return;const w=()=>{h.current&&j(h.current.offsetHeight)},x=new ResizeObserver(w);return x.observe(h.current),w(),()=>x.disconnect()},[]);const u={height:b==="auto"?"auto":`${b+14}px`,maxHeight:r?`${r}px`:void 0};return e.jsx("div",{ref:c,className:`absolute bottom-full mb-4 ${g} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${o}`,style:{...u,borderRadius:"var(--radius-lg)"},onClick:w=>w.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:h,children:s})})})},de=({content:s,className:t})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:s}}):e.jsx("span",{className:t,children:s}):e.jsx("span",{className:t,children:s}),N=({label:s,value:t,active:i,onClick:r,hasSubmenu:o,icon:c,rightIcon:h})=>e.jsxs("button",{onClick:r,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-white/10 transition-colors text-left text-zinc-200 active:bg-white/5 focus:outline-none focus:bg-white/10 group overflow-hidden my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[c&&e.jsx("span",{className:"text-zinc-400 shrink-0 group-hover:text-zinc-300 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(de,{content:c})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${i?"text-[var(--accent)]":""}`,title:typeof s=="string"?s:void 0,children:e.jsx(de,{content:s})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400 shrink-0",children:[t&&e.jsx("span",{className:"text-xs font-medium truncate max-w-[60px]",title:t,children:e.jsx(de,{content:t})}),h,i&&e.jsx(Pe,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),o&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),F=({label:s,onBack:t,rightAction:i})=>e.jsxs("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:[e.jsxs("button",{className:"flex items-center gap-2 hover:text-white transition-colors focus:outline-none",onClick:t,children:[e.jsx(ws,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(de,{content:s})})]}),i]}),J=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),ei=({items:s,onClose:t,title:i,maxHeight:r,className:o})=>{const[c,h]=m.useState([]),b=c.length>0?c[c.length-1]:null,j=b?b.children||[]:s,g=b?b.html:i||"Menu",u=()=>{h(x=>x.slice(0,-1))},w=x=>{x.children&&h(C=>[...C,x])};return e.jsx(Fe,{onClose:t,maxHeight:r,className:o,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[c.length>0?e.jsx(F,{label:g||"Menu",onBack:u}):i&&e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:i})}),e.jsx("div",{className:"pb-1",children:j.map((x,C)=>x.separator?e.jsx(J,{},C):x.range?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:x.html,icon:x.icon,value:x.value??x.min??0,min:x.min??0,max:x.max??100,step:x.step??1,onChange:R=>x.onRange&&x.onRange(R),formatValue:x.formatValue})},C):x.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(W,{label:x.html,icon:x.icon,checked:x.switch,tooltip:x.tooltip,onChange:R=>x.onSwitch&&x.onSwitch(x,R)})},C):e.jsx(m.Fragment,{children:e.jsx(N,{label:x.html,icon:x.icon,value:x.currentLabel||x.value,active:x.active,hasSubmenu:!!x.children,onClick:()=>{x.children?w(x):x.onClick?(x.onClick(x),!x.switch&&!x.range&&t()):x.click&&(x.click(x),t())}})},C))})]})})},ti=({tracks:s,current:t,onSelect:i,onUpload:r,onClose:o,settings:c,onSettingsChange:h,onReset:b,offset:j,onOffsetChange:g,maxHeight:u,animationClass:w})=>{const[x,C]=m.useState("main"),R=m.useRef(null);return e.jsxs(Fe,{onClose:o,align:"right",maxHeight:u,className:w,children:[x==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{children:[e.jsx(N,{label:"Upload Subtitle",icon:e.jsx(js,{className:"w-4 h-4"}),onClick:()=>{var p;return(p=R.current)==null?void 0:p.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:R,className:"hidden",onChange:p=>{var D;(D=p.target.files)!=null&&D[0]&&r(p.target.files[0])}}),e.jsx(N,{label:"Customize",icon:e.jsx(Ms,{className:"w-4 h-4"}),onClick:()=>C("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(N,{label:"Off",active:t===-1,onClick:()=>{i(-1),o()}}),s.map(p=>e.jsx(N,{label:p.label,value:p.language,active:t===p.index,onClick:()=>{i(p.index),o()}},p.index))]})]}),x==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(F,{label:"Customize",onBack:()=>C("main"),rightAction:e.jsx("button",{onClick:b,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Rs,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(K,{children:e.jsx(W,{label:"Native Video Subtitle",checked:c.useNative,onChange:p=>h({useNative:p})})}),!c.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{title:"Sync & Position",children:[e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsx("div",{className:"flex justify-between items-center mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ss,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Sync Offset"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>g(Math.round((j-.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Cs,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 bg-zinc-900 border border-white/5 rounded-lg h-8 flex items-center justify-center text-xs font-mono font-medium text-[var(--accent)]",children:[j>0?"+":"",(j==null?void 0:j.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>g(Math.round((j+.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Ns,{className:"w-4 h-4"})})]})]}),e.jsx(ne,{label:"Vertical Position",icon:e.jsx(Is,{className:"w-4 h-4"}),value:c.verticalOffset,min:0,max:200,step:5,onChange:p=>h({verticalOffset:p}),formatValue:p=>`${p}px`})]}),e.jsxs(K,{title:"Appearance",children:[e.jsx(ne,{label:"Text Size",icon:e.jsx(Ts,{className:"w-4 h-4"}),value:c.textSize,min:50,max:200,step:10,onChange:p=>h({textSize:p}),formatValue:p=>`${p}%`}),e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Mt,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Text Color"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1 bg-zinc-800/50 rounded-lg",children:[["#ffffff","#ffff00","#00ffff","#ff00ff","#ff0000","#00ff00"].map(p=>e.jsx("button",{onClick:()=>h({textColor:p}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${c.textColor===p?"ring-2 scale-110":""}`,style:{backgroundColor:p,"--tw-ring-color":"var(--accent)"}},p)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:c.textColor,onChange:p=>h({textColor:p.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(Zs,{label:"Text Style",value:c.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:p=>h({textStyle:p})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(W,{label:"Bold",icon:e.jsx(Ls,{className:"w-4 h-4"}),checked:c.isBold,onChange:p=>h({isBold:p})}),e.jsx(W,{label:"Fix Caps",icon:e.jsx($s,{className:"w-4 h-4"}),checked:c.fixCapitalization,onChange:p=>h({fixCapitalization:p})})]})]}),e.jsxs(K,{title:"Background",children:[e.jsx(ne,{label:"Opacity",icon:e.jsx(zs,{className:"w-4 h-4"}),value:c.backgroundOpacity,min:0,max:100,step:5,onChange:p=>h({backgroundOpacity:p}),formatValue:p=>`${p}%`}),e.jsx(W,{label:"Blur Background",icon:e.jsx(Es,{className:"w-4 h-4"}),checked:c.backgroundBlur,onChange:p=>h({backgroundBlur:p})}),c.backgroundBlur&&e.jsx(ne,{label:"Blur Intensity",value:c.backgroundBlurAmount,min:0,max:20,step:1,onChange:p=>h({backgroundBlurAmount:p}),formatValue:p=>`${p}px`})]})]})]})]})]})},Re=({content:s})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:s}}):e.jsx("span",{children:s}):e.jsx(e.Fragment,{children:s}),si=({x:s,y:t,items:i,onClose:r,containerWidth:o,containerHeight:c})=>{const h=m.useRef(null),[b,j]=m.useState({top:t,left:s,opacity:0});return m.useLayoutEffect(()=>{if(!h.current)return;const g=h.current.getBoundingClientRect(),u=g.width,w=g.height;let x=s,C=t;s+u>o-10&&(x=s-u),x<10&&(x=10),x+u>o&&(x=Math.max(10,o-u-10)),t+w>c-10&&(C=t-w);let R=c-20;C<10&&(C=10),C+w>c-10&&(C=Math.max(10,c-w-10)),j({top:C,left:x,maxHeight:R,opacity:1})},[s,t,i,o,c]),m.useEffect(()=>{const g=u=>{h.current&&!h.current.contains(u.target)&&r()};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[r]),e.jsx("div",{ref:h,className:"absolute z-50 min-w-[200px] bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl p-1.5 font-[family-name:var(--font-main)] overflow-y-auto hide-scrollbar flex flex-col",style:{top:b.top,left:b.left,maxHeight:b.maxHeight,opacity:b.opacity,borderRadius:"var(--radius-lg)"},onClick:g=>g.stopPropagation(),children:i.map((g,u)=>g.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},u):g.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(Re,{content:g.html||""})},u):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{g.disabled||(g.click?g.click(r):g.onClick&&g.onClick(r))},disabled:g.disabled,className:"w-full text-left px-3 py-2.5 flex items-center justify-between hover:bg-white/10 focus:bg-white/10 focus:outline-none transition-colors text-sm text-zinc-200 disabled:opacity-50 disabled:cursor-not-allowed group my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[g.icon&&e.jsx("span",{className:"text-zinc-400 w-4 h-4 flex items-center justify-center shrink-0 group-hover:text-zinc-300 transition-colors",children:e.jsx(Re,{content:g.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${g.checked?"text-[var(--accent)]":""}`,children:e.jsx(Re,{content:g.html||""})})]}),g.checked&&e.jsx(Pe,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),g.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},u))})},ii=({player:s,onClose:t})=>{const[i,r]=m.useState({});return m.useEffect(()=>{const o=()=>{var j;if(!s.video)return;const h=s.video,b=h.getVideoPlaybackQuality?h.getVideoPlaybackQuality():null;r({"Player Size":`${h.offsetWidth} x ${h.offsetHeight}`,"Video Resolution":`${h.videoWidth} x ${h.videoHeight}`,"Current Time":`${h.currentTime.toFixed(3)}s`,Duration:`${h.duration.toFixed(3)}s`,Volume:`${Math.round(h.volume*100)}%`,"Dropped Frames":b?b.droppedVideoFrames:"N/A",Buffer:h.buffered.length>0?`${(h.buffered.end(h.buffered.length-1)-h.currentTime).toFixed(2)}s`:"0s",Engine:((j=s.store.get().sources[s.store.get().currentSourceIndex])==null?void 0:j.type)||"native",URL:h.currentSrc})};o();const c=setInterval(o,1e3);return()=>clearInterval(c)},[s]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-[var(--bg-panel)] border border-white/10 rounded-xl w-full max-w-md shadow-2xl relative font-mono text-xs text-zinc-300 flex flex-col",style:{borderRadius:"var(--radius)",maxHeight:"90%"},children:[e.jsxs("div",{className:"p-5 pb-0 flex-shrink-0 relative",children:[e.jsx("button",{onClick:o=>{o.stopPropagation(),t()},className:"absolute top-3 right-3 p-1.5 text-zinc-400 hover:text-white hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Os,{className:"w-4 h-4"})}),e.jsx("h3",{className:"text-sm font-bold text-white mb-4 uppercase tracking-wider border-b border-white/10 pb-2",children:"Video Statistics"})]}),e.jsx("div",{className:"overflow-y-auto hide-scrollbar p-5 pt-0 space-y-2.5 flex-1 min-h-0",children:Object.entries(i).map(([o,c])=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-1",children:[e.jsx("span",{className:"text-zinc-500 font-bold shrink-0",children:o}),e.jsx("span",{className:"text-zinc-200 truncate select-all font-medium bg-white/5 px-1.5 py-0.5 rounded break-all text-right",title:String(c),children:String(c)})]},o))})]})})};function ni(s){if(!s)return"#ffffff";s=s.replace("#",""),s.length===3&&(s=s.split("").map(c=>c+c).join(""));const t=parseInt(s.substring(0,2),16),i=parseInt(s.substring(2,4),16),r=parseInt(s.substring(4,6),16);return(t*299+i*587+r*114)/1e3>=128?"#000000":"#ffffff"}const ri=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],ai=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],kt=({content:s,className:t,style:i})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("div",{className:t,style:i,dangerouslySetInnerHTML:{__html:s}}):e.jsx("div",{className:t,style:i,children:s}):e.jsx("div",{className:t,style:i,children:s}),$e=s=>{var pt,bt;const{src:t,type:i,sources:r,poster:o,autoPlay:c,thumbnails:h,textTracks:b,plugins:j,onGetInstance:g,...u}=s,w=u.screenshot??!1,x=u.pip??!0,C=u.setting??!0,R=u.fullscreen??!0,p=u.fullscreenWeb??!1,D=u.lock??!1,q=u.fastForward??!0,Tt=u.flip??!0,zt=u.aspectRatio??!0,Ae=u.hotKey??!0,It=u.backdrop??!0,he=u.gestureSeek??!1,Rt=u.centerControls??!0,Be=u.fetchTimeout??3e4;u.autoOrientation;const U=m.useRef(null),[n,Ve]=m.useState(null),[xe,me]=m.useState(!1),[Oe,Lt]=m.useState(0),[$t,Et]=m.useState(0),[He,Pt]=m.useState(!1),We=m.useMemo(()=>Ct(u),[]),a=m.useSyncExternalStore(m.useCallback(l=>n?n.store.subscribe(l):()=>{},[n]),()=>n?n.store.get():We,()=>We),Ft=m.useMemo(()=>ni(a.themeColor),[a.themeColor]),[L,Y]=m.useState(!1),[$,fe]=m.useState(!1),[E,z]=m.useState("main"),[I,De]=m.useState(null),qe=m.useRef(null);I&&(qe.current=I);const[Z,pe]=m.useState({x:0,y:0,visible:!1}),[At,_e]=m.useState(!1),Ge=Ie(L,300),Ue=Ie($,300),Qe=Ie(!!I,300),P=m.useCallback(()=>{Y(!1),fe(!1),De(null)},[]),[be,re]=m.useState(!1),[ae,ge]=m.useState(0),[Bt,Xe]=m.useState(!1),[Vt,Je]=m.useState(!1),[ve,oe]=m.useState(!1),[Ke,Ye]=m.useState([]),[Ze,et]=m.useState(null),[Ot,Ht]=m.useState(0),[_,tt]=m.useState(null),[Q,le]=m.useState(null),[li,st]=m.useState(null),[je,it]=m.useState(!1),we=m.useRef(null),nt=m.useRef(1),te=m.useRef(null),rt=m.useRef(0),ee=m.useRef(!1),se=m.useRef(null),G=m.useRef(null),ye=m.useRef(null),ke=m.useRef(null),ie=m.useRef(null);m.useEffect(()=>{if(Pt("ontouchstart"in window||navigator.maxTouchPoints>0),!U.current)return;const l=new Nt({...u,poster:o});j&&j.length>0&&j.forEach(y=>l.use(y)),l.attach(U.current),Ve(l),g&&g(l);const f=new ResizeObserver(y=>{for(const k of y)Lt(k.contentRect.height),Et(k.contentRect.width)});return f.observe(U.current),()=>{f.disconnect(),l.destroy(),Ve(null)}},[]),m.useEffect(()=>{if(!n)return;const l={};u.theme!==void 0&&u.theme!==a.theme&&(l.theme=u.theme),u.themeColor!==void 0&&u.themeColor!==a.themeColor&&(l.themeColor=u.themeColor),u.iconSize!==void 0&&u.iconSize!==a.iconSize&&(l.iconSize=u.iconSize),Object.keys(l).length>0&&n.setAppearance(l),u.volume!==void 0&&Math.abs(u.volume-a.volume)>.01&&n.setVolume(u.volume),u.muted!==void 0&&u.muted!==a.isMuted&&(u.muted?n.video.muted=!0:n.video.muted=!1)},[n,u.theme,u.themeColor,u.iconSize,u.volume,u.muted]),m.useEffect(()=>{if(!n)return;const l=b||[];r&&r.length>0?(me(!1),n.setSources(r,l)):t&&(me(!1),n.setSources([{url:t,type:i||"auto"}],l))},[t,i,r,b,n]),m.useEffect(()=>{n&&c&&n.play().catch(()=>{console.warn("Autoplay failed (likely needs user interaction)")})},[n,c]),m.useEffect(()=>{a.isPlaying&&!xe&&me(!0)},[a.isPlaying,xe]),m.useEffect(()=>{h&&n?cs(h,n.notify.bind(n),Be).then(l=>Ye(l)):Ye([])},[h,n,Be]),m.useEffect(()=>(Q&&(ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{le(null)},600)),()=>{ie.current&&clearTimeout(ie.current)}),[Q]),m.useEffect(()=>{const l=f=>{var k;if(!n||!Ae||((k=document.activeElement)==null?void 0:k.tagName)==="INPUT")return;switch(f.key.toLowerCase()){case" ":case"k":f.preventDefault(),n.togglePlay();break;case"arrowright":f.preventDefault(),n.skip(5);break;case"arrowleft":f.preventDefault(),n.skip(-5);break;case"arrowup":f.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":f.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":f.preventDefault(),n.toggleFullscreen();break;case"m":f.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(f.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n,Ae]);const at=()=>{n&&(n.setControlsVisible(!0),G.current&&clearTimeout(G.current),!(L||$||I)&&(G.current=setTimeout(()=>{!a.isPlaying||L||$||I||n.setControlsVisible(!1)},2500)))};m.useEffect(()=>{n&&(!L&&!$&&!I&&a.isPlaying?at():(L||$||I)&&(n.setControlsVisible(!0),G.current&&clearTimeout(G.current)))},[L,$,I,a.isPlaying,n]);const ot=m.useCallback(()=>{if(!(!q||!n||!a.isPlaying||a.isLocked)){if(L||$||I){P();return}nt.current=n.video.playbackRate,we.current=setTimeout(()=>{n.video.playbackRate=2,it(!0)},500)}},[q,n,a.isPlaying,a.isLocked,L,$,I]),Se=m.useCallback(()=>{we.current&&clearTimeout(we.current),je&&n&&(n.video.playbackRate=nt.current,it(!1))},[je,n]),Wt=l=>{if(ot(),L||$||I){P();return}he&&!a.isLocked&&(te.current=l.touches[0].clientX,rt.current=a.currentTime,ee.current=!1)},Dt=l=>{if(!a.isLocked&&he&&te.current!==null){const f=l.touches[0].clientX-te.current;if(Math.abs(f)>10&&(Se(),ee.current=!0,re(!0),U.current&&a.duration)){const y=U.current.getBoundingClientRect(),k=f/y.width,O=Math.max(0,Math.min(a.duration,rt.current+k*a.duration));ge(O)}}},qt=l=>{if(Se(),he&&ee.current){n==null||n.seek(ae),re(!1),ee.current=!1,te.current=null;return}te.current=null},Ce=l=>{if(!ye.current||!a.duration)return 0;const f=ye.current.getBoundingClientRect(),y="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(y-f.left)/f.width))*a.duration},lt=l=>{if(a.isLocked)return;(L||$||I)&&P(),re(!0),ge(Ce(l));const f=k=>ge(Ce(k)),y=k=>{n==null||n.seek(Ce(k)),re(!1),document.removeEventListener("mousemove",f),document.removeEventListener("touchmove",f),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y)};document.addEventListener("mousemove",f),document.addEventListener("touchmove",f),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)},ct=l=>{if(!ke.current)return 0;const f=ke.current.getBoundingClientRect(),y="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(y-f.left)/f.width))},dt=l=>{if(!n||a.isLocked)return;Xe(!0),n.setVolume(ct(l));const f=k=>n.setVolume(ct(k)),y=()=>{Xe(!1),document.removeEventListener("mousemove",f),document.removeEventListener("touchmove",f),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y)};document.addEventListener("mousemove",f),document.addEventListener("touchmove",f),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)},_t=l=>{if(!a.duration||a.isLive)return;const f=l.currentTarget.getBoundingClientRect(),y=(l.clientX-f.left)/f.width,k=y*a.duration;Ht(y*100),et(k),Ke.length>0&&tt(Ke.find(O=>k>=O.start&&k<O.end)||null)},ce=l=>{!n||a.isLocked||(n.skip(l==="forward"?10:-10),st(l),setTimeout(()=>st(null),300))},Gt=l=>{if(!n)return;if(ee.current){ee.current=!1;return}if(L||$||I){P();return}if(ve&&oe(!1),Z.visible&&pe({...Z,visible:!1}),n.setControlsVisible(!0),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{!a.isPlaying||L||$||I||n.setControlsVisible(!1)},2500),a.isLocked)return;const f=l.currentTarget.getBoundingClientRect(),y=l.clientX-f.left,k=f.width,O=Date.now();se.current?(clearTimeout(se.current),se.current=null,y<k*.35?(ce("rewind"),le({type:"rewind",id:O})):y>k*.65?(ce("forward"),le({type:"forward",id:O})):n.toggleFullscreen()):se.current=setTimeout(()=>{n.togglePlay(),se.current=null},250)},Ut=l=>{var y;if(l.preventDefault(),a.isLocked)return;const f=(y=U.current)==null?void 0:y.getBoundingClientRect();f&&pe({visible:!0,x:l.clientX-f.left,y:l.clientY-f.top})},Qt=l=>{if(l.stopPropagation(),ve){oe(!1);return}He?oe(!0):n==null||n.toggleMute()},Xt=a.isMuted||a.volume===0?xs:a.volume<.5?hs:us,Ne=Math.max(100,Oe-120),Jt=()=>{switch(a.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},Kt=()=>{switch(a.iconSize){case"small":return"p-2 min-w-[32px] min-h-[32px]";case"large":return"p-3 min-w-[44px] min-h-[44px]";default:return"p-2.5 min-w-[36px] min-h-[36px]"}},A=Jt(),V=Kt(),X=(()=>{switch(a.iconSize){case"small":return{playBtn:"w-14 h-14",playIcon:"w-6 h-6",skipBtn:"w-10 h-10",skipIcon:"w-5 h-5"};case"large":return{playBtn:"w-24 h-24",playIcon:"w-12 h-12",skipBtn:"w-16 h-16",skipIcon:"w-8 h-8"};default:return{playBtn:"w-20 h-20",playIcon:"w-9 h-9",skipBtn:"w-12 h-12",skipIcon:"w-6 h-6"}}})(),Yt=!a.isLocked&&(a.controlsVisible||!a.isPlaying||L||$||I),ut=Vt||Bt||ve,Me=It?"backdrop-blur-xl bg-black/80":"bg-black/95",ht=m.useMemo(()=>{const l=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];return u.controls&&u.controls.forEach(f=>{const y=l.find(k=>k.id===f.id);y?Object.assign(y,f):l.push(f)}),l.filter(f=>!(f.id==="screenshot"&&!w||f.id==="pip"&&!x||f.id==="settings"&&!C||f.id==="fullscreen"&&!R||f.id==="fullscreenWeb"&&!p)).sort((f,y)=>f.index-y.index)},[u.controls,w,x,C,R,p]),xt=l=>{var f,y,k,O,gt;if(!l.isBuiltIn){const d=l.id||`ctrl-${l.index}`,T=I===d,H=T||Qe.isMounted&&qe.current===d;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:M=>{if(M.stopPropagation(),l.children){const Te=T;P(),Te||De(d)}else l.click?l.click(n):l.onClick&&l.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${V} ${T?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${l.className||""}`,style:{borderRadius:"var(--radius)",...l.style},title:l.tooltip,children:e.jsx(kt,{content:l.html||""})}),l.children&&H&&e.jsx(ei,{items:l.children,onClose:P,maxHeight:Ne,className:`strata-backdrop ${Me} ${Qe.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},l.index)}switch(l.id){case"play":return e.jsx("button",{onClick:()=>n==null?void 0:n.togglePlay(),className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},children:a.isPlaying?e.jsx(jt,{className:`${A} fill-current`}):e.jsx(vt,{className:`${A} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&Je(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&Je(!1)},children:[e.jsx("button",{onClick:Qt,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Xt,{className:A})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${ut?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:ke,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:dt,onTouchStart:dt,children:[e.jsx("div",{className:"w-full h-1 bg-white/20 overflow-hidden",style:{borderRadius:"var(--radius-full)"},children:e.jsx("div",{className:"h-full bg-white",style:{width:`${(a.isMuted?0:a.volume)*100}%`,borderRadius:"var(--radius-full)"}})}),e.jsx("div",{className:"absolute h-3 w-3 bg-white shadow-md top-1/2 -translate-y-1/2 pointer-events-none",style:{left:`calc(${(a.isMuted?0:a.volume)*100}% * 0.85 + 4px)`,borderRadius:"var(--radius-full)"}})]})}),ut&&e.jsx("div",{className:"strata-tooltip absolute bottom-full mb-2 px-1.5 py-0.5 rounded text-[10px] font-bold font-mono shadow-lg pointer-events-none whitespace-nowrap z-50 transform -translate-x-1/2",style:{left:`calc(52px + ${(a.isMuted?0:a.volume)*80}px)`},children:a.isMuted?"0%":`${Math.round(a.volume*100)}%`})]},"volume");case"time":return u.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${a.themeColor}1a`,borderColor:`${a.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:a.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:a.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[ze(be?ae:a.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",ze(a.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:d=>{d.stopPropagation();const T=$;P(),T||fe(!0)},className:`strata-control-btn transition-colors focus:outline-none ${V} ${$?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(gs,{className:A})}),Ue.isMounted&&e.jsx(ti,{tracks:a.subtitleTracks,current:a.currentSubtitle,onSelect:d=>n==null?void 0:n.setSubtitle(d),onUpload:d=>n==null?void 0:n.addTextTrack(d,d.name),onClose:()=>fe(!1),settings:a.subtitleSettings,onSettingsChange:d=>n==null?void 0:n.updateSubtitleSettings(d),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:a.subtitleOffset,onOffsetChange:d=>n==null?void 0:n.setSubtitleOffset(d),maxHeight:Ne,animationClass:`strata-backdrop ${Me} ${Ue.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onClick:()=>n==null?void 0:n.screenshot(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(Ps,{className:A})},"ss");case"pip":return e.jsx("button",{onClick:()=>n==null?void 0:n.togglePip(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},children:e.jsx(bs,{className:A})},"pip");case"download":return e.jsx("button",{onClick:()=>n==null?void 0:n.download(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},children:e.jsx(vs,{className:A})},"dl");case"fullscreen":return e.jsx("button",{onClick:()=>n==null?void 0:n.toggleFullscreen(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${V}`,style:{borderRadius:"var(--radius)"},children:a.isFullscreen?e.jsx(fs,{className:A}):e.jsx(ms,{className:A})},"fs");case"fullscreenWeb":return e.jsx("button",{onClick:()=>n==null?void 0:n.toggleWebFullscreen(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${V} ${a.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Bs,{className:A})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:d=>{d.stopPropagation();const T=L;P(),T||(Y(!0),z("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${V} ${L?"rotate-90 text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(ps,{className:A})}),Ge.isMounted&&e.jsx(Fe,{onClose:()=>Y(!1),align:"right",maxHeight:Ne,className:`strata-backdrop ${Me} ${Ge.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[E==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),a.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(N,{label:"Source",icon:e.jsx(Ws,{className:"w-4 h-4"}),value:((f=a.sources[a.currentSourceIndex])==null?void 0:f.name)||`Source ${a.currentSourceIndex+1}`,onClick:()=>z("sources"),hasSubmenu:!0}),e.jsx(J,{})]}),e.jsx(N,{label:"Quality",icon:e.jsx(Ds,{className:"w-4 h-4"}),value:a.currentQuality===-1?"Auto":`${(y=a.qualityLevels[a.currentQuality])==null?void 0:y.height}p`,onClick:()=>z("quality"),hasSubmenu:!0}),e.jsx(N,{label:"Speed",icon:e.jsx(Gs,{className:"w-4 h-4"}),value:`${a.playbackRate}x`,onClick:()=>z("speed"),hasSubmenu:!0}),e.jsx(N,{label:"Audio",icon:e.jsx(Us,{className:"w-4 h-4"}),value:((k=a.audioTracks[a.currentAudioTrack])==null?void 0:k.label)||"Default",onClick:()=>z("audio"),hasSubmenu:!0}),e.jsx(J,{}),Tt&&e.jsx(N,{label:"Flip",icon:e.jsx(Qs,{className:"w-4 h-4"}),value:a.flipState.horizontal?"H":a.flipState.vertical?"V":"Normal",onClick:()=>z("flip"),hasSubmenu:!0}),zt&&e.jsx(N,{label:"Aspect Ratio",icon:e.jsx(qs,{className:"w-4 h-4"}),value:a.aspectRatio,onClick:()=>z("ratio"),hasSubmenu:!0}),e.jsx(N,{label:"Audio Boost",icon:e.jsx(_s,{className:"w-4 h-4"}),value:a.audioGain>1?`${a.audioGain}x`:"Off",onClick:()=>z("boost"),hasSubmenu:!0}),e.jsx(J,{}),e.jsx(N,{label:"Watch Party",icon:e.jsx(ks,{className:"w-4 h-4"}),onClick:()=>z("party"),hasSubmenu:!0}),e.jsx(N,{label:"Cast to Device",icon:e.jsx(ys,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),Y(!1)}}),u.settings&&u.settings.length>0&&e.jsx(J,{}),(O=u.settings)==null?void 0:O.map((d,T)=>d.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(W,{label:d.html,icon:d.icon,checked:d.switch,tooltip:d.tooltip,onChange:H=>{d.onSwitch&&d.onSwitch(d,H)}})},`cust-${T}`):e.jsx(N,{label:d.html,icon:d.icon,value:d.currentLabel||d.value,hasSubmenu:!!d.children,onClick:()=>{d.children?z(`custom-${T}`):(d.click?d.click(d):d.onClick&&d.onClick(d),Y(!1))}},`cust-${T}`)),e.jsx(J,{}),e.jsx(N,{label:"Appearance",icon:e.jsx(Mt,{className:"w-4 h-4"}),onClick:()=>z("appearance"),hasSubmenu:!0})]}),E.startsWith("custom-")&&(()=>{var H;const d=parseInt(E.split("-")[1]),T=(H=u.settings)==null?void 0:H[d];return!T||!T.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(F,{label:T.html||"Menu",onBack:()=>z("main")}),T.children.map((M,Te)=>e.jsxs(m.Fragment,{children:[M.separator&&e.jsx(J,{}),M.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(W,{label:M.html,checked:M.switch,onChange:es=>M.onSwitch&&M.onSwitch(M,es)})}),!M.separator&&M.switch===void 0&&e.jsx(N,{label:M.html,icon:M.icon,value:M.value,active:M.active,onClick:()=>{M.onClick?M.onClick(M):M.click&&M.click(M),Y(!1)}})]},Te))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio"].includes(E)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[E==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Select Source",onBack:()=>z("main")}),a.sources.map((d,T)=>{const H=a.sourceStatuses[T],M=H==="success"?e.jsx(Xs,{className:"w-3.5 h-3.5 text-emerald-500"}):H==="error"?e.jsx(Js,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(N,{label:d.name||`Source ${T+1}`,value:d.type,active:a.currentSourceIndex===T,rightIcon:M,onClick:()=>n==null?void 0:n.switchSource(T)},T)})]}),E==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Speed",onBack:()=>z("main")}),[.5,1,1.5,2].map(d=>e.jsx(N,{label:`${d}x`,active:a.playbackRate===d,onClick:()=>n.video.playbackRate=d},d))]}),E==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Quality",onBack:()=>z("main")}),e.jsx(N,{label:"Auto",active:a.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),a.qualityLevels.map(d=>e.jsx(N,{label:`${d.height}p`,value:`${Math.round(d.bitrate/1e3)}k`,active:a.currentQuality===d.index,onClick:()=>n==null?void 0:n.setQuality(d.index)},d.index))]}),E==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Audio Track",onBack:()=>z("main")}),a.audioTracks.length===0&&e.jsx("div",{className:"px-4 py-3 text-zinc-500 text-xs text-center",children:"No tracks available"}),a.audioTracks.map(d=>e.jsx(N,{label:d.label,value:d.language,active:a.currentAudioTrack===d.index,onClick:()=>n==null?void 0:n.setAudioTrack(d.index)},d.index))]}),E==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Audio Boost",onBack:()=>z("main")}),[1,1.5,2,3].map(d=>e.jsx(N,{label:d===1?"Off":`${d}x`,active:a.audioGain===d,onClick:()=>n==null?void 0:n.setAudioGain(d)},d))]}),E==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Video Flip",onBack:()=>z("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(W,{label:"Horizontal Flip",checked:a.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(W,{label:"Vertical Flip",checked:a.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),E==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Aspect Ratio",onBack:()=>z("main")}),["default","16:9","4:3"].map(d=>e.jsx(N,{label:d==="default"?"Default":d,active:a.aspectRatio===d,onClick:()=>n==null?void 0:n.setAspectRatio(d)},d))]}),E==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Watch Party",onBack:()=>z("main")}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-xs text-zinc-400 leading-relaxed",children:"Create a synchronized room on WatchParty.me to watch together."}),e.jsx("a",{href:`https://www.watchparty.me/create?video=${encodeURIComponent(((gt=a.sources[a.currentSourceIndex])==null?void 0:gt.url)||t||"")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-full py-2.5 bg-[var(--accent)] hover:opacity-90 text-white font-medium transition-opacity text-xs",style:{borderRadius:"var(--radius)"},children:"Create Room"})]})]}),E==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Appearance",onBack:()=>z("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx(K,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:ai.map(d=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:d.value,themeColor:d.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${a.theme===d.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:d.label},d.value))})}),e.jsx(K,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(d=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:d}),className:`py-1.5 text-xs font-medium transition-colors ${a.iconSize===d?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:d.charAt(0).toUpperCase()+d.slice(1)},d))})}),e.jsxs(K,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:ri.map(d=>e.jsx("button",{title:d.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:d.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${a.themeColor===d.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:d.value,borderRadius:"var(--radius-full)"},children:a.themeColor===d.value&&e.jsx(Pe,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},d.value))}),e.jsx("div",{className:"px-3 pt-4",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white/5 p-2 hover:bg-white/10 transition-colors group",style:{borderRadius:"var(--radius)"},children:[e.jsx("div",{className:"relative w-6 h-6 overflow-hidden ring-1 ring-white/20",style:{borderRadius:"var(--radius-full)"},children:e.jsx("input",{type:"color",value:a.themeColor,onChange:d=>n==null?void 0:n.setAppearance({themeColor:d.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})}),e.jsx("span",{className:"text-xs text-zinc-400 font-medium group-hover:text-zinc-200",children:"Custom Color"}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-500 ml-auto uppercase",children:a.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},Zt=m.useMemo(()=>{const l=[{html:"Playback",isLabel:!0},{html:"Loop",checked:a.isLooping,onClick:()=>n==null?void 0:n.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>n==null?void 0:n.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>n==null?void 0:n.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:a.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:a.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"4:3",checked:a.aspectRatio==="4:3",onClick:()=>n==null?void 0:n.setAspectRatio("4:3")},{separator:!0},{html:"Video Info",icon:e.jsx(Hs,{className:"w-3.5 h-3.5"}),onClick:()=>_e(!0)},{separator:!0}];return u.contextmenu&&l.push(...u.contextmenu),l.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),l.push({html:"Close",onClick:f=>f(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),l},[u.contextmenu,a.aspectRatio,a.isLooping,n]),mt=a.isWebFullscreen,ft=e.jsxs("div",{id:u.id,ref:U,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset ${mt?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius)]"} ${u.container||""}`,style:{touchAction:"manipulation","--accent":a.themeColor,"--accent-contrast":Ft},onMouseMove:at,onMouseLeave:()=>{a.isPlaying&&!L&&!$&&!I&&n&&n.setControlsVisible(!1)},onMouseDown:ot,onMouseUp:Se,onTouchStart:Wt,onTouchMove:Dt,onTouchEnd:qt,onContextMenu:Ut,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":a.theme,children:[e.jsx("style",{children:`
|
|
25
|
+
`})]})]}),Zs=({label:s,value:t,options:i,onChange:r,icon:l})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[l&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(de,{content:l})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:s})]}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:u=>r(u.target.value),className:"w-full bg-zinc-800 border-[length:var(--border-width)] border-white/10 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:ring-2 appearance-none hover:bg-zinc-700 transition-colors cursor-pointer",style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius)"},children:i.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-400",children:e.jsx("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1 1L5 5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),K=({title:s,children:t})=>e.jsxs("div",{className:"py-2",children:[s&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:s}),e.jsx("div",{className:"space-y-0.5",children:t})]}),Fe=({children:s,onClose:t,align:i="right",maxHeight:r,className:l})=>{const u=p.useRef(null),d=p.useRef(null),[g,w]=p.useState("auto"),f=i==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";p.useLayoutEffect(()=>{if(!d.current)return;const j=()=>{d.current&&w(d.current.offsetHeight)},x=new ResizeObserver(j);return x.observe(d.current),j(),()=>x.disconnect()},[]);const h={height:g==="auto"?"auto":`${g+14}px`,maxHeight:r?`${r}px`:void 0};return e.jsx("div",{ref:u,className:`absolute bottom-full mb-4 ${f} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${l}`,style:{...h,borderRadius:"var(--radius-lg)"},onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),onTouchStart:j=>j.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:d,children:s})})})},ue=({content:s,className:t})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:s}}):e.jsx("span",{className:t,children:s}):e.jsx("span",{className:t,children:s}),M=({label:s,value:t,active:i,onClick:r,hasSubmenu:l,icon:u,rightIcon:d})=>e.jsxs("button",{onClick:r,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-white/10 transition-colors text-left text-zinc-200 active:bg-white/5 focus:outline-none focus:bg-white/10 group overflow-hidden my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[u&&e.jsx("span",{className:"text-zinc-400 shrink-0 group-hover:text-zinc-300 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(ue,{content:u})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${i?"text-[var(--accent)]":""}`,title:typeof s=="string"?s:void 0,children:e.jsx(ue,{content:s})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400 shrink-0",children:[t&&e.jsx("span",{className:"text-xs font-medium truncate max-w-[60px]",title:t,children:e.jsx(ue,{content:t})}),d,i&&e.jsx(Ee,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),l&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),A=({label:s,onBack:t,rightAction:i})=>e.jsxs("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:[e.jsxs("button",{className:"flex items-center gap-2 hover:text-white transition-colors focus:outline-none",onClick:t,children:[e.jsx(js,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(ue,{content:s})})]}),i]}),J=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),ei=({items:s,onClose:t,title:i,maxHeight:r,className:l})=>{const[u,d]=p.useState([]),g=u.length>0?u[u.length-1]:null,w=g?g.children||[]:s,f=g?g.html:i||"Menu",h=()=>{d(x=>x.slice(0,-1))},j=x=>{x.children&&d(N=>[...N,x])};return e.jsx(Fe,{onClose:t,maxHeight:r,className:l,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[u.length>0?e.jsx(A,{label:f||"Menu",onBack:h}):i&&e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:i})}),e.jsx("div",{className:"pb-1",children:w.map((x,N)=>x.separator?e.jsx(J,{},N):x.range?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:x.html,icon:x.icon,value:x.value??x.min??0,min:x.min??0,max:x.max??100,step:x.step??1,onChange:P=>x.onRange&&x.onRange(P),formatValue:x.formatValue})},N):x.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(D,{label:x.html,icon:x.icon,checked:x.switch,tooltip:x.tooltip,onChange:P=>x.onSwitch&&x.onSwitch(x,P)})},N):e.jsx(p.Fragment,{children:e.jsx(M,{label:x.html,icon:x.icon,value:x.currentLabel||x.value,active:x.active,hasSubmenu:!!x.children,onClick:()=>{x.children?j(x):x.onClick?(x.onClick(x),!x.switch&&!x.range&&t()):x.click&&(x.click(x),t())}})},N))})]})})},ti=({tracks:s,current:t,onSelect:i,onUpload:r,onClose:l,settings:u,onSettingsChange:d,onReset:g,offset:w,onOffsetChange:f,maxHeight:h,animationClass:j})=>{const[x,N]=p.useState("main"),P=p.useRef(null);return e.jsxs(Fe,{onClose:l,align:"right",maxHeight:h,className:j,children:[x==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{children:[e.jsx(M,{label:"Upload Subtitle",icon:e.jsx(ws,{className:"w-4 h-4"}),onClick:()=>{var b;return(b=P.current)==null?void 0:b.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:P,className:"hidden",onChange:b=>{var q;(q=b.target.files)!=null&&q[0]&&r(b.target.files[0])}}),e.jsx(M,{label:"Customize",icon:e.jsx(Ms,{className:"w-4 h-4"}),onClick:()=>N("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(M,{label:"Off",active:t===-1,onClick:()=>{i(-1),l()}}),s.map(b=>e.jsx(M,{label:b.label,value:b.language,active:t===b.index,onClick:()=>{i(b.index),l()}},b.index))]})]}),x==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(A,{label:"Customize",onBack:()=>N("main"),rightAction:e.jsx("button",{onClick:g,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Is,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(K,{children:e.jsx(D,{label:"Native Video Subtitle",checked:u.useNative,onChange:b=>d({useNative:b})})}),!u.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{title:"Sync & Position",children:[e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsx("div",{className:"flex justify-between items-center mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ss,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Sync Offset"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>f(Math.round((w-.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Cs,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 bg-zinc-900 border border-white/5 rounded-lg h-8 flex items-center justify-center text-xs font-mono font-medium text-[var(--accent)]",children:[w>0?"+":"",(w==null?void 0:w.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>f(Math.round((w+.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Ns,{className:"w-4 h-4"})})]})]}),e.jsx(ne,{label:"Vertical Position",icon:e.jsx(Rs,{className:"w-4 h-4"}),value:u.verticalOffset,min:0,max:200,step:5,onChange:b=>d({verticalOffset:b}),formatValue:b=>`${b}px`})]}),e.jsxs(K,{title:"Appearance",children:[e.jsx(ne,{label:"Text Size",icon:e.jsx(Ts,{className:"w-4 h-4"}),value:u.textSize,min:50,max:200,step:10,onChange:b=>d({textSize:b}),formatValue:b=>`${b}%`}),e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(zt,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Text Color"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1 bg-zinc-800/50 rounded-lg",children:[["#ffffff","#ffff00","#00ffff","#ff00ff","#ff0000","#00ff00"].map(b=>e.jsx("button",{onClick:()=>d({textColor:b}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${u.textColor===b?"ring-2 scale-110":""}`,style:{backgroundColor:b,"--tw-ring-color":"var(--accent)"}},b)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:u.textColor,onChange:b=>d({textColor:b.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(Zs,{label:"Text Style",value:u.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:b=>d({textStyle:b})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(D,{label:"Bold",icon:e.jsx(Ps,{className:"w-4 h-4"}),checked:u.isBold,onChange:b=>d({isBold:b})}),e.jsx(D,{label:"Fix Caps",icon:e.jsx(Ls,{className:"w-4 h-4"}),checked:u.fixCapitalization,onChange:b=>d({fixCapitalization:b})})]})]}),e.jsxs(K,{title:"Background",children:[e.jsx(ne,{label:"Opacity",icon:e.jsx(zs,{className:"w-4 h-4"}),value:u.backgroundOpacity,min:0,max:100,step:5,onChange:b=>d({backgroundOpacity:b}),formatValue:b=>`${b}%`}),e.jsx(D,{label:"Blur Background",icon:e.jsx($s,{className:"w-4 h-4"}),checked:u.backgroundBlur,onChange:b=>d({backgroundBlur:b})}),u.backgroundBlur&&e.jsx(ne,{label:"Blur Intensity",value:u.backgroundBlurAmount,min:0,max:20,step:1,onChange:b=>d({backgroundBlurAmount:b}),formatValue:b=>`${b}px`})]})]})]})]})]})},Ie=({content:s})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:s}}):e.jsx("span",{children:s}):e.jsx(e.Fragment,{children:s}),si=({x:s,y:t,items:i,onClose:r,containerWidth:l,containerHeight:u})=>{const d=p.useRef(null),[g,w]=p.useState({top:t,left:s,opacity:0});return p.useLayoutEffect(()=>{if(!d.current)return;const f=d.current.getBoundingClientRect(),h=f.width,j=f.height;let x=s,N=t;s+h>l-10&&(x=s-h),x<10&&(x=10),x+h>l&&(x=Math.max(10,l-h-10)),t+j>u-10&&(N=t-j);let P=u-20;N<10&&(N=10),N+j>u-10&&(N=Math.max(10,u-j-10)),w({top:N,left:x,maxHeight:P,opacity:1})},[s,t,i,l,u]),p.useEffect(()=>{const f=h=>{d.current&&!d.current.contains(h.target)&&r()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r]),e.jsx("div",{ref:d,className:"absolute z-50 min-w-[200px] bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl p-1.5 font-[family-name:var(--font-main)] overflow-y-auto hide-scrollbar flex flex-col",style:{top:g.top,left:g.left,maxHeight:g.maxHeight,opacity:g.opacity,borderRadius:"var(--radius-lg)"},onClick:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),onTouchStart:f=>f.stopPropagation(),children:i.map((f,h)=>f.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},h):f.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(Ie,{content:f.html||""})},h):e.jsxs(p.Fragment,{children:[e.jsxs("button",{onClick:()=>{f.disabled||(f.click?f.click(r):f.onClick&&f.onClick(r))},disabled:f.disabled,className:"w-full text-left px-3 py-2.5 flex items-center justify-between hover:bg-white/10 focus:bg-white/10 focus:outline-none transition-colors text-sm text-zinc-200 disabled:opacity-50 disabled:cursor-not-allowed group my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[f.icon&&e.jsx("span",{className:"text-zinc-400 w-4 h-4 flex items-center justify-center shrink-0 group-hover:text-zinc-300 transition-colors",children:e.jsx(Ie,{content:f.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${f.checked?"text-[var(--accent)]":""}`,children:e.jsx(Ie,{content:f.html||""})})]}),f.checked&&e.jsx(Ee,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),f.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},h))})},ii=({player:s,onClose:t})=>{const[i,r]=p.useState({});return p.useEffect(()=>{const l=()=>{var w;if(!s.video)return;const d=s.video,g=d.getVideoPlaybackQuality?d.getVideoPlaybackQuality():null;r({"Player Size":`${d.offsetWidth} x ${d.offsetHeight}`,"Video Resolution":`${d.videoWidth} x ${d.videoHeight}`,"Current Time":`${d.currentTime.toFixed(3)}s`,Duration:`${d.duration.toFixed(3)}s`,Volume:`${Math.round(d.volume*100)}%`,"Dropped Frames":g?g.droppedVideoFrames:"N/A",Buffer:d.buffered.length>0?`${(d.buffered.end(d.buffered.length-1)-d.currentTime).toFixed(2)}s`:"0s",Engine:((w=s.store.get().sources[s.store.get().currentSourceIndex])==null?void 0:w.type)||"native",URL:d.currentSrc})};l();const u=setInterval(l,1e3);return()=>clearInterval(u)},[s]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-[var(--bg-panel)] border border-white/10 rounded-xl w-full max-w-md shadow-2xl relative font-mono text-xs text-zinc-300 flex flex-col",style:{borderRadius:"var(--radius)",maxHeight:"90%"},children:[e.jsxs("div",{className:"p-5 pb-0 flex-shrink-0 relative",children:[e.jsx("button",{onClick:l=>{l.stopPropagation(),t()},className:"absolute top-3 right-3 p-1.5 text-zinc-400 hover:text-white hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Os,{className:"w-4 h-4"})}),e.jsx("h3",{className:"text-sm font-bold text-white mb-4 uppercase tracking-wider border-b border-white/10 pb-2",children:"Video Statistics"})]}),e.jsx("div",{className:"overflow-y-auto hide-scrollbar p-5 pt-0 space-y-2.5 flex-1 min-h-0",children:Object.entries(i).map(([l,u])=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-1",children:[e.jsx("span",{className:"text-zinc-500 font-bold shrink-0",children:l}),e.jsx("span",{className:"text-zinc-200 truncate select-all font-medium bg-white/5 px-1.5 py-0.5 rounded break-all text-right",title:String(u),children:String(u)})]},l))})]})})};function ni(s){if(!s)return"#ffffff";s=s.replace("#",""),s.length===3&&(s=s.split("").map(u=>u+u).join(""));const t=parseInt(s.substring(0,2),16),i=parseInt(s.substring(2,4),16),r=parseInt(s.substring(4,6),16);return(t*299+i*587+r*114)/1e3>=128?"#000000":"#ffffff"}const ri=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],oi=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],Ct=({content:s,className:t,style:i})=>typeof s=="string"?s.trim().startsWith("<")?e.jsx("div",{className:t,style:i,dangerouslySetInnerHTML:{__html:s}}):e.jsx("div",{className:t,style:i,children:s}):e.jsx("div",{className:t,style:i,children:s}),Le=s=>{var gt,vt;const{src:t,type:i,sources:r,poster:l,autoPlay:u,thumbnails:d,textTracks:g,plugins:w,onGetInstance:f,...h}=s,j=h.screenshot??!1,x=h.pip??!0,N=h.setting??!0,P=h.fullscreen??!0,b=h.fullscreenWeb??!1,q=h.lock??!1,_=h.fastForward??!0,Rt=h.flip??!0,It=h.aspectRatio??!0,Ae=h.hotKey??!0,Pt=h.backdrop??!0,he=h.gestureSeek??!1,Lt=h.centerControls??!0,Be=h.fetchTimeout??3e4;h.autoOrientation;const E=p.useRef(null),[n,Ve]=p.useState(null),[pe,xe]=p.useState(!1),[Oe,He]=p.useState(0),[$t,We]=p.useState(0),[De,Et]=p.useState(!1),qe=p.useMemo(()=>Mt(h),[]),o=p.useSyncExternalStore(p.useCallback(c=>n?n.store.subscribe(c):()=>{},[n]),()=>n?n.store.get():qe,()=>qe),Ft=p.useMemo(()=>ni(o.themeColor),[o.themeColor]),[L,Y]=p.useState(!1),[$,me]=p.useState(!1),[F,z]=p.useState("main"),[I,_e]=p.useState(null),Ge=p.useRef(null);I&&(Ge.current=I);const[Z,fe]=p.useState({x:0,y:0,visible:!1}),[At,Ue]=p.useState(!1),Qe=Re(L,300),Xe=Re($,300),Je=Re(!!I,300),R=p.useCallback(()=>{Y(!1),me(!1),_e(null),fe(c=>({...c,visible:!1}))},[]),[be,re]=p.useState(!1),[oe,ge]=p.useState(0),[Bt,Ke]=p.useState(!1),[Vt,Ye]=p.useState(!1),[ve,ae]=p.useState(!1),[Ze,et]=p.useState([]),[tt,st]=p.useState(null),[Ot,Ht]=p.useState(0),[G,it]=p.useState(null),[Q,le]=p.useState(null),[li,nt]=p.useState(null),[we,rt]=p.useState(!1),je=p.useRef(null),ot=p.useRef(1),te=p.useRef(null),at=p.useRef(0),ee=p.useRef(!1),se=p.useRef(null),U=p.useRef(null),ye=p.useRef(null),ke=p.useRef(null),ie=p.useRef(null);p.useLayoutEffect(()=>{n&&E.current&&n.attach(E.current)},[n,o.isWebFullscreen]),p.useLayoutEffect(()=>{if(!E.current)return;(()=>{E.current&&(He(E.current.clientHeight),We(E.current.clientWidth))})();const m=new ResizeObserver(y=>{for(const S of y)He(S.contentRect.height),We(S.contentRect.width)});return m.observe(E.current),()=>{m.disconnect()}},[o.isWebFullscreen]),p.useEffect(()=>{if(Et("ontouchstart"in window||navigator.maxTouchPoints>0),!E.current)return;const c=new Tt({...h,poster:l});return w&&w.length>0&&w.forEach(m=>c.use(m)),c.attach(E.current),Ve(c),f&&f(c),()=>{c.destroy(),Ve(null)}},[]),p.useEffect(()=>{if(!n)return;const c={};h.theme!==void 0&&h.theme!==o.theme&&(c.theme=h.theme),h.themeColor!==void 0&&h.themeColor!==o.themeColor&&(c.themeColor=h.themeColor),h.iconSize!==void 0&&h.iconSize!==o.iconSize&&(c.iconSize=h.iconSize),Object.keys(c).length>0&&n.setAppearance(c),h.volume!==void 0&&Math.abs(h.volume-o.volume)>.01&&n.setVolume(h.volume),h.muted!==void 0&&h.muted!==o.isMuted&&(h.muted?n.video.muted=!0:n.video.muted=!1)},[n,h.theme,h.themeColor,h.iconSize,h.volume,h.muted]),p.useEffect(()=>{if(!n)return;const c=g||[];r&&r.length>0?(xe(!1),n.setSources(r,c)):t&&(xe(!1),n.setSources([{url:t,type:i||"auto"}],c))},[t,i,r,g,n]),p.useEffect(()=>{n&&u&&n.play().catch(()=>{console.warn("Autoplay failed (likely needs user interaction)")})},[n,u]),p.useEffect(()=>{o.isPlaying&&!pe&&xe(!0)},[o.isPlaying,pe]),p.useEffect(()=>{d&&n?cs(d,n.notify.bind(n),Be).then(c=>et(c)):et([])},[d,n,Be]),p.useEffect(()=>(Q&&(ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{le(null)},600)),()=>{ie.current&&clearTimeout(ie.current)}),[Q]),p.useEffect(()=>{const c=m=>{var S;if(!n||!Ae||((S=document.activeElement)==null?void 0:S.tagName)==="INPUT")return;switch(m.key.toLowerCase()){case" ":case"k":m.preventDefault(),n.togglePlay();break;case"arrowright":m.preventDefault(),n.skip(5);break;case"arrowleft":m.preventDefault(),n.skip(-5);break;case"arrowup":m.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":m.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":m.preventDefault(),n.toggleFullscreen();break;case"m":m.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(m.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,Ae]);const lt=()=>{n&&(n.setControlsVisible(!0),U.current&&clearTimeout(U.current),!(L||$||I)&&(U.current=setTimeout(()=>{!o.isPlaying||L||$||I||n.setControlsVisible(!1)},2500)))};p.useEffect(()=>{n&&(!L&&!$&&!I&&o.isPlaying?lt():(L||$||I)&&(n.setControlsVisible(!0),U.current&&clearTimeout(U.current)))},[L,$,I,o.isPlaying,n]);const ct=p.useCallback(()=>{if(!(!_||!n||!o.isPlaying||o.isLocked)){if(L||$||I){R();return}ot.current=n.video.playbackRate,je.current=setTimeout(()=>{n.video.playbackRate=2,rt(!0)},500)}},[_,n,o.isPlaying,o.isLocked,L,$,I]),Se=p.useCallback(()=>{je.current&&clearTimeout(je.current),we&&n&&(n.video.playbackRate=ot.current,rt(!1))},[we,n]),Wt=c=>{if(ct(),L||$||I){R();return}he&&!o.isLocked&&(te.current=c.touches[0].clientX,at.current=o.currentTime,ee.current=!1)},Dt=c=>{if(!o.isLocked&&he&&te.current!==null){const m=c.touches[0].clientX-te.current;if(Math.abs(m)>10&&(Se(),ee.current=!0,re(!0),E.current&&o.duration)){const y=E.current.getBoundingClientRect(),S=m/y.width,H=Math.max(0,Math.min(o.duration,at.current+S*o.duration));ge(H)}}},qt=c=>{if(Se(),he&&ee.current){n==null||n.seek(oe),re(!1),ee.current=!1,te.current=null;return}te.current=null},Ce=c=>{if(!ye.current||!o.duration)return 0;const m=ye.current.getBoundingClientRect(),y="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(y-m.left)/m.width))*o.duration},ut=c=>{if(c.stopPropagation(),o.isLocked)return;(L||$||I)&&R(),re(!0),ge(Ce(c));const m=S=>ge(Ce(S)),y=S=>{n==null||n.seek(Ce(S)),re(!1),document.removeEventListener("mousemove",m),document.removeEventListener("touchmove",m),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y)};document.addEventListener("mousemove",m),document.addEventListener("touchmove",m),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)},dt=c=>{if(!ke.current)return 0;const m=ke.current.getBoundingClientRect(),y="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(y-m.left)/m.width))},ht=c=>{if(c.stopPropagation(),!n||o.isLocked)return;Ke(!0),n.setVolume(dt(c));const m=S=>n.setVolume(dt(S)),y=()=>{Ke(!1),document.removeEventListener("mousemove",m),document.removeEventListener("touchmove",m),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y)};document.addEventListener("mousemove",m),document.addEventListener("touchmove",m),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)},_t=c=>{if(!o.duration||o.isLive)return;const m=c.currentTarget.getBoundingClientRect(),y=(c.clientX-m.left)/m.width,S=y*o.duration;Ht(y*100),st(S),Ze.length>0&&it(Ze.find(H=>S>=H.start&&S<H.end)||null)},ce=c=>{!n||o.isLocked||(n.skip(c==="forward"?10:-10),nt(c),setTimeout(()=>nt(null),300))},Gt=c=>{if(!n)return;if(ee.current){ee.current=!1;return}if(L||$||I||Z.visible){R();return}if(ve&&ae(!1),n.setControlsVisible(!0),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{!o.isPlaying||L||$||I||n.setControlsVisible(!1)},2500),o.isLocked)return;const m=c.currentTarget.getBoundingClientRect(),y=c.clientX-m.left,S=m.width,H=Date.now();se.current?(clearTimeout(se.current),se.current=null,y<S*.35?(ce("rewind"),le({type:"rewind",id:H})):y>S*.65?(ce("forward"),le({type:"forward",id:H})):n.toggleFullscreen()):se.current=setTimeout(()=>{n.togglePlay(),se.current=null},250)},Ut=c=>{var y;if(c.preventDefault(),c.stopPropagation(),o.isLocked)return;R();const m=(y=E.current)==null?void 0:y.getBoundingClientRect();m&&requestAnimationFrame(()=>{fe({visible:!0,x:c.clientX-m.left,y:c.clientY-m.top})})},Qt=c=>{if(c.stopPropagation(),R(),ve){ae(!1);return}De?ae(!0):n==null||n.toggleMute()},Xt=o.isMuted||o.volume===0?ps:o.volume<.5?hs:ds,Ne=Math.max(100,Oe-120),Jt=()=>{switch(o.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},Kt=()=>{switch(o.iconSize){case"small":return"p-2 min-w-[32px] min-h-[32px]";case"large":return"p-3 min-w-[44px] min-h-[44px]";default:return"p-2.5 min-w-[36px] min-h-[36px]"}},B=Jt(),O=Kt(),X=(()=>{switch(o.iconSize){case"small":return{playBtn:"w-14 h-14",playIcon:"w-6 h-6",skipBtn:"w-10 h-10",skipIcon:"w-5 h-5"};case"large":return{playBtn:"w-24 h-24",playIcon:"w-12 h-12",skipBtn:"w-16 h-16",skipIcon:"w-8 h-8"};default:return{playBtn:"w-20 h-20",playIcon:"w-9 h-9",skipBtn:"w-12 h-12",skipIcon:"w-6 h-6"}}})(),Yt=!o.isLocked&&(o.controlsVisible||!o.isPlaying||L||$||I||Z.visible),pt=Vt||Bt||ve,Me=Pt?"backdrop-blur-xl bg-black/80":"bg-black/95",xt=p.useMemo(()=>{const c=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];return h.controls&&h.controls.forEach(m=>{const y=c.find(S=>S.id===m.id);y?Object.assign(y,m):c.push(m)}),c.filter(m=>!(m.id==="screenshot"&&!j||m.id==="pip"&&!x||m.id==="settings"&&!N||m.id==="fullscreen"&&!P||m.id==="fullscreenWeb"&&!b)).sort((m,y)=>m.index-y.index)},[h.controls,j,x,N,P,b]),mt=c=>{var m,y,S,H,wt;if(!c.isBuiltIn){const a=c.id||`ctrl-${c.index}`,T=I===a,W=T||Je.isMounted&&Ge.current===a;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:k=>k.stopPropagation(),onTouchStart:k=>k.stopPropagation(),onClick:k=>{if(k.stopPropagation(),c.children){const Te=T;R(),Te||_e(a)}else R(),c.click?c.click(n):c.onClick&&c.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${O} ${T?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${c.className||""}`,style:{borderRadius:"var(--radius)",...c.style},title:c.tooltip,children:e.jsx(Ct,{content:c.html||""})}),c.children&&W&&e.jsx(ei,{items:c.children,onClose:R,maxHeight:Ne,className:`strata-backdrop ${Me} ${Je.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},c.index)}switch(c.id){case"play":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.togglePlay()},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},children:o.isPlaying?e.jsx(yt,{className:`${B} fill-current`}):e.jsx(jt,{className:`${B} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&Ye(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&Ye(!1)},children:[e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:Qt,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Xt,{className:B})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${pt?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:ke,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:ht,onTouchStart:ht,children:[e.jsx("div",{className:"w-full h-1 bg-white/20 overflow-hidden",style:{borderRadius:"var(--radius-full)"},children:e.jsx("div",{className:"h-full bg-white",style:{width:`${(o.isMuted?0:o.volume)*100}%`,borderRadius:"var(--radius-full)"}})}),e.jsx("div",{className:"absolute h-3 w-3 bg-white shadow-md top-1/2 -translate-y-1/2 pointer-events-none",style:{left:`calc(${(o.isMuted?0:o.volume)*100}% * 0.85 + 4px)`,borderRadius:"var(--radius-full)"}})]})}),pt&&e.jsx("div",{className:"strata-tooltip absolute bottom-full mb-2 px-1.5 py-0.5 rounded text-[10px] font-bold font-mono shadow-lg pointer-events-none whitespace-nowrap z-50 transform -translate-x-1/2",style:{left:`calc(52px + ${(o.isMuted?0:o.volume)*80}px)`},children:o.isMuted?"0%":`${Math.round(o.volume*100)}%`})]},"volume");case"time":return h.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${o.themeColor}1a`,borderColor:`${o.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:o.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:o.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[ze(be?oe:o.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",ze(o.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation();const T=$;R(),T||me(!0)},className:`strata-control-btn transition-colors focus:outline-none ${O} ${$?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(gs,{className:B})}),Xe.isMounted&&e.jsx(ti,{tracks:o.subtitleTracks,current:o.currentSubtitle,onSelect:a=>n==null?void 0:n.setSubtitle(a),onUpload:a=>n==null?void 0:n.addTextTrack(a,a.name),onClose:()=>me(!1),settings:o.subtitleSettings,onSettingsChange:a=>n==null?void 0:n.updateSubtitleSettings(a),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:o.subtitleOffset,onOffsetChange:a=>n==null?void 0:n.setSubtitleOffset(a),maxHeight:Ne,animationClass:`strata-backdrop ${Me} ${Xe.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.screenshot()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(Es,{className:B})},"ss");case"pip":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.togglePip()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},children:e.jsx(bs,{className:B})},"pip");case"download":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.download()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},children:e.jsx(vs,{className:B})},"dl");case"fullscreen":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.toggleFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${O}`,style:{borderRadius:"var(--radius)"},children:o.isFullscreen||o.isWebFullscreen?e.jsx(ms,{className:B}):e.jsx(xs,{className:B})},"fs");case"fullscreenWeb":return e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),R(),n==null||n.toggleWebFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${O} ${o.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Bs,{className:B})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation();const T=L;R(),T||(Y(!0),z("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${O} ${L?"rotate-90 text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(fs,{className:B})}),Qe.isMounted&&e.jsx(Fe,{onClose:()=>Y(!1),align:"right",maxHeight:Ne,className:`strata-backdrop ${Me} ${Qe.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[F==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),o.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Source",icon:e.jsx(Ws,{className:"w-4 h-4"}),value:((m=o.sources[o.currentSourceIndex])==null?void 0:m.name)||`Source ${o.currentSourceIndex+1}`,onClick:()=>z("sources"),hasSubmenu:!0}),e.jsx(J,{})]}),e.jsx(M,{label:"Quality",icon:e.jsx(Ds,{className:"w-4 h-4"}),value:o.currentQuality===-1?"Auto":`${(y=o.qualityLevels[o.currentQuality])==null?void 0:y.height}p`,onClick:()=>z("quality"),hasSubmenu:!0}),e.jsx(M,{label:"Speed",icon:e.jsx(Gs,{className:"w-4 h-4"}),value:`${o.playbackRate}x`,onClick:()=>z("speed"),hasSubmenu:!0}),e.jsx(M,{label:"Audio",icon:e.jsx(Us,{className:"w-4 h-4"}),value:((S=o.audioTracks[o.currentAudioTrack])==null?void 0:S.label)||"Default",onClick:()=>z("audio"),hasSubmenu:!0}),e.jsx(J,{}),Rt&&e.jsx(M,{label:"Flip",icon:e.jsx(Qs,{className:"w-4 h-4"}),value:o.flipState.horizontal?"H":o.flipState.vertical?"V":"Normal",onClick:()=>z("flip"),hasSubmenu:!0}),It&&e.jsx(M,{label:"Aspect Ratio",icon:e.jsx(qs,{className:"w-4 h-4"}),value:o.aspectRatio,onClick:()=>z("ratio"),hasSubmenu:!0}),e.jsx(M,{label:"Audio Boost",icon:e.jsx(_s,{className:"w-4 h-4"}),value:o.audioGain>1?`${o.audioGain}x`:"Off",onClick:()=>z("boost"),hasSubmenu:!0}),e.jsx(J,{}),e.jsx(M,{label:"Watch Party",icon:e.jsx(ks,{className:"w-4 h-4"}),onClick:()=>z("party"),hasSubmenu:!0}),e.jsx(M,{label:"Cast to Device",icon:e.jsx(ys,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),Y(!1)}}),h.settings&&h.settings.length>0&&e.jsx(J,{}),(H=h.settings)==null?void 0:H.map((a,T)=>a.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(D,{label:a.html,icon:a.icon,checked:a.switch,tooltip:a.tooltip,onChange:W=>{a.onSwitch&&a.onSwitch(a,W)}})},`cust-${T}`):e.jsx(M,{label:a.html,icon:a.icon,value:a.currentLabel||a.value,hasSubmenu:!!a.children,onClick:()=>{a.children?z(`custom-${T}`):(a.click?a.click(a):a.onClick&&a.onClick(a),Y(!1))}},`cust-${T}`)),e.jsx(J,{}),e.jsx(M,{label:"Appearance",icon:e.jsx(zt,{className:"w-4 h-4"}),onClick:()=>z("appearance"),hasSubmenu:!0})]}),F.startsWith("custom-")&&(()=>{var W;const a=parseInt(F.split("-")[1]),T=(W=h.settings)==null?void 0:W[a];return!T||!T.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(A,{label:T.html||"Menu",onBack:()=>z("main")}),T.children.map((k,Te)=>e.jsxs(p.Fragment,{children:[k.separator&&e.jsx(J,{}),k.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(D,{label:k.html,checked:k.switch,onChange:es=>k.onSwitch&&k.onSwitch(k,es)})}),!k.separator&&k.switch===void 0&&e.jsx(M,{label:k.html,icon:k.icon,value:k.value,active:k.active,onClick:()=>{k.onClick?k.onClick(k):k.click&&k.click(k),Y(!1)}})]},Te))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio"].includes(F)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[F==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Select Source",onBack:()=>z("main")}),o.sources.map((a,T)=>{const W=o.sourceStatuses[T],k=W==="success"?e.jsx(Xs,{className:"w-3.5 h-3.5 text-emerald-500"}):W==="error"?e.jsx(Js,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(M,{label:a.name||`Source ${T+1}`,value:a.type,active:o.currentSourceIndex===T,rightIcon:k,onClick:()=>n==null?void 0:n.switchSource(T)},T)})]}),F==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Speed",onBack:()=>z("main")}),[.5,1,1.5,2].map(a=>e.jsx(M,{label:`${a}x`,active:o.playbackRate===a,onClick:()=>n.video.playbackRate=a},a))]}),F==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Quality",onBack:()=>z("main")}),e.jsx(M,{label:"Auto",active:o.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),o.qualityLevels.map(a=>e.jsx(M,{label:`${a.height}p`,value:`${Math.round(a.bitrate/1e3)}k`,active:o.currentQuality===a.index,onClick:()=>n==null?void 0:n.setQuality(a.index)},a.index))]}),F==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Audio Track",onBack:()=>z("main")}),o.audioTracks.length===0&&e.jsx("div",{className:"px-4 py-3 text-zinc-500 text-xs text-center",children:"No tracks available"}),o.audioTracks.map(a=>e.jsx(M,{label:a.label,value:a.language,active:o.currentAudioTrack===a.index,onClick:()=>n==null?void 0:n.setAudioTrack(a.index)},a.index))]}),F==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Audio Boost",onBack:()=>z("main")}),[1,1.5,2,3].map(a=>e.jsx(M,{label:a===1?"Off":`${a}x`,active:o.audioGain===a,onClick:()=>n==null?void 0:n.setAudioGain(a)},a))]}),F==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Video Flip",onBack:()=>z("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(D,{label:"Horizontal Flip",checked:o.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(D,{label:"Vertical Flip",checked:o.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),F==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Aspect Ratio",onBack:()=>z("main")}),["default","16:9","4:3"].map(a=>e.jsx(M,{label:a==="default"?"Default":a,active:o.aspectRatio===a,onClick:()=>n==null?void 0:n.setAspectRatio(a)},a))]}),F==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Watch Party",onBack:()=>z("main")}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-xs text-zinc-400 leading-relaxed",children:"Create a synchronized room on WatchParty.me to watch together."}),e.jsx("a",{href:`https://www.watchparty.me/create?video=${encodeURIComponent(((wt=o.sources[o.currentSourceIndex])==null?void 0:wt.url)||t||"")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-full py-2.5 bg-[var(--accent)] hover:opacity-90 text-white font-medium transition-opacity text-xs",style:{borderRadius:"var(--radius)"},children:"Create Room"})]})]}),F==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Appearance",onBack:()=>z("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx(K,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:oi.map(a=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:a.value,themeColor:a.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${o.theme===a.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:a.label},a.value))})}),e.jsx(K,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(a=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:a}),className:`py-1.5 text-xs font-medium transition-colors ${o.iconSize===a?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:a.charAt(0).toUpperCase()+a.slice(1)},a))})}),e.jsxs(K,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:ri.map(a=>e.jsx("button",{title:a.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:a.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${o.themeColor===a.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:a.value,borderRadius:"var(--radius-full)"},children:o.themeColor===a.value&&e.jsx(Ee,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},a.value))}),e.jsx("div",{className:"px-3 pt-4",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white/5 p-2 hover:bg-white/10 transition-colors group",style:{borderRadius:"var(--radius)"},children:[e.jsx("div",{className:"relative w-6 h-6 overflow-hidden ring-1 ring-white/20",style:{borderRadius:"var(--radius-full)"},children:e.jsx("input",{type:"color",value:o.themeColor,onChange:a=>n==null?void 0:n.setAppearance({themeColor:a.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})}),e.jsx("span",{className:"text-xs text-zinc-400 font-medium group-hover:text-zinc-200",children:"Custom Color"}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-500 ml-auto uppercase",children:o.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},Zt=p.useMemo(()=>{const c=[{html:"Playback",isLabel:!0},{html:"Loop",checked:o.isLooping,onClick:()=>n==null?void 0:n.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>n==null?void 0:n.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>n==null?void 0:n.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:o.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:o.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"4:3",checked:o.aspectRatio==="4:3",onClick:()=>n==null?void 0:n.setAspectRatio("4:3")},{separator:!0},{html:"Video Info",icon:e.jsx(Hs,{className:"w-3.5 h-3.5"}),onClick:()=>Ue(!0)},{separator:!0}];return h.contextmenu&&c.push(...h.contextmenu),c.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),c.push({html:"Close",onClick:m=>m(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),c},[h.contextmenu,o.aspectRatio,o.isLooping,n]),ft=o.isWebFullscreen,bt=e.jsxs("div",{id:h.id,ref:E,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset flex items-center justify-center ${ft?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius)]"} ${h.container||""}`,style:{touchAction:"manipulation","--accent":o.themeColor,"--accent-contrast":Ft},onMouseMove:lt,onMouseLeave:()=>{o.isPlaying&&!L&&!$&&!I&&n&&n.setControlsVisible(!1)},onMouseDown:ct,onMouseUp:Se,onTouchStart:Wt,onTouchMove:Dt,onTouchEnd:qt,onContextMenu:Ut,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":o.theme,children:[e.jsx("style",{children:`
|
|
26
26
|
[data-theme="default"] {
|
|
27
27
|
--radius: 0.75rem;
|
|
28
28
|
--radius-lg: 0.75rem;
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
/* Override Backdrop for specific themes if needed */
|
|
116
116
|
[data-theme="pixel"] .strata-backdrop { backdrop-filter: none; background: #000; }
|
|
117
117
|
[data-theme="hacker"] .strata-backdrop { backdrop-filter: none; background: #000; }
|
|
118
|
-
`}),
|
|
118
|
+
`}),o.theme==="hacker"&&e.jsx("div",{className:"strata-scanlines"}),!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-950 z-50",children:e.jsx(Pe,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),n&&e.jsxs(e.Fragment,{children:[(gt=h.layers)==null?void 0:gt.map((c,m)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${c.className||""}`,style:c.style,children:e.jsx(Ct,{content:c.html||"",className:"w-full h-full"})},m)),e.jsx(Ks,{notifications:o.notifications}),e.jsx(Ys,{cues:o.activeCues,settings:o.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-0",onClick:Gt,"aria-hidden":"true"}),l&&!pe&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none",style:{backgroundImage:`url(${l})`}}),Z.visible&&e.jsx(si,{x:Z.x,y:Z.y,items:Zt,onClose:()=>fe({...Z,visible:!1}),containerWidth:$t,containerHeight:Oe}),At&&n&&e.jsx(ii,{player:n,onClose:()=>Ue(!1)}),we&&e.jsxs("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 bg-black/50 backdrop-blur-md px-4 py-2 rounded-full flex items-center gap-2 z-40 animate-in fade-in zoom-in duration-200",children:[e.jsx(Vs,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),q&&De&&o.controlsVisible&&e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),n.toggleLock()},className:`absolute left-4 md:left-6 bottom-24 md:bottom-28 z-50 p-3 rounded-full bg-black/50 backdrop-blur-md border border-white/10 text-white transition-all active:scale-95 ${o.isLocked?"text-[var(--accent)] bg-white/10":"hover:bg-white/10"}`,children:o.isLocked?e.jsx(Fs,{className:"w-5 h-5"}):e.jsx(As,{className:"w-5 h-5"})}),Q&&e.jsx("div",{className:`absolute top-0 bottom-0 flex items-center justify-center w-[35%] z-20 bg-white/5 backdrop-blur-[1px] animate-out fade-out duration-500 fill-mode-forwards ${Q.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>le(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[Q.type==="rewind"?e.jsx(kt,{className:"w-12 h-12 animate-pulse"}):e.jsx(St,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:Q.type==="rewind"?"-10s":"+10s"})]})},Q.id),o.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(Pe,{className:"w-12 h-12 text-[var(--accent)] animate-spin drop-shadow-lg"})}),o.error&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 bg-black/90 backdrop-blur-md animate-in fade-in",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-red-500 p-8 max-w-md text-center",children:[e.jsx("span",{className:"text-5xl mb-2",children:"⚠️"}),e.jsx("h3",{className:"text-xl font-bold text-white",children:"Playback Error"}),e.jsx("p",{className:"text-zinc-400 text-sm",children:o.error}),e.jsx("button",{onClick:()=>n.load(n.store.get().sources[n.store.get().currentSourceIndex]||{url:t||"",type:i||"auto"},g),className:"px-6 py-2 bg-[var(--accent)] text-white font-medium rounded-full hover:opacity-90 transition-opacity mt-4 shadow-lg",children:"Try Again"})]})}),Lt&&!o.isLocked&&(!o.isPlaying&&!o.isBuffering&&!o.error||o.controlsVisible)&&!o.isBuffering?e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-300 pointer-events-none ${o.controlsVisible||!o.isPlaying?"opacity-100":"opacity-0"}`,children:e.jsxs("div",{className:"flex items-center gap-8 md:gap-16 pointer-events-auto",children:[e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),R(),ce("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${X.skipBtn}`,children:e.jsx(kt,{className:X.skipIcon})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),R(),n.togglePlay()},className:`group relative flex items-center justify-center rounded-full bg-white/10 hover:bg-[var(--accent)] border border-white/10 shadow-2xl transition-all duration-300 active:scale-90 active:opacity-80 focus:outline-none backdrop-blur-md ${X.playBtn}`,children:o.isPlaying?e.jsx(yt,{className:`${X.playIcon} text-white fill-current`}):e.jsx(jt,{className:`${X.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),R(),ce("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${X.skipBtn}`,children:e.jsx(St,{className:X.skipIcon})})]})}):null,e.jsxs("div",{className:`absolute inset-x-0 bottom-0 z-30 transition-all duration-300 px-4 md:px-6 py-4 bg-gradient-to-t from-black/90 via-black/50 to-transparent ${Yt?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:c=>{(L||$||I)&&R(),c.target===c.currentTarget&&ae(!1),c.stopPropagation()},children:[!h.isLive&&e.jsxs("div",{ref:ye,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:_t,onMouseLeave:()=>{st(null),it(null)},onMouseDown:ut,onTouchStart:ut,children:[(vt=h.highlight)==null?void 0:vt.map((c,m)=>e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-yellow-400 rounded-full z-10 pointer-events-none",style:{left:`${c.time/o.duration*100}%`},title:c.text},m)),tt!==null&&e.jsxs("div",{className:"absolute bottom-full mb-1.5 flex flex-col items-center transform -translate-x-1/2 z-40 pointer-events-none transition-opacity duration-150",style:{left:`clamp(70px, ${Ot}%, calc(100% - 70px))`},children:[G&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${G.w*.5}px`,height:`${G.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${G.url}")`,width:`${G.w}px`,height:`${G.h}px`,backgroundPosition:`-${G.x}px -${G.y}px`,backgroundRepeat:"no-repeat",transform:"scale(0.5)",transformOrigin:"top left"}})}),e.jsx("div",{className:"strata-tooltip px-2 py-0.5 text-[11px] font-bold font-mono shadow-lg tabular-nums mt-1",children:ze(tt)})]}),e.jsxs("div",{className:"w-full h-1 bg-white/20 overflow-hidden relative backdrop-blur-sm border-[length:var(--border-width)] border-white/10",style:{borderRadius:"var(--radius-full)"},children:[o.duration>0&&o.buffered.map((c,m)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${c.start/o.duration*100}%`,width:`${(c.end-c.start)/o.duration*100}%`}},m)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(be?oe:o.currentTime)/o.duration*100}%`}})]}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-3.5 h-3.5 bg-white shadow-md scale-0 group-hover/slider:scale-100 transition-transform duration-100 z-10",style:{left:`${(be?oe:o.currentTime)/o.duration*100}%`,borderRadius:"var(--radius-full)"}})]}),e.jsxs("div",{className:"flex items-center justify-between pointer-events-auto",children:[e.jsx("div",{className:"flex items-center gap-3",children:xt.filter(c=>c.position==="left"||c.position==="center").map(mt)}),e.jsx("div",{className:"flex items-center gap-1",children:xt.filter(c=>c.position==="right").map(mt)})]})]})]})]});return ft&&typeof document<"u"?ns.createPortal(bt,document.body):bt},ai=(s,t)=>{const i=is.createRoot(s);return i.render(p.createElement(Le,t)),{unmount:()=>{i.unmount()},update:r=>{i.render(p.createElement(Le,{...t,...r}))}}};exports.StrataCore=Tt;exports.StrataPlayer=Le;exports.mountStrataPlayer=ai;
|
|
119
119
|
//# sourceMappingURL=strataplayer.cjs.js.map
|