strataplayer 1.2.13 → 1.2.14

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