strataplayer 1.2.10 → 1.2.11

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.
@@ -1,222 +1,12 @@
1
- "use strict";var qt=Object.defineProperty;var Dt=(o,t,s)=>t in o?qt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var j=(o,t,s)=>Dt(o,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),Wt=require("react-dom/client"),e=require("react/jsx-runtime");class Ut{constructor(){j(this,"events");this.events=new Map}on(t,s){var n;return this.events.has(t)||this.events.set(t,[]),(n=this.events.get(t))==null||n.push(s),()=>this.off(t,s)}off(t,s){const n=this.events.get(t);n&&this.events.set(t,n.filter(r=>r!==s))}emit(t,s){const n=this.events.get(t);n&&n.forEach(r=>r(s))}destroy(){this.events.clear()}}class Gt{constructor(t){j(this,"state");j(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const s=this.state,n=typeof t=="function"?t(s):t;this.state={...s,...n},this.listeners.forEach(r=>r(this.state,s))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class _t{constructor(t){j(this,"context",null);j(this,"source",null);j(this,"gainNode",null);j(this,"video");j(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(s){console.warn("StrataPlayer: Failed to initialize AudioEngine",s)}}}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 Se={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},ht="strata-settings",$={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,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:Se,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",isAutoSized:!1,isLooping:!1,controlsVisible:!0},mt=(o={})=>{let t={};if(!o.disablePersistence&&typeof window<"u")try{const n=localStorage.getItem(ht);n&&(t=JSON.parse(n))}catch{}const s={...Se,...t.subtitleSettings||{},...o.subtitleSettings||{}};return{...$,...t,volume:o.volume??t.volume??$.volume,isMuted:o.muted??t.isMuted??$.isMuted,playbackRate:o.playbackRate??t.playbackRate??$.playbackRate,audioGain:o.audioGain??t.audioGain??$.audioGain,theme:o.theme??t.theme??$.theme,themeColor:o.themeColor??t.themeColor??$.themeColor,iconSize:o.iconSize??t.iconSize??$.iconSize,subtitleSettings:s,isAutoSized:o.autoSize??$.isAutoSized,isLive:o.isLive??t.isLive??$.isLive,isLooping:o.loop??t.isLooping??$.isLooping}};class ft{constructor(t={},s){j(this,"video");j(this,"container",null);j(this,"events");j(this,"store");j(this,"plugins",new Map);j(this,"audioEngine");j(this,"config");j(this,"resizeObserver",null);j(this,"retryCount",0);j(this,"maxRetries",5);j(this,"retryTimer",null);j(this,"currentSource",null);j(this,"currentSrc","");j(this,"currentTracks",[]);j(this,"castInitialized",!1);j(this,"boundCueChange");j(this,"boundFullscreenChange");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=s||document.createElement("video"),this.video.crossOrigin="anonymous",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new Ut;const n=mt(t);this.store=new Gt(n),this.audioEngine=new _t(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const r=!!document.fullscreenElement;if(this.store.setState({isFullscreen:r}),this.emit("resize"),this.emit(r?"fullscreen":"fullscreen_exit"),r&&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!r&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=n.volume,this.video.muted=n.isMuted,this.video.playbackRate=n.playbackRate,this.video.loop=n.isLooping,n.audioGain>1&&this.audioEngine.setGain(n.audioGain),n.isAutoSized&&(this.video.style.objectFit="cover"),this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(r=>{const c={volume:r.volume,isMuted:r.isMuted,playbackRate:r.playbackRate,subtitleSettings:r.subtitleSettings,iconSize:r.iconSize,themeColor:r.themeColor,theme:r.theme,isLive:r.isLive,isLooping:r.isLooping};localStorage.setItem(ht,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,s){return this.events.on(t,s)}off(t,s){return this.events.off(t,s)}emit(t,s){return this.events.emit(t,s)}initVideoListeners(){const t=n=>this.store.setState(n);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(n=>{this.video.addEventListener(n,r=>{switch(this.emit(`video:${n}`,r),n==="play"&&this.emit("play"),n==="pause"&&this.emit("pause"),n==="ended"&&this.emit("ended"),n==="error"&&this.emit("error",this.video.error),n==="seeked"&&this.emit("seek"),n){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);break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null});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))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",s=>this.skip(s.seekOffset?-s.seekOffset:-10)),t.setActionHandler("seekforward",s=>this.skip(s.seekOffset||10)),t.setActionHandler("seekto",s=>{s.seekTime!==void 0&&this.seek(s.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const s=this.store.get().currentSourceIndex;s>0&&this.switchSource(s-1)}),t.setActionHandler("nexttrack",()=>{const s=this.store.get().currentSourceIndex,n=this.store.get().sources.length;s<n-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var n,r;if(!("mediaSession"in navigator))return;const t=((n=this.currentSource)==null?void 0:n.name)||((r=this.currentSource)==null?void 0:r.url.split("/").pop())||"Video",s=[];this.config.poster&&s.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),s.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:s})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,s=this.video.currentTime,n=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:n,position:Math.max(0,Math.min(s,t))})}catch(r){console.warn("MediaSession Position Error:",r)}}triggerError(t,s=!1){s?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const s=this.video.error,n=t||(s==null?void 0:s.message)||(s?`Code ${s.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",s),this.retryCount<this.maxRetries){this.retryCount++;const r=Math.pow(2,this.retryCount-1)*1500;this.notify({id:"retry",type:"loading",message:`Error: ${n}. Retrying (${this.retryCount}/${this.maxRetries})...`}),console.warn(`[StrataPlayer] Error: ${n}. Retrying in ${r}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)}}},r)}else{this.removeNotification("retry");const r=`Failed to play after ${this.maxRetries} attempts: ${n}`;this.store.setState({error:r}),this.emit("error",r)}}updateBuffer(){const t=[];for(let s=0;s<this.video.buffered.length;s++)t.push({start:this.video.buffered.start(s),end:this.video.buffered.end(s)});this.store.setState({buffered:t})}updateSubtitles(){setTimeout(()=>{const t=Array.from(this.video.textTracks).filter(n=>n.kind==="subtitles"||n.kind==="captions").map((n,r)=>({label:n.label||n.language||`Track ${r+1}`,language:n.language,index:r}));this.store.setState({subtitleTracks:t});const s=this.store.get();s.currentSubtitle!==-1&&t.length>0&&s.currentSubtitle<t.length&&this.setSubtitle(s.currentSubtitle)},50)}async fetchWithRetry(t,s=3,n){const r=n??this.config.fetchTimeout??3e4;for(let c=0;c<s;c++){const h=new AbortController,b=setTimeout(()=>h.abort(),r);try{const g=await fetch(t,{signal:h.signal});if(clearTimeout(b),!g.ok)throw new Error(`HTTP ${g.status}`);return g}catch(g){if(clearTimeout(b),c===s-1)throw g;g.name==="AbortError"&&console.warn(`Fetch timeout (${r}ms) for ${t}`),await new Promise(x=>setTimeout(x,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(s=>{for(const n of s)this.emit("resize",{width:n.contentRect.width,height:n.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,s=[]){this.store.setState({sources:t}),this.currentTracks=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const n=this.video.currentTime,r=!this.video.paused;this.load(s[t],this.currentTracks);const c=()=>{this.video.currentTime=n,r&&this.video.play(),this.video.removeEventListener("canplay",c)};this.video.addEventListener("canplay",c)}}load(t,s=[],n=!1){this.retryTimer&&clearTimeout(this.retryTimer);const r=typeof t=="string"?{url:t,type:"auto"}:t;n||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=r.url,this.currentSource=r,this.currentTracks=s;const h=this.store.get().sources.findIndex(x=>x.url===r.url);this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,currentSourceIndex:h}),this.updateMediaSessionMetadata();let b=r.type||"auto";b==="auto"&&(r.url.includes(".m3u8")?b="hls":r.url.includes(".mpd")?b="dash":r.url.includes(".flv")||r.url.includes(".ts")?b="mpegts":r.url.startsWith("magnet:")||r.url.includes(".torrent")?b="webtorrent":b="mp4"),this.events.emit("load",{url:r.url,type:b});const g=this.video.getElementsByTagName("track");for(;g.length>0;)g[0].remove();s.length>0&&s.forEach(x=>{this.fetchWithRetry(x.src).then(()=>{this.addTextTrackInternal(x.src,x.label,x.srcLang,x.default)}).catch(d=>{this.notify({type:"warning",message:`Failed to load subtitle: ${x.label}`,duration:4e3})})}),(b==="mp4"||b==="webm"||b==="ogg")&&(this.video.src=r.url)}loadSubtitle(t,s="Subtitle"){this.addTextTrackInternal(t,s,void 0,!0)}addTextTrack(t,s){const n=new FileReader;n.onload=r=>{var g;if(!((g=r.target)!=null&&g.result))return;let c=r.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 Ht=Object.defineProperty;var Wt=(i,t,s)=>t in i?Ht(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var k=(i,t,s)=>Wt(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),Dt=require("react-dom/client"),e=require("react/jsx-runtime");class Ut{constructor(){k(this,"events");this.events=new Map}on(t,s){var r;return this.events.has(t)||this.events.set(t,[]),(r=this.events.get(t))==null||r.push(s),()=>this.off(t,s)}off(t,s){const r=this.events.get(t);r&&this.events.set(t,r.filter(a=>a!==s))}emit(t,s){const r=this.events.get(t);r&&r.forEach(a=>a(s))}destroy(){this.events.clear()}}class Gt{constructor(t){k(this,"state");k(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const s=this.state,r=typeof t=="function"?t(s):t;this.state={...s,...r},this.listeners.forEach(a=>a(this.state,s))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class _t{constructor(t){k(this,"context",null);k(this,"source",null);k(this,"gainNode",null);k(this,"video");k(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(s){console.warn("StrataPlayer: Failed to initialize AudioEngine",s)}}}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 Se={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},ht="strata-settings",$={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,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:Se,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",isAutoSized:!1,isLooping:!1,controlsVisible:!0},mt=(i={})=>{let t={};if(!i.disablePersistence&&typeof window<"u")try{const r=localStorage.getItem(ht);r&&(t=JSON.parse(r))}catch{}const s={...Se,...t.subtitleSettings||{},...i.subtitleSettings||{}};return{...$,...t,volume:i.volume??t.volume??$.volume,isMuted:i.muted??t.isMuted??$.isMuted,playbackRate:i.playbackRate??t.playbackRate??$.playbackRate,audioGain:i.audioGain??t.audioGain??$.audioGain,theme:i.theme??t.theme??$.theme,themeColor:i.themeColor??t.themeColor??$.themeColor,iconSize:i.iconSize??t.iconSize??$.iconSize,subtitleSettings:s,isAutoSized:i.autoSize??$.isAutoSized,isLive:i.isLive??t.isLive??$.isLive,isLooping:i.loop??t.isLooping??$.isLooping}};class xt{constructor(t={},s){k(this,"video");k(this,"container",null);k(this,"events");k(this,"store");k(this,"plugins",new Map);k(this,"audioEngine");k(this,"config");k(this,"resizeObserver",null);k(this,"retryCount",0);k(this,"maxRetries",5);k(this,"retryTimer",null);k(this,"currentSource",null);k(this,"currentSrc","");k(this,"currentTracks",[]);k(this,"castInitialized",!1);k(this,"boundCueChange");k(this,"boundFullscreenChange");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=s||document.createElement("video"),this.video.crossOrigin="anonymous",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new Ut;const r=mt(t);this.store=new Gt(r),this.audioEngine=new _t(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const a=!!document.fullscreenElement;if(this.store.setState({isFullscreen:a}),this.emit("resize"),this.emit(a?"fullscreen":"fullscreen_exit"),a&&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!a&&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(a=>{const c={volume:a.volume,isMuted:a.isMuted,playbackRate:a.playbackRate,subtitleSettings:a.subtitleSettings,iconSize:a.iconSize,themeColor:a.themeColor,theme:a.theme,isLive:a.isLive,isLooping:a.isLooping};localStorage.setItem(ht,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,s){return this.events.on(t,s)}off(t,s){return this.events.off(t,s)}emit(t,s){return this.events.emit(t,s)}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,a=>{switch(this.emit(`video:${r}`,a),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);break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null});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))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",s=>this.skip(s.seekOffset?-s.seekOffset:-10)),t.setActionHandler("seekforward",s=>this.skip(s.seekOffset||10)),t.setActionHandler("seekto",s=>{s.seekTime!==void 0&&this.seek(s.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const s=this.store.get().currentSourceIndex;s>0&&this.switchSource(s-1)}),t.setActionHandler("nexttrack",()=>{const s=this.store.get().currentSourceIndex,r=this.store.get().sources.length;s<r-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var r,a;if(!("mediaSession"in navigator))return;const t=((r=this.currentSource)==null?void 0:r.name)||((a=this.currentSource)==null?void 0:a.url.split("/").pop())||"Video",s=[];this.config.poster&&s.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),s.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:s})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,s=this.video.currentTime,r=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:r,position:Math.max(0,Math.min(s,t))})}catch(a){console.warn("MediaSession Position Error:",a)}}triggerError(t,s=!1){s?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const s=this.video.error,r=t||(s==null?void 0:s.message)||(s?`Code ${s.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",s),this.retryCount<this.maxRetries){this.retryCount++;const a=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 ${a}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)}}},a)}else{this.removeNotification("retry");const a=`Failed to play after ${this.maxRetries} attempts: ${r}`;this.store.setState({error:a}),this.emit("error",a)}}updateBuffer(){const t=[];for(let s=0;s<this.video.buffered.length;s++)t.push({start:this.video.buffered.start(s),end:this.video.buffered.end(s)});this.store.setState({buffered:t})}updateSubtitles(){setTimeout(()=>{const t=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions").map((r,a)=>({label:r.label||r.language||`Track ${a+1}`,language:r.language,index:a}));this.store.setState({subtitleTracks:t});const s=this.store.get();s.currentSubtitle!==-1&&t.length>0&&s.currentSubtitle<t.length&&this.setSubtitle(s.currentSubtitle)},50)}async fetchWithRetry(t,s=3,r){const a=r??this.config.fetchTimeout??3e4;for(let c=0;c<s;c++){const h=new AbortController,b=setTimeout(()=>h.abort(),a);try{const w=await fetch(t,{signal:h.signal});if(clearTimeout(b),!w.ok)throw new Error(`HTTP ${w.status}`);return w}catch(w){if(clearTimeout(b),c===s-1)throw w;w.name==="AbortError"&&console.warn(`Fetch timeout (${a}ms) for ${t}`),await new Promise(p=>setTimeout(p,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(s=>{for(const r of s)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,s=[]){this.store.setState({sources:t}),this.currentTracks=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const r=this.video.currentTime,a=!this.video.paused;this.load(s[t],this.currentTracks);const c=()=>{this.video.currentTime=r,a&&this.video.play(),this.video.removeEventListener("canplay",c)};this.video.addEventListener("canplay",c)}}load(t,s=[],r=!1){this.retryTimer&&clearTimeout(this.retryTimer);const a=typeof t=="string"?{url:t,type:"auto"}:t;r||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=a.url,this.currentSource=a,this.currentTracks=s;const h=this.store.get().sources.findIndex(p=>p.url===a.url);this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,currentSourceIndex:h}),this.updateMediaSessionMetadata();let b=a.type||"auto";b==="auto"&&(a.url.includes(".m3u8")?b="hls":a.url.includes(".mpd")?b="dash":a.url.includes(".flv")||a.url.includes(".ts")?b="mpegts":a.url.startsWith("magnet:")||a.url.includes(".torrent")?b="webtorrent":b="mp4"),this.events.emit("load",{url:a.url,type:b});const w=this.video.getElementsByTagName("track");for(;w.length>0;)w[0].remove();s.length>0&&s.forEach(p=>{this.fetchWithRetry(p.src).then(()=>{this.addTextTrackInternal(p.src,p.label,p.srcLang,p.default)}).catch(u=>{this.notify({type:"warning",message:`Failed to load subtitle: ${p.label}`,duration:4e3})})}),(b==="mp4"||b==="webm"||b==="ogg")&&(this.video.src=a.url)}loadSubtitle(t,s="Subtitle"){this.addTextTrackInternal(t,s,void 0,!0)}addTextTrack(t,s){const r=new FileReader;r.onload=a=>{var w;if(!((w=a.target)!=null&&w.result))return;let c=a.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
2
2
 
3
- `+c));const h=new Blob([c],{type:"text/vtt"}),b=URL.createObjectURL(h);this.addTextTrackInternal(b,s,"user",!0),setTimeout(()=>{const d=this.store.get().subtitleTracks.findIndex(w=>w.label===s);d!==-1&&(this.setSubtitle(d),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3}))},200)},n.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},n.readAsText(t)}addTextTrackInternal(t,s,n="",r=!1){const c=document.createElement("track");c.kind="subtitles",c.label=s,c.src=t,c.srclang=n,r&&(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 s=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:s}),this.video.currentTime=s}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const s=Math.max(0,Math.min(t,1));this.video.volume=s,s>0&&this.video.muted&&(this.video.muted=!1),s===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)}}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 s=t.getContext("2d");if(s){s.drawImage(this.video,0,0,t.width,t.height);try{const n=t.toDataURL("image/png"),r=document.createElement("a");r.download=`screenshot-${new Date().toISOString()}.png`,r.href=n,r.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 s=this.store.get().flipState,n={...s,[t]:!s[t]};this.store.setState({flipState:n});const r=n.horizontal?-1:1,c=n.vertical?-1:1;this.video.style.transform=`scale(${r}, ${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,s=()=>{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(n){console.warn("Cast Init Error or already initialized",n)}};t.cast&&t.cast.framework?s():t.__onGCastApiAvailable=n=>{n&&s()}}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(s=>{s!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+s,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 s=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!s)return;const n=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),r=new t.chrome.cast.media.LoadRequest(n);s.loadMedia(r).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(c=>console.error("Cast load error",c))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){const t=this.store.get();if(t.currentSubtitle===-1){this.store.setState({activeCues:[]});return}const n=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions")[t.currentSubtitle];if(n&&n.activeCues){const r=Array.from(n.activeCues).map(c=>c.text);this.store.setState({activeCues:r})}else this.store.setState({activeCues:[]})}setSubtitle(t){if(Array.from(this.video.textTracks).forEach(s=>{s.removeEventListener("cuechange",this.boundCueChange),s.mode="hidden"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t!==-1){const n=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions")[t];if(n){const r=this.store.get().subtitleSettings;n.mode=r.useNative?"showing":"hidden",n.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}}updateSubtitleSettings(t){const n={...this.store.get().subtitleSettings,...t};this.store.setState({subtitleSettings:n}),t.useNative!==void 0&&this.setSubtitle(this.store.get().currentSubtitle)}resetSubtitleSettings(){this.store.setState({subtitleSettings:Se}),this.setSubtitle(this.store.get().currentSubtitle)}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,n=t-s;Math.abs(n)<.001||(Array.from(this.video.textTracks).forEach(r=>{(r.mode==="showing"||r.mode==="hidden")&&r.cues&&Array.from(r.cues).forEach(c=>{c.startTime+=n,c.endTime+=n})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}async download(){var n;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 s=this.notify({type:"loading",message:"Preparing download...",progress:0});try{const r=await this.fetchWithRetry(t);if(!r.body)throw new Error("No body");const c=r.body.getReader(),h=r.headers.get("Content-Length"),b=h?parseInt(h,10):0;let g=0;const x=[];for(;;){const{done:z,value:M}=await c.read();if(z)break;if(x.push(M),g+=M.length,b){const p=Math.round(g/b*100);this.notify({id:s,type:"loading",message:`Downloading... ${p}%`,progress:p})}}const d=new Blob(x),w=window.URL.createObjectURL(d),k=document.createElement("a");k.style.display="none",k.href=w,k.download=((n=t.split("/").pop())==null?void 0:n.split("?")[0])||"video.mp4",document.body.appendChild(k),k.click(),window.URL.revokeObjectURL(w),document.body.removeChild(k),this.notify({id:s,type:"success",message:"Saved!",duration:3e3})}catch{this.notify({id:s,type:"error",message:"Download failed.",duration:4e3}),window.open(t,"_blank")}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),n={...t,id:s};return this.store.setState({notifications:[n]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(n=>n.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),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(s=>s.destroy&&s.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const ye=o=>{if(isNaN(o))return"00:00";const t=Math.floor(o/3600),s=Math.floor(o%3600/60),n=Math.floor(o%60);return t>0?`${t}:${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${s}:${n.toString().padStart(2,"0")}`},Xt=async(o,t=3,s=2e4)=>{for(let n=0;n<t;n++){const r=new AbortController,c=setTimeout(()=>r.abort(),s);try{const h=await fetch(o,{signal:r.signal});if(clearTimeout(c),!h.ok)throw new Error(`HTTP ${h.status}`);return await h.text()}catch(h){if(clearTimeout(c),n===t-1)throw h;await new Promise(b=>setTimeout(b,1e3))}}throw new Error("Failed")},Qt=async(o,t,s=2e4)=>{try{const r=(await Xt(o,3,s)).split(`
4
- `),c=[];let h=null,b=null;const g=o.substring(0,o.lastIndexOf("/")+1),x=d=>{const w=d.split(":");let k=0;return w.length===3?(k+=parseFloat(w[0])*3600,k+=parseFloat(w[1])*60,k+=parseFloat(w[2])):(k+=parseFloat(w[0])*60,k+=parseFloat(w[1])),k};for(let d of r)if(d=d.trim(),d.includes("-->")){const w=d.split("-->");h=x(w[0].trim()),b=x(w[1].trim())}else if(h!==null&&b!==null&&d.length>0){let[w,k]=d.split("#");!w.match(/^https?:\/\//)&&!w.startsWith("data:")&&(w=g+w);let z=0,M=0,p=0,B=0;if(k&&k.startsWith("xywh=")){const V=k.replace("xywh=","").split(",");V.length===4&&(z=parseInt(V[0]),M=parseInt(V[1]),p=parseInt(V[2]),B=parseInt(V[3]))}p>0&&B>0&&c.push({start:h,end:b,url:w,x:z,y:M,w:p,h:B}),h=null,b=null}return c}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},nt=(o,t=200)=>{const[s,n]=m.useState(o),[r,c]=m.useState(!1);return m.useEffect(()=>{if(o)n(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(!0)})});else{c(!1);const h=setTimeout(()=>{n(!1)},t);return()=>clearTimeout(h)}},[o,t]),{isMounted:s,isVisible:r}};/**
5
- * @license lucide-react v0.462.0 - ISC
6
- *
7
- * This source code is licensed under the ISC license.
8
- * See the LICENSE file in the root directory of this source tree.
9
- */const Jt=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pt=(...o)=>o.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim();/**
10
- * @license lucide-react v0.462.0 - ISC
11
- *
12
- * This source code is licensed under the ISC license.
13
- * See the LICENSE file in the root directory of this source tree.
14
- */var Kt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
15
- * @license lucide-react v0.462.0 - ISC
16
- *
17
- * This source code is licensed under the ISC license.
18
- * See the LICENSE file in the root directory of this source tree.
19
- */const Yt=m.forwardRef(({color:o="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:c,iconNode:h,...b},g)=>m.createElement("svg",{ref:g,...Kt,width:t,height:t,stroke:o,strokeWidth:n?Number(s)*24/Number(t):s,className:pt("lucide",r),...b},[...h.map(([x,d])=>m.createElement(x,d)),...Array.isArray(c)?c:[c]]));/**
20
- * @license lucide-react v0.462.0 - ISC
21
- *
22
- * This source code is licensed under the ISC license.
23
- * See the LICENSE file in the root directory of this source tree.
24
- */const y=(o,t)=>{const s=m.forwardRef(({className:n,...r},c)=>m.createElement(Yt,{ref:c,iconNode:t,className:pt(`lucide-${Jt(o)}`,n),...r}));return s.displayName=`${o}`,s};/**
25
- * @license lucide-react v0.462.0 - ISC
26
- *
27
- * This source code is licensed under the ISC license.
28
- * See the LICENSE file in the root directory of this source tree.
29
- */const Zt=y("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
30
- * @license lucide-react v0.462.0 - ISC
31
- *
32
- * This source code is licensed under the ISC license.
33
- * See the LICENSE file in the root directory of this source tree.
34
- */const es=y("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
35
- * @license lucide-react v0.462.0 - ISC
36
- *
37
- * This source code is licensed under the ISC license.
38
- * See the LICENSE file in the root directory of this source tree.
39
- */const ts=y("Camera",[["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",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
40
- * @license lucide-react v0.462.0 - ISC
41
- *
42
- * This source code is licensed under the ISC license.
43
- * See the LICENSE file in the root directory of this source tree.
44
- */const ss=y("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/**
45
- * @license lucide-react v0.462.0 - ISC
46
- *
47
- * This source code is licensed under the ISC license.
48
- * See the LICENSE file in the root directory of this source tree.
49
- */const is=y("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/**
50
- * @license lucide-react v0.462.0 - ISC
51
- *
52
- * This source code is licensed under the ISC license.
53
- * See the LICENSE file in the root directory of this source tree.
54
- */const ns=y("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/**
55
- * @license lucide-react v0.462.0 - ISC
56
- *
57
- * This source code is licensed under the ISC license.
58
- * See the LICENSE file in the root directory of this source tree.
59
- */const rs=y("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
60
- * @license lucide-react v0.462.0 - ISC
61
- *
62
- * This source code is licensed under the ISC license.
63
- * See the LICENSE file in the root directory of this source tree.
64
- */const as=y("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
65
- * @license lucide-react v0.462.0 - ISC
66
- *
67
- * This source code is licensed under the ISC license.
68
- * See the LICENSE file in the root directory of this source tree.
69
- */const os=y("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
70
- * @license lucide-react v0.462.0 - ISC
71
- *
72
- * This source code is licensed under the ISC license.
73
- * See the LICENSE file in the root directory of this source tree.
74
- */const ls=y("Droplet",[["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",key:"c7niix"}]]);/**
75
- * @license lucide-react v0.462.0 - ISC
76
- *
77
- * This source code is licensed under the ISC license.
78
- * See the LICENSE file in the root directory of this source tree.
79
- */const cs=y("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
80
- * @license lucide-react v0.462.0 - ISC
81
- *
82
- * This source code is licensed under the ISC license.
83
- * See the LICENSE file in the root directory of this source tree.
84
- */const ds=y("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
85
- * @license lucide-react v0.462.0 - ISC
86
- *
87
- * This source code is licensed under the ISC license.
88
- * See the LICENSE file in the root directory of this source tree.
89
- */const us=y("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
90
- * @license lucide-react v0.462.0 - ISC
91
- *
92
- * This source code is licensed under the ISC license.
93
- * See the LICENSE file in the root directory of this source tree.
94
- */const hs=y("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
95
- * @license lucide-react v0.462.0 - ISC
96
- *
97
- * This source code is licensed under the ISC license.
98
- * See the LICENSE file in the root directory of this source tree.
99
- */const ms=y("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
100
- * @license lucide-react v0.462.0 - ISC
101
- *
102
- * This source code is licensed under the ISC license.
103
- * See the LICENSE file in the root directory of this source tree.
104
- */const fs=y("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
105
- * @license lucide-react v0.462.0 - ISC
106
- *
107
- * This source code is licensed under the ISC license.
108
- * See the LICENSE file in the root directory of this source tree.
109
- */const ps=y("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/**
110
- * @license lucide-react v0.462.0 - ISC
111
- *
112
- * This source code is licensed under the ISC license.
113
- * See the LICENSE file in the root directory of this source tree.
114
- */const xs=y("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
115
- * @license lucide-react v0.462.0 - ISC
116
- *
117
- * This source code is licensed under the ISC license.
118
- * See the LICENSE file in the root directory of this source tree.
119
- */const bs=y("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
120
- * @license lucide-react v0.462.0 - ISC
121
- *
122
- * This source code is licensed under the ISC license.
123
- * See the LICENSE file in the root directory of this source tree.
124
- */const vs=y("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
125
- * @license lucide-react v0.462.0 - ISC
126
- *
127
- * This source code is licensed under the ISC license.
128
- * See the LICENSE file in the root directory of this source tree.
129
- */const gs=y("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["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",key:"12rzf8"}]]);/**
130
- * @license lucide-react v0.462.0 - ISC
131
- *
132
- * This source code is licensed under the ISC license.
133
- * See the LICENSE file in the root directory of this source tree.
134
- */const ys=y("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
135
- * @license lucide-react v0.462.0 - ISC
136
- *
137
- * This source code is licensed under the ISC license.
138
- * See the LICENSE file in the root directory of this source tree.
139
- */const ws=y("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/**
140
- * @license lucide-react v0.462.0 - ISC
141
- *
142
- * This source code is licensed under the ISC license.
143
- * See the LICENSE file in the root directory of this source tree.
144
- */const ks=y("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
145
- * @license lucide-react v0.462.0 - ISC
146
- *
147
- * This source code is licensed under the ISC license.
148
- * See the LICENSE file in the root directory of this source tree.
149
- */const js=y("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
150
- * @license lucide-react v0.462.0 - ISC
151
- *
152
- * This source code is licensed under the ISC license.
153
- * See the LICENSE file in the root directory of this source tree.
154
- */const Ss=y("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
155
- * @license lucide-react v0.462.0 - ISC
156
- *
157
- * This source code is licensed under the ISC license.
158
- * See the LICENSE file in the root directory of this source tree.
159
- */const Cs=y("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
160
- * @license lucide-react v0.462.0 - ISC
161
- *
162
- * This source code is licensed under the ISC license.
163
- * See the LICENSE file in the root directory of this source tree.
164
- */const Ns=y("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
165
- * @license lucide-react v0.462.0 - ISC
166
- *
167
- * This source code is licensed under the ISC license.
168
- * See the LICENSE file in the root directory of this source tree.
169
- */const zs=y("Settings",[["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-.08a2 2 0 0 1-1-1.74v-.5a2 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",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
170
- * @license lucide-react v0.462.0 - ISC
171
- *
172
- * This source code is licensed under the ISC license.
173
- * See the LICENSE file in the root directory of this source tree.
174
- */const Ms=y("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/**
175
- * @license lucide-react v0.462.0 - ISC
176
- *
177
- * This source code is licensed under the ISC license.
178
- * See the LICENSE file in the root directory of this source tree.
179
- */const Ts=y("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
180
- * @license lucide-react v0.462.0 - ISC
181
- *
182
- * This source code is licensed under the ISC license.
183
- * See the LICENSE file in the root directory of this source tree.
184
- */const Rs=y("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
185
- * @license lucide-react v0.462.0 - ISC
186
- *
187
- * This source code is licensed under the ISC license.
188
- * See the LICENSE file in the root directory of this source tree.
189
- */const Is=y("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
190
- * @license lucide-react v0.462.0 - ISC
191
- *
192
- * This source code is licensed under the ISC license.
193
- * See the LICENSE file in the root directory of this source tree.
194
- */const Ls=y("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/**
195
- * @license lucide-react v0.462.0 - ISC
196
- *
197
- * This source code is licensed under the ISC license.
198
- * See the LICENSE file in the root directory of this source tree.
199
- */const $s=y("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
200
- * @license lucide-react v0.462.0 - ISC
201
- *
202
- * This source code is licensed under the ISC license.
203
- * See the LICENSE file in the root directory of this source tree.
204
- */const Es=y("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
205
- * @license lucide-react v0.462.0 - ISC
206
- *
207
- * This source code is licensed under the ISC license.
208
- * See the LICENSE file in the root directory of this source tree.
209
- */const Ps=y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
210
- * @license lucide-react v0.462.0 - ISC
211
- *
212
- * This source code is licensed under the ISC license.
213
- * See the LICENSE file in the root directory of this source tree.
214
- */const As=y("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),rt=ks,at=ys,Fs=$s,Bs=Ls,Vs=Es,Os=fs,Hs=ps,qs=zs,Ce=rs,Ds=ws,Ws=ss,Us=os,Gs=Rs,_s=Zt,ke=us,Xs=ns,Qs=Is,Js=as,Ks=xs,Ys=js,Zs=Ms,ei=Ts,xt=gs,ti=cs,si=vs,ii=Ss,ni=es,ri=is,ai=ls,oi=ts,li=ms,ci=hs,di=bs,ui=As,hi=Ps,mi=ds,ot=({className:o})=>e.jsxs("div",{className:`relative flex items-center justify-center ${o}`,children:[e.jsx(Cs,{className:"w-full h-full",strokeWidth:2}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),lt=({className:o})=>e.jsxs("div",{className:`relative flex items-center justify-center ${o}`,children:[e.jsx(Ns,{className:"w-full h-full",strokeWidth:2}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),fi=({notifications:o})=>e.jsx("div",{className:"absolute top-4 left-4 z-50 flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[400px]",children:o.map(t=>e.jsxs("div",{className:`
3
+ `+c));const h=new Blob([c],{type:"text/vtt"}),b=URL.createObjectURL(h);this.addTextTrackInternal(b,s,"user",!0),setTimeout(()=>{const u=this.store.get().subtitleTracks.findIndex(j=>j.label===s);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,s,r="",a=!1){const c=document.createElement("track");c.kind="subtitles",c.label=s,c.src=t,c.srclang=r,a&&(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 s=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:s}),this.video.currentTime=s}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const s=Math.max(0,Math.min(t,1));this.video.volume=s,s>0&&this.video.muted&&(this.video.muted=!1),s===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)}}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 s=t.getContext("2d");if(s){s.drawImage(this.video,0,0,t.width,t.height);try{const r=t.toDataURL("image/png"),a=document.createElement("a");a.download=`screenshot-${new Date().toISOString()}.png`,a.href=r,a.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 s=this.store.get().flipState,r={...s,[t]:!s[t]};this.store.setState({flipState:r});const a=r.horizontal?-1:1,c=r.vertical?-1:1;this.video.style.transform=`scale(${a}, ${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,s=()=>{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?s():t.__onGCastApiAvailable=r=>{r&&s()}}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(s=>{s!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+s,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 s=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!s)return;const r=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),a=new t.chrome.cast.media.LoadRequest(r);s.loadMedia(a).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(c=>console.error("Cast load error",c))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){const t=this.store.get();if(t.currentSubtitle===-1){this.store.setState({activeCues:[]});return}const r=Array.from(this.video.textTracks).filter(a=>a.kind==="subtitles"||a.kind==="captions")[t.currentSubtitle];if(r&&r.activeCues){const a=Array.from(r.activeCues).map(c=>c.text);this.store.setState({activeCues:a})}else this.store.setState({activeCues:[]})}setSubtitle(t){if(Array.from(this.video.textTracks).forEach(s=>{s.removeEventListener("cuechange",this.boundCueChange),s.mode="hidden"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t!==-1){const r=Array.from(this.video.textTracks).filter(a=>a.kind==="subtitles"||a.kind==="captions")[t];if(r){const a=this.store.get().subtitleSettings;r.mode=a.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:Se}),this.setSubtitle(this.store.get().currentSubtitle)}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,r=t-s;Math.abs(r)<.001||(Array.from(this.video.textTracks).forEach(a=>{(a.mode==="showing"||a.mode==="hidden")&&a.cues&&Array.from(a.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 s=this.notify({type:"loading",message:"Preparing download...",progress:0});try{const a=await this.fetchWithRetry(t);if(!a.body)throw new Error("No body");const c=a.body.getReader(),h=a.headers.get("Content-Length"),b=h?parseInt(h,10):0;let w=0;const p=[];for(;;){const{done:M,value:T}=await c.read();if(M)break;if(p.push(T),w+=T.length,b){const f=Math.round(w/b*100);this.notify({id:s,type:"loading",message:`Downloading... ${f}%`,progress:f})}}const u=new Blob(p),j=window.URL.createObjectURL(u),y=document.createElement("a");y.style.display="none",y.href=j,y.download=((r=t.split("/").pop())==null?void 0:r.split("?")[0])||"video.mp4",document.body.appendChild(y),y.click(),window.URL.revokeObjectURL(j),document.body.removeChild(y),this.notify({id:s,type:"success",message:"Saved!",duration:3e3})}catch{this.notify({id:s,type:"error",message:"Download failed.",duration:4e3}),window.open(t,"_blank")}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),r={...t,id:s};return this.store.setState({notifications:[r]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(r=>r.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),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(s=>s.destroy&&s.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const we=i=>{if(isNaN(i))return"00:00";const t=Math.floor(i/3600),s=Math.floor(i%3600/60),r=Math.floor(i%60);return t>0?`${t}:${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${s}:${r.toString().padStart(2,"0")}`},qt=async(i,t=3,s=2e4)=>{for(let r=0;r<t;r++){const a=new AbortController,c=setTimeout(()=>a.abort(),s);try{const h=await fetch(i,{signal:a.signal});if(clearTimeout(c),!h.ok)throw new Error(`HTTP ${h.status}`);return await h.text()}catch(h){if(clearTimeout(c),r===t-1)throw h;await new Promise(b=>setTimeout(b,1e3))}}throw new Error("Failed")},Qt=async(i,t,s=2e4)=>{try{const a=(await qt(i,3,s)).split(`
4
+ `),c=[];let h=null,b=null;const w=i.substring(0,i.lastIndexOf("/")+1),p=u=>{const j=u.split(":");let y=0;return j.length===3?(y+=parseFloat(j[0])*3600,y+=parseFloat(j[1])*60,y+=parseFloat(j[2])):(y+=parseFloat(j[0])*60,y+=parseFloat(j[1])),y};for(let u of a)if(u=u.trim(),u.includes("-->")){const j=u.split("-->");h=p(j[0].trim()),b=p(j[1].trim())}else if(h!==null&&b!==null&&u.length>0){let[j,y]=u.split("#");!j.match(/^https?:\/\//)&&!j.startsWith("data:")&&(j=w+j);let M=0,T=0,f=0,B=0;if(y&&y.startsWith("xywh=")){const V=y.replace("xywh=","").split(",");V.length===4&&(M=parseInt(V[0]),T=parseInt(V[1]),f=parseInt(V[2]),B=parseInt(V[3]))}f>0&&B>0&&c.push({start:h,end:b,url:j,x:M,y:T,w:f,h:B}),h=null,b=null}return c}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},nt=(i,t=200)=>{const[s,r]=x.useState(i),[a,c]=x.useState(!1);return x.useEffect(()=>{if(i)r(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(!0)})});else{c(!1);const h=setTimeout(()=>{r(!1)},t);return()=>clearTimeout(h)}},[i,t]),{isMounted:s,isVisible:a}},g=({className:i,children:t,fill:s="none",strokeWidth:r=2,viewBox:a="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:a,fill:s,stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round",className:i,children:t}),rt=({className:i})=>e.jsx(g,{className:i,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),at=({className:i})=>e.jsxs(g,{className:i,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"})]}),Xt=({className:i})=>e.jsxs(g,{className:i,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"})]}),Jt=({className:i})=>e.jsxs(g,{className:i,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"})]}),Kt=({className:i})=>e.jsxs(g,{className:i,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"})]}),Yt=({className:i})=>e.jsxs(g,{className:i,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"})]}),Zt=({className:i})=>e.jsxs(g,{className:i,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"})]}),es=({className:i})=>e.jsxs(g,{className:i,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"})]}),Ce=({className:i})=>e.jsx(g,{className:i,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),ts=({className:i})=>e.jsxs(g,{className:i,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"})]}),ss=({className:i})=>e.jsxs(g,{className:i,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"})]}),is=({className:i})=>e.jsxs(g,{className:i,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"})]}),ns=({className:i})=>e.jsxs(g,{className:i,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"})]}),rs=({className:i})=>e.jsxs(g,{className:i,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),ye=({className:i})=>e.jsx(g,{className:i,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),as=({className:i})=>e.jsxs(g,{className:i,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"})]}),os=({className:i})=>e.jsxs(g,{className:i,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"})]}),ls=({className:i})=>e.jsxs(g,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),cs=({className:i})=>e.jsx(g,{className:i,children:e.jsx("path",{d:"M5 12h14"})}),ds=({className:i})=>e.jsxs(g,{className:i,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),us=({className:i})=>e.jsxs(g,{className:i,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"})]}),hs=({className:i})=>e.jsxs(g,{className:i,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"})]}),ft=({className:i})=>e.jsxs(g,{className:i,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"})]}),ms=({className:i})=>e.jsxs(g,{className:i,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"})]}),xs=({className:i})=>e.jsxs(g,{className:i,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"})]}),fs=({className:i})=>e.jsxs(g,{className:i,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:i})=>e.jsxs(g,{className:i,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"})]}),bs=({className:i})=>e.jsxs(g,{className:i,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"})]}),vs=({className:i})=>e.jsx(g,{className:i,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"})}),gs=({className:i})=>e.jsxs(g,{className:i,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"})]}),ws=({className:i})=>e.jsxs(g,{className:i,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"})]}),js=({className:i})=>e.jsxs(g,{className:i,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"})]}),ys=({className:i})=>e.jsxs(g,{className:i,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"})]}),ks=({className:i})=>e.jsxs(g,{className:i,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"})]}),Ss=({className:i})=>e.jsxs(g,{className:i,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Cs=({className:i})=>e.jsxs(g,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]}),ot=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(g,{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"})]}),lt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(g,{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"})]}),Ns=({notifications:i})=>e.jsx("div",{className:"absolute top-4 left-4 z-50 flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[400px]",children:i.map(t=>e.jsxs("div",{className:`
215
5
  bg-zinc-950/90 backdrop-blur-md border border-white/10 text-white px-4 py-3 rounded-lg shadow-xl text-sm font-medium flex items-start gap-3 animate-in slide-in-from-left-2 fade-in duration-300 pointer-events-auto
216
6
  w-fit max-w-full
217
7
  ${t.type==="error"?"border-red-500/50 text-red-100":""}
218
8
  ${t.type==="warning"?"border-amber-500/50 text-amber-100":""}
219
- `,children:[t.type==="loading"&&e.jsx(ke,{className:"w-4 h-4 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-1 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))}),pi=({cues:o,settings:t})=>{if(t.useNative||o.length===0)return null;const s=()=>{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:o.map((n,r)=>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:s(),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:n}})},r))})},bt=({children:o,onClose:t,align:s="right",maxHeight:n,className:r})=>{const c=m.useRef(null),h=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right",b=n?{maxHeight:`${n}px`}:{};return e.jsx("div",{className:`absolute bottom-full mb-4 ${h} 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-all duration-300 ease-out ${r}`,style:{...b,borderRadius:"var(--radius-lg)"},onClick:g=>g.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:c,children:o})})})},ct=({content:o,className:t})=>typeof o=="string"?o.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:o}}):e.jsx("span",{className:t,children:o}):e.jsx("span",{className:t,children:o}),C=({label:o,value:t,active:s,onClick:n,hasSubmenu:r,icon:c})=>e.jsxs("button",{onClick:n,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(ct,{content:c})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${s?"text-[var(--accent)]":""}`,title:typeof o=="string"?o:void 0,children:e.jsx(ct,{content:o})})]}),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:t}),s&&e.jsx(Ce,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),r&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),F=({label:o,onBack:t,rightAction:s})=>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(_s,{className:"w-3 h-3"}),e.jsx("span",{children:o})]}),s]}),dt=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),ae=({content:o})=>typeof o=="string"?o.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:o}}):e.jsx("span",{children:o}):e.jsx(e.Fragment,{children:o}),_=({label:o,checked:t,onChange:s,icon:n,tooltip:r})=>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:[n&&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(ae,{content:n})}),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(ae,{content:o})}),r&&e.jsx("span",{className:"text-[10px] text-zinc-500",children:r})]})]}),e.jsx("button",{onClick:()=>s(!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-0.5 bg-white w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)"}})})]}),re=({label:o,value:t,min:s,max:n,step:r,onChange:c,formatValue:h,icon:b})=>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:[b&&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(ae,{content:b})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:o})]}),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:h?h(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:s,max:n,step:r,value:t,onChange:g=>c(parseFloat(g.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-s)/(n-s)*100}%, #3f3f46 ${(t-s)/(n-s)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
9
+ `,children:[t.type==="loading"&&e.jsx(ye,{className:"w-4 h-4 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-1 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))}),Ms=({cues:i,settings:t})=>{if(t.useNative||i.length===0)return null;const s=()=>{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:i.map((r,a)=>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:s(),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}})},a))})},pt=({children:i,onClose:t,align:s="right",maxHeight:r,className:a})=>{const c=x.useRef(null),h=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right",b=r?{maxHeight:`${r}px`}:{};return e.jsx("div",{className:`absolute bottom-full mb-4 ${h} 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-all duration-300 ease-out ${a}`,style:{...b,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:c,children:i})})})},ct=({content:i,className:t})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{className:t,children:i}):e.jsx("span",{className:t,children:i}),C=({label:i,value:t,active:s,onClick:r,hasSubmenu:a,icon:c})=>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(ct,{content:c})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${s?"text-[var(--accent)]":""}`,title:typeof i=="string"?i:void 0,children:e.jsx(ct,{content:i})})]}),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:t}),s&&e.jsx(Ce,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),a&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),A=({label:i,onBack:t,rightAction:s})=>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(rs,{className:"w-3 h-3"}),e.jsx("span",{children:i})]}),s]}),dt=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),ae=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),q=({label:i,checked:t,onChange:s,icon:r,tooltip:a})=>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(ae,{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(ae,{content:i})}),a&&e.jsx("span",{className:"text-[10px] text-zinc-500",children:a})]})]}),e.jsx("button",{onClick:()=>s(!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-0.5 bg-white w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)"}})})]}),re=({label:i,value:t,min:s,max:r,step:a,onChange:c,formatValue:h,icon:b})=>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:[b&&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(ae,{content:b})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),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:h?h(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:s,max:r,step:a,value:t,onChange:w=>c(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-s)/(r-s)*100}%, #3f3f46 ${(t-s)/(r-s)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
220
10
  .strata-range-input::-webkit-slider-thumb {
221
11
  -webkit-appearance: none;
222
12
  height: 14px;
@@ -232,7 +22,7 @@
232
22
  transform: scale(1.1);
233
23
  }
234
24
  /* Pixel theme specific overrides are handled by global css */
235
- `})]})]}),xi=({label:o,value:t,options:s,onChange:n,icon:r})=>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:[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(ae,{content:r})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:o})]}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:c=>n(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:s.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"})})})]})]}),X=({title:o,children:t})=>e.jsxs("div",{className:"py-2",children:[o&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:o}),e.jsx("div",{className:"space-y-0.5",children:t})]}),bi=({tracks:o,current:t,onSelect:s,onUpload:n,onClose:r,settings:c,onSettingsChange:h,onReset:b,offset:g,onOffsetChange:x,maxHeight:d,animationClass:w})=>{const[k,z]=m.useState("main"),M=m.useRef(null);return e.jsxs(bt,{onClose:r,align:"right",maxHeight:d,className:w,children:[k==="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(C,{label:"Upload Subtitle",icon:e.jsx(Gs,{className:"w-4 h-4"}),onClick:()=>{var p;return(p=M.current)==null?void 0:p.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:M,className:"hidden",onChange:p=>{var B;(B=p.target.files)!=null&&B[0]&&n(p.target.files[0])}}),e.jsx(C,{label:"Customize",icon:e.jsx(Zs,{className:"w-4 h-4"}),onClick:()=>z("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(C,{label:"Off",active:t===-1,onClick:()=>{s(-1),r()}}),o.map(p=>e.jsx(C,{label:p.label,value:p.language,active:t===p.index,onClick:()=>{s(p.index),r()}},p.index))]})]}),k==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(F,{label:"Customize",onBack:()=>z("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(ii,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(X,{children:e.jsx(_,{label:"Native Video Subtitle",checked:c.useNative,onChange:p=>h({useNative:p})})}),!c.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(X,{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(Js,{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:()=>x(Math.round((g-.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(Ks,{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:[g>0?"+":"",(g==null?void 0:g.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>x(Math.round((g+.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(Ys,{className:"w-4 h-4"})})]})]}),e.jsx(re,{label:"Vertical Position",icon:e.jsx(si,{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(X,{title:"Appearance",children:[e.jsx(re,{label:"Text Size",icon:e.jsx(ei,{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(xt,{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(xi,{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(_,{label:"Bold",icon:e.jsx(ni,{className:"w-4 h-4"}),checked:c.isBold,onChange:p=>h({isBold:p})}),e.jsx(_,{label:"Fix Caps",icon:e.jsx(ri,{className:"w-4 h-4"}),checked:c.fixCapitalization,onChange:p=>h({fixCapitalization:p})})]})]}),e.jsxs(X,{title:"Background",children:[e.jsx(re,{label:"Opacity",icon:e.jsx(ti,{className:"w-4 h-4"}),value:c.backgroundOpacity,min:0,max:100,step:5,onChange:p=>h({backgroundOpacity:p}),formatValue:p=>`${p}%`}),e.jsx(_,{label:"Blur Background",icon:e.jsx(ai,{className:"w-4 h-4"}),checked:c.backgroundBlur,onChange:p=>h({backgroundBlur:p})}),c.backgroundBlur&&e.jsx(re,{label:"Blur Intensity",value:c.backgroundBlurAmount,min:0,max:20,step:1,onChange:p=>h({backgroundBlurAmount:p}),formatValue:p=>`${p}px`})]})]})]})]})]})},we=({content:o})=>typeof o=="string"?o.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:o}}):e.jsx("span",{children:o}):e.jsx(e.Fragment,{children:o}),vi=({x:o,y:t,items:s,onClose:n,containerWidth:r,containerHeight:c})=>{const h=m.useRef(null),[b,g]=m.useState({top:t,left:o,opacity:0});return m.useLayoutEffect(()=>{if(!h.current)return;const x=h.current.getBoundingClientRect(),d=x.width,w=x.height;let k=o,z=t;o+d>r-10&&(k=o-d),k<10&&(k=10),k+d>r&&(k=Math.max(10,r-d-10)),t+w>c-10&&(z=t-w);let M=c-20;z<10&&(z=10),z+w>c-10&&(z=Math.max(10,c-w-10)),g({top:z,left:k,maxHeight:M,opacity:1})},[o,t,s,r,c]),m.useEffect(()=>{const x=d=>{h.current&&!h.current.contains(d.target)&&n()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),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:x=>x.stopPropagation(),children:s.map((x,d)=>x.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},d):x.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(we,{content:x.html||""})},d):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{x.disabled||(x.click?x.click(n):x.onClick&&x.onClick(n))},disabled:x.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:[x.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(we,{content:x.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${x.checked?"text-[var(--accent)]":""}`,children:e.jsx(we,{content:x.html||""})})]}),x.checked&&e.jsx(Ce,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),x.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},d))})},gi=({player:o,onClose:t})=>{const[s,n]=m.useState({});return m.useEffect(()=>{const r=()=>{var g;if(!o.video)return;const h=o.video,b=h.getVideoPlaybackQuality?h.getVideoPlaybackQuality():null;n({"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:((g=o.store.get().sources[o.store.get().currentSourceIndex])==null?void 0:g.type)||"native",URL:h.currentSrc})};r();const c=setInterval(r,1e3);return()=>clearInterval(c)},[o]),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:r=>{r.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(hi,{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(s).map(([r,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:r}),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)})]},r))})]})})},yi=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],wi=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],ut=({content:o,className:t,style:s})=>typeof o=="string"?o.trim().startsWith("<")?e.jsx("div",{className:t,style:s,dangerouslySetInnerHTML:{__html:o}}):e.jsx("div",{className:t,style:s,children:o}):e.jsx("div",{className:t,style:s,children:o}),je=o=>{var tt,st;const{src:t,type:s,sources:n,poster:r,autoPlay:c,thumbnails:h,textTracks:b,plugins:g,onGetInstance:x,...d}=o,w=d.screenshot??!1,k=d.pip??!0,z=d.setting??!0,M=d.fullscreen??!0,p=d.fullscreenWeb??!1,B=d.lock??!1,V=d.fastForward??!0,vt=d.flip??!0,gt=d.aspectRatio??!0,Ne=d.hotKey??!0,yt=d.backdrop??!0,oe=d.gestureSeek??!1,wt=d.centerControls??!0,ze=d.fetchTimeout??3e4;d.autoOrientation;const D=m.useRef(null),[i,Me]=m.useState(null),[le,ce]=m.useState(!1),[Te,kt]=m.useState(0),[jt,St]=m.useState(0),Re=m.useMemo(()=>mt(d),[]),a=m.useSyncExternalStore(m.useCallback(l=>i?i.store.subscribe(l):()=>{},[i]),()=>i?i.store.get():Re,()=>Re),[T,E]=m.useState(!1),[R,O]=m.useState(!1),[I,N]=m.useState("main"),[Q,de]=m.useState({x:0,y:0,visible:!1}),[Ct,Ie]=m.useState(!1),Le=nt(T,200),$e=nt(R,200),[ue,ee]=m.useState(!1),[te,he]=m.useState(0),[Nt,Ee]=m.useState(!1),[zt,Pe]=m.useState(!1),[me,se]=m.useState(!1),[Ae,Fe]=m.useState([]),[Be,Ve]=m.useState(null),[Mt,Tt]=m.useState(0),[H,Oe]=m.useState(null),[W,ie]=m.useState(null),[ji,He]=m.useState(null),[fe,qe]=m.useState(!1),pe=m.useRef(null),De=m.useRef(1),K=m.useRef(null),We=m.useRef(0),J=m.useRef(!1),Y=m.useRef(null),q=m.useRef(null),xe=m.useRef(null),be=m.useRef(null),Z=m.useRef(null);m.useEffect(()=>{if(!D.current)return;const l=new ft({...d,poster:r});g&&g.length>0&&g.forEach(v=>l.use(v)),l.attach(D.current),Me(l),x&&x(l);const f=new ResizeObserver(v=>{for(const S of v)kt(S.contentRect.height),St(S.contentRect.width)});return f.observe(D.current),()=>{f.disconnect(),l.destroy(),Me(null)}},[]),m.useEffect(()=>{if(!i)return;const l={};d.theme!==void 0&&d.theme!==a.theme&&(l.theme=d.theme),d.themeColor!==void 0&&d.themeColor!==a.themeColor&&(l.themeColor=d.themeColor),d.iconSize!==void 0&&d.iconSize!==a.iconSize&&(l.iconSize=d.iconSize),Object.keys(l).length>0&&i.setAppearance(l),d.volume!==void 0&&Math.abs(d.volume-a.volume)>.01&&i.setVolume(d.volume),d.muted!==void 0&&d.muted!==a.isMuted&&(d.muted?i.video.muted=!0:i.video.muted=!1)},[i,d.theme,d.themeColor,d.iconSize,d.volume,d.muted]),m.useEffect(()=>{if(!i)return;const l=b||[];n&&n.length>0?(ce(!1),i.setSources(n,l)):t&&(ce(!1),i.setSources([{url:t,type:s||"auto"}],l))},[t,s,n,b,i]),m.useEffect(()=>{i&&c&&(i.video.muted=!0,i.store.setState({isMuted:!0}),i.play().catch(()=>{}))},[i,c]),m.useEffect(()=>{a.isPlaying&&!le&&ce(!0)},[a.isPlaying,le]),m.useEffect(()=>{h&&i?Qt(h,i.notify.bind(i),ze).then(l=>Fe(l)):Fe([])},[h,i,ze]),m.useEffect(()=>(W&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{ie(null)},600)),()=>{Z.current&&clearTimeout(Z.current)}),[W]),m.useEffect(()=>{const l=f=>{var v;if(!(!i||!Ne)&&((v=document.activeElement)==null?void 0:v.tagName)!=="INPUT")switch(f.key.toLowerCase()){case" ":case"k":f.preventDefault(),i.togglePlay();break;case"arrowright":f.preventDefault(),i.skip(5);break;case"arrowleft":f.preventDefault(),i.skip(-5);break;case"arrowup":f.preventDefault(),i.setVolume(i.video.volume+.1);break;case"arrowdown":f.preventDefault(),i.setVolume(i.video.volume-.1);break;case"f":f.preventDefault(),i.toggleFullscreen();break;case"m":f.preventDefault(),i.toggleMute();break}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[i,Ne]);const Ue=()=>{i&&(i.setControlsVisible(!0),q.current&&clearTimeout(q.current),!(T||R)&&(q.current=setTimeout(()=>{!a.isPlaying||T||R||i.setControlsVisible(!1)},2500)))};m.useEffect(()=>{i&&(!T&&!R&&a.isPlaying?Ue():(T||R)&&(i.setControlsVisible(!0),q.current&&clearTimeout(q.current)))},[T,R,a.isPlaying,i]);const Ge=m.useCallback(()=>{!V||!i||!a.isPlaying||a.isLocked||(De.current=i.video.playbackRate,pe.current=setTimeout(()=>{i.video.playbackRate=2,qe(!0)},500))},[V,i,a.isPlaying,a.isLocked]),ve=m.useCallback(()=>{pe.current&&clearTimeout(pe.current),fe&&i&&(i.video.playbackRate=De.current,qe(!1))},[fe,i]),Rt=l=>{Ge(),oe&&!a.isLocked&&(K.current=l.touches[0].clientX,We.current=a.currentTime,J.current=!1)},It=l=>{if(!a.isLocked&&oe&&K.current!==null){const f=l.touches[0].clientX-K.current;if(Math.abs(f)>10&&(ve(),J.current=!0,ee(!0),D.current&&a.duration)){const v=D.current.getBoundingClientRect(),S=f/v.width,A=Math.max(0,Math.min(a.duration,We.current+S*a.duration));he(A)}}},Lt=l=>{if(ve(),oe&&J.current){i==null||i.seek(te),ee(!1),J.current=!1,K.current=null;return}K.current=null},ge=l=>{if(!xe.current||!a.duration)return 0;const f=xe.current.getBoundingClientRect(),v="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(v-f.left)/f.width))*a.duration},_e=l=>{if(a.isLocked)return;ee(!0),he(ge(l));const f=S=>he(ge(S)),v=S=>{i==null||i.seek(ge(S)),ee(!1),document.removeEventListener("mousemove",f),document.removeEventListener("touchmove",f),document.removeEventListener("mouseup",v),document.removeEventListener("touchend",v)};document.addEventListener("mousemove",f),document.addEventListener("touchmove",f),document.addEventListener("mouseup",v),document.addEventListener("touchend",v)},Xe=l=>{if(!be.current)return 0;const f=be.current.getBoundingClientRect(),v="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(v-f.left)/f.width))},Qe=l=>{if(!i||a.isLocked)return;Ee(!0),i.setVolume(Xe(l));const f=S=>i.setVolume(Xe(S)),v=()=>{Ee(!1),document.removeEventListener("mousemove",f),document.removeEventListener("touchmove",f),document.removeEventListener("mouseup",v),document.removeEventListener("touchend",v)};document.addEventListener("mousemove",f),document.addEventListener("touchmove",f),document.addEventListener("mouseup",v),document.addEventListener("touchend",v)},$t=l=>{if(!a.duration||a.isLive)return;const f=l.currentTarget.getBoundingClientRect(),v=(l.clientX-f.left)/f.width,S=v*a.duration;Tt(v*100),Ve(S),Ae.length>0&&Oe(Ae.find(A=>S>=A.start&&S<A.end)||null)},ne=l=>{!i||a.isLocked||(i.skip(l==="forward"?10:-10),He(l),setTimeout(()=>He(null),300))},Et=l=>{if(!i)return;if(J.current){J.current=!1;return}if(T&&E(!1),R&&O(!1),me&&se(!1),Q.visible&&de({...Q,visible:!1}),i.setControlsVisible(!0),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{!a.isPlaying||T||R||i.setControlsVisible(!1)},2500),a.isLocked)return;const f=l.currentTarget.getBoundingClientRect(),v=l.clientX-f.left,S=f.width,A=Date.now();Y.current?(clearTimeout(Y.current),Y.current=null,v<S*.35?(ne("rewind"),ie({type:"rewind",id:A})):v>S*.65?(ne("forward"),ie({type:"forward",id:A})):i.toggleFullscreen()):Y.current=setTimeout(()=>{i.togglePlay(),Y.current=null},250)},Pt=l=>{var v;if(l.preventDefault(),a.isLocked)return;const f=(v=D.current)==null?void 0:v.getBoundingClientRect();f&&de({visible:!0,x:l.clientX-f.left,y:l.clientY-f.top})},At=l=>{l.stopPropagation();const f="ontouchstart"in window||navigator.maxTouchPoints>0,v=window.matchMedia("(hover: none)").matches||f;if(me){se(!1);return}v?se(!0):i==null||i.toggleMute()},Ft=a.isMuted||a.volume===0?Vs:a.volume<.5?Bs:Fs,Je=Math.max(100,Te-120),Bt=()=>{switch(a.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},Vt=()=>{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]"}},L=Bt(),P=Vt(),U=(()=>{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"}}})(),Ot=!a.isLocked&&(a.controlsVisible||!a.isPlaying||T||R),Ke=zt||Nt||me,Ye=yt?"backdrop-blur-xl bg-black/80":"bg-black/95",Ze=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 d.controls&&d.controls.forEach(f=>{const v=l.find(S=>S.id===f.id);v?Object.assign(v,f):l.push(f)}),l.filter(f=>!(f.id==="screenshot"&&!w||f.id==="pip"&&!k||f.id==="settings"&&!z||f.id==="fullscreen"&&!M||f.id==="fullscreenWeb"&&!p)).sort((f,v)=>f.index-v.index)},[d.controls,w,k,z,M,p]),et=l=>{var f,v,S,A,it;if(!l.isBuiltIn)return e.jsx("button",{onClick:()=>{l.click?l.click(i):l.onClick&&l.onClick(i)},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none flex items-center justify-center ${P} ${l.className||""}`,style:{borderRadius:"var(--radius)",...l.style},title:l.tooltip,children:e.jsx(ut,{content:l.html||""})},l.index);switch(l.id){case"play":return e.jsx("button",{onClick:()=>i==null?void 0:i.togglePlay(),className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:a.isPlaying?e.jsx(at,{className:`${L} fill-current`}):e.jsx(rt,{className:`${L} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&Pe(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&Pe(!1)},children:[e.jsx("button",{onClick:At,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ft,{className:L})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${Ke?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:be,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:Qe,onTouchStart:Qe,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)"}})]})}),Ke&&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 d.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-red-500/10 border border-red-500/20 rounded-md",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 tracking-wider",children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[ye(ue?te:a.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",ye(a.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:u=>{u.stopPropagation(),O(!R),E(!1)},className:`strata-control-btn transition-colors focus:outline-none ${P} ${R?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ws,{className:L})}),$e.isMounted&&e.jsx(bi,{tracks:a.subtitleTracks,current:a.currentSubtitle,onSelect:u=>i==null?void 0:i.setSubtitle(u),onUpload:u=>i==null?void 0:i.addTextTrack(u,u.name),onClose:()=>O(!1),settings:a.subtitleSettings,onSettingsChange:u=>i==null?void 0:i.updateSubtitleSettings(u),onReset:()=>i==null?void 0:i.resetSubtitleSettings(),offset:a.subtitleOffset,onOffsetChange:u=>i==null?void 0:i.setSubtitleOffset(u),maxHeight:Je,animationClass:`strata-backdrop ${Ye} ${$e.isVisible?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-2 scale-95"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onClick:()=>i==null?void 0:i.screenshot(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(oi,{className:L})},"ss");case"pip":return e.jsx("button",{onClick:()=>i==null?void 0:i.togglePip(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ds,{className:L})},"pip");case"download":return e.jsx("button",{onClick:()=>i==null?void 0:i.download(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Us,{className:L})},"dl");case"fullscreen":return e.jsx("button",{onClick:()=>i==null?void 0:i.toggleFullscreen(),className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform hover:scale-110 focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:a.isFullscreen?e.jsx(Hs,{className:L}):e.jsx(Os,{className:L})},"fs");case"fullscreenWeb":return e.jsx("button",{className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(di,{className:L})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:u=>{u.stopPropagation(),E(!T),O(!1),N("main")},className:`strata-control-btn transition-all duration-300 focus:outline-none ${P} ${T?"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(qs,{className:L})}),Le.isMounted&&e.jsx(bt,{onClose:()=>E(!1),align:"right",maxHeight:Je,className:`strata-backdrop ${Ye} ${Le.isVisible?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-2 scale-95"}`,children:e.jsxs("div",{className:"w-full",children:[I==="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.jsx(C,{label:"Source",value:((f=a.sources[a.currentSourceIndex])==null?void 0:f.name)||`Source ${a.currentSourceIndex+1}`,onClick:()=>N("sources"),hasSubmenu:!0}),e.jsx(C,{label:"Speed",value:`${a.playbackRate}x`,onClick:()=>N("speed"),hasSubmenu:!0}),e.jsx(C,{label:"Quality",value:a.currentQuality===-1?"Auto":`${(v=a.qualityLevels[a.currentQuality])==null?void 0:v.height}p`,onClick:()=>N("quality"),hasSubmenu:!0}),e.jsx(C,{label:"Audio",value:((S=a.audioTracks[a.currentAudioTrack])==null?void 0:S.label)||"Default",onClick:()=>N("audio"),hasSubmenu:!0}),vt&&e.jsx(C,{label:"Flip",value:a.flipState.horizontal?"H":a.flipState.vertical?"V":"Normal",onClick:()=>N("flip"),hasSubmenu:!0}),gt&&e.jsx(C,{label:"Aspect Ratio",value:a.aspectRatio,onClick:()=>N("ratio"),hasSubmenu:!0}),e.jsx(dt,{}),e.jsx(C,{label:"Audio Boost",value:a.audioGain>1?`${a.audioGain}x`:"Off",onClick:()=>N("boost"),hasSubmenu:!0}),e.jsx(C,{label:"Watch Party",icon:e.jsx(Qs,{className:"w-4 h-4"}),onClick:()=>N("party"),hasSubmenu:!0}),e.jsx(C,{label:"Cast to Device",icon:e.jsx(Xs,{className:"w-4 h-4"}),onClick:()=>{i==null||i.requestCast(),E(!1)}}),(A=d.settings)==null?void 0:A.map((u,G)=>u.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(_,{label:u.html,icon:u.icon,checked:u.switch,tooltip:u.tooltip,onChange:Ci=>{u.onSwitch&&u.onSwitch(u)}})},`cust-${G}`):e.jsx(C,{label:u.html,icon:u.icon,onClick:()=>{u.click?u.click():u.onClick&&u.onClick(),E(!1)}},`cust-${G}`)),e.jsx(dt,{}),e.jsx(C,{label:"Appearance",icon:e.jsx(xt,{className:"w-4 h-4"}),onClick:()=>N("appearance"),hasSubmenu:!0})]}),["speed","quality","audio","boost","party","appearance","sources","flip","ratio"].includes(I)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[I==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Select Source",onBack:()=>N("main")}),a.sources.map((u,G)=>e.jsx(C,{label:u.name||`Source ${G+1}`,value:u.type,active:a.currentSourceIndex===G,onClick:()=>i==null?void 0:i.switchSource(G)},G))]}),I==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Speed",onBack:()=>N("main")}),[.5,1,1.5,2].map(u=>e.jsx(C,{label:`${u}x`,active:a.playbackRate===u,onClick:()=>i.video.playbackRate=u},u))]}),I==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Quality",onBack:()=>N("main")}),e.jsx(C,{label:"Auto",active:a.currentQuality===-1,onClick:()=>i==null?void 0:i.setQuality(-1)}),a.qualityLevels.map(u=>e.jsx(C,{label:`${u.height}p`,value:`${Math.round(u.bitrate/1e3)}k`,active:a.currentQuality===u.index,onClick:()=>i==null?void 0:i.setQuality(u.index)},u.index))]}),I==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Audio Track",onBack:()=>N("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(u=>e.jsx(C,{label:u.label,value:u.language,active:a.currentAudioTrack===u.index,onClick:()=>i==null?void 0:i.setAudioTrack(u.index)},u.index))]}),I==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Audio Boost",onBack:()=>N("main")}),[1,1.5,2,3].map(u=>e.jsx(C,{label:u===1?"Off":`${u}x`,active:a.audioGain===u,onClick:()=>i==null?void 0:i.setAudioGain(u)},u))]}),I==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Video Flip",onBack:()=>N("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(_,{label:"Horizontal Flip",checked:a.flipState.horizontal,onChange:()=>i==null?void 0:i.setFlip("horizontal")}),e.jsx(_,{label:"Vertical Flip",checked:a.flipState.vertical,onChange:()=>i==null?void 0:i.setFlip("vertical")})]})]}),I==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Aspect Ratio",onBack:()=>N("main")}),["default","16:9","4:3"].map(u=>e.jsx(C,{label:u==="default"?"Default":u,active:a.aspectRatio===u,onClick:()=>i==null?void 0:i.setAspectRatio(u)},u))]}),I==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Watch Party",onBack:()=>N("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(((it=a.sources[a.currentSourceIndex])==null?void 0:it.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"})]})]}),I==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Appearance",onBack:()=>N("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx(X,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:wi.map(u=>e.jsx("button",{onClick:()=>i==null?void 0:i.setAppearance({theme:u.value,themeColor:u.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${a.theme===u.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:u.label},u.value))})}),e.jsx(X,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(u=>e.jsx("button",{onClick:()=>i==null?void 0:i.setAppearance({iconSize:u}),className:`py-1.5 text-xs font-medium transition-colors ${a.iconSize===u?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:u.charAt(0).toUpperCase()+u.slice(1)},u))})}),e.jsxs(X,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:yi.map(u=>e.jsx("button",{title:u.label,onClick:()=>i==null?void 0:i.setAppearance({themeColor:u.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${a.themeColor===u.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:u.value,borderRadius:"var(--radius-full)"},children:a.themeColor===u.value&&e.jsx(Ce,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},u.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:u=>i==null?void 0:i.setAppearance({themeColor:u.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}},Ht=m.useMemo(()=>{const l=[{html:"Playback",isLabel:!0},{html:"Loop",checked:a.isLooping,onClick:()=>i==null?void 0:i.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>i==null?void 0:i.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>i==null?void 0:i.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:a.aspectRatio==="default",onClick:()=>i==null?void 0:i.setAspectRatio("default")},{html:"16:9",checked:a.aspectRatio==="16:9",onClick:()=>i==null?void 0:i.setAspectRatio("16:9")},{html:"4:3",checked:a.aspectRatio==="4:3",onClick:()=>i==null?void 0:i.setAspectRatio("4:3")},{separator:!0},{html:"Video Info",icon:e.jsx(mi,{className:"w-3.5 h-3.5"}),onClick:()=>Ie(!0)},{separator:!0}];return d.contextmenu&&l.push(...d.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},[d.contextmenu,a.aspectRatio,a.isLooping,i]);return e.jsxs("div",{id:d.id,ref:D,className:`group relative w-full h-full bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none rounded-[var(--radius)] text-zinc-100 strata-player-reset ${d.container||""}`,style:{touchAction:"manipulation","--accent":a.themeColor},onMouseMove:Ue,onMouseLeave:()=>{a.isPlaying&&!T&&!R&&i&&i.setControlsVisible(!1)},onMouseDown:Ge,onMouseUp:ve,onTouchStart:Rt,onTouchMove:It,onTouchEnd:Lt,onContextMenu:Pt,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":a.theme,children:[e.jsx("style",{children:`
25
+ `})]})]}),Ts=({label:i,value:t,options:s,onChange:r,icon:a})=>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:[a&&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(ae,{content:a})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),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:s.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"})})})]})]}),Q=({title:i,children:t})=>e.jsxs("div",{className:"py-2",children:[i&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:i}),e.jsx("div",{className:"space-y-0.5",children:t})]}),zs=({tracks:i,current:t,onSelect:s,onUpload:r,onClose:a,settings:c,onSettingsChange:h,onReset:b,offset:w,onOffsetChange:p,maxHeight:u,animationClass:j})=>{const[y,M]=x.useState("main"),T=x.useRef(null);return e.jsxs(pt,{onClose:a,align:"right",maxHeight:u,className:j,children:[y==="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(C,{label:"Upload Subtitle",icon:e.jsx(ns,{className:"w-4 h-4"}),onClick:()=>{var f;return(f=T.current)==null?void 0:f.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:T,className:"hidden",onChange:f=>{var B;(B=f.target.files)!=null&&B[0]&&r(f.target.files[0])}}),e.jsx(C,{label:"Customize",icon:e.jsx(us,{className:"w-4 h-4"}),onClick:()=>M("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(C,{label:"Off",active:t===-1,onClick:()=>{s(-1),a()}}),i.map(f=>e.jsx(C,{label:f.label,value:f.language,active:t===f.index,onClick:()=>{s(f.index),a()}},f.index))]})]}),y==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(A,{label:"Customize",onBack:()=>M("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(fs,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(Q,{children:e.jsx(q,{label:"Native Video Subtitle",checked:c.useNative,onChange:f=>h({useNative:f})})}),!c.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{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(ls,{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:()=>p(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:()=>p(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(ds,{className:"w-4 h-4"})})]})]}),e.jsx(re,{label:"Vertical Position",icon:e.jsx(xs,{className:"w-4 h-4"}),value:c.verticalOffset,min:0,max:200,step:5,onChange:f=>h({verticalOffset:f}),formatValue:f=>`${f}px`})]}),e.jsxs(Q,{title:"Appearance",children:[e.jsx(re,{label:"Text Size",icon:e.jsx(hs,{className:"w-4 h-4"}),value:c.textSize,min:50,max:200,step:10,onChange:f=>h({textSize:f}),formatValue:f=>`${f}%`}),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(ft,{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(f=>e.jsx("button",{onClick:()=>h({textColor:f}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${c.textColor===f?"ring-2 scale-110":""}`,style:{backgroundColor:f,"--tw-ring-color":"var(--accent)"}},f)),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:f=>h({textColor:f.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(Ts,{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:f=>h({textStyle:f})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(q,{label:"Bold",icon:e.jsx(ps,{className:"w-4 h-4"}),checked:c.isBold,onChange:f=>h({isBold:f})}),e.jsx(q,{label:"Fix Caps",icon:e.jsx(bs,{className:"w-4 h-4"}),checked:c.fixCapitalization,onChange:f=>h({fixCapitalization:f})})]})]}),e.jsxs(Q,{title:"Background",children:[e.jsx(re,{label:"Opacity",icon:e.jsx(ms,{className:"w-4 h-4"}),value:c.backgroundOpacity,min:0,max:100,step:5,onChange:f=>h({backgroundOpacity:f}),formatValue:f=>`${f}%`}),e.jsx(q,{label:"Blur Background",icon:e.jsx(vs,{className:"w-4 h-4"}),checked:c.backgroundBlur,onChange:f=>h({backgroundBlur:f})}),c.backgroundBlur&&e.jsx(re,{label:"Blur Intensity",value:c.backgroundBlurAmount,min:0,max:20,step:1,onChange:f=>h({backgroundBlurAmount:f}),formatValue:f=>`${f}px`})]})]})]})]})]})},je=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),Rs=({x:i,y:t,items:s,onClose:r,containerWidth:a,containerHeight:c})=>{const h=x.useRef(null),[b,w]=x.useState({top:t,left:i,opacity:0});return x.useLayoutEffect(()=>{if(!h.current)return;const p=h.current.getBoundingClientRect(),u=p.width,j=p.height;let y=i,M=t;i+u>a-10&&(y=i-u),y<10&&(y=10),y+u>a&&(y=Math.max(10,a-u-10)),t+j>c-10&&(M=t-j);let T=c-20;M<10&&(M=10),M+j>c-10&&(M=Math.max(10,c-j-10)),w({top:M,left:y,maxHeight:T,opacity:1})},[i,t,s,a,c]),x.useEffect(()=>{const p=u=>{h.current&&!h.current.contains(u.target)&&r()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[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:p=>p.stopPropagation(),children:s.map((p,u)=>p.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},u):p.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(je,{content:p.html||""})},u):e.jsxs(x.Fragment,{children:[e.jsxs("button",{onClick:()=>{p.disabled||(p.click?p.click(r):p.onClick&&p.onClick(r))},disabled:p.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:[p.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(je,{content:p.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${p.checked?"text-[var(--accent)]":""}`,children:e.jsx(je,{content:p.html||""})})]}),p.checked&&e.jsx(Ce,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),p.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},u))})},Is=({player:i,onClose:t})=>{const[s,r]=x.useState({});return x.useEffect(()=>{const a=()=>{var w;if(!i.video)return;const h=i.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:((w=i.store.get().sources[i.store.get().currentSourceIndex])==null?void 0:w.type)||"native",URL:h.currentSrc})};a();const c=setInterval(a,1e3);return()=>clearInterval(c)},[i]),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:a=>{a.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(Ss,{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(s).map(([a,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:a}),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)})]},a))})]})})},Ls=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],$s=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],ut=({content:i,className:t,style:s})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("div",{className:t,style:s,dangerouslySetInnerHTML:{__html:i}}):e.jsx("div",{className:t,style:s,children:i}):e.jsx("div",{className:t,style:s,children:i}),ke=i=>{var tt,st;const{src:t,type:s,sources:r,poster:a,autoPlay:c,thumbnails:h,textTracks:b,plugins:w,onGetInstance:p,...u}=i,j=u.screenshot??!1,y=u.pip??!0,M=u.setting??!0,T=u.fullscreen??!0,f=u.fullscreenWeb??!1,B=u.lock??!1,V=u.fastForward??!0,bt=u.flip??!0,vt=u.aspectRatio??!0,Ne=u.hotKey??!0,gt=u.backdrop??!0,oe=u.gestureSeek??!1,wt=u.centerControls??!0,Me=u.fetchTimeout??3e4;u.autoOrientation;const D=x.useRef(null),[n,Te]=x.useState(null),[le,ce]=x.useState(!1),[ze,jt]=x.useState(0),[yt,kt]=x.useState(0),Re=x.useMemo(()=>mt(u),[]),o=x.useSyncExternalStore(x.useCallback(l=>n?n.store.subscribe(l):()=>{},[n]),()=>n?n.store.get():Re,()=>Re),[z,E]=x.useState(!1),[R,O]=x.useState(!1),[I,N]=x.useState("main"),[X,de]=x.useState({x:0,y:0,visible:!1}),[St,Ie]=x.useState(!1),Le=nt(z,200),$e=nt(R,200),[ue,ee]=x.useState(!1),[te,he]=x.useState(0),[Ct,Ee]=x.useState(!1),[Nt,Pe]=x.useState(!1),[me,se]=x.useState(!1),[Fe,Ae]=x.useState([]),[Be,Ve]=x.useState(null),[Mt,Tt]=x.useState(0),[H,Oe]=x.useState(null),[U,ie]=x.useState(null),[Ps,He]=x.useState(null),[xe,We]=x.useState(!1),fe=x.useRef(null),De=x.useRef(1),K=x.useRef(null),Ue=x.useRef(0),J=x.useRef(!1),Y=x.useRef(null),W=x.useRef(null),pe=x.useRef(null),be=x.useRef(null),Z=x.useRef(null);x.useEffect(()=>{if(!D.current)return;const l=new xt({...u,poster:a});w&&w.length>0&&w.forEach(v=>l.use(v)),l.attach(D.current),Te(l),p&&p(l);const m=new ResizeObserver(v=>{for(const S of v)jt(S.contentRect.height),kt(S.contentRect.width)});return m.observe(D.current),()=>{m.disconnect(),l.destroy(),Te(null)}},[]),x.useEffect(()=>{if(!n)return;const l={};u.theme!==void 0&&u.theme!==o.theme&&(l.theme=u.theme),u.themeColor!==void 0&&u.themeColor!==o.themeColor&&(l.themeColor=u.themeColor),u.iconSize!==void 0&&u.iconSize!==o.iconSize&&(l.iconSize=u.iconSize),Object.keys(l).length>0&&n.setAppearance(l),u.volume!==void 0&&Math.abs(u.volume-o.volume)>.01&&n.setVolume(u.volume),u.muted!==void 0&&u.muted!==o.isMuted&&(u.muted?n.video.muted=!0:n.video.muted=!1)},[n,u.theme,u.themeColor,u.iconSize,u.volume,u.muted]),x.useEffect(()=>{if(!n)return;const l=b||[];r&&r.length>0?(ce(!1),n.setSources(r,l)):t&&(ce(!1),n.setSources([{url:t,type:s||"auto"}],l))},[t,s,r,b,n]),x.useEffect(()=>{n&&c&&(n.video.muted=!0,n.store.setState({isMuted:!0}),n.play().catch(()=>{}))},[n,c]),x.useEffect(()=>{o.isPlaying&&!le&&ce(!0)},[o.isPlaying,le]),x.useEffect(()=>{h&&n?Qt(h,n.notify.bind(n),Me).then(l=>Ae(l)):Ae([])},[h,n,Me]),x.useEffect(()=>(U&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{ie(null)},600)),()=>{Z.current&&clearTimeout(Z.current)}),[U]),x.useEffect(()=>{const l=m=>{var v;if(!(!n||!Ne)&&((v=document.activeElement)==null?void 0:v.tagName)!=="INPUT")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}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n,Ne]);const Ge=()=>{n&&(n.setControlsVisible(!0),W.current&&clearTimeout(W.current),!(z||R)&&(W.current=setTimeout(()=>{!o.isPlaying||z||R||n.setControlsVisible(!1)},2500)))};x.useEffect(()=>{n&&(!z&&!R&&o.isPlaying?Ge():(z||R)&&(n.setControlsVisible(!0),W.current&&clearTimeout(W.current)))},[z,R,o.isPlaying,n]);const _e=x.useCallback(()=>{!V||!n||!o.isPlaying||o.isLocked||(De.current=n.video.playbackRate,fe.current=setTimeout(()=>{n.video.playbackRate=2,We(!0)},500))},[V,n,o.isPlaying,o.isLocked]),ve=x.useCallback(()=>{fe.current&&clearTimeout(fe.current),xe&&n&&(n.video.playbackRate=De.current,We(!1))},[xe,n]),zt=l=>{_e(),oe&&!o.isLocked&&(K.current=l.touches[0].clientX,Ue.current=o.currentTime,J.current=!1)},Rt=l=>{if(!o.isLocked&&oe&&K.current!==null){const m=l.touches[0].clientX-K.current;if(Math.abs(m)>10&&(ve(),J.current=!0,ee(!0),D.current&&o.duration)){const v=D.current.getBoundingClientRect(),S=m/v.width,F=Math.max(0,Math.min(o.duration,Ue.current+S*o.duration));he(F)}}},It=l=>{if(ve(),oe&&J.current){n==null||n.seek(te),ee(!1),J.current=!1,K.current=null;return}K.current=null},ge=l=>{if(!pe.current||!o.duration)return 0;const m=pe.current.getBoundingClientRect(),v="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(v-m.left)/m.width))*o.duration},qe=l=>{if(o.isLocked)return;ee(!0),he(ge(l));const m=S=>he(ge(S)),v=S=>{n==null||n.seek(ge(S)),ee(!1),document.removeEventListener("mousemove",m),document.removeEventListener("touchmove",m),document.removeEventListener("mouseup",v),document.removeEventListener("touchend",v)};document.addEventListener("mousemove",m),document.addEventListener("touchmove",m),document.addEventListener("mouseup",v),document.addEventListener("touchend",v)},Qe=l=>{if(!be.current)return 0;const m=be.current.getBoundingClientRect(),v="touches"in l?l.touches[0].clientX:l.clientX;return Math.max(0,Math.min(1,(v-m.left)/m.width))},Xe=l=>{if(!n||o.isLocked)return;Ee(!0),n.setVolume(Qe(l));const m=S=>n.setVolume(Qe(S)),v=()=>{Ee(!1),document.removeEventListener("mousemove",m),document.removeEventListener("touchmove",m),document.removeEventListener("mouseup",v),document.removeEventListener("touchend",v)};document.addEventListener("mousemove",m),document.addEventListener("touchmove",m),document.addEventListener("mouseup",v),document.addEventListener("touchend",v)},Lt=l=>{if(!o.duration||o.isLive)return;const m=l.currentTarget.getBoundingClientRect(),v=(l.clientX-m.left)/m.width,S=v*o.duration;Tt(v*100),Ve(S),Fe.length>0&&Oe(Fe.find(F=>S>=F.start&&S<F.end)||null)},ne=l=>{!n||o.isLocked||(n.skip(l==="forward"?10:-10),He(l),setTimeout(()=>He(null),300))},$t=l=>{if(!n)return;if(J.current){J.current=!1;return}if(z&&E(!1),R&&O(!1),me&&se(!1),X.visible&&de({...X,visible:!1}),n.setControlsVisible(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{!o.isPlaying||z||R||n.setControlsVisible(!1)},2500),o.isLocked)return;const m=l.currentTarget.getBoundingClientRect(),v=l.clientX-m.left,S=m.width,F=Date.now();Y.current?(clearTimeout(Y.current),Y.current=null,v<S*.35?(ne("rewind"),ie({type:"rewind",id:F})):v>S*.65?(ne("forward"),ie({type:"forward",id:F})):n.toggleFullscreen()):Y.current=setTimeout(()=>{n.togglePlay(),Y.current=null},250)},Et=l=>{var v;if(l.preventDefault(),o.isLocked)return;const m=(v=D.current)==null?void 0:v.getBoundingClientRect();m&&de({visible:!0,x:l.clientX-m.left,y:l.clientY-m.top})},Pt=l=>{l.stopPropagation();const m="ontouchstart"in window||navigator.maxTouchPoints>0,v=window.matchMedia("(hover: none)").matches||m;if(me){se(!1);return}v?se(!0):n==null||n.toggleMute()},Ft=o.isMuted||o.volume===0?Kt:o.volume<.5?Jt:Xt,Je=Math.max(100,ze-120),At=()=>{switch(o.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},Bt=()=>{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]"}},L=At(),P=Bt(),G=(()=>{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"}}})(),Vt=!o.isLocked&&(o.controlsVisible||!o.isPlaying||z||R),Ke=Nt||Ct||me,Ye=gt?"backdrop-blur-xl bg-black/80":"bg-black/95",Ze=x.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(m=>{const v=l.find(S=>S.id===m.id);v?Object.assign(v,m):l.push(m)}),l.filter(m=>!(m.id==="screenshot"&&!j||m.id==="pip"&&!y||m.id==="settings"&&!M||m.id==="fullscreen"&&!T||m.id==="fullscreenWeb"&&!f)).sort((m,v)=>m.index-v.index)},[u.controls,j,y,M,T,f]),et=l=>{var m,v,S,F,it;if(!l.isBuiltIn)return e.jsx("button",{onClick:()=>{l.click?l.click(n):l.onClick&&l.onClick(n)},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none flex items-center justify-center ${P} ${l.className||""}`,style:{borderRadius:"var(--radius)",...l.style},title:l.tooltip,children:e.jsx(ut,{content:l.html||""})},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 ${P}`,style:{borderRadius:"var(--radius)"},children:o.isPlaying?e.jsx(at,{className:`${L} fill-current`}):e.jsx(rt,{className:`${L} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&Pe(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&Pe(!1)},children:[e.jsx("button",{onClick:Pt,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ft,{className:L})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${Ke?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:be,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:Xe,onTouchStart:Xe,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)"}})]})}),Ke&&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 u.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-red-500/10 border border-red-500/20 rounded-md",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 tracking-wider",children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[we(ue?te:o.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",we(o.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:d=>{d.stopPropagation(),O(!R),E(!1)},className:`strata-control-btn transition-colors focus:outline-none ${P} ${R?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(ss,{className:L})}),$e.isMounted&&e.jsx(zs,{tracks:o.subtitleTracks,current:o.currentSubtitle,onSelect:d=>n==null?void 0:n.setSubtitle(d),onUpload:d=>n==null?void 0:n.addTextTrack(d,d.name),onClose:()=>O(!1),settings:o.subtitleSettings,onSettingsChange:d=>n==null?void 0:n.updateSubtitleSettings(d),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:o.subtitleOffset,onOffsetChange:d=>n==null?void 0:n.setSubtitleOffset(d),maxHeight:Je,animationClass:`strata-backdrop ${Ye} ${$e.isVisible?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-2 scale-95"}`})]},"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 ${P}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(gs,{className:L})},"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 ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(ts,{className:L})},"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 ${P}`,style:{borderRadius:"var(--radius)"},children:e.jsx(is,{className:L})},"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 hover:scale-110 focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},children:o.isFullscreen?e.jsx(Zt,{className:L}):e.jsx(Yt,{className:L})},"fs");case"fullscreenWeb":return e.jsx("button",{className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${P}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(ys,{className:L})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:d=>{d.stopPropagation(),E(!z),O(!1),N("main")},className:`strata-control-btn transition-all duration-300 focus:outline-none ${P} ${z?"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(es,{className:L})}),Le.isMounted&&e.jsx(pt,{onClose:()=>E(!1),align:"right",maxHeight:Je,className:`strata-backdrop ${Ye} ${Le.isVisible?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-2 scale-95"}`,children:e.jsxs("div",{className:"w-full",children:[I==="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.jsx(C,{label:"Source",value:((m=o.sources[o.currentSourceIndex])==null?void 0:m.name)||`Source ${o.currentSourceIndex+1}`,onClick:()=>N("sources"),hasSubmenu:!0}),e.jsx(C,{label:"Speed",value:`${o.playbackRate}x`,onClick:()=>N("speed"),hasSubmenu:!0}),e.jsx(C,{label:"Quality",value:o.currentQuality===-1?"Auto":`${(v=o.qualityLevels[o.currentQuality])==null?void 0:v.height}p`,onClick:()=>N("quality"),hasSubmenu:!0}),e.jsx(C,{label:"Audio",value:((S=o.audioTracks[o.currentAudioTrack])==null?void 0:S.label)||"Default",onClick:()=>N("audio"),hasSubmenu:!0}),bt&&e.jsx(C,{label:"Flip",value:o.flipState.horizontal?"H":o.flipState.vertical?"V":"Normal",onClick:()=>N("flip"),hasSubmenu:!0}),vt&&e.jsx(C,{label:"Aspect Ratio",value:o.aspectRatio,onClick:()=>N("ratio"),hasSubmenu:!0}),e.jsx(dt,{}),e.jsx(C,{label:"Audio Boost",value:o.audioGain>1?`${o.audioGain}x`:"Off",onClick:()=>N("boost"),hasSubmenu:!0}),e.jsx(C,{label:"Watch Party",icon:e.jsx(os,{className:"w-4 h-4"}),onClick:()=>N("party"),hasSubmenu:!0}),e.jsx(C,{label:"Cast to Device",icon:e.jsx(as,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),E(!1)}}),(F=u.settings)==null?void 0:F.map((d,_)=>d.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(q,{label:d.html,icon:d.icon,checked:d.switch,tooltip:d.tooltip,onChange:As=>{d.onSwitch&&d.onSwitch(d)}})},`cust-${_}`):e.jsx(C,{label:d.html,icon:d.icon,onClick:()=>{d.click?d.click():d.onClick&&d.onClick(),E(!1)}},`cust-${_}`)),e.jsx(dt,{}),e.jsx(C,{label:"Appearance",icon:e.jsx(ft,{className:"w-4 h-4"}),onClick:()=>N("appearance"),hasSubmenu:!0})]}),["speed","quality","audio","boost","party","appearance","sources","flip","ratio"].includes(I)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[I==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Select Source",onBack:()=>N("main")}),o.sources.map((d,_)=>e.jsx(C,{label:d.name||`Source ${_+1}`,value:d.type,active:o.currentSourceIndex===_,onClick:()=>n==null?void 0:n.switchSource(_)},_))]}),I==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Speed",onBack:()=>N("main")}),[.5,1,1.5,2].map(d=>e.jsx(C,{label:`${d}x`,active:o.playbackRate===d,onClick:()=>n.video.playbackRate=d},d))]}),I==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Quality",onBack:()=>N("main")}),e.jsx(C,{label:"Auto",active:o.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),o.qualityLevels.map(d=>e.jsx(C,{label:`${d.height}p`,value:`${Math.round(d.bitrate/1e3)}k`,active:o.currentQuality===d.index,onClick:()=>n==null?void 0:n.setQuality(d.index)},d.index))]}),I==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Audio Track",onBack:()=>N("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(d=>e.jsx(C,{label:d.label,value:d.language,active:o.currentAudioTrack===d.index,onClick:()=>n==null?void 0:n.setAudioTrack(d.index)},d.index))]}),I==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Audio Boost",onBack:()=>N("main")}),[1,1.5,2,3].map(d=>e.jsx(C,{label:d===1?"Off":`${d}x`,active:o.audioGain===d,onClick:()=>n==null?void 0:n.setAudioGain(d)},d))]}),I==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Video Flip",onBack:()=>N("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(q,{label:"Horizontal Flip",checked:o.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(q,{label:"Vertical Flip",checked:o.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),I==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Aspect Ratio",onBack:()=>N("main")}),["default","16:9","4:3"].map(d=>e.jsx(C,{label:d==="default"?"Default":d,active:o.aspectRatio===d,onClick:()=>n==null?void 0:n.setAspectRatio(d)},d))]}),I==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Watch Party",onBack:()=>N("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(((it=o.sources[o.currentSourceIndex])==null?void 0:it.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"})]})]}),I==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(A,{label:"Appearance",onBack:()=>N("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx(Q,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:$s.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 ${o.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(Q,{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 ${o.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(Q,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:Ls.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 ${o.themeColor===d.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:d.value,borderRadius:"var(--radius-full)"},children:o.themeColor===d.value&&e.jsx(Ce,{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:o.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:o.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},Ot=x.useMemo(()=>{const l=[{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(Cs,{className:"w-3.5 h-3.5"}),onClick:()=>Ie(!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: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"})]})})}),l},[u.contextmenu,o.aspectRatio,o.isLooping,n]);return e.jsxs("div",{id:u.id,ref:D,className:`group relative w-full h-full bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none rounded-[var(--radius)] text-zinc-100 strata-player-reset ${u.container||""}`,style:{touchAction:"manipulation","--accent":o.themeColor},onMouseMove:Ge,onMouseLeave:()=>{o.isPlaying&&!z&&!R&&n&&n.setControlsVisible(!1)},onMouseDown:_e,onMouseUp:ve,onTouchStart:zt,onTouchMove:Rt,onTouchEnd:It,onContextMenu:Et,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":o.theme,children:[e.jsx("style",{children:`
236
26
  [data-theme="default"] {
237
27
  --radius: 0.75rem;
238
28
  --radius-lg: 0.75rem;
@@ -325,5 +115,5 @@
325
115
  /* Override Backdrop for specific themes if needed */
326
116
  [data-theme="pixel"] .strata-backdrop { backdrop-filter: none; background: #000; }
327
117
  [data-theme="hacker"] .strata-backdrop { backdrop-filter: none; background: #000; }
328
- `}),a.theme==="hacker"&&e.jsx("div",{className:"strata-scanlines"}),!i&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-950 z-50",children:e.jsx(ke,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),i&&e.jsxs(e.Fragment,{children:[(tt=d.layers)==null?void 0:tt.map((l,f)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${l.className||""}`,style:l.style,children:e.jsx(ut,{content:l.html||"",className:"w-full h-full"})},f)),e.jsx(fi,{notifications:a.notifications}),e.jsx(pi,{cues:a.activeCues,settings:a.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-0",onClick:Et,"aria-hidden":"true"}),r&&!le&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none",style:{backgroundImage:`url(${r})`}}),Q.visible&&e.jsx(vi,{x:Q.x,y:Q.y,items:Ht,onClose:()=>de({...Q,visible:!1}),containerWidth:jt,containerHeight:Te}),Ct&&i&&e.jsx(gi,{player:i,onClose:()=>Ie(!1)}),fe&&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(ui,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),B&&a.controlsVisible&&e.jsx("button",{onClick:l=>{l.stopPropagation(),i.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 ${a.isLocked?"text-[var(--accent)] bg-white/10":"hover:bg-white/10"}`,children:a.isLocked?e.jsx(li,{className:"w-5 h-5"}):e.jsx(ci,{className:"w-5 h-5"})}),W&&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 ${W.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>ie(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[W.type==="rewind"?e.jsx(ot,{className:"w-12 h-12 animate-pulse"}):e.jsx(lt,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:W.type==="rewind"?"-10s":"+10s"})]})},W.id),a.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(ke,{className:"w-12 h-12 text-[var(--accent)] animate-spin drop-shadow-lg"})}),a.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:a.error}),e.jsx("button",{onClick:()=>i.load(i.store.get().sources[i.store.get().currentSourceIndex]||{url:t||""},b),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"})]})}),wt&&!a.isLocked&&(!a.isPlaying&&!a.isBuffering&&!a.error||a.controlsVisible)&&!a.isBuffering?e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-300 pointer-events-none ${a.controlsVisible||!a.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",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),ne("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all active:scale-110 text-white/90 focus:outline-none backdrop-blur-sm ${U.skipBtn}`,children:e.jsx(ot,{className:U.skipIcon})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),i.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 hover:scale-105 active:scale-110 duration-75 focus:outline-none backdrop-blur-md ${U.playBtn}`,children:a.isPlaying?e.jsx(at,{className:`${U.playIcon} text-white fill-current`}):e.jsx(rt,{className:`${U.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),ne("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all active:scale-110 text-white/90 focus:outline-none backdrop-blur-sm ${U.skipBtn}`,children:e.jsx(lt,{className:U.skipIcon})})]})}):null,e.jsxs("div",{className:`absolute inset-x-0 bottom-0 z-30 transition-all duration-300 px-4 md:px-6 pb-4 md:pb-6 pt-24 bg-gradient-to-t from-black/95 via-black/70 to-transparent ${Ot?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:l=>{l.target===l.currentTarget&&(E(!1),O(!1),se(!1)),l.stopPropagation()},children:[!d.isLive&&e.jsxs("div",{ref:xe,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:$t,onMouseLeave:()=>{Ve(null),Oe(null)},onMouseDown:_e,onTouchStart:_e,children:[(st=d.highlight)==null?void 0:st.map((l,f)=>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:`${l.time/a.duration*100}%`},title:l.text},f)),Be!==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, ${Mt}%, calc(100% - 70px))`},children:[H&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${H.w*.5}px`,height:`${H.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${H.url}")`,width:`${H.w}px`,height:`${H.h}px`,backgroundPosition:`-${H.x}px -${H.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:ye(Be)})]}),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:[a.duration>0&&a.buffered.map((l,f)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${l.start/a.duration*100}%`,width:`${(l.end-l.start)/a.duration*100}%`}},f)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(ue?te:a.currentTime)/a.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:`${(ue?te:a.currentTime)/a.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:Ze.filter(l=>l.position==="left"||l.position==="center").map(et)}),e.jsx("div",{className:"flex items-center gap-1",children:Ze.filter(l=>l.position==="right").map(et)})]})]})]})]})},ki=(o,t)=>{const s=Wt.createRoot(o);return s.render(m.createElement(je,t)),{unmount:()=>{s.unmount()},update:n=>{s.render(m.createElement(je,{...t,...n}))}}};exports.StrataCore=ft;exports.StrataPlayer=je;exports.mountStrataPlayer=ki;
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(ye,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),n&&e.jsxs(e.Fragment,{children:[(tt=u.layers)==null?void 0:tt.map((l,m)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${l.className||""}`,style:l.style,children:e.jsx(ut,{content:l.html||"",className:"w-full h-full"})},m)),e.jsx(Ns,{notifications:o.notifications}),e.jsx(Ms,{cues:o.activeCues,settings:o.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-0",onClick:$t,"aria-hidden":"true"}),a&&!le&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none",style:{backgroundImage:`url(${a})`}}),X.visible&&e.jsx(Rs,{x:X.x,y:X.y,items:Ot,onClose:()=>de({...X,visible:!1}),containerWidth:yt,containerHeight:ze}),St&&n&&e.jsx(Is,{player:n,onClose:()=>Ie(!1)}),xe&&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(ks,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),B&&o.controlsVisible&&e.jsx("button",{onClick:l=>{l.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(ws,{className:"w-5 h-5"}):e.jsx(js,{className:"w-5 h-5"})}),U&&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 ${U.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>ie(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[U.type==="rewind"?e.jsx(ot,{className:"w-12 h-12 animate-pulse"}):e.jsx(lt,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:U.type==="rewind"?"-10s":"+10s"})]})},U.id),o.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(ye,{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||""},b),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"})]})}),wt&&!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",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),ne("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all active:scale-110 text-white/90 focus:outline-none backdrop-blur-sm ${G.skipBtn}`,children:e.jsx(ot,{className:G.skipIcon})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),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 hover:scale-105 active:scale-110 duration-75 focus:outline-none backdrop-blur-md ${G.playBtn}`,children:o.isPlaying?e.jsx(at,{className:`${G.playIcon} text-white fill-current`}):e.jsx(rt,{className:`${G.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),E(!1),O(!1),ne("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all active:scale-110 text-white/90 focus:outline-none backdrop-blur-sm ${G.skipBtn}`,children:e.jsx(lt,{className:G.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 ${Vt?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:l=>{l.target===l.currentTarget&&(E(!1),O(!1),se(!1)),l.stopPropagation()},children:[!u.isLive&&e.jsxs("div",{ref:pe,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:Lt,onMouseLeave:()=>{Ve(null),Oe(null)},onMouseDown:qe,onTouchStart:qe,children:[(st=u.highlight)==null?void 0:st.map((l,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:`${l.time/o.duration*100}%`},title:l.text},m)),Be!==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, ${Mt}%, calc(100% - 70px))`},children:[H&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${H.w*.5}px`,height:`${H.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${H.url}")`,width:`${H.w}px`,height:`${H.h}px`,backgroundPosition:`-${H.x}px -${H.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:we(Be)})]}),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((l,m)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${l.start/o.duration*100}%`,width:`${(l.end-l.start)/o.duration*100}%`}},m)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(ue?te: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:`${(ue?te: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:Ze.filter(l=>l.position==="left"||l.position==="center").map(et)}),e.jsx("div",{className:"flex items-center gap-1",children:Ze.filter(l=>l.position==="right").map(et)})]})]})]})]})},Es=(i,t)=>{const s=Dt.createRoot(i);return s.render(x.createElement(ke,t)),{unmount:()=>{s.unmount()},update:r=>{s.render(x.createElement(ke,{...t,...r}))}}};exports.StrataCore=xt;exports.StrataPlayer=ke;exports.mountStrataPlayer=Es;
329
119
  //# sourceMappingURL=strataplayer.cjs.js.map