strataplayer 1.2.20 → 1.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/core/StrataCore.d.ts +9 -2
- package/dist/strataplayer.cjs.js +16 -12
- package/dist/strataplayer.cjs.js.map +1 -1
- package/dist/strataplayer.es.js +1266 -1169
- package/dist/strataplayer.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/ui/Icons.d.ts +6 -0
- package/package.json +1 -1
package/dist/strataplayer.cjs.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),u=[];let d=null,f=null;const b=i.substring(0,i.lastIndexOf("/")+1),v=h=>{const w=h.split(":");let p=0;return w.length===3?(p+=parseFloat(w[0])*3600,p+=parseFloat(w[1])*60,p+=parseFloat(w[2])):(p+=parseFloat(w[0])*60,p+=parseFloat(w[1])),p};for(let h of r)if(h=h.trim(),h.includes("-->")){const w=h.split("-->");d=v(w[0].trim()),f=v(w[1].trim())}else if(d!==null&&f!==null&&h.length>0){let[w,p]=h.split("#");!w.match(/^https?:\/\//)&&!w.startsWith("data:")&&(w=b+w);let N=0,T=0,V=0,X=0;if(p&&p.startsWith("xywh=")){const O=p.replace("xywh=","").split(",");O.length===4&&(N=parseInt(O[0]),T=parseInt(O[1]),V=parseInt(O[2]),X=parseInt(O[3]))}V>0&&X>0&&u.push({start:d,end:f,url:w,x:N,y:T,w:V,h:X}),d=null,f=null}return u}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},xs=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const i=document.createElement("link");i.rel="preconnect",i.href="https://fonts.googleapis.com",document.head.appendChild(i);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const s=document.createElement("link");s.id="strata-fonts",s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(s)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const i=document.createElement("script");i.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(i)}}},Xe={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},Lt="strata-settings",K={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:Xe,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",isAutoSized:!1,isLooping:!1,controlsVisible:!0},$t=(i={})=>{let t={};if(!i.disablePersistence&&typeof window<"u")try{const o=localStorage.getItem(Lt);o&&(t=JSON.parse(o))}catch{}const s={...Xe,...t.subtitleSettings||{},...i.subtitleSettings||{}};return{...K,...t,volume:i.volume??t.volume??K.volume,isMuted:i.muted??t.isMuted??K.isMuted,playbackRate:i.playbackRate??t.playbackRate??K.playbackRate,audioGain:i.audioGain??t.audioGain??K.audioGain,theme:i.theme??t.theme??K.theme,themeColor:i.themeColor??t.themeColor??K.themeColor,iconSize:i.iconSize??t.iconSize??K.iconSize,subtitleSettings:s,isAutoSized:i.autoSize??K.isAutoSized,isLive:i.isLive??t.isLive??K.isLive,isLooping:i.loop??t.isLooping??K.isLooping,sourceStatuses:{}}};class Et{constructor(t={},s){z(this,"video");z(this,"container",null);z(this,"events");z(this,"store");z(this,"plugins",new Map);z(this,"audioEngine");z(this,"config");z(this,"resizeObserver",null);z(this,"retryCount",0);z(this,"maxRetries",5);z(this,"retryTimer",null);z(this,"currentSource",null);z(this,"currentSrc","");z(this,"trackConfigs",[]);z(this,"currentDownloadController",null);z(this,"castInitialized",!1);z(this,"boundCueChange");z(this,"boundFullscreenChange");xs(),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 us;const o=$t(t);this.store=new hs(o),this.audioEngine=new ps(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 d=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(d).catch(()=>{})}catch{}}else!r&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=o.volume,this.video.muted=o.isMuted,this.video.playbackRate=o.playbackRate,this.video.loop=o.isLooping,o.audioGain>1&&this.audioEngine.setGain(o.audioGain),o.isAutoSized&&(this.video.style.objectFit="cover"),this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(r=>{const u={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(Lt,JSON.stringify(u))})}get playing(){return!this.video.paused&&!this.video.ended&&this.video.readyState>2}get currentTime(){return this.video.currentTime}set currentTime(t){this.seek(t)}get duration(){return this.video.duration||0}get paused(){return this.video.paused}get volume(){return this.video.volume}set volume(t){this.setVolume(t)}get muted(){return this.video.muted}set muted(t){this.video.muted=t,this.store.setState({isMuted:t})}get playbackRate(){return this.video.playbackRate}set playbackRate(t){this.video.playbackRate=t}get loop(){return this.video.loop}set loop(t){this.video.loop=t,this.store.setState({isLooping:t})}forward(t=10){this.skip(t)}backward(t=10){this.skip(-t)}on(t,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=o=>this.store.setState(o);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(o=>{this.video.addEventListener(o,r=>{switch(this.emit(`video:${o}`,r),o==="play"&&this.emit("play"),o==="pause"&&this.emit("pause"),o==="ended"&&this.emit("ended"),o==="error"&&this.emit("error",this.video.error),o==="seeked"&&this.emit("seek"),o){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),document.addEventListener("fullscreenchange",this.boundFullscreenChange)}updateSourceStatus(t){const s=this.store.get().currentSourceIndex;s!==-1&&this.store.setState(o=>({sourceStatuses:{...o.sourceStatuses,[s]:t}}))}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,o=this.store.get().sources.length;s<o-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var o,r;if(!("mediaSession"in navigator))return;const t=((o=this.currentSource)==null?void 0:o.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,o=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:o,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,o=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: ${o}.
|
|
3
|
-
Retrying (${this.retryCount}/${this.maxRetries})`}),console.warn(`[StrataPlayer] Error: ${o}. Retrying in ${
|
|
1
|
+
"use strict";var ps=Object.defineProperty;var bs=(i,t,s)=>t in i?ps(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var P=(i,t,s)=>bs(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),gs=require("react-dom/client"),e=require("react/jsx-runtime"),vs=require("react-dom");class ws{constructor(){P(this,"events");this.events=new Map}on(t,s){var o;return this.events.has(t)||this.events.set(t,[]),(o=this.events.get(t))==null||o.push(s),()=>this.off(t,s)}off(t,s){const o=this.events.get(t);o&&this.events.set(t,o.filter(a=>a!==s))}emit(t,s){const o=this.events.get(t);o&&o.forEach(a=>a(s))}destroy(){this.events.clear()}}class js{constructor(t){P(this,"state");P(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const s=this.state,o=typeof t=="function"?t(s):t;this.state={...s,...o},this.listeners.forEach(a=>a(this.state,s))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class ys{constructor(t){P(this,"context",null);P(this,"source",null);P(this,"gainNode",null);P(this,"video");P(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 Xe=i=>{if(isNaN(i))return"00:00";const t=Math.floor(i/3600),s=Math.floor(i%3600/60),o=Math.floor(i%60);return t>0?`${t}:${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${s}:${o.toString().padStart(2,"0")}`},ks=async(i,t=3,s=2e4)=>{for(let o=0;o<t;o++){const a=new AbortController,d=setTimeout(()=>a.abort(),s);try{const u=await fetch(i,{signal:a.signal});if(clearTimeout(d),!u.ok)throw new Error(`HTTP ${u.status}`);return await u.text()}catch(u){if(clearTimeout(d),o===t-1)throw u;await new Promise(x=>setTimeout(x,1e3))}}throw new Error("Failed")},Ss=async(i,t,s=2e4)=>{try{const a=(await ks(i,3,s)).split(`
|
|
2
|
+
`),d=[];let u=null,x=null;const v=i.substring(0,i.lastIndexOf("/")+1),p=h=>{const g=h.split(":");let f=0;return g.length===3?(f+=parseFloat(g[0])*3600,f+=parseFloat(g[1])*60,f+=parseFloat(g[2])):(f+=parseFloat(g[0])*60,f+=parseFloat(g[1])),f};for(let h of a)if(h=h.trim(),h.includes("-->")){const g=h.split("-->");u=p(g[0].trim()),x=p(g[1].trim())}else if(u!==null&&x!==null&&h.length>0){let[g,f]=h.split("#");!g.match(/^https?:\/\//)&&!g.startsWith("data:")&&(g=v+g);let k=0,F=0,H=0,D=0;if(f&&f.startsWith("xywh=")){const G=f.replace("xywh=","").split(",");G.length===4&&(k=parseInt(G[0]),F=parseInt(G[1]),H=parseInt(G[2]),D=parseInt(G[3]))}H>0&&D>0&&d.push({start:u,end:x,url:g,x:k,y:F,w:H,h:D}),u=null,x=null}return d}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},Cs=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const i=document.createElement("link");i.rel="preconnect",i.href="https://fonts.googleapis.com",document.head.appendChild(i);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const s=document.createElement("link");s.id="strata-fonts",s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(s)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const i=document.createElement("script");i.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(i)}}},et={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},Wt="strata-settings",Q={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:et,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",videoFit:"contain",brightness:1,isAutoSized:!1,isLooping:!1,controlsVisible:!0},Ut=(i={})=>{let t={};if(!i.disablePersistence&&typeof window<"u")try{const a=localStorage.getItem(Wt);a&&(t=JSON.parse(a))}catch{}const s={...et,...t.subtitleSettings||{},...i.subtitleSettings||{}},o=i.videoFit??(i.autoSize?"cover":void 0)??t.videoFit??Q.videoFit;return{...Q,...t,volume:i.volume??t.volume??Q.volume,isMuted:i.muted??t.isMuted??Q.isMuted,playbackRate:i.playbackRate??t.playbackRate??Q.playbackRate,audioGain:i.audioGain??t.audioGain??Q.audioGain,theme:i.theme??t.theme??Q.theme,themeColor:i.themeColor??t.themeColor??Q.themeColor,iconSize:i.iconSize??t.iconSize??Q.iconSize,subtitleSettings:s,isAutoSized:i.autoSize??Q.isAutoSized,videoFit:o,brightness:i.brightness??t.brightness??Q.brightness,isLive:i.isLive??t.isLive??Q.isLive,isLooping:i.loop??t.isLooping??Q.isLooping,sourceStatuses:{}}};class Gt{constructor(t={},s){P(this,"video");P(this,"container",null);P(this,"events");P(this,"store");P(this,"plugins",new Map);P(this,"audioEngine");P(this,"config");P(this,"resizeObserver",null);P(this,"retryCount",0);P(this,"maxRetries",5);P(this,"retryTimer",null);P(this,"currentSource",null);P(this,"currentSrc","");P(this,"trackConfigs",[]);P(this,"activeDownloads",new Map);P(this,"castInitialized",!1);P(this,"boundCueChange");P(this,"boundFullscreenChange");Cs(),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",this.video.preload="auto",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new ws;const o=Ut(t);this.store=new js(o),this.audioEngine=new ys(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 u=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(u).catch(()=>{})}catch{}}else!a&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=o.volume,this.video.muted=o.isMuted,this.video.playbackRate=o.playbackRate,this.video.loop=o.isLooping,this.video.style.filter=`brightness(${o.brightness})`,o.audioGain>1&&this.audioEngine.setGain(o.audioGain),this.video.style.objectFit=o.videoFit,this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(a=>{const d={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,brightness:a.brightness,videoFit:a.videoFit};localStorage.setItem(Wt,JSON.stringify(d))})}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=o=>this.store.setState(o);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(o=>{this.video.addEventListener(o,a=>{switch(this.emit(`video:${o}`,a),o==="play"&&this.emit("play"),o==="pause"&&this.emit("pause"),o==="ended"&&this.emit("ended"),o==="error"&&this.emit("error",this.video.error),o==="seeked"&&this.emit("seek"),o){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),document.addEventListener("fullscreenchange",this.boundFullscreenChange)}updateSourceStatus(t){const s=this.store.get().currentSourceIndex;s!==-1&&this.store.setState(o=>({sourceStatuses:{...o.sourceStatuses,[s]:t}}))}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,o=this.store.get().sources.length;s<o-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var o,a;if(!("mediaSession"in navigator))return;const t=((o=this.currentSource)==null?void 0:o.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,o=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:o,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,o=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: ${o}.
|
|
3
|
+
Retrying (${this.retryCount}/${this.maxRetries})`}),console.warn(`[StrataPlayer] Error: ${o}. Retrying in ${a}ms...`),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.currentSource){this.load(this.currentSource,this.trackConfigs,!0);const d=this.store.get().currentTime;if(d>0){const u=()=>{this.video.currentTime=d,this.video.removeEventListener("canplay",u)};this.video.addEventListener("canplay",u)}}},a)}else{this.removeNotification("retry");const a=`Failed to play after ${this.maxRetries} attempts: ${o}`;this.store.setState({error:a}),this.emit("error",a),this.updateSourceStatus("error")}}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})}updateSubtitleTrackState(t,s){this.store.setState(o=>{const a=[...o.subtitleTracks];return a[t]&&(a[t]={...a[t],...s}),{subtitleTracks:a}})}async fetchWithRetry(t,s=3,o,a){const d=o??this.config.fetchTimeout??3e4;for(let u=0;u<s;u++){const x=a?null:new AbortController,v=a||(x==null?void 0:x.signal),p=setTimeout(()=>x==null?void 0:x.abort(),d);try{const h=await fetch(t,{signal:v});if(clearTimeout(p),!h.ok)throw new Error(`HTTP ${h.status}`);return h}catch(h){if(clearTimeout(p),a!=null&&a.aborted)throw new Error("Aborted");if(u===s-1)throw h;if(h.name==="AbortError"){if(a!=null&&a.aborted)throw h;console.warn(`Fetch timeout (${d}ms) for ${t}`)}await new Promise(g=>setTimeout(g,1e3*Math.pow(2,u)))}}throw new Error("Fetch failed")}convertToVTT(t){let s=t.trim();if(!s.startsWith("WEBVTT")){let o=s.replace(/(\d+:\d{2}:\d{2}),(\d{3})/g,"$1.$2");return o=o.replace(/(\d{2}:\d{2}),(\d{3})/g,"$1.$2"),`WEBVTT
|
|
4
4
|
|
|
5
|
-
`+o}return s}formatDuration(t){if(!isFinite(t)||t<=0)return"";const s=Math.floor(t/1e3),o=Math.floor(s/(3600*24)),r=Math.floor(s%(3600*24)/3600),u=Math.floor(s%3600/60),d=s%60,f=[];return o>0&&f.push(`${o}d`),r>0&&f.push(`${r}h`),u>0&&f.push(`${u}m`),f.push(`${d}s`),f.join(" ")}attach(t){this.resizeObserver&&this.resizeObserver.disconnect(),this.container=t,this.container.appendChild(this.video),this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().isAutoSized?"cover":"contain",this.video.style.backgroundColor="black",this.updateAspectRatio(),this.resizeObserver=new ResizeObserver(s=>{for(const o of s)this.emit("resize",{width:o.contentRect.width,height:o.contentRect.height}),this.updateAspectRatio()}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,s=[]){this.store.setState({sources:t}),this.trackConfigs=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const o=this.video.currentTime,r=!this.video.paused;this.load(s[t],this.trackConfigs);const u=()=>{this.video.currentTime=o,r&&this.video.play(),this.video.removeEventListener("canplay",u)};this.video.addEventListener("canplay",u)}}load(t,s=[],o=!1){this.retryTimer&&clearTimeout(this.retryTimer);const r=typeof t=="string"?{url:t,type:"auto"}:t;o||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=r.url,this.currentSource=r,this.trackConfigs=s;const d=this.store.get().sources.findIndex(w=>w.url===r.url),f=s.map((w,p)=>({...w,index:p,status:"idle",isDefault:!!w.default}));this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:f,currentSubtitle:-1,currentSourceIndex:d}),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 v=this.video.getElementsByTagName("track");for(;v.length>0;)v[0].remove();const h=f.findIndex(w=>w.default);h!==-1&&this.setSubtitle(h),(b==="mp4"||b==="webm"||b==="ogg")&&(this.video.src=r.url)}loadSubtitle(t,s="Subtitle"){const o=this.store.get().subtitleTracks.length,r={src:t,label:s,srcLang:"user",default:!0,kind:"subtitles",index:o,status:"idle",isDefault:!0};this.store.setState(u=>({subtitleTracks:[...u.subtitleTracks,r]})),this.setSubtitle(o)}addTextTrack(t,s){const o=new FileReader;o.onload=r=>{var b;if(!((b=r.target)!=null&&b.result))return;let u=r.target.result;u=this.convertToVTT(u);const d=new Blob([u],{type:"text/vtt"}),f=URL.createObjectURL(d);this.loadSubtitle(f,s),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3})},o.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},o.readAsText(t)}addTextTrackInternal(t,s,o="",r=!1){const u=document.createElement("track");u.kind="subtitles",u.label=s,u.src=t,u.srclang=o,r&&(u.default=!0),this.video.appendChild(u)}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){if(document.fullscreenElement){await document.exitFullscreen().catch(()=>{});return}if(this.store.get().isWebFullscreen){this.toggleWebFullscreen();return}try{await this.container.requestFullscreen()}catch(t){console.warn("Native fullscreen failed, falling back to Web Fullscreen",t),this.toggleWebFullscreen()}}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen;document.fullscreenElement&&document.exitFullscreen().catch(()=>{});const s=!t;this.store.setState({isWebFullscreen:s}),typeof document<"u"&&(document.body.style.overflow=s?"hidden":""),this.emit("webfullscreen",s)}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 o=t.toDataURL("image/png"),r=document.createElement("a");r.download=`screenshot-${new Date().toISOString()}.png`,r.href=o,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,o={...s,[t]:!s[t]};this.store.setState({flipState:o});const r=o.horizontal?-1:1,u=o.vertical?-1:1;this.video.style.transform=`scale(${r}, ${u})`}setAspectRatio(t){this.store.setState({aspectRatio:t}),this.updateAspectRatio(),t!=="default"&&this.notify({type:"info",message:`Aspect Ratio: ${t}`,duration:2e3})}updateAspectRatio(){if(!this.container)return;const{aspectRatio:t,isAutoSized:s}=this.store.get();if(t==="default"){this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=s?"cover":"contain";return}const[o,r]=t.split(":").map(Number);if(!o||!r)return;const u=o/r,d=this.container.getBoundingClientRect();if(d.width===0||d.height===0)return;const f=d.width/d.height;let b,v;f>u?(v=d.height,b=v*u):(b=d.width,v=b/u),this.video.style.width=`${b}px`,this.video.style.height=`${v}px`,this.video.style.objectFit="fill"}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(o){console.warn("Cast Init Error or already initialized",o)}};t.cast&&t.cast.framework?s():t.__onGCastApiAvailable=o=>{o&&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 o=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),r=new t.chrome.cast.media.LoadRequest(o);s.loadMedia(r).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(u=>console.error("Cast load error",u))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){if(this.store.get().currentSubtitle===-1){this.store.setState({activeCues:[]});return}const o=Array.from(this.video.textTracks).filter(r=>r.kind==="subtitles"||r.kind==="captions").find(r=>r.mode==="showing"||r.mode==="hidden");if(o&&o.activeCues){const r=Array.from(o.activeCues).map(u=>u.text);this.store.setState({activeCues:r})}else this.store.setState({activeCues:[]})}async setSubtitle(t){const o=this.store.get().subtitleTracks[t];if(Array.from(this.video.textTracks).forEach(d=>{d.removeEventListener("cuechange",this.boundCueChange),d.mode="disabled"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t===-1||!o)return;if(o.status==="idle"||o.status==="error"){this.updateSubtitleTrackState(t,{status:"loading"});try{let f=await(await this.fetchWithRetry(o.src)).text();f=this.convertToVTT(f);const b=new Blob([f],{type:"text/vtt"}),v=URL.createObjectURL(b);this.addTextTrackInternal(v,o.label,o.srcLang,!1),this.updateSubtitleTrackState(t,{status:"success"})}catch(d){this.updateSubtitleTrackState(t,{status:"error"}),console.error("Failed to load subtitle",d);return}}const r=Array.from(this.video.textTracks);let u=r.find(d=>d.label===o.label&&d.language===o.srcLang);if(u||(u=r.find(d=>d.label===o.label)),u){const d=this.store.get().subtitleSettings;u.mode=d.useNative?"showing":"hidden",u.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}updateSubtitleSettings(t){const o={...this.store.get().subtitleSettings,...t};if(this.store.setState({subtitleSettings:o}),t.useNative!==void 0){const r=this.store.get().currentSubtitle;if(r!==-1){const d=this.store.get().subtitleTracks[r],f=Array.from(this.video.textTracks).find(b=>b.label===d.label&&b.language===d.srcLang);f&&(f.mode=t.useNative?"showing":"hidden")}}}resetSubtitleSettings(){this.store.setState({subtitleSettings:Xe}),this.updateSubtitleSettings({useNative:!1})}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,o=t-s;Math.abs(o)<.001||(Array.from(this.video.textTracks).forEach(r=>{(r.mode==="showing"||r.mode==="hidden")&&r.cues&&Array.from(r.cues).forEach(u=>{u.startTime+=o,u.endTime+=o})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}cancelDownload(){this.currentDownloadController&&(this.currentDownloadController.abort(),this.currentDownloadController=null,this.notify({type:"info",message:"Download cancelled",duration:2e3}))}async download(t={}){var u,d,f;const s=((u=this.currentSource)==null?void 0:u.url)||this.video.src;if(!s)return;if(s.includes(".m3u8")||((d=this.currentSource)==null?void 0:d.type)==="hls"){this.downloadHls(s,t.format||"ts");return}if(s.startsWith("blob:")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}this.currentDownloadController&&this.currentDownloadController.abort(),this.currentDownloadController=new AbortController;const o=this.currentDownloadController.signal,r=this.notify({type:"loading",message:"Preparing download",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload()}});try{const b=await this.fetchWithRetry(s,3,void 0,o);if(!b.body)throw new Error("No body");const v=b.body.getReader(),h=b.headers.get("Content-Length"),w=h?parseInt(h,10):0;let p=0;const N=[],T=Date.now(),V=[];for(;;){const{done:D,value:y}=await v.read();if(D)break;if(N.push(y),p+=y.length,w){const U=Date.now(),P=Math.round(p/w*100);for(V.push({time:U,loaded:p});V.length>0&&U-V[0].time>5e3;)V.shift();let H="",Q=0;if(V.length>1){const R=V[0],n=V[V.length-1],Y=n.time-R.time,Z=n.loaded-R.loaded;Y>0&&(Q=Z/Y)}else{const R=U-T;R>0&&(Q=p/R)}if(Q>0){const n=(w-p)/Q;H=`
|
|
6
|
-
${this.formatDuration(
|
|
7
|
-
`);let
|
|
8
|
-
`),
|
|
9
|
-
${this.formatDuration(
|
|
10
|
-
${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`Downloading segment ${y+1}/${h.length}${H}`,progress:U,action:{label:"Cancel",onClick:()=>this.cancelDownload()}});const R=await(await this.fetchWithRetry(h[y],3,void 0,o)).arrayBuffer();y===0&&new Uint8Array(R.slice(0,4))[0]===71&&(O=!0,s==="mp4"&&(this.notify({type:"info",message:"Stream is MPEG-TS. Downloading as .ts to prevent corruption.",duration:5e3}),w="ts",p="video/mp2t"));const n=new Blob([R]);T?await T.write(n):V.push(n)}if(o.aborted)throw T&&await T.abort(),new Error("Aborted");if(T)await T.close(),this.notify({id:r,type:"success",message:"Download complete!",duration:3e3});else{this.notify({id:r,type:"loading",message:"Stitching video",progress:100});const y=new Blob(V,{type:p}),U=window.URL.createObjectURL(y),P=document.createElement("a");P.style.display="none",P.href=U;const H=s==="mp4"&&O?"ts":w;P.download=`video.${H}`,document.body.appendChild(P),P.click(),window.URL.revokeObjectURL(U),document.body.removeChild(P),this.notify({id:r,type:"success",message:"Saved!",duration:3e3})}}catch(d){o.aborted?this.removeNotification(r):this.notify({id:r,type:"error",message:`Download failed: ${d.message}`,duration:4e3})}finally{this.currentDownloadController=null}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),o={...t,id:s};return this.store.setState(r=>r.notifications.find(d=>d.id===s)?{notifications:r.notifications.map(d=>d.id===s?o:d)}:{notifications:[...r.notifications,o]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(o=>o.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.currentDownloadController&&this.currentDownloadController.abort(),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),document.removeEventListener("fullscreenchange",this.boundFullscreenChange),this.video.pause(),this.video.src="";const t=this.video.getElementsByTagName("track");for(;t.length>0;)t[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(s=>s.destroy&&s.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const We=(i,t=200)=>{const[s,o]=m.useState(i),[r,u]=m.useState(!1);return m.useEffect(()=>{if(i)o(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{u(!0)})});else{u(!1);const d=setTimeout(()=>{o(!1)},t);return()=>clearTimeout(d)}},[i,t]),{isMounted:s,isVisible:r}},j=({className:i,children:t,fill:s="none",strokeWidth:o=2,viewBox:r="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:r,fill:s,stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",className:i,children:t}),Mt=({className:i})=>e.jsx(j,{className:i,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),Tt=({className:i})=>e.jsxs(j,{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"})]}),bs=({className:i})=>e.jsxs(j,{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"})]}),gs=({className:i})=>e.jsxs(j,{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"})]}),vs=({className:i})=>e.jsxs(j,{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"})]}),ws=({className:i})=>e.jsxs(j,{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"})]}),js=({className:i})=>e.jsxs(j,{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"})]}),ys=({className:i})=>e.jsxs(j,{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"})]}),ze=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),ks=({className:i})=>e.jsxs(j,{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(j,{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"})]}),Ge=({className:i})=>e.jsxs(j,{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"})]}),Cs=({className:i})=>e.jsxs(j,{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"})]}),Ns=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Me=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Ms=({className:i})=>e.jsxs(j,{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"})]}),Ts=({className:i})=>e.jsxs(j,{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"})]}),zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),Rs=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M5 12h14"})}),Is=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),Ft=({className:i})=>e.jsxs(j,{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"})]}),Ps=({className:i})=>e.jsxs(j,{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"})]}),At=({className:i})=>e.jsxs(j,{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"})]}),Ls=({className:i})=>e.jsxs(j,{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"})]}),$s=({className:i})=>e.jsxs(j,{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"})]}),Es=({className:i})=>e.jsxs(j,{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"})]}),Fs=({className:i})=>e.jsxs(j,{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"})]}),As=({className:i})=>e.jsxs(j,{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"})]}),Bs=({className:i})=>e.jsx(j,{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"})}),Vs=({className:i})=>e.jsxs(j,{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"})]}),Ds=({className:i})=>e.jsxs(j,{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"})]}),Os=({className:i})=>e.jsxs(j,{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"})]}),Hs=({className:i})=>e.jsxs(j,{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"})]}),Ws=({className:i})=>e.jsxs(j,{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"})]}),Bt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Us=({className:i})=>e.jsxs(j,{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"})]}),Gs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),qs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),_s=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),Xs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),Qs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),Js=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),qe=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),Ks=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 20h.01"}),e.jsx("path",{d:"M7 20v-4"}),e.jsx("path",{d:"M12 20v-8"}),e.jsx("path",{d:"M17 20V8"}),e.jsx("path",{d:"M22 20V4"})]}),Ys=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 7v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 12h18"})]}),Zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),Vt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"m9 15 2 2 4-4"})]}),ei=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M12 12v4"})]}),zt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{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"})]}),Rt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{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"})]}),ti=({notifications:i})=>e.jsx("div",{className:"absolute top-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[280px]",children:i.map(t=>{const s=typeof t.progress=="number";return e.jsx("div",{className:`
|
|
5
|
+
`+o}return s}formatDuration(t){if(!isFinite(t)||t<=0)return"";const s=Math.floor(t/1e3),o=Math.floor(s/(3600*24)),a=Math.floor(s%(3600*24)/3600),d=Math.floor(s%3600/60),u=s%60,x=[];return o>0&&x.push(`${o}d`),a>0&&x.push(`${a}h`),d>0&&x.push(`${d}m`),x.push(`${u}s`),x.join(" ")}attach(t){this.resizeObserver&&this.resizeObserver.disconnect(),this.container=t,this.container.appendChild(this.video),this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().videoFit,this.video.style.backgroundColor="black",this.updateAspectRatio(),this.resizeObserver=new ResizeObserver(s=>{for(const o of s)this.emit("resize",{width:o.contentRect.width,height:o.contentRect.height}),this.updateAspectRatio()}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,s=[]){this.store.setState({sources:t}),this.trackConfigs=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const o=this.video.currentTime,a=!this.video.paused;this.load(s[t],this.trackConfigs);const d=()=>{this.video.currentTime=o,a&&this.video.play(),this.video.removeEventListener("canplay",d)};this.video.addEventListener("canplay",d)}}load(t,s=[],o=!1){this.retryTimer&&clearTimeout(this.retryTimer);const a=typeof t=="string"?{url:t,type:"auto"}:t;o||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=a.url,this.currentSource=a,this.trackConfigs=s;const u=this.store.get().sources.findIndex(g=>g.url===a.url),x=s.map((g,f)=>({...g,index:f,status:"idle",isDefault:!!g.default}));this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:x,currentSubtitle:-1,currentSourceIndex:u}),this.updateMediaSessionMetadata();let v=a.type||"auto";v==="auto"&&(a.url.includes(".m3u8")?v="hls":a.url.includes(".mpd")?v="dash":a.url.includes(".flv")||a.url.includes(".ts")?v="mpegts":a.url.startsWith("magnet:")||a.url.includes(".torrent")?v="webtorrent":v="mp4"),this.events.emit("load",{url:a.url,type:v});const p=this.video.getElementsByTagName("track");for(;p.length>0;)p[0].remove();const h=x.findIndex(g=>g.default);h!==-1&&this.setSubtitle(h),(v==="mp4"||v==="webm"||v==="ogg")&&(this.video.src=a.url)}loadSubtitle(t,s="Subtitle"){const o=this.store.get().subtitleTracks.length,a={src:t,label:s,srcLang:"user",default:!0,kind:"subtitles",index:o,status:"idle",isDefault:!0};this.store.setState(d=>({subtitleTracks:[...d.subtitleTracks,a]})),this.setSubtitle(o)}addTextTrack(t,s){const o=new FileReader;o.onload=a=>{var v;if(!((v=a.target)!=null&&v.result))return;let d=a.target.result;d=this.convertToVTT(d);const u=new Blob([d],{type:"text/vtt"}),x=URL.createObjectURL(u);this.loadSubtitle(x,s),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3})},o.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},o.readAsText(t)}addTextTrackInternal(t,s,o="",a=!1){const d=document.createElement("track");d.kind="subtitles",d.label=s,d.src=t,d.srclang=o,a&&(d.default=!0),this.video.appendChild(d)}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){if(document.fullscreenElement){await document.exitFullscreen().catch(()=>{});return}if(this.store.get().isWebFullscreen){this.toggleWebFullscreen();return}try{await this.container.requestFullscreen()}catch(t){console.warn("Native fullscreen failed, falling back to Web Fullscreen",t),this.toggleWebFullscreen()}}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen;document.fullscreenElement&&document.exitFullscreen().catch(()=>{});const s=!t;this.store.setState({isWebFullscreen:s}),typeof document<"u"&&(document.body.style.overflow=s?"hidden":""),this.emit("webfullscreen",s)}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 o=t.toDataURL("image/png"),a=document.createElement("a");a.download=`screenshot-${new Date().toISOString()}.png`,a.href=o,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,o={...s,[t]:!s[t]};this.store.setState({flipState:o});const a=o.horizontal?-1:1,d=o.vertical?-1:1;this.video.style.transform=`scale(${a}, ${d})`}setAspectRatio(t){this.store.setState({aspectRatio:t}),this.updateAspectRatio(),t!=="default"&&this.notify({type:"info",message:`Aspect Ratio: ${t}`,duration:2e3})}setVideoFit(t){this.store.setState({videoFit:t}),this.video.style.objectFit=t,this.updateAspectRatio()}setBrightness(t){const s=Math.max(0,Math.min(t,2));this.store.setState({brightness:s}),this.video.style.filter=`brightness(${s})`}updateAspectRatio(){if(!this.container)return;const{aspectRatio:t,videoFit:s}=this.store.get();if(t==="default"){this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=s;return}const[o,a]=t.split(":").map(Number);if(!o||!a)return;const d=o/a,u=this.container.getBoundingClientRect();if(u.width===0||u.height===0)return;const x=u.width/u.height;let v,p;x>d?(p=u.height,v=p*d):(v=u.width,p=v/d),this.video.style.width=`${v}px`,this.video.style.height=`${p}px`,this.video.style.objectFit="fill"}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(o){console.warn("Cast Init Error or already initialized",o)}};t.cast&&t.cast.framework?s():t.__onGCastApiAvailable=o=>{o&&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 o=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),a=new t.chrome.cast.media.LoadRequest(o);s.loadMedia(a).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(d=>console.error("Cast load error",d))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){if(this.store.get().currentSubtitle===-1){this.store.setState({activeCues:[]});return}const o=Array.from(this.video.textTracks).filter(a=>a.kind==="subtitles"||a.kind==="captions").find(a=>a.mode==="showing"||a.mode==="hidden");if(o&&o.activeCues){const a=Array.from(o.activeCues).map(d=>d.text);this.store.setState({activeCues:a})}else this.store.setState({activeCues:[]})}async setSubtitle(t){const o=this.store.get().subtitleTracks[t];if(Array.from(this.video.textTracks).forEach(u=>{u.removeEventListener("cuechange",this.boundCueChange),u.mode="disabled"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t===-1||!o)return;if(o.status==="idle"||o.status==="error"){this.updateSubtitleTrackState(t,{status:"loading"});try{let x=await(await this.fetchWithRetry(o.src)).text();x=this.convertToVTT(x);const v=new Blob([x],{type:"text/vtt"}),p=URL.createObjectURL(v);this.addTextTrackInternal(p,o.label,o.srcLang,!1),this.updateSubtitleTrackState(t,{status:"success"})}catch(u){this.updateSubtitleTrackState(t,{status:"error"}),console.error("Failed to load subtitle",u);return}}const a=Array.from(this.video.textTracks);let d=a.find(u=>u.label===o.label&&u.language===o.srcLang);if(d||(d=a.find(u=>u.label===o.label)),d){const u=this.store.get().subtitleSettings;d.mode=u.useNative?"showing":"hidden",d.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}updateSubtitleSettings(t){const o={...this.store.get().subtitleSettings,...t};if(this.store.setState({subtitleSettings:o}),t.useNative!==void 0){const a=this.store.get().currentSubtitle;if(a!==-1){const u=this.store.get().subtitleTracks[a],x=Array.from(this.video.textTracks).find(v=>v.label===u.label&&v.language===u.srcLang);x&&(x.mode=t.useNative?"showing":"hidden")}}}resetSubtitleSettings(){this.store.setState({subtitleSettings:et}),this.updateSubtitleSettings({useNative:!1})}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,o=t-s;Math.abs(o)<.001||(Array.from(this.video.textTracks).forEach(a=>{(a.mode==="showing"||a.mode==="hidden")&&a.cues&&Array.from(a.cues).forEach(d=>{d.startTime+=o,d.endTime+=o})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}cancelDownload(t){var s;t&&this.activeDownloads.has(t)?((s=this.activeDownloads.get(t))==null||s.abort(),this.activeDownloads.delete(t),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.removeNotification(t)):t||this.activeDownloads.size>0&&(this.activeDownloads.forEach(o=>o.abort()),this.activeDownloads.clear(),this.notify({type:"info",message:"All downloads cancelled",duration:2e3}))}async download(t={}){var u,x,v;const s=((u=this.currentSource)==null?void 0:u.url)||this.video.src;if(!s)return;if(s.includes(".m3u8")||((x=this.currentSource)==null?void 0:x.type)==="hls"){this.downloadHls(s,t.format||"ts");return}if(s.startsWith("blob:")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Preparing download",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{const p=await this.fetchWithRetry(s,3,void 0,d);if(!p.body)throw new Error("No body");const h=p.body.getReader(),g=p.headers.get("Content-Length"),f=g?parseInt(g,10):0;let k=0;const F=[],H=Date.now(),D=[];let G=0;for(;;){const{done:ue,value:y}=await h.read();if(ue)break;if(F.push(y),k+=y.length,f){const O=Date.now();if(O-G>800||k===f){G=O;const V=Math.round(k/f*100);for(D.push({time:O,loaded:k});D.length>0&&O-D[0].time>5e3;)D.shift();let N="",n=0;if(D.length>1){const q=D[0],U=D[D.length-1],ee=U.time-q.time,ie=U.loaded-q.loaded;ee>0&&(n=ie/ee)}else{const q=O-H;q>0&&(n=k/q)}if(n>0){const U=(f-k)/n;N=`
|
|
6
|
+
${this.formatDuration(U)} remaining`}this.notify({id:o,type:"loading",message:`${N}`,progress:V,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}}}const b=new Blob(F),_=window.URL.createObjectURL(b),W=document.createElement("a");W.style.display="none",W.href=_,W.download=((v=s.split("/").pop())==null?void 0:v.split("?")[0])||"video.mp4",document.body.appendChild(W),W.click(),window.URL.revokeObjectURL(_),document.body.removeChild(W),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}catch{d.aborted?this.removeNotification(o):(this.notify({id:o,type:"error",message:"Download failed.",duration:4e3}),window.open(s,"_blank"))}finally{this.activeDownloads.delete(o)}}async downloadHls(t,s){var u;const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Analyzing HLS stream",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{let x=await this.fetchWithRetry(t,3,void 0,d),v=await x.text(),p=t.substring(0,t.lastIndexOf("/")+1);if(v.includes("#EXT-X-STREAM-INF")){this.notify({id:o,type:"loading",message:"Selecting best quality",progress:0});const y=v.split(`
|
|
7
|
+
`);let O=0,V="";for(let N=0;N<y.length;N++)if(y[N].includes("#EXT-X-STREAM-INF")){const n=y[N].match(/BANDWIDTH=(\d+)/);if(n){const q=parseInt(n[1]);let U=(u=y[N+1])==null?void 0:u.trim();U&&!U.startsWith("#")&&q>O&&(O=q,V=U)}}V&&(V.startsWith("http")||(V=p+V),x=await this.fetchWithRetry(V,3,void 0,d),v=await x.text(),p=V.substring(0,V.lastIndexOf("/")+1))}if(v.includes("#EXT-X-KEY"))throw new Error("Encrypted HLS streams are not supported for download.");const h=v.split(`
|
|
8
|
+
`),g=[];for(let y of h)y=y.trim(),y&&!y.startsWith("#")&&(y.startsWith("http")?g.push(y):g.push(p+y));if(g.length===0)throw new Error("No segments found.");let f=s==="mp4"?"mp4":"ts",k=s==="mp4"?"video/mp4":"video/mp2t",F=null,H=null,D=[];if("showSaveFilePicker"in window)try{F=await window.showSaveFilePicker({suggestedName:`video.${f}`,types:[{description:s==="mp4"?"MPEG-4 Video":"MPEG Transport Stream",accept:{[k]:[`.${f}`]}}]}),H=await F.createWritable()}catch(y){if(y.name==="AbortError"){this.removeNotification(o),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.activeDownloads.delete(o);return}console.warn("File System API cancelled or failed, falling back to memory",y)}let b=!1;const _=Date.now(),W=[];let ue=0;for(let y=0;y<g.length&&!d.aborted;y++){const O=Date.now();if(O-ue>800||y===0||y===g.length-1){ue=O;const q=Math.round((y+1)/g.length*100);for(W.push({time:O,count:y+1});W.length>0&&O-W[0].time>5e3;)W.shift();let U="";if(W.length>1){const ee=W[0],ie=W[W.length-1],he=ie.time-ee.time,me=ie.count-ee.count;if(he>0&&me>0){const je=he/me,$e=(g.length-(y+1))*je;U=`
|
|
9
|
+
${this.formatDuration($e)} remaining`}}else if(y>0){const ie=(O-_)/y,me=(g.length-y)*ie;U=`
|
|
10
|
+
${this.formatDuration(me)} remaining`}this.notify({id:o,type:"loading",message:`Downloading segment ${y+1}/${g.length}${U}`,progress:q,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}const N=await(await this.fetchWithRetry(g[y],3,void 0,d)).arrayBuffer();y===0&&new Uint8Array(N.slice(0,4))[0]===71&&(b=!0,s==="mp4"&&(this.notify({type:"info",message:"Stream is MPEG-TS. Downloading as .ts to prevent corruption.",duration:5e3}),f="ts",k="video/mp2t"));const n=new Blob([N]);H?await H.write(n):D.push(n)}if(d.aborted)throw H&&await H.abort(),new Error("Aborted");if(H)await H.close(),this.notify({id:o,type:"success",message:"Download complete!",duration:3e3});else{this.notify({id:o,type:"loading",message:"Stitching video",progress:100});const y=new Blob(D,{type:k}),O=window.URL.createObjectURL(y),V=document.createElement("a");V.style.display="none",V.href=O;const N=s==="mp4"&&b?"ts":f;V.download=`video.${N}`,document.body.appendChild(V),V.click(),window.URL.revokeObjectURL(O),document.body.removeChild(V),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}}catch(x){d.aborted?this.removeNotification(o):this.notify({id:o,type:"error",message:`Download failed: ${x.message}`,duration:4e3})}finally{this.activeDownloads.delete(o)}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),o={...t,id:s};return this.store.setState(a=>a.notifications.find(u=>u.id===s)?{notifications:a.notifications.map(u=>u.id===s?o:u)}:{notifications:[...a.notifications,o]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(o=>o.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.activeDownloads.forEach(s=>s.abort()),this.activeDownloads.clear(),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),document.removeEventListener("fullscreenchange",this.boundFullscreenChange),this.video.pause(),this.video.src="";const t=this.video.getElementsByTagName("track");for(;t.length>0;)t[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(s=>s.destroy&&s.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const Qe=(i,t=200)=>{const[s,o]=m.useState(i),[a,d]=m.useState(!1);return m.useEffect(()=>{if(i)o(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{d(!0)})});else{d(!1);const u=setTimeout(()=>{o(!1)},t);return()=>clearTimeout(u)}},[i,t]),{isMounted:s,isVisible:a}},j=({className:i,children:t,fill:s="none",strokeWidth:o=2,viewBox:a="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:a,fill:s,stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",className:i,children:t}),Lt=({className:i})=>e.jsx(j,{className:i,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),$t=({className:i})=>e.jsxs(j,{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"})]}),Et=({className:i})=>e.jsxs(j,{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"})]}),Ns=({className:i})=>e.jsxs(j,{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"})]}),At=({className:i})=>e.jsxs(j,{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"})]}),Ms=({className:i})=>e.jsxs(j,{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"})]}),Ts=({className:i})=>e.jsxs(j,{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"})]}),zs=({className:i})=>e.jsxs(j,{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"})]}),Fe=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),Rs=({className:i})=>e.jsxs(j,{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"})]}),Is=({className:i})=>e.jsxs(j,{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"})]}),Je=({className:i})=>e.jsxs(j,{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"})]}),Ps=({className:i})=>e.jsxs(j,{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"})]}),Fs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Ie=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Ls=({className:i})=>e.jsxs(j,{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"})]}),$s=({className:i})=>e.jsxs(j,{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"})]}),Es=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),As=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M5 12h14"})}),Vs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),qt=({className:i})=>e.jsxs(j,{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"})]}),Bs=({className:i})=>e.jsxs(j,{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"})]}),_t=({className:i})=>e.jsxs(j,{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"})]}),Ds=({className:i})=>e.jsxs(j,{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"})]}),Os=({className:i})=>e.jsxs(j,{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"})]}),Hs=({className:i})=>e.jsxs(j,{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"})]}),Ws=({className:i})=>e.jsxs(j,{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"})]}),Us=({className:i})=>e.jsxs(j,{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"})]}),Gs=({className:i})=>e.jsx(j,{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"})}),qs=({className:i})=>e.jsxs(j,{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"})]}),_s=({className:i})=>e.jsxs(j,{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"})]}),Xs=({className:i})=>e.jsxs(j,{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"})]}),Qs=({className:i})=>e.jsxs(j,{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"})]}),Ys=({className:i})=>e.jsxs(j,{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"})]}),Xt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Js=({className:i})=>e.jsxs(j,{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"})]}),Ks=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),Zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),ei=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),ti=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),si=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),ii=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),Ke=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),ni=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 20h.01"}),e.jsx("path",{d:"M7 20v-4"}),e.jsx("path",{d:"M12 20v-8"}),e.jsx("path",{d:"M17 20V8"}),e.jsx("path",{d:"M22 20V4"})]}),oi=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 7v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 12h18"})]}),ai=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),Qt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"m9 15 2 2 4-4"})]}),ri=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M12 12v4"})]}),Vt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("path",{d:"M12 1v2"}),e.jsx("path",{d:"M12 21v2"}),e.jsx("path",{d:"M4.22 4.22l1.42 1.42"}),e.jsx("path",{d:"M18.36 18.36l1.42 1.42"}),e.jsx("path",{d:"M1 12h2"}),e.jsx("path",{d:"M21 12h2"}),e.jsx("path",{d:"M4.22 19.78l1.42-1.42"}),e.jsx("path",{d:"M18.36 5.64l1.42-1.42"})]}),li=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"7",x:"3",y:"3",rx:"1"}),e.jsx("rect",{width:"9",height:"7",x:"3",y:"14",rx:"1"}),e.jsx("rect",{width:"5",height:"7",x:"16",y:"14",rx:"1"})]}),Bt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{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"})]}),Dt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{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"})]}),ci=({notifications:i})=>e.jsx("div",{className:"absolute top-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[280px]",children:i.map(t=>{const s=typeof t.progress=="number";return e.jsx("div",{className:`
|
|
11
11
|
relative overflow-hidden bg-zinc-950/80 backdrop-blur-xl border border-white/10 text-zinc-100 shadow-2xl rounded-lg pointer-events-auto
|
|
12
12
|
animate-in slide-in-from-left-4 fade-in duration-300
|
|
13
13
|
${s?"w-64":"w-auto max-w-full px-3 py-2.5"}
|
|
14
|
-
`,style:{borderRadius:"var(--radius)"},children:s?e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 flex items-center justify-center text-[var(--accent)] shrink-0",children:e.jsx(
|
|
14
|
+
`,style:{borderRadius:"var(--radius)"},children:s?e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 flex items-center justify-center text-[var(--accent)] shrink-0",children:e.jsx(Je,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[e.jsxs("div",{className:"flex justify-between items-baseline mb-1",children:[e.jsx("span",{className:"text-xs font-bold text-white tracking-tight",children:"Downloading"}),e.jsxs("span",{className:"text-[10px] font-mono text-zinc-400",children:[t.progress,"%"]})]}),e.jsx("p",{className:"text-[10px] text-zinc-400 mb-2 leading-tight whitespace-pre-wrap",children:t.message.replace(/Downloading\.\.\. \d+%/,"").trim()||"Processing..."}),e.jsx("div",{className:"h-0.5 w-full bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)] transition-all duration-300 ease-out",style:{width:`${t.progress}%`}})})]}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"text-zinc-500 hover:text-zinc-200 transition-colors p-1 -mt-1.5 -mr-1.5",title:t.action.label,children:e.jsx(Xt,{className:"w-3.5 h-3.5"})})]})}):e.jsxs("div",{className:"flex items-start gap-2.5",children:[t.type==="loading"&&e.jsx(Ie,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)] shrink-0 mt-0.5"}),t.type==="success"&&e.jsx(Fe,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0 mt-0.5"}),t.type==="error"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500 shrink-0 mt-0.5"}),t.type==="warning"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}),t.type==="info"&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)] mt-1.5 shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium leading-snug break-words text-zinc-200 whitespace-pre-wrap",children:t.message}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"mt-1 self-start text-[10px] font-bold text-[var(--accent)] hover:text-white transition-colors uppercase tracking-wider",children:t.action.label})]})]})},t.id)})}),di=({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 strata-subtitle-overlay",style:{bottom:`${t.verticalOffset}px`},children:i.map((o,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,whiteSpace:"pre-line"},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:o}})},a))})},Pe=({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}),ne=({label:i,checked:t,onChange:s,icon:o,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:[o&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Pe,{content:o})}),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(Pe,{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-1 w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)",backgroundColor:t?"var(--accent-contrast)":"#ffffff"}})})]}),xe=({label:i,value:t,min:s,max:o,step:a,onChange:d,formatValue:u,icon:x})=>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:[x&&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(Pe,{content:x})}),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:u?u(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:s,max:o,step:a,value:t,onChange:v=>d(parseFloat(v.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)/(o-s)*100}%, #3f3f46 ${(t-s)/(o-s)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
|
|
15
15
|
.strata-range-input::-webkit-slider-thumb {
|
|
16
16
|
-webkit-appearance: none;
|
|
17
17
|
height: 14px;
|
|
@@ -27,12 +27,13 @@ ${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`
|
|
|
27
27
|
transform: scale(1.1);
|
|
28
28
|
}
|
|
29
29
|
/* Pixel theme specific overrides are handled by global css */
|
|
30
|
-
`})]})]}),ii=({label:i,value:t,options:s,onChange:o,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(Te,{content:r})}),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:u=>o(u.target.value),className:"w-full bg-zinc-800 border-[length:var(--border-width)] border-white/10 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:ring-2 appearance-none hover:bg-zinc-700 transition-colors cursor-pointer",style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius)"},children:s.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-400",children:e.jsx("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1 1L5 5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),de=({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})]}),Qe=({children:i,onClose:t,align:s="right",maxHeight:o,className:r})=>{const u=m.useRef(null),d=m.useRef(null),[f,b]=m.useState("auto"),v=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";m.useLayoutEffect(()=>{if(!d.current)return;const w=()=>{d.current&&b(d.current.offsetHeight)},p=new ResizeObserver(w);return p.observe(d.current),w(),()=>p.disconnect()},[]);const h={height:f==="auto"?"auto":`${f+14}px`,maxHeight:o?`${o}px`:void 0};return e.jsx("div",{ref:u,className:`absolute bottom-full mb-4 ${v} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${r}`,style:{...h,borderRadius:"var(--radius-lg)"},onClick:w=>w.stopPropagation(),onMouseDown:w=>w.stopPropagation(),onTouchStart:w=>w.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:d,children:i})})})},xe=({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}),E=({label:i,value:t,active:s,onClick:o,hasSubmenu:r,icon:u,rightIcon:d})=>e.jsxs("button",{onClick:o,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-white/10 transition-colors text-left text-zinc-200 active:bg-white/5 focus:outline-none focus:bg-white/10 group overflow-hidden my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[u&&e.jsx("span",{className:"text-zinc-400 shrink-0 group-hover:text-zinc-300 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(xe,{content:u})}),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(xe,{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:e.jsx(xe,{content:t})}),d,s&&e.jsx(ze,{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:"›"})]})]}),_=({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(Ns,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(xe,{content:i})})]}),s]}),ce=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),It=({items:i,onClose:t,title:s,maxHeight:o,className:r})=>{const[u,d]=m.useState([]),f=u.length>0?u[u.length-1]:null,b=f?f.children||[]:i,v=f?f.html:s||"Menu",h=()=>{d(p=>p.slice(0,-1))},w=p=>{p.children&&d(N=>[...N,p])};return e.jsx(Qe,{onClose:t,maxHeight:o,className:r,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[u.length>0?e.jsx(_,{label:v||"Menu",onBack:h}):s&&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:s})}),e.jsx("div",{className:"pb-1",children:b.map((p,N)=>p.separator?e.jsx(ce,{},N):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(xe,{content:p.html||""})},N):p.range?e.jsx("div",{className:"px-1",children:e.jsx(fe,{label:p.html,icon:p.icon,value:p.value??p.min??0,min:p.min??0,max:p.max??100,step:p.step??1,onChange:T=>p.onRange&&p.onRange(T),formatValue:p.formatValue})},N):p.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(te,{label:p.html,icon:p.icon,checked:p.switch,tooltip:p.tooltip,onChange:T=>p.onSwitch&&p.onSwitch(p,T)})},N):e.jsx(m.Fragment,{children:e.jsx(E,{label:p.html,icon:p.icon,value:p.currentLabel||p.value,active:p.active,hasSubmenu:!!p.children,onClick:()=>{p.children?w(p):p.onClick?(p.onClick(p),!p.switch&&!p.range&&t()):p.click&&(p.click(p),t())}})},N))})]})})},ni=({tracks:i,current:t,onSelect:s,onUpload:o,onClose:r,settings:u,onSettingsChange:d,onReset:f,offset:b,onOffsetChange:v,maxHeight:h,animationClass:w})=>{const[p,N]=m.useState("main"),[T,V]=m.useState(""),X=m.useRef(null),O=m.useMemo(()=>T?i.filter(x=>x.label.toLowerCase().includes(T.toLowerCase())||x.srcLang&&x.srcLang.toLowerCase().includes(T.toLowerCase())):i,[i,T]);return e.jsxs(Qe,{onClose:r,align:"right",maxHeight:h,className:w,children:[p==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200 flex flex-col h-full",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 shrink-0",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{className:"px-1.5 pb-2 shrink-0",children:[e.jsx(E,{label:"Upload Subtitle",icon:e.jsx(Cs,{className:"w-4 h-4"}),onClick:()=>{var x;return(x=X.current)==null?void 0:x.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:X,className:"hidden",onChange:x=>{var D;(D=x.target.files)!=null&&D[0]&&o(x.target.files[0])}}),e.jsx(E,{label:"Customize",icon:e.jsx(Ft,{className:"w-4 h-4"}),onClick:()=>N("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(E,{label:"Off",active:t===-1,onClick:()=>{s(-1),r()}}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx("input",{type:"text",placeholder:"Search subtitles...",value:T,onChange:x=>V(x.target.value),className:"w-full bg-zinc-800/50 border border-white/10 rounded-md py-1.5 pl-8 pr-3 text-xs text-zinc-200 focus:outline-none focus:border-white/20 transition-colors"}),e.jsx(Zs,{className:"w-3.5 h-3.5 text-zinc-500 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"overflow-y-auto hide-scrollbar flex-1",children:[O.map(x=>{let D=null;return x.status==="loading"?D=e.jsx(Me,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)]"}):x.status==="error"?D=e.jsx(ei,{className:"w-3.5 h-3.5 text-red-500"}):x.status==="success"&&(D=e.jsx(Vt,{className:"w-3.5 h-3.5 text-emerald-500"})),e.jsx(E,{label:x.label,value:x.srcLang,active:t===x.index,rightIcon:D,onClick:()=>{s(x.index),r()}},x.index)}),O.length===0&&T&&e.jsx("div",{className:"px-4 py-3 text-center text-xs text-zinc-500",children:"No results found"})]})]}),p==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(_,{label:"Customize",onBack:()=>N("main"),rightAction:e.jsx("button",{onClick:f,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Es,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(de,{children:e.jsx(te,{label:"Native Video Subtitle",checked:u.useNative,onChange:x=>d({useNative:x})})}),!u.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(de,{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(zs,{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:()=>v(Math.round((b-.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(Rs,{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:[b>0?"+":"",(b==null?void 0:b.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>v(Math.round((b+.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(Is,{className:"w-4 h-4"})})]})]}),e.jsx(fe,{label:"Vertical Position",icon:e.jsx($s,{className:"w-4 h-4"}),value:u.verticalOffset,min:0,max:200,step:5,onChange:x=>d({verticalOffset:x}),formatValue:x=>`${x}px`})]}),e.jsxs(de,{title:"Appearance",children:[e.jsx(fe,{label:"Text Size",icon:e.jsx(Ps,{className:"w-4 h-4"}),value:u.textSize,min:50,max:200,step:10,onChange:x=>d({textSize:x}),formatValue:x=>`${x}%`}),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(At,{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(x=>e.jsx("button",{onClick:()=>d({textColor:x}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${u.textColor===x?"ring-2 scale-110":""}`,style:{backgroundColor:x,"--tw-ring-color":"var(--accent)"}},x)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:u.textColor,onChange:x=>d({textColor:x.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(ii,{label:"Text Style",value:u.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:x=>d({textStyle:x})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(te,{label:"Bold",icon:e.jsx(Fs,{className:"w-4 h-4"}),checked:u.isBold,onChange:x=>d({isBold:x})}),e.jsx(te,{label:"Fix Caps",icon:e.jsx(As,{className:"w-4 h-4"}),checked:u.fixCapitalization,onChange:x=>d({fixCapitalization:x})})]})]}),e.jsxs(de,{title:"Background",children:[e.jsx(fe,{label:"Opacity",icon:e.jsx(Ls,{className:"w-4 h-4"}),value:u.backgroundOpacity,min:0,max:100,step:5,onChange:x=>d({backgroundOpacity:x}),formatValue:x=>`${x}%`}),e.jsx(te,{label:"Blur Background",icon:e.jsx(Bs,{className:"w-4 h-4"}),checked:u.backgroundBlur,onChange:x=>d({backgroundBlur:x})}),u.backgroundBlur&&e.jsx(fe,{label:"Blur Intensity",value:u.backgroundBlurAmount,min:0,max:20,step:1,onChange:x=>d({backgroundBlurAmount:x}),formatValue:x=>`${x}px`})]})]})]})]})]})},Ue=({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}),oi=({x:i,y:t,items:s,onClose:o,containerWidth:r,containerHeight:u})=>{const d=m.useRef(null),[f,b]=m.useState({top:t,left:i,opacity:0});return m.useLayoutEffect(()=>{if(!d.current)return;const v=d.current.getBoundingClientRect(),h=v.width,w=v.height;let p=i,N=t;i+h>r-10&&(p=i-h),p<10&&(p=10),p+h>r&&(p=Math.max(10,r-h-10)),t+w>u-10&&(N=t-w);let T=u-20;N<10&&(N=10),N+w>u-10&&(N=Math.max(10,u-w-10)),b({top:N,left:p,maxHeight:T,opacity:1})},[i,t,s,r,u]),m.useEffect(()=>{const v=h=>{d.current&&!d.current.contains(h.target)&&o()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]),e.jsx("div",{ref:d,className:"absolute z-50 min-w-[200px] bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl p-1.5 font-[family-name:var(--font-main)] overflow-y-auto hide-scrollbar flex flex-col",style:{top:f.top,left:f.left,maxHeight:f.maxHeight,opacity:f.opacity,borderRadius:"var(--radius-lg)"},onClick:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),onTouchStart:v=>v.stopPropagation(),children:s.map((v,h)=>v.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},h):v.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(Ue,{content:v.html||""})},h):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{v.disabled||(v.click?v.click(o):v.onClick&&v.onClick(o))},disabled:v.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:[v.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(Ue,{content:v.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${v.checked?"text-[var(--accent)]":""}`,children:e.jsx(Ue,{content:v.html||""})})]}),v.checked&&e.jsx(ze,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),v.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},h))})},ri=({player:i,onClose:t})=>{const[s,o]=m.useState({});return m.useEffect(()=>{const r=()=>{var b;if(!i.video)return;const d=i.video,f=d.getVideoPlaybackQuality?d.getVideoPlaybackQuality():null;o({"Player Size":`${d.offsetWidth} x ${d.offsetHeight}`,"Video Resolution":`${d.videoWidth} x ${d.videoHeight}`,"Current Time":`${d.currentTime.toFixed(3)}s`,Duration:`${d.duration.toFixed(3)}s`,Volume:`${Math.round(d.volume*100)}%`,"Dropped Frames":f?f.droppedVideoFrames:"N/A",Buffer:d.buffered.length>0?`${(d.buffered.end(d.buffered.length-1)-d.currentTime).toFixed(2)}s`:"0s",Engine:((b=i.store.get().sources[i.store.get().currentSourceIndex])==null?void 0:b.type)||"native",URL:d.currentSrc})};r();const u=setInterval(r,1e3);return()=>clearInterval(u)},[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: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(Bt,{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,u])=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-1",children:[e.jsx("span",{className:"text-zinc-500 font-bold shrink-0",children: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(u),children:String(u)})]},r))})]})})};function ai(i){if(!i)return"#ffffff";i=i.replace("#",""),i.length===3&&(i=i.split("").map(u=>u+u).join(""));const t=parseInt(i.substring(0,2),16),s=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return(t*299+s*587+o*114)/1e3>=128?"#000000":"#ffffff"}const li=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],ci=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],Pt=({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}),_e=i=>{var Ct,Nt;const{src:t,type:s,sources:o,poster:r,autoPlay:u,thumbnails:d,textTracks:f,plugins:b,onGetInstance:v,...h}=i,w=h.screenshot??!1,p=h.pip??!0,N=h.setting??!0,T=h.fullscreen??!0,V=h.fullscreenWeb??!1,X=h.lock??!1,O=h.fastForward??!0,x=h.flip??!0,D=h.aspectRatio??!0,y=h.hotKey??!0,U=h.backdrop??!0,P=h.gestureSeek??!1,H=h.centerControls??!0,Q=h.fetchTimeout??3e4;h.autoOrientation;const R=m.useRef(null),[n,Y]=m.useState(null),[Z,ne]=m.useState(!1),[oe,be]=m.useState(0),[Je,ge]=m.useState(0),[Ke,Dt]=m.useState(!1),Ye=m.useMemo(()=>$t(h),[]),a=m.useSyncExternalStore(m.useCallback(c=>n?n.store.subscribe(c):()=>{},[n]),()=>n?n.store.get():Ye,()=>Ye),Ot=m.useMemo(()=>ai(a.themeColor),[a.themeColor]),[F,Ze]=m.useState(!1),[A,et]=m.useState(!1),[G,B]=m.useState("main"),[L,Re]=m.useState(null),Ie=m.useRef(null);L&&(Ie.current=L);const[ee,tt]=m.useState({x:0,y:0,visible:!1}),[Ht,st]=m.useState(!1),it=We(F,300),nt=We(A,300),ve=We(!!L,300),S=m.useCallback(()=>{(F||A||L||ee.visible)&&(Ze(!1),et(!1),Re(null),tt(c=>({...c,visible:!1})))},[F,A,L,ee.visible]);m.useEffect(()=>{const c=g=>{(F||A||L||ee.visible)&&S()};return(F||A||L||ee.visible)&&(document.addEventListener("click",c),document.addEventListener("touchstart",c)),()=>{document.removeEventListener("click",c),document.removeEventListener("touchstart",c)}},[F,A,L,ee.visible,S]);const[Pe,we]=m.useState(!1),[je,Le]=m.useState(0),[Wt,ot]=m.useState(!1),[Ut,rt]=m.useState(!1),[$e,ye]=m.useState(!1),[at,lt]=m.useState([]),[ct,dt]=m.useState(null),[Gt,qt]=m.useState(0),[se,ut]=m.useState(null),[re,ke]=m.useState(null),[ui,ht]=m.useState(null),[Ee,pt]=m.useState(!1),Fe=m.useRef(null),mt=m.useRef(1),he=m.useRef(null),ft=m.useRef(0),ue=m.useRef(!1),pe=m.useRef(null),ie=m.useRef(null),Ae=m.useRef(null),Be=m.useRef(null),me=m.useRef(null);m.useLayoutEffect(()=>{n&&R.current&&n.attach(R.current)},[n,a.isWebFullscreen]),m.useLayoutEffect(()=>{if(!R.current)return;(()=>{R.current&&(be(R.current.clientHeight),ge(R.current.clientWidth))})();const g=new ResizeObserver(k=>{for(const C of k)be(C.contentRect.height),ge(C.contentRect.width)});return g.observe(R.current),()=>{g.disconnect()}},[a.isWebFullscreen]),m.useEffect(()=>{if(Dt("ontouchstart"in window||navigator.maxTouchPoints>0),!R.current)return;const c=new Et({...h,poster:r});return b&&b.length>0&&b.forEach(g=>c.use(g)),c.attach(R.current),Y(c),v&&v(c),()=>{c.destroy(),Y(null)}},[]),m.useEffect(()=>{if(!n)return;const c={};h.theme!==void 0&&h.theme!==a.theme&&(c.theme=h.theme),h.themeColor!==void 0&&h.themeColor!==a.themeColor&&(c.themeColor=h.themeColor),h.iconSize!==void 0&&h.iconSize!==a.iconSize&&(c.iconSize=h.iconSize),Object.keys(c).length>0&&n.setAppearance(c),h.volume!==void 0&&Math.abs(h.volume-a.volume)>.01&&n.setVolume(h.volume),h.muted!==void 0&&h.muted!==a.isMuted&&(h.muted?n.video.muted=!0:n.video.muted=!1)},[n,h.theme,h.themeColor,h.iconSize,h.volume,h.muted]),m.useEffect(()=>{if(!n)return;const c=f||[];o&&o.length>0?(ne(!1),n.setSources(o,c)):t&&(ne(!1),n.setSources([{url:t,type:s||"auto"}],c))},[t,s,o,f,n]),m.useEffect(()=>{n&&u&&n.play().catch(()=>{n.pause(),n.store.setState({isPlaying:!1,isBuffering:!1}),n.notify({type:"warning",message:"Autoplay blocked by browser. Click play to start.",duration:5e3})})},[n,u]),m.useEffect(()=>{a.isPlaying&&!Z&&ne(!0)},[a.isPlaying,Z]),m.useEffect(()=>{d&&n?fs(d,n.notify.bind(n),Q).then(c=>lt(c)):lt([])},[d,n,Q]),m.useEffect(()=>(re&&(me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{ke(null)},600)),()=>{me.current&&clearTimeout(me.current)}),[re]),m.useEffect(()=>{const c=g=>{var C;if(!n||!y||((C=document.activeElement)==null?void 0:C.tagName)==="INPUT")return;switch(g.key.toLowerCase()){case" ":case"k":g.preventDefault(),n.togglePlay();break;case"arrowright":g.preventDefault(),n.skip(5);break;case"arrowleft":g.preventDefault(),n.skip(-5);break;case"arrowup":g.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":g.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":g.preventDefault(),n.toggleFullscreen();break;case"m":g.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(g.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,y]);const xt=()=>{n&&(n.setControlsVisible(!0),ie.current&&clearTimeout(ie.current),!(F||A||L)&&(ie.current=setTimeout(()=>{!a.isPlaying||F||A||L||n.setControlsVisible(!1)},2500)))};m.useEffect(()=>{n&&(!F&&!A&&!L&&a.isPlaying?xt():(F||A||L)&&(n.setControlsVisible(!0),ie.current&&clearTimeout(ie.current)))},[F,A,L,a.isPlaying,n]);const bt=m.useCallback(()=>{if(!(!O||!n||!a.isPlaying||a.isLocked)){if(F||A||L){S();return}mt.current=n.video.playbackRate,Fe.current=setTimeout(()=>{n.video.playbackRate=2,pt(!0)},500)}},[O,n,a.isPlaying,a.isLocked,F,A,L]),Ve=m.useCallback(()=>{Fe.current&&clearTimeout(Fe.current),Ee&&n&&(n.video.playbackRate=mt.current,pt(!1))},[Ee,n]),_t=c=>{if(bt(),F||A||L){S();return}P&&!a.isLocked&&(he.current=c.touches[0].clientX,ft.current=a.currentTime,ue.current=!1)},Xt=c=>{if(!a.isLocked&&P&&he.current!==null){const g=c.touches[0].clientX-he.current;if(Math.abs(g)>10&&(Ve(),ue.current=!0,we(!0),R.current&&a.duration)){const k=R.current.getBoundingClientRect(),C=g/k.width,I=Math.max(0,Math.min(a.duration,ft.current+C*a.duration));Le(I)}}},Qt=c=>{if(Ve(),P&&ue.current){n==null||n.seek(je),we(!1),ue.current=!1,he.current=null;return}he.current=null},De=c=>{if(!Ae.current||!a.duration)return 0;const g=Ae.current.getBoundingClientRect(),k="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(k-g.left)/g.width))*a.duration},gt=c=>{if(c.stopPropagation(),a.isLocked)return;(F||A||L)&&S(),we(!0),Le(De(c));const g=C=>Le(De(C)),k=C=>{n==null||n.seek(De(C)),we(!1),document.removeEventListener("mousemove",g),document.removeEventListener("touchmove",g),document.removeEventListener("mouseup",k),document.removeEventListener("touchend",k)};document.addEventListener("mousemove",g),document.addEventListener("touchmove",g),document.addEventListener("mouseup",k),document.addEventListener("touchend",k)},vt=c=>{if(!Be.current)return 0;const g=Be.current.getBoundingClientRect(),k="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(k-g.left)/g.width))},wt=c=>{if(c.stopPropagation(),!n||a.isLocked)return;ot(!0),n.setVolume(vt(c));const g=C=>n.setVolume(vt(C)),k=()=>{ot(!1),document.removeEventListener("mousemove",g),document.removeEventListener("touchmove",g),document.removeEventListener("mouseup",k),document.removeEventListener("touchend",k)};document.addEventListener("mousemove",g),document.addEventListener("touchmove",g),document.addEventListener("mouseup",k),document.addEventListener("touchend",k)},Jt=c=>{if(!a.duration||a.isLive)return;const g=c.currentTarget.getBoundingClientRect(),k=(c.clientX-g.left)/g.width,C=k*a.duration;qt(k*100),dt(C),at.length>0&&ut(at.find(I=>C>=I.start&&C<I.end)||null)},Se=c=>{!n||a.isLocked||(n.skip(c==="forward"?10:-10),ht(c),setTimeout(()=>ht(null),300))},Kt=c=>{if(!n)return;if(ue.current){ue.current=!1;return}if(F||A||L||ee.visible){S();return}if($e&&ye(!1),n.setControlsVisible(!0),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{!a.isPlaying||F||A||L||n.setControlsVisible(!1)},2500),a.isLocked)return;const g=c.currentTarget.getBoundingClientRect(),k=c.clientX-g.left,C=g.width,I=Date.now();pe.current?(clearTimeout(pe.current),pe.current=null,k<C*.35?(Se("rewind"),ke({type:"rewind",id:I})):k>C*.65?(Se("forward"),ke({type:"forward",id:I})):n.toggleFullscreen()):pe.current=setTimeout(()=>{n.togglePlay(),pe.current=null},250)},Yt=c=>{var k;if(c.preventDefault(),c.stopPropagation(),a.isLocked)return;S();const g=(k=R.current)==null?void 0:k.getBoundingClientRect();g&&requestAnimationFrame(()=>{tt({visible:!0,x:c.clientX-g.left,y:c.clientY-g.top})})},Zt=c=>{if(c.stopPropagation(),S(),$e){ye(!1);return}Ke?ye(!0):n==null||n.toggleMute()},es=a.isMuted||a.volume===0?vs:a.volume<.5?gs:bs,Ce=Math.max(100,oe-120),ts=()=>{switch(a.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},ss=()=>{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]"}},q=ts(),J=ss(),ae=(()=>{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"}}})(),is=!a.isLocked&&(a.controlsVisible||!a.isPlaying||F||A||L||ee.visible),jt=Ut||Wt||$e,Ne=U?"backdrop-blur-xl bg-black/80":"bg-black/95",yt=m.useMemo(()=>{const c=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];h.controls&&h.controls.forEach(I=>{const le=c.find(l=>l.id===I.id);le?Object.assign(le,I):c.push(I)});const g=a.sources[a.currentSourceIndex]||{url:t||"",type:s||"auto"},k=g.type==="hls"||g.url.includes(".m3u8"),C=c.find(I=>I.id==="download");return C&&(k?(C.children=[{html:"Download Format",isLabel:!0},{html:"MPEG-TS",value:"Original Stream",icon:e.jsx(Vt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"ts"})},{html:"MP4",value:"Converted",icon:e.jsx(Ft,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"mp4"})}],C.onClick=void 0):(C.children=void 0,C.onClick=I=>I.download())),c.filter(I=>!(I.id==="screenshot"&&!w||I.id==="pip"&&!p||I.id==="settings"&&!N||I.id==="fullscreen"&&!T||I.id==="fullscreenWeb"&&!V)).sort((I,le)=>I.index-le.index)},[h.controls,w,p,N,T,V,a.currentSourceIndex,a.sources,t,s]),kt=c=>{var g,k,C,I,le;if(!c.isBuiltIn){const l=c.id||`ctrl-${c.index}`,$=L===l,W=$||ve.isMounted&&Ie.current===l;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:M=>M.stopPropagation(),onTouchStart:M=>M.stopPropagation(),onClick:M=>{if(M.stopPropagation(),c.children){const Oe=$;S(),Oe||Re(l)}else S(),c.click?c.click(n):c.onClick&&c.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${J} ${$?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${c.className||""}`,style:{borderRadius:"var(--radius)",...c.style},title:c.tooltip,children:e.jsx(Pt,{content:c.html||""})}),c.children&&W&&e.jsx(It,{items:c.children,onClose:S,maxHeight:Ce,className:`strata-backdrop ${Ne} ${ve.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},c.index)}switch(c.id){case"play":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.togglePlay()},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},children:a.isPlaying?e.jsx(Tt,{className:`${q} fill-current`}):e.jsx(Mt,{className:`${q} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&rt(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&rt(!1)},children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:Zt,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},children:e.jsx(es,{className:q})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${jt?"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:wt,onTouchStart:wt,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)"}})]})}),jt&&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 h.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${a.themeColor}1a`,borderColor:`${a.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:a.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:a.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[He(Pe?je:a.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",He(a.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const $=A;S(),$||et(!0)},className:`strata-control-btn transition-colors focus:outline-none ${J} ${A?"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:q})}),nt.isMounted&&e.jsx(ni,{tracks:a.subtitleTracks,current:a.currentSubtitle,onSelect:l=>n==null?void 0:n.setSubtitle(l),onUpload:l=>n==null?void 0:n.addTextTrack(l,l.name),onClose:S,settings:a.subtitleSettings,onSettingsChange:l=>n==null?void 0:n.updateSubtitleSettings(l),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:a.subtitleOffset,onOffsetChange:l=>n==null?void 0:n.setSubtitleOffset(l),maxHeight:Ce,animationClass:`strata-backdrop ${Ne} ${nt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.screenshot()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(Vs,{className:q})},"ss");case"pip":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.togglePip()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},children:e.jsx(ks,{className:q})},"pip");case"download":if(c.children){const l=L==="download-menu",$=l||ve.isMounted&&Ie.current==="download-menu";return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:W=>W.stopPropagation(),onTouchStart:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation();const M=l;S(),M||Re("download-menu")},className:`strata-control-btn transition-colors hidden sm:block focus:outline-none ${J} ${l?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ge,{className:q})}),$&&e.jsx(It,{items:c.children,onClose:S,maxHeight:Ce,className:`strata-backdrop ${Ne} ${ve.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"dl")}return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.download()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Ge,{className:q})},"dl");case"fullscreen":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.toggleFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${J}`,style:{borderRadius:"var(--radius)"},children:a.isFullscreen||a.isWebFullscreen?e.jsx(js,{className:q}):e.jsx(ws,{className:q})},"fs");case"fullscreenWeb":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),S(),n==null||n.toggleWebFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${J} ${a.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Hs,{className:q})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const $=F;S(),$||(Ze(!0),B("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${J} ${F?"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(ys,{className:q})}),it.isMounted&&e.jsx(Qe,{onClose:S,align:"right",maxHeight:Ce,className:`strata-backdrop ${Ne} ${it.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[G==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),a.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"Source",icon:e.jsx(Gs,{className:"w-4 h-4"}),value:((g=a.sources[a.currentSourceIndex])==null?void 0:g.name)||`Source ${a.currentSourceIndex+1}`,onClick:()=>B("sources"),hasSubmenu:!0}),e.jsx(ce,{})]}),e.jsx(E,{label:"Quality",icon:e.jsx(Ks,{className:"w-4 h-4"}),value:a.currentQuality===-1?"Auto":`${(k=a.qualityLevels[a.currentQuality])==null?void 0:k.height}p`,onClick:()=>B("quality"),hasSubmenu:!0}),e.jsx(E,{label:"Speed",icon:e.jsx(Xs,{className:"w-4 h-4"}),value:`${a.playbackRate}x`,onClick:()=>B("speed"),hasSubmenu:!0}),e.jsx(E,{label:"Audio",icon:e.jsx(Qs,{className:"w-4 h-4"}),value:((C=a.audioTracks[a.currentAudioTrack])==null?void 0:C.label)||"Default",onClick:()=>B("audio"),hasSubmenu:!0}),e.jsx(ce,{}),x&&e.jsx(E,{label:"Flip",icon:e.jsx(Ys,{className:"w-4 h-4"}),value:a.flipState.horizontal?"H":a.flipState.vertical?"V":"Normal",onClick:()=>B("flip"),hasSubmenu:!0}),D&&e.jsx(E,{label:"Aspect Ratio",icon:e.jsx(qs,{className:"w-4 h-4"}),value:a.aspectRatio,onClick:()=>B("ratio"),hasSubmenu:!0}),e.jsx(E,{label:"Audio Boost",icon:e.jsx(_s,{className:"w-4 h-4"}),value:a.audioGain>1?`${a.audioGain}x`:"Off",onClick:()=>B("boost"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(E,{label:"Watch Party",icon:e.jsx(Ts,{className:"w-4 h-4"}),onClick:()=>B("party"),hasSubmenu:!0}),e.jsx(E,{label:"Cast to Device",icon:e.jsx(Ms,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),S()}}),h.settings&&h.settings.length>0&&e.jsx(ce,{}),(I=h.settings)==null?void 0:I.map((l,$)=>l.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(te,{label:l.html,icon:l.icon,checked:l.switch,tooltip:l.tooltip,onChange:W=>{l.onSwitch&&l.onSwitch(l,W)}})},`cust-${$}`):e.jsx(E,{label:l.html,icon:l.icon,value:l.currentLabel||l.value,hasSubmenu:!!l.children,onClick:()=>{l.children?B(`custom-${$}`):(l.click?l.click(l):l.onClick&&l.onClick(l),S())}},`cust-${$}`)),e.jsx(ce,{}),e.jsx(E,{label:"Appearance",icon:e.jsx(At,{className:"w-4 h-4"}),onClick:()=>B("appearance"),hasSubmenu:!0})]}),G.startsWith("custom-")&&(()=>{var W;const l=parseInt(G.split("-")[1]),$=(W=h.settings)==null?void 0:W[l];return!$||!$.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(_,{label:$.html||"Menu",onBack:()=>B("main")}),$.children.map((M,Oe)=>e.jsxs(m.Fragment,{children:[M.separator&&e.jsx(ce,{}),M.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(te,{label:M.html,checked:M.switch,onChange:rs=>M.onSwitch&&M.onSwitch(M,rs)})}),!M.separator&&M.switch===void 0&&e.jsx(E,{label:M.html,icon:M.icon,value:M.value,active:M.active,onClick:()=>{M.onClick?M.onClick(M):M.click&&M.click(M),S()}})]},Oe))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio"].includes(G)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[G==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Select Source",onBack:()=>B("main")}),a.sources.map((l,$)=>{const W=a.sourceStatuses[$],M=W==="success"?e.jsx(Js,{className:"w-3.5 h-3.5 text-emerald-500"}):W==="error"?e.jsx(qe,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(E,{label:l.name||`Source ${$+1}`,value:l.type,active:a.currentSourceIndex===$,rightIcon:M,onClick:()=>n==null?void 0:n.switchSource($)},$)})]}),G==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Speed",onBack:()=>B("main")}),[.5,1,1.5,2].map(l=>e.jsx(E,{label:`${l}x`,active:a.playbackRate===l,onClick:()=>n.video.playbackRate=l},l))]}),G==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Quality",onBack:()=>B("main")}),e.jsx(E,{label:"Auto",active:a.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),a.qualityLevels.map(l=>e.jsx(E,{label:`${l.height}p`,value:`${Math.round(l.bitrate/1e3)}k`,active:a.currentQuality===l.index,onClick:()=>n==null?void 0:n.setQuality(l.index)},l.index))]}),G==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Audio Track",onBack:()=>B("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(l=>e.jsx(E,{label:l.label,value:l.language,active:a.currentAudioTrack===l.index,onClick:()=>n==null?void 0:n.setAudioTrack(l.index)},l.index))]}),G==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Audio Boost",onBack:()=>B("main")}),[1,1.5,2,3].map(l=>e.jsx(E,{label:l===1?"Off":`${l}x`,active:a.audioGain===l,onClick:()=>n==null?void 0:n.setAudioGain(l)},l))]}),G==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Video Flip",onBack:()=>B("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(te,{label:"Horizontal Flip",checked:a.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(te,{label:"Vertical Flip",checked:a.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),G==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Aspect Ratio",onBack:()=>B("main")}),["default","16:9","4:3"].map(l=>e.jsx(E,{label:l==="default"?"Default":l,active:a.aspectRatio===l,onClick:()=>n==null?void 0:n.setAspectRatio(l)},l))]}),G==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Watch Party",onBack:()=>B("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(((le=a.sources[a.currentSourceIndex])==null?void 0:le.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"})]})]}),G==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Appearance",onBack:()=>B("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx(de,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:ci.map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:l.value,themeColor:l.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${a.theme===l.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:l.label},l.value))})}),e.jsx(de,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:l}),className:`py-1.5 text-xs font-medium transition-colors ${a.iconSize===l?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:l.charAt(0).toUpperCase()+l.slice(1)},l))})}),e.jsxs(de,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:li.map(l=>e.jsx("button",{title:l.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:l.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${a.themeColor===l.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:l.value,borderRadius:"var(--radius-full)"},children:a.themeColor===l.value&&e.jsx(ze,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},l.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:l=>n==null?void 0:n.setAppearance({themeColor:l.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}},ns=m.useMemo(()=>{const c=[{html:"Playback",isLabel:!0},{html:"Loop",checked:a.isLooping,onClick:()=>n==null?void 0:n.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>n==null?void 0:n.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>n==null?void 0:n.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:a.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:a.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"4:3",checked:a.aspectRatio==="4:3",onClick:()=>n==null?void 0:n.setAspectRatio("4:3")},{separator:!0},{html:"Video Info",icon:e.jsx(Us,{className:"w-3.5 h-3.5"}),onClick:()=>st(!0)},{separator:!0}];return h.contextmenu&&c.push(...h.contextmenu),c.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),c.push({html:"Close",onClick:g=>g(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),c},[h.contextmenu,a.aspectRatio,a.isLooping,n]),os=a.isWebFullscreen,St=e.jsxs("div",{id:h.id,ref:R,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset flex items-center justify-center ${os?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius)]"} ${h.container||""}`,style:{touchAction:"manipulation","--accent":a.themeColor,"--accent-contrast":Ot},onMouseMove:xt,onMouseLeave:()=>{a.isPlaying&&!F&&!A&&!L&&n&&n.setControlsVisible(!1)},onMouseDown:bt,onMouseUp:Ve,onTouchStart:_t,onTouchMove:Xt,onTouchEnd:Qt,onContextMenu:Yt,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":a.theme,children:[e.jsx("style",{children:`
|
|
30
|
+
`})]})]}),ui=({label:i,value:t,options:s,onChange:o,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(Pe,{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:d=>o(d.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(d=>e.jsx("option",{value:d.value,children:d.label},d.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"})})})]})]}),de=({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})]}),tt=({children:i,onClose:t,align:s="right",maxHeight:o,className:a})=>{const d=m.useRef(null),u=m.useRef(null),[x,v]=m.useState("auto"),p=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";m.useLayoutEffect(()=>{if(!u.current)return;const g=()=>{u.current&&v(u.current.offsetHeight)},f=new ResizeObserver(g);return f.observe(u.current),g(),()=>f.disconnect()},[]);const h={height:x==="auto"?"auto":`${x+14}px`,maxHeight:o?`${o}px`:void 0};return e.jsx("div",{ref:d,className:`absolute bottom-full mb-4 ${p} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${a}`,style:{...h,borderRadius:"var(--radius-lg)"},onClick:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onTouchStart:g=>g.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:u,children:i})})})},we=({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}),I=({label:i,value:t,active:s,onClick:o,hasSubmenu:a,icon:d,rightIcon:u})=>e.jsxs("button",{onClick:o,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:[d&&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(we,{content:d})}),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(we,{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:e.jsx(we,{content:t})}),u,s&&e.jsx(Fe,{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:"›"})]})]}),Y=({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(Fs,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(we,{content:i})})]}),s]}),ce=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),Ot=({items:i,onClose:t,title:s,maxHeight:o,className:a})=>{const[d,u]=m.useState([]),x=d.length>0?d[d.length-1]:null,v=x?x.children||[]:i,p=x?x.html:s||"Menu",h=()=>{u(f=>f.slice(0,-1))},g=f=>{f.children&&u(k=>[...k,f])};return e.jsx(tt,{onClose:t,maxHeight:o,className:a,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[d.length>0?e.jsx(Y,{label:p||"Menu",onBack:h}):s&&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:s})}),e.jsx("div",{className:"pb-1",children:v.map((f,k)=>f.separator?e.jsx(ce,{},k):f.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(we,{content:f.html||""})},k):f.range?e.jsx("div",{className:"px-1",children:e.jsx(xe,{label:f.html,icon:f.icon,value:f.value??f.min??0,min:f.min??0,max:f.max??100,step:f.step??1,onChange:F=>f.onRange&&f.onRange(F),formatValue:f.formatValue})},k):f.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:f.html,icon:f.icon,checked:f.switch,tooltip:f.tooltip,onChange:F=>f.onSwitch&&f.onSwitch(f,F)})},k):e.jsx(m.Fragment,{children:e.jsx(I,{label:f.html,icon:f.icon,value:f.currentLabel||f.value,active:f.active,hasSubmenu:!!f.children,onClick:()=>{f.children?g(f):f.onClick?(f.onClick(f),!f.switch&&!f.range&&t()):f.click&&(f.click(f),t())}})},k))})]})})},hi=({tracks:i,current:t,onSelect:s,onUpload:o,onClose:a,settings:d,onSettingsChange:u,onReset:x,offset:v,onOffsetChange:p,maxHeight:h,animationClass:g})=>{const[f,k]=m.useState("main"),[F,H]=m.useState(""),D=m.useRef(null),G=m.useMemo(()=>F?i.filter(b=>b.label.toLowerCase().includes(F.toLowerCase())||b.srcLang&&b.srcLang.toLowerCase().includes(F.toLowerCase())):i,[i,F]);return e.jsxs(tt,{onClose:a,align:"right",maxHeight:h,className:g,children:[f==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200 flex flex-col h-full",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 shrink-0",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{className:"px-1.5 pb-2 shrink-0",children:[e.jsx(I,{label:"Upload Subtitle",icon:e.jsx(Ps,{className:"w-4 h-4"}),onClick:()=>{var b;return(b=D.current)==null?void 0:b.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:D,className:"hidden",onChange:b=>{var _;(_=b.target.files)!=null&&_[0]&&o(b.target.files[0])}}),e.jsx(I,{label:"Customize",icon:e.jsx(qt,{className:"w-4 h-4"}),onClick:()=>k("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(I,{label:"Off",active:t===-1,onClick:()=>{s(-1),a()}}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx("input",{type:"text",placeholder:"Search subtitles...",value:F,onChange:b=>H(b.target.value),className:"w-full bg-zinc-800/50 border border-white/10 rounded-md py-1.5 pl-8 pr-3 text-xs text-zinc-200 focus:outline-none focus:border-white/20 transition-colors"}),e.jsx(ai,{className:"w-3.5 h-3.5 text-zinc-500 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"overflow-y-auto hide-scrollbar flex-1",children:[G.map(b=>{let _=null;return b.status==="loading"?_=e.jsx(Ie,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)]"}):b.status==="error"?_=e.jsx(ri,{className:"w-3.5 h-3.5 text-red-500"}):b.status==="success"&&(_=e.jsx(Qt,{className:"w-3.5 h-3.5 text-emerald-500"})),e.jsx(I,{label:b.label,value:b.srcLang,active:t===b.index,rightIcon:_,onClick:()=>{s(b.index),a()}},b.index)}),G.length===0&&F&&e.jsx("div",{className:"px-4 py-3 text-center text-xs text-zinc-500",children:"No results found"})]})]}),f==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:"Customize",onBack:()=>k("main"),rightAction:e.jsx("button",{onClick:x,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Hs,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(de,{children:e.jsx(ne,{label:"Native Video Subtitle",checked:d.useNative,onChange:b=>u({useNative:b})})}),!d.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(de,{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(Es,{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((v-.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(As,{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:[v>0?"+":"",(v==null?void 0:v.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>p(Math.round((v+.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(Vs,{className:"w-4 h-4"})})]})]}),e.jsx(xe,{label:"Vertical Position",icon:e.jsx(Os,{className:"w-4 h-4"}),value:d.verticalOffset,min:0,max:200,step:5,onChange:b=>u({verticalOffset:b}),formatValue:b=>`${b}px`})]}),e.jsxs(de,{title:"Appearance",children:[e.jsx(xe,{label:"Text Size",icon:e.jsx(Bs,{className:"w-4 h-4"}),value:d.textSize,min:50,max:200,step:10,onChange:b=>u({textSize:b}),formatValue:b=>`${b}%`}),e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(_t,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Text Color"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1 bg-zinc-800/50 rounded-lg",children:[["#ffffff","#ffff00","#00ffff","#ff00ff","#ff0000","#00ff00"].map(b=>e.jsx("button",{onClick:()=>u({textColor:b}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${d.textColor===b?"ring-2 scale-110":""}`,style:{backgroundColor:b,"--tw-ring-color":"var(--accent)"}},b)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:d.textColor,onChange:b=>u({textColor:b.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(ui,{label:"Text Style",value:d.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:b=>u({textStyle:b})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(ne,{label:"Bold",icon:e.jsx(Ws,{className:"w-4 h-4"}),checked:d.isBold,onChange:b=>u({isBold:b})}),e.jsx(ne,{label:"Fix Caps",icon:e.jsx(Us,{className:"w-4 h-4"}),checked:d.fixCapitalization,onChange:b=>u({fixCapitalization:b})})]})]}),e.jsxs(de,{title:"Background",children:[e.jsx(xe,{label:"Opacity",icon:e.jsx(Ds,{className:"w-4 h-4"}),value:d.backgroundOpacity,min:0,max:100,step:5,onChange:b=>u({backgroundOpacity:b}),formatValue:b=>`${b}%`}),e.jsx(ne,{label:"Blur Background",icon:e.jsx(Gs,{className:"w-4 h-4"}),checked:d.backgroundBlur,onChange:b=>u({backgroundBlur:b})}),d.backgroundBlur&&e.jsx(xe,{label:"Blur Intensity",value:d.backgroundBlurAmount,min:0,max:20,step:1,onChange:b=>u({backgroundBlurAmount:b}),formatValue:b=>`${b}px`})]})]})]})]})]})},Ye=({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}),mi=({x:i,y:t,items:s,onClose:o,containerWidth:a,containerHeight:d})=>{const u=m.useRef(null),[x,v]=m.useState({top:t,left:i,opacity:0});return m.useLayoutEffect(()=>{if(!u.current)return;const p=u.current.getBoundingClientRect(),h=p.width,g=p.height;let f=i,k=t;i+h>a-10&&(f=i-h),f<10&&(f=10),f+h>a&&(f=Math.max(10,a-h-10)),t+g>d-10&&(k=t-g);let F=d-20;k<10&&(k=10),k+g>d-10&&(k=Math.max(10,d-g-10)),v({top:k,left:f,maxHeight:F,opacity:1})},[i,t,s,a,d]),m.useEffect(()=>{const p=h=>{u.current&&!u.current.contains(h.target)&&o()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]),e.jsx("div",{ref:u,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:x.top,left:x.left,maxHeight:x.maxHeight,opacity:x.opacity,borderRadius:"var(--radius-lg)"},onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:s.map((p,h)=>p.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},h):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(Ye,{content:p.html||""})},h):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{p.disabled||(p.click?p.click(o):p.onClick&&p.onClick(o))},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(Ye,{content:p.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${p.checked?"text-[var(--accent)]":""}`,children:e.jsx(Ye,{content:p.html||""})})]}),p.checked&&e.jsx(Fe,{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"})]},h))})},fi=({player:i,onClose:t})=>{const[s,o]=m.useState({});return m.useEffect(()=>{const a=()=>{var v;if(!i.video)return;const u=i.video,x=u.getVideoPlaybackQuality?u.getVideoPlaybackQuality():null;o({"Player Size":`${u.offsetWidth} x ${u.offsetHeight}`,"Video Resolution":`${u.videoWidth} x ${u.videoHeight}`,"Current Time":`${u.currentTime.toFixed(3)}s`,Duration:`${u.duration.toFixed(3)}s`,Volume:`${Math.round(u.volume*100)}%`,"Dropped Frames":x?x.droppedVideoFrames:"N/A",Buffer:u.buffered.length>0?`${(u.buffered.end(u.buffered.length-1)-u.currentTime).toFixed(2)}s`:"0s",Engine:((v=i.store.get().sources[i.store.get().currentSourceIndex])==null?void 0:v.type)||"native",URL:u.currentSrc})};a();const d=setInterval(a,1e3);return()=>clearInterval(d)},[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(Xt,{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,d])=>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(d),children:String(d)})]},a))})]})})};function xi(i){if(!i)return"#ffffff";i=i.replace("#",""),i.length===3&&(i=i.split("").map(d=>d+d).join(""));const t=parseInt(i.substring(0,2),16),s=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return(t*299+s*587+o*114)/1e3>=128?"#000000":"#ffffff"}const pi=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],bi=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],Ht=({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}),Ze=i=>{var Pt,Ft;const{src:t,type:s,sources:o,poster:a,autoPlay:d,thumbnails:u,textTracks:x,plugins:v,onGetInstance:p,...h}=i,g=h.screenshot??!1,f=h.pip??!0,k=h.setting??!0,F=h.fullscreen??!0,H=h.fullscreenWeb??!1,D=h.lock??!1,G=h.fastForward??!0,b=h.flip??!0,_=h.aspectRatio??!0,W=h.hotKey??!0,ue=h.backdrop??!0,y=h.gestureSeek??!1,O=h.centerControls??!0,V=h.fetchTimeout??3e4;h.autoOrientation;const N=m.useRef(null),[n,q]=m.useState(null),[U,ee]=m.useState(!1),[ie,he]=m.useState(0),[me,je]=m.useState(0),[Le,$e]=m.useState(!1),st=m.useMemo(()=>Ut(h),[]),r=m.useSyncExternalStore(m.useCallback(c=>n?n.store.subscribe(c):()=>{},[n]),()=>n?n.store.get():st,()=>st),Yt=m.useMemo(()=>xi(r.themeColor),[r.themeColor]),[E,it]=m.useState(!1),[A,nt]=m.useState(!1),[X,$]=m.useState("main"),[L,Ee]=m.useState(null),Ae=m.useRef(null);L&&(Ae.current=L);const[te,ot]=m.useState({x:0,y:0,visible:!1}),[Jt,at]=m.useState(!1),rt=Qe(E,300),lt=Qe(A,300),ye=Qe(!!L,300),M=m.useCallback(()=>{(E||A||L||te.visible)&&(it(!1),nt(!1),Ee(null),ot(c=>({...c,visible:!1})))},[E,A,L,te.visible]);m.useEffect(()=>{const c=w=>{(E||A||L||te.visible)&&M()};return(E||A||L||te.visible)&&(document.addEventListener("click",c),document.addEventListener("touchstart",c)),()=>{document.removeEventListener("click",c),document.removeEventListener("touchstart",c)}},[E,A,L,te.visible,M]);const[Ve,ke]=m.useState(!1),[Se,Be]=m.useState(0),[Kt,ct]=m.useState(!1),[Zt,dt]=m.useState(!1),[Ce,fe]=m.useState(!1),[ut,De]=m.useState(!1),[ht,mt]=m.useState([]),[ft,xt]=m.useState(null),[es,ts]=m.useState(0),[oe,pt]=m.useState(null),[re,Ne]=m.useState(null),[vi,bt]=m.useState(null),[Oe,gt]=m.useState(!1),He=m.useRef(null),vt=m.useRef(1),pe=m.useRef(null),Me=m.useRef(null),wt=m.useRef(0),jt=m.useRef(0),yt=m.useRef(0),J=m.useRef(null),be=m.useRef(!1),ge=m.useRef(null),ae=m.useRef(null),We=m.useRef(null),Ue=m.useRef(null),ve=m.useRef(null);m.useLayoutEffect(()=>{n&&N.current&&n.attach(N.current)},[n,r.isWebFullscreen]),m.useLayoutEffect(()=>{if(!N.current)return;(()=>{N.current&&(he(N.current.clientHeight),je(N.current.clientWidth))})();const w=new ResizeObserver(S=>{for(const C of S)he(C.contentRect.height),je(C.contentRect.width)});return w.observe(N.current),()=>{w.disconnect()}},[r.isWebFullscreen]),m.useEffect(()=>{if($e("ontouchstart"in window||navigator.maxTouchPoints>0),!N.current)return;const c=new Gt({...h,poster:a});return v&&v.length>0&&v.forEach(w=>c.use(w)),c.attach(N.current),q(c),p&&p(c),()=>{c.destroy(),q(null)}},[]),m.useEffect(()=>{if(!n)return;const c={};h.theme!==void 0&&h.theme!==r.theme&&(c.theme=h.theme),h.themeColor!==void 0&&h.themeColor!==r.themeColor&&(c.themeColor=h.themeColor),h.iconSize!==void 0&&h.iconSize!==r.iconSize&&(c.iconSize=h.iconSize),h.brightness!==void 0&&Math.abs(h.brightness-r.brightness)>.05&&n.setBrightness(h.brightness),h.videoFit!==void 0&&h.videoFit!==r.videoFit&&n.setVideoFit(h.videoFit),Object.keys(c).length>0&&n.setAppearance(c),h.volume!==void 0&&Math.abs(h.volume-r.volume)>.01&&n.setVolume(h.volume),h.muted!==void 0&&h.muted!==r.isMuted&&(h.muted?n.video.muted=!0:n.video.muted=!1)},[n,h.theme,h.themeColor,h.iconSize,h.volume,h.muted,h.brightness,h.videoFit]),m.useEffect(()=>{if(!n)return;const c=x||[];o&&o.length>0?(ee(!1),n.setSources(o,c)):t&&(ee(!1),n.setSources([{url:t,type:s||"auto"}],c))},[t,s,o,x,n]),m.useEffect(()=>{n&&d&&n.play().catch(()=>{n.pause(),n.store.setState({isPlaying:!1,isBuffering:!1}),n.notify({type:"warning",message:"Autoplay blocked by browser. Click play to start.",duration:5e3})})},[n,d]),m.useEffect(()=>{r.isPlaying&&!U&&ee(!0)},[r.isPlaying,U]),m.useEffect(()=>{u&&n?Ss(u,n.notify.bind(n),V).then(c=>mt(c)):mt([])},[u,n,V]),m.useEffect(()=>(re&&(ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{Ne(null)},600)),()=>{ve.current&&clearTimeout(ve.current)}),[re]),m.useEffect(()=>{const c=w=>{var C;if(!n||!W||((C=document.activeElement)==null?void 0:C.tagName)==="INPUT")return;switch(w.key.toLowerCase()){case" ":case"k":w.preventDefault(),n.togglePlay();break;case"arrowright":w.preventDefault(),n.skip(5);break;case"arrowleft":w.preventDefault(),n.skip(-5);break;case"arrowup":w.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":w.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":w.preventDefault(),n.toggleFullscreen();break;case"m":w.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(w.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,W]);const kt=()=>{n&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),!(E||A||L)&&(ae.current=setTimeout(()=>{!r.isPlaying||E||A||L||n.setControlsVisible(!1)},2500)))};m.useEffect(()=>{n&&(!E&&!A&&!L&&r.isPlaying?kt():(E||A||L)&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current)))},[E,A,L,r.isPlaying,n]);const St=m.useCallback(()=>{if(!(!G||!n||!r.isPlaying||r.isLocked)){if(E||A||L){M();return}vt.current=n.video.playbackRate,He.current=setTimeout(()=>{n.video.playbackRate=2,gt(!0)},500)}},[G,n,r.isPlaying,r.isLocked,E,A,L]),Ge=m.useCallback(()=>{He.current&&clearTimeout(He.current),Oe&&n&&(n.video.playbackRate=vt.current,gt(!1))},[Oe,n]),ss=c=>{if(St(),E||A||L){M();return}r.isLocked||(pe.current=c.touches[0].clientX,Me.current=c.touches[0].clientY,wt.current=r.currentTime,jt.current=r.volume,yt.current=r.brightness,be.current=!1,J.current=null)},is=c=>{var se,l;if(r.isLocked||!n||pe.current===null||Me.current===null)return;const w=c.touches[0].clientX,S=c.touches[0].clientY,C=w-pe.current,R=S-Me.current;if(!J.current&&(Math.abs(C)>10||Math.abs(R)>10))if(be.current=!0,Ge(),Math.abs(C)>Math.abs(R))y&&(J.current="seek",ke(!0));else{const z=N.current?N.current.clientWidth/2:window.innerWidth/2;pe.current<z?(J.current="brightness",De(!0)):(J.current="volume",fe(!0))}if(J.current==="seek"&&N.current&&r.duration){const z=N.current.getBoundingClientRect(),B=C/z.width,T=Math.max(0,Math.min(r.duration,wt.current+B*r.duration));Be(T)}else if(J.current==="volume"){const B=-(R/(((se=N.current)==null?void 0:se.clientHeight)||300))*1.5;n.setVolume(Math.max(0,Math.min(1,jt.current+B)))}else if(J.current==="brightness"){const B=-(R/(((l=N.current)==null?void 0:l.clientHeight)||300))*1.5;n.setBrightness(Math.max(0,Math.min(2,yt.current+B)))}},ns=c=>{Ge(),J.current==="seek"?(n==null||n.seek(Se),ke(!1)):J.current==="volume"?fe(!1):J.current==="brightness"&&De(!1),be.current=!1,J.current=null,pe.current=null,Me.current=null},qe=c=>{if(!We.current||!r.duration)return 0;const w=We.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))*r.duration},Ct=c=>{if(c.stopPropagation(),r.isLocked)return;(E||A||L)&&M(),ke(!0),Be(qe(c));const w=C=>Be(qe(C)),S=C=>{n==null||n.seek(qe(C)),ke(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},Nt=c=>{if(!Ue.current)return 0;const w=Ue.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))},Mt=c=>{if(c.stopPropagation(),!n||r.isLocked)return;ct(!0),n.setVolume(Nt(c));const w=C=>n.setVolume(Nt(C)),S=()=>{ct(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},os=c=>{if(!r.duration||r.isLive)return;const w=c.currentTarget.getBoundingClientRect(),S=(c.clientX-w.left)/w.width,C=S*r.duration;ts(S*100),xt(C),ht.length>0&&pt(ht.find(R=>C>=R.start&&C<R.end)||null)},Te=c=>{!n||r.isLocked||(n.skip(c==="forward"?10:-10),bt(c),setTimeout(()=>bt(null),300))},as=c=>{if(!n)return;if(be.current){be.current=!1;return}if(E||A||L||te.visible){M();return}if(Ce&&fe(!1),ut&&De(!1),n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{!r.isPlaying||E||A||L||n.setControlsVisible(!1)},2500),r.isLocked)return;const w=c.currentTarget.getBoundingClientRect(),S=c.clientX-w.left,C=w.width,R=Date.now();ge.current?(clearTimeout(ge.current),ge.current=null,S<C*.35?(Te("rewind"),Ne({type:"rewind",id:R})):S>C*.65?(Te("forward"),Ne({type:"forward",id:R})):n.toggleFullscreen()):ge.current=setTimeout(()=>{n.togglePlay(),ge.current=null},250)},rs=c=>{var S;if(c.preventDefault(),c.stopPropagation(),r.isLocked)return;M();const w=(S=N.current)==null?void 0:S.getBoundingClientRect();w&&requestAnimationFrame(()=>{ot({visible:!0,x:c.clientX-w.left,y:c.clientY-w.top})})},ls=c=>{if(c.stopPropagation(),M(),Ce){fe(!1);return}Le?fe(!0):n==null||n.toggleMute()},cs=r.isMuted||r.volume===0?At:r.volume<.5?Ns:Et,ze=Math.max(100,ie-120),ds=()=>{switch(r.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},us=()=>{switch(r.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]"}},K=ds(),Z=us(),le=(()=>{switch(r.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"}}})(),hs=!r.isLocked&&(r.controlsVisible||!r.isPlaying||E||A||L||te.visible),Tt=Zt||Kt||Ce,Re=ue?"backdrop-blur-xl bg-black/80":"bg-black/95",zt=m.useMemo(()=>{const c=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];h.controls&&h.controls.forEach(R=>{const se=c.find(l=>l.id===R.id);se?Object.assign(se,R):c.push(R)});const w=r.sources[r.currentSourceIndex]||{url:t||"",type:s||"auto"},S=w.type==="hls"||w.url.includes(".m3u8"),C=c.find(R=>R.id==="download");return C&&(S?(C.children=[{html:"Download Format",isLabel:!0},{html:"MPEG-TS",value:"Original Stream",icon:e.jsx(Qt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"ts"})},{html:"MP4",value:"Converted",icon:e.jsx(qt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"mp4"})}],C.onClick=void 0):(C.children=void 0,C.onClick=R=>R.download())),c.filter(R=>!(R.id==="screenshot"&&!g||R.id==="pip"&&!f||R.id==="settings"&&!k||R.id==="fullscreen"&&!F||R.id==="fullscreenWeb"&&!H)).sort((R,se)=>R.index-se.index)},[h.controls,g,f,k,F,H,r.currentSourceIndex,r.sources,t,s]),Rt=c=>{var w,S,C,R,se;if(!c.isBuiltIn){const l=c.id||`ctrl-${c.index}`,z=L===l,B=z||ye.isMounted&&Ae.current===l;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:T=>T.stopPropagation(),onTouchStart:T=>T.stopPropagation(),onClick:T=>{if(T.stopPropagation(),c.children){const _e=z;M(),_e||Ee(l)}else M(),c.click?c.click(n):c.onClick&&c.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${Z} ${z?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${c.className||""}`,style:{borderRadius:"var(--radius)",...c.style},title:c.tooltip,children:e.jsx(Ht,{content:c.html||""})}),c.children&&B&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Re} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},c.index)}switch(c.id){case"play":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePlay()},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isPlaying?e.jsx($t,{className:`${K} fill-current`}):e.jsx(Lt,{className:`${K} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&dt(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&dt(!1)},children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:ls,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(cs,{className:K})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${Tt?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:Ue,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:Mt,onTouchStart:Mt,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:`${(r.isMuted?0:r.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(${(r.isMuted?0:r.volume)*100}% * 0.85 + 4px)`,borderRadius:"var(--radius-full)"}})]})}),Tt&&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 + ${(r.isMuted?0:r.volume)*80}px)`},children:r.isMuted?"0%":`${Math.round(r.volume*100)}%`})]},"volume");case"time":return h.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${r.themeColor}1a`,borderColor:`${r.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:r.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:r.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[Xe(Ve?Se:r.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",Xe(r.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=A;M(),z||nt(!0)},className:`strata-control-btn transition-colors focus:outline-none ${Z} ${A?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Is,{className:K})}),lt.isMounted&&e.jsx(hi,{tracks:r.subtitleTracks,current:r.currentSubtitle,onSelect:l=>n==null?void 0:n.setSubtitle(l),onUpload:l=>n==null?void 0:n.addTextTrack(l,l.name),onClose:M,settings:r.subtitleSettings,onSettingsChange:l=>n==null?void 0:n.updateSubtitleSettings(l),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:r.subtitleOffset,onOffsetChange:l=>n==null?void 0:n.setSubtitleOffset(l),maxHeight:ze,animationClass:`strata-backdrop ${Re} ${lt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.screenshot()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(qs,{className:K})},"ss");case"pip":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePip()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Rs,{className:K})},"pip");case"download":if(c.children){const l=L==="download-menu",z=l||ye.isMounted&&Ae.current==="download-menu";return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:B=>B.stopPropagation(),onTouchStart:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation();const T=l;M(),T||Ee("download-menu")},className:`strata-control-btn transition-colors hidden sm:block focus:outline-none ${Z} ${l?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})}),z&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Re} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"dl")}return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.download()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})},"dl");case"fullscreen":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isFullscreen||r.isWebFullscreen?e.jsx(Ts,{className:K}):e.jsx(Ms,{className:K})},"fs");case"fullscreenWeb":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleWebFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${Z} ${r.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Qs,{className:K})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=E;M(),z||(it(!0),$("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${Z} ${E?"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(zs,{className:K})}),rt.isMounted&&e.jsx(tt,{onClose:M,align:"right",maxHeight:ze,className:`strata-backdrop ${Re} ${rt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[X==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),r.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(I,{label:"Source",icon:e.jsx(Ks,{className:"w-4 h-4"}),value:((w=r.sources[r.currentSourceIndex])==null?void 0:w.name)||`Source ${r.currentSourceIndex+1}`,onClick:()=>$("sources"),hasSubmenu:!0}),e.jsx(ce,{})]}),e.jsx(I,{label:"Quality",icon:e.jsx(ni,{className:"w-4 h-4"}),value:r.currentQuality===-1?"Auto":`${(S=r.qualityLevels[r.currentQuality])==null?void 0:S.height}p`,onClick:()=>$("quality"),hasSubmenu:!0}),e.jsx(I,{label:"Speed",icon:e.jsx(ti,{className:"w-4 h-4"}),value:`${r.playbackRate}x`,onClick:()=>$("speed"),hasSubmenu:!0}),e.jsx(I,{label:"Audio",icon:e.jsx(si,{className:"w-4 h-4"}),value:((C=r.audioTracks[r.currentAudioTrack])==null?void 0:C.label)||"Default",onClick:()=>$("audio"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(I,{label:"Video Fit",icon:e.jsx(li,{className:"w-4 h-4"}),value:r.videoFit==="none"?"Default":r.videoFit.charAt(0).toUpperCase()+r.videoFit.slice(1),onClick:()=>$("videofit"),hasSubmenu:!0}),_&&e.jsx(I,{label:"Aspect Ratio",icon:e.jsx(Zs,{className:"w-4 h-4"}),value:r.aspectRatio,onClick:()=>$("ratio"),hasSubmenu:!0}),b&&e.jsx(I,{label:"Flip",icon:e.jsx(oi,{className:"w-4 h-4"}),value:r.flipState.horizontal?"H":r.flipState.vertical?"V":"Normal",onClick:()=>$("flip"),hasSubmenu:!0}),e.jsx(I,{label:"Audio Boost",icon:e.jsx(ei,{className:"w-4 h-4"}),value:r.audioGain>1?`${r.audioGain}x`:"Off",onClick:()=>$("boost"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(I,{label:"Watch Party",icon:e.jsx($s,{className:"w-4 h-4"}),onClick:()=>$("party"),hasSubmenu:!0}),e.jsx(I,{label:"Cast to Device",icon:e.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),M()}}),h.settings&&h.settings.length>0&&e.jsx(ce,{}),(R=h.settings)==null?void 0:R.map((l,z)=>l.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:l.html,icon:l.icon,checked:l.switch,tooltip:l.tooltip,onChange:B=>{l.onSwitch&&l.onSwitch(l,B)}})},`cust-${z}`):e.jsx(I,{label:l.html,icon:l.icon,value:l.currentLabel||l.value,hasSubmenu:!!l.children,onClick:()=>{l.children?$(`custom-${z}`):(l.click?l.click(l):l.onClick&&l.onClick(l),M())}},`cust-${z}`)),e.jsx(ce,{}),e.jsx(I,{label:"Appearance",icon:e.jsx(_t,{className:"w-4 h-4"}),onClick:()=>$("appearance"),hasSubmenu:!0})]}),X.startsWith("custom-")&&(()=>{var B;const l=parseInt(X.split("-")[1]),z=(B=h.settings)==null?void 0:B[l];return!z||!z.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:z.html||"Menu",onBack:()=>$("main")}),z.children.map((T,_e)=>e.jsxs(m.Fragment,{children:[T.separator&&e.jsx(ce,{}),T.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:T.html,checked:T.switch,onChange:xs=>T.onSwitch&&T.onSwitch(T,xs)})}),!T.separator&&T.switch===void 0&&e.jsx(I,{label:T.html,icon:T.icon,value:T.value,active:T.active,onClick:()=>{T.onClick?T.onClick(T):T.click&&T.click(T),M()}})]},_e))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio","videofit"].includes(X)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[X==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Select Source",onBack:()=>$("main")}),r.sources.map((l,z)=>{const B=r.sourceStatuses[z],T=B==="success"?e.jsx(ii,{className:"w-3.5 h-3.5 text-emerald-500"}):B==="error"?e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(I,{label:l.name||`Source ${z+1}`,value:l.type,active:r.currentSourceIndex===z,rightIcon:T,onClick:()=>n==null?void 0:n.switchSource(z)},z)})]}),X==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Speed",onBack:()=>$("main")}),[.5,1,1.5,2].map(l=>e.jsx(I,{label:`${l}x`,active:r.playbackRate===l,onClick:()=>n.video.playbackRate=l},l))]}),X==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Quality",onBack:()=>$("main")}),e.jsx(I,{label:"Auto",active:r.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),r.qualityLevels.map(l=>e.jsx(I,{label:`${l.height}p`,value:`${Math.round(l.bitrate/1e3)}k`,active:r.currentQuality===l.index,onClick:()=>n==null?void 0:n.setQuality(l.index)},l.index))]}),X==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Track",onBack:()=>$("main")}),r.audioTracks.length===0&&e.jsx("div",{className:"px-4 py-3 text-zinc-500 text-xs text-center",children:"No tracks available"}),r.audioTracks.map(l=>e.jsx(I,{label:l.label,value:l.language,active:r.currentAudioTrack===l.index,onClick:()=>n==null?void 0:n.setAudioTrack(l.index)},l.index))]}),X==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Boost",onBack:()=>$("main")}),[1,1.5,2,3].map(l=>e.jsx(I,{label:l===1?"Off":`${l}x`,active:r.audioGain===l,onClick:()=>n==null?void 0:n.setAudioGain(l)},l))]}),X==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Flip",onBack:()=>$("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(ne,{label:"Horizontal Flip",checked:r.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(ne,{label:"Vertical Flip",checked:r.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),X==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Aspect Ratio",onBack:()=>$("main")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto hide-scrollbar",children:["default","16:9","4:3","21:9","18:9","1:1","9:16"].map(l=>e.jsx(I,{label:l==="default"?"Default":l.replace(":"," : "),active:r.aspectRatio===l,onClick:()=>n==null?void 0:n.setAspectRatio(l)},l))})]}),X==="videofit"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Fit",onBack:()=>$("main")}),e.jsx(I,{label:"Contain (Default)",value:"Fit",active:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")}),e.jsx(I,{label:"Cover",value:"Zoom",active:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")}),e.jsx(I,{label:"Fill",value:"Stretch",active:r.videoFit==="fill",onClick:()=>n==null?void 0:n.setVideoFit("fill")}),e.jsx(I,{label:"None",value:"Original",active:r.videoFit==="none",onClick:()=>n==null?void 0:n.setVideoFit("none")})]}),X==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Watch Party",onBack:()=>$("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(((se=r.sources[r.currentSourceIndex])==null?void 0:se.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"})]})]}),X==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Appearance",onBack:()=>$("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx("div",{className:"px-1 pt-1",children:e.jsx(xe,{label:"Brightness",icon:e.jsx(Vt,{className:"w-4 h-4"}),value:r.brightness,min:0,max:2,step:.1,onChange:l=>n==null?void 0:n.setBrightness(l),formatValue:l=>`${Math.round(l*100)}%`})}),e.jsx(de,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:bi.map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:l.value,themeColor:l.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${r.theme===l.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:l.label},l.value))})}),e.jsx(de,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:l}),className:`py-1.5 text-xs font-medium transition-colors ${r.iconSize===l?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:l.charAt(0).toUpperCase()+l.slice(1)},l))})}),e.jsxs(de,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:pi.map(l=>e.jsx("button",{title:l.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:l.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${r.themeColor===l.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:l.value,borderRadius:"var(--radius-full)"},children:r.themeColor===l.value&&e.jsx(Fe,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},l.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:r.themeColor,onChange:l=>n==null?void 0:n.setAppearance({themeColor:l.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:r.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},ms=m.useMemo(()=>{const c=[{html:"Playback",isLabel:!0},{html:"Loop",checked:r.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:r.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:r.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"21:9",checked:r.aspectRatio==="21:9",onClick:()=>n==null?void 0:n.setAspectRatio("21:9")},{separator:!0},{html:"Video Fit",isLabel:!0},{html:"Contain",checked:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")},{html:"Cover",checked:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")},{separator:!0},{html:"Video Info",icon:e.jsx(Js,{className:"w-3.5 h-3.5"}),onClick:()=>at(!0)},{separator:!0}];return h.contextmenu&&c.push(...h.contextmenu),c.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),c.push({html:"Close",onClick:w=>w(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),c},[h.contextmenu,r.aspectRatio,r.isLooping,r.videoFit,n]),fs=r.isWebFullscreen,It=e.jsxs("div",{id:h.id,ref:N,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset flex items-center justify-center ${fs?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius-player)]"} ${h.container||""}`,style:{touchAction:"manipulation","--accent":r.themeColor,"--accent-contrast":Yt},onMouseMove:kt,onMouseLeave:()=>{r.isPlaying&&!E&&!A&&!L&&n&&n.setControlsVisible(!1)},onMouseDown:St,onMouseUp:Ge,onTouchStart:ss,onTouchMove:is,onTouchEnd:ns,onContextMenu:rs,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":r.theme,children:[e.jsx("style",{children:`
|
|
31
31
|
[data-theme="default"] {
|
|
32
32
|
--radius: 0.75rem;
|
|
33
33
|
--radius-lg: 0.75rem;
|
|
34
34
|
--radius-sm: 0.375rem;
|
|
35
35
|
--radius-full: 9999px;
|
|
36
|
+
--radius-player: 0.25rem;
|
|
36
37
|
--font-main: "Inter", sans-serif;
|
|
37
38
|
--border-width: 0px;
|
|
38
39
|
--bg-panel: rgba(9, 9, 11, 0.95);
|
|
@@ -45,6 +46,7 @@ ${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`
|
|
|
45
46
|
--radius-lg: 0px;
|
|
46
47
|
--radius-sm: 0px;
|
|
47
48
|
--radius-full: 0px;
|
|
49
|
+
--radius-player: 0px;
|
|
48
50
|
--font-main: "Press Start 2P", cursive;
|
|
49
51
|
--border-width: 2px;
|
|
50
52
|
--bg-panel: #000000;
|
|
@@ -58,6 +60,7 @@ ${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`
|
|
|
58
60
|
--radius-lg: 6px;
|
|
59
61
|
--radius-sm: 2px;
|
|
60
62
|
--radius-full: 4px;
|
|
63
|
+
--radius-player: 4px;
|
|
61
64
|
--font-main: "Cinzel", serif;
|
|
62
65
|
--border-width: 1px;
|
|
63
66
|
--bg-panel: #0a0a0a;
|
|
@@ -70,6 +73,7 @@ ${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`
|
|
|
70
73
|
--radius-lg: 0px;
|
|
71
74
|
--radius-sm: 0px;
|
|
72
75
|
--radius-full: 0px;
|
|
76
|
+
--radius-player: 0px;
|
|
73
77
|
--font-main: "JetBrains Mono", monospace;
|
|
74
78
|
--border-width: 1px;
|
|
75
79
|
--bg-panel: #000000;
|
|
@@ -120,5 +124,5 @@ ${this.formatDuration(oe)} remaining`}this.notify({id:r,type:"loading",message:`
|
|
|
120
124
|
/* Override Backdrop for specific themes if needed */
|
|
121
125
|
[data-theme="pixel"] .strata-backdrop { backdrop-filter: none; background: #000; }
|
|
122
126
|
[data-theme="hacker"] .strata-backdrop { backdrop-filter: none; background: #000; }
|
|
123
|
-
`}),
|
|
127
|
+
`}),r.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(Ie,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),n&&e.jsxs(e.Fragment,{children:[(Pt=h.layers)==null?void 0:Pt.map((c,w)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${c.className||""}`,style:c.style,children:e.jsx(Ht,{content:c.html||"",className:"w-full h-full"})},w)),e.jsx(ci,{notifications:r.notifications}),e.jsx(di,{cues:r.activeCues,settings:r.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-[1] cursor-pointer",onClick:as,"aria-hidden":"true",role:"button",tabIndex:-1}),a&&!U&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none strata-poster",style:{backgroundImage:`url(${a})`}}),te.visible&&e.jsx(mi,{x:te.x,y:te.y,items:ms,onClose:M,containerWidth:me,containerHeight:ie}),Jt&&n&&e.jsx(fi,{player:n,onClose:()=>at(!1)}),Oe&&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 pointer-events-none",children:[e.jsx(Ys,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),Ce&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[r.isMuted||r.volume===0?e.jsx(At,{className:"w-10 h-10 text-white/80"}):e.jsx(Et,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${r.isMuted?0:r.volume*100}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.volume*100),"%"]})]}),ut&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[e.jsx(Vt,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${Math.min(100,r.brightness*100)}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.brightness*100),"%"]})]}),D&&Le&&r.controlsVisible&&e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),n.toggleLock()},className:`absolute left-4 md:left-6 bottom-24 md:bottom-28 z-50 p-3 rounded-full bg-black/50 backdrop-blur-md border border-white/10 text-white transition-all active:scale-95 ${r.isLocked?"text-[var(--accent)] bg-white/10":"hover:bg-white/10"}`,children:r.isLocked?e.jsx(_s,{className:"w-5 h-5"}):e.jsx(Xs,{className:"w-5 h-5"})}),re&&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 pointer-events-none ${re.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>Ne(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[re.type==="rewind"?e.jsx(Bt,{className:"w-12 h-12 animate-pulse"}):e.jsx(Dt,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:re.type==="rewind"?"-10s":"+10s"})]})},re.id),r.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(Ie,{className:"w-12 h-12 text-[var(--accent)] animate-spin drop-shadow-lg"})}),r.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:r.error}),e.jsx("button",{onClick:()=>n.load(n.store.get().sources[n.store.get().currentSourceIndex]||{url:t||"",type:s||"auto"},x),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"})]})}),O&&!r.isLocked&&(!r.isPlaying&&!r.isBuffering&&!r.error||r.controlsVisible)&&!r.isBuffering?e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-300 pointer-events-none ${r.controlsVisible||!r.isPlaying?"opacity-100":"opacity-0"}`,children:e.jsxs("div",{className:"flex items-center gap-8 md:gap-16 pointer-events-auto",children:[e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Bt,{className:le.skipIcon})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),n.togglePlay()},className:`group relative flex items-center justify-center rounded-full bg-white/10 hover:bg-[var(--accent)] border border-white/10 shadow-2xl transition-all duration-300 active:scale-90 active:opacity-80 focus:outline-none backdrop-blur-md ${le.playBtn}`,children:r.isPlaying?e.jsx($t,{className:`${le.playIcon} text-white fill-current`}):e.jsx(Lt,{className:`${le.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Dt,{className:le.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 ${hs?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:c=>{(E||A||L)&&M(),c.target===c.currentTarget&&fe(!1),c.stopPropagation()},children:[!h.isLive&&e.jsxs("div",{ref:We,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:os,onMouseLeave:()=>{xt(null),pt(null)},onMouseDown:Ct,onTouchStart:Ct,children:[(Ft=h.highlight)==null?void 0:Ft.map((c,w)=>e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-yellow-400 rounded-full z-10 pointer-events-none",style:{left:`${c.time/r.duration*100}%`},title:c.text},w)),ft!==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, ${es}%, calc(100% - 70px))`},children:[oe&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${oe.w*.5}px`,height:`${oe.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${oe.url}")`,width:`${oe.w}px`,height:`${oe.h}px`,backgroundPosition:`-${oe.x}px -${oe.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:Xe(ft)})]}),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:[r.duration>0&&r.buffered.map((c,w)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${c.start/r.duration*100}%`,width:`${(c.end-c.start)/r.duration*100}%`}},w)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(Ve?Se:r.currentTime)/r.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:`${(Ve?Se:r.currentTime)/r.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:zt.filter(c=>c.position==="left"||c.position==="center").map(Rt)}),e.jsx("div",{className:"flex items-center gap-1",children:zt.filter(c=>c.position==="right").map(Rt)})]})]})]})]});return r.isWebFullscreen&&typeof document<"u"?vs.createPortal(It,document.body):It},gi=(i,t)=>{const s=gs.createRoot(i);return s.render(m.createElement(Ze,t)),{unmount:()=>{s.unmount()},update:o=>{s.render(m.createElement(Ze,{...t,...o}))}}};exports.StrataCore=Gt;exports.StrataPlayer=Ze;exports.mountStrataPlayer=gi;
|
|
124
128
|
//# sourceMappingURL=strataplayer.cjs.js.map
|