ts-video-player 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cdn.min.js CHANGED
@@ -1,6 +1,6 @@
1
- function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown",streamType:"unknown",providerType:"unknown",loadingState:"idle",preload:"metadata",canPlay:!1,canPlayThrough:!1,error:null,playbackState:"idle",paused:!0,playing:!1,started:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:0,playbackRate:1,loop:!1,autoplay:!1,playsinline:!0,muted:!1,volume:1,buffered:[],bufferedAmount:0,seekable:[],videoWidth:0,videoHeight:0,aspectRatio:1.7777777777777777,qualities:[],autoQuality:!0,audioTracks:[],textTracks:[],fullscreen:!1,pictureInPicture:!1,canFullscreen:!1,canPictureInPicture:!1,volumeAvailability:"unavailable",fullscreenAvailability:"unavailable",pipAvailability:"unavailable",controlsVisible:!0,userActive:!0,pointerOver:!1,title:"",poster:""}}class q{state;listeners=new Map;_pendingKeys=null;_flushScheduled=!1;constructor(h){this.state={...Uh(),...h}}getState(){return this.state}get(h){return this.state[h]}set(h,b){if(this.state[h]===b)return;this.state={...this.state,[h]:b},this.scheduleNotify(h)}batch(h){for(let[b,w]of Object.entries(h))if(this.state[b]!==w)this.state[b]=w,this.scheduleNotify(b)}subscribe(h,b){if(typeof h==="function"){if(!this.listeners.has("*"))this.listeners.set("*",new Set);return this.listeners.get("*").add(h),()=>this.listeners.get("*")?.delete(h)}let w=h;if(!b)return()=>{};if(!this.listeners.has(w))this.listeners.set(w,new Set);return this.listeners.get(w).add(b),()=>this.listeners.get(w)?.delete(b)}reset(){this.state=Uh(),this._pendingKeys=null,this._flushScheduled=!1,this.notifyAll()}flush(){if(this._pendingKeys){let h=this._pendingKeys;this._pendingKeys=null,this._flushScheduled=!1;for(let b of h)this.notifyKey(b);this.notifyAll()}}scheduleNotify(h){if(!this._pendingKeys)this._pendingKeys=new Set;if(this._pendingKeys.add(h),!this._flushScheduled)this._flushScheduled=!0,queueMicrotask(()=>this.flush())}notifyKey(h){this.listeners.get(h)?.forEach((b)=>b(this.state,h))}notifyAll(){this.listeners.get("*")?.forEach((h)=>h(this.state))}}function Yh(h){if(h.duration===0||h.buffered.length===0)return 0;let b=0;for(let w of h.buffered)b+=w.end-w.start;return Math.min(b/h.duration,1)}var qh="ts-video-player";function Bh(h=localStorage){try{let b=h.getItem(qh);if(b)return JSON.parse(b)}catch{}return{}}function Y0(h,b=localStorage){try{let w=Bh(b);b.setItem(qh,JSON.stringify({...w,...h}))}catch{}}function Dh(h,b=["volume","muted","playbackRate"],w=localStorage){let C=Bh(w);if(C.volume!==void 0)h.set("volume",C.volume);if(C.muted!==void 0)h.set("muted",C.muted);if(C.playbackRate!==void 0)h.set("playbackRate",C.playbackRate);let M=b.map((z)=>h.subscribe(z,($)=>{let _=$[z];Y0({[z]:_},w)}));return()=>M.forEach((z)=>z())}class U{listeners=new Map;onceListeners=new Map;on(h,b){if(!this.listeners.has(h))this.listeners.set(h,new Set);return this.listeners.get(h).add(b),()=>this.off(h,b)}once(h,b){if(!this.onceListeners.has(h))this.onceListeners.set(h,new Set);return this.onceListeners.get(h).add(b),()=>this.onceListeners.get(h)?.delete(b)}off(h,b){this.listeners.get(h)?.delete(b),this.onceListeners.get(h)?.delete(b)}emit(h,...b){this.listeners.get(h)?.forEach((C)=>{try{C(...b)}catch(M){console.error(`[ts-video-player] Error in event handler for "${String(h)}":`,M)}});let w=this.onceListeners.get(h);if(w)w.forEach((C)=>{try{C(...b)}catch(M){console.error(`[ts-video-player] Error in once handler for "${String(h)}":`,M)}}),w.clear()}removeAllListeners(h){if(h)this.listeners.delete(h),this.onceListeners.delete(h);else this.listeners.clear(),this.onceListeners.clear()}listenerCount(h){return(this.listeners.get(h)?.size||0)+(this.onceListeners.get(h)?.size||0)}}class B{media;emitter;listeners=[];constructor(h,b){this.media=h,this.emitter=b,this.attachListeners()}attachListeners(){let h=(b,w)=>{this.media.addEventListener(b,w),this.listeners.push(()=>this.media.removeEventListener(b,w))};h("loadstart",()=>this.emitter.emit("loadstart")),h("loadedmetadata",()=>this.emitter.emit("loadedmetadata")),h("loadeddata",()=>this.emitter.emit("loadeddata")),h("canplay",()=>this.emitter.emit("canplay")),h("canplaythrough",()=>this.emitter.emit("canplaythrough")),h("play",()=>this.emitter.emit("play")),h("pause",()=>this.emitter.emit("pause")),h("playing",()=>this.emitter.emit("playing")),h("waiting",()=>this.emitter.emit("waiting")),h("ended",()=>this.emitter.emit("ended")),h("seeking",()=>this.emitter.emit("seeking")),h("seeked",()=>this.emitter.emit("seeked")),h("timeupdate",()=>this.emitter.emit("timeupdate",this.media.currentTime)),h("durationchange",()=>this.emitter.emit("durationchange",this.media.duration)),h("volumechange",()=>this.emitter.emit("volumechange",this.media.volume,this.media.muted)),h("ratechange",()=>this.emitter.emit("ratechange",this.media.playbackRate)),h("progress",()=>{let b=this.getTimeRanges(this.media.buffered);this.emitter.emit("progress",b)}),h("error",()=>{let b=this.normalizeError(this.media.error);this.emitter.emit("error",b)})}getTimeRanges(h){let b=[];for(let w=0;w<h.length;w++)b.push({start:h.start(w),end:h.end(w)});return b}normalizeError(h){if(!h)return{code:0,message:"Unknown error"};let b={1:"The fetching of the media resource was aborted by the user agent.",2:"A network error occurred while fetching the media resource.",3:"An error occurred while decoding the media resource.",4:"The media resource is not supported."};return{code:h.code,message:b[h.code]||h.message||"Unknown error"}}destroy(){this.listeners.forEach((h)=>h()),this.listeners=[]}}function k(h){let b=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],w=()=>{let C=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);h(C)};return b.forEach((C)=>document.addEventListener(C,w)),()=>{b.forEach((C)=>document.removeEventListener(C,w))}}function y(h,b){let w=()=>b(!0),C=()=>b(!1);return h.addEventListener("enterpictureinpicture",w),h.addEventListener("leavepictureinpicture",C),()=>{h.removeEventListener("enterpictureinpicture",w),h.removeEventListener("leavepictureinpicture",C)}}var q0={" ":"togglePlay",k:"togglePlay",m:"toggleMute",f:"toggleFullscreen",i:"togglePiP",c:"toggleCaptions",ArrowLeft:"seekBackward",ArrowRight:"seekForward",j:"seekBackward",l:"seekForward",ArrowUp:"volumeUp",ArrowDown:"volumeDown",">":"speedUp","<":"speedDown",Home:"seekStart",End:"seekEnd","0":"seek0","1":"seek10","2":"seek20","3":"seek30","4":"seek40","5":"seek50","6":"seek60","7":"seek70","8":"seek80","9":"seek90"};function Oh(h,b={}){let{seekStep:w=5,volumeStep:C=0.1,speedStep:M=0.25}=b;return(z)=>{if(z.target instanceof HTMLInputElement||z.target instanceof HTMLTextAreaElement||z.target instanceof HTMLSelectElement||z.target?.isContentEditable)return;let $=z.key,_=q0[$];if(!_)return;switch(z.preventDefault(),_){case"togglePlay":h.togglePlay();break;case"toggleMute":h.toggleMute();break;case"toggleFullscreen":h.toggleFullscreen();break;case"togglePiP":h.togglePiP();break;case"toggleCaptions":h.toggleCaptions();break;case"seekBackward":h.seekBackward();break;case"seekForward":h.seekForward();break;case"volumeUp":h.volumeUp();break;case"volumeDown":h.volumeDown();break;case"speedUp":h.speedUp();break;case"speedDown":h.speedDown();break;case"seekStart":h.seekStart();break;case"seekEnd":h.seekEnd();break;default:if(_.startsWith("seek")){let H=parseInt(_.replace("seek",""),10);if(!isNaN(H))h.seekPercent(H)}}}}function Ph(h,b={}){let{timeout:w=3000,onActive:C,onInactive:M}=b,z=null,$=!0,_=()=>{if(!$)$=!0,C?.();W()},H=()=>{if($)$=!1,M?.()},W=()=>{if(z)clearTimeout(z);z=setTimeout(H,w)},N=["mousemove","mouseenter","mouseleave","mousedown","keydown","touchstart","touchmove"];return N.forEach((Z)=>h.addEventListener(Z,_)),W(),()=>{if(z)clearTimeout(z);N.forEach((Z)=>h.removeEventListener(Z,_))}}function Ih(){return typeof navigator<"u"&&"mediaSession"in navigator}function Sh(h,b,w){if(!Ih())return()=>{};let C=navigator.mediaSession;if(w)B0(w);let M=[["play",()=>b.play()],["pause",()=>b.pause()],["stop",()=>b.stop()],["seekbackward",(W)=>{let N=W.seekOffset||-10;b.seekBy(N)}],["seekforward",(W)=>{let N=W.seekOffset||10;b.seekBy(N)}],["seekto",(W)=>{let N=W.seekTime;if(N!==void 0)b.seekTo(N)}]];for(let[W,N]of M)try{C.setActionHandler(W,N)}catch{}let z=h.subscribe("paused",(W)=>{C.playbackState=W.paused?"paused":"playing"}),$=null,_=()=>{let W=h.getState();if(!isFinite(W.duration)||W.duration<=0)return;try{C.setPositionState({duration:W.duration,playbackRate:W.playbackRate,position:Math.min(W.currentTime,W.duration)})}catch{}},H=h.subscribe("playing",(W)=>{if(W.playing){if(_(),!$)$=setInterval(_,1000)}else{if($)clearInterval($),$=null;_()}});return()=>{if($)clearInterval($);z(),H();for(let[W]of M)try{C.setActionHandler(W,null)}catch{}}}function B0(h){if(!Ih())return;navigator.mediaSession.metadata=new MediaMetadata({title:h.title||"",artist:h.artist||"",album:h.album||"",artwork:h.artwork||[]})}function Th(){return typeof screen<"u"&&"orientation"in screen&&typeof screen.orientation.lock==="function"}function uh(h){if(!Th())return;let b={landscape:"landscape",portrait:"portrait",any:"any"};screen.orientation.lock(b[h]).catch(()=>{})}function xh(){if(!Th())return;try{screen.orientation.unlock()}catch{}}function D0(){if(typeof navigator>"u")return!1;let h=navigator.userAgent;if(/iPad|iPhone|iPod/.test(h)&&!window.MSStream)return!0;if(navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)return!0;return!1}function O0(){if(typeof navigator>"u")return!1;return/^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent)}function kh(){if(typeof window>"u")return!1;return navigator.standalone===!0||window.matchMedia("(display-mode: standalone)").matches}function yh(h){if(D0())return"unsupported";if(!h)return"unavailable";return"available"}async function vh(h){let b=h.volume;try{let w=b===1?0.5:1;h.volume=w,await new Promise((M)=>setTimeout(M,0));let C=h.volume!==b;return h.volume=b,C?"available":"unsupported"}catch{try{h.volume=b}catch{}return"unsupported"}}function gh(h,b){let w=typeof document<"u"?document:null;if(!w)return"unsupported";if(w.fullscreenEnabled||w.webkitFullscreenEnabled)return"available";if(w.mozFullScreenEnabled||w.msFullscreenEnabled)return"available";if(b){let C=b;if(C.webkitSupportsFullscreen===!0)return"available";if(typeof C.webkitEnterFullscreen==="function")return"available"}if(!h&&!b)return"unavailable";return"unsupported"}async function ph(h,b){let w=b;if(h){let C=h;if(typeof C.requestFullscreen==="function")return C.requestFullscreen();if(typeof C.webkitRequestFullscreen==="function")return C.webkitRequestFullscreen();if(typeof C.webkitRequestFullScreen==="function")return C.webkitRequestFullScreen()}if(w&&typeof w.webkitEnterFullscreen==="function"){w.webkitEnterFullscreen();return}if(b&&typeof b.requestFullscreen==="function")return b.requestFullscreen()}async function mh(h){let b=document,w=h;if(typeof b.exitFullscreen==="function")return b.exitFullscreen();if(typeof b.webkitExitFullscreen==="function")return b.webkitExitFullscreen();if(typeof b.webkitCancelFullScreen==="function")return b.webkitCancelFullScreen();if(w&&typeof w.webkitExitFullscreen==="function")w.webkitExitFullscreen()}function lh(h){if(!h)return"unavailable";if("requestPictureInPicture"in h){if(typeof document<"u"&&document.pictureInPictureEnabled===!1)return"unavailable";if(O0()&&kh())return"unavailable";return"available"}let b=h;if(typeof b.webkitSetPresentationMode==="function"){if(kh())return"unavailable";if(typeof b.webkitSupportsPresentationMode==="function")return b.webkitSupportsPresentationMode("picture-in-picture")?"available":"unsupported";return"available"}return"unsupported"}async function fh(h){let b=h;if(typeof b.requestPictureInPicture==="function"){await b.requestPictureInPicture();return}if(typeof b.webkitSetPresentationMode==="function")b.webkitSetPresentationMode("picture-in-picture")}async function dh(h){if(document.pictureInPictureElement&&typeof document.exitPictureInPicture==="function"){await document.exitPictureInPicture();return}if(h){let b=h;if(b.webkitPresentationMode==="picture-in-picture"&&typeof b.webkitSetPresentationMode==="function")b.webkitSetPresentationMode("inline")}}class F{container=null;options={};events=new U;_ready=!1;get mediaElement(){return null}get ready(){return this._ready}async setup(h,b){this.container=h,this.options=b,await this.initialize(),this._ready=!0,this.events.emit("ready")}destroy(){this._ready=!1,this.cleanup(),this.events.removeAllListeners()}stop(){this.pause(),this.seekTo(0)}getQualities(){return[]}setQuality(h){}getTextTracks(){return[]}setTextTrackMode(h,b){}getAudioTracks(){return[]}setAudioTrack(h){}getFeatureAvailability(h){let b=this.mediaElement,w=b instanceof HTMLMediaElement?b:null,C=b instanceof HTMLVideoElement?b:null;switch(h){case"volume":return b&&!(b instanceof HTMLMediaElement)?"available":yh(w);case"fullscreen":return gh(this.container,C);case"pip":return b&&!(b instanceof HTMLMediaElement)?"unsupported":lh(C);default:return"unsupported"}}async enterFullscreen(){await ph(this.container,this.mediaElement)}async exitFullscreen(){await mh(this.mediaElement)}getFullscreenElement(){return this.container}async enterPiP(){let h=this.mediaElement;if(!h)return;await fh(h)}async exitPiP(){await dh(this.mediaElement)}on(h,b){this.events.on(h,b)}off(h,b){this.events.off(h,b)}emitError(h,b,w){let C={code:h,message:b,details:w};this.events.emit("error",C)}}function ch(h){if(typeof h==="string"){let b=t(h);if(b==="mp4"||b==="webm"||b==="ogg"||b==="ogv"||b==="mov"||b==="mp3"||b==="wav"||b==="flac"||b==="m4a"||b==="aac"||b==="oga"||b==="opus")return!0;return!1}if(typeof h==="object"&&"type"in h){let b=h.type?.toLowerCase()||"";return b.startsWith("video/")||b.startsWith("audio/")||b==="application/ogg"}return!1}function t(h){let b=h.split(/[?#]/,1)[0];return b.slice(b.lastIndexOf(".")+1).toLowerCase()}function th(h){let b=t(h);return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",flac:"audio/flac",m4a:"audio/mp4",aac:"audio/aac",oga:"audio/ogg",opus:"audio/ogg; codecs=opus"}[b||""]||"video/mp4"}class v extends F{name="html5";type="video";media=null;eventsNormalizer=null;cleanupFullscreen=null;cleanupPiP=null;isAudio=!1;get mediaElement(){return this.media}async initialize(){if(!this.container)throw Error("Container element is required");if(this.isAudio=this.options.mediaType==="audio",this.media=document.createElement(this.isAudio?"audio":"video"),this.media.className="ts-video-player__media",this.options.autoplay)this.media.autoplay=!0;if(this.options.loop)this.media.loop=!0;if(this.options.muted)this.media.muted=!0;if(this.options.playsinline&&!this.isAudio)this.media.playsInline=!0;if(this.options.preload)this.media.preload=this.options.preload;if(this.options.crossorigin)this.media.crossOrigin=this.options.crossorigin;if(this.options.controlsList?.length)this.media.setAttribute("controlslist",this.options.controlsList.join(" "));if(!this.isAudio&&this.options.disablePictureInPicture)this.media.disablePictureInPicture=!0;if(this.options.poster&&!this.isAudio)this.media.poster=this.options.poster;if(this.options.volume!==void 0)this.media.volume=this.options.volume;this.container.appendChild(this.media);for(let h of this.options.tracks??[])this.addTextTrack(h);if(this.eventsNormalizer=new B(this.media,this.events),this.cleanupFullscreen=k((h)=>{this.events.emit("fullscreenchange",h)}),!this.isAudio&&this.media instanceof HTMLVideoElement)this.cleanupPiP=y(this.media,(h)=>{this.events.emit("pipchange",h)});if(!this.isAudio)this.media.addEventListener("loadedmetadata",()=>{let h=this.media,b=this.getFeatureAvailability("fullscreen"),w=this.getFeatureAvailability("pip"),C=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:h.videoWidth,videoHeight:h.videoHeight,aspectRatio:(h.videoHeight>0?h.videoWidth/h.videoHeight:0)||1.7777777777777777,canFullscreen:b==="available",canPictureInPicture:w==="available",fullscreenAvailability:b,pipAvailability:w,volumeAvailability:C}),this.events.emit("availabilitychange","fullscreen",b),this.events.emit("availabilitychange","pip",w),this.events.emit("availabilitychange","volume",C)});if(this.media.addEventListener("loadeddata",()=>{if(!this.media)return;vh(this.media).then((h)=>{this.events.emit("statechange",{volumeAvailability:h}),this.events.emit("availabilitychange","volume",h)}).catch(()=>{})}),!this.isAudio&&this.media instanceof HTMLVideoElement)this.media.addEventListener("webkitpresentationmodechanged",()=>{let h=this.media;if(h?.webkitPresentationMode){let b=h.webkitPresentationMode==="picture-in-picture";this.events.emit("pipchange",b)}})}cleanup(){if(this.eventsNormalizer?.destroy(),this.cleanupFullscreen?.(),this.cleanupPiP?.(),this.media)this.media.pause(),this.media.removeAttribute("src"),this.media.load(),this.media.remove(),this.media=null}canPlay(h){return ch(h)}async load(h){if(!this.media)return;this.media.innerHTML="",this.media.removeAttribute("src");let b=Array.isArray(h)?h:[h];for(let w of b)if(typeof w==="string"){let C=document.createElement("source");C.src=w,C.type=th(w),this.media.appendChild(C)}else if("src"in w&&typeof w.src==="string"){let C=w,M=document.createElement("source");M.src=C.src,M.type=C.type||th(C.src),this.media.appendChild(M)}this.media.load()}async play(){if(!this.media)return;try{await this.media.play()}catch(h){if(h.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",h);else throw h}}pause(){this.media?.pause()}seekTo(h){if(this.media)this.media.currentTime=Math.max(0,Math.min(h,this.getDuration()))}getCurrentTime(){return this.media?.currentTime||0}getDuration(){return this.media?.duration||0}setVolume(h){if(this.media)this.media.volume=Math.max(0,Math.min(1,h))}getVolume(){return this.media?.volume||1}setMuted(h){if(this.media)this.media.muted=h}getMuted(){return this.media?.muted||!1}setPlaybackRate(h){if(this.media)this.media.playbackRate=Math.max(0.25,Math.min(4,h))}getPlaybackRate(){return this.media?.playbackRate||1}getTextTracks(){if(!this.media)return[];let h=[],b=this.media.textTracks;for(let w=0;w<b.length;w++){let C=b[w];h.push({id:String(w),kind:C.kind,label:C.label||`Track ${w+1}`,language:C.language||"",mode:C.mode,cues:this.getTrackCues(C)})}return h}getTrackCues(h){if(!h.cues)return[];let b=[];for(let w=0;w<h.cues.length;w++){let C=h.cues[w];b.push({id:C.id||String(w),startTime:C.startTime,endTime:C.endTime,text:C.text})}return b}setTextTrackMode(h,b){if(!this.media)return;let w=parseInt(h,10),C=this.media.textTracks[w];if(C)C.mode=b,this.events.emit("texttrackchange",b==="showing"?this.getTextTracks()[w]:null)}getAudioTracks(){if(!this.media||this.isAudio)return[];let h=this.media;if(!("audioTracks"in h))return[];let b=h.audioTracks,w=[];for(let C=0;C<b.length;C++){let M=b[C];w.push({id:M.id||String(C),label:M.label||`Track ${C+1}`,language:M.language||"",kind:M.kind||"",selected:M.enabled})}return w}setAudioTrack(h){if(!this.media||this.isAudio)return;let b=this.media;if(!("audioTracks"in b))return;let w=b.audioTracks;for(let C=0;C<w.length;C++){let M=w[C].id===h||String(C)===h;w[C].enabled=M}this.events.emit("audiotrackchange",this.getAudioTracks().find((C)=>C.selected)||null)}addTextTrack(h){if(!this.media)return;let b=document.createElement("track");if(h.src)b.src=h.src;if(b.kind=h.kind||"subtitles",b.label=h.label||"",b.srclang=h.language||"",h.default)b.default=!0;this.media.appendChild(b)}}var oh={name:"html5",type:"video",canPlay(h){return ch(h)},mediaType(h){if(typeof h==="string"){let b=t(h);if(["mp3","wav","flac","m4a","aac","oga","opus"].includes(b))return"audio";return"video"}if(typeof h==="object"&&"type"in h){if((h.type?.toLowerCase()||"").startsWith("audio/"))return"audio"}return"video"},async load(h,b){let w=new v;return await w.setup(h,b),w}};var P0=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/youtube\.com\/v\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/];function c(h){for(let b of P0){let w=h.match(b);if(w)return w[1]}return null}function sh(h){if(typeof h==="string")return c(h)!==null;if(typeof h==="object"&&"type"in h)return h.type==="youtube";return!1}function I0(h){if(typeof h==="string"){let b=c(h);if(!b)return null;let w=new URL(h,"https://youtube.com"),C=w.searchParams.get("t")||w.searchParams.get("start"),M=w.searchParams.get("end");return{videoId:b,startTime:C?nh(C):void 0,endTime:M?nh(M):void 0}}if(typeof h==="object"&&"type"in h&&h.type==="youtube"){let b=h;return{videoId:b.videoId||c(b.src)||"",startTime:b.startTime,endTime:b.endTime}}return null}function nh(h){if(/^\d+$/.test(h))return parseInt(h,10);let b=h.match(/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?/);if(b){let C=parseInt(b[1]||"0",10),M=parseInt(b[2]||"0",10),z=parseInt(b[3]||"0",10);return C*3600+M*60+z}let w=h.split(":").map((C)=>parseInt(C,10));if(w.length===2)return w[0]*60+w[1];if(w.length===3)return w[0]*3600+w[1]*60+w[2];return 0}class g extends F{name="youtube";type="youtube";player=null;iframe=null;pendingVideoId=null;startTime;endTime;timeUpdateInterval=null;lastState=-1;get mediaElement(){return this.iframe}async initialize(){if(!this.container)throw Error("Container element is required");await this.loadYouTubeAPI();let h=document.createElement("div");h.id=`ts-video-player-yt-${Date.now()}`,h.className="ts-video-player__youtube",this.container.appendChild(h);let b={autoplay:this.options.autoplay?1:0,controls:0,disablekb:1,enablejsapi:1,iv_load_policy:3,modestbranding:1,playsinline:this.options.playsinline?1:0,rel:0,origin:window.location.origin};if(this.options.youtubeParams)Object.assign(b,this.options.youtubeParams);b.host="https://www.youtube-nocookie.com",this.player=new window.YT.Player(h.id,{width:"100%",height:"100%",playerVars:b,events:{onReady:()=>this.onReady(),onStateChange:(w)=>this.onStateChange(w),onError:(w)=>this.onError(w),onPlaybackQualityChange:()=>this.onQualityChange(),onPlaybackRateChange:()=>this.onRateChange()}}),this.iframe=this.player.getIframe(),this.iframe.className="ts-video-player__media"}async loadYouTubeAPI(){if(window.YT?.Player)return;return new Promise((h)=>{if(document.querySelector('script[src*="youtube.com/iframe_api"]')){let w=()=>{if(window.YT?.Player)h();else setTimeout(w,100)};w();return}let b=document.createElement("script");b.src="https://www.youtube.com/iframe_api",b.async=!0,window.onYouTubeIframeAPIReady=()=>{h()},document.head.appendChild(b)})}cleanup(){if(this.timeUpdateInterval)clearInterval(this.timeUpdateInterval),this.timeUpdateInterval=null;this.player?.destroy(),this.player=null,this.iframe=null}onReady(){if(this.timeUpdateInterval=setInterval(()=>{if(this.player&&this.lastState===1)this.events.emit("timeupdate",this.getCurrentTime())},250),this.events.emit("loadedmetadata"),this.events.emit("canplay"),this.pendingVideoId)this.loadVideo(this.pendingVideoId,this.startTime,this.endTime),this.pendingVideoId=null}onStateChange(h){let b=h.data;this.lastState=b;let w=window.YT.PlayerState;switch(b){case w.UNSTARTED:this.events.emit("loadstart");break;case w.PLAYING:this.events.emit("play"),this.events.emit("playing"),this.events.emit("statechange",{paused:!1,playing:!0,waiting:!1});break;case w.PAUSED:this.events.emit("pause"),this.events.emit("statechange",{paused:!0,playing:!1});break;case w.BUFFERING:this.events.emit("waiting"),this.events.emit("statechange",{waiting:!0});break;case w.ENDED:this.events.emit("ended"),this.events.emit("statechange",{ended:!0,playing:!1});break;case w.CUED:this.events.emit("loadeddata"),this.events.emit("durationchange",this.getDuration());break}}onError(h){let b={2:"Invalid video ID",5:"HTML5 player error",100:"Video not found or removed",101:"Video cannot be embedded",150:"Video cannot be embedded"};this.emitError(h.data,b[h.data]||"Unknown YouTube error")}onQualityChange(){let h=this.player?.getPlaybackQuality()||"auto",b=this.getQualities();this.events.emit("qualitychange",b.find((w)=>w.id===h)||null)}onRateChange(){this.events.emit("ratechange",this.getPlaybackRate())}canPlay(h){return sh(h)}async load(h){let b=I0(h);if(!b){this.emitError(2,"Invalid YouTube source");return}if(this.startTime=b.startTime,this.endTime=b.endTime,!this.player||!this._ready){this.pendingVideoId=b.videoId;return}this.loadVideo(b.videoId,b.startTime,b.endTime)}loadVideo(h,b,w){if(!this.player)return;if(this.options.autoplay)this.player.loadVideoById({videoId:h,startSeconds:b,endSeconds:w});else this.player.cueVideoById({videoId:h,startSeconds:b,endSeconds:w})}async play(){this.player?.playVideo()}pause(){this.player?.pauseVideo()}stop(){this.player?.stopVideo()}seekTo(h){this.player?.seekTo(h,!0),this.events.emit("seeking"),setTimeout(()=>this.events.emit("seeked"),100)}getCurrentTime(){return this.player?.getCurrentTime()||0}getDuration(){return this.player?.getDuration()||0}setVolume(h){this.player?.setVolume(Math.round(h*100)),this.events.emit("volumechange",h,this.getMuted())}getVolume(){return(this.player?.getVolume()||100)/100}setMuted(h){if(h)this.player?.mute();else this.player?.unMute();this.events.emit("volumechange",this.getVolume(),h)}getMuted(){return this.player?.isMuted()||!1}setPlaybackRate(h){this.player?.setPlaybackRate(h)}getPlaybackRate(){return this.player?.getPlaybackRate()||1}getQualities(){let h=this.player?.getAvailableQualityLevels()||[],b={highres:2160,hd2160:2160,hd1440:1440,hd1080:1080,hd720:720,large:480,medium:360,small:240,tiny:144},w=this.player?.getPlaybackQuality();return h.map((C)=>({id:C,width:Math.round((b[C]||480)*1.7777777777777777),height:b[C]||480,bitrate:0,selected:C===w}))}setQuality(h){if(h==="auto")this.player?.setPlaybackQuality("default");else this.player?.setPlaybackQuality(h.id)}}var ih={name:"youtube",type:"youtube",canPlay(h){return sh(h)},mediaType(){return"video"},preconnect(){return["https://www.youtube-nocookie.com","https://www.youtube.com","https://i.ytimg.com","https://s.ytimg.com"]},async load(h,b){let w=new g;return await w.setup(h,b),w}};var S0=[/vimeo\.com\/(\d+)/,/vimeo\.com\/video\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/,/vimeo\.com\/channels\/[\w]+\/(\d+)/,/vimeo\.com\/groups\/[\w]+\/videos\/(\d+)/];function o(h){for(let b of S0){let w=h.match(b);if(w)return w[1]}return null}function T0(h){let b=h.match(/vimeo\.com\/\d+\/([a-f0-9]+)/);return b?b[1]:null}function rh(h){if(typeof h==="string")return o(h)!==null;if(typeof h==="object"&&"type"in h)return h.type==="vimeo";return!1}function u0(h){if(typeof h==="string"){let b=o(h);if(!b)return null;return{videoId:b,hash:T0(h)||void 0}}if(typeof h==="object"&&"type"in h&&h.type==="vimeo"){let b=h;return{videoId:b.videoId||o(b.src)||"",hash:b.hash}}return null}var ah="https://player.vimeo.com/api/player.js";class eh extends F{name="vimeo";type="vimeo";container_el=null;player=null;iframe=null;timeUpdateInterval=null;_qualities=[];_duration=0;get mediaElement(){return this.iframe}async initialize(){if(!this.container)throw Error("Container element is required");await this.loadVimeoSDK(),this.container_el=document.createElement("div"),this.container_el.className="ts-video-player__vimeo",this.container.appendChild(this.container_el)}async loadVimeoSDK(){if(window.Vimeo)return;return new Promise((h,b)=>{if(document.querySelector(`script[src="${ah}"]`)){let C=()=>{if(window.Vimeo)h();else setTimeout(C,100)};C();return}let w=document.createElement("script");w.src=ah,w.async=!0,w.onload=()=>h(),w.onerror=()=>b(Error("Failed to load Vimeo SDK")),document.head.appendChild(w)})}cleanup(){if(this.timeUpdateInterval)clearInterval(this.timeUpdateInterval),this.timeUpdateInterval=null;this.player?.destroy(),this.player=null,this.iframe=null,this.container_el?.remove(),this.container_el=null}canPlay(h){return rh(h)}async load(h){let b=u0(h);if(!b||!this.container_el){this.emitError(2,"Invalid Vimeo source");return}if(this.player)await this.player.destroy(),this.player=null;let w={id:parseInt(b.videoId,10),autopause:!1,autoplay:this.options.autoplay||!1,controls:!1,loop:this.options.loop||!1,muted:this.options.muted||!1,playsinline:this.options.playsinline!==!1,responsive:!0,dnt:!0};if(this.options.vimeoParams)Object.assign(w,this.options.vimeoParams);if(this.player=new window.Vimeo.Player(this.container_el,w),await this.player.ready(),this.iframe=this.container_el.querySelector("iframe"),this.iframe)this.iframe.className="ts-video-player__media";this.attachVimeoEvents(),this.events.emit("loadedmetadata"),this.events.emit("canplay"),this._duration=await this.player.getDuration(),this.events.emit("durationchange",this._duration),await this.updateQualities();let[C,M]=await Promise.all([this.player.getVideoWidth(),this.player.getVideoHeight()]);this.events.emit("statechange",{videoWidth:C,videoHeight:M,aspectRatio:C/M||1.7777777777777777,canFullscreen:!0,canPictureInPicture:!1})}attachVimeoEvents(){if(!this.player)return;this.player.on("play",()=>{this.events.emit("play"),this.events.emit("playing"),this.events.emit("statechange",{paused:!1,playing:!0})}),this.player.on("pause",()=>{this.events.emit("pause"),this.events.emit("statechange",{paused:!0,playing:!1})}),this.player.on("ended",()=>{this.events.emit("ended"),this.events.emit("statechange",{ended:!0,playing:!1})}),this.player.on("timeupdate",(h)=>{this.events.emit("timeupdate",h.seconds)}),this.player.on("seeking",()=>{this.events.emit("seeking")}),this.player.on("seeked",()=>{this.events.emit("seeked")}),this.player.on("bufferstart",()=>{this.events.emit("waiting"),this.events.emit("statechange",{waiting:!0})}),this.player.on("bufferend",()=>{this.events.emit("statechange",{waiting:!1})}),this.player.on("progress",(h)=>{let b=[{start:0,end:h.percent*this._duration}];this.events.emit("progress",b)}),this.player.on("volumechange",async()=>{let[h,b]=await Promise.all([this.player.getVolume(),this.player.getMuted()]);this.events.emit("volumechange",h,b)}),this.player.on("playbackratechange",(h)=>{this.events.emit("ratechange",h.playbackRate)}),this.player.on("qualitychange",async()=>{await this.updateQualities();let h=this._qualities.find((b)=>b.selected);this.events.emit("qualitychange",h||null)}),this.player.on("error",(h)=>{this.emitError(5,h.message,h)})}async updateQualities(){if(!this.player)return;try{let h=await this.player.getQualities();this._qualities=h.map((b)=>{let w=b.label.match(/(\d+)p/),C=w?parseInt(w[1],10):0;return{id:b.id,width:Math.round(C*1.7777777777777777),height:C,bitrate:0,selected:b.active}}),this.events.emit("statechange",{qualities:this._qualities})}catch{}}async play(){try{await this.player?.play()}catch(h){if(h.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",h);else throw h}}pause(){this.player?.pause()}stop(){this.pause(),this.seekTo(0)}seekTo(h){this.player?.setCurrentTime(h)}getCurrentTime(){return 0}getDuration(){return this._duration}setVolume(h){this.player?.setVolume(Math.max(0,Math.min(1,h)))}getVolume(){return 1}setMuted(h){this.player?.setMuted(h)}getMuted(){return!1}setPlaybackRate(h){this.player?.setPlaybackRate(h)}getPlaybackRate(){return 1}getQualities(){return this._qualities}setQuality(h){if(!this.player)return;if(h==="auto")this.player.setQuality("auto");else this.player.setQuality(h.id)}async enableTextTrack(h){await this.player?.enableTextTrack(h)}async disableTextTrack(){await this.player?.disableTextTrack()}async getChapters(){if(!this.player)return[];try{return await this.player.getChapters()}catch{return[]}}}var h0={name:"vimeo",type:"vimeo",canPlay(h){return rh(h)},mediaType(){return"video"},preconnect(){return["https://player.vimeo.com","https://i.vimeocdn.com","https://f.vimeocdn.com"]},async load(h,b){let w=new eh;return await w.setup(h,b),w}};function b0(h){if(typeof h==="string"){let b=h.toLowerCase();return b.endsWith(".m3u8")||b.includes("application/x-mpegurl")||b.includes("application/vnd.apple.mpegurl")}if(typeof h==="object"&&"type"in h){let b=h.type?.toLowerCase()||"";return b==="application/x-mpegurl"||b==="application/vnd.apple.mpegurl"}return!1}function x0(){return document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}var k0="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js";class p extends F{name="hls";type="hls";video=null;hls=null;eventsNormalizer=null;cleanupFullscreen=null;cleanupPiP=null;useNativeHLS=!1;_qualities=[];_audioTracks=[];_textTracks=[];currentQualityIndex=-1;get mediaElement(){return this.video}get canLiveSync(){return!this.useNativeHLS&&this.hls!==null}get hlsConfig(){return this.hls?.config||{}}async initialize(){if(!this.container)throw Error("Container element is required");if(this.video=document.createElement("video"),this.video.className="ts-video-player__media",this.options.autoplay)this.video.autoplay=!0;if(this.options.loop)this.video.loop=!0;if(this.options.muted)this.video.muted=!0;if(this.options.playsinline)this.video.playsInline=!0;if(this.options.preload)this.video.preload=this.options.preload;if(this.options.crossorigin)this.video.crossOrigin=this.options.crossorigin;if(this.options.poster)this.video.poster=this.options.poster;if(this.options.volume!==void 0)this.video.volume=this.options.volume;if(this.container.appendChild(this.video),this.eventsNormalizer=new B(this.video,this.events),this.cleanupFullscreen=k((h)=>{this.events.emit("fullscreenchange",h)}),this.cleanupPiP=y(this.video,(h)=>{this.events.emit("pipchange",h)}),this.useNativeHLS=x0(),!this.useNativeHLS)await this.loadHLSLibrary();this.video.addEventListener("loadedmetadata",()=>{let h=this.getFeatureAvailability("fullscreen"),b=this.getFeatureAvailability("pip"),w=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:this.video.videoWidth,videoHeight:this.video.videoHeight,aspectRatio:(this.video.videoHeight>0?this.video.videoWidth/this.video.videoHeight:0)||1.7777777777777777,canFullscreen:h==="available",canPictureInPicture:b==="available",fullscreenAvailability:h,pipAvailability:b,volumeAvailability:w}),this.events.emit("availabilitychange","fullscreen",h),this.events.emit("availabilitychange","pip",b),this.events.emit("availabilitychange","volume",w)})}async loadHLSLibrary(){if(window.Hls)return;return new Promise((h,b)=>{let w=document.createElement("script");w.src=this.options.hlsCdnUrl||k0,w.async=!0,w.onload=()=>h(),w.onerror=()=>b(Error("Failed to load HLS.js")),document.head.appendChild(w)})}cleanup(){if(this.eventsNormalizer?.destroy(),this.cleanupFullscreen?.(),this.cleanupPiP?.(),this.hls)this.hls.destroy(),this.hls=null;if(this.video)this.video.pause(),this.video.removeAttribute("src"),this.video.load(),this.video.remove(),this.video=null;this._qualities=[],this._audioTracks=[],this._textTracks=[]}canPlay(h){return b0(h)}async load(h){if(!this.video)return;let b=typeof h==="string"?h:h.src;if(this.useNativeHLS){this.video.src=b,this.video.load();return}if(!window.Hls)await this.loadHLSLibrary();if(!window.Hls?.isSupported()){this.emitError(4,"HLS is not supported in this browser");return}if(this.hls)this.hls.destroy();let w={enableWorker:!0,lowLatencyMode:!1,...this.options.hlsConfig};this.hls=new window.Hls(w),this.attachHLSEvents(),this.hls.attachMedia(this.video),this.hls.loadSource(b)}attachHLSEvents(){if(!this.hls||!window.Hls)return;let h=window.Hls;this.hls.on(h.Events.MANIFEST_PARSED,(b,w)=>{if(this.updateQualities(w.levels),this.options.autoplay)this.video?.play().catch(()=>{})}),this.hls.on(h.Events.LEVEL_SWITCHED,(b,w)=>{this.currentQualityIndex=w.level,this.updateQualitySelection(),this.events.emit("qualitychange",this._qualities[w.level]||null)}),this.hls.on(h.Events.AUDIO_TRACK_LOADED,()=>{this.updateAudioTracks()}),this.hls.on(h.Events.AUDIO_TRACK_SWITCHED,()=>{this.updateAudioTracks();let b=this._audioTracks.find((w)=>w.selected);this.events.emit("audiotrackchange",b||null)}),this.hls.on(h.Events.SUBTITLE_TRACK_LOADED,()=>{this.updateTextTracks()}),this.hls.on(h.Events.ERROR,(b,w)=>{if(w.fatal)switch(w.type){case h.ErrorTypes.NETWORK_ERROR:this.hls?.startLoad();break;case h.ErrorTypes.MEDIA_ERROR:this.hls?.recoverMediaError();break;default:this.emitError(5,`HLS fatal error: ${w.details}`,w),this.hls?.destroy();break}})}updateQualities(h){this._qualities=h.map((b,w)=>({id:String(w),width:b.width,height:b.height,bitrate:b.bitrate,codec:b.codecSet||b.videoCodec||void 0,selected:w===this.currentQualityIndex})),this.events.emit("statechange",{qualities:this._qualities})}updateQualitySelection(){this._qualities=this._qualities.map((h,b)=>({...h,selected:b===this.currentQualityIndex}))}updateAudioTracks(){if(!this.hls)return;this._audioTracks=this.hls.audioTracks.map((h,b)=>({id:String(h.id),label:h.name||`Track ${b+1}`,language:h.lang||"",kind:h.default?"main":"alternative",selected:b===this.hls.audioTrack})),this.events.emit("statechange",{audioTracks:this._audioTracks})}updateTextTracks(){if(!this.hls)return;this._textTracks=this.hls.subtitleTracks.map((h,b)=>({id:String(h.id),kind:"subtitles",label:h.name||`Subtitle ${b+1}`,language:h.lang||"",mode:b===this.hls.subtitleTrack?"showing":"disabled",cues:[]})),this.events.emit("statechange",{textTracks:this._textTracks})}async play(){if(!this.video)return;try{await this.video.play()}catch(h){if(h.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",h);else throw h}}pause(){this.video?.pause()}seekTo(h){if(this.video)this.video.currentTime=Math.max(0,Math.min(h,this.getDuration()))}getCurrentTime(){return this.video?.currentTime||0}getDuration(){return this.video?.duration||0}syncToLive(){if(this.hls?.liveSyncPosition!=null)this.seekTo(this.hls.liveSyncPosition)}setVolume(h){if(this.video)this.video.volume=Math.max(0,Math.min(1,h))}getVolume(){return this.video?.volume||1}setMuted(h){if(this.video)this.video.muted=h}getMuted(){return this.video?.muted||!1}setPlaybackRate(h){if(this.video)this.video.playbackRate=Math.max(0.25,Math.min(4,h))}getPlaybackRate(){return this.video?.playbackRate||1}getQualities(){return this._qualities}setQuality(h){if(!this.hls)return;if(h==="auto")this.hls.currentLevel=-1,this.currentQualityIndex=-1,this.events.emit("statechange",{autoQuality:!0});else{let b=parseInt(h.id,10);if(!isNaN(b)&&b>=0&&b<this._qualities.length)this.hls.currentLevel=b,this.currentQualityIndex=b,this.events.emit("statechange",{autoQuality:!1})}}getAudioTracks(){return this._audioTracks}setAudioTrack(h){if(!this.hls)return;let b=parseInt(h,10);if(!isNaN(b)&&b>=0&&b<this.hls.audioTracks.length)this.hls.audioTrack=b}getTextTracks(){return this._textTracks}setTextTrackMode(h,b){if(!this.hls)return;if(b==="showing"){let C=parseInt(h,10);if(!isNaN(C))this.hls.subtitleTrack=C}else this.hls.subtitleTrack=-1;this.updateTextTracks();let w=this._textTracks.find((C)=>C.mode==="showing");this.events.emit("texttrackchange",w||null)}}var w0={name:"hls",type:"hls",canPlay(h){return b0(h)},mediaType(){return"video"},preconnect(){return["https://cdn.jsdelivr.net"]},async load(h,b){let w=new p;return await w.setup(h,b),w}};var K=null,m=null,y0="https://cdn.dashjs.org/latest/dash.all.min.js";async function v0(h){if(K)return K;if(m)return m;return m=new Promise((b,w)=>{if(typeof window<"u"&&window.dashjs){K=window.dashjs,b(K);return}let C=document.createElement("script");C.src=h||y0,C.async=!0,C.onload=()=>{K=window.dashjs,b(K)},C.onerror=()=>{w(Error("Failed to load dash.js"))},document.head.appendChild(C)}),m}function n(h){if(typeof h==="object"&&"type"in h&&h.type==="dash")return!0;if(typeof h==="string")return h.includes(".mpd")||h.includes("manifest(format=mpd");return!1}class l extends F{name="dash";type="dash";dash=null;video=null;source=null;config={};_volume=1;_muted=!1;_playbackRate=1;get mediaElement(){return this.video}async initialize(){if(this.video=document.createElement("video"),this.video.style.width="100%",this.video.style.height="100%",this.video.style.display="block",await v0(this.options.dashCdnUrl),this.dash=K.MediaPlayer().create(),this.options.dashConfig)this.config.dashConfig=this.options.dashConfig;if(this.config.dashConfig)Object.entries(this.config.dashConfig).forEach(([h,b])=>{this.dash.updateSettings({[h]:b})});if(this.config.lowLatency)this.dash.updateSettings({streaming:{lowLatencyEnabled:!0,liveDelay:3,liveCatchUpMinDrift:0.05,liveCatchUpPlaybackRate:0.5}});if(this.attachDashEvents(),this.container)this.container.appendChild(this.video);this.attachVideoEvents()}attachVideoEvents(){if(!this.video)return;this.video.addEventListener("play",()=>this.events.emit("play")),this.video.addEventListener("pause",()=>this.events.emit("pause")),this.video.addEventListener("ended",()=>this.events.emit("ended")),this.video.addEventListener("timeupdate",()=>this.events.emit("timeupdate",this.getCurrentTime())),this.video.addEventListener("durationchange",()=>this.events.emit("durationchange",this.getDuration())),this.video.addEventListener("volumechange",()=>{this.events.emit("volumechange",this.getVolume(),this.getMuted())}),this.video.addEventListener("waiting",()=>this.events.emit("waiting")),this.video.addEventListener("playing",()=>this.events.emit("playing")),this.video.addEventListener("seeking",()=>this.events.emit("seeking")),this.video.addEventListener("seeked",()=>this.events.emit("seeked")),this.video.addEventListener("progress",()=>{let h=[];for(let b=0;b<this.video.buffered.length;b++)h.push({start:this.video.buffered.start(b),end:this.video.buffered.end(b)});this.events.emit("progress",h)}),this.video.addEventListener("loadedmetadata",()=>{this.events.emit("loadedmetadata");let h=this.getFeatureAvailability("fullscreen"),b=this.getFeatureAvailability("pip"),w=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:this.video.videoWidth,videoHeight:this.video.videoHeight,aspectRatio:(this.video.videoHeight>0?this.video.videoWidth/this.video.videoHeight:0)||1.7777777777777777,canFullscreen:h==="available",canPictureInPicture:b==="available",fullscreenAvailability:h,pipAvailability:b,volumeAvailability:w}),this.events.emit("availabilitychange","fullscreen",h),this.events.emit("availabilitychange","pip",b),this.events.emit("availabilitychange","volume",w)}),this.video.addEventListener("loadeddata",()=>this.events.emit("loadeddata")),this.video.addEventListener("canplay",()=>this.events.emit("canplay")),this.video.addEventListener("canplaythrough",()=>this.events.emit("canplaythrough")),this.video.addEventListener("ratechange",()=>this.events.emit("ratechange",this.getPlaybackRate()))}attachDashEvents(){if(!K)return;let h=K.MediaPlayer;this.dash.on(h.events.QUALITY_CHANGE_RENDERED,()=>{this.events.emit("qualitychange",this.getQualities().find((b)=>b.selected)||null)}),this.dash.on(h.events.MANIFEST_LOADED,()=>{}),this.dash.on(h.events.ERROR,(b)=>{this.emitError(b.error?.code||0,b.error?.message||"DASH playback error",b.error)})}configureDRM(h){let b={};if(h.widevine)b["com.widevine.alpha"]={serverURL:h.widevine.url,httpRequestHeaders:h.widevine.headers};if(h.playready)b["com.microsoft.playready"]={serverURL:h.playready.url,httpRequestHeaders:h.playready.headers};if(h.fairplay)b["com.apple.fps.1_0"]={serverURL:h.fairplay.url,serverCertificateURL:h.fairplay.certificateUrl,httpRequestHeaders:h.fairplay.headers};this.dash.setProtectionData(b)}async load(h){if(!this.video||!this.dash)return;if(typeof h==="string")this.source={src:h,type:"dash"};else if(n(h))this.source=h;else{this.emitError(4,"Invalid DASH source");return}if(this.source.drm)this.configureDRM(this.source.drm);this.dash.initialize(this.video,this.source.src,!1)}canPlay(h){return n(h)}cleanup(){if(this.dash)this.dash.reset(),this.dash=null;if(this.video)this.video.remove(),this.video=null;this.source=null}async play(){if(!this.video)return;try{await this.video.play()}catch(h){if(h.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",h);else throw h}}pause(){if(this.video)this.video.pause()}seekTo(h){if(this.video)this.video.currentTime=h}getCurrentTime(){return this.video?.currentTime||0}getDuration(){return this.video?.duration||0}setVolume(h){if(this._volume=Math.max(0,Math.min(1,h)),this.video)this.video.volume=this._volume}getVolume(){return this.video?.volume??this._volume}setMuted(h){if(this._muted=h,this.video)this.video.muted=h}getMuted(){return this.video?.muted??this._muted}setPlaybackRate(h){if(this._playbackRate=h,this.video)this.video.playbackRate=h}getPlaybackRate(){return this.video?.playbackRate??this._playbackRate}get isLive(){return this.dash?.isDynamic()??!1}get liveLatency(){return this.dash?.getCurrentLiveLatency()??0}get canLiveSync(){return this.isLive}syncToLive(){if(this.dash&&this.isLive)this.dash.seekToOriginalLive()}getQualities(){if(!this.dash)return[];let h=this.dash.getBitrateInfoListFor("video");if(!h)return[];let b=this.dash.getQualityFor("video");return h.map((w,C)=>({id:`${C}`,label:`${w.height}p`,width:w.width,height:w.height,bitrate:w.bitrate,selected:C===b}))}setQuality(h){if(!this.dash)return;if(h==="auto")this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!0}}}});else{let b=Number.parseInt(h.id,10);if(!Number.isNaN(b))this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1}}}}),this.dash.setQualityFor("video",b)}}get isAutoQuality(){if(!this.dash)return!0;return this.dash.getSettings()?.streaming?.abr?.autoSwitchBitrate?.video??!0}getAudioTracks(){if(!this.dash)return[];let h=this.dash.getTracksFor("audio");if(!h)return[];let b=this.dash.getCurrentTrackFor("audio");return h.map((w,C)=>({id:w.id||`${C}`,label:w.labels?.[0]?.text||w.lang||`Track ${C+1}`,language:w.lang||"",kind:"main",selected:w===b}))}setAudioTrack(h){if(!this.dash)return;let w=this.dash.getTracksFor("audio").find((C,M)=>(C.id||`${M}`)===h);if(w)this.dash.setCurrentTrack(w)}getTextTracks(){if(!this.dash)return[];let h=this.dash.getTracksFor("text");if(!h)return[];let b=this.dash.getCurrentTrackFor("text");return h.map((w,C)=>({id:w.id||`${C}`,label:w.labels?.[0]?.text||w.lang||`Subtitle ${C+1}`,language:w.lang||"",kind:w.kind||"subtitles",mode:w===b?"showing":"disabled",cues:[]}))}setTextTrackMode(h,b){if(!this.dash)return;if(b==="disabled"){this.dash.enableText(!1);return}let C=this.dash.getTracksFor("text").find((M,z)=>(M.id||`${z}`)===h);if(C)this.dash.setCurrentTrack(C),this.dash.enableText(b==="showing")}}var C0={name:"dash",type:"dash",canPlay(h){return n(h)},mediaType(){return"video"},async load(h,b){let w=new l;return await w.setup(h,b),w},preconnect(){return["https://cdn.dashjs.org"]}};var f=[w0,C0,ih,h0,oh];function g0(h,b=f){for(let w of b)if(w.canPlay(h))return w;return null}function M0(h,b=f){let w=[];return h.forEach((C,M)=>{let z=g0(C,b);if(z)w.push({src:C,index:M,loader:z})}),w}class Y{_el;_options;_store;_events=new U;_provider=null;_loaders;_cleanupFns=[];_destroyed=!1;_sourceLoadId=0;_announcer=null;constructor(h,b={}){if(typeof h==="string"){let w=document.querySelector(h);if(!w)throw Error(`Container element not found: ${h}`);this._el=w}else this._el=h;if(this._options={...p0,...b},this._loaders=f,this._store=new q,this.setupElement(),this.setupState(),this.setupKeyboard(),this.setupActivity(),this.setupStorage(),this.setupMediaSession(),this.setupEvents(),this._options.src)this.setSrc(this._options.src);this._events.emit("init")}get el(){return this._el}get state(){return this._store.getState()}get provider(){return this._provider}get ready(){return this._provider?.ready||!1}setupElement(){this._el.classList.add("ts-video-player"),this._el.setAttribute("tabindex","0"),this._el.setAttribute("role","region"),this._el.setAttribute("aria-roledescription","video player"),this._el.setAttribute("aria-label",this._options.title||"Video player"),this._el.setAttribute("aria-keyshortcuts","Space K M F I C ArrowLeft ArrowRight J L ArrowUp ArrowDown Home End 0 1 2 3 4 5 6 7 8 9");let h=document.createElement("div");if(h.className="ts-video-player__container",this._el.appendChild(h),this._options.announcements!==!1){let w=document.createElement("div");w.className="ts-video-player__announcer",w.setAttribute("role","status"),w.setAttribute("aria-live","polite"),w.setAttribute("aria-atomic","true"),w.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",this._el.appendChild(w),this._announcer=w}let b=this._el;b.__videoPlayer=this}setupState(){this._store.batch({volume:this._options.volume??1,muted:this._options.muted??!1,loop:this._options.loop??!1,autoplay:this._options.autoplay??!1,playsinline:this._options.playsinline??!0,playbackRate:this._options.playbackRate??1,poster:this._options.poster||"",title:this._options.title||"",preload:this._options.preload||"metadata"});let h=this._store.subscribe((b)=>{this.updateAttributes(b)});this._cleanupFns.push(h)}setupKeyboard(){if(this._options.keyboard===!1)return;let h={togglePlay:()=>this.togglePlay(),toggleMute:()=>this.toggleMute(),toggleFullscreen:()=>this.toggleFullscreen(),togglePiP:()=>this.togglePiP(),toggleCaptions:()=>this.toggleCaptions(),seekBackward:()=>this.seekBy(-5),seekForward:()=>this.seekBy(5),volumeUp:()=>this.setVolume(Math.min(1,this.state.volume+0.1)),volumeDown:()=>this.setVolume(Math.max(0,this.state.volume-0.1)),speedUp:()=>this.setPlaybackRate(Math.min(4,this.state.playbackRate+0.25)),speedDown:()=>this.setPlaybackRate(Math.max(0.25,this.state.playbackRate-0.25)),seekStart:()=>this.seekTo(0),seekEnd:()=>this.seekTo(this.state.duration),seekPercent:(M)=>this.seekTo(M/100*this.state.duration)},b=typeof this._options.keyboard==="object"?this._options.keyboard:{},w=Oh(h,{seekStep:b.seekStep,volumeStep:b.volumeStep}),C=b.global?document:this._el;C.addEventListener("keydown",w),this._cleanupFns.push(()=>C.removeEventListener("keydown",w))}setupActivity(){let h=Ph(this._el,{timeout:this._options.controlsTimeout||3000,onActive:()=>{this._store.batch({userActive:!0,controlsVisible:!0}),this._events.emit("useractivitychange",!0),this._events.emit("controlschange",!0)},onInactive:()=>{if(this.state.playing)this._store.batch({userActive:!1,controlsVisible:!1}),this._events.emit("useractivitychange",!1),this._events.emit("controlschange",!1)}});this._cleanupFns.push(h);let b=()=>this._store.set("pointerOver",!0),w=()=>this._store.set("pointerOver",!1);this._el.addEventListener("mouseenter",b),this._el.addEventListener("mouseleave",w),this._cleanupFns.push(()=>this._el.removeEventListener("mouseenter",b),()=>this._el.removeEventListener("mouseleave",w))}setupStorage(){if(!this._options.storage)return;let h=typeof this._options.storage==="object"?this._options.storage:{},b=h.type==="session"?sessionStorage:localStorage,w=Dh(this._store,h.persist||["volume","muted","playbackRate"],b);this._cleanupFns.push(w)}setupMediaSession(){if(this._options.mediaSession===!1)return;let h=typeof this._options.mediaSession==="object"?this._options.mediaSession:this._options.title?{title:this._options.title}:void 0,b=Sh(this._store,{play:()=>this.play(),pause:()=>this.pause(),seekTo:(w)=>this.seekTo(w),seekBy:(w)=>this.seekBy(w),stop:()=>this.stop()},h);this._cleanupFns.push(b)}setupEvents(){if(this._options.on){for(let[h,b]of Object.entries(this._options.on))if(b)this.on(h,b)}}updateAttributes(h){let b=this._el;b.dataset.paused=String(h.paused),b.dataset.playing=String(h.playing),b.dataset.started=String(h.started),b.dataset.ended=String(h.ended),b.dataset.seeking=String(h.seeking),b.dataset.waiting=String(h.waiting),b.dataset.loop=String(h.loop),b.dataset.autoplay=String(h.autoplay),b.dataset.loading=String(h.waiting||h.loadingState==="loading"),b.dataset.canPlay=String(h.canPlay),b.dataset.loadingState=h.loadingState,b.setAttribute("aria-busy",String(h.waiting||h.loadingState==="loading")),b.dataset.muted=String(h.muted),b.dataset.volumeLevel=h.muted||h.volume===0?"silent":h.volume<0.5?"low":"high",b.dataset.fullscreen=String(h.fullscreen),b.dataset.pip=String(h.pictureInPicture),b.dataset.controlsVisible=String(h.controlsVisible),b.dataset.userActive=String(h.userActive),b.dataset.mediaType=h.mediaType,b.dataset.streamType=h.streamType;let w=h.textTracks.some((C)=>C.mode==="showing");b.dataset.captions=String(w),b.dataset.error=String(!!h.error)}announce(h){if(!this._announcer)return;this._announcer.textContent="",requestAnimationFrame(()=>{if(this._announcer)this._announcer.textContent=h})}destroy(){if(this._destroyed)return;this._destroyed=!0,this._sourceLoadId++,this._events.emit("destroy"),this._cleanupFns.forEach((h)=>h()),this._cleanupFns=[],this._provider?.destroy(),this._provider=null,this._events.removeAllListeners(),this._store.reset(),this._el.classList.remove("ts-video-player"),this._el.innerHTML="",delete this._el.__videoPlayer}async setSrc(h){if(this._destroyed)return;let b=++this._sourceLoadId,w=Array.isArray(h)?h:[h];if(w.length===0)return;this._store.batch({sources:w,src:w[0],loadingState:"loading",error:null}),this._events.emit("sourceschange",w);let C=M0(w,this._loaders);if(C.length===0){this._store.batch({loadingState:"error",error:{code:4,message:"No compatible provider found for source"}});return}let M;for(let z of C){if(this._destroyed||b!==this._sourceLoadId)return;let{loader:$}=z;if(this._provider&&this._provider.type!==$.type)this._provider.destroy(),this._provider=null,this._events.emit("providerchange",null);if(!this._provider){let _=this._el.querySelector(".ts-video-player__container");try{if(this._provider=await $.load(_,{...this._options,mediaType:$.mediaType(z.src)}),this._destroyed||b!==this._sourceLoadId){this._provider.destroy(),this._provider=null;return}this._events.emit("providerchange",this._provider),this.attachProviderEvents(this._provider)}catch(H){M=H,this._provider=null;continue}}try{let _=$.type==="video"?C.filter((H)=>H.loader.type===$.type).map((H)=>H.src):[z.src];if(await this._provider.load(_.length>1?_:z.src),this._destroyed||b!==this._sourceLoadId)return;this._store.batch({src:z.src,currentSourceIndex:z.index,mediaType:$.mediaType(z.src),providerType:$.type});return}catch(_){if(M=_,this._provider)this._provider.destroy(),this._provider=null;this._events.emit("providerchange",null)}}if(this._destroyed||b!==this._sourceLoadId)return;this._store.batch({loadingState:"error",error:{code:4,message:"Failed to load all compatible sources",details:M}})}getSrc(){return this.state.src}attachProviderEvents(h){h.on("loadstart",()=>{this._store.set("loadingState","loading"),this._events.emit("loadstart")}),h.on("loadedmetadata",()=>{this._events.emit("loadedmetadata")}),h.on("loadeddata",()=>{this._events.emit("loadeddata")}),h.on("canplay",()=>{this._store.batch({canPlay:!0,loadingState:"loaded"}),this._events.emit("canplay")}),h.on("canplaythrough",()=>{this._store.set("canPlayThrough",!0),this._events.emit("canplaythrough")}),h.on("play",()=>{this._store.batch({paused:!1,ended:!1}),this._events.emit("play"),this.announce("Playing")}),h.on("pause",()=>{this._store.set("paused",!0),this._events.emit("pause"),this.announce("Paused")}),h.on("playing",()=>{this._store.batch({playing:!0,started:!0,waiting:!1,playbackState:"playing"}),this._events.emit("playing")}),h.on("waiting",()=>{this._store.batch({waiting:!0,playbackState:"buffering"}),this._events.emit("waiting")}),h.on("seeking",()=>{this._store.set("seeking",!0),this._events.emit("seeking")}),h.on("seeked",()=>{this._store.set("seeking",!1),this._events.emit("seeked")}),h.on("timeupdate",(b)=>{this._store.set("currentTime",b),this._events.emit("timeupdate",b)}),h.on("durationchange",(b)=>{this._store.set("duration",b),this._events.emit("durationchange",b)}),h.on("volumechange",(b,w)=>{if(this._store.batch({volume:b,muted:w}),this._events.emit("volumechange",b,w),w)this.announce("Muted");else this.announce(`Volume ${Math.round(b*100)}%`)}),h.on("ratechange",(b)=>{this._store.set("playbackRate",b),this._events.emit("ratechange",b)}),h.on("progress",(b)=>{this._store.batch({buffered:b,bufferedAmount:Yh({...this.state,buffered:b})}),this._events.emit("progress",b)}),h.on("ended",()=>{if(this._store.batch({ended:!0,playing:!1,playbackState:"ended"}),this._events.emit("ended"),this.announce("Playback ended"),this.state.loop)this.seekTo(0),this.play()}),h.on("error",(b)=>{this._store.batch({loadingState:"error",error:b}),this._events.emit("error",b),this.announce(`Error: ${b.message}`)}),h.on("statechange",(b)=>{this._store.batch(b),this._events.emit("statechange",b)}),h.on("qualitychange",(b)=>{this._store.set("qualities",h.getQualities()),this._events.emit("qualitychange",b)}),h.on("fullscreenchange",(b)=>{this._store.set("fullscreen",b),this._events.emit("fullscreenchange",b),this.announce(b?"Entered fullscreen":"Exited fullscreen")}),h.on("pipchange",(b)=>{this._store.set("pictureInPicture",b),this._events.emit("pipchange",b)}),h.on("availabilitychange",(b,w)=>{if(b==="volume")this._store.set("volumeAvailability",w);else if(b==="fullscreen")this._store.set("fullscreenAvailability",w);else if(b==="pip")this._store.set("pipAvailability",w);this._events.emit("availabilitychange",b,w)})}async play(){if(!this._provider)return;await this._provider.play()}pause(){this._provider?.pause()}togglePlay(){if(this.state.paused)this.play().catch(()=>{});else this.pause()}stop(){this._provider?.stop(),this._store.batch({playing:!1,paused:!0,currentTime:0,playbackState:"idle"})}seekTo(h){this._provider?.seekTo(h)}seekBy(h){let b=Math.max(0,Math.min(this.state.currentTime+h,this.state.duration));this.seekTo(b)}setVolume(h){if(this.state.volumeAvailability==="unsupported")return;let b=Math.max(0,Math.min(1,h));this._provider?.setVolume(b),this._store.set("volume",b)}setMuted(h){this._provider?.setMuted(h),this._store.set("muted",h)}toggleMute(){this.setMuted(!this.state.muted)}setPlaybackRate(h){let b=Math.max(0.25,Math.min(4,h));this._provider?.setPlaybackRate(b),this._store.set("playbackRate",b)}async enterFullscreen(){if(this.state.fullscreenAvailability==="unsupported")return;if(this.state.pictureInPicture)await this.exitPiP();if(await this._provider?.enterFullscreen(),this._options.fullscreenOrientationLock!==!1)uh("landscape")}async exitFullscreen(){if(await this._provider?.exitFullscreen(),this._options.fullscreenOrientationLock!==!1)xh()}async toggleFullscreen(){if(this.state.fullscreen)await this.exitFullscreen();else await this.enterFullscreen()}async enterPiP(){if(this.state.pipAvailability==="unsupported")return;if(this.state.fullscreen)await this.exitFullscreen();await this._provider?.enterPiP()}async exitPiP(){await this._provider?.exitPiP()}async togglePiP(){if(this.state.pictureInPicture)await this.exitPiP();else await this.enterPiP()}setQuality(h){if(this._provider?.setQuality(h),h==="auto")this._store.set("autoQuality",!0);else this._store.set("autoQuality",!1)}setTextTrack(h,b){this._provider?.setTextTrackMode(h,b),this._store.set("textTracks",this._provider?.getTextTracks()||[])}setAudioTrack(h){this._provider?.setAudioTrack(h),this._store.set("audioTracks",this._provider?.getAudioTracks()||[])}toggleCaptions(){let h=this.state.textTracks,b=h.find((w)=>w.mode==="showing");if(b)this.setTextTrack(b.id,"disabled");else{let w=h.find((C)=>C.kind==="subtitles"||C.kind==="captions");if(w)this.setTextTrack(w.id,"showing")}}on(h,b){this._events.on(h,b)}off(h,b){this._events.off(h,b)}once(h,b){this._events.once(h,b)}subscribe(h,b){return this._store.subscribe(h,b)}}var p0={autoplay:!1,loop:!1,muted:!1,volume:1,playbackRate:1,playsinline:!0,preload:"metadata",controls:!0,keyboard:!0,controlsTimeout:3000,storage:!0};function z0(h,b){return new Y(h,b)}var m0={colors:{primary:"#00a8ff",secondary:"#6c5ce7",background:"rgba(0, 0, 0, 0.85)",text:"#ffffff",textOnPrimary:"#ffffff",border:"rgba(255, 255, 255, 0.1)",focus:"#00a8ff",error:"#ff4757",success:"#2ed573",warning:"#ffa502"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',fontSize:"14px",fontSizeSmall:"12px",fontSizeLarge:"16px",fontWeight:"400",fontWeightBold:"600",lineHeight:"1.5"},spacing:{xs:"4px",sm:"8px",md:"12px",lg:"16px",xl:"24px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.2)",md:"0 4px 6px rgba(0, 0, 0, 0.3)",lg:"0 10px 15px rgba(0, 0, 0, 0.4)"},transitions:{fast:"100ms",normal:"200ms",slow:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)"},slider:{trackHeight:"4px",thumbSize:"14px",trackBg:"rgba(255, 255, 255, 0.2)",trackFillBg:"var(--tsvp-color-primary)",bufferedBg:"rgba(255, 255, 255, 0.4)",thumbBg:"#ffffff",thumbBorder:"none"},controls:{height:"48px",background:"linear-gradient(transparent, rgba(0, 0, 0, 0.7))",padding:"0 12px",buttonSize:"40px",iconSize:"24px",tooltipBg:"rgba(0, 0, 0, 0.9)",tooltipText:"#ffffff"},menu:{background:"rgba(20, 20, 20, 0.95)",borderRadius:"8px",shadow:"0 4px 20px rgba(0, 0, 0, 0.5)",itemHeight:"40px",itemHoverBg:"rgba(255, 255, 255, 0.1)",itemActiveBg:"rgba(0, 168, 255, 0.2)"},captions:{fontFamily:"inherit",fontSize:"1.5em",textColor:"#ffffff",background:"rgba(0, 0, 0, 0.75)",textShadow:"0 1px 2px rgba(0, 0, 0, 0.5)",borderRadius:"4px",padding:"4px 8px"},thumbnails:{width:"160px",height:"90px",borderRadius:"4px",border:"2px solid rgba(255, 255, 255, 0.2)",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},live:{indicatorColor:"#ff0000",indicatorSize:"8px",badgeBg:"#ff0000",badgeText:"#ffffff"}},l0={colors:{primary:"#00a8ff",background:"rgba(0, 0, 0, 0.9)",text:"#ffffff"}},f0={colors:{primary:"#0070f3",background:"rgba(255, 255, 255, 0.95)",text:"#1a1a1a",textOnPrimary:"#ffffff",border:"rgba(0, 0, 0, 0.1)"},controls:{background:"linear-gradient(transparent, rgba(255, 255, 255, 0.9))",tooltipBg:"rgba(0, 0, 0, 0.8)"},menu:{background:"rgba(255, 255, 255, 0.98)",shadow:"0 4px 20px rgba(0, 0, 0, 0.15)",itemHoverBg:"rgba(0, 0, 0, 0.05)",itemActiveBg:"rgba(0, 112, 243, 0.1)"},captions:{background:"rgba(255, 255, 255, 0.9)",textColor:"#1a1a1a"}},d0={colors:{primary:"#ffffff",background:"transparent"},controls:{height:"40px",background:"transparent"},slider:{trackHeight:"2px",thumbSize:"10px"}},t0={colors:{primary:"#e50914",background:"rgba(0, 0, 0, 0.85)"},slider:{trackFillBg:"#e50914"},live:{indicatorColor:"#e50914",badgeBg:"#e50914"}},c0={colors:{primary:"#ff0000",background:"rgba(0, 0, 0, 0.85)"},slider:{trackHeight:"3px",thumbSize:"13px",trackFillBg:"#ff0000"},controls:{height:"48px"},live:{indicatorColor:"#ff0000",badgeBg:"#ff0000"}},o0={colors:{primary:"#00adef",background:"rgba(0, 0, 0, 0.85)"},slider:{trackFillBg:"#00adef"}},s={dark:l0,light:f0,minimal:d0,netflix:t0,youtube:c0,vimeo:o0};function n0(h,b){let w={...h};for(let C of Object.keys(b)){let M=h[C],z=b[C];if(z&&typeof z==="object")w[C]={...M||{},...z};else if(z!==void 0)w[C]=z}return w}function s0(h,b="tsvp"){let w=n0(m0,h),C=[];if(w.colors)C.push(`--${b}-color-primary: ${w.colors.primary};`),C.push(`--${b}-color-secondary: ${w.colors.secondary};`),C.push(`--${b}-color-background: ${w.colors.background};`),C.push(`--${b}-color-text: ${w.colors.text};`),C.push(`--${b}-color-text-on-primary: ${w.colors.textOnPrimary};`),C.push(`--${b}-color-border: ${w.colors.border};`),C.push(`--${b}-color-focus: ${w.colors.focus};`),C.push(`--${b}-color-error: ${w.colors.error};`),C.push(`--${b}-color-success: ${w.colors.success};`),C.push(`--${b}-color-warning: ${w.colors.warning};`);if(w.typography)C.push(`--${b}-font-family: ${w.typography.fontFamily};`),C.push(`--${b}-font-size: ${w.typography.fontSize};`),C.push(`--${b}-font-size-sm: ${w.typography.fontSizeSmall};`),C.push(`--${b}-font-size-lg: ${w.typography.fontSizeLarge};`),C.push(`--${b}-font-weight: ${w.typography.fontWeight};`),C.push(`--${b}-font-weight-bold: ${w.typography.fontWeightBold};`),C.push(`--${b}-line-height: ${w.typography.lineHeight};`);if(w.spacing)C.push(`--${b}-spacing-xs: ${w.spacing.xs};`),C.push(`--${b}-spacing-sm: ${w.spacing.sm};`),C.push(`--${b}-spacing-md: ${w.spacing.md};`),C.push(`--${b}-spacing-lg: ${w.spacing.lg};`),C.push(`--${b}-spacing-xl: ${w.spacing.xl};`);if(w.borderRadius)C.push(`--${b}-radius-sm: ${w.borderRadius.sm};`),C.push(`--${b}-radius-md: ${w.borderRadius.md};`),C.push(`--${b}-radius-lg: ${w.borderRadius.lg};`),C.push(`--${b}-radius-full: ${w.borderRadius.full};`);if(w.shadows)C.push(`--${b}-shadow-sm: ${w.shadows.sm};`),C.push(`--${b}-shadow-md: ${w.shadows.md};`),C.push(`--${b}-shadow-lg: ${w.shadows.lg};`);if(w.transitions)C.push(`--${b}-transition-fast: ${w.transitions.fast};`),C.push(`--${b}-transition-normal: ${w.transitions.normal};`),C.push(`--${b}-transition-slow: ${w.transitions.slow};`),C.push(`--${b}-transition-easing: ${w.transitions.easing};`);if(w.slider)C.push(`--${b}-slider-track-height: ${w.slider.trackHeight};`),C.push(`--${b}-slider-thumb-size: ${w.slider.thumbSize};`),C.push(`--${b}-slider-track-bg: ${w.slider.trackBg};`),C.push(`--${b}-slider-track-fill-bg: ${w.slider.trackFillBg};`),C.push(`--${b}-slider-buffered-bg: ${w.slider.bufferedBg};`),C.push(`--${b}-slider-thumb-bg: ${w.slider.thumbBg};`),C.push(`--${b}-slider-thumb-border: ${w.slider.thumbBorder};`);if(w.controls)C.push(`--${b}-controls-height: ${w.controls.height};`),C.push(`--${b}-controls-bg: ${w.controls.background};`),C.push(`--${b}-controls-padding: ${w.controls.padding};`),C.push(`--${b}-controls-button-size: ${w.controls.buttonSize};`),C.push(`--${b}-controls-icon-size: ${w.controls.iconSize};`),C.push(`--${b}-controls-tooltip-bg: ${w.controls.tooltipBg};`),C.push(`--${b}-controls-tooltip-text: ${w.controls.tooltipText};`);if(w.menu)C.push(`--${b}-menu-bg: ${w.menu.background};`),C.push(`--${b}-menu-radius: ${w.menu.borderRadius};`),C.push(`--${b}-menu-shadow: ${w.menu.shadow};`),C.push(`--${b}-menu-item-height: ${w.menu.itemHeight};`),C.push(`--${b}-menu-item-hover-bg: ${w.menu.itemHoverBg};`),C.push(`--${b}-menu-item-active-bg: ${w.menu.itemActiveBg};`);if(w.captions)C.push(`--${b}-captions-font-family: ${w.captions.fontFamily};`),C.push(`--${b}-captions-font-size: ${w.captions.fontSize};`),C.push(`--${b}-captions-text-color: ${w.captions.textColor};`),C.push(`--${b}-captions-bg: ${w.captions.background};`),C.push(`--${b}-captions-text-shadow: ${w.captions.textShadow};`),C.push(`--${b}-captions-radius: ${w.captions.borderRadius};`),C.push(`--${b}-captions-padding: ${w.captions.padding};`);if(w.thumbnails)C.push(`--${b}-thumbnail-width: ${w.thumbnails.width};`),C.push(`--${b}-thumbnail-height: ${w.thumbnails.height};`),C.push(`--${b}-thumbnail-radius: ${w.thumbnails.borderRadius};`),C.push(`--${b}-thumbnail-border: ${w.thumbnails.border};`),C.push(`--${b}-thumbnail-shadow: ${w.thumbnails.shadow};`);if(w.live)C.push(`--${b}-live-indicator-color: ${w.live.indicatorColor};`),C.push(`--${b}-live-indicator-size: ${w.live.indicatorSize};`),C.push(`--${b}-live-badge-bg: ${w.live.badgeBg};`),C.push(`--${b}-live-badge-text: ${w.live.badgeText};`);return C.join(`
2
- `)}function _0(h,b){let w=typeof b==="string"?s[b]:b;h.querySelectorAll("style[data-tsvp-theme]").forEach((M)=>M.remove());let C=s0(w);h.style.cssText+=C.split(`
3
- `).map((M)=>M.trim().replace(";","")).join("; ")}var i0={play:"Play",pause:"Pause",replay:"Replay",mute:"Mute",unmute:"Unmute",volume:"Volume",seekBackward:"Seek backward {seconds} seconds",seekForward:"Seek forward {seconds} seconds",seekTo:"Seek to {time}",duration:"Duration",currentTime:"Current time",played:"Played",buffered:"Buffered",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",enterPiP:"Enter picture-in-picture",exitPiP:"Exit picture-in-picture",enableCaptions:"Enable captions",disableCaptions:"Disable captions",captions:"Captions",captionsOff:"Off",settings:"Settings",quality:"Quality",auto:"Auto",speed:"Speed",normal:"Normal",loop:"Loop",loopEnabled:"Loop enabled",loopDisabled:"Loop disabled",audioBoost:"Audio boost",audioTrack:"Audio track",live:"LIVE",liveEdge:"At live edge",seekToLive:"Seek to live edge",behindLive:"{seconds}s behind",networkError:"A network error occurred",mediaError:"The media could not be loaded",unknownError:"An unknown error occurred",loading:"Loading",buffering:"Buffering",chapters:"Chapters",airPlay:"AirPlay",googleCast:"Cast",casting:"Casting to {device}",download:"Download",share:"Share",close:"Close",menu:"Menu",back:"Back"},a0={play:"Reproducir",pause:"Pausar",replay:"Repetir",mute:"Silenciar",unmute:"Activar sonido",volume:"Volumen",seekBackward:"Retroceder {seconds} segundos",seekForward:"Avanzar {seconds} segundos",seekTo:"Ir a {time}",duration:"Duración",currentTime:"Tiempo actual",played:"Reproducido",buffered:"Almacenado",enterFullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",enterPiP:"Imagen en imagen",exitPiP:"Salir de imagen en imagen",enableCaptions:"Activar subtítulos",disableCaptions:"Desactivar subtítulos",captions:"Subtítulos",captionsOff:"Desactivados",settings:"Ajustes",quality:"Calidad",auto:"Automático",speed:"Velocidad",normal:"Normal",loop:"Bucle",loopEnabled:"Bucle activado",loopDisabled:"Bucle desactivado",audioBoost:"Aumento de audio",audioTrack:"Pista de audio",live:"EN VIVO",liveEdge:"En vivo",seekToLive:"Ir al directo",behindLive:"{seconds}s de retraso",networkError:"Error de red",mediaError:"No se pudo cargar el medio",unknownError:"Error desconocido",loading:"Cargando",buffering:"Almacenando",chapters:"Capítulos",airPlay:"AirPlay",googleCast:"Enviar",casting:"Enviando a {device}",download:"Descargar",share:"Compartir",close:"Cerrar",menu:"Menú",back:"Volver"},r0={play:"Lecture",pause:"Pause",replay:"Relire",mute:"Muet",unmute:"Son activé",volume:"Volume",seekBackward:"Reculer de {seconds} secondes",seekForward:"Avancer de {seconds} secondes",seekTo:"Aller à {time}",duration:"Durée",currentTime:"Temps actuel",played:"Joué",buffered:"Mis en mémoire tampon",enterFullscreen:"Plein écran",exitFullscreen:"Quitter le plein écran",enterPiP:"Image dans l'image",exitPiP:"Quitter l'image dans l'image",enableCaptions:"Activer les sous-titres",disableCaptions:"Désactiver les sous-titres",captions:"Sous-titres",captionsOff:"Désactivés",settings:"Paramètres",quality:"Qualité",auto:"Auto",speed:"Vitesse",normal:"Normal",loop:"Boucle",loopEnabled:"Boucle activée",loopDisabled:"Boucle désactivée",audioBoost:"Amplification audio",audioTrack:"Piste audio",live:"EN DIRECT",liveEdge:"En direct",seekToLive:"Aller au direct",behindLive:"{seconds}s de retard",networkError:"Erreur réseau",mediaError:"Le média n'a pas pu être chargé",unknownError:"Erreur inconnue",loading:"Chargement",buffering:"Mise en mémoire tampon",chapters:"Chapitres",airPlay:"AirPlay",googleCast:"Caster",casting:"Diffusion sur {device}",download:"Télécharger",share:"Partager",close:"Fermer",menu:"Menu",back:"Retour"},e0={play:"Abspielen",pause:"Pause",replay:"Wiederholen",mute:"Stumm",unmute:"Ton an",volume:"Lautstärke",seekBackward:"{seconds} Sekunden zurück",seekForward:"{seconds} Sekunden vor",seekTo:"Zu {time} springen",duration:"Dauer",currentTime:"Aktuelle Zeit",played:"Abgespielt",buffered:"Gepuffert",enterFullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",enterPiP:"Bild-in-Bild",exitPiP:"Bild-in-Bild beenden",enableCaptions:"Untertitel aktivieren",disableCaptions:"Untertitel deaktivieren",captions:"Untertitel",captionsOff:"Aus",settings:"Einstellungen",quality:"Qualität",auto:"Auto",speed:"Geschwindigkeit",normal:"Normal",loop:"Schleife",loopEnabled:"Schleife aktiviert",loopDisabled:"Schleife deaktiviert",audioBoost:"Audio-Verstärkung",audioTrack:"Audiospur",live:"LIVE",liveEdge:"Am Live-Punkt",seekToLive:"Zum Live-Punkt",behindLive:"{seconds}s hinter Live",networkError:"Netzwerkfehler",mediaError:"Medium konnte nicht geladen werden",unknownError:"Unbekannter Fehler",loading:"Wird geladen",buffering:"Puffern",chapters:"Kapitel",airPlay:"AirPlay",googleCast:"Streamen",casting:"Streame zu {device}",download:"Herunterladen",share:"Teilen",close:"Schließen",menu:"Menü",back:"Zurück"},h2={play:"再生",pause:"一時停止",replay:"リプレイ",mute:"ミュート",unmute:"ミュート解除",volume:"音量",seekBackward:"{seconds}秒戻る",seekForward:"{seconds}秒進む",seekTo:"{time}にシーク",duration:"長さ",currentTime:"現在の時間",played:"再生済み",buffered:"バッファ済み",enterFullscreen:"フルスクリーン",exitFullscreen:"フルスクリーン終了",enterPiP:"ピクチャーインピクチャー",exitPiP:"ピクチャーインピクチャー終了",enableCaptions:"字幕を有効化",disableCaptions:"字幕を無効化",captions:"字幕",captionsOff:"オフ",settings:"設定",quality:"画質",auto:"自動",speed:"再生速度",normal:"通常",loop:"ループ",loopEnabled:"ループ有効",loopDisabled:"ループ無効",audioBoost:"オーディオブースト",audioTrack:"オーディオトラック",live:"ライブ",liveEdge:"ライブ中",seekToLive:"ライブに移動",behindLive:"{seconds}秒遅れ",networkError:"ネットワークエラー",mediaError:"メディアを読み込めません",unknownError:"不明なエラー",loading:"読み込み中",buffering:"バッファリング",chapters:"チャプター",airPlay:"AirPlay",googleCast:"キャスト",casting:"{device}にキャスト中",download:"ダウンロード",share:"共有",close:"閉じる",menu:"メニュー",back:"戻る"},b2={play:"播放",pause:"暂停",replay:"重播",mute:"静音",unmute:"取消静音",volume:"音量",seekBackward:"后退{seconds}秒",seekForward:"前进{seconds}秒",seekTo:"跳转到{time}",duration:"时长",currentTime:"当前时间",played:"已播放",buffered:"已缓冲",enterFullscreen:"全屏",exitFullscreen:"退出全屏",enterPiP:"画中画",exitPiP:"退出画中画",enableCaptions:"开启字幕",disableCaptions:"关闭字幕",captions:"字幕",captionsOff:"关闭",settings:"设置",quality:"画质",auto:"自动",speed:"播放速度",normal:"正常",loop:"循环",loopEnabled:"循环已开启",loopDisabled:"循环已关闭",audioBoost:"音频增强",audioTrack:"音轨",live:"直播",liveEdge:"直播中",seekToLive:"跳转到直播",behindLive:"落后{seconds}秒",networkError:"网络错误",mediaError:"无法加载媒体",unknownError:"未知错误",loading:"加载中",buffering:"缓冲中",chapters:"章节",airPlay:"AirPlay",googleCast:"投射",casting:"正在投射到{device}",download:"下载",share:"分享",close:"关闭",menu:"菜单",back:"返回"},w2={en:i0,es:a0,fr:r0,de:e0,ja:h2,zh:b2};class d{language;fallbackLanguage;translations;interpolationPattern;constructor(h={}){if(this.language=h.language||this.detectLanguage()||"en",this.fallbackLanguage=h.fallbackLanguage||"en",this.translations={...w2},h.translations){for(let[b,w]of Object.entries(h.translations))if(w)this.translations[b]={...this.translations[b],...w}}this.interpolationPattern=h.interpolationPattern||/\{(\w+)\}/g}detectLanguage(){if(typeof navigator>"u")return null;let h=navigator.language||navigator.userLanguage;if(!h)return null;if(this.translations[h])return h;let b=h.split("-")[0];if(this.translations[b])return b;return null}getLanguage(){return this.language}setLanguage(h){this.language=h}t(h,b){let w=this.translations[this.language]?.[h];if(!w)w=this.translations[this.fallbackLanguage]?.[h];if(!w)return h;if(b)w=w.replace(this.interpolationPattern,(C,M)=>{let z=b[M];return z!==void 0?String(z):C});return w}addTranslations(h,b){this.translations[h]={...this.translations[h],...b}}getTranslations(h){return this.translations[h]}getAvailableLanguages(){return Object.keys(this.translations)}hasLanguage(h){return h in this.translations}}var i=null;function C2(h){return new d(h)}function M2(h){if(!i)i=C2(h);return i}function $0(h,b){return M2().t(h,b)}var z2={name:"default",description:"Full-featured default layout with all controls",styles:`
1
+ function De(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown",streamType:"unknown",providerType:"unknown",loadingState:"idle",preload:"metadata",canPlay:!1,canPlayThrough:!1,error:null,playbackState:"idle",paused:!0,playing:!1,started:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:0,playbackRate:1,loop:!1,autoplay:!1,playsinline:!0,muted:!1,volume:1,buffered:[],bufferedAmount:0,seekable:[],videoWidth:0,videoHeight:0,aspectRatio:1.7777777777777777,qualities:[],autoQuality:!0,audioTracks:[],textTracks:[],fullscreen:!1,pictureInPicture:!1,canFullscreen:!1,canPictureInPicture:!1,volumeAvailability:"unavailable",fullscreenAvailability:"unavailable",pipAvailability:"unavailable",controlsVisible:!0,userActive:!0,pointerOver:!1,title:"",poster:""}}class A{state;listeners=new Map;_pendingKeys=null;_flushScheduled=!1;constructor(e){this.state={...De(),...e}}getState(){return this.state}get(e){return this.state[e]}set(e,t){if(this.state[e]===t)return;this.state={...this.state,[e]:t},this.scheduleNotify(e)}batch(e){for(let[t,i]of Object.entries(e))if(this.state[t]!==i)this.state[t]=i,this.scheduleNotify(t)}subscribe(e,t){if(typeof e==="function"){if(!this.listeners.has("*"))this.listeners.set("*",new Set);return this.listeners.get("*").add(e),()=>this.listeners.get("*")?.delete(e)}let i=e;if(!t)return()=>{};if(!this.listeners.has(i))this.listeners.set(i,new Set);return this.listeners.get(i).add(t),()=>this.listeners.get(i)?.delete(t)}reset(){this.state=De(),this._pendingKeys=null,this._flushScheduled=!1,this.notifyAll()}flush(){if(this._pendingKeys){let e=this._pendingKeys;this._pendingKeys=null,this._flushScheduled=!1;for(let t of e)this.notifyKey(t);this.notifyAll()}}scheduleNotify(e){if(!this._pendingKeys)this._pendingKeys=new Set;if(this._pendingKeys.add(e),!this._flushScheduled)this._flushScheduled=!0,queueMicrotask(()=>this.flush())}notifyKey(e){this.listeners.get(e)?.forEach((t)=>t(this.state,e))}notifyAll(){this.listeners.get("*")?.forEach((e)=>e(this.state))}}function $e(e){if(e.duration===0||e.buffered.length===0)return 0;let t=0;for(let i of e.buffered)t+=i.end-i.start;return Math.min(t/e.duration,1)}var Fe="ts-video-player";function Oe(e=localStorage){try{let t=e.getItem(Fe);if(t)return JSON.parse(t)}catch{}return{}}function Lt(e,t=localStorage){try{let i=Oe(t);t.setItem(Fe,JSON.stringify({...i,...e}))}catch{}}function qe(e,t=["volume","muted","playbackRate"],i=localStorage){let n=Oe(i);if(n.volume!==void 0)e.set("volume",n.volume);if(n.muted!==void 0)e.set("muted",n.muted);if(n.playbackRate!==void 0)e.set("playbackRate",n.playbackRate);let s=t.map((r)=>e.subscribe(r,(o)=>{let a=o[r];Lt({[r]:a},i)}));return()=>s.forEach((r)=>r())}class x{listeners=new Map;onceListeners=new Map;on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);return this.listeners.get(e).add(t),()=>this.off(e,t)}once(e,t){if(!this.onceListeners.has(e))this.onceListeners.set(e,new Set);return this.onceListeners.get(e).add(t),()=>this.onceListeners.get(e)?.delete(t)}off(e,t){this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t)}emit(e,...t){this.listeners.get(e)?.forEach((n)=>{try{n(...t)}catch(s){console.error(`[ts-video-player] Error in event handler for "${String(e)}":`,s)}});let i=this.onceListeners.get(e);if(i)i.forEach((n)=>{try{n(...t)}catch(s){console.error(`[ts-video-player] Error in once handler for "${String(e)}":`,s)}}),i.clear()}removeAllListeners(e){if(e)this.listeners.delete(e),this.onceListeners.delete(e);else this.listeners.clear(),this.onceListeners.clear()}listenerCount(e){return(this.listeners.get(e)?.size||0)+(this.onceListeners.get(e)?.size||0)}}class M{media;emitter;listeners=[];constructor(e,t){this.media=e,this.emitter=t,this.attachListeners()}attachListeners(){let e=(t,i)=>{this.media.addEventListener(t,i),this.listeners.push(()=>this.media.removeEventListener(t,i))};e("loadstart",()=>this.emitter.emit("loadstart")),e("loadedmetadata",()=>this.emitter.emit("loadedmetadata")),e("loadeddata",()=>this.emitter.emit("loadeddata")),e("canplay",()=>this.emitter.emit("canplay")),e("canplaythrough",()=>this.emitter.emit("canplaythrough")),e("play",()=>this.emitter.emit("play")),e("pause",()=>this.emitter.emit("pause")),e("playing",()=>this.emitter.emit("playing")),e("waiting",()=>this.emitter.emit("waiting")),e("ended",()=>this.emitter.emit("ended")),e("seeking",()=>this.emitter.emit("seeking")),e("seeked",()=>this.emitter.emit("seeked")),e("timeupdate",()=>this.emitter.emit("timeupdate",this.media.currentTime)),e("durationchange",()=>this.emitter.emit("durationchange",this.media.duration)),e("volumechange",()=>this.emitter.emit("volumechange",this.media.volume,this.media.muted)),e("ratechange",()=>this.emitter.emit("ratechange",this.media.playbackRate)),e("progress",()=>{let t=this.getTimeRanges(this.media.buffered);this.emitter.emit("progress",t)}),e("error",()=>{let t=this.normalizeError(this.media.error);this.emitter.emit("error",t)})}getTimeRanges(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}normalizeError(e){if(!e)return{code:0,message:"Unknown error"};let t={1:"The fetching of the media resource was aborted by the user agent.",2:"A network error occurred while fetching the media resource.",3:"An error occurred while decoding the media resource.",4:"The media resource is not supported."};return{code:e.code,message:t[e.code]||e.message||"Unknown error"}}destroy(){this.listeners.forEach((e)=>e()),this.listeners=[]}}function q(e){let t=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],i=()=>{let n=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);e(n)};return t.forEach((n)=>document.addEventListener(n,i)),()=>{t.forEach((n)=>document.removeEventListener(n,i))}}function N(e,t){let i=()=>t(!0),n=()=>t(!1);return e.addEventListener("enterpictureinpicture",i),e.addEventListener("leavepictureinpicture",n),()=>{e.removeEventListener("enterpictureinpicture",i),e.removeEventListener("leavepictureinpicture",n)}}var _t={" ":"togglePlay",k:"togglePlay",m:"toggleMute",f:"toggleFullscreen",i:"togglePiP",c:"toggleCaptions",ArrowLeft:"seekBackward",ArrowRight:"seekForward",j:"seekBackward",l:"seekForward",ArrowUp:"volumeUp",ArrowDown:"volumeDown",">":"speedUp","<":"speedDown",Home:"seekStart",End:"seekEnd","0":"seek0","1":"seek10","2":"seek20","3":"seek30","4":"seek40","5":"seek50","6":"seek60","7":"seek70","8":"seek80","9":"seek90"};function Ne(e,t={}){let{seekStep:i=5,volumeStep:n=0.1,speedStep:s=0.25}=t;return(r)=>{if(r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement||r.target?.isContentEditable)return;let o=r.key,a=_t[o];if(!a)return;switch(r.preventDefault(),a){case"togglePlay":e.togglePlay();break;case"toggleMute":e.toggleMute();break;case"toggleFullscreen":e.toggleFullscreen();break;case"togglePiP":e.togglePiP();break;case"toggleCaptions":e.toggleCaptions();break;case"seekBackward":e.seekBackward();break;case"seekForward":e.seekForward();break;case"volumeUp":e.volumeUp();break;case"volumeDown":e.volumeDown();break;case"speedUp":e.speedUp();break;case"speedDown":e.speedDown();break;case"seekStart":e.seekStart();break;case"seekEnd":e.seekEnd();break;default:if(a.startsWith("seek")){let l=parseInt(a.replace("seek",""),10);if(!isNaN(l))e.seekPercent(l)}}}}function ze(e,t={}){let{timeout:i=3000,onActive:n,onInactive:s}=t,r=null,o=!0,a=()=>{if(!o)o=!0,n?.();d()},l=()=>{if(o)o=!1,s?.()},d=()=>{if(r)clearTimeout(r);r=setTimeout(l,i)},c=["mousemove","mouseenter","mouseleave","mousedown","keydown","touchstart","touchmove"];return c.forEach((u)=>e.addEventListener(u,a)),d(),()=>{if(r)clearTimeout(r);c.forEach((u)=>e.removeEventListener(u,a))}}function Ue(){return typeof navigator<"u"&&"mediaSession"in navigator}function Qe(e,t,i){if(!Ue())return()=>{};let n=navigator.mediaSession;if(i)Ct(i);let s=[["play",()=>t.play()],["pause",()=>t.pause()],["stop",()=>t.stop()],["seekbackward",(d)=>{let c=d.seekOffset||-10;t.seekBy(c)}],["seekforward",(d)=>{let c=d.seekOffset||10;t.seekBy(c)}],["seekto",(d)=>{let c=d.seekTime;if(c!==void 0)t.seekTo(c)}]];for(let[d,c]of s)try{n.setActionHandler(d,c)}catch{}let r=e.subscribe("paused",(d)=>{n.playbackState=d.paused?"paused":"playing"}),o=null,a=()=>{let d=e.getState();if(!isFinite(d.duration)||d.duration<=0)return;try{n.setPositionState({duration:d.duration,playbackRate:d.playbackRate,position:Math.min(d.currentTime,d.duration)})}catch{}},l=e.subscribe("playing",(d)=>{if(d.playing){if(a(),!o)o=setInterval(a,1000)}else{if(o)clearInterval(o),o=null;a()}});return()=>{if(o)clearInterval(o);r(),l();for(let[d]of s)try{n.setActionHandler(d,null)}catch{}}}function Ct(e){if(!Ue())return;navigator.mediaSession.metadata=new MediaMetadata({title:e.title||"",artist:e.artist||"",album:e.album||"",artwork:e.artwork||[]})}function Ke(){return typeof screen<"u"&&"orientation"in screen&&typeof screen.orientation.lock==="function"}function We(e){if(!Ke())return;let t={landscape:"landscape",portrait:"portrait",any:"any"};screen.orientation.lock(t[e]).catch(()=>{})}function je(){if(!Ke())return;try{screen.orientation.unlock()}catch{}}function Rt(){if(typeof navigator>"u")return!1;let e=navigator.userAgent;if(/iPad|iPhone|iPod/.test(e)&&!window.MSStream)return!0;if(navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)return!0;return!1}function Ht(){if(typeof navigator>"u")return!1;return/^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ye(){if(typeof window>"u")return!1;return navigator.standalone===!0||window.matchMedia("(display-mode: standalone)").matches}function Xe(e){if(Rt())return"unsupported";if(!e)return"unavailable";return"available"}async function Ge(e){let t=e.volume;try{let i=t===1?0.5:1;e.volume=i,await new Promise((s)=>setTimeout(s,0));let n=e.volume!==t;return e.volume=t,n?"available":"unsupported"}catch{try{e.volume=t}catch{}return"unsupported"}}function Je(e,t){let i=typeof document<"u"?document:null;if(!i)return"unsupported";if(i.fullscreenEnabled||i.webkitFullscreenEnabled)return"available";if(i.mozFullScreenEnabled||i.msFullscreenEnabled)return"available";if(t){let n=t;if(n.webkitSupportsFullscreen===!0)return"available";if(typeof n.webkitEnterFullscreen==="function")return"available"}if(!e&&!t)return"unavailable";return"unsupported"}async function Ze(e,t){let i=t;if(e){let n=e;if(typeof n.requestFullscreen==="function")return n.requestFullscreen();if(typeof n.webkitRequestFullscreen==="function")return n.webkitRequestFullscreen();if(typeof n.webkitRequestFullScreen==="function")return n.webkitRequestFullScreen()}if(i&&typeof i.webkitEnterFullscreen==="function"){i.webkitEnterFullscreen();return}if(t&&typeof t.requestFullscreen==="function")return t.requestFullscreen()}async function et(e){let t=document,i=e;if(typeof t.exitFullscreen==="function")return t.exitFullscreen();if(typeof t.webkitExitFullscreen==="function")return t.webkitExitFullscreen();if(typeof t.webkitCancelFullScreen==="function")return t.webkitCancelFullScreen();if(i&&typeof i.webkitExitFullscreen==="function")i.webkitExitFullscreen()}function tt(e){if(!e)return"unavailable";if("requestPictureInPicture"in e){if(typeof document<"u"&&document.pictureInPictureEnabled===!1)return"unavailable";if(Ht()&&Ye())return"unavailable";return"available"}let t=e;if(typeof t.webkitSetPresentationMode==="function"){if(Ye())return"unavailable";if(typeof t.webkitSupportsPresentationMode==="function")return t.webkitSupportsPresentationMode("picture-in-picture")?"available":"unsupported";return"available"}return"unsupported"}async function it(e){let t=e;if(typeof t.requestPictureInPicture==="function"){await t.requestPictureInPicture();return}if(typeof t.webkitSetPresentationMode==="function")t.webkitSetPresentationMode("picture-in-picture")}async function nt(e){if(document.pictureInPictureElement&&typeof document.exitPictureInPicture==="function"){await document.exitPictureInPicture();return}if(e){let t=e;if(t.webkitPresentationMode==="picture-in-picture"&&typeof t.webkitSetPresentationMode==="function")t.webkitSetPresentationMode("inline")}}class b{container=null;options={};events=new x;_ready=!1;get mediaElement(){return null}get ready(){return this._ready}async setup(e,t){this.container=e,this.options=t,await this.initialize(),this._ready=!0,this.events.emit("ready")}destroy(){this._ready=!1,this.cleanup(),this.events.removeAllListeners()}stop(){this.pause(),this.seekTo(0)}getQualities(){return[]}setQuality(e){}getTextTracks(){return[]}setTextTrackMode(e,t){}getAudioTracks(){return[]}setAudioTrack(e){}getFeatureAvailability(e){let t=this.mediaElement,i=t instanceof HTMLMediaElement?t:null,n=t instanceof HTMLVideoElement?t:null;switch(e){case"volume":return t&&!(t instanceof HTMLMediaElement)?"available":Xe(i);case"fullscreen":return Je(this.container,n);case"pip":return t&&!(t instanceof HTMLMediaElement)?"unsupported":tt(n);default:return"unsupported"}}async enterFullscreen(){await Ze(this.container,this.mediaElement)}async exitFullscreen(){await et(this.mediaElement)}getFullscreenElement(){return this.container}async enterPiP(){let e=this.mediaElement;if(!e)return;await it(e)}async exitPiP(){await nt(this.mediaElement)}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}emitError(e,t,i){let n={code:e,message:t,details:i};this.events.emit("error",n)}}function ve(e){if(typeof e==="string"){let t=ge(e);if(t==="mp4"||t==="webm"||t==="ogg"||t==="ogv"||t==="mov"||t==="mp3"||t==="wav"||t==="flac"||t==="m4a"||t==="aac"||t==="oga"||t==="opus")return!0;return!1}if(typeof e==="object"&&"type"in e){let t=e.type?.toLowerCase()||"";return t.startsWith("video/")||t.startsWith("audio/")||t==="application/ogg"}return!1}function ge(e){let t=e.split(/[?#]/,1)[0];return t.slice(t.lastIndexOf(".")+1).toLowerCase()}function z(e){let t=ge(e);return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",flac:"audio/flac",m4a:"audio/mp4",aac:"audio/aac",oga:"audio/ogg",opus:"audio/ogg; codecs=opus"}[t||""]||"video/mp4"}class L extends b{name="html5";type="video";media=null;eventsNormalizer=null;cleanupFullscreen=null;cleanupPiP=null;isAudio=!1;get mediaElement(){return this.media}async initialize(){if(!this.container)throw Error("Container element is required");if(this.isAudio=this.options.mediaType==="audio",this.media=document.createElement(this.isAudio?"audio":"video"),this.media.className="ts-video-player__media",this.options.autoplay)this.media.autoplay=!0;if(this.options.loop)this.media.loop=!0;if(this.options.muted)this.media.muted=!0;if(this.options.playsinline&&!this.isAudio)this.media.playsInline=!0;if(this.options.preload)this.media.preload=this.options.preload;if(this.options.crossorigin)this.media.crossOrigin=this.options.crossorigin;if(this.options.controlsList?.length)this.media.setAttribute("controlslist",this.options.controlsList.join(" "));if(!this.isAudio&&this.options.disablePictureInPicture)this.media.disablePictureInPicture=!0;if(this.options.poster&&!this.isAudio)this.media.poster=this.options.poster;if(this.options.volume!==void 0)this.media.volume=this.options.volume;this.container.appendChild(this.media);for(let e of this.options.tracks??[])this.addTextTrack(e);if(this.eventsNormalizer=new M(this.media,this.events),this.cleanupFullscreen=q((e)=>{this.events.emit("fullscreenchange",e)}),!this.isAudio&&this.media instanceof HTMLVideoElement)this.cleanupPiP=N(this.media,(e)=>{this.events.emit("pipchange",e)});if(!this.isAudio)this.media.addEventListener("loadedmetadata",()=>{let e=this.media,t=this.getFeatureAvailability("fullscreen"),i=this.getFeatureAvailability("pip"),n=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:e.videoWidth,videoHeight:e.videoHeight,aspectRatio:(e.videoHeight>0?e.videoWidth/e.videoHeight:0)||1.7777777777777777,canFullscreen:t==="available",canPictureInPicture:i==="available",fullscreenAvailability:t,pipAvailability:i,volumeAvailability:n}),this.events.emit("availabilitychange","fullscreen",t),this.events.emit("availabilitychange","pip",i),this.events.emit("availabilitychange","volume",n)});if(this.media.addEventListener("loadeddata",()=>{if(!this.media)return;Ge(this.media).then((e)=>{this.events.emit("statechange",{volumeAvailability:e}),this.events.emit("availabilitychange","volume",e)}).catch(()=>{})}),!this.isAudio&&this.media instanceof HTMLVideoElement)this.media.addEventListener("webkitpresentationmodechanged",()=>{let e=this.media;if(e?.webkitPresentationMode){let t=e.webkitPresentationMode==="picture-in-picture";this.events.emit("pipchange",t)}})}cleanup(){if(this.eventsNormalizer?.destroy(),this.cleanupFullscreen?.(),this.cleanupPiP?.(),this.media)this.media.pause(),this.media.removeAttribute("src"),this.media.load(),this.media.remove(),this.media=null}canPlay(e){return ve(e)}async load(e){if(!this.media)return;this.media.innerHTML="",this.media.removeAttribute("src");let t=Array.isArray(e)?e:[e];for(let i of t)if(typeof i==="string"){let n=document.createElement("source");n.src=i,n.type=z(i),this.media.appendChild(n)}else if("src"in i&&typeof i.src==="string"){let n=i,s=document.createElement("source");s.src=n.src,s.type=n.type||z(n.src),this.media.appendChild(s)}this.media.load()}async play(){if(!this.media)return;try{await this.media.play()}catch(e){if(e.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",e);else throw e}}pause(){this.media?.pause()}seekTo(e){if(this.media)this.media.currentTime=Math.max(0,Math.min(e,this.getDuration()))}getCurrentTime(){return this.media?.currentTime||0}getDuration(){return this.media?.duration||0}setVolume(e){if(this.media)this.media.volume=Math.max(0,Math.min(1,e))}getVolume(){return this.media?.volume||1}setMuted(e){if(this.media)this.media.muted=e}getMuted(){return this.media?.muted||!1}setPlaybackRate(e){if(this.media)this.media.playbackRate=Math.max(0.25,Math.min(4,e))}getPlaybackRate(){return this.media?.playbackRate||1}getTextTracks(){if(!this.media)return[];let e=[],t=this.media.textTracks;for(let i=0;i<t.length;i++){let n=t[i];e.push({id:String(i),kind:n.kind,label:n.label||`Track ${i+1}`,language:n.language||"",mode:n.mode,cues:this.getTrackCues(n)})}return e}getTrackCues(e){if(!e.cues)return[];let t=[];for(let i=0;i<e.cues.length;i++){let n=e.cues[i];t.push({id:n.id||String(i),startTime:n.startTime,endTime:n.endTime,text:n.text})}return t}setTextTrackMode(e,t){if(!this.media)return;let i=parseInt(e,10),n=this.media.textTracks[i];if(n)n.mode=t,this.events.emit("texttrackchange",t==="showing"?this.getTextTracks()[i]:null)}getAudioTracks(){if(!this.media||this.isAudio)return[];let e=this.media;if(!("audioTracks"in e))return[];let t=e.audioTracks,i=[];for(let n=0;n<t.length;n++){let s=t[n];i.push({id:s.id||String(n),label:s.label||`Track ${n+1}`,language:s.language||"",kind:s.kind||"",selected:s.enabled})}return i}setAudioTrack(e){if(!this.media||this.isAudio)return;let t=this.media;if(!("audioTracks"in t))return;let i=t.audioTracks;for(let n=0;n<i.length;n++){let s=i[n].id===e||String(n)===e;i[n].enabled=s}this.events.emit("audiotrackchange",this.getAudioTracks().find((n)=>n.selected)||null)}addTextTrack(e){if(!this.media)return;let t=document.createElement("track");if(e.src)t.src=e.src;if(t.kind=e.kind||"subtitles",t.label=e.label||"",t.srclang=e.language||"",e.default)t.default=!0;this.media.appendChild(t)}}var fe={name:"html5",type:"video",canPlay(e){return ve(e)},mediaType(e){if(typeof e==="string"){let t=ge(e);if(["mp3","wav","flac","m4a","aac","oga","opus"].includes(t))return"audio";return"video"}if(typeof e==="object"&&"type"in e){if((e.type?.toLowerCase()||"").startsWith("audio/"))return"audio"}return"video"},async load(e,t){let i=new L;return await i.setup(e,t),i}};var It=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/youtube\.com\/v\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/];function U(e){for(let t of It){let i=e.match(t);if(i)return i[1]}return null}function ye(e){if(typeof e==="string")return U(e)!==null;if(typeof e==="object"&&"type"in e)return e.type==="youtube";return!1}function Vt(e){if(typeof e==="string"){let t=U(e);if(!t)return null;let i=new URL(e,"https://youtube.com"),n=i.searchParams.get("t")||i.searchParams.get("start"),s=i.searchParams.get("end");return{videoId:t,startTime:n?st(n):void 0,endTime:s?st(s):void 0}}if(typeof e==="object"&&"type"in e&&e.type==="youtube"){let t=e;return{videoId:t.videoId||U(t.src)||"",startTime:t.startTime,endTime:t.endTime}}return null}function st(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=e.match(/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?/);if(t){let n=parseInt(t[1]||"0",10),s=parseInt(t[2]||"0",10),r=parseInt(t[3]||"0",10);return n*3600+s*60+r}let i=e.split(":").map((n)=>parseInt(n,10));if(i.length===2)return i[0]*60+i[1];if(i.length===3)return i[0]*3600+i[1]*60+i[2];return 0}class _ extends b{name="youtube";type="youtube";player=null;iframe=null;pendingVideoId=null;playerReady=!1;startTime;endTime;timeUpdateInterval=null;lastState=-1;get mediaElement(){return this.iframe}async initialize(){if(!this.container)throw Error("Container element is required");await this.loadYouTubeAPI();let e=document.createElement("div");e.id=`ts-video-player-yt-${Date.now()}`,e.className="ts-video-player__youtube",this.container.appendChild(e);let t={autoplay:this.options.autoplay?1:0,controls:0,disablekb:1,enablejsapi:1,iv_load_policy:3,modestbranding:1,playsinline:this.options.playsinline?1:0,rel:0,origin:window.location.origin};if(this.options.youtubeParams)Object.assign(t,this.options.youtubeParams);this.player=new window.YT.Player(e,{host:"https://www.youtube-nocookie.com",width:"100%",height:"100%",playerVars:t,events:{onReady:()=>this.onReady(),onStateChange:(i)=>this.onStateChange(i),onError:(i)=>this.onError(i),onPlaybackQualityChange:()=>this.onQualityChange(),onPlaybackRateChange:()=>this.onRateChange()}}),this.iframe=this.player.getIframe(),this.iframe.className="ts-video-player__media"}async loadYouTubeAPI(){if(window.YT?.Player)return;return new Promise((e)=>{if(document.querySelector('script[src*="youtube.com/iframe_api"]')){let i=()=>{if(window.YT?.Player)e();else setTimeout(i,100)};i();return}let t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",t.async=!0,window.onYouTubeIframeAPIReady=()=>{e()},document.head.appendChild(t)})}cleanup(){if(this.timeUpdateInterval)clearInterval(this.timeUpdateInterval),this.timeUpdateInterval=null;this.player?.destroy(),this.player=null,this.playerReady=!1,this.iframe=null}onReady(){if(this.playerReady=!0,this.timeUpdateInterval=setInterval(()=>{if(this.player&&this.lastState===1)this.events.emit("timeupdate",this.getCurrentTime())},250),this.events.emit("loadedmetadata"),this.events.emit("canplay"),this.pendingVideoId)this.loadVideo(this.pendingVideoId,this.startTime,this.endTime),this.pendingVideoId=null}onStateChange(e){let t=e.data;this.lastState=t;let i=window.YT.PlayerState;switch(t){case i.UNSTARTED:this.events.emit("loadstart");break;case i.PLAYING:this.events.emit("play"),this.events.emit("playing"),this.events.emit("statechange",{paused:!1,playing:!0,waiting:!1});break;case i.PAUSED:this.events.emit("pause"),this.events.emit("statechange",{paused:!0,playing:!1});break;case i.BUFFERING:this.events.emit("waiting"),this.events.emit("statechange",{waiting:!0});break;case i.ENDED:this.events.emit("ended"),this.events.emit("statechange",{ended:!0,playing:!1});break;case i.CUED:this.events.emit("loadeddata"),this.events.emit("durationchange",this.getDuration());break}}onError(e){let t={2:"Invalid video ID",5:"HTML5 player error",100:"Video not found or removed",101:"Video cannot be embedded",150:"Video cannot be embedded"};this.emitError(e.data,t[e.data]||"Unknown YouTube error")}onQualityChange(){let e=this.player?.getPlaybackQuality()||"auto",t=this.getQualities();this.events.emit("qualitychange",t.find((i)=>i.id===e)||null)}onRateChange(){this.events.emit("ratechange",this.getPlaybackRate())}canPlay(e){return ye(e)}async load(e){let t=Vt(e);if(!t){this.emitError(2,"Invalid YouTube source");return}if(this.startTime=t.startTime,this.endTime=t.endTime,!this.player||!this._ready||!this.playerReady){this.pendingVideoId=t.videoId;return}this.loadVideo(t.videoId,t.startTime,t.endTime)}loadVideo(e,t,i){if(!this.player)return;if(this.options.autoplay)this.player.loadVideoById({videoId:e,startSeconds:t,endSeconds:i});else this.player.cueVideoById({videoId:e,startSeconds:t,endSeconds:i})}async play(){this.player?.playVideo()}pause(){this.player?.pauseVideo()}stop(){this.player?.stopVideo()}seekTo(e){this.player?.seekTo(e,!0),this.events.emit("seeking"),setTimeout(()=>this.events.emit("seeked"),100)}getCurrentTime(){return this.player?.getCurrentTime()||0}getDuration(){return this.player?.getDuration()||0}setVolume(e){this.player?.setVolume(Math.round(e*100)),this.events.emit("volumechange",e,this.getMuted())}getVolume(){return(this.player?.getVolume()||100)/100}setMuted(e){if(e)this.player?.mute();else this.player?.unMute();this.events.emit("volumechange",this.getVolume(),e)}getMuted(){return this.player?.isMuted()||!1}setPlaybackRate(e){this.player?.setPlaybackRate(e)}getPlaybackRate(){return this.player?.getPlaybackRate()||1}getQualities(){let e=this.player?.getAvailableQualityLevels()||[],t={highres:2160,hd2160:2160,hd1440:1440,hd1080:1080,hd720:720,large:480,medium:360,small:240,tiny:144},i=this.player?.getPlaybackQuality();return e.map((n)=>({id:n,width:Math.round((t[n]||480)*1.7777777777777777),height:t[n]||480,bitrate:0,selected:n===i}))}setQuality(e){if(e==="auto")this.player?.setPlaybackQuality("default");else this.player?.setPlaybackQuality(e.id)}}var be={name:"youtube",type:"youtube",canPlay(e){return ye(e)},mediaType(){return"video"},preconnect(){return["https://www.youtube-nocookie.com","https://www.youtube.com","https://i.ytimg.com","https://s.ytimg.com"]},async load(e,t){let i=new _;return await i.setup(e,t),i}};var Bt=[/vimeo\.com\/(\d+)/,/vimeo\.com\/video\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/,/vimeo\.com\/channels\/[\w]+\/(\d+)/,/vimeo\.com\/groups\/[\w]+\/videos\/(\d+)/];function Q(e){for(let t of Bt){let i=e.match(t);if(i)return i[1]}return null}function at(e){let t=e.match(/vimeo\.com\/\d+\/([a-f0-9]+)/);return t?t[1]:null}function ke(e){if(typeof e==="string")return Q(e)!==null;if(typeof e==="object"&&"type"in e)return e.type==="vimeo";return!1}function Dt(e){if(typeof e==="string"){let t=Q(e);if(!t)return null;return{videoId:t,hash:at(e)||void 0}}if(typeof e==="object"&&"type"in e&&e.type==="vimeo"){let t=e;return{videoId:t.videoId||Q(t.src)||"",hash:t.hash}}return null}var rt="https://player.vimeo.com/api/player.js";class Te extends b{name="vimeo";type="vimeo";container_el=null;player=null;iframe=null;timeUpdateInterval=null;_qualities=[];_duration=0;get mediaElement(){return this.iframe}async initialize(){if(!this.container)throw Error("Container element is required");await this.loadVimeoSDK(),this.container_el=document.createElement("div"),this.container_el.className="ts-video-player__vimeo",this.container.appendChild(this.container_el)}async loadVimeoSDK(){if(window.Vimeo)return;return new Promise((e,t)=>{if(document.querySelector(`script[src="${rt}"]`)){let n=()=>{if(window.Vimeo)e();else setTimeout(n,100)};n();return}let i=document.createElement("script");i.src=rt,i.async=!0,i.onload=()=>e(),i.onerror=()=>t(Error("Failed to load Vimeo SDK")),document.head.appendChild(i)})}cleanup(){if(this.timeUpdateInterval)clearInterval(this.timeUpdateInterval),this.timeUpdateInterval=null;this.player?.destroy(),this.player=null,this.iframe=null,this.container_el?.remove(),this.container_el=null}canPlay(e){return ke(e)}async load(e){let t=Dt(e);if(!t||!this.container_el){this.emitError(2,"Invalid Vimeo source");return}if(this.player)await this.player.destroy(),this.player=null;let i={id:parseInt(t.videoId,10),autopause:!1,autoplay:this.options.autoplay||!1,controls:!1,loop:this.options.loop||!1,muted:this.options.muted||!1,playsinline:this.options.playsinline!==!1,responsive:!0,dnt:!0};if(this.options.vimeoParams)Object.assign(i,this.options.vimeoParams);if(this.player=new window.Vimeo.Player(this.container_el,i),await this.player.ready(),this.iframe=this.container_el.querySelector("iframe"),this.iframe)this.iframe.className="ts-video-player__media";this.attachVimeoEvents(),this.events.emit("loadedmetadata"),this.events.emit("canplay"),this._duration=await this.player.getDuration(),this.events.emit("durationchange",this._duration),await this.updateQualities();let[n,s]=await Promise.all([this.player.getVideoWidth(),this.player.getVideoHeight()]);this.events.emit("statechange",{videoWidth:n,videoHeight:s,aspectRatio:n/s||1.7777777777777777,canFullscreen:!0,canPictureInPicture:!1})}attachVimeoEvents(){if(!this.player)return;this.player.on("play",()=>{this.events.emit("play"),this.events.emit("playing"),this.events.emit("statechange",{paused:!1,playing:!0})}),this.player.on("pause",()=>{this.events.emit("pause"),this.events.emit("statechange",{paused:!0,playing:!1})}),this.player.on("ended",()=>{this.events.emit("ended"),this.events.emit("statechange",{ended:!0,playing:!1})}),this.player.on("timeupdate",(e)=>{this.events.emit("timeupdate",e.seconds)}),this.player.on("seeking",()=>{this.events.emit("seeking")}),this.player.on("seeked",()=>{this.events.emit("seeked")}),this.player.on("bufferstart",()=>{this.events.emit("waiting"),this.events.emit("statechange",{waiting:!0})}),this.player.on("bufferend",()=>{this.events.emit("statechange",{waiting:!1})}),this.player.on("progress",(e)=>{let t=[{start:0,end:e.percent*this._duration}];this.events.emit("progress",t)}),this.player.on("volumechange",async()=>{let[e,t]=await Promise.all([this.player.getVolume(),this.player.getMuted()]);this.events.emit("volumechange",e,t)}),this.player.on("playbackratechange",(e)=>{this.events.emit("ratechange",e.playbackRate)}),this.player.on("qualitychange",async()=>{await this.updateQualities();let e=this._qualities.find((t)=>t.selected);this.events.emit("qualitychange",e||null)}),this.player.on("error",(e)=>{this.emitError(5,e.message,e)})}async updateQualities(){if(!this.player)return;try{let e=await this.player.getQualities();this._qualities=e.map((t)=>{let i=t.label.match(/(\d+)p/),n=i?parseInt(i[1],10):0;return{id:t.id,width:Math.round(n*1.7777777777777777),height:n,bitrate:0,selected:t.active}}),this.events.emit("statechange",{qualities:this._qualities})}catch{}}async play(){try{await this.player?.play()}catch(e){if(e.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",e);else throw e}}pause(){this.player?.pause()}stop(){this.pause(),this.seekTo(0)}seekTo(e){this.player?.setCurrentTime(e)}getCurrentTime(){return 0}getDuration(){return this._duration}setVolume(e){this.player?.setVolume(Math.max(0,Math.min(1,e)))}getVolume(){return 1}setMuted(e){this.player?.setMuted(e)}getMuted(){return!1}setPlaybackRate(e){this.player?.setPlaybackRate(e)}getPlaybackRate(){return 1}getQualities(){return this._qualities}setQuality(e){if(!this.player)return;if(e==="auto")this.player.setQuality("auto");else this.player.setQuality(e.id)}async enableTextTrack(e){await this.player?.enableTextTrack(e)}async disableTextTrack(){await this.player?.disableTextTrack()}async getChapters(){if(!this.player)return[];try{return await this.player.getChapters()}catch{return[]}}}var we={name:"vimeo",type:"vimeo",canPlay(e){return ke(e)},mediaType(){return"video"},preconnect(){return["https://player.vimeo.com","https://i.vimeocdn.com","https://f.vimeocdn.com"]},async load(e,t){let i=new Te;return await i.setup(e,t),i}};function Se(e){if(typeof e==="string"){let t=e.toLowerCase();return t.endsWith(".m3u8")||t.includes("application/x-mpegurl")||t.includes("application/vnd.apple.mpegurl")}if(typeof e==="object"&&"type"in e){let t=e.type?.toLowerCase()||"";return t==="application/x-mpegurl"||t==="application/vnd.apple.mpegurl"}return!1}function ot(){return document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}var $t="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js";class C extends b{name="hls";type="hls";video=null;hls=null;eventsNormalizer=null;cleanupFullscreen=null;cleanupPiP=null;useNativeHLS=!1;_qualities=[];_audioTracks=[];_textTracks=[];currentQualityIndex=-1;get mediaElement(){return this.video}get canLiveSync(){return!this.useNativeHLS&&this.hls!==null}get hlsConfig(){return this.hls?.config||{}}async initialize(){if(!this.container)throw Error("Container element is required");if(this.video=document.createElement("video"),this.video.className="ts-video-player__media",this.options.autoplay)this.video.autoplay=!0;if(this.options.loop)this.video.loop=!0;if(this.options.muted)this.video.muted=!0;if(this.options.playsinline)this.video.playsInline=!0;if(this.options.preload)this.video.preload=this.options.preload;if(this.options.crossorigin)this.video.crossOrigin=this.options.crossorigin;if(this.options.poster)this.video.poster=this.options.poster;if(this.options.volume!==void 0)this.video.volume=this.options.volume;if(this.container.appendChild(this.video),this.eventsNormalizer=new M(this.video,this.events),this.cleanupFullscreen=q((e)=>{this.events.emit("fullscreenchange",e)}),this.cleanupPiP=N(this.video,(e)=>{this.events.emit("pipchange",e)}),this.useNativeHLS=ot(),!this.useNativeHLS)await this.loadHLSLibrary();this.video.addEventListener("loadedmetadata",()=>{let e=this.getFeatureAvailability("fullscreen"),t=this.getFeatureAvailability("pip"),i=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:this.video.videoWidth,videoHeight:this.video.videoHeight,aspectRatio:(this.video.videoHeight>0?this.video.videoWidth/this.video.videoHeight:0)||1.7777777777777777,canFullscreen:e==="available",canPictureInPicture:t==="available",fullscreenAvailability:e,pipAvailability:t,volumeAvailability:i}),this.events.emit("availabilitychange","fullscreen",e),this.events.emit("availabilitychange","pip",t),this.events.emit("availabilitychange","volume",i)})}async loadHLSLibrary(){if(window.Hls)return;return new Promise((e,t)=>{let i=document.createElement("script");i.src=this.options.hlsCdnUrl||$t,i.async=!0,i.onload=()=>e(),i.onerror=()=>t(Error("Failed to load HLS.js")),document.head.appendChild(i)})}cleanup(){if(this.eventsNormalizer?.destroy(),this.cleanupFullscreen?.(),this.cleanupPiP?.(),this.hls)this.hls.destroy(),this.hls=null;if(this.video)this.video.pause(),this.video.removeAttribute("src"),this.video.load(),this.video.remove(),this.video=null;this._qualities=[],this._audioTracks=[],this._textTracks=[]}canPlay(e){return Se(e)}async load(e){if(!this.video)return;let t=typeof e==="string"?e:e.src;if(this.useNativeHLS){this.video.src=t,this.video.load();return}if(!window.Hls)await this.loadHLSLibrary();if(!window.Hls?.isSupported()){this.emitError(4,"HLS is not supported in this browser");return}if(this.hls)this.hls.destroy();let i={enableWorker:!0,lowLatencyMode:!1,...this.options.hlsConfig};this.hls=new window.Hls(i),this.attachHLSEvents(),this.hls.attachMedia(this.video),this.hls.loadSource(t)}attachHLSEvents(){if(!this.hls||!window.Hls)return;let e=window.Hls;this.hls.on(e.Events.MANIFEST_PARSED,(t,i)=>{if(this.updateQualities(i.levels),this.options.autoplay)this.video?.play().catch(()=>{})}),this.hls.on(e.Events.LEVEL_SWITCHED,(t,i)=>{this.currentQualityIndex=i.level,this.updateQualitySelection(),this.events.emit("qualitychange",this._qualities[i.level]||null)}),this.hls.on(e.Events.AUDIO_TRACK_LOADED,()=>{this.updateAudioTracks()}),this.hls.on(e.Events.AUDIO_TRACK_SWITCHED,()=>{this.updateAudioTracks();let t=this._audioTracks.find((i)=>i.selected);this.events.emit("audiotrackchange",t||null)}),this.hls.on(e.Events.SUBTITLE_TRACK_LOADED,()=>{this.updateTextTracks()}),this.hls.on(e.Events.ERROR,(t,i)=>{if(i.fatal)switch(i.type){case e.ErrorTypes.NETWORK_ERROR:this.hls?.startLoad();break;case e.ErrorTypes.MEDIA_ERROR:this.hls?.recoverMediaError();break;default:this.emitError(5,`HLS fatal error: ${i.details}`,i),this.hls?.destroy();break}})}updateQualities(e){this._qualities=e.map((t,i)=>({id:String(i),width:t.width,height:t.height,bitrate:t.bitrate,codec:t.codecSet||t.videoCodec||void 0,selected:i===this.currentQualityIndex})),this.events.emit("statechange",{qualities:this._qualities})}updateQualitySelection(){this._qualities=this._qualities.map((e,t)=>({...e,selected:t===this.currentQualityIndex}))}updateAudioTracks(){if(!this.hls)return;this._audioTracks=this.hls.audioTracks.map((e,t)=>({id:String(e.id),label:e.name||`Track ${t+1}`,language:e.lang||"",kind:e.default?"main":"alternative",selected:t===this.hls.audioTrack})),this.events.emit("statechange",{audioTracks:this._audioTracks})}updateTextTracks(){if(!this.hls)return;this._textTracks=this.hls.subtitleTracks.map((e,t)=>({id:String(e.id),kind:"subtitles",label:e.name||`Subtitle ${t+1}`,language:e.lang||"",mode:t===this.hls.subtitleTrack?"showing":"disabled",cues:[]})),this.events.emit("statechange",{textTracks:this._textTracks})}async play(){if(!this.video)return;try{await this.video.play()}catch(e){if(e.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",e);else throw e}}pause(){this.video?.pause()}seekTo(e){if(this.video)this.video.currentTime=Math.max(0,Math.min(e,this.getDuration()))}getCurrentTime(){return this.video?.currentTime||0}getDuration(){return this.video?.duration||0}syncToLive(){if(this.hls?.liveSyncPosition!=null)this.seekTo(this.hls.liveSyncPosition)}setVolume(e){if(this.video)this.video.volume=Math.max(0,Math.min(1,e))}getVolume(){return this.video?.volume||1}setMuted(e){if(this.video)this.video.muted=e}getMuted(){return this.video?.muted||!1}setPlaybackRate(e){if(this.video)this.video.playbackRate=Math.max(0.25,Math.min(4,e))}getPlaybackRate(){return this.video?.playbackRate||1}getQualities(){return this._qualities}setQuality(e){if(!this.hls)return;if(e==="auto")this.hls.currentLevel=-1,this.currentQualityIndex=-1,this.events.emit("statechange",{autoQuality:!0});else{let t=parseInt(e.id,10);if(!isNaN(t)&&t>=0&&t<this._qualities.length)this.hls.currentLevel=t,this.currentQualityIndex=t,this.events.emit("statechange",{autoQuality:!1})}}getAudioTracks(){return this._audioTracks}setAudioTrack(e){if(!this.hls)return;let t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<this.hls.audioTracks.length)this.hls.audioTrack=t}getTextTracks(){return this._textTracks}setTextTrackMode(e,t){if(!this.hls)return;if(t==="showing"){let n=parseInt(e,10);if(!isNaN(n))this.hls.subtitleTrack=n}else this.hls.subtitleTrack=-1;this.updateTextTracks();let i=this._textTracks.find((n)=>n.mode==="showing");this.events.emit("texttrackchange",i||null)}}var xe={name:"hls",type:"hls",canPlay(e){return Se(e)},mediaType(){return"video"},preconnect(){return["https://cdn.jsdelivr.net"]},async load(e,t){let i=new C;return await i.setup(e,t),i}};var T=null,K=null,Ft="https://cdn.dashjs.org/latest/dash.all.min.js";async function Ot(e){if(T)return T;if(K)return K;return K=new Promise((t,i)=>{if(typeof window<"u"&&window.dashjs){T=window.dashjs,t(T);return}let n=document.createElement("script");n.src=e||Ft,n.async=!0,n.onload=()=>{T=window.dashjs,t(T)},n.onerror=()=>{i(Error("Failed to load dash.js"))},document.head.appendChild(n)}),K}function W(e){if(typeof e==="object"&&"type"in e&&e.type==="dash")return!0;if(typeof e==="string")return e.includes(".mpd")||e.includes("manifest(format=mpd");return!1}class R extends b{name="dash";type="dash";dash=null;video=null;source=null;config={};_volume=1;_muted=!1;_playbackRate=1;get mediaElement(){return this.video}async initialize(){if(this.video=document.createElement("video"),this.video.style.width="100%",this.video.style.height="100%",this.video.style.display="block",await Ot(this.options.dashCdnUrl),this.dash=T.MediaPlayer().create(),this.options.dashConfig)this.config.dashConfig=this.options.dashConfig;if(this.config.dashConfig)Object.entries(this.config.dashConfig).forEach(([e,t])=>{this.dash.updateSettings({[e]:t})});if(this.config.lowLatency)this.dash.updateSettings({streaming:{lowLatencyEnabled:!0,liveDelay:3,liveCatchUpMinDrift:0.05,liveCatchUpPlaybackRate:0.5}});if(this.attachDashEvents(),this.container)this.container.appendChild(this.video);this.attachVideoEvents()}attachVideoEvents(){if(!this.video)return;this.video.addEventListener("play",()=>this.events.emit("play")),this.video.addEventListener("pause",()=>this.events.emit("pause")),this.video.addEventListener("ended",()=>this.events.emit("ended")),this.video.addEventListener("timeupdate",()=>this.events.emit("timeupdate",this.getCurrentTime())),this.video.addEventListener("durationchange",()=>this.events.emit("durationchange",this.getDuration())),this.video.addEventListener("volumechange",()=>{this.events.emit("volumechange",this.getVolume(),this.getMuted())}),this.video.addEventListener("waiting",()=>this.events.emit("waiting")),this.video.addEventListener("playing",()=>this.events.emit("playing")),this.video.addEventListener("seeking",()=>this.events.emit("seeking")),this.video.addEventListener("seeked",()=>this.events.emit("seeked")),this.video.addEventListener("progress",()=>{let e=[];for(let t=0;t<this.video.buffered.length;t++)e.push({start:this.video.buffered.start(t),end:this.video.buffered.end(t)});this.events.emit("progress",e)}),this.video.addEventListener("loadedmetadata",()=>{this.events.emit("loadedmetadata");let e=this.getFeatureAvailability("fullscreen"),t=this.getFeatureAvailability("pip"),i=this.getFeatureAvailability("volume");this.events.emit("statechange",{videoWidth:this.video.videoWidth,videoHeight:this.video.videoHeight,aspectRatio:(this.video.videoHeight>0?this.video.videoWidth/this.video.videoHeight:0)||1.7777777777777777,canFullscreen:e==="available",canPictureInPicture:t==="available",fullscreenAvailability:e,pipAvailability:t,volumeAvailability:i}),this.events.emit("availabilitychange","fullscreen",e),this.events.emit("availabilitychange","pip",t),this.events.emit("availabilitychange","volume",i)}),this.video.addEventListener("loadeddata",()=>this.events.emit("loadeddata")),this.video.addEventListener("canplay",()=>this.events.emit("canplay")),this.video.addEventListener("canplaythrough",()=>this.events.emit("canplaythrough")),this.video.addEventListener("ratechange",()=>this.events.emit("ratechange",this.getPlaybackRate()))}attachDashEvents(){if(!T)return;let e=T.MediaPlayer;this.dash.on(e.events.QUALITY_CHANGE_RENDERED,()=>{this.events.emit("qualitychange",this.getQualities().find((t)=>t.selected)||null)}),this.dash.on(e.events.MANIFEST_LOADED,()=>{}),this.dash.on(e.events.ERROR,(t)=>{this.emitError(t.error?.code||0,t.error?.message||"DASH playback error",t.error)})}configureDRM(e){let t={};if(e.widevine)t["com.widevine.alpha"]={serverURL:e.widevine.url,httpRequestHeaders:e.widevine.headers};if(e.playready)t["com.microsoft.playready"]={serverURL:e.playready.url,httpRequestHeaders:e.playready.headers};if(e.fairplay)t["com.apple.fps.1_0"]={serverURL:e.fairplay.url,serverCertificateURL:e.fairplay.certificateUrl,httpRequestHeaders:e.fairplay.headers};this.dash.setProtectionData(t)}async load(e){if(!this.video||!this.dash)return;if(typeof e==="string")this.source={src:e,type:"dash"};else if(W(e))this.source=e;else{this.emitError(4,"Invalid DASH source");return}if(this.source.drm)this.configureDRM(this.source.drm);this.dash.initialize(this.video,this.source.src,!1)}canPlay(e){return W(e)}cleanup(){if(this.dash)this.dash.reset(),this.dash=null;if(this.video)this.video.remove(),this.video=null;this.source=null}async play(){if(!this.video)return;try{await this.video.play()}catch(e){if(e.name==="NotAllowedError")this.emitError(1,"Playback was blocked. User interaction required.",e);else throw e}}pause(){if(this.video)this.video.pause()}seekTo(e){if(this.video)this.video.currentTime=e}getCurrentTime(){return this.video?.currentTime||0}getDuration(){return this.video?.duration||0}setVolume(e){if(this._volume=Math.max(0,Math.min(1,e)),this.video)this.video.volume=this._volume}getVolume(){return this.video?.volume??this._volume}setMuted(e){if(this._muted=e,this.video)this.video.muted=e}getMuted(){return this.video?.muted??this._muted}setPlaybackRate(e){if(this._playbackRate=e,this.video)this.video.playbackRate=e}getPlaybackRate(){return this.video?.playbackRate??this._playbackRate}get isLive(){return this.dash?.isDynamic()??!1}get liveLatency(){return this.dash?.getCurrentLiveLatency()??0}get canLiveSync(){return this.isLive}syncToLive(){if(this.dash&&this.isLive)this.dash.seekToOriginalLive()}getQualities(){if(!this.dash)return[];let e=this.dash.getBitrateInfoListFor("video");if(!e)return[];let t=this.dash.getQualityFor("video");return e.map((i,n)=>({id:`${n}`,label:`${i.height}p`,width:i.width,height:i.height,bitrate:i.bitrate,selected:n===t}))}setQuality(e){if(!this.dash)return;if(e==="auto")this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!0}}}});else{let t=Number.parseInt(e.id,10);if(!Number.isNaN(t))this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1}}}}),this.dash.setQualityFor("video",t)}}get isAutoQuality(){if(!this.dash)return!0;return this.dash.getSettings()?.streaming?.abr?.autoSwitchBitrate?.video??!0}getAudioTracks(){if(!this.dash)return[];let e=this.dash.getTracksFor("audio");if(!e)return[];let t=this.dash.getCurrentTrackFor("audio");return e.map((i,n)=>({id:i.id||`${n}`,label:i.labels?.[0]?.text||i.lang||`Track ${n+1}`,language:i.lang||"",kind:"main",selected:i===t}))}setAudioTrack(e){if(!this.dash)return;let i=this.dash.getTracksFor("audio").find((n,s)=>(n.id||`${s}`)===e);if(i)this.dash.setCurrentTrack(i)}getTextTracks(){if(!this.dash)return[];let e=this.dash.getTracksFor("text");if(!e)return[];let t=this.dash.getCurrentTrackFor("text");return e.map((i,n)=>({id:i.id||`${n}`,label:i.labels?.[0]?.text||i.lang||`Subtitle ${n+1}`,language:i.lang||"",kind:i.kind||"subtitles",mode:i===t?"showing":"disabled",cues:[]}))}setTextTrackMode(e,t){if(!this.dash)return;if(t==="disabled"){this.dash.enableText(!1);return}let n=this.dash.getTracksFor("text").find((s,r)=>(s.id||`${r}`)===e);if(n)this.dash.setCurrentTrack(n),this.dash.enableText(t==="showing")}}var Ee={name:"dash",type:"dash",canPlay(e){return W(e)},mediaType(){return"video"},async load(e,t){let i=new R;return await i.setup(e,t),i},preconnect(){return["https://cdn.dashjs.org"]}};var j=[xe,Ee,be,we,fe];function lt(e){if(!e||typeof e!=="object"||typeof e.src!=="string")return null;return"type"in e&&e.type?null:e.src}var qt={youtube:()=>"youtube",vimeo:()=>"vimeo",hls:()=>"application/x-mpegurl",dash:()=>"dash",video:(e)=>z(e)};function Nt(e,t){let i=lt(e),n=i&&qt[t.type];return i&&n?{...e,type:n(i)}:e}function zt(e,t=j){for(let n of t)if(n.canPlay(e))return n;let i=lt(e);if(i){for(let n of t)if(n.canPlay(i))return n}return null}function dt(e,t=j){let i=[];return e.forEach((n,s)=>{let r=zt(n,t);if(r)i.push({src:Nt(n,r),index:s,loader:r})}),i}class E{_el;_options;_store;_events=new x;_provider=null;_loaders;_cleanupFns=[];_destroyed=!1;_sourceLoadId=0;_announcer=null;constructor(e,t={}){if(typeof e==="string"){let i=document.querySelector(e);if(!i)throw Error(`Container element not found: ${e}`);this._el=i}else this._el=e;if(this._options={...Ut,...t},this._loaders=j,this._store=new A,this.setupElement(),this.setupState(),this.setupKeyboard(),this.setupActivity(),this.setupStorage(),this.setupMediaSession(),this.setupEvents(),this._options.src)this.setSrc(this._options.src);this._events.emit("init")}get el(){return this._el}get state(){return this._store.getState()}get provider(){return this._provider}get ready(){return this._provider?.ready||!1}setupElement(){this._el.classList.add("ts-video-player"),this._el.setAttribute("tabindex","0"),this._el.setAttribute("role","region"),this._el.setAttribute("aria-roledescription","video player"),this._el.setAttribute("aria-label",this._options.title||"Video player"),this._el.setAttribute("aria-keyshortcuts","Space K M F I C ArrowLeft ArrowRight J L ArrowUp ArrowDown Home End 0 1 2 3 4 5 6 7 8 9");let e=document.createElement("div");if(e.className="ts-video-player__container",this._el.appendChild(e),this._options.announcements!==!1){let i=document.createElement("div");i.className="ts-video-player__announcer",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",this._el.appendChild(i),this._announcer=i}let t=this._el;t.__videoPlayer=this}setupState(){this._store.batch({volume:this._options.volume??1,muted:this._options.muted??!1,loop:this._options.loop??!1,autoplay:this._options.autoplay??!1,playsinline:this._options.playsinline??!0,playbackRate:this._options.playbackRate??1,poster:this._options.poster||"",title:this._options.title||"",preload:this._options.preload||"metadata"});let e=this._store.subscribe((t)=>{this.updateAttributes(t)});this._cleanupFns.push(e)}setupKeyboard(){if(this._options.keyboard===!1)return;let e={togglePlay:()=>this.togglePlay(),toggleMute:()=>this.toggleMute(),toggleFullscreen:()=>this.toggleFullscreen(),togglePiP:()=>this.togglePiP(),toggleCaptions:()=>this.toggleCaptions(),seekBackward:()=>this.seekBy(-5),seekForward:()=>this.seekBy(5),volumeUp:()=>this.setVolume(Math.min(1,this.state.volume+0.1)),volumeDown:()=>this.setVolume(Math.max(0,this.state.volume-0.1)),speedUp:()=>this.setPlaybackRate(Math.min(4,this.state.playbackRate+0.25)),speedDown:()=>this.setPlaybackRate(Math.max(0.25,this.state.playbackRate-0.25)),seekStart:()=>this.seekTo(0),seekEnd:()=>this.seekTo(this.state.duration),seekPercent:(s)=>this.seekTo(s/100*this.state.duration)},t=typeof this._options.keyboard==="object"?this._options.keyboard:{},i=Ne(e,{seekStep:t.seekStep,volumeStep:t.volumeStep}),n=t.global?document:this._el;n.addEventListener("keydown",i),this._cleanupFns.push(()=>n.removeEventListener("keydown",i))}setupActivity(){let e=ze(this._el,{timeout:this._options.controlsTimeout||3000,onActive:()=>{this._store.batch({userActive:!0,controlsVisible:!0}),this._events.emit("useractivitychange",!0),this._events.emit("controlschange",!0)},onInactive:()=>{if(this.state.playing)this._store.batch({userActive:!1,controlsVisible:!1}),this._events.emit("useractivitychange",!1),this._events.emit("controlschange",!1)}});this._cleanupFns.push(e);let t=()=>this._store.set("pointerOver",!0),i=()=>this._store.set("pointerOver",!1);this._el.addEventListener("mouseenter",t),this._el.addEventListener("mouseleave",i),this._cleanupFns.push(()=>this._el.removeEventListener("mouseenter",t),()=>this._el.removeEventListener("mouseleave",i))}setupStorage(){if(!this._options.storage)return;let e=typeof this._options.storage==="object"?this._options.storage:{},t=e.type==="session"?sessionStorage:localStorage,i=qe(this._store,e.persist||["volume","muted","playbackRate"],t);this._cleanupFns.push(i)}setupMediaSession(){if(this._options.mediaSession===!1)return;let e=typeof this._options.mediaSession==="object"?this._options.mediaSession:this._options.title?{title:this._options.title}:void 0,t=Qe(this._store,{play:()=>this.play(),pause:()=>this.pause(),seekTo:(i)=>this.seekTo(i),seekBy:(i)=>this.seekBy(i),stop:()=>this.stop()},e);this._cleanupFns.push(t)}setupEvents(){if(this._options.on){for(let[e,t]of Object.entries(this._options.on))if(t)this.on(e,t)}}updateAttributes(e){let t=this._el;t.dataset.paused=String(e.paused),t.dataset.playing=String(e.playing),t.dataset.started=String(e.started),t.dataset.ended=String(e.ended),t.dataset.seeking=String(e.seeking),t.dataset.waiting=String(e.waiting),t.dataset.loop=String(e.loop),t.dataset.autoplay=String(e.autoplay),t.dataset.loading=String(e.waiting||e.loadingState==="loading"),t.dataset.canPlay=String(e.canPlay),t.dataset.loadingState=e.loadingState,t.setAttribute("aria-busy",String(e.waiting||e.loadingState==="loading")),t.dataset.muted=String(e.muted),t.dataset.volumeLevel=e.muted||e.volume===0?"silent":e.volume<0.5?"low":"high",t.dataset.fullscreen=String(e.fullscreen),t.dataset.pip=String(e.pictureInPicture),t.dataset.controlsVisible=String(e.controlsVisible),t.dataset.userActive=String(e.userActive),t.dataset.mediaType=e.mediaType,t.dataset.streamType=e.streamType;let i=e.textTracks.some((n)=>n.mode==="showing");t.dataset.captions=String(i),t.dataset.error=String(!!e.error)}announce(e){if(!this._announcer)return;this._announcer.textContent="",requestAnimationFrame(()=>{if(this._announcer)this._announcer.textContent=e})}destroy(){if(this._destroyed)return;this._destroyed=!0,this._sourceLoadId++,this._events.emit("destroy"),this._cleanupFns.forEach((e)=>e()),this._cleanupFns=[],this._provider?.destroy(),this._provider=null,this._events.removeAllListeners(),this._store.reset(),this._el.classList.remove("ts-video-player"),this._el.innerHTML="",delete this._el.__videoPlayer}async setSrc(e){if(this._destroyed)return;let t=++this._sourceLoadId,i=Array.isArray(e)?e:[e];if(i.length===0)return;this._store.batch({sources:i,src:i[0],loadingState:"loading",error:null}),this._events.emit("sourceschange",i);let n=dt(i,this._loaders);if(n.length===0){this._store.batch({loadingState:"error",error:{code:4,message:"No compatible provider found for source"}});return}let s;for(let r of n){if(this._destroyed||t!==this._sourceLoadId)return;let{loader:o}=r;if(this._provider&&this._provider.type!==o.type)this._provider.destroy(),this._provider=null,this._events.emit("providerchange",null);if(!this._provider){let a=this._el.querySelector(".ts-video-player__container");try{if(this._provider=await o.load(a,{...this._options,mediaType:o.mediaType(r.src)}),this._destroyed||t!==this._sourceLoadId){this._provider.destroy(),this._provider=null;return}this._events.emit("providerchange",this._provider),this.attachProviderEvents(this._provider)}catch(l){s=l,this._provider=null;continue}}try{let a=o.type==="video"?n.filter((l)=>l.loader.type===o.type).map((l)=>l.src):[r.src];if(await this._provider.load(a.length>1?a:r.src),this._destroyed||t!==this._sourceLoadId)return;this._store.batch({src:r.src,currentSourceIndex:r.index,mediaType:o.mediaType(r.src),providerType:o.type});return}catch(a){if(s=a,this._provider)this._provider.destroy(),this._provider=null;this._events.emit("providerchange",null)}}if(this._destroyed||t!==this._sourceLoadId)return;this._store.batch({loadingState:"error",error:{code:4,message:"Failed to load all compatible sources",details:s}})}getSrc(){return this.state.src}attachProviderEvents(e){e.on("loadstart",()=>{this._store.set("loadingState","loading"),this._events.emit("loadstart")}),e.on("loadedmetadata",()=>{this._events.emit("loadedmetadata")}),e.on("loadeddata",()=>{this._events.emit("loadeddata")}),e.on("canplay",()=>{this._store.batch({canPlay:!0,loadingState:"loaded"}),this._events.emit("canplay")}),e.on("canplaythrough",()=>{this._store.set("canPlayThrough",!0),this._events.emit("canplaythrough")}),e.on("play",()=>{this._store.batch({paused:!1,ended:!1}),this._events.emit("play"),this.announce("Playing")}),e.on("pause",()=>{this._store.set("paused",!0),this._events.emit("pause"),this.announce("Paused")}),e.on("playing",()=>{this._store.batch({playing:!0,started:!0,waiting:!1,playbackState:"playing"}),this._events.emit("playing")}),e.on("waiting",()=>{this._store.batch({waiting:!0,playbackState:"buffering"}),this._events.emit("waiting")}),e.on("seeking",()=>{this._store.set("seeking",!0),this._events.emit("seeking")}),e.on("seeked",()=>{this._store.set("seeking",!1),this._events.emit("seeked")}),e.on("timeupdate",(t)=>{this._store.set("currentTime",t),this._events.emit("timeupdate",t)}),e.on("durationchange",(t)=>{this._store.set("duration",t),this._events.emit("durationchange",t)}),e.on("volumechange",(t,i)=>{if(this._store.batch({volume:t,muted:i}),this._events.emit("volumechange",t,i),i)this.announce("Muted");else this.announce(`Volume ${Math.round(t*100)}%`)}),e.on("ratechange",(t)=>{this._store.set("playbackRate",t),this._events.emit("ratechange",t)}),e.on("progress",(t)=>{this._store.batch({buffered:t,bufferedAmount:$e({...this.state,buffered:t})}),this._events.emit("progress",t)}),e.on("ended",()=>{if(this._store.batch({ended:!0,playing:!1,playbackState:"ended"}),this._events.emit("ended"),this.announce("Playback ended"),this.state.loop)this.seekTo(0),this.play()}),e.on("error",(t)=>{this._store.batch({loadingState:"error",error:t}),this._events.emit("error",t),this.announce(`Error: ${t.message}`)}),e.on("statechange",(t)=>{this._store.batch(t),this._events.emit("statechange",t)}),e.on("qualitychange",(t)=>{this._store.set("qualities",e.getQualities()),this._events.emit("qualitychange",t)}),e.on("fullscreenchange",(t)=>{this._store.set("fullscreen",t),this._events.emit("fullscreenchange",t),this.announce(t?"Entered fullscreen":"Exited fullscreen")}),e.on("pipchange",(t)=>{this._store.set("pictureInPicture",t),this._events.emit("pipchange",t)}),e.on("availabilitychange",(t,i)=>{if(t==="volume")this._store.set("volumeAvailability",i);else if(t==="fullscreen")this._store.set("fullscreenAvailability",i);else if(t==="pip")this._store.set("pipAvailability",i);this._events.emit("availabilitychange",t,i)})}async play(){if(!this._provider)return;await this._provider.play()}pause(){this._provider?.pause()}togglePlay(){if(this.state.paused)this.play().catch(()=>{});else this.pause()}stop(){this._provider?.stop(),this._store.batch({playing:!1,paused:!0,currentTime:0,playbackState:"idle"})}seekTo(e){this._provider?.seekTo(e)}seekBy(e){let t=Math.max(0,Math.min(this.state.currentTime+e,this.state.duration));this.seekTo(t)}setVolume(e){if(this.state.volumeAvailability==="unsupported")return;let t=Math.max(0,Math.min(1,e));this._provider?.setVolume(t),this._store.set("volume",t)}setMuted(e){this._provider?.setMuted(e),this._store.set("muted",e)}toggleMute(){this.setMuted(!this.state.muted)}setPlaybackRate(e){let t=Math.max(0.25,Math.min(4,e));this._provider?.setPlaybackRate(t),this._store.set("playbackRate",t)}async enterFullscreen(){if(this.state.fullscreenAvailability==="unsupported")return;if(this.state.pictureInPicture)await this.exitPiP();if(await this._provider?.enterFullscreen(),this._options.fullscreenOrientationLock!==!1)We("landscape")}async exitFullscreen(){if(await this._provider?.exitFullscreen(),this._options.fullscreenOrientationLock!==!1)je()}async toggleFullscreen(){if(this.state.fullscreen)await this.exitFullscreen();else await this.enterFullscreen()}async enterPiP(){if(this.state.pipAvailability==="unsupported")return;if(this.state.fullscreen)await this.exitFullscreen();await this._provider?.enterPiP()}async exitPiP(){await this._provider?.exitPiP()}async togglePiP(){if(this.state.pictureInPicture)await this.exitPiP();else await this.enterPiP()}setQuality(e){if(this._provider?.setQuality(e),e==="auto")this._store.set("autoQuality",!0);else this._store.set("autoQuality",!1)}setTextTrack(e,t){this._provider?.setTextTrackMode(e,t),this._store.set("textTracks",this._provider?.getTextTracks()||[])}setAudioTrack(e){this._provider?.setAudioTrack(e),this._store.set("audioTracks",this._provider?.getAudioTracks()||[])}toggleCaptions(){let e=this.state.textTracks,t=e.find((i)=>i.mode==="showing");if(t)this.setTextTrack(t.id,"disabled");else{let i=e.find((n)=>n.kind==="subtitles"||n.kind==="captions");if(i)this.setTextTrack(i.id,"showing")}}on(e,t){this._events.on(e,t)}off(e,t){this._events.off(e,t)}once(e,t){this._events.once(e,t)}subscribe(e,t){return this._store.subscribe(e,t)}}var Ut={autoplay:!1,loop:!1,muted:!1,volume:1,playbackRate:1,playsinline:!0,preload:"metadata",controls:!0,keyboard:!0,controlsTimeout:3000,storage:!0};function ct(e,t){return new E(e,t)}var Qt={colors:{primary:"#00a8ff",secondary:"#6c5ce7",background:"rgba(0, 0, 0, 0.85)",text:"#ffffff",textOnPrimary:"#ffffff",border:"rgba(255, 255, 255, 0.1)",focus:"#00a8ff",error:"#ff4757",success:"#2ed573",warning:"#ffa502"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',fontSize:"14px",fontSizeSmall:"12px",fontSizeLarge:"16px",fontWeight:"400",fontWeightBold:"600",lineHeight:"1.5"},spacing:{xs:"4px",sm:"8px",md:"12px",lg:"16px",xl:"24px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.2)",md:"0 4px 6px rgba(0, 0, 0, 0.3)",lg:"0 10px 15px rgba(0, 0, 0, 0.4)"},transitions:{fast:"100ms",normal:"200ms",slow:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)"},slider:{trackHeight:"4px",thumbSize:"14px",trackBg:"rgba(255, 255, 255, 0.2)",trackFillBg:"var(--tsvp-color-primary)",bufferedBg:"rgba(255, 255, 255, 0.4)",thumbBg:"#ffffff",thumbBorder:"none"},controls:{height:"48px",background:"linear-gradient(transparent, rgba(0, 0, 0, 0.7))",padding:"0 12px",buttonSize:"40px",iconSize:"24px",tooltipBg:"rgba(0, 0, 0, 0.9)",tooltipText:"#ffffff"},menu:{background:"rgba(20, 20, 20, 0.95)",borderRadius:"8px",shadow:"0 4px 20px rgba(0, 0, 0, 0.5)",itemHeight:"40px",itemHoverBg:"rgba(255, 255, 255, 0.1)",itemActiveBg:"rgba(0, 168, 255, 0.2)"},captions:{fontFamily:"inherit",fontSize:"1.5em",textColor:"#ffffff",background:"rgba(0, 0, 0, 0.75)",textShadow:"0 1px 2px rgba(0, 0, 0, 0.5)",borderRadius:"4px",padding:"4px 8px"},thumbnails:{width:"160px",height:"90px",borderRadius:"4px",border:"2px solid rgba(255, 255, 255, 0.2)",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},live:{indicatorColor:"#ff0000",indicatorSize:"8px",badgeBg:"#ff0000",badgeText:"#ffffff"}},Kt={colors:{primary:"#00a8ff",background:"rgba(0, 0, 0, 0.9)",text:"#ffffff"}},Wt={colors:{primary:"#0070f3",background:"rgba(255, 255, 255, 0.95)",text:"#1a1a1a",textOnPrimary:"#ffffff",border:"rgba(0, 0, 0, 0.1)"},controls:{background:"linear-gradient(transparent, rgba(255, 255, 255, 0.9))",tooltipBg:"rgba(0, 0, 0, 0.8)"},menu:{background:"rgba(255, 255, 255, 0.98)",shadow:"0 4px 20px rgba(0, 0, 0, 0.15)",itemHoverBg:"rgba(0, 0, 0, 0.05)",itemActiveBg:"rgba(0, 112, 243, 0.1)"},captions:{background:"rgba(255, 255, 255, 0.9)",textColor:"#1a1a1a"}},jt={colors:{primary:"#ffffff",background:"transparent"},controls:{height:"40px",background:"transparent"},slider:{trackHeight:"2px",thumbSize:"10px"}},Yt={colors:{primary:"#e50914",background:"rgba(0, 0, 0, 0.85)"},slider:{trackFillBg:"#e50914"},live:{indicatorColor:"#e50914",badgeBg:"#e50914"}},Xt={colors:{primary:"#ff0000",background:"rgba(0, 0, 0, 0.85)"},slider:{trackHeight:"3px",thumbSize:"13px",trackFillBg:"#ff0000"},controls:{height:"48px"},live:{indicatorColor:"#ff0000",badgeBg:"#ff0000"}},Gt={colors:{primary:"#00adef",background:"rgba(0, 0, 0, 0.85)"},slider:{trackFillBg:"#00adef"}},Pe={dark:Kt,light:Wt,minimal:jt,netflix:Yt,youtube:Xt,vimeo:Gt};function Jt(e,t){let i={...e};for(let n of Object.keys(t)){let s=e[n],r=t[n];if(r&&typeof r==="object")i[n]={...s||{},...r};else if(r!==void 0)i[n]=r}return i}function Zt(e,t="tsvp"){let i=Jt(Qt,e),n=[];if(i.colors)n.push(`--${t}-color-primary: ${i.colors.primary};`),n.push(`--${t}-color-secondary: ${i.colors.secondary};`),n.push(`--${t}-color-background: ${i.colors.background};`),n.push(`--${t}-color-text: ${i.colors.text};`),n.push(`--${t}-color-text-on-primary: ${i.colors.textOnPrimary};`),n.push(`--${t}-color-border: ${i.colors.border};`),n.push(`--${t}-color-focus: ${i.colors.focus};`),n.push(`--${t}-color-error: ${i.colors.error};`),n.push(`--${t}-color-success: ${i.colors.success};`),n.push(`--${t}-color-warning: ${i.colors.warning};`);if(i.typography)n.push(`--${t}-font-family: ${i.typography.fontFamily};`),n.push(`--${t}-font-size: ${i.typography.fontSize};`),n.push(`--${t}-font-size-sm: ${i.typography.fontSizeSmall};`),n.push(`--${t}-font-size-lg: ${i.typography.fontSizeLarge};`),n.push(`--${t}-font-weight: ${i.typography.fontWeight};`),n.push(`--${t}-font-weight-bold: ${i.typography.fontWeightBold};`),n.push(`--${t}-line-height: ${i.typography.lineHeight};`);if(i.spacing)n.push(`--${t}-spacing-xs: ${i.spacing.xs};`),n.push(`--${t}-spacing-sm: ${i.spacing.sm};`),n.push(`--${t}-spacing-md: ${i.spacing.md};`),n.push(`--${t}-spacing-lg: ${i.spacing.lg};`),n.push(`--${t}-spacing-xl: ${i.spacing.xl};`);if(i.borderRadius)n.push(`--${t}-radius-sm: ${i.borderRadius.sm};`),n.push(`--${t}-radius-md: ${i.borderRadius.md};`),n.push(`--${t}-radius-lg: ${i.borderRadius.lg};`),n.push(`--${t}-radius-full: ${i.borderRadius.full};`);if(i.shadows)n.push(`--${t}-shadow-sm: ${i.shadows.sm};`),n.push(`--${t}-shadow-md: ${i.shadows.md};`),n.push(`--${t}-shadow-lg: ${i.shadows.lg};`);if(i.transitions)n.push(`--${t}-transition-fast: ${i.transitions.fast};`),n.push(`--${t}-transition-normal: ${i.transitions.normal};`),n.push(`--${t}-transition-slow: ${i.transitions.slow};`),n.push(`--${t}-transition-easing: ${i.transitions.easing};`);if(i.slider)n.push(`--${t}-slider-track-height: ${i.slider.trackHeight};`),n.push(`--${t}-slider-thumb-size: ${i.slider.thumbSize};`),n.push(`--${t}-slider-track-bg: ${i.slider.trackBg};`),n.push(`--${t}-slider-track-fill-bg: ${i.slider.trackFillBg};`),n.push(`--${t}-slider-buffered-bg: ${i.slider.bufferedBg};`),n.push(`--${t}-slider-thumb-bg: ${i.slider.thumbBg};`),n.push(`--${t}-slider-thumb-border: ${i.slider.thumbBorder};`);if(i.controls)n.push(`--${t}-controls-height: ${i.controls.height};`),n.push(`--${t}-controls-bg: ${i.controls.background};`),n.push(`--${t}-controls-padding: ${i.controls.padding};`),n.push(`--${t}-controls-button-size: ${i.controls.buttonSize};`),n.push(`--${t}-controls-icon-size: ${i.controls.iconSize};`),n.push(`--${t}-controls-tooltip-bg: ${i.controls.tooltipBg};`),n.push(`--${t}-controls-tooltip-text: ${i.controls.tooltipText};`);if(i.menu)n.push(`--${t}-menu-bg: ${i.menu.background};`),n.push(`--${t}-menu-radius: ${i.menu.borderRadius};`),n.push(`--${t}-menu-shadow: ${i.menu.shadow};`),n.push(`--${t}-menu-item-height: ${i.menu.itemHeight};`),n.push(`--${t}-menu-item-hover-bg: ${i.menu.itemHoverBg};`),n.push(`--${t}-menu-item-active-bg: ${i.menu.itemActiveBg};`);if(i.captions)n.push(`--${t}-captions-font-family: ${i.captions.fontFamily};`),n.push(`--${t}-captions-font-size: ${i.captions.fontSize};`),n.push(`--${t}-captions-text-color: ${i.captions.textColor};`),n.push(`--${t}-captions-bg: ${i.captions.background};`),n.push(`--${t}-captions-text-shadow: ${i.captions.textShadow};`),n.push(`--${t}-captions-radius: ${i.captions.borderRadius};`),n.push(`--${t}-captions-padding: ${i.captions.padding};`);if(i.thumbnails)n.push(`--${t}-thumbnail-width: ${i.thumbnails.width};`),n.push(`--${t}-thumbnail-height: ${i.thumbnails.height};`),n.push(`--${t}-thumbnail-radius: ${i.thumbnails.borderRadius};`),n.push(`--${t}-thumbnail-border: ${i.thumbnails.border};`),n.push(`--${t}-thumbnail-shadow: ${i.thumbnails.shadow};`);if(i.live)n.push(`--${t}-live-indicator-color: ${i.live.indicatorColor};`),n.push(`--${t}-live-indicator-size: ${i.live.indicatorSize};`),n.push(`--${t}-live-badge-bg: ${i.live.badgeBg};`),n.push(`--${t}-live-badge-text: ${i.live.badgeText};`);return n.join(`
2
+ `)}function ut(e,t){let i=typeof t==="string"?Pe[t]:t;e.querySelectorAll("style[data-tsvp-theme]").forEach((s)=>s.remove());let n=Zt(i);e.style.cssText+=n.split(`
3
+ `).map((s)=>s.trim().replace(";","")).join("; ")}var ei={play:"Play",pause:"Pause",replay:"Replay",mute:"Mute",unmute:"Unmute",volume:"Volume",seekBackward:"Seek backward {seconds} seconds",seekForward:"Seek forward {seconds} seconds",seekTo:"Seek to {time}",duration:"Duration",currentTime:"Current time",played:"Played",buffered:"Buffered",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",enterPiP:"Enter picture-in-picture",exitPiP:"Exit picture-in-picture",enableCaptions:"Enable captions",disableCaptions:"Disable captions",captions:"Captions",captionsOff:"Off",settings:"Settings",quality:"Quality",auto:"Auto",speed:"Speed",normal:"Normal",loop:"Loop",loopEnabled:"Loop enabled",loopDisabled:"Loop disabled",audioBoost:"Audio boost",audioTrack:"Audio track",live:"LIVE",liveEdge:"At live edge",seekToLive:"Seek to live edge",behindLive:"{seconds}s behind",networkError:"A network error occurred",mediaError:"The media could not be loaded",unknownError:"An unknown error occurred",loading:"Loading",buffering:"Buffering",chapters:"Chapters",airPlay:"AirPlay",googleCast:"Cast",casting:"Casting to {device}",download:"Download",share:"Share",close:"Close",menu:"Menu",back:"Back"},ti={play:"Reproducir",pause:"Pausar",replay:"Repetir",mute:"Silenciar",unmute:"Activar sonido",volume:"Volumen",seekBackward:"Retroceder {seconds} segundos",seekForward:"Avanzar {seconds} segundos",seekTo:"Ir a {time}",duration:"Duración",currentTime:"Tiempo actual",played:"Reproducido",buffered:"Almacenado",enterFullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",enterPiP:"Imagen en imagen",exitPiP:"Salir de imagen en imagen",enableCaptions:"Activar subtítulos",disableCaptions:"Desactivar subtítulos",captions:"Subtítulos",captionsOff:"Desactivados",settings:"Ajustes",quality:"Calidad",auto:"Automático",speed:"Velocidad",normal:"Normal",loop:"Bucle",loopEnabled:"Bucle activado",loopDisabled:"Bucle desactivado",audioBoost:"Aumento de audio",audioTrack:"Pista de audio",live:"EN VIVO",liveEdge:"En vivo",seekToLive:"Ir al directo",behindLive:"{seconds}s de retraso",networkError:"Error de red",mediaError:"No se pudo cargar el medio",unknownError:"Error desconocido",loading:"Cargando",buffering:"Almacenando",chapters:"Capítulos",airPlay:"AirPlay",googleCast:"Enviar",casting:"Enviando a {device}",download:"Descargar",share:"Compartir",close:"Cerrar",menu:"Menú",back:"Volver"},ii={play:"Lecture",pause:"Pause",replay:"Relire",mute:"Muet",unmute:"Son activé",volume:"Volume",seekBackward:"Reculer de {seconds} secondes",seekForward:"Avancer de {seconds} secondes",seekTo:"Aller à {time}",duration:"Durée",currentTime:"Temps actuel",played:"Joué",buffered:"Mis en mémoire tampon",enterFullscreen:"Plein écran",exitFullscreen:"Quitter le plein écran",enterPiP:"Image dans l'image",exitPiP:"Quitter l'image dans l'image",enableCaptions:"Activer les sous-titres",disableCaptions:"Désactiver les sous-titres",captions:"Sous-titres",captionsOff:"Désactivés",settings:"Paramètres",quality:"Qualité",auto:"Auto",speed:"Vitesse",normal:"Normal",loop:"Boucle",loopEnabled:"Boucle activée",loopDisabled:"Boucle désactivée",audioBoost:"Amplification audio",audioTrack:"Piste audio",live:"EN DIRECT",liveEdge:"En direct",seekToLive:"Aller au direct",behindLive:"{seconds}s de retard",networkError:"Erreur réseau",mediaError:"Le média n'a pas pu être chargé",unknownError:"Erreur inconnue",loading:"Chargement",buffering:"Mise en mémoire tampon",chapters:"Chapitres",airPlay:"AirPlay",googleCast:"Caster",casting:"Diffusion sur {device}",download:"Télécharger",share:"Partager",close:"Fermer",menu:"Menu",back:"Retour"},ni={play:"Abspielen",pause:"Pause",replay:"Wiederholen",mute:"Stumm",unmute:"Ton an",volume:"Lautstärke",seekBackward:"{seconds} Sekunden zurück",seekForward:"{seconds} Sekunden vor",seekTo:"Zu {time} springen",duration:"Dauer",currentTime:"Aktuelle Zeit",played:"Abgespielt",buffered:"Gepuffert",enterFullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",enterPiP:"Bild-in-Bild",exitPiP:"Bild-in-Bild beenden",enableCaptions:"Untertitel aktivieren",disableCaptions:"Untertitel deaktivieren",captions:"Untertitel",captionsOff:"Aus",settings:"Einstellungen",quality:"Qualität",auto:"Auto",speed:"Geschwindigkeit",normal:"Normal",loop:"Schleife",loopEnabled:"Schleife aktiviert",loopDisabled:"Schleife deaktiviert",audioBoost:"Audio-Verstärkung",audioTrack:"Audiospur",live:"LIVE",liveEdge:"Am Live-Punkt",seekToLive:"Zum Live-Punkt",behindLive:"{seconds}s hinter Live",networkError:"Netzwerkfehler",mediaError:"Medium konnte nicht geladen werden",unknownError:"Unbekannter Fehler",loading:"Wird geladen",buffering:"Puffern",chapters:"Kapitel",airPlay:"AirPlay",googleCast:"Streamen",casting:"Streame zu {device}",download:"Herunterladen",share:"Teilen",close:"Schließen",menu:"Menü",back:"Zurück"},si={play:"再生",pause:"一時停止",replay:"リプレイ",mute:"ミュート",unmute:"ミュート解除",volume:"音量",seekBackward:"{seconds}秒戻る",seekForward:"{seconds}秒進む",seekTo:"{time}にシーク",duration:"長さ",currentTime:"現在の時間",played:"再生済み",buffered:"バッファ済み",enterFullscreen:"フルスクリーン",exitFullscreen:"フルスクリーン終了",enterPiP:"ピクチャーインピクチャー",exitPiP:"ピクチャーインピクチャー終了",enableCaptions:"字幕を有効化",disableCaptions:"字幕を無効化",captions:"字幕",captionsOff:"オフ",settings:"設定",quality:"画質",auto:"自動",speed:"再生速度",normal:"通常",loop:"ループ",loopEnabled:"ループ有効",loopDisabled:"ループ無効",audioBoost:"オーディオブースト",audioTrack:"オーディオトラック",live:"ライブ",liveEdge:"ライブ中",seekToLive:"ライブに移動",behindLive:"{seconds}秒遅れ",networkError:"ネットワークエラー",mediaError:"メディアを読み込めません",unknownError:"不明なエラー",loading:"読み込み中",buffering:"バッファリング",chapters:"チャプター",airPlay:"AirPlay",googleCast:"キャスト",casting:"{device}にキャスト中",download:"ダウンロード",share:"共有",close:"閉じる",menu:"メニュー",back:"戻る"},ri={play:"播放",pause:"暂停",replay:"重播",mute:"静音",unmute:"取消静音",volume:"音量",seekBackward:"后退{seconds}秒",seekForward:"前进{seconds}秒",seekTo:"跳转到{time}",duration:"时长",currentTime:"当前时间",played:"已播放",buffered:"已缓冲",enterFullscreen:"全屏",exitFullscreen:"退出全屏",enterPiP:"画中画",exitPiP:"退出画中画",enableCaptions:"开启字幕",disableCaptions:"关闭字幕",captions:"字幕",captionsOff:"关闭",settings:"设置",quality:"画质",auto:"自动",speed:"播放速度",normal:"正常",loop:"循环",loopEnabled:"循环已开启",loopDisabled:"循环已关闭",audioBoost:"音频增强",audioTrack:"音轨",live:"直播",liveEdge:"直播中",seekToLive:"跳转到直播",behindLive:"落后{seconds}秒",networkError:"网络错误",mediaError:"无法加载媒体",unknownError:"未知错误",loading:"加载中",buffering:"缓冲中",chapters:"章节",airPlay:"AirPlay",googleCast:"投射",casting:"正在投射到{device}",download:"下载",share:"分享",close:"关闭",menu:"菜单",back:"返回"},ai={en:ei,es:ti,fr:ii,de:ni,ja:si,zh:ri};class Y{language;fallbackLanguage;translations;interpolationPattern;constructor(e={}){if(this.language=e.language||this.detectLanguage()||"en",this.fallbackLanguage=e.fallbackLanguage||"en",this.translations={...ai},e.translations){for(let[t,i]of Object.entries(e.translations))if(i)this.translations[t]={...this.translations[t],...i}}this.interpolationPattern=e.interpolationPattern||/\{(\w+)\}/g}detectLanguage(){if(typeof navigator>"u")return null;let e=navigator.language||navigator.userLanguage;if(!e)return null;if(this.translations[e])return e;let t=e.split("-")[0];if(this.translations[t])return t;return null}getLanguage(){return this.language}setLanguage(e){this.language=e}t(e,t){let i=this.translations[this.language]?.[e];if(!i)i=this.translations[this.fallbackLanguage]?.[e];if(!i)return e;if(t)i=i.replace(this.interpolationPattern,(n,s)=>{let r=t[s];return r!==void 0?String(r):n});return i}addTranslations(e,t){this.translations[e]={...this.translations[e],...t}}getTranslations(e){return this.translations[e]}getAvailableLanguages(){return Object.keys(this.translations)}hasLanguage(e){return e in this.translations}}var Ae=null;function oi(e){return new Y(e)}function li(e){if(!Ae)Ae=oi(e);return Ae}function pt(e,t){return li().t(e,t)}var di={name:"default",description:"Full-featured default layout with all controls",styles:`
4
4
  .tsvp-layout-default {
5
5
  --tsvp-controls-height: 48px;
6
6
  }
@@ -84,7 +84,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
84
84
  </div>
85
85
  </div>
86
86
  </div>
87
- `},_2={name:"minimal",description:"Clean, minimal layout with essential controls only",styles:`
87
+ `},ci={name:"minimal",description:"Clean, minimal layout with essential controls only",styles:`
88
88
  .tsvp-layout-minimal {
89
89
  --tsvp-controls-height: 36px;
90
90
  --tsvp-slider-track-height: 2px;
@@ -123,7 +123,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
123
123
  <slot name="time"></slot>
124
124
  <slot name="fullscreen-button"></slot>
125
125
  </div>
126
- `},$2={name:"cinema",description:"Immersive cinema-style layout with center play button",styles:`
126
+ `},ui={name:"cinema",description:"Immersive cinema-style layout with center play button",styles:`
127
127
  .tsvp-layout-cinema {
128
128
  --tsvp-controls-height: 60px;
129
129
  }
@@ -208,7 +208,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
208
208
  <slot name="fullscreen-button"></slot>
209
209
  </div>
210
210
  </div>
211
- `,init:(h)=>{let b=h.querySelector(".tsvp-center-play");if(b)b.addEventListener("click",()=>{h.dispatchEvent(new CustomEvent("tsvp:toggleplay"))})}},H2={name:"youtube",description:"YouTube-inspired layout with familiar controls",styles:`
211
+ `,init:(e)=>{let t=e.querySelector(".tsvp-center-play");if(t)t.addEventListener("click",()=>{e.dispatchEvent(new CustomEvent("tsvp:toggleplay"))})}},pi={name:"youtube",description:"YouTube-inspired layout with familiar controls",styles:`
212
212
  .tsvp-layout-youtube {
213
213
  --tsvp-color-primary: #ff0000;
214
214
  --tsvp-slider-track-height: 3px;
@@ -294,7 +294,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
294
294
  <div class="tsvp-end-screen">
295
295
  <slot name="end-screen"></slot>
296
296
  </div>
297
- `},W2={name:"vimeo",description:"Vimeo-inspired clean layout",styles:`
297
+ `},hi={name:"vimeo",description:"Vimeo-inspired clean layout",styles:`
298
298
  .tsvp-layout-vimeo {
299
299
  --tsvp-color-primary: #00adef;
300
300
  --tsvp-controls-height: 44px;
@@ -375,7 +375,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
375
375
  <slot name="fullscreen-button"></slot>
376
376
  </div>
377
377
  </div>
378
- `},N2={name:"audio",description:"Compact layout for audio-only playback",styles:`
378
+ `},mi={name:"audio",description:"Compact layout for audio-only playback",styles:`
379
379
  .tsvp-layout-audio {
380
380
  --tsvp-controls-height: 64px;
381
381
  height: var(--tsvp-controls-height);
@@ -457,7 +457,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
457
457
  </div>
458
458
  <slot name="volume"></slot>
459
459
  </div>
460
- `},a={default:z2,minimal:_2,cinema:$2,youtube:H2,vimeo:W2,audio:N2};class H0{container;currentLayout=null;styleElement=null;constructor(h){this.container=h}apply(h){let b=typeof h==="string"?a[h]:h;if(this.cleanup(),this.container.classList.add(`tsvp-layout-${b.name}`),this.styleElement=document.createElement("style"),this.styleElement.textContent=b.styles,document.head.appendChild(this.styleElement),this.container.innerHTML=b.template,b.init)b.init(this.container);this.currentLayout=b}getLayout(){return this.currentLayout}cleanup(){if(this.currentLayout){if(this.container.classList.remove(`tsvp-layout-${this.currentLayout.name}`),this.currentLayout.destroy)this.currentLayout.destroy(this.container);if(this.styleElement)this.styleElement.remove(),this.styleElement=null;this.currentLayout=null}}destroy(){this.cleanup()}}function W0(h){return new H0(h)}var Z2=[10,25,50,75,90,100];class D{player=null;config;state;heartbeatTimer=null;eventQueue=[];flushTimer=null;sessionId;visitorId;unsubscribers=[];constructor(h){this.config={milestones:Z2,heartbeatInterval:30,trackQualityChanges:!0,trackSeeking:!0,trackBuffering:!0,trackErrors:!0,trackEngagement:!0,...h},this.sessionId=h.sessionId||this.generateId(),this.visitorId=h.visitorId||this.getOrCreateVisitorId(),this.state=this.createInitialState()}createInitialState(){return{hasStarted:!1,hasCompleted:!1,watchTime:0,pauseCount:0,seekCount:0,bufferCount:0,bufferTime:0,qualityChangeCount:0,reachedMilestones:[],reachedQuartiles:[],playbackStartTime:null,lastHeartbeat:0,isBuffering:!1,bufferStartTime:null}}attach(h){if(this.config.disabled)return;this.player=h,this.attachEventListeners(),this.startHeartbeat()}detach(){this.stopHeartbeat(),this.unsubscribers.forEach((h)=>h()),this.unsubscribers=[],this.flush(),this.player=null}attachEventListeners(){if(!this.player)return;if(this.on("play",()=>{if(!this.state.hasStarted)this.state.hasStarted=!0,this.state.playbackStartTime=Date.now(),this.trackEvent("video_start");else this.trackEvent("video_resume");this.trackEvent("video_play")}),this.on("pause",()=>{this.state.pauseCount++,this.updateWatchTime(),this.trackEvent("video_pause")}),this.config.trackSeeking)this.on("seeking",()=>{this.state.seekCount++}),this.on("seeked",()=>{let h=this.player?.state;this.trackEvent("video_seek",{seekTo:h?.currentTime||0})});if(this.config.trackBuffering)this.on("waiting",()=>{if(!this.state.isBuffering)this.state.isBuffering=!0,this.state.bufferStartTime=Date.now(),this.state.bufferCount++,this.trackEvent("video_buffer_start")}),this.on("playing",()=>{if(this.state.isBuffering){if(this.state.isBuffering=!1,this.state.bufferStartTime)this.state.bufferTime+=(Date.now()-this.state.bufferStartTime)/1000;this.trackEvent("video_buffer_end",{bufferDuration:this.state.bufferStartTime?(Date.now()-this.state.bufferStartTime)/1000:0}),this.state.bufferStartTime=null}});if(this.on("timeupdate",()=>{this.checkMilestones()}),this.config.trackQualityChanges)this.on("qualitychange",(h)=>{this.state.qualityChangeCount++,this.trackEvent("video_quality_change",{quality:h?`${h.height}p`:"auto",bitrate:h?.bitrate})});if(this.on("volumechange",()=>{let h=this.player?.state;if(h?.muted)this.trackEvent("video_mute");else this.trackEvent("video_volume_change",{volume:h?.volume})}),this.on("fullscreenchange",(h)=>{this.trackEvent(h?"video_fullscreen_enter":"video_fullscreen_exit")}),this.on("pipchange",(h)=>{this.trackEvent(h?"video_pip_enter":"video_pip_exit")}),this.on("texttrackchange",(h)=>{if(h)this.trackEvent("video_caption_change",{language:h.language,label:h.label});else this.trackEvent("video_caption_disable")}),this.on("audiotrackchange",(h)=>{if(h)this.trackEvent("video_audio_track_change",{language:h.language,label:h.label})}),this.on("ratechange",(h)=>{this.trackEvent("video_speed_change",{speed:h})}),this.on("ended",()=>{if(!this.state.hasCompleted)this.state.hasCompleted=!0,this.updateWatchTime(),this.trackEvent("video_complete",{watchTime:this.state.watchTime,pauseCount:this.state.pauseCount,seekCount:this.state.seekCount,bufferCount:this.state.bufferCount,bufferTime:this.state.bufferTime})}),this.config.trackErrors)this.on("error",(h)=>{this.trackEvent("video_error",{code:h?.code,message:h?.message})})}on(h,b){if(!this.player)return;this.player.on(h,b),this.unsubscribers.push(()=>this.player?.off(h,b))}checkMilestones(){let h=this.player?.state;if(!h||!h.duration)return;let b=h.currentTime/h.duration*100;for(let C of this.config.milestones||[])if(b>=C&&!this.state.reachedMilestones.includes(C))this.state.reachedMilestones.push(C),this.trackEvent("video_milestone",{milestone:C});let w=[25,50,75,100];for(let C of w)if(b>=C&&!this.state.reachedQuartiles.includes(C))this.state.reachedQuartiles.push(C),this.trackEvent("video_quartile",{quartile:C})}updateWatchTime(){if(this.state.playbackStartTime)this.state.watchTime+=(Date.now()-this.state.playbackStartTime)/1000,this.state.playbackStartTime=Date.now()}startHeartbeat(){if(this.heartbeatTimer)return;let h=(this.config.heartbeatInterval||30)*1000;this.heartbeatTimer=setInterval(()=>{let b=this.player?.state;if(b?.playbackState==="playing")this.updateWatchTime(),this.trackEvent("video_heartbeat",{watchTime:this.state.watchTime,currentTime:b.currentTime})},h)}stopHeartbeat(){if(this.heartbeatTimer)clearInterval(this.heartbeatTimer),this.heartbeatTimer=null}trackEvent(h,b){if(this.config.disabled)return;let w=this.player?.state,C={name:h,timestamp:new Date,currentTime:w?.currentTime||0,duration:w?.duration||this.config.duration||0,properties:b};this.eventQueue.push(C),this.scheduleFlush()}scheduleFlush(){if(this.flushTimer)return;this.flushTimer=setTimeout(()=>{this.flush(),this.flushTimer=null},1000)}async flush(){if(this.eventQueue.length===0)return;let h=[...this.eventQueue];this.eventQueue=[];try{await this.sendEvents(h)}catch(b){console.error("Failed to send analytics events:",b),this.eventQueue.unshift(...h)}}async sendEvents(h){let b=h.map((w)=>this.buildEventPayload(w));for(let w of b)await fetch(this.config.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w),keepalive:!0})}buildEventPayload(h){return{s:this.config.siteId,sid:this.sessionId,vid:this.visitorId,e:"event",u:typeof window<"u"?window.location.href:"",p:{eventName:h.name,videoId:this.config.videoId,videoTitle:this.config.videoTitle,contentType:this.config.contentType,category:this.config.category,creatorId:this.config.creatorId,seriesId:this.config.seriesId,episode:this.config.episode,season:this.config.season,currentTime:h.currentTime,duration:h.duration,progress:h.duration>0?h.currentTime/h.duration*100:0,watchTime:this.state.watchTime,...this.config.customProperties,...h.properties}}}generateId(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}getOrCreateVisitorId(){if(typeof localStorage>"u")return this.generateId();let h="tsvp_visitor_id",b=localStorage.getItem(h);if(!b)b=this.generateId(),localStorage.setItem(h,b);return b}getState(){return{...this.state}}getSummary(){return{videoId:this.config.videoId,sessionId:this.sessionId,hasStarted:this.state.hasStarted,hasCompleted:this.state.hasCompleted,watchTime:this.state.watchTime,pauseCount:this.state.pauseCount,seekCount:this.state.seekCount,bufferCount:this.state.bufferCount,bufferTime:this.state.bufferTime,qualityChangeCount:this.state.qualityChangeCount,reachedMilestones:this.state.reachedMilestones,completionRate:this.state.reachedQuartiles.length>0?Math.max(...this.state.reachedQuartiles):0}}reset(){this.flush(),this.state=this.createInitialState(),this.sessionId=this.generateId()}destroy(){if(this.detach(),this.flushTimer)clearTimeout(this.flushTimer)}}function N0(h){return new D(h)}function r(h){return{name:"analytics",install(b,w){let C=N0({...h,...w});return C.attach(b),b.analytics=C,()=>{C.destroy(),delete b.analytics}}}}class e{maxRedirects;timeout;redirectCount=0;constructor(h={}){this.maxRedirects=h.maxRedirects??5,this.timeout=h.timeout??1e4}async parseFromUrl(h){return this.redirectCount=0,this.fetchAndParse(h)}parseFromXml(h){let w=new DOMParser().parseFromString(h,"text/xml");return this.parseDocument(w)}async fetchAndParse(h){if(this.redirectCount>=this.maxRedirects)throw Error("Too many VAST redirects");let b=new AbortController,w=setTimeout(()=>b.abort(),this.timeout);try{let M=await(await fetch(h,{signal:b.signal})).text(),$=new DOMParser().parseFromString(M,"text/xml"),_=$.querySelector("Wrapper");if(_){let H=_.querySelector("VASTAdTagURI")?.textContent?.trim();if(H)return this.redirectCount++,this.fetchAndParse(H)}return this.parseDocument($)}finally{clearTimeout(w)}}parseDocument(h){let b=[];return h.querySelectorAll("Ad").forEach((C)=>{let M=C.querySelector("InLine");if(!M)return;let z={id:C.getAttribute("id")||this.generateId(),type:"linear",adSystem:M.querySelector("AdSystem")?.textContent?.trim(),title:M.querySelector("AdTitle")?.textContent?.trim(),description:M.querySelector("Description")?.textContent?.trim(),duration:0,mediaFiles:[],trackingEvents:[]},$=M.querySelector("Linear");if($){let _=$.querySelector("Duration")?.textContent?.trim();if(_)z.duration=this.parseDuration(_);let H=$.getAttribute("skipoffset");if(H)z.skipOffset=this.parseOffset(H,z.duration);$.querySelectorAll("MediaFile").forEach((N)=>{let Z=N.textContent?.trim();if(Z)z.mediaFiles.push({url:Z,type:N.getAttribute("type")||"video/mp4",width:Number.parseInt(N.getAttribute("width")||"0",10),height:Number.parseInt(N.getAttribute("height")||"0",10),bitrate:N.getAttribute("bitrate")?Number.parseInt(N.getAttribute("bitrate"),10):void 0,delivery:N.getAttribute("delivery")||"progressive"})});let W=$.querySelector("VideoClicks > ClickThrough");if(W)z.clickThroughUrl=W.textContent?.trim();$.querySelectorAll("TrackingEvents > Tracking").forEach((N)=>{let Z=N.getAttribute("event"),E=N.textContent?.trim();if(Z&&E){let Q={event:Z,url:E};if(Z==="progress"){let R=N.getAttribute("offset");if(R)Q.offset=this.parseOffset(R,z.duration)}z.trackingEvents.push(Q)}}),$.querySelectorAll("Icons > Icon").forEach((N)=>{let Z=N.querySelector("StaticResource");if(Z?.textContent)z.icons=z.icons||[],z.icons.push({url:Z.textContent.trim(),width:Number.parseInt(N.getAttribute("width")||"0",10),height:Number.parseInt(N.getAttribute("height")||"0",10),xPosition:N.getAttribute("xPosition")||"right",yPosition:N.getAttribute("yPosition")||"top",clickUrl:N.querySelector("IconClicks > IconClickThrough")?.textContent?.trim()})})}if(M.querySelectorAll("CompanionAds > Companion").forEach((_)=>{z.companions=z.companions||[];let H=_.querySelector("StaticResource"),W=_.querySelector("IFrameResource"),N=_.querySelector("HTMLResource"),Z="",E="static";if(H?.textContent)Z=H.textContent.trim(),E="static";else if(W?.textContent)Z=W.textContent.trim(),E="iframe";else if(N?.textContent)Z=N.textContent.trim(),E="html";if(Z)z.companions.push({width:Number.parseInt(_.getAttribute("width")||"0",10),height:Number.parseInt(_.getAttribute("height")||"0",10),resourceUrl:Z,resourceType:E,clickThroughUrl:_.querySelector("CompanionClickThrough")?.textContent?.trim(),altText:_.getAttribute("altText")||void 0,trackingUrl:_.querySelector("TrackingEvents > Tracking")?.textContent?.trim()})}),z.mediaFiles.length>0)b.push(z)}),b}parseDuration(h){let b=h.split(":");if(b.length!==3)return 0;let w=Number.parseFloat(b[0]),C=Number.parseFloat(b[1]),M=Number.parseFloat(b[2]);return w*3600+C*60+M}parseOffset(h,b){if(h.endsWith("%")){let w=Number.parseFloat(h)/100;return b*w}return this.parseDuration(h)}generateId(){return`ad-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}}class O{player=null;config;parser;state;container=null;adVideo=null;adContainer=null;skipButton=null;adBreaks=[];currentAds=[];currentAdIndex=0;skipTimer=null;contentPaused=!1;onAdStart=null;onAdComplete=null;onAdSkip=null;onAdClick=null;onAdErrorCallback=null;onAllAdsComplete=null;constructor(h={}){if(this.config={skipDelay:5,maxRedirects:5,timeout:1e4,vpaidEnabled:!1,preloadAds:!0,debug:!1,...h},this.parser=new e({maxRedirects:this.config.maxRedirects,timeout:this.config.timeout}),this.state={isPlaying:!1,currentAd:null,currentBreak:null,timeRemaining:0,canSkip:!1,skipCountdown:0,isLoading:!1,error:null},this.config.schedule)this.adBreaks=this.config.schedule;else if(this.config.vastUrl||this.config.vastXml)this.adBreaks=[{type:"preroll",vastUrl:this.config.vastUrl,vastXml:this.config.vastXml}]}attach(h,b){if(this.player=h,this.container=b,this.createAdContainer(),this.attachPlayerEvents(),this.config.preloadAds)this.preloadAds()}createAdContainer(){if(!this.container)return;this.adContainer=document.createElement("div"),this.adContainer.className="tsvp-ad-container",this.adContainer.style.cssText=`
460
+ `},Me={default:di,minimal:ci,cinema:ui,youtube:pi,vimeo:hi,audio:mi};class ht{container;currentLayout=null;styleElement=null;constructor(e){this.container=e}apply(e){let t=typeof e==="string"?Me[e]:e;if(this.cleanup(),this.container.classList.add(`tsvp-layout-${t.name}`),this.styleElement=document.createElement("style"),this.styleElement.textContent=t.styles,document.head.appendChild(this.styleElement),this.container.innerHTML=t.template,t.init)t.init(this.container);this.currentLayout=t}getLayout(){return this.currentLayout}cleanup(){if(this.currentLayout){if(this.container.classList.remove(`tsvp-layout-${this.currentLayout.name}`),this.currentLayout.destroy)this.currentLayout.destroy(this.container);if(this.styleElement)this.styleElement.remove(),this.styleElement=null;this.currentLayout=null}}destroy(){this.cleanup()}}function mt(e){return new ht(e)}var vi=[10,25,50,75,90,100];class H{player=null;config;state;heartbeatTimer=null;eventQueue=[];flushTimer=null;sessionId;visitorId;unsubscribers=[];constructor(e){this.config={milestones:vi,heartbeatInterval:30,trackQualityChanges:!0,trackSeeking:!0,trackBuffering:!0,trackErrors:!0,trackEngagement:!0,...e},this.sessionId=e.sessionId||this.generateId(),this.visitorId=e.visitorId||this.getOrCreateVisitorId(),this.state=this.createInitialState()}createInitialState(){return{hasStarted:!1,hasCompleted:!1,watchTime:0,pauseCount:0,seekCount:0,bufferCount:0,bufferTime:0,qualityChangeCount:0,reachedMilestones:[],reachedQuartiles:[],playbackStartTime:null,lastHeartbeat:0,isBuffering:!1,bufferStartTime:null}}attach(e){if(this.config.disabled)return;this.player=e,this.attachEventListeners(),this.startHeartbeat()}detach(){this.stopHeartbeat(),this.unsubscribers.forEach((e)=>e()),this.unsubscribers=[],this.flush(),this.player=null}attachEventListeners(){if(!this.player)return;if(this.on("play",()=>{if(!this.state.hasStarted)this.state.hasStarted=!0,this.state.playbackStartTime=Date.now(),this.trackEvent("video_start");else this.trackEvent("video_resume");this.trackEvent("video_play")}),this.on("pause",()=>{this.state.pauseCount++,this.updateWatchTime(),this.trackEvent("video_pause")}),this.config.trackSeeking)this.on("seeking",()=>{this.state.seekCount++}),this.on("seeked",()=>{let e=this.player?.state;this.trackEvent("video_seek",{seekTo:e?.currentTime||0})});if(this.config.trackBuffering)this.on("waiting",()=>{if(!this.state.isBuffering)this.state.isBuffering=!0,this.state.bufferStartTime=Date.now(),this.state.bufferCount++,this.trackEvent("video_buffer_start")}),this.on("playing",()=>{if(this.state.isBuffering){if(this.state.isBuffering=!1,this.state.bufferStartTime)this.state.bufferTime+=(Date.now()-this.state.bufferStartTime)/1000;this.trackEvent("video_buffer_end",{bufferDuration:this.state.bufferStartTime?(Date.now()-this.state.bufferStartTime)/1000:0}),this.state.bufferStartTime=null}});if(this.on("timeupdate",()=>{this.checkMilestones()}),this.config.trackQualityChanges)this.on("qualitychange",(e)=>{this.state.qualityChangeCount++,this.trackEvent("video_quality_change",{quality:e?`${e.height}p`:"auto",bitrate:e?.bitrate})});if(this.on("volumechange",()=>{let e=this.player?.state;if(e?.muted)this.trackEvent("video_mute");else this.trackEvent("video_volume_change",{volume:e?.volume})}),this.on("fullscreenchange",(e)=>{this.trackEvent(e?"video_fullscreen_enter":"video_fullscreen_exit")}),this.on("pipchange",(e)=>{this.trackEvent(e?"video_pip_enter":"video_pip_exit")}),this.on("texttrackchange",(e)=>{if(e)this.trackEvent("video_caption_change",{language:e.language,label:e.label});else this.trackEvent("video_caption_disable")}),this.on("audiotrackchange",(e)=>{if(e)this.trackEvent("video_audio_track_change",{language:e.language,label:e.label})}),this.on("ratechange",(e)=>{this.trackEvent("video_speed_change",{speed:e})}),this.on("ended",()=>{if(!this.state.hasCompleted)this.state.hasCompleted=!0,this.updateWatchTime(),this.trackEvent("video_complete",{watchTime:this.state.watchTime,pauseCount:this.state.pauseCount,seekCount:this.state.seekCount,bufferCount:this.state.bufferCount,bufferTime:this.state.bufferTime})}),this.config.trackErrors)this.on("error",(e)=>{this.trackEvent("video_error",{code:e?.code,message:e?.message})})}on(e,t){if(!this.player)return;this.player.on(e,t),this.unsubscribers.push(()=>this.player?.off(e,t))}checkMilestones(){let e=this.player?.state;if(!e||!e.duration)return;let t=e.currentTime/e.duration*100;for(let n of this.config.milestones||[])if(t>=n&&!this.state.reachedMilestones.includes(n))this.state.reachedMilestones.push(n),this.trackEvent("video_milestone",{milestone:n});let i=[25,50,75,100];for(let n of i)if(t>=n&&!this.state.reachedQuartiles.includes(n))this.state.reachedQuartiles.push(n),this.trackEvent("video_quartile",{quartile:n})}updateWatchTime(){if(this.state.playbackStartTime)this.state.watchTime+=(Date.now()-this.state.playbackStartTime)/1000,this.state.playbackStartTime=Date.now()}startHeartbeat(){if(this.heartbeatTimer)return;let e=(this.config.heartbeatInterval||30)*1000;this.heartbeatTimer=setInterval(()=>{let t=this.player?.state;if(t?.playbackState==="playing")this.updateWatchTime(),this.trackEvent("video_heartbeat",{watchTime:this.state.watchTime,currentTime:t.currentTime})},e)}stopHeartbeat(){if(this.heartbeatTimer)clearInterval(this.heartbeatTimer),this.heartbeatTimer=null}trackEvent(e,t){if(this.config.disabled)return;let i=this.player?.state,n={name:e,timestamp:new Date,currentTime:i?.currentTime||0,duration:i?.duration||this.config.duration||0,properties:t};this.eventQueue.push(n),this.scheduleFlush()}scheduleFlush(){if(this.flushTimer)return;this.flushTimer=setTimeout(()=>{this.flush(),this.flushTimer=null},1000)}async flush(){if(this.eventQueue.length===0)return;let e=[...this.eventQueue];this.eventQueue=[];try{await this.sendEvents(e)}catch(t){console.error("Failed to send analytics events:",t),this.eventQueue.unshift(...e)}}async sendEvents(e){let t=e.map((i)=>this.buildEventPayload(i));for(let i of t)await fetch(this.config.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0})}buildEventPayload(e){return{s:this.config.siteId,sid:this.sessionId,vid:this.visitorId,e:"event",u:typeof window<"u"?window.location.href:"",p:{eventName:e.name,videoId:this.config.videoId,videoTitle:this.config.videoTitle,contentType:this.config.contentType,category:this.config.category,creatorId:this.config.creatorId,seriesId:this.config.seriesId,episode:this.config.episode,season:this.config.season,currentTime:e.currentTime,duration:e.duration,progress:e.duration>0?e.currentTime/e.duration*100:0,watchTime:this.state.watchTime,...this.config.customProperties,...e.properties}}}generateId(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}getOrCreateVisitorId(){if(typeof localStorage>"u")return this.generateId();let e="tsvp_visitor_id",t=localStorage.getItem(e);if(!t)t=this.generateId(),localStorage.setItem(e,t);return t}getState(){return{...this.state}}getSummary(){return{videoId:this.config.videoId,sessionId:this.sessionId,hasStarted:this.state.hasStarted,hasCompleted:this.state.hasCompleted,watchTime:this.state.watchTime,pauseCount:this.state.pauseCount,seekCount:this.state.seekCount,bufferCount:this.state.bufferCount,bufferTime:this.state.bufferTime,qualityChangeCount:this.state.qualityChangeCount,reachedMilestones:this.state.reachedMilestones,completionRate:this.state.reachedQuartiles.length>0?Math.max(...this.state.reachedQuartiles):0}}reset(){this.flush(),this.state=this.createInitialState(),this.sessionId=this.generateId()}destroy(){if(this.detach(),this.flushTimer)clearTimeout(this.flushTimer)}}function vt(e){return new H(e)}function Le(e){return{name:"analytics",install(t,i){let n=vt({...e,...i});return n.attach(t),t.analytics=n,()=>{n.destroy(),delete t.analytics}}}}class _e{maxRedirects;timeout;redirectCount=0;constructor(e={}){this.maxRedirects=e.maxRedirects??5,this.timeout=e.timeout??1e4}async parseFromUrl(e){return this.redirectCount=0,this.fetchAndParse(e)}parseFromXml(e){let i=new DOMParser().parseFromString(e,"text/xml");return this.parseDocument(i)}async fetchAndParse(e){if(this.redirectCount>=this.maxRedirects)throw Error("Too many VAST redirects");let t=new AbortController,i=setTimeout(()=>t.abort(),this.timeout);try{let s=await(await fetch(e,{signal:t.signal})).text(),o=new DOMParser().parseFromString(s,"text/xml"),a=o.querySelector("Wrapper");if(a){let l=a.querySelector("VASTAdTagURI")?.textContent?.trim();if(l)return this.redirectCount++,this.fetchAndParse(l)}return this.parseDocument(o)}finally{clearTimeout(i)}}parseDocument(e){let t=[];return e.querySelectorAll("Ad").forEach((n)=>{let s=n.querySelector("InLine");if(!s)return;let r={id:n.getAttribute("id")||this.generateId(),type:"linear",adSystem:s.querySelector("AdSystem")?.textContent?.trim(),title:s.querySelector("AdTitle")?.textContent?.trim(),description:s.querySelector("Description")?.textContent?.trim(),duration:0,mediaFiles:[],trackingEvents:[]},o=s.querySelector("Linear");if(o){let a=o.querySelector("Duration")?.textContent?.trim();if(a)r.duration=this.parseDuration(a);let l=o.getAttribute("skipoffset");if(l)r.skipOffset=this.parseOffset(l,r.duration);o.querySelectorAll("MediaFile").forEach((c)=>{let u=c.textContent?.trim();if(u)r.mediaFiles.push({url:u,type:c.getAttribute("type")||"video/mp4",width:Number.parseInt(c.getAttribute("width")||"0",10),height:Number.parseInt(c.getAttribute("height")||"0",10),bitrate:c.getAttribute("bitrate")?Number.parseInt(c.getAttribute("bitrate"),10):void 0,delivery:c.getAttribute("delivery")||"progressive"})});let d=o.querySelector("VideoClicks > ClickThrough");if(d)r.clickThroughUrl=d.textContent?.trim();o.querySelectorAll("TrackingEvents > Tracking").forEach((c)=>{let u=c.getAttribute("event"),v=c.textContent?.trim();if(u&&v){let g={event:u,url:v};if(u==="progress"){let k=c.getAttribute("offset");if(k)g.offset=this.parseOffset(k,r.duration)}r.trackingEvents.push(g)}}),o.querySelectorAll("Icons > Icon").forEach((c)=>{let u=c.querySelector("StaticResource");if(u?.textContent)r.icons=r.icons||[],r.icons.push({url:u.textContent.trim(),width:Number.parseInt(c.getAttribute("width")||"0",10),height:Number.parseInt(c.getAttribute("height")||"0",10),xPosition:c.getAttribute("xPosition")||"right",yPosition:c.getAttribute("yPosition")||"top",clickUrl:c.querySelector("IconClicks > IconClickThrough")?.textContent?.trim()})})}if(s.querySelectorAll("CompanionAds > Companion").forEach((a)=>{r.companions=r.companions||[];let l=a.querySelector("StaticResource"),d=a.querySelector("IFrameResource"),c=a.querySelector("HTMLResource"),u="",v="static";if(l?.textContent)u=l.textContent.trim(),v="static";else if(d?.textContent)u=d.textContent.trim(),v="iframe";else if(c?.textContent)u=c.textContent.trim(),v="html";if(u)r.companions.push({width:Number.parseInt(a.getAttribute("width")||"0",10),height:Number.parseInt(a.getAttribute("height")||"0",10),resourceUrl:u,resourceType:v,clickThroughUrl:a.querySelector("CompanionClickThrough")?.textContent?.trim(),altText:a.getAttribute("altText")||void 0,trackingUrl:a.querySelector("TrackingEvents > Tracking")?.textContent?.trim()})}),r.mediaFiles.length>0)t.push(r)}),t}parseDuration(e){let t=e.split(":");if(t.length!==3)return 0;let i=Number.parseFloat(t[0]),n=Number.parseFloat(t[1]),s=Number.parseFloat(t[2]);return i*3600+n*60+s}parseOffset(e,t){if(e.endsWith("%")){let i=Number.parseFloat(e)/100;return t*i}return this.parseDuration(e)}generateId(){return`ad-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}}class I{player=null;config;parser;state;container=null;adVideo=null;adContainer=null;skipButton=null;adBreaks=[];currentAds=[];currentAdIndex=0;skipTimer=null;contentPaused=!1;onAdStart=null;onAdComplete=null;onAdSkip=null;onAdClick=null;onAdErrorCallback=null;onAllAdsComplete=null;constructor(e={}){if(this.config={skipDelay:5,maxRedirects:5,timeout:1e4,vpaidEnabled:!1,preloadAds:!0,debug:!1,...e},this.parser=new _e({maxRedirects:this.config.maxRedirects,timeout:this.config.timeout}),this.state={isPlaying:!1,currentAd:null,currentBreak:null,timeRemaining:0,canSkip:!1,skipCountdown:0,isLoading:!1,error:null},this.config.schedule)this.adBreaks=this.config.schedule;else if(this.config.vastUrl||this.config.vastXml)this.adBreaks=[{type:"preroll",vastUrl:this.config.vastUrl,vastXml:this.config.vastXml}]}attach(e,t){if(this.player=e,this.container=t,this.createAdContainer(),this.attachPlayerEvents(),this.config.preloadAds)this.preloadAds()}createAdContainer(){if(!this.container)return;this.adContainer=document.createElement("div"),this.adContainer.className="tsvp-ad-container",this.adContainer.style.cssText=`
461
461
  position: absolute;
462
462
  inset: 0;
463
463
  z-index: 50;
@@ -467,13 +467,13 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
467
467
  width: 100%;
468
468
  height: 100%;
469
469
  object-fit: contain;
470
- `,this.adVideo.playsInline=!0;let h=document.createElement("div");h.className="tsvp-ad-overlay",h.style.cssText=`
470
+ `,this.adVideo.playsInline=!0;let e=document.createElement("div");e.className="tsvp-ad-overlay",e.style.cssText=`
471
471
  position: absolute;
472
472
  inset: 0;
473
473
  display: flex;
474
474
  flex-direction: column;
475
475
  pointer-events: none;
476
- `;let b=document.createElement("div");b.className="tsvp-ad-info",b.style.cssText=`
476
+ `;let t=document.createElement("div");t.className="tsvp-ad-info",t.style.cssText=`
477
477
  position: absolute;
478
478
  top: 12px;
479
479
  left: 12px;
@@ -483,7 +483,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
483
483
  font-size: 12px;
484
484
  font-family: var(--tsvp-font-family, sans-serif);
485
485
  border-radius: 4px;
486
- `,b.textContent="Ad",this.skipButton=document.createElement("button"),this.skipButton.className="tsvp-ad-skip",this.skipButton.style.cssText=`
486
+ `,t.textContent="Ad",this.skipButton=document.createElement("button"),this.skipButton.className="tsvp-ad-skip",this.skipButton.style.cssText=`
487
487
  position: absolute;
488
488
  bottom: 80px;
489
489
  right: 12px;
@@ -497,7 +497,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
497
497
  cursor: pointer;
498
498
  pointer-events: auto;
499
499
  display: none;
500
- `,this.skipButton.addEventListener("click",()=>this.skipAd());let w=document.createElement("button");w.className="tsvp-ad-learn-more",w.style.cssText=`
500
+ `,this.skipButton.addEventListener("click",()=>this.skipAd());let i=document.createElement("button");i.className="tsvp-ad-learn-more",i.style.cssText=`
501
501
  position: absolute;
502
502
  bottom: 80px;
503
503
  left: 12px;
@@ -511,9 +511,9 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
511
511
  cursor: pointer;
512
512
  pointer-events: auto;
513
513
  display: none;
514
- `,w.textContent="Learn More",w.addEventListener("click",()=>this.handleAdClick()),h.appendChild(b),h.appendChild(this.skipButton),h.appendChild(w),this.adContainer.appendChild(this.adVideo),this.adContainer.appendChild(h),this.container.appendChild(this.adContainer),this.adVideo.addEventListener("timeupdate",()=>this.onAdTimeUpdate()),this.adVideo.addEventListener("ended",()=>this.onAdEnded()),this.adVideo.addEventListener("error",()=>this.handleAdError())}attachPlayerEvents(){if(!this.player)return;let h=!0;this.player.on("play",async()=>{if(h){h=!1;let b=this.adBreaks.find((w)=>w.type==="preroll"&&!w.played);if(b)await this.playAdBreak(b)}}),this.player.on("timeupdate",()=>{let b=this.player?.state;if(!b)return;for(let w of this.adBreaks)if(w.type==="midroll"&&!w.played&&w.timeOffset&&b.currentTime>=w.timeOffset){this.playAdBreak(w);break}}),this.player.on("ended",async()=>{let b=this.adBreaks.find((w)=>w.type==="postroll"&&!w.played);if(b)await this.playAdBreak(b)})}async preloadAds(){for(let h of this.adBreaks)if(h.vastUrl)try{await this.parser.parseFromUrl(h.vastUrl)}catch(b){this.log("Failed to preload ad:",b)}}async playAdBreak(h){if(this.state.isPlaying)return;this.state.currentBreak=h,this.state.isLoading=!0,this.pauseContent();try{if(h.vastUrl)this.currentAds=await this.parser.parseFromUrl(h.vastUrl);else if(h.vastXml)this.currentAds=this.parser.parseFromXml(h.vastXml);if(this.currentAds.length===0)throw Error("No ads found in VAST response");this.currentAdIndex=0,h.played=!0,await this.playAd(this.currentAds[0])}catch(b){this.state.error=b.message,this.state.isLoading=!1,this.onAdErrorCallback?.(b.message),this.resumeContent()}}async playAd(h){if(!this.adVideo||!this.adContainer)return;this.state.currentAd=h,this.state.isPlaying=!0,this.state.isLoading=!1,this.state.timeRemaining=h.duration,this.state.canSkip=!1,this.state.skipCountdown=this.config.skipDelay||0;let b=this.selectMediaFile(h.mediaFiles);if(!b)throw Error("No suitable media file found");this.adContainer.style.display="block",this.adVideo.src=b.url,await this.adVideo.play(),this.trackEvent(h,"impression"),this.trackEvent(h,"start"),this.startSkipTimer(h),this.onAdStart?.(h)}selectMediaFile(h){return[...h].sort((w,C)=>{if(w.type.includes("mp4")&&!C.type.includes("mp4"))return-1;if(!w.type.includes("mp4")&&C.type.includes("mp4"))return 1;return(C.bitrate||0)-(w.bitrate||0)})[0]||null}startSkipTimer(h){let b=this.config.skipDelay===-1?h.skipOffset||5:this.config.skipDelay||0;if(b<=0){this.state.canSkip=!0,this.updateSkipButton();return}this.state.skipCountdown=b,this.skipTimer=setInterval(()=>{if(this.state.skipCountdown--,this.state.skipCountdown<=0){if(this.state.canSkip=!0,this.skipTimer)clearInterval(this.skipTimer),this.skipTimer=null}this.updateSkipButton()},1000)}updateSkipButton(){if(!this.skipButton)return;if(this.state.canSkip)this.skipButton.textContent="Skip Ad",this.skipButton.style.display="block";else if(this.state.skipCountdown>0)this.skipButton.textContent=`Skip in ${this.state.skipCountdown}s`,this.skipButton.style.display="block",this.skipButton.style.cursor="default";else this.skipButton.style.display="none"}skipAd(){if(!this.state.canSkip||!this.state.currentAd)return;this.trackEvent(this.state.currentAd,"skip"),this.onAdSkip?.(this.state.currentAd),this.onAdEnded()}handleAdClick(){if(!this.state.currentAd?.clickThroughUrl)return;this.adVideo?.pause(),this.trackEvent(this.state.currentAd,"clickThrough"),this.onAdClick?.(this.state.currentAd),window.open(this.state.currentAd.clickThroughUrl,"_blank")}onAdTimeUpdate(){if(!this.adVideo||!this.state.currentAd)return;let h=this.adVideo.currentTime,b=this.state.currentAd.duration;this.state.timeRemaining=Math.max(0,b-h);let w=h/b;if(w>=0.25)this.trackEvent(this.state.currentAd,"firstQuartile");if(w>=0.5)this.trackEvent(this.state.currentAd,"midpoint");if(w>=0.75)this.trackEvent(this.state.currentAd,"thirdQuartile");for(let C of this.state.currentAd.trackingEvents)if(C.event==="progress"&&C.offset&&h>=C.offset)this.trackUrl(C.url)}onAdEnded(){if(this.state.currentAd)this.trackEvent(this.state.currentAd,"complete"),this.onAdComplete?.(this.state.currentAd);if(this.skipTimer)clearInterval(this.skipTimer),this.skipTimer=null;if(this.currentAdIndex++,this.currentAdIndex<this.currentAds.length)this.playAd(this.currentAds[this.currentAdIndex]);else this.finishAdBreak()}handleAdError(){this.state.error="Ad playback failed",this.onAdErrorCallback?.("Ad playback failed"),this.trackEvent(this.state.currentAd,"error"),this.finishAdBreak()}finishAdBreak(){if(this.state.isPlaying=!1,this.state.currentAd=null,this.state.currentBreak=null,this.currentAds=[],this.currentAdIndex=0,this.adContainer)this.adContainer.style.display="none";this.onAllAdsComplete?.(),this.resumeContent()}pauseContent(){if(!this.player)return;if(this.player.state.playbackState==="playing")this.contentPaused=!0,this.player.pause()}resumeContent(){if(!this.player)return;if(this.contentPaused)this.contentPaused=!1,this.player.play()}trackEvent(h,b){let w=h.trackingEvents.filter((C)=>C.event===b);for(let C of w)this.trackUrl(C.url)}trackUrl(h){let b=new Image;b.src=h}log(...h){if(this.config.debug)console.log("[VideoAds]",...h)}getState(){return{...this.state}}on(h,b){switch(h){case"adStart":this.onAdStart=b;break;case"adComplete":this.onAdComplete=b;break;case"adSkip":this.onAdSkip=b;break;case"adClick":this.onAdClick=b;break;case"adError":this.onAdErrorCallback=b;break;case"allAdsComplete":this.onAllAdsComplete=b;break}}destroy(){if(this.skipTimer)clearInterval(this.skipTimer);if(this.adContainer)this.adContainer.remove();this.player=null,this.container=null,this.adVideo=null,this.adContainer=null}}function Z0(h){return new O(h)}function hh(h){return{name:"ads",install(b,w){let C=Z0(h);return C.attach(b,w),b.ads=C,()=>{C.destroy(),delete b.ads}}}}var G0={intro:"Skip Intro",outro:"Skip Outro",recap:"Skip Recap",preview:"Skip Preview",credits:"Skip Credits",sponsor:"Skip",custom:"Skip"};class P{player=null;config;state;container=null;button=null;markersContainer=null;countdownTimer=null;hideTimer=null;unsubscribers=[];onSkip=null;onSegmentEnter=null;onSegmentExit=null;constructor(h){this.config={segments:h.segments||[],buttonVisibleDuration:h.buttonVisibleDuration??1e4,defaultAutoSkipDelay:h.defaultAutoSkipDelay??0,buttonPosition:h.buttonPosition||"bottom-right",showMarkers:h.showMarkers??!0,markerColor:h.markerColor||"rgba(255, 255, 0, 0.8)",keyboardShortcut:h.keyboardShortcut??!0},this.state={activeSegment:null,buttonVisible:!1,countdown:0,isAutoSkipping:!1}}attach(h,b){if(this.player=h,this.container=b,this.createButton(),this.attachEventListeners(),this.config.showMarkers)this.createMarkers()}createButton(){if(!this.container)return;this.button=document.createElement("button"),this.button.className="tsvp-skip-button",this.button.type="button";let h=this.getPositionStyles();this.button.style.cssText=`
514
+ `,i.textContent="Learn More",i.addEventListener("click",()=>this.handleAdClick()),e.appendChild(t),e.appendChild(this.skipButton),e.appendChild(i),this.adContainer.appendChild(this.adVideo),this.adContainer.appendChild(e),this.container.appendChild(this.adContainer),this.adVideo.addEventListener("timeupdate",()=>this.onAdTimeUpdate()),this.adVideo.addEventListener("ended",()=>this.onAdEnded()),this.adVideo.addEventListener("error",()=>this.handleAdError())}attachPlayerEvents(){if(!this.player)return;let e=!0;this.player.on("play",async()=>{if(e){e=!1;let t=this.adBreaks.find((i)=>i.type==="preroll"&&!i.played);if(t)await this.playAdBreak(t)}}),this.player.on("timeupdate",()=>{let t=this.player?.state;if(!t)return;for(let i of this.adBreaks)if(i.type==="midroll"&&!i.played&&i.timeOffset&&t.currentTime>=i.timeOffset){this.playAdBreak(i);break}}),this.player.on("ended",async()=>{let t=this.adBreaks.find((i)=>i.type==="postroll"&&!i.played);if(t)await this.playAdBreak(t)})}async preloadAds(){for(let e of this.adBreaks)if(e.vastUrl)try{await this.parser.parseFromUrl(e.vastUrl)}catch(t){this.log("Failed to preload ad:",t)}}async playAdBreak(e){if(this.state.isPlaying)return;this.state.currentBreak=e,this.state.isLoading=!0,this.pauseContent();try{if(e.vastUrl)this.currentAds=await this.parser.parseFromUrl(e.vastUrl);else if(e.vastXml)this.currentAds=this.parser.parseFromXml(e.vastXml);if(this.currentAds.length===0)throw Error("No ads found in VAST response");this.currentAdIndex=0,e.played=!0,await this.playAd(this.currentAds[0])}catch(t){this.state.error=t.message,this.state.isLoading=!1,this.onAdErrorCallback?.(t.message),this.resumeContent()}}async playAd(e){if(!this.adVideo||!this.adContainer)return;this.state.currentAd=e,this.state.isPlaying=!0,this.state.isLoading=!1,this.state.timeRemaining=e.duration,this.state.canSkip=!1,this.state.skipCountdown=this.config.skipDelay||0;let t=this.selectMediaFile(e.mediaFiles);if(!t)throw Error("No suitable media file found");this.adContainer.style.display="block",this.adVideo.src=t.url,await this.adVideo.play(),this.trackEvent(e,"impression"),this.trackEvent(e,"start"),this.startSkipTimer(e),this.onAdStart?.(e)}selectMediaFile(e){return[...e].sort((i,n)=>{if(i.type.includes("mp4")&&!n.type.includes("mp4"))return-1;if(!i.type.includes("mp4")&&n.type.includes("mp4"))return 1;return(n.bitrate||0)-(i.bitrate||0)})[0]||null}startSkipTimer(e){let t=this.config.skipDelay===-1?e.skipOffset||5:this.config.skipDelay||0;if(t<=0){this.state.canSkip=!0,this.updateSkipButton();return}this.state.skipCountdown=t,this.skipTimer=setInterval(()=>{if(this.state.skipCountdown--,this.state.skipCountdown<=0){if(this.state.canSkip=!0,this.skipTimer)clearInterval(this.skipTimer),this.skipTimer=null}this.updateSkipButton()},1000)}updateSkipButton(){if(!this.skipButton)return;if(this.state.canSkip)this.skipButton.textContent="Skip Ad",this.skipButton.style.display="block";else if(this.state.skipCountdown>0)this.skipButton.textContent=`Skip in ${this.state.skipCountdown}s`,this.skipButton.style.display="block",this.skipButton.style.cursor="default";else this.skipButton.style.display="none"}skipAd(){if(!this.state.canSkip||!this.state.currentAd)return;this.trackEvent(this.state.currentAd,"skip"),this.onAdSkip?.(this.state.currentAd),this.onAdEnded()}handleAdClick(){if(!this.state.currentAd?.clickThroughUrl)return;this.adVideo?.pause(),this.trackEvent(this.state.currentAd,"clickThrough"),this.onAdClick?.(this.state.currentAd),window.open(this.state.currentAd.clickThroughUrl,"_blank")}onAdTimeUpdate(){if(!this.adVideo||!this.state.currentAd)return;let e=this.adVideo.currentTime,t=this.state.currentAd.duration;this.state.timeRemaining=Math.max(0,t-e);let i=e/t;if(i>=0.25)this.trackEvent(this.state.currentAd,"firstQuartile");if(i>=0.5)this.trackEvent(this.state.currentAd,"midpoint");if(i>=0.75)this.trackEvent(this.state.currentAd,"thirdQuartile");for(let n of this.state.currentAd.trackingEvents)if(n.event==="progress"&&n.offset&&e>=n.offset)this.trackUrl(n.url)}onAdEnded(){if(this.state.currentAd)this.trackEvent(this.state.currentAd,"complete"),this.onAdComplete?.(this.state.currentAd);if(this.skipTimer)clearInterval(this.skipTimer),this.skipTimer=null;if(this.currentAdIndex++,this.currentAdIndex<this.currentAds.length)this.playAd(this.currentAds[this.currentAdIndex]);else this.finishAdBreak()}handleAdError(){this.state.error="Ad playback failed",this.onAdErrorCallback?.("Ad playback failed"),this.trackEvent(this.state.currentAd,"error"),this.finishAdBreak()}finishAdBreak(){if(this.state.isPlaying=!1,this.state.currentAd=null,this.state.currentBreak=null,this.currentAds=[],this.currentAdIndex=0,this.adContainer)this.adContainer.style.display="none";this.onAllAdsComplete?.(),this.resumeContent()}pauseContent(){if(!this.player)return;if(this.player.state.playbackState==="playing")this.contentPaused=!0,this.player.pause()}resumeContent(){if(!this.player)return;if(this.contentPaused)this.contentPaused=!1,this.player.play()}trackEvent(e,t){let i=e.trackingEvents.filter((n)=>n.event===t);for(let n of i)this.trackUrl(n.url)}trackUrl(e){let t=new Image;t.src=e}log(...e){if(this.config.debug)console.log("[VideoAds]",...e)}getState(){return{...this.state}}on(e,t){switch(e){case"adStart":this.onAdStart=t;break;case"adComplete":this.onAdComplete=t;break;case"adSkip":this.onAdSkip=t;break;case"adClick":this.onAdClick=t;break;case"adError":this.onAdErrorCallback=t;break;case"allAdsComplete":this.onAllAdsComplete=t;break}}destroy(){if(this.skipTimer)clearInterval(this.skipTimer);if(this.adContainer)this.adContainer.remove();this.player=null,this.container=null,this.adVideo=null,this.adContainer=null}}function gt(e){return new I(e)}function Ce(e){return{name:"ads",install(t,i){let n=gt(e);return n.attach(t,i),t.ads=n,()=>{n.destroy(),delete t.ads}}}}var ft={intro:"Skip Intro",outro:"Skip Outro",recap:"Skip Recap",preview:"Skip Preview",credits:"Skip Credits",sponsor:"Skip",custom:"Skip"};class V{player=null;config;state;container=null;button=null;markersContainer=null;countdownTimer=null;hideTimer=null;unsubscribers=[];onSkip=null;onSegmentEnter=null;onSegmentExit=null;constructor(e){this.config={segments:e.segments||[],buttonVisibleDuration:e.buttonVisibleDuration??1e4,defaultAutoSkipDelay:e.defaultAutoSkipDelay??0,buttonPosition:e.buttonPosition||"bottom-right",showMarkers:e.showMarkers??!0,markerColor:e.markerColor||"rgba(255, 255, 0, 0.8)",keyboardShortcut:e.keyboardShortcut??!0},this.state={activeSegment:null,buttonVisible:!1,countdown:0,isAutoSkipping:!1}}attach(e,t){if(this.player=e,this.container=t,this.createButton(),this.attachEventListeners(),this.config.showMarkers)this.createMarkers()}createButton(){if(!this.container)return;this.button=document.createElement("button"),this.button.className="tsvp-skip-button",this.button.type="button";let e=this.getPositionStyles();this.button.style.cssText=`
515
515
  position: absolute;
516
- ${h}
516
+ ${e}
517
517
  padding: 12px 24px;
518
518
  background: rgba(0, 0, 0, 0.85);
519
519
  color: #fff;
@@ -526,22 +526,22 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
526
526
  z-index: 30;
527
527
  display: none;
528
528
  transition: transform 150ms ease, background 150ms ease;
529
- `,this.button.addEventListener("mouseenter",()=>{this.button.style.background="rgba(255, 255, 255, 0.2)",this.button.style.transform="scale(1.05)"}),this.button.addEventListener("mouseleave",()=>{this.button.style.background="rgba(0, 0, 0, 0.85)",this.button.style.transform="scale(1)"}),this.button.addEventListener("click",()=>this.skip()),this.container.appendChild(this.button)}getPositionStyles(){switch(this.config.buttonPosition){case"top-left":return"top: 20px; left: 20px;";case"top-right":return"top: 20px; right: 20px;";case"bottom-left":return"bottom: 80px; left: 20px;";case"bottom-right":default:return"bottom: 80px; right: 20px;"}}createMarkers(){}getMarkersElement(h){this.markersContainer=document.createElement("div"),this.markersContainer.className="tsvp-skip-markers",this.markersContainer.style.cssText=`
529
+ `,this.button.addEventListener("mouseenter",()=>{this.button.style.background="rgba(255, 255, 255, 0.2)",this.button.style.transform="scale(1.05)"}),this.button.addEventListener("mouseleave",()=>{this.button.style.background="rgba(0, 0, 0, 0.85)",this.button.style.transform="scale(1)"}),this.button.addEventListener("click",()=>this.skip()),this.container.appendChild(this.button)}getPositionStyles(){switch(this.config.buttonPosition){case"top-left":return"top: 20px; left: 20px;";case"top-right":return"top: 20px; right: 20px;";case"bottom-left":return"bottom: 80px; left: 20px;";case"bottom-right":default:return"bottom: 80px; right: 20px;"}}createMarkers(){}getMarkersElement(e){this.markersContainer=document.createElement("div"),this.markersContainer.className="tsvp-skip-markers",this.markersContainer.style.cssText=`
530
530
  position: absolute;
531
531
  left: 0;
532
532
  right: 0;
533
533
  top: 0;
534
534
  bottom: 0;
535
535
  pointer-events: none;
536
- `;for(let b of this.config.segments){let w=document.createElement("div");w.className="tsvp-skip-marker";let C=b.startTime/h*100,M=(b.endTime-b.startTime)/h*100;w.style.cssText=`
536
+ `;for(let t of this.config.segments){let i=document.createElement("div");i.className="tsvp-skip-marker";let n=t.startTime/e*100,s=(t.endTime-t.startTime)/e*100;i.style.cssText=`
537
537
  position: absolute;
538
- left: ${C}%;
539
- width: ${M}%;
538
+ left: ${n}%;
539
+ width: ${s}%;
540
540
  top: 0;
541
541
  bottom: 0;
542
542
  background: ${this.config.markerColor};
543
543
  opacity: 0.6;
544
- `,this.markersContainer.appendChild(w)}return this.markersContainer}attachEventListeners(){if(!this.player)return;let h=()=>{let b=this.player?.state;if(!b)return;this.checkSegments(b.currentTime)};if(this.player.on("timeupdate",h),this.unsubscribers.push(()=>this.player?.off("timeupdate",h)),this.config.keyboardShortcut){let b=(w)=>{if(w.key==="Enter"&&this.state.activeSegment&&this.state.buttonVisible)w.preventDefault(),this.skip()};document.addEventListener("keydown",b),this.unsubscribers.push(()=>document.removeEventListener("keydown",b))}}checkSegments(h){let b=this.state.activeSegment,w=null;for(let C of this.config.segments)if(h>=C.startTime&&h<C.endTime){w=C;break}if(w!==b){if(b)this.onSegmentExit?.(b),this.hideButton();if(w)this.state.activeSegment=w,this.onSegmentEnter?.(w),this.showButton(w);else this.state.activeSegment=null}}showButton(h){if(!this.button)return;let b=h.buttonText||G0[h.type];this.button.textContent=b,this.state.buttonVisible=!0,this.button.style.display="block",this.button.style.opacity="0",this.button.style.transform="translateX(20px)",requestAnimationFrame(()=>{this.button.style.transition="opacity 200ms ease, transform 200ms ease",this.button.style.opacity="1",this.button.style.transform="translateX(0)"});let w=h.autoSkipDelay??this.config.defaultAutoSkipDelay;if(w>0)this.startAutoSkip(w,h);if(this.config.buttonVisibleDuration>0&&!w)this.hideTimer=setTimeout(()=>{this.hideButton()},this.config.buttonVisibleDuration)}hideButton(){if(!this.button)return;if(this.state.buttonVisible=!1,this.state.isAutoSkipping=!1,this.state.countdown=0,this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;if(this.hideTimer)clearTimeout(this.hideTimer),this.hideTimer=null;this.button.style.opacity="0",this.button.style.transform="translateX(20px)",setTimeout(()=>{if(this.button&&!this.state.buttonVisible)this.button.style.display="none"},200)}startAutoSkip(h,b){this.state.isAutoSkipping=!0,this.state.countdown=h,this.updateButtonText(b),this.countdownTimer=setInterval(()=>{if(this.state.countdown--,this.updateButtonText(b),this.state.countdown<=0){if(this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;this.skip()}},1000)}updateButtonText(h){if(!this.button)return;let b=h.buttonText||G0[h.type];if(this.state.isAutoSkipping&&this.state.countdown>0&&h.showCountdown!==!1)this.button.textContent=`${b} (${this.state.countdown})`;else this.button.textContent=b}skip(){if(!this.state.activeSegment||!this.player)return;let h=this.state.activeSegment,b=h.skipTo??h.endTime;this.player.seekTo(b),this.onSkip?.(h),this.hideButton()}addSegment(h){this.config.segments.push(h)}removeSegment(h){this.config.segments=this.config.segments.filter((b)=>b.type!==h)}clearSegments(){this.config.segments=[],this.hideButton()}setSegments(h){this.config.segments=h}getSegments(){return[...this.config.segments]}getState(){return{...this.state}}on(h,b){switch(h){case"skip":this.onSkip=b;break;case"segmentEnter":this.onSegmentEnter=b;break;case"segmentExit":this.onSegmentExit=b;break}}destroy(){if(this.countdownTimer)clearInterval(this.countdownTimer);if(this.hideTimer)clearTimeout(this.hideTimer);this.unsubscribers.forEach((h)=>h()),this.button?.remove(),this.markersContainer?.remove(),this.player=null,this.container=null}}function J0(h){return new P(h)}function bh(h){return{name:"skipSegments",install(b,w){let C=J0(h);return C.attach(b,w),b.skipSegments=C,()=>{C.destroy(),delete b.skipSegments}}}}class I{player=null;config;state;container=null;element=null;countdownTimer=null;showTimer=null;unsubscribers=[];onRecommendationClick=null;onReplay=null;onAutoplay=null;onShow=null;onHide=null;constructor(h={}){this.config={enabled:h.enabled??!0,showDelay:h.showDelay??0,recommendations:h.recommendations||[],actions:h.actions||[],showReplay:h.showReplay??!0,showShare:h.showShare??!1,autoplayCountdown:h.autoplayCountdown??0,title:h.title||"",template:h.template||"",backgroundStyle:h.backgroundStyle||"blur"},this.state={visible:!1,countdown:0,isCountingDown:!1,selectedIndex:0}}attach(h,b){this.player=h,this.container=b,this.createElement(),this.attachEventListeners()}createElement(){if(!this.container)return;this.element=document.createElement("div"),this.element.className="tsvp-end-screen",this.element.style.cssText=`
544
+ `,this.markersContainer.appendChild(i)}return this.markersContainer}attachEventListeners(){if(!this.player)return;let e=()=>{let t=this.player?.state;if(!t)return;this.checkSegments(t.currentTime)};if(this.player.on("timeupdate",e),this.unsubscribers.push(()=>this.player?.off("timeupdate",e)),this.config.keyboardShortcut){let t=(i)=>{if(i.key==="Enter"&&this.state.activeSegment&&this.state.buttonVisible)i.preventDefault(),this.skip()};document.addEventListener("keydown",t),this.unsubscribers.push(()=>document.removeEventListener("keydown",t))}}checkSegments(e){let t=this.state.activeSegment,i=null;for(let n of this.config.segments)if(e>=n.startTime&&e<n.endTime){i=n;break}if(i!==t){if(t)this.onSegmentExit?.(t),this.hideButton();if(i)this.state.activeSegment=i,this.onSegmentEnter?.(i),this.showButton(i);else this.state.activeSegment=null}}showButton(e){if(!this.button)return;let t=e.buttonText||ft[e.type];this.button.textContent=t,this.state.buttonVisible=!0,this.button.style.display="block",this.button.style.opacity="0",this.button.style.transform="translateX(20px)",requestAnimationFrame(()=>{this.button.style.transition="opacity 200ms ease, transform 200ms ease",this.button.style.opacity="1",this.button.style.transform="translateX(0)"});let i=e.autoSkipDelay??this.config.defaultAutoSkipDelay;if(i>0)this.startAutoSkip(i,e);if(this.config.buttonVisibleDuration>0&&!i)this.hideTimer=setTimeout(()=>{this.hideButton()},this.config.buttonVisibleDuration)}hideButton(){if(!this.button)return;if(this.state.buttonVisible=!1,this.state.isAutoSkipping=!1,this.state.countdown=0,this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;if(this.hideTimer)clearTimeout(this.hideTimer),this.hideTimer=null;this.button.style.opacity="0",this.button.style.transform="translateX(20px)",setTimeout(()=>{if(this.button&&!this.state.buttonVisible)this.button.style.display="none"},200)}startAutoSkip(e,t){this.state.isAutoSkipping=!0,this.state.countdown=e,this.updateButtonText(t),this.countdownTimer=setInterval(()=>{if(this.state.countdown--,this.updateButtonText(t),this.state.countdown<=0){if(this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;this.skip()}},1000)}updateButtonText(e){if(!this.button)return;let t=e.buttonText||ft[e.type];if(this.state.isAutoSkipping&&this.state.countdown>0&&e.showCountdown!==!1)this.button.textContent=`${t} (${this.state.countdown})`;else this.button.textContent=t}skip(){if(!this.state.activeSegment||!this.player)return;let e=this.state.activeSegment,t=e.skipTo??e.endTime;this.player.seekTo(t),this.onSkip?.(e),this.hideButton()}addSegment(e){this.config.segments.push(e)}removeSegment(e){this.config.segments=this.config.segments.filter((t)=>t.type!==e)}clearSegments(){this.config.segments=[],this.hideButton()}setSegments(e){this.config.segments=e}getSegments(){return[...this.config.segments]}getState(){return{...this.state}}on(e,t){switch(e){case"skip":this.onSkip=t;break;case"segmentEnter":this.onSegmentEnter=t;break;case"segmentExit":this.onSegmentExit=t;break}}destroy(){if(this.countdownTimer)clearInterval(this.countdownTimer);if(this.hideTimer)clearTimeout(this.hideTimer);this.unsubscribers.forEach((e)=>e()),this.button?.remove(),this.markersContainer?.remove(),this.player=null,this.container=null}}function yt(e){return new V(e)}function Re(e){return{name:"skipSegments",install(t,i){let n=yt(e);return n.attach(t,i),t.skipSegments=n,()=>{n.destroy(),delete t.skipSegments}}}}class B{player=null;config;state;container=null;element=null;countdownTimer=null;showTimer=null;unsubscribers=[];onRecommendationClick=null;onReplay=null;onAutoplay=null;onShow=null;onHide=null;constructor(e={}){this.config={enabled:e.enabled??!0,showDelay:e.showDelay??0,recommendations:e.recommendations||[],actions:e.actions||[],showReplay:e.showReplay??!0,showShare:e.showShare??!1,autoplayCountdown:e.autoplayCountdown??0,title:e.title||"",template:e.template||"",backgroundStyle:e.backgroundStyle||"blur"},this.state={visible:!1,countdown:0,isCountingDown:!1,selectedIndex:0}}attach(e,t){this.player=e,this.container=t,this.createElement(),this.attachEventListeners()}createElement(){if(!this.container)return;this.element=document.createElement("div"),this.element.className="tsvp-end-screen",this.element.style.cssText=`
545
545
  position: absolute;
546
546
  inset: 0;
547
547
  display: none;
@@ -553,33 +553,33 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
553
553
  color: var(--tsvp-color-text, #ffffff);
554
554
  padding: 24px;
555
555
  overflow: auto;
556
- `,this.applyBackgroundStyle(),this.container.appendChild(this.element)}applyBackgroundStyle(){if(!this.element)return;switch(this.config.backgroundStyle){case"blur":this.element.style.background="rgba(0, 0, 0, 0.85)",this.element.style.backdropFilter="blur(10px)";break;case"dark":this.element.style.background="rgba(0, 0, 0, 0.95)";break;case"gradient":this.element.style.background="linear-gradient(135deg, rgba(0,0,0,0.9) 0%, rgba(20,20,40,0.95) 100%)";break;case"none":this.element.style.background="transparent";break}}render(){if(!this.element)return;if(this.config.template){this.element.innerHTML=this.config.template;return}if(this.element.innerHTML="",this.config.title){let b=document.createElement("h2");b.className="tsvp-end-screen-title",b.textContent=this.config.title,b.style.cssText=`
556
+ `,this.applyBackgroundStyle(),this.container.appendChild(this.element)}applyBackgroundStyle(){if(!this.element)return;switch(this.config.backgroundStyle){case"blur":this.element.style.background="rgba(0, 0, 0, 0.85)",this.element.style.backdropFilter="blur(10px)";break;case"dark":this.element.style.background="rgba(0, 0, 0, 0.95)";break;case"gradient":this.element.style.background="linear-gradient(135deg, rgba(0,0,0,0.9) 0%, rgba(20,20,40,0.95) 100%)";break;case"none":this.element.style.background="transparent";break}}render(){if(!this.element)return;if(this.config.template){this.element.innerHTML=this.config.template;return}if(this.element.innerHTML="",this.config.title){let t=document.createElement("h2");t.className="tsvp-end-screen-title",t.textContent=this.config.title,t.style.cssText=`
557
557
  margin: 0 0 24px;
558
558
  font-size: 24px;
559
559
  font-weight: 600;
560
560
  text-align: center;
561
- `,this.element.appendChild(b)}if(this.config.recommendations.length>0){let b=document.createElement("div");b.className="tsvp-end-screen-grid",b.style.cssText=`
561
+ `,this.element.appendChild(t)}if(this.config.recommendations.length>0){let t=document.createElement("div");t.className="tsvp-end-screen-grid",t.style.cssText=`
562
562
  display: grid;
563
563
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
564
564
  gap: 16px;
565
565
  max-width: 900px;
566
566
  width: 100%;
567
567
  margin-bottom: 24px;
568
- `,this.config.recommendations.forEach((w,C)=>{let M=this.createRecommendationCard(w,C);b.appendChild(M)}),this.element.appendChild(b)}let h=document.createElement("div");if(h.className="tsvp-end-screen-actions",h.style.cssText=`
568
+ `,this.config.recommendations.forEach((i,n)=>{let s=this.createRecommendationCard(i,n);t.appendChild(s)}),this.element.appendChild(t)}let e=document.createElement("div");if(e.className="tsvp-end-screen-actions",e.style.cssText=`
569
569
  display: flex;
570
570
  gap: 12px;
571
571
  flex-wrap: wrap;
572
572
  justify-content: center;
573
- `,this.config.showReplay){let b=this.createActionButton({label:"Replay",icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
573
+ `,this.config.showReplay){let t=this.createActionButton({label:"Replay",icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
574
574
  <path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/>
575
- </svg>`,style:"secondary",onClick:()=>this.replay()});h.appendChild(b)}if(this.config.showShare){let b=this.createActionButton({label:"Share",icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
575
+ </svg>`,style:"secondary",onClick:()=>this.replay()});e.appendChild(t)}if(this.config.showShare){let t=this.createActionButton({label:"Share",icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
576
576
  <path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z"/>
577
- </svg>`,style:"outline",onClick:()=>this.share()});h.appendChild(b)}for(let b of this.config.actions){let w=this.createActionButton(b);h.appendChild(w)}if(this.element.appendChild(h),this.state.isCountingDown&&this.config.recommendations.length>0){let b=document.createElement("div");b.className="tsvp-end-screen-countdown",b.style.cssText=`
577
+ </svg>`,style:"outline",onClick:()=>this.share()});e.appendChild(t)}for(let t of this.config.actions){let i=this.createActionButton(t);e.appendChild(i)}if(this.element.appendChild(e),this.state.isCountingDown&&this.config.recommendations.length>0){let t=document.createElement("div");t.className="tsvp-end-screen-countdown",t.style.cssText=`
578
578
  margin-top: 24px;
579
579
  text-align: center;
580
580
  font-size: 14px;
581
581
  opacity: 0.8;
582
- `,b.innerHTML=`
582
+ `,t.innerHTML=`
583
583
  Next video in <strong>${this.state.countdown}</strong> seconds
584
584
  <button class="tsvp-end-screen-cancel" style="
585
585
  margin-left: 12px;
@@ -590,18 +590,18 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
590
590
  color: inherit;
591
591
  cursor: pointer;
592
592
  ">Cancel</button>
593
- `,b.querySelector(".tsvp-end-screen-cancel")?.addEventListener("click",()=>this.cancelAutoplay()),this.element.appendChild(b)}}createRecommendationCard(h,b){let w=document.createElement("div");w.className="tsvp-end-screen-card",w.tabIndex=0;let C=b===this.state.selectedIndex&&this.state.isCountingDown;w.style.cssText=`
593
+ `,t.querySelector(".tsvp-end-screen-cancel")?.addEventListener("click",()=>this.cancelAutoplay()),this.element.appendChild(t)}}createRecommendationCard(e,t){let i=document.createElement("div");i.className="tsvp-end-screen-card",i.tabIndex=0;let n=t===this.state.selectedIndex&&this.state.isCountingDown;i.style.cssText=`
594
594
  background: rgba(255, 255, 255, 0.1);
595
595
  border-radius: 8px;
596
596
  overflow: hidden;
597
597
  cursor: pointer;
598
598
  transition: transform 150ms ease, background 150ms ease;
599
- ${C?"outline: 2px solid var(--tsvp-color-primary, #00a8ff); outline-offset: 2px;":""}
600
- `;let M=document.createElement("div");if(M.className="tsvp-end-screen-thumbnail",M.style.cssText=`
599
+ ${n?"outline: 2px solid var(--tsvp-color-primary, #00a8ff); outline-offset: 2px;":""}
600
+ `;let s=document.createElement("div");if(s.className="tsvp-end-screen-thumbnail",s.style.cssText=`
601
601
  position: relative;
602
602
  aspect-ratio: 16 / 9;
603
- background: url(${h.thumbnail}) center/cover;
604
- `,h.duration){let _=document.createElement("span");_.className="tsvp-end-screen-duration",_.textContent=h.duration,_.style.cssText=`
603
+ background: url(${e.thumbnail}) center/cover;
604
+ `,e.duration){let a=document.createElement("span");a.className="tsvp-end-screen-duration",a.textContent=e.duration,a.style.cssText=`
605
605
  position: absolute;
606
606
  bottom: 4px;
607
607
  right: 4px;
@@ -610,9 +610,9 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
610
610
  border-radius: 4px;
611
611
  font-size: 12px;
612
612
  font-weight: 500;
613
- `,M.appendChild(_)}w.appendChild(M);let z=document.createElement("div");z.className="tsvp-end-screen-info",z.style.cssText=`
613
+ `,s.appendChild(a)}i.appendChild(s);let r=document.createElement("div");r.className="tsvp-end-screen-info",r.style.cssText=`
614
614
  padding: 12px;
615
- `;let $=document.createElement("h3");if($.className="tsvp-end-screen-card-title",$.textContent=h.title,$.style.cssText=`
615
+ `;let o=document.createElement("h3");if(o.className="tsvp-end-screen-card-title",o.textContent=e.title,o.style.cssText=`
616
616
  margin: 0 0 4px;
617
617
  font-size: 14px;
618
618
  font-weight: 500;
@@ -621,21 +621,21 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
621
621
  display: -webkit-box;
622
622
  -webkit-line-clamp: 2;
623
623
  -webkit-box-orient: vertical;
624
- `,z.appendChild($),h.channel){let _=document.createElement("p");_.className="tsvp-end-screen-channel",_.textContent=h.channel,_.style.cssText=`
624
+ `,r.appendChild(o),e.channel){let a=document.createElement("p");a.className="tsvp-end-screen-channel",a.textContent=e.channel,a.style.cssText=`
625
625
  margin: 0;
626
626
  font-size: 12px;
627
627
  opacity: 0.7;
628
- `,z.appendChild(_)}if(h.views||h.date){let _=document.createElement("p");_.className="tsvp-end-screen-meta",_.textContent=[h.views,h.date].filter(Boolean).join(" • "),_.style.cssText=`
628
+ `,r.appendChild(a)}if(e.views||e.date){let a=document.createElement("p");a.className="tsvp-end-screen-meta",a.textContent=[e.views,e.date].filter(Boolean).join(" • "),a.style.cssText=`
629
629
  margin: 4px 0 0;
630
630
  font-size: 12px;
631
631
  opacity: 0.6;
632
- `,z.appendChild(_)}return w.appendChild(z),w.addEventListener("mouseenter",()=>{w.style.transform="scale(1.03)",w.style.background="rgba(255, 255, 255, 0.15)"}),w.addEventListener("mouseleave",()=>{w.style.transform="scale(1)",w.style.background="rgba(255, 255, 255, 0.1)"}),w.addEventListener("click",()=>{if(this.onRecommendationClick?.(h),h.onClick)h.onClick();else if(h.url)window.location.href=h.url}),w}createActionButton(h){let b=document.createElement("button");b.className=`tsvp-end-screen-btn tsvp-end-screen-btn--${h.style||"secondary"}`,b.type="button";let w="rgba(255, 255, 255, 0.2)",C="transparent";switch(h.style){case"primary":w="var(--tsvp-color-primary, #00a8ff)";break;case"outline":w="transparent",C="rgba(255, 255, 255, 0.5)";break}if(b.style.cssText=`
632
+ `,r.appendChild(a)}return i.appendChild(r),i.addEventListener("mouseenter",()=>{i.style.transform="scale(1.03)",i.style.background="rgba(255, 255, 255, 0.15)"}),i.addEventListener("mouseleave",()=>{i.style.transform="scale(1)",i.style.background="rgba(255, 255, 255, 0.1)"}),i.addEventListener("click",()=>{if(this.onRecommendationClick?.(e),e.onClick)e.onClick();else if(e.url)window.location.href=e.url}),i}createActionButton(e){let t=document.createElement("button");t.className=`tsvp-end-screen-btn tsvp-end-screen-btn--${e.style||"secondary"}`,t.type="button";let i="rgba(255, 255, 255, 0.2)",n="transparent";switch(e.style){case"primary":i="var(--tsvp-color-primary, #00a8ff)";break;case"outline":i="transparent",n="rgba(255, 255, 255, 0.5)";break}if(t.style.cssText=`
633
633
  display: flex;
634
634
  align-items: center;
635
635
  gap: 8px;
636
636
  padding: 10px 20px;
637
- background: ${w};
638
- border: 1px solid ${C};
637
+ background: ${i};
638
+ border: 1px solid ${n};
639
639
  border-radius: 6px;
640
640
  color: #fff;
641
641
  font-size: 14px;
@@ -643,25 +643,25 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
643
643
  font-family: inherit;
644
644
  cursor: pointer;
645
645
  transition: transform 150ms ease, opacity 150ms ease;
646
- `,h.icon){let z=document.createElement("span");z.innerHTML=h.icon,z.style.display="flex",b.appendChild(z)}let M=document.createElement("span");return M.textContent=h.label,b.appendChild(M),b.addEventListener("mouseenter",()=>{b.style.transform="scale(1.05)"}),b.addEventListener("mouseleave",()=>{b.style.transform="scale(1)"}),b.addEventListener("click",h.onClick),b}attachEventListeners(){if(!this.player)return;let h=()=>{if(this.config.enabled)this.showTimer=setTimeout(()=>{this.show()},this.config.showDelay)};this.player.on("ended",h),this.unsubscribers.push(()=>this.player?.off("ended",h));let b=()=>{if(this.state.visible)this.hide()};this.player.on("play",b),this.unsubscribers.push(()=>this.player?.off("play",b));let w=(C)=>{if(!this.state.visible)return;switch(C.key){case"Escape":this.hide();break;case"ArrowLeft":this.selectPrevious();break;case"ArrowRight":this.selectNext();break;case"Enter":this.selectCurrent();break}};document.addEventListener("keydown",w),this.unsubscribers.push(()=>document.removeEventListener("keydown",w))}show(){if(!this.element||this.state.visible)return;if(this.state.visible=!0,this.state.selectedIndex=0,this.config.autoplayCountdown>0&&this.config.recommendations.length>0)this.startAutoplayCountdown();this.render(),this.element.style.display="flex",this.element.style.opacity="0",requestAnimationFrame(()=>{this.element.style.transition="opacity 300ms ease",this.element.style.opacity="1"}),this.onShow?.()}hide(){if(!this.element||!this.state.visible)return;this.state.visible=!1,this.cancelAutoplay(),this.element.style.opacity="0",setTimeout(()=>{if(this.element&&!this.state.visible)this.element.style.display="none"},300),this.onHide?.()}startAutoplayCountdown(){this.state.isCountingDown=!0,this.state.countdown=this.config.autoplayCountdown,this.countdownTimer=setInterval(()=>{if(this.state.countdown--,this.render(),this.state.countdown<=0)this.playNextVideo()},1000)}cancelAutoplay(){if(this.state.isCountingDown=!1,this.state.countdown=0,this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;if(this.state.visible)this.render()}playNextVideo(){let h=this.config.recommendations[this.state.selectedIndex];if(h){if(this.onAutoplay?.(h),h.onClick)h.onClick();else if(h.url)window.location.href=h.url}}selectPrevious(){if(this.config.recommendations.length===0)return;this.state.selectedIndex=(this.state.selectedIndex-1+this.config.recommendations.length)%this.config.recommendations.length,this.render()}selectNext(){if(this.config.recommendations.length===0)return;this.state.selectedIndex=(this.state.selectedIndex+1)%this.config.recommendations.length,this.render()}selectCurrent(){let h=this.config.recommendations[this.state.selectedIndex];if(h){if(this.onRecommendationClick?.(h),h.onClick)h.onClick();else if(h.url)window.location.href=h.url}}replay(){this.hide(),this.player?.seekTo(0),this.player?.play(),this.onReplay?.()}share(){if(navigator.share)navigator.share({title:document.title,url:window.location.href});else navigator.clipboard?.writeText(window.location.href)}setRecommendations(h){if(this.config.recommendations=h,this.state.visible)this.render()}getState(){return{...this.state}}on(h,b){switch(h){case"recommendationClick":this.onRecommendationClick=b;break;case"replay":this.onReplay=b;break;case"autoplay":this.onAutoplay=b;break;case"show":this.onShow=b;break;case"hide":this.onHide=b;break}}destroy(){if(this.countdownTimer)clearInterval(this.countdownTimer);if(this.showTimer)clearTimeout(this.showTimer);this.unsubscribers.forEach((h)=>h()),this.element?.remove(),this.player=null,this.container=null}}function A0(h){return new I(h)}function wh(h){return{name:"endScreen",install(b,w){let C=A0(h);return C.attach(b,w),b.endScreen=C,()=>{C.destroy(),delete b.endScreen}}}}class S{player=null;container=null;elements=new Map;dynamicTimers=new Map;unsubscribers=[];constructor(){}attach(h,b){this.player=h,this.container=b}add(h,b){if(!this.container)throw Error("Watermark manager not attached to container");this.remove(h);let w=this.createElement(b);if(w.dataset.watermarkId=h,this.elements.set(h,w),this.container.appendChild(w),b.showOnlyDuringPlayback&&this.player)this.setupPlaybackVisibility(h,w);if(b.animation&&b.animation.type!=="none")this.applyAnimation(w,b.animation);return w}createElement(h){let b=document.createElement("div");b.className="tsvp-watermark";let w=this.getPositionStyles(h.position||"bottom-right",h.offset);if(b.style.cssText=`
646
+ `,e.icon){let r=document.createElement("span");r.innerHTML=e.icon,r.style.display="flex",t.appendChild(r)}let s=document.createElement("span");return s.textContent=e.label,t.appendChild(s),t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.05)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",e.onClick),t}attachEventListeners(){if(!this.player)return;let e=()=>{if(this.config.enabled)this.showTimer=setTimeout(()=>{this.show()},this.config.showDelay)};this.player.on("ended",e),this.unsubscribers.push(()=>this.player?.off("ended",e));let t=()=>{if(this.state.visible)this.hide()};this.player.on("play",t),this.unsubscribers.push(()=>this.player?.off("play",t));let i=(n)=>{if(!this.state.visible)return;switch(n.key){case"Escape":this.hide();break;case"ArrowLeft":this.selectPrevious();break;case"ArrowRight":this.selectNext();break;case"Enter":this.selectCurrent();break}};document.addEventListener("keydown",i),this.unsubscribers.push(()=>document.removeEventListener("keydown",i))}show(){if(!this.element||this.state.visible)return;if(this.state.visible=!0,this.state.selectedIndex=0,this.config.autoplayCountdown>0&&this.config.recommendations.length>0)this.startAutoplayCountdown();this.render(),this.element.style.display="flex",this.element.style.opacity="0",requestAnimationFrame(()=>{this.element.style.transition="opacity 300ms ease",this.element.style.opacity="1"}),this.onShow?.()}hide(){if(!this.element||!this.state.visible)return;this.state.visible=!1,this.cancelAutoplay(),this.element.style.opacity="0",setTimeout(()=>{if(this.element&&!this.state.visible)this.element.style.display="none"},300),this.onHide?.()}startAutoplayCountdown(){this.state.isCountingDown=!0,this.state.countdown=this.config.autoplayCountdown,this.countdownTimer=setInterval(()=>{if(this.state.countdown--,this.render(),this.state.countdown<=0)this.playNextVideo()},1000)}cancelAutoplay(){if(this.state.isCountingDown=!1,this.state.countdown=0,this.countdownTimer)clearInterval(this.countdownTimer),this.countdownTimer=null;if(this.state.visible)this.render()}playNextVideo(){let e=this.config.recommendations[this.state.selectedIndex];if(e){if(this.onAutoplay?.(e),e.onClick)e.onClick();else if(e.url)window.location.href=e.url}}selectPrevious(){if(this.config.recommendations.length===0)return;this.state.selectedIndex=(this.state.selectedIndex-1+this.config.recommendations.length)%this.config.recommendations.length,this.render()}selectNext(){if(this.config.recommendations.length===0)return;this.state.selectedIndex=(this.state.selectedIndex+1)%this.config.recommendations.length,this.render()}selectCurrent(){let e=this.config.recommendations[this.state.selectedIndex];if(e){if(this.onRecommendationClick?.(e),e.onClick)e.onClick();else if(e.url)window.location.href=e.url}}replay(){this.hide(),this.player?.seekTo(0),this.player?.play(),this.onReplay?.()}share(){if(navigator.share)navigator.share({title:document.title,url:window.location.href});else navigator.clipboard?.writeText(window.location.href)}setRecommendations(e){if(this.config.recommendations=e,this.state.visible)this.render()}getState(){return{...this.state}}on(e,t){switch(e){case"recommendationClick":this.onRecommendationClick=t;break;case"replay":this.onReplay=t;break;case"autoplay":this.onAutoplay=t;break;case"show":this.onShow=t;break;case"hide":this.onHide=t;break}}destroy(){if(this.countdownTimer)clearInterval(this.countdownTimer);if(this.showTimer)clearTimeout(this.showTimer);this.unsubscribers.forEach((e)=>e()),this.element?.remove(),this.player=null,this.container=null}}function bt(e){return new B(e)}function He(e){return{name:"endScreen",install(t,i){let n=bt(e);return n.attach(t,i),t.endScreen=n,()=>{n.destroy(),delete t.endScreen}}}}class D{player=null;container=null;elements=new Map;dynamicTimers=new Map;unsubscribers=[];constructor(){}attach(e,t){this.player=e,this.container=t}add(e,t){if(!this.container)throw Error("Watermark manager not attached to container");this.remove(e);let i=this.createElement(t);if(i.dataset.watermarkId=e,this.elements.set(e,i),this.container.appendChild(i),t.showOnlyDuringPlayback&&this.player)this.setupPlaybackVisibility(e,i);if(t.animation&&t.animation.type!=="none")this.applyAnimation(i,t.animation);return i}createElement(e){let t=document.createElement("div");t.className="tsvp-watermark";let i=this.getPositionStyles(e.position||"bottom-right",e.offset);if(t.style.cssText=`
647
647
  position: absolute;
648
- ${w}
648
+ ${i}
649
649
  z-index: 25;
650
- pointer-events: ${h.url?"auto":"none"};
651
- opacity: ${h.opacity??0.7};
652
- transition: opacity ${h.fadeIn||300}ms ease;
653
- ${h.rotate?`transform: rotate(${h.rotate}deg);`:""}
654
- `,h.styles)Object.assign(b.style,h.styles);let C;if(h.html)C=document.createElement("div"),C.innerHTML=h.html;else if(h.image){let M=document.createElement("img");M.src=h.image,M.alt="Watermark",M.style.cssText=`
650
+ pointer-events: ${e.url?"auto":"none"};
651
+ opacity: ${e.opacity??0.7};
652
+ transition: opacity ${e.fadeIn||300}ms ease;
653
+ ${e.rotate?`transform: rotate(${e.rotate}deg);`:""}
654
+ `,e.styles)Object.assign(t.style,e.styles);let n;if(e.html)n=document.createElement("div"),n.innerHTML=e.html;else if(e.image){let s=document.createElement("img");s.src=e.image,s.alt="Watermark",s.style.cssText=`
655
655
  display: block;
656
656
  max-width: 100%;
657
657
  height: auto;
658
- ${h.size?`width: ${h.size};`:""}
659
- `,C=M}else if(h.text)C=document.createElement("span"),C.textContent=h.text,C.style.cssText=`
658
+ ${e.size?`width: ${e.size};`:""}
659
+ `,n=s}else if(e.text)n=document.createElement("span"),n.textContent=e.text,n.style.cssText=`
660
660
  font-family: var(--tsvp-font-family, sans-serif);
661
- font-size: ${h.size||"14px"};
661
+ font-size: ${e.size||"14px"};
662
662
  color: rgba(255, 255, 255, 0.8);
663
663
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
664
- `;else C=document.createElement("span");if(h.url){let M=document.createElement("a");M.href=h.url,M.target=h.newTab?"_blank":"_self",M.rel=h.newTab?"noopener noreferrer":"",M.style.textDecoration="none",M.appendChild(C),b.appendChild(M)}else b.appendChild(C);return b}getPositionStyles(h,b){let w=typeof b?.x==="number"?`${b.x}px`:b?.x||"16px",C=typeof b?.y==="number"?`${b.y}px`:b?.y||"16px",M={"top-left":`top: ${C}; left: ${w};`,"top-center":`top: ${C}; left: 50%; transform: translateX(-50%);`,"top-right":`top: ${C}; right: ${w};`,"center-left":`top: 50%; left: ${w}; transform: translateY(-50%);`,center:"top: 50%; left: 50%; transform: translate(-50%, -50%);","center-right":`top: 50%; right: ${w}; transform: translateY(-50%);`,"bottom-left":`bottom: ${C}; left: ${w};`,"bottom-center":`bottom: ${C}; left: 50%; transform: translateX(-50%);`,"bottom-right":`bottom: ${C}; right: ${w};`};return M[h]||M["bottom-right"]}setupPlaybackVisibility(h,b){if(!this.player)return;b.style.opacity="0";let w=()=>{b.style.opacity=""},C=()=>{b.style.opacity="0"};this.player.on("play",w),this.player.on("pause",C),this.player.on("ended",C),this.unsubscribers.push(()=>{this.player?.off("play",w),this.player?.off("pause",C),this.player?.off("ended",C)})}applyAnimation(h,b){let w=b.duration||1000,C=b.delay||0,M=b.repeat?"infinite":"1";if(!document.querySelector("#tsvp-watermark-animations")){let $=document.createElement("style");$.id="tsvp-watermark-animations",$.textContent=`
664
+ `;else n=document.createElement("span");if(e.url){let s=document.createElement("a");s.href=e.url,s.target=e.newTab?"_blank":"_self",s.rel=e.newTab?"noopener noreferrer":"",s.style.textDecoration="none",s.appendChild(n),t.appendChild(s)}else t.appendChild(n);return t}getPositionStyles(e,t){let i=typeof t?.x==="number"?`${t.x}px`:t?.x||"16px",n=typeof t?.y==="number"?`${t.y}px`:t?.y||"16px",s={"top-left":`top: ${n}; left: ${i};`,"top-center":`top: ${n}; left: 50%; transform: translateX(-50%);`,"top-right":`top: ${n}; right: ${i};`,"center-left":`top: 50%; left: ${i}; transform: translateY(-50%);`,center:"top: 50%; left: 50%; transform: translate(-50%, -50%);","center-right":`top: 50%; right: ${i}; transform: translateY(-50%);`,"bottom-left":`bottom: ${n}; left: ${i};`,"bottom-center":`bottom: ${n}; left: 50%; transform: translateX(-50%);`,"bottom-right":`bottom: ${n}; right: ${i};`};return s[e]||s["bottom-right"]}setupPlaybackVisibility(e,t){if(!this.player)return;t.style.opacity="0";let i=()=>{t.style.opacity=""},n=()=>{t.style.opacity="0"};this.player.on("play",i),this.player.on("pause",n),this.player.on("ended",n),this.unsubscribers.push(()=>{this.player?.off("play",i),this.player?.off("pause",n),this.player?.off("ended",n)})}applyAnimation(e,t){let i=t.duration||1000,n=t.delay||0,s=t.repeat?"infinite":"1";if(!document.querySelector("#tsvp-watermark-animations")){let o=document.createElement("style");o.id="tsvp-watermark-animations",o.textContent=`
665
665
  @keyframes tsvp-watermark-fade {
666
666
  0%, 100% { opacity: 0.3; }
667
667
  50% { opacity: 1; }
@@ -679,7 +679,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
679
679
  0%, 100% { transform: scale(1); }
680
680
  50% { transform: scale(1.1); }
681
681
  }
682
- `,document.head.appendChild($)}let z=`tsvp-watermark-${b.type}`;h.style.animation=`${z} ${w}ms ease ${C}ms ${M}`}addDynamic(h,b,w={}){let C=()=>{let _=[];if(b.userId)_.push(b.userId);if(b.showTimestamp)_.push(new Date().toISOString());if(b.customText)_.push(b.customText);return _.join(" | ")},M=["top-left","top-right","bottom-left","bottom-right","center-left","center-right"],z=w.position||"bottom-right",$=this.add(h,{...w,text:C(),position:z,opacity:w.opacity??0.3});if(b.updateInterval&&b.updateInterval>0){let _=setInterval(()=>{let H=$.querySelector("span");if(H)H.textContent=C()},b.updateInterval);this.dynamicTimers.set(`${h}-text`,_)}if(b.randomizePosition&&b.moveInterval&&b.moveInterval>0){let _=setInterval(()=>{let H=Math.floor(Math.random()*M.length);z=M[H];let W=this.getPositionStyles(z,w.offset);$.style.cssText=$.style.cssText.replace(/top:.*?;|bottom:.*?;|left:.*?;|right:.*?;|transform:.*?;/g,""),$.style.cssText+=W},b.moveInterval);this.dynamicTimers.set(`${h}-move`,_)}return $}remove(h){let b=this.elements.get(h);if(b)b.remove(),this.elements.delete(h);let w=this.dynamicTimers.get(`${h}-text`);if(w)clearInterval(w),this.dynamicTimers.delete(`${h}-text`);let C=this.dynamicTimers.get(`${h}-move`);if(C)clearInterval(C),this.dynamicTimers.delete(`${h}-move`)}removeAll(){for(let h of this.elements.keys())this.remove(h)}update(h,b){let w=this.elements.get(h);if(!w)return;if(b.opacity!==void 0)w.style.opacity=String(b.opacity);if(b.position){let C=this.getPositionStyles(b.position,b.offset);w.style.cssText=w.style.cssText.replace(/top:.*?;|bottom:.*?;|left:.*?;|right:.*?;|transform:.*?;/g,""),w.style.cssText+=C}if(b.text){let C=w.querySelector("span");if(C)C.textContent=b.text}if(b.image){let C=w.querySelector("img");if(C)C.src=b.image}}show(h){let b=this.elements.get(h);if(b)b.style.display=""}hide(h){let b=this.elements.get(h);if(b)b.style.display="none"}showAll(){for(let h of this.elements.keys())this.show(h)}hideAll(){for(let h of this.elements.keys())this.hide(h)}get(h){return this.elements.get(h)}getAll(){return Array.from(this.elements.keys())}destroy(){this.removeAll(),this.unsubscribers.forEach((h)=>h()),this.player=null,this.container=null}}function E0(){return new S}function Ch(h){return{name:"watermark",install(b,w){let C=E0();C.attach(b,w);for(let{id:M,...z}of h)C.add(M,z);return b.watermark=C,()=>{C.destroy(),delete b.watermark}}}}var G=globalThis.HTMLElement??class{};var G2=["src","poster","autoplay","loop","muted","controls","volume","playback-rate","preload","playsinline","crossorigin","controlslist","disable-picture-in-picture"];class Mh extends G{_player=null;_container=null;_disconnectId=0;static get observedAttributes(){return[...G2]}get player(){return this._player}connectedCallback(){if(this._disconnectId++,this._player)return;let h=this.shadowRoot??this.attachShadow({mode:"open"});this._container=document.createElement("div"),this._container.setAttribute("part","container"),this._container.style.cssText="position:relative;width:100%;height:100%;";let b=document.createElement("slot");this._container.appendChild(b),h.appendChild(this._container);let w=this.buildOptions();this._player=new Y(this._container,w),this.forwardEvents()}disconnectedCallback(){if(this.hasAttribute("keep-alive"))return;let h=++this._disconnectId;queueMicrotask(()=>{if(this.isConnected||h!==this._disconnectId)return;this._player?.destroy(),this._player=null,this._container=null,this.shadowRoot?.replaceChildren()})}attributeChangedCallback(h,b,w){if(!this._player)return;switch(h){case"src":if(w)this._player.setSrc(w);break;case"muted":this._player.setMuted(w!==null);break;case"volume":if(w!==null)this._player.setVolume(parseFloat(w));break;case"playback-rate":if(w!==null)this._player.setPlaybackRate(parseFloat(w));break}}buildOptions(){let h={},b=this.readSourceConfig();if(b.sources?.length)h.src=b.sources;if(b.tracks?.length)h.tracks=b.tracks;let w=this.getAttribute("src");if(w&&!h.src)h.src=b.drm?{src:w,type:"application/dash+xml",drm:b.drm}:w;let C=this.getAttribute("poster");if(C)h.poster=C;let M=this.getAttribute("title");if(M)h.title=M;if(this.hasAttribute("autoplay"))h.autoplay=!0;if(this.hasAttribute("loop"))h.loop=!0;if(this.hasAttribute("muted"))h.muted=!0;let z=this.getAttribute("volume");if(z)h.volume=parseFloat(z);let $=this.getAttribute("playback-rate");if($)h.playbackRate=parseFloat($);let _=this.getAttribute("preload");if(_)h.preload=_;if(this.hasAttribute("controls"))h.controls=!0;h.playsinline=this.getAttribute("playsinline")!=="false";let H=this.getAttribute("crossorigin");if(H!==null)h.crossorigin=H;let W=this.getAttribute("controlslist");if(W)h.controlsList=W.split(/\s+/);return h.disablePictureInPicture=this.hasAttribute("disable-picture-in-picture"),h}readSourceConfig(){let h=this.querySelector('script[type="application/json"][data-media-config]'),b=this.getAttribute("data-media-config")?.trim()||h?.textContent?.trim();if(!b)return{};if(b.length>65536)throw TypeError("Media player configuration is too large");try{let w=JSON.parse(b);if(w.sources!==void 0&&(!Array.isArray(w.sources)||w.sources.some((M)=>!M||typeof M!=="object"||typeof M.src!=="string")))throw TypeError("Media player sources are invalid");let C=new Set(["subtitles","captions","descriptions","chapters","metadata"]);if(w.tracks!==void 0&&(!Array.isArray(w.tracks)||w.tracks.some((M)=>!M||typeof M!=="object"||typeof M.src!=="string"||!C.has(String(M.kind)))))throw TypeError("Media player tracks are invalid");return{sources:w.sources,drm:w.drm,tracks:w.tracks}}catch(w){if(w instanceof TypeError)throw w;throw TypeError("Media player configuration is invalid JSON")}}forwardEvents(){if(!this._player)return;let h=["play","pause","playing","waiting","ended","timeupdate","durationchange","volumechange","fullscreenchange","pipchange","error","loadstart","loadeddata","loadedmetadata","canplay","canplaythrough","seeking","seeked","ratechange","qualitychange","statechange","availabilitychange"];for(let b of h)this._player.on(b,(...w)=>{this.dispatchEvent(new CustomEvent(b,{detail:w.length===1?w[0]:w,bubbles:!0,composed:!0}))})}}function j(h,b=0){if(!isFinite(h)||isNaN(h))return"0:00";let w=Math.floor(h),C=Math.floor(w/3600),M=Math.floor(w%3600/60),z=w%60;if(C>0||b>=3600)return`${C}:${M.toString().padStart(2,"0")}:${z.toString().padStart(2,"0")}`;return`${M}:${z.toString().padStart(2,"0")}`}function T(h){if(!isFinite(h)||isNaN(h))return"0 seconds";let b=Math.floor(h),w=Math.floor(b/3600),C=Math.floor(b%3600/60),M=b%60,z=[];if(w>0)z.push(`${w} ${w===1?"hour":"hours"}`);if(C>0)z.push(`${C} ${C===1?"minute":"minutes"}`);if(M>0||z.length===0)z.push(`${M} ${M===1?"second":"seconds"}`);return z.join(", ")}function Q0(h){if(!isFinite(h)||isNaN(h))return"PT0S";let b=Math.floor(h),w=Math.floor(b/3600),C=Math.floor(b%3600/60),M=b%60,z="PT";if(w>0)z+=`${w}H`;if(C>0)z+=`${C}M`;if(M>0||z==="PT")z+=`${M}S`;return z}function J(h){let b=h.getAttribute("for");if(b)return document.getElementById(b)?.player??null;return h.closest("video-player")?.player??null}class zh extends G{_cleanups=[];connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
682
+ `,document.head.appendChild(o)}let r=`tsvp-watermark-${t.type}`;e.style.animation=`${r} ${i}ms ease ${n}ms ${s}`}addDynamic(e,t,i={}){let n=()=>{let a=[];if(t.userId)a.push(t.userId);if(t.showTimestamp)a.push(new Date().toISOString());if(t.customText)a.push(t.customText);return a.join(" | ")},s=["top-left","top-right","bottom-left","bottom-right","center-left","center-right"],r=i.position||"bottom-right",o=this.add(e,{...i,text:n(),position:r,opacity:i.opacity??0.3});if(t.updateInterval&&t.updateInterval>0){let a=setInterval(()=>{let l=o.querySelector("span");if(l)l.textContent=n()},t.updateInterval);this.dynamicTimers.set(`${e}-text`,a)}if(t.randomizePosition&&t.moveInterval&&t.moveInterval>0){let a=setInterval(()=>{let l=Math.floor(Math.random()*s.length);r=s[l];let d=this.getPositionStyles(r,i.offset);o.style.cssText=o.style.cssText.replace(/top:.*?;|bottom:.*?;|left:.*?;|right:.*?;|transform:.*?;/g,""),o.style.cssText+=d},t.moveInterval);this.dynamicTimers.set(`${e}-move`,a)}return o}remove(e){let t=this.elements.get(e);if(t)t.remove(),this.elements.delete(e);let i=this.dynamicTimers.get(`${e}-text`);if(i)clearInterval(i),this.dynamicTimers.delete(`${e}-text`);let n=this.dynamicTimers.get(`${e}-move`);if(n)clearInterval(n),this.dynamicTimers.delete(`${e}-move`)}removeAll(){for(let e of this.elements.keys())this.remove(e)}update(e,t){let i=this.elements.get(e);if(!i)return;if(t.opacity!==void 0)i.style.opacity=String(t.opacity);if(t.position){let n=this.getPositionStyles(t.position,t.offset);i.style.cssText=i.style.cssText.replace(/top:.*?;|bottom:.*?;|left:.*?;|right:.*?;|transform:.*?;/g,""),i.style.cssText+=n}if(t.text){let n=i.querySelector("span");if(n)n.textContent=t.text}if(t.image){let n=i.querySelector("img");if(n)n.src=t.image}}show(e){let t=this.elements.get(e);if(t)t.style.display=""}hide(e){let t=this.elements.get(e);if(t)t.style.display="none"}showAll(){for(let e of this.elements.keys())this.show(e)}hideAll(){for(let e of this.elements.keys())this.hide(e)}get(e){return this.elements.get(e)}getAll(){return Array.from(this.elements.keys())}destroy(){this.removeAll(),this.unsubscribers.forEach((e)=>e()),this.player=null,this.container=null}}function kt(){return new D}function Ie(e){return{name:"watermark",install(t,i){let n=kt();n.attach(t,i);for(let{id:s,...r}of e)n.add(s,r);return t.watermark=n,()=>{n.destroy(),delete t.watermark}}}}var p=globalThis.HTMLElement??class{};var gi=["src","poster","autoplay","loop","muted","controls","volume","playback-rate","preload","playsinline","crossorigin","controlslist","disable-picture-in-picture"];class X extends p{_player=null;_container=null;_disconnectId=0;static get observedAttributes(){return[...gi]}get player(){return this._player}connectedCallback(){if(this._disconnectId++,this._player)return;let e=this.shadowRoot??this.attachShadow({mode:"open"});this._container=document.createElement("div"),this._container.setAttribute("part","container"),this._container.style.cssText="position:relative;width:100%;height:100%;";let t=document.createElement("slot");this._container.appendChild(t),e.appendChild(this._container);let i=this.buildOptions();this._player=new E(this._container,i),this.forwardEvents()}disconnectedCallback(){if(this.hasAttribute("keep-alive"))return;let e=++this._disconnectId;queueMicrotask(()=>{if(this.isConnected||e!==this._disconnectId)return;this._player?.destroy(),this._player=null,this._container=null,this.shadowRoot?.replaceChildren()})}attributeChangedCallback(e,t,i){if(!this._player)return;switch(e){case"src":if(i)this._player.setSrc(i);break;case"muted":this._player.setMuted(i!==null);break;case"volume":if(i!==null)this._player.setVolume(parseFloat(i));break;case"playback-rate":if(i!==null)this._player.setPlaybackRate(parseFloat(i));break}}buildOptions(){let e={},t=this.readSourceConfig();if(t.sources?.length)e.src=t.sources;if(t.tracks?.length)e.tracks=t.tracks;let i=this.getAttribute("src");if(i&&!e.src)e.src=t.drm?{src:i,type:"application/dash+xml",drm:t.drm}:i;let n=this.getAttribute("poster");if(n)e.poster=n;let s=this.getAttribute("title");if(s)e.title=s;if(this.hasAttribute("autoplay"))e.autoplay=!0;if(this.hasAttribute("loop"))e.loop=!0;if(this.hasAttribute("muted"))e.muted=!0;let r=this.getAttribute("volume");if(r)e.volume=parseFloat(r);let o=this.getAttribute("playback-rate");if(o)e.playbackRate=parseFloat(o);let a=this.getAttribute("preload");if(a)e.preload=a;if(this.hasAttribute("controls"))e.controls=!0;e.playsinline=this.getAttribute("playsinline")!=="false";let l=this.getAttribute("crossorigin");if(l!==null)e.crossorigin=l;let d=this.getAttribute("controlslist");if(d)e.controlsList=d.split(/\s+/);return e.disablePictureInPicture=this.hasAttribute("disable-picture-in-picture"),e}readSourceConfig(){let e=this.querySelector('script[type="application/json"][data-media-config]'),t=this.getAttribute("data-media-config")?.trim()||e?.textContent?.trim();if(!t)return{};if(t.length>65536)throw TypeError("Media player configuration is too large");try{let i=JSON.parse(t);if(i.sources!==void 0&&(!Array.isArray(i.sources)||i.sources.some((s)=>!s||typeof s!=="object"||typeof s.src!=="string")))throw TypeError("Media player sources are invalid");let n=new Set(["subtitles","captions","descriptions","chapters","metadata"]);if(i.tracks!==void 0&&(!Array.isArray(i.tracks)||i.tracks.some((s)=>!s||typeof s!=="object"||typeof s.src!=="string"||!n.has(String(s.kind)))))throw TypeError("Media player tracks are invalid");return{sources:i.sources,drm:i.drm,tracks:i.tracks}}catch(i){if(i instanceof TypeError)throw i;throw TypeError("Media player configuration is invalid JSON")}}forwardEvents(){if(!this._player)return;let e=["play","pause","playing","waiting","ended","timeupdate","durationchange","volumechange","fullscreenchange","pipchange","error","loadstart","loadeddata","loadedmetadata","canplay","canplaythrough","seeking","seeked","ratechange","qualitychange","statechange","availabilitychange"];for(let t of e)this._player.on(t,(...i)=>{this.dispatchEvent(new CustomEvent(t,{detail:i.length===1?i[0]:i,bubbles:!0,composed:!0}))})}}function w(e,t=0){if(!isFinite(e)||isNaN(e))return"0:00";let i=Math.floor(e),n=Math.floor(i/3600),s=Math.floor(i%3600/60),r=i%60;if(n>0||t>=3600)return`${n}:${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`;return`${s}:${r.toString().padStart(2,"0")}`}function P(e){if(!isFinite(e)||isNaN(e))return"0 seconds";let t=Math.floor(e),i=Math.floor(t/3600),n=Math.floor(t%3600/60),s=t%60,r=[];if(i>0)r.push(`${i} ${i===1?"hour":"hours"}`);if(n>0)r.push(`${n} ${n===1?"minute":"minutes"}`);if(s>0||r.length===0)r.push(`${s} ${s===1?"second":"seconds"}`);return r.join(", ")}function Ve(e){if(!isFinite(e)||isNaN(e))return"PT0S";let t=Math.floor(e),i=Math.floor(t/3600),n=Math.floor(t%3600/60),s=t%60,r="PT";if(i>0)r+=`${i}H`;if(n>0)r+=`${n}M`;if(s>0||r==="PT")r+=`${s}S`;return r}function h(e){let t=e.getAttribute("for");if(t)return document.getElementById(t)?.player??null;return e.closest("video-player")?.player??null}class G extends p{_cleanups=[];connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
683
683
  <style>
684
684
  :host {
685
685
  display: flex;
@@ -738,7 +738,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
738
738
  <slot name="right"></slot>
739
739
  <slot></slot>
740
740
  </div>
741
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((h)=>h()),this._cleanups=[]}attach(){let h=J(this);if(!h)return;let b=h.subscribe((M)=>{if(M.controlsVisible)this.removeAttribute("controls-hidden");else this.setAttribute("controls-hidden","");this.dataset.fullscreen=M.fullscreenAvailability,this.dataset.pip=M.pipAvailability,this.dataset.volume=M.volumeAvailability,this.dataset.captions=String(M.textTracks.length>0),this.dataset.qualities=String(M.qualities.length>0)}),w=this.shadowRoot.querySelector(".overlay"),C=()=>h.togglePlay();w.addEventListener("click",C),this._cleanups.push(b,()=>w.removeEventListener("click",C))}}var L0="M8 5v14l11-7z",J2="M6 19h4V5H6v14zm8-14v14h4V5h-4z";class _h extends G{_cleanup=null;_onClick=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
741
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((e)=>e()),this._cleanups=[]}attach(){let e=h(this);if(!e)return;let t=e.subscribe((s)=>{if(s.controlsVisible)this.removeAttribute("controls-hidden");else this.setAttribute("controls-hidden","");this.dataset.fullscreen=s.fullscreenAvailability,this.dataset.pip=s.pipAvailability,this.dataset.volume=s.volumeAvailability,this.dataset.captions=String(s.textTracks.length>0),this.dataset.qualities=String(s.qualities.length>0)}),i=this.shadowRoot.querySelector(".overlay"),n=()=>e.togglePlay();i.addEventListener("click",n),this._cleanups.push(t,()=>i.removeEventListener("click",n))}}var Tt="M8 5v14l11-7z",fi="M6 19h4V5H6v14zm8-14v14h4V5h-4z";class J extends p{_cleanup=null;_onClick=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
742
742
  <style>
743
743
  :host { display: inline-flex; }
744
744
  button {
@@ -750,10 +750,10 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
750
750
  </style>
751
751
  <button part="button" type="button" aria-label="Play">
752
752
  <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
753
- <path d="${L0}"/>
753
+ <path d="${Tt}"/>
754
754
  </svg>
755
755
  </button>
756
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let h=this.shadowRoot?.querySelector("button");if(h&&this._onClick)h.removeEventListener("click",this._onClick);this._cleanup?.(),this._cleanup=null,this._onClick=null}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector("button");this._onClick=()=>h.togglePlay(),b.addEventListener("click",this._onClick);let w=h.subscribe("paused",(C)=>{let M=C.paused;b.setAttribute("aria-label",M?"Play":"Pause"),b.setAttribute("aria-pressed",String(!M)),this.shadowRoot.querySelector("path").setAttribute("d",M?L0:J2)});this._cleanup=w}}var A2="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z",E2="M18.5 12A4.5 4.5 0 0 0 16 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z",V0="M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z";function Q2(h,b){if(h||b===0)return A2;if(b<0.5)return E2;return V0}class $h extends G{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
756
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let e=this.shadowRoot?.querySelector("button");if(e&&this._onClick)e.removeEventListener("click",this._onClick);this._cleanup?.(),this._cleanup=null,this._onClick=null}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector("button");this._onClick=()=>e.togglePlay(),t.addEventListener("click",this._onClick);let i=e.subscribe("paused",(n)=>{let s=n.paused;t.setAttribute("aria-label",s?"Play":"Pause"),t.setAttribute("aria-pressed",String(!s)),this.shadowRoot.querySelector("path").setAttribute("d",s?Tt:fi)});this._cleanup=i}}var yi="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z",bi="M18.5 12A4.5 4.5 0 0 0 16 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z",wt="M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z";function ki(e,t){if(e||t===0)return yi;if(t<0.5)return bi;return wt}class Z extends p{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
757
757
  <style>
758
758
  :host { display: inline-flex; }
759
759
  button {
@@ -765,10 +765,10 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
765
765
  </style>
766
766
  <button part="button" type="button" aria-label="Mute">
767
767
  <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
768
- <path d="${V0}"/>
768
+ <path d="${wt}"/>
769
769
  </svg>
770
770
  </button>
771
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector("button");b.addEventListener("click",()=>h.toggleMute());let w=h.subscribe((C)=>{let M=Q2(C.muted,C.volume);b.setAttribute("aria-label",C.muted?"Unmute":"Mute"),this.shadowRoot.querySelector("path").setAttribute("d",M)});this._cleanup=w}}var F0="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z",L2="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z";class Hh extends G{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
771
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector("button");t.addEventListener("click",()=>e.toggleMute());let i=e.subscribe((n)=>{let s=ki(n.muted,n.volume);t.setAttribute("aria-label",n.muted?"Unmute":"Mute"),this.shadowRoot.querySelector("path").setAttribute("d",s)});this._cleanup=i}}var St="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z",Ti="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z";class ee extends p{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
772
772
  <style>
773
773
  :host { display: inline-flex; }
774
774
  :host([hidden]) { display: none; }
@@ -782,10 +782,10 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
782
782
  </style>
783
783
  <button part="button" type="button" aria-label="Enter fullscreen">
784
784
  <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
785
- <path d="${F0}"/>
785
+ <path d="${St}"/>
786
786
  </svg>
787
787
  </button>
788
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector("button");b.addEventListener("click",()=>h.toggleFullscreen());let w=h.subscribe((C)=>{let M=C.fullscreenAvailability;if(M==="unsupported")this.setAttribute("hidden","");else this.removeAttribute("hidden");b.disabled=M!=="available";let z=C.fullscreen;b.setAttribute("aria-label",z?"Exit fullscreen":"Enter fullscreen"),this.shadowRoot.querySelector("path").setAttribute("d",z?L2:F0)});this._cleanup=w}}var V2="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z";class Wh extends G{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
788
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector("button");t.addEventListener("click",()=>e.toggleFullscreen());let i=e.subscribe((n)=>{let s=n.fullscreenAvailability;if(s==="unsupported")this.setAttribute("hidden","");else this.removeAttribute("hidden");t.disabled=s!=="available";let r=n.fullscreen;t.setAttribute("aria-label",r?"Exit fullscreen":"Enter fullscreen"),this.shadowRoot.querySelector("path").setAttribute("d",r?Ti:St)});this._cleanup=i}}var wi="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z";class te extends p{_cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
789
789
  <style>
790
790
  :host { display: inline-flex; }
791
791
  :host([hidden]) { display: none; }
@@ -799,10 +799,10 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
799
799
  </style>
800
800
  <button part="button" type="button" aria-label="Picture in picture">
801
801
  <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
802
- <path d="${V2}"/>
802
+ <path d="${wi}"/>
803
803
  </svg>
804
804
  </button>
805
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector("button");b.addEventListener("click",()=>h.togglePiP());let w=h.subscribe((C)=>{let M=C.pipAvailability;if(M==="unsupported")this.setAttribute("hidden","");else this.removeAttribute("hidden");b.disabled=M!=="available"});this._cleanup=w}}class Nh extends G{_cleanup=null;_showRemaining=!1;static get observedAttributes(){return["type"]}get type(){return this.getAttribute("type")||"current"}connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
805
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector("button");t.addEventListener("click",()=>e.togglePiP());let i=e.subscribe((n)=>{let s=n.pipAvailability;if(s==="unsupported")this.setAttribute("hidden","");else this.removeAttribute("hidden");t.disabled=s!=="available"});this._cleanup=i}}class ie extends p{_cleanup=null;_showRemaining=!1;static get observedAttributes(){return["type"]}get type(){return this.getAttribute("type")||"current"}connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
806
806
  <style>
807
807
  :host {
808
808
  display: inline-flex;
@@ -816,7 +816,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
816
816
  .separator { margin: 0 2px; }
817
817
  </style>
818
818
  <time part="time" datetime="PT0S" aria-valuetext="0 seconds">0:00</time>
819
- `}this.addEventListener("click",this.handleClick),queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null,this.removeEventListener("click",this.handleClick)}handleClick=()=>{if(this.type==="duration"){this._showRemaining=!this._showRemaining;let h=J(this);if(h)this.render(h.state)}};attach(){let h=J(this);if(!h)return;let b=h.subscribe((w)=>{this.render(w)});this._cleanup=b}render(h){let b=this.shadowRoot?.querySelector("time");if(!b)return;let w=this.type,C;if(w==="remaining"||w==="duration"&&this._showRemaining){C=Math.max(h.duration-h.currentTime,0);let M=`-${j(C,h.duration)}`;b.textContent=M}else if(w==="duration")C=h.duration,b.textContent=j(C);else C=h.currentTime,b.textContent=j(C,h.duration);b.setAttribute("datetime",Q0(C)),b.setAttribute("aria-valuetext",T(C))}}class Zh extends G{connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
819
+ `}this.addEventListener("click",this.handleClick),queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanup?.(),this._cleanup=null,this.removeEventListener("click",this.handleClick)}handleClick=()=>{if(this.type==="duration"){this._showRemaining=!this._showRemaining;let e=h(this);if(e)this.render(e.state)}};attach(){let e=h(this);if(!e)return;let t=e.subscribe((i)=>{this.render(i)});this._cleanup=t}render(e){let t=this.shadowRoot?.querySelector("time");if(!t)return;let i=this.type,n;if(i==="remaining"||i==="duration"&&this._showRemaining){n=Math.max(e.duration-e.currentTime,0);let s=`-${w(n,e.duration)}`;t.textContent=s}else if(i==="duration")n=e.duration,t.textContent=w(n);else n=e.currentTime,t.textContent=w(n,e.duration);t.setAttribute("datetime",Ve(n)),t.setAttribute("aria-valuetext",P(n))}}class ne extends p{connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
820
820
  <style>
821
821
  :host {
822
822
  display: inline-flex;
@@ -829,7 +829,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
829
829
  }
830
830
  </style>
831
831
  <slot></slot>
832
- `}}}class Gh extends G{connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
832
+ `}}}class se extends p{connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
833
833
  <style>
834
834
  :host {
835
835
  display: inline-flex;
@@ -842,7 +842,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
842
842
  }
843
843
  </style>
844
844
  <span aria-hidden="true" part="separator"><slot>/</slot></span>
845
- `}this.setAttribute("role","separator"),this.setAttribute("aria-hidden","true")}}class Jh extends G{_cleanups=[];connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
845
+ `}this.setAttribute("role","separator"),this.setAttribute("aria-hidden","true")}}class re extends p{_cleanups=[];connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
846
846
  <style>
847
847
  :host {
848
848
  display: inline-block;
@@ -854,7 +854,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
854
854
  }
855
855
  </style>
856
856
  <span part="value">0:00</span>
857
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((h)=>h()),this._cleanups=[]}attach(){let h=J(this);if(!h)return;let b=this.closest("media-progress-bar")||this.parentElement?.querySelector("media-progress-bar");if(b){let w=(C)=>{let M=C,$=(b.shadowRoot?.querySelector(".track")||b).getBoundingClientRect(),H=Math.max(0,Math.min(1,(M.clientX-$.left)/$.width))*(h.state.duration||0);this.updateTime(H,h.state.duration)};b.addEventListener("pointermove",w),this._cleanups.push(()=>b.removeEventListener("pointermove",w))}}updateTime(h,b){let w=this.shadowRoot?.querySelector("span");if(w)w.textContent=j(h,b)}}class Ah extends G{_cleanups=[];_isDragging=!1;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
857
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((e)=>e()),this._cleanups=[]}attach(){let e=h(this);if(!e)return;let t=this.closest("media-progress-bar")||this.parentElement?.querySelector("media-progress-bar");if(t){let i=(n)=>{let s=n,o=(t.shadowRoot?.querySelector(".track")||t).getBoundingClientRect(),l=Math.max(0,Math.min(1,(s.clientX-o.left)/o.width))*(e.state.duration||0);this.updateTime(l,e.state.duration)};t.addEventListener("pointermove",i),this._cleanups.push(()=>t.removeEventListener("pointermove",i))}}updateTime(e,t){let i=this.shadowRoot?.querySelector("span");if(i)i.textContent=w(e,t)}}class ae extends p{_cleanups=[];_isDragging=!1;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
858
858
  <style>
859
859
  :host { display: flex; flex: 1; align-items: center; }
860
860
  .container {
@@ -914,7 +914,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
914
914
  <div class="thumb" part="thumb"></div>
915
915
  </div>
916
916
  </div>
917
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((h)=>h()),this._cleanups=[]}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector(".container"),w=this.shadowRoot.querySelector(".track"),C=this.shadowRoot.querySelector(".fill"),M=this.shadowRoot.querySelector(".thumb"),z=this.shadowRoot.querySelector(".buffered"),$=this.shadowRoot.querySelector(".tooltip"),_=this.getAttribute("waveform");if(_){let A=new URL(_,document.baseURI);if(["http:","https:","blob:"].includes(A.protocol)||A.href.startsWith("data:image/")){let V=this.shadowRoot.querySelector(".waveform");V.style.backgroundImage=`url(${JSON.stringify(A.href)})`}}let H=(A)=>{let V=w.getBoundingClientRect(),X=Math.max(0,Math.min(1,(A.clientX-V.left)/V.width))*(h.state.duration||0);$.textContent=j(X,h.state.duration);let u=b.getBoundingClientRect(),x=$.offsetWidth,K0=A.clientX-u.left,j0=x/2,X0=u.width-x/2,U0=Math.max(j0,Math.min(X0,K0));$.style.left=`${U0}px`},W=(A)=>{let V=w.getBoundingClientRect(),X=Math.max(0,Math.min(1,(A.clientX-V.left)/V.width))*(h.state.duration||0);h.seekTo(X)},N=(A)=>{this._isDragging=!0,b.setPointerCapture(A.pointerId),W(A)},Z=(A)=>{if(H(A),!this._isDragging)return;W(A)},E=(A)=>{if(!this._isDragging)return;this._isDragging=!1,b.releasePointerCapture(A.pointerId)},Q=(A)=>{let L=h.state.currentTime;switch(A.key){case"ArrowRight":L=Math.min(h.state.duration,L+5);break;case"ArrowLeft":L=Math.max(0,L-5);break;case"Home":L=0;break;case"End":L=h.state.duration;break;default:return}A.preventDefault(),h.seekTo(L)};b.addEventListener("pointerdown",N),b.addEventListener("pointermove",Z),b.addEventListener("pointerup",E),b.addEventListener("keydown",Q),this._cleanups.push(()=>b.removeEventListener("pointerdown",N),()=>b.removeEventListener("pointermove",Z),()=>b.removeEventListener("pointerup",E),()=>b.removeEventListener("keydown",Q));let R=h.subscribe((A)=>{if(this._isDragging)return;let V=A.duration||0,L=V>0?A.currentTime/V*100:0;C.style.width=`${L}%`,M.style.left=`${L}%`,b.setAttribute("aria-valuenow",String(Math.round(L))),b.setAttribute("aria-valuetext",`${T(A.currentTime)} of ${T(V)}`);let X=(A.bufferedAmount||0)*100;z.style.width=`${X}%`});this._cleanups.push(R)}}class Eh extends G{_cleanups=[];_isDragging=!1;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
917
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((e)=>e()),this._cleanups=[]}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector(".container"),i=this.shadowRoot.querySelector(".track"),n=this.shadowRoot.querySelector(".fill"),s=this.shadowRoot.querySelector(".thumb"),r=this.shadowRoot.querySelector(".buffered"),o=this.shadowRoot.querySelector(".tooltip"),a=this.getAttribute("waveform");if(a){let m=new URL(a,document.baseURI);if(["http:","https:","blob:"].includes(m.protocol)||m.href.startsWith("data:image/")){let y=this.shadowRoot.querySelector(".waveform");y.style.backgroundImage=`url(${JSON.stringify(m.href)})`}}let l=(m)=>{let y=i.getBoundingClientRect(),S=Math.max(0,Math.min(1,(m.clientX-y.left)/y.width))*(e.state.duration||0);o.textContent=w(S,e.state.duration);let F=t.getBoundingClientRect(),O=o.offsetWidth,Et=m.clientX-F.left,Pt=O/2,At=F.width-O/2,Mt=Math.max(Pt,Math.min(At,Et));o.style.left=`${Mt}px`},d=(m)=>{let y=i.getBoundingClientRect(),S=Math.max(0,Math.min(1,(m.clientX-y.left)/y.width))*(e.state.duration||0);e.seekTo(S)},c=(m)=>{this._isDragging=!0,t.setPointerCapture(m.pointerId),d(m)},u=(m)=>{if(l(m),!this._isDragging)return;d(m)},v=(m)=>{if(!this._isDragging)return;this._isDragging=!1,t.releasePointerCapture(m.pointerId)},g=(m)=>{let f=e.state.currentTime;switch(m.key){case"ArrowRight":f=Math.min(e.state.duration,f+5);break;case"ArrowLeft":f=Math.max(0,f-5);break;case"Home":f=0;break;case"End":f=e.state.duration;break;default:return}m.preventDefault(),e.seekTo(f)};t.addEventListener("pointerdown",c),t.addEventListener("pointermove",u),t.addEventListener("pointerup",v),t.addEventListener("keydown",g),this._cleanups.push(()=>t.removeEventListener("pointerdown",c),()=>t.removeEventListener("pointermove",u),()=>t.removeEventListener("pointerup",v),()=>t.removeEventListener("keydown",g));let k=e.subscribe((m)=>{if(this._isDragging)return;let y=m.duration||0,f=y>0?m.currentTime/y*100:0;n.style.width=`${f}%`,s.style.left=`${f}%`,t.setAttribute("aria-valuenow",String(Math.round(f))),t.setAttribute("aria-valuetext",`${P(m.currentTime)} of ${P(y)}`);let S=(m.bufferedAmount||0)*100;r.style.width=`${S}%`});this._cleanups.push(k)}}class oe extends p{_cleanups=[];_isDragging=!1;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
918
918
  <style>
919
919
  :host { display: inline-flex; align-items: center; width: 80px; }
920
920
  :host([hidden]) { display: none; }
@@ -948,7 +948,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
948
948
  <div class="thumb" part="thumb"></div>
949
949
  </div>
950
950
  </div>
951
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((h)=>h()),this._cleanups=[]}attach(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector(".container"),w=this.shadowRoot.querySelector(".track"),C=this.shadowRoot.querySelector(".fill"),M=this.shadowRoot.querySelector(".thumb"),z=(Z)=>{let E=w.getBoundingClientRect(),Q=Math.max(0,Math.min(1,(Z.clientX-E.left)/E.width));if(h.setVolume(Q),Q>0&&h.state.muted)h.setMuted(!1)},$=(Z)=>{this._isDragging=!0,b.setPointerCapture(Z.pointerId),z(Z)},_=(Z)=>{if(!this._isDragging)return;z(Z)},H=(Z)=>{if(!this._isDragging)return;this._isDragging=!1,b.releasePointerCapture(Z.pointerId)},W=(Z)=>{let E=h.state.volume,Q=0.05;switch(Z.key){case"ArrowRight":case"ArrowUp":E=Math.min(1,E+Q);break;case"ArrowLeft":case"ArrowDown":E=Math.max(0,E-Q);break;default:return}Z.preventDefault(),h.setVolume(E)};b.addEventListener("pointerdown",$),b.addEventListener("pointermove",_),b.addEventListener("pointerup",H),b.addEventListener("keydown",W),this._cleanups.push(()=>b.removeEventListener("pointerdown",$),()=>b.removeEventListener("pointermove",_),()=>b.removeEventListener("pointerup",H),()=>b.removeEventListener("keydown",W));let N=h.subscribe((Z)=>{if(Z.volumeAvailability==="unsupported"){this.setAttribute("hidden","");return}this.removeAttribute("hidden");let Q=(Z.muted?0:Z.volume)*100;C.style.width=`${Q}%`,M.style.left=`${Q}%`,b.setAttribute("aria-valuenow",String(Math.round(Q)))});this._cleanups.push(N)}}function R0(h,b,w={}){let{placement:C="top",offset:M=4,boundary:z=null,padding:$=8}=w,_=h.getBoundingClientRect(),H=b.getBoundingClientRect(),W=z?z.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth,width:window.innerWidth,height:window.innerHeight},N=_.top-W.top-$,Z=W.bottom-_.bottom-$,E;if(C.startsWith("top"))E=H.height+M<=N?"top":"bottom";else E=H.height+M<=Z?"bottom":"top";let Q;if(E==="top")Q=_.top-H.height-M;else Q=_.bottom+M;let R="";if(C.endsWith("-start"))R="-start";else if(C.endsWith("-end"))R="-end";let A;switch(R){case"-start":A=_.left;break;case"-end":A=_.right-H.width;break;default:A=_.left+(_.width-H.width)/2;break}let V=W.left+$,L=W.right-H.width-$;A=Math.max(V,Math.min(L,A));let X=W.top+$,u=W.bottom-H.height-$;Q=Math.max(X,Math.min(u,Q));let x=`${E}${R}`;return{top:Q,left:A,placement:x}}var F2="M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z",R2=[0.25,0.5,0.75,1,1.25,1.5,1.75,2];class Qh extends G{_cleanup=null;_isOpen=!1;_currentPanel="main";connectedCallback(){if(!this.shadowRoot){let b=this.attachShadow({mode:"open"});b.innerHTML=`
951
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this._cleanups.forEach((e)=>e()),this._cleanups=[]}attach(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector(".container"),i=this.shadowRoot.querySelector(".track"),n=this.shadowRoot.querySelector(".fill"),s=this.shadowRoot.querySelector(".thumb"),r=(u)=>{let v=i.getBoundingClientRect(),g=Math.max(0,Math.min(1,(u.clientX-v.left)/v.width));if(e.setVolume(g),g>0&&e.state.muted)e.setMuted(!1)},o=(u)=>{this._isDragging=!0,t.setPointerCapture(u.pointerId),r(u)},a=(u)=>{if(!this._isDragging)return;r(u)},l=(u)=>{if(!this._isDragging)return;this._isDragging=!1,t.releasePointerCapture(u.pointerId)},d=(u)=>{let v=e.state.volume,g=0.05;switch(u.key){case"ArrowRight":case"ArrowUp":v=Math.min(1,v+g);break;case"ArrowLeft":case"ArrowDown":v=Math.max(0,v-g);break;default:return}u.preventDefault(),e.setVolume(v)};t.addEventListener("pointerdown",o),t.addEventListener("pointermove",a),t.addEventListener("pointerup",l),t.addEventListener("keydown",d),this._cleanups.push(()=>t.removeEventListener("pointerdown",o),()=>t.removeEventListener("pointermove",a),()=>t.removeEventListener("pointerup",l),()=>t.removeEventListener("keydown",d));let c=e.subscribe((u)=>{if(u.volumeAvailability==="unsupported"){this.setAttribute("hidden","");return}this.removeAttribute("hidden");let g=(u.muted?0:u.volume)*100;n.style.width=`${g}%`,s.style.left=`${g}%`,t.setAttribute("aria-valuenow",String(Math.round(g)))});this._cleanups.push(c)}}function xt(e,t,i={}){let{placement:n="top",offset:s=4,boundary:r=null,padding:o=8}=i,a=e.getBoundingClientRect(),l=t.getBoundingClientRect(),d=r?r.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth,width:window.innerWidth,height:window.innerHeight},c=a.top-d.top-o,u=d.bottom-a.bottom-o,v;if(n.startsWith("top"))v=l.height+s<=c?"top":"bottom";else v=l.height+s<=u?"bottom":"top";let g;if(v==="top")g=a.top-l.height-s;else g=a.bottom+s;let k="";if(n.endsWith("-start"))k="-start";else if(n.endsWith("-end"))k="-end";let m;switch(k){case"-start":m=a.left;break;case"-end":m=a.right-l.width;break;default:m=a.left+(a.width-l.width)/2;break}let y=d.left+o,f=d.right-l.width-o;m=Math.max(y,Math.min(f,m));let S=d.top+o,F=d.bottom-l.height-o;g=Math.max(S,Math.min(F,g));let O=`${v}${k}`;return{top:g,left:m,placement:O}}var Si="M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z",xi=[0.25,0.5,0.75,1,1.25,1.5,1.75,2];class le extends p{_cleanup=null;_isOpen=!1;_currentPanel="main";connectedCallback(){if(!this.shadowRoot){let t=this.attachShadow({mode:"open"});t.innerHTML=`
952
952
  <style>
953
953
  :host { display: inline-flex; position: relative; }
954
954
  button.trigger {
@@ -982,11 +982,11 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
982
982
  <button class="trigger" part="trigger" type="button"
983
983
  aria-label="Settings" aria-haspopup="true" aria-expanded="false">
984
984
  <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
985
- <path d="${F2}"/>
985
+ <path d="${Si}"/>
986
986
  </svg>
987
987
  </button>
988
988
  <div class="menu" part="menu" role="menu" aria-hidden="true"></div>
989
- `}let h=this.shadowRoot.querySelector(".trigger");this._onTriggerClick=()=>this.toggle(),h.addEventListener("click",this._onTriggerClick),this._onDocClick=(b)=>{if(this._isOpen&&!this.contains(b.target))this.close()},document.addEventListener("click",this._onDocClick),this._onDocKeydown=(b)=>{if(b.key==="Escape"&&this._isOpen)this.close()},document.addEventListener("keydown",this._onDocKeydown),queueMicrotask(()=>this.attach())}_onTriggerClick=null;_onDocClick=null;_onDocKeydown=null;disconnectedCallback(){if(this._cleanup?.(),this._cleanup=null,this._onTriggerClick)this.shadowRoot?.querySelector(".trigger")?.removeEventListener("click",this._onTriggerClick);if(this._onDocClick)document.removeEventListener("click",this._onDocClick);if(this._onDocKeydown)document.removeEventListener("keydown",this._onDocKeydown)}toggle(){if(this._isOpen)this.close();else this.open()}open(){this._isOpen=!0,this._currentPanel="main",this.setAttribute("open",""),this.shadowRoot.querySelector(".trigger").setAttribute("aria-expanded","true"),this.shadowRoot.querySelector(".menu").setAttribute("aria-hidden","false"),this.renderPanel(),this.positionMenu()}close(){this._isOpen=!1,this.removeAttribute("open"),this.shadowRoot.querySelector(".trigger").setAttribute("aria-expanded","false"),this.shadowRoot.querySelector(".menu").setAttribute("aria-hidden","true")}positionMenu(){let h=this.shadowRoot.querySelector(".trigger"),b=this.shadowRoot.querySelector(".menu");if(!h||!b)return;let w=this.closest("video-player, .ts-video-player"),C=R0(h,b,{placement:"top-end",offset:4,boundary:w,padding:8});b.style.top=`${C.top}px`,b.style.left=`${C.left}px`}attach(){let h=J(this);if(!h)return;let b=h.subscribe(()=>{if(this._isOpen)this.renderPanel()});this._cleanup=b}renderPanel(){let h=J(this);if(!h)return;let b=this.shadowRoot.querySelector(".menu");switch(b.innerHTML="",this._currentPanel){case"main":this.renderMain(b,h);break;case"speed":this.renderSpeed(b,h);break;case"quality":this.renderQuality(b,h);break;case"captions":this.renderCaptions(b,h);break;case"audio":this.renderAudio(b,h);break}if(this._isOpen)queueMicrotask(()=>this.positionMenu())}renderMain(h,b){let w=b.state;if(this.addItem(h,`Speed: ${w.playbackRate}x`,()=>{this._currentPanel="speed",this.renderPanel()}),w.qualities.length>0){let C=w.qualities.find((z)=>z.selected),M=w.autoQuality?"Auto":C?`${C.height}p`:"Auto";this.addItem(h,`Quality: ${M}`,()=>{this._currentPanel="quality",this.renderPanel()})}if(w.textTracks.length>0){let C=w.textTracks.find((M)=>M.mode==="showing");this.addItem(h,`Captions: ${C?.label||"Off"}`,()=>{this._currentPanel="captions",this.renderPanel()})}if(w.audioTracks.length>1){let C=w.audioTracks.find((M)=>M.selected);this.addItem(h,`Audio: ${C?.label||"Default"}`,()=>{this._currentPanel="audio",this.renderPanel()})}}renderSpeed(h,b){this.addItem(h,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);for(let w of R2){let C=b.state.playbackRate===w;this.addItem(h,`${w}x`,()=>{b.setPlaybackRate(w),this.close()},C)}}renderQuality(h,b){this.addItem(h,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0),this.addItem(h,"Auto",()=>{b.setQuality("auto"),this.close()},b.state.autoQuality);for(let w of b.state.qualities)this.addItem(h,`${w.height}p`,()=>{b.setQuality(w),this.close()},w.selected&&!b.state.autoQuality)}renderCaptions(h,b){this.addItem(h,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);let w=b.state.textTracks.some((C)=>C.mode==="showing");this.addItem(h,"Off",()=>{for(let C of b.state.textTracks)if(C.mode==="showing")b.setTextTrack(C.id,"disabled");this.close()},!w);for(let C of b.state.textTracks)if(C.kind==="subtitles"||C.kind==="captions")this.addItem(h,C.label,()=>{b.setTextTrack(C.id,"showing"),this.close()},C.mode==="showing")}renderAudio(h,b){this.addItem(h,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);for(let w of b.state.audioTracks)this.addItem(h,w.label||w.language||"Audio track",()=>{b.setAudioTrack(w.id),this.close()},w.selected)}addItem(h,b,w,C=!1,M=!1){let z=document.createElement("button");if(z.className=`item${M?" back":""}`,z.setAttribute("role","menuitem"),!M)z.setAttribute("aria-checked",String(C));z.textContent=b,z.addEventListener("click",w),h.appendChild(z)}}class Lh extends G{cleanup=null;onClick=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
989
+ `}let e=this.shadowRoot.querySelector(".trigger");this._onTriggerClick=()=>this.toggle(),e.addEventListener("click",this._onTriggerClick),this._onDocClick=(t)=>{if(this._isOpen&&!this.contains(t.target))this.close()},document.addEventListener("click",this._onDocClick),this._onDocKeydown=(t)=>{if(t.key==="Escape"&&this._isOpen)this.close()},document.addEventListener("keydown",this._onDocKeydown),queueMicrotask(()=>this.attach())}_onTriggerClick=null;_onDocClick=null;_onDocKeydown=null;disconnectedCallback(){if(this._cleanup?.(),this._cleanup=null,this._onTriggerClick)this.shadowRoot?.querySelector(".trigger")?.removeEventListener("click",this._onTriggerClick);if(this._onDocClick)document.removeEventListener("click",this._onDocClick);if(this._onDocKeydown)document.removeEventListener("keydown",this._onDocKeydown)}toggle(){if(this._isOpen)this.close();else this.open()}open(){this._isOpen=!0,this._currentPanel="main",this.setAttribute("open",""),this.shadowRoot.querySelector(".trigger").setAttribute("aria-expanded","true"),this.shadowRoot.querySelector(".menu").setAttribute("aria-hidden","false"),this.renderPanel(),this.positionMenu()}close(){this._isOpen=!1,this.removeAttribute("open"),this.shadowRoot.querySelector(".trigger").setAttribute("aria-expanded","false"),this.shadowRoot.querySelector(".menu").setAttribute("aria-hidden","true")}positionMenu(){let e=this.shadowRoot.querySelector(".trigger"),t=this.shadowRoot.querySelector(".menu");if(!e||!t)return;let i=this.closest("video-player, .ts-video-player"),n=xt(e,t,{placement:"top-end",offset:4,boundary:i,padding:8});t.style.top=`${n.top}px`,t.style.left=`${n.left}px`}attach(){let e=h(this);if(!e)return;let t=e.subscribe(()=>{if(this._isOpen)this.renderPanel()});this._cleanup=t}renderPanel(){let e=h(this);if(!e)return;let t=this.shadowRoot.querySelector(".menu");switch(t.innerHTML="",this._currentPanel){case"main":this.renderMain(t,e);break;case"speed":this.renderSpeed(t,e);break;case"quality":this.renderQuality(t,e);break;case"captions":this.renderCaptions(t,e);break;case"audio":this.renderAudio(t,e);break}if(this._isOpen)queueMicrotask(()=>this.positionMenu())}renderMain(e,t){let i=t.state;if(this.addItem(e,`Speed: ${i.playbackRate}x`,()=>{this._currentPanel="speed",this.renderPanel()}),i.qualities.length>0){let n=i.qualities.find((r)=>r.selected),s=i.autoQuality?"Auto":n?`${n.height}p`:"Auto";this.addItem(e,`Quality: ${s}`,()=>{this._currentPanel="quality",this.renderPanel()})}if(i.textTracks.length>0){let n=i.textTracks.find((s)=>s.mode==="showing");this.addItem(e,`Captions: ${n?.label||"Off"}`,()=>{this._currentPanel="captions",this.renderPanel()})}if(i.audioTracks.length>1){let n=i.audioTracks.find((s)=>s.selected);this.addItem(e,`Audio: ${n?.label||"Default"}`,()=>{this._currentPanel="audio",this.renderPanel()})}}renderSpeed(e,t){this.addItem(e,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);for(let i of xi){let n=t.state.playbackRate===i;this.addItem(e,`${i}x`,()=>{t.setPlaybackRate(i),this.close()},n)}}renderQuality(e,t){this.addItem(e,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0),this.addItem(e,"Auto",()=>{t.setQuality("auto"),this.close()},t.state.autoQuality);for(let i of t.state.qualities)this.addItem(e,`${i.height}p`,()=>{t.setQuality(i),this.close()},i.selected&&!t.state.autoQuality)}renderCaptions(e,t){this.addItem(e,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);let i=t.state.textTracks.some((n)=>n.mode==="showing");this.addItem(e,"Off",()=>{for(let n of t.state.textTracks)if(n.mode==="showing")t.setTextTrack(n.id,"disabled");this.close()},!i);for(let n of t.state.textTracks)if(n.kind==="subtitles"||n.kind==="captions")this.addItem(e,n.label,()=>{t.setTextTrack(n.id,"showing"),this.close()},n.mode==="showing")}renderAudio(e,t){this.addItem(e,"Back",()=>{this._currentPanel="main",this.renderPanel()},!1,!0);for(let i of t.state.audioTracks)this.addItem(e,i.label||i.language||"Audio track",()=>{t.setAudioTrack(i.id),this.close()},i.selected)}addItem(e,t,i,n=!1,s=!1){let r=document.createElement("button");if(r.className=`item${s?" back":""}`,r.setAttribute("role","menuitem"),!s)r.setAttribute("aria-checked",String(n));r.textContent=t,r.addEventListener("click",i),e.appendChild(r)}}class de extends p{cleanup=null;onClick=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
990
990
  <style>
991
991
  :host { display: inline-flex; }
992
992
  button { min-width: 40px; height: 40px; padding: 0 8px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; }
@@ -995,7 +995,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
995
995
  button:disabled { cursor: default; opacity: .45; }
996
996
  </style>
997
997
  <button part="button" type="button"></button>
998
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let h=this.shadowRoot?.querySelector("button");if(h&&this.onClick)h.removeEventListener("click",this.onClick);this.cleanup?.(),this.cleanup=null,this.onClick=null}attach(){let h=J(this),b=this.shadowRoot?.querySelector("button");if(!h||!b)return;let w=Number.parseFloat(this.getAttribute("seconds")??"10"),C=Number.isFinite(w)&&w!==0?w:10,M=C>0?`Forward ${C} seconds`:`Back ${Math.abs(C)} seconds`;b.textContent=C>0?`+${C}`:String(C),b.setAttribute("aria-label",M),this.onClick=()=>h.seekBy(C),b.addEventListener("click",this.onClick),this.cleanup=h.subscribe((z)=>{b.disabled=C<0?z.currentTime<=0:z.duration>0&&z.currentTime>=z.duration})}}var K2=[0.5,0.75,1,1.25,1.5,2];class Vh extends G{cleanup=null;onClick=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
998
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let e=this.shadowRoot?.querySelector("button");if(e&&this.onClick)e.removeEventListener("click",this.onClick);this.cleanup?.(),this.cleanup=null,this.onClick=null}attach(){let e=h(this),t=this.shadowRoot?.querySelector("button");if(!e||!t)return;let i=Number.parseFloat(this.getAttribute("seconds")??"10"),n=Number.isFinite(i)&&i!==0?i:10,s=n>0?`Forward ${n} seconds`:`Back ${Math.abs(n)} seconds`;t.textContent=n>0?`+${n}`:String(n),t.setAttribute("aria-label",s),this.onClick=()=>e.seekBy(n),t.addEventListener("click",this.onClick),this.cleanup=e.subscribe((r)=>{t.disabled=n<0?r.currentTime<=0:r.duration>0&&r.currentTime>=r.duration})}}var Ei=[0.5,0.75,1,1.25,1.5,2];class ce extends p{cleanup=null;onClick=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
999
999
  <style>
1000
1000
  :host { display: inline-flex; }
1001
1001
  button { min-width: 42px; height: 40px; padding: 0 8px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-variant-numeric: tabular-nums; }
@@ -1003,7 +1003,7 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
1003
1003
  button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
1004
1004
  </style>
1005
1005
  <button part="button" type="button" aria-label="Playback speed"></button>
1006
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let h=this.shadowRoot?.querySelector("button");if(h&&this.onClick)h.removeEventListener("click",this.onClick);this.cleanup?.(),this.cleanup=null,this.onClick=null}getRates(){let h=(this.getAttribute("rates")??"").split(",").map((b)=>Number.parseFloat(b.trim())).filter((b)=>Number.isFinite(b)&&b>=0.25&&b<=4);return[...new Set(h.length>0?h:K2)].sort((b,w)=>b-w)}attach(){let h=J(this),b=this.shadowRoot?.querySelector("button");if(!h||!b)return;let w=this.getRates();this.onClick=()=>{let C=w.findIndex((M)=>M>h.state.playbackRate+0.001);h.setPlaybackRate(w[C<0?0:C])},b.addEventListener("click",this.onClick),this.cleanup=h.subscribe("playbackRate",(C)=>{b.textContent=`${C.playbackRate}x`,b.setAttribute("aria-label",`Playback speed ${C.playbackRate}x`)})}}var j2="M6.2 19h11.6L12 13.2 6.2 19zM19 3H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h2v-2H5V5h14v10h-2v2h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";class Fh extends G{cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
1006
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){let e=this.shadowRoot?.querySelector("button");if(e&&this.onClick)e.removeEventListener("click",this.onClick);this.cleanup?.(),this.cleanup=null,this.onClick=null}getRates(){let e=(this.getAttribute("rates")??"").split(",").map((t)=>Number.parseFloat(t.trim())).filter((t)=>Number.isFinite(t)&&t>=0.25&&t<=4);return[...new Set(e.length>0?e:Ei)].sort((t,i)=>t-i)}attach(){let e=h(this),t=this.shadowRoot?.querySelector("button");if(!e||!t)return;let i=this.getRates();this.onClick=()=>{let n=i.findIndex((s)=>s>e.state.playbackRate+0.001);e.setPlaybackRate(i[n<0?0:n])},t.addEventListener("click",this.onClick),this.cleanup=e.subscribe("playbackRate",(n)=>{t.textContent=`${n.playbackRate}x`,t.setAttribute("aria-label",`Playback speed ${n.playbackRate}x`)})}}var Pi="M6.2 19h11.6L12 13.2 6.2 19zM19 3H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h2v-2H5V5h14v10h-2v2h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";class ue extends p{cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
1007
1007
  <style>
1008
1008
  :host { display: none; }
1009
1009
  :host([available]) { display: inline-flex; }
@@ -1012,9 +1012,9 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
1012
1012
  :host([connected]) button { color: var(--media-airplay-active-color, #38bdf8); }
1013
1013
  </style>
1014
1014
  <button part="button" type="button" aria-label="Play on AirPlay">
1015
- <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon"><path d="${j2}"/></svg>
1015
+ <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon"><path d="${Pi}"/></svg>
1016
1016
  </button>
1017
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let h=J(this),b=this.shadowRoot?.querySelector("button");if(!h||!b)return;let w=null,C=()=>M(),M=()=>{let _=h.provider?.mediaElement,H=_ instanceof HTMLVideoElement?_:null;if(H!==w)w?.removeEventListener("webkitplaybacktargetavailabilitychanged",C),w?.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",C),H?.addEventListener("webkitplaybacktargetavailabilitychanged",C),H?.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",C),w=H;let W=typeof w?.webkitShowPlaybackTargetPicker==="function";this.toggleAttribute("available",W),this.toggleAttribute("connected",w?.webkitCurrentPlaybackTargetIsWireless===!0),b.setAttribute("aria-pressed",String(w?.webkitCurrentPlaybackTargetIsWireless===!0))},z=()=>w?.webkitShowPlaybackTargetPicker?.();b.addEventListener("click",z);let $=h.subscribe(M);M(),this.cleanup=()=>{$(),b.removeEventListener("click",z),w?.removeEventListener("webkitplaybacktargetavailabilitychanged",C),w?.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",C)}}}class Rh extends G{cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
1017
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let e=h(this),t=this.shadowRoot?.querySelector("button");if(!e||!t)return;let i=null,n=()=>s(),s=()=>{let a=e.provider?.mediaElement,l=a instanceof HTMLVideoElement?a:null;if(l!==i)i?.removeEventListener("webkitplaybacktargetavailabilitychanged",n),i?.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",n),l?.addEventListener("webkitplaybacktargetavailabilitychanged",n),l?.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",n),i=l;let d=typeof i?.webkitShowPlaybackTargetPicker==="function";this.toggleAttribute("available",d),this.toggleAttribute("connected",i?.webkitCurrentPlaybackTargetIsWireless===!0),t.setAttribute("aria-pressed",String(i?.webkitCurrentPlaybackTargetIsWireless===!0))},r=()=>i?.webkitShowPlaybackTargetPicker?.();t.addEventListener("click",r);let o=e.subscribe(s);s(),this.cleanup=()=>{o(),t.removeEventListener("click",r),i?.removeEventListener("webkitplaybacktargetavailabilitychanged",n),i?.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",n)}}}class pe extends p{cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
1018
1018
  <style>
1019
1019
  :host { display: none; }
1020
1020
  :host([available]) { display: inline-flex; }
@@ -1023,14 +1023,14 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
1023
1023
  :host(:not([at-live-edge])) button { opacity: 0.72; }
1024
1024
  </style>
1025
1025
  <button part="button" type="button" aria-label="Go to live edge"><i aria-hidden="true"></i><span>LIVE</span></button>
1026
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let h=J(this),b=this.shadowRoot?.querySelector("button");if(!h||!b)return;let w=Math.max(0,Number(this.getAttribute("threshold")||10)),C=()=>{let $=h.state,_=$.seekable.at(-1)?.end,H=h.provider?.isLive===!0,W=_!==void 0&&(H||!Number.isFinite($.duration)),N=W&&_-$.currentTime<=w;this.toggleAttribute("available",W),this.toggleAttribute("at-live-edge",N),b.setAttribute("aria-pressed",String(N))},M=()=>{let $=h.state.seekable.at(-1)?.end;if($!==void 0)h.seekTo($),h.play()};b.addEventListener("click",M);let z=h.subscribe(C);C(),this.cleanup=()=>{z(),b.removeEventListener("click",M)}}}class Kh extends G{cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
1026
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let e=h(this),t=this.shadowRoot?.querySelector("button");if(!e||!t)return;let i=Math.max(0,Number(this.getAttribute("threshold")||10)),n=()=>{let o=e.state,a=o.seekable.at(-1)?.end,l=e.provider?.isLive===!0,d=a!==void 0&&(l||!Number.isFinite(o.duration)),c=d&&a-o.currentTime<=i;this.toggleAttribute("available",d),this.toggleAttribute("at-live-edge",c),t.setAttribute("aria-pressed",String(c))},s=()=>{let o=e.state.seekable.at(-1)?.end;if(o!==void 0)e.seekTo(o),e.play()};t.addEventListener("click",s);let r=e.subscribe(n);n(),this.cleanup=()=>{r(),t.removeEventListener("click",s)}}}class he extends p{cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
1027
1027
  <style>
1028
1028
  :host { display: none; position: absolute; inset: 0; z-index: 5; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.76); color: white; text-align: center; }
1029
1029
  :host([open]) { display: grid; }
1030
1030
  p { max-width: 42rem; margin: 0; font: 500 14px/1.5 system-ui, sans-serif; }
1031
1031
  </style>
1032
1032
  <p part="message" role="alert" aria-live="assertive"></p>
1033
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let h=J(this),b=this.shadowRoot?.querySelector("p");if(!h||!b)return;let w=()=>{let C=h.state.error;if(this.toggleAttribute("open",!!C),b.textContent=C?.message||"",C?.code!==void 0)this.setAttribute("data-code",String(C.code));else this.removeAttribute("data-code")};this.cleanup=h.subscribe(w),w()}}var X2="M1 18v3h3a3 3 0 0 0-3-3zm0-4v2a5 5 0 0 1 5 5h2a7 7 0 0 0-7-7zm0-4v2c5 0 9 4 9 9h2c0-6.1-4.9-11-11-11zm18-7H5a2 2 0 0 0-2 2v3h2V5h14v10h-5v2h5a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";class jh extends G{cleanup=null;connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
1033
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let e=h(this),t=this.shadowRoot?.querySelector("p");if(!e||!t)return;let i=()=>{let n=e.state.error;if(this.toggleAttribute("open",!!n),t.textContent=n?.message||"",n?.code!==void 0)this.setAttribute("data-code",String(n.code));else this.removeAttribute("data-code")};this.cleanup=e.subscribe(i),i()}}var Ai="M1 18v3h3a3 3 0 0 0-3-3zm0-4v2a5 5 0 0 1 5 5h2a7 7 0 0 0-7-7zm0-4v2c5 0 9 4 9 9h2c0-6.1-4.9-11-11-11zm18-7H5a2 2 0 0 0-2 2v3h2V5h14v10h-5v2h5a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z";class me extends p{cleanup=null;connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`
1034
1034
  <style>
1035
1035
  :host { display: none; }
1036
1036
  :host([available]) { display: inline-flex; }
@@ -1039,6 +1039,6 @@ function Uh(){return{src:null,sources:[],currentSourceIndex:0,mediaType:"unknown
1039
1039
  :host([connected]) button { color: var(--media-remote-active-color, #38bdf8); }
1040
1040
  </style>
1041
1041
  <button part="button" type="button" aria-label="Play on another device">
1042
- <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon"><path d="${X2}"/></svg>
1042
+ <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon"><path d="${Ai}"/></svg>
1043
1043
  </button>
1044
- `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let h=J(this),b=this.shadowRoot?.querySelector("button");if(!h||!b)return;let w=null,C=null,M=0,z=()=>{let N=w?.state==="connected";this.toggleAttribute("connected",N),b.setAttribute("aria-pressed",String(N))},$=()=>{if(M++,w?.removeEventListener("connecting",z),w?.removeEventListener("connect",z),w?.removeEventListener("disconnect",z),w&&C!==null)w.cancelWatchAvailability(C).catch(()=>{});w=null,C=null,this.removeAttribute("available"),this.removeAttribute("connected")},_=()=>{let N=h.provider?.mediaElement,Z=N instanceof HTMLMediaElement?N.remote??null:null;if(Z===w)return;if($(),!Z)return;w=Z;let E=M;w.addEventListener("connecting",z),w.addEventListener("connect",z),w.addEventListener("disconnect",z),z(),w.watchAvailability((Q)=>{if(M===E&&w===Z)this.toggleAttribute("available",Q)}).then((Q)=>{if(M===E&&w===Z)C=Q;else Z.cancelWatchAvailability(Q).catch(()=>{})}).catch(()=>this.removeAttribute("available"))},H=()=>{w?.prompt().catch(()=>{})};b.addEventListener("click",H);let W=h.subscribe(_);_(),this.cleanup=()=>{W(),b.removeEventListener("click",H),$()}}}var U2=[["video-player",Mh],["video-skin",zh],["media-play-button",_h],["media-mute-button",$h],["media-fullscreen-button",Hh],["media-pip-button",Wh],["media-time-display",Nh],["media-time-group",Zh],["media-time-separator",Gh],["media-preview-time",Jh],["media-progress-bar",Ah],["media-volume-slider",Eh],["media-settings-menu",Qh],["media-seek-button",Lh],["media-playback-rate-button",Vh],["media-airplay-button",Fh],["media-live-button",Rh],["media-error-display",Kh],["media-remote-playback-button",jh]];function Xh(){for(let[h,b]of U2)if(!customElements.get(h))customElements.define(h,b)}if(typeof window<"u")Xh(),window.VideoPlayer={createPlayer:z0,Player:Y,EventEmitter:U,StateStore:q,HTML5Provider:v,YouTubeProvider:g,HLSProvider:p,DASHProvider:l,applyTheme:_0,presetThemes:s,I18n:d,t:$0,layouts:a,createLayoutManager:W0,registerElements:Xh,plugins:{VideoAnalytics:D,analyticsPlugin:r,AdsManager:O,adsPlugin:hh,SkipSegmentsManager:P,skipSegmentsPlugin:bh,EndScreenManager:I,endScreenPlugin:wh,WatermarkManager:S,watermarkPlugin:Ch}};
1044
+ `}queueMicrotask(()=>this.attach())}disconnectedCallback(){this.cleanup?.(),this.cleanup=null}attach(){let e=h(this),t=this.shadowRoot?.querySelector("button");if(!e||!t)return;let i=null,n=null,s=0,r=()=>{let c=i?.state==="connected";this.toggleAttribute("connected",c),t.setAttribute("aria-pressed",String(c))},o=()=>{if(s++,i?.removeEventListener("connecting",r),i?.removeEventListener("connect",r),i?.removeEventListener("disconnect",r),i&&n!==null)i.cancelWatchAvailability(n).catch(()=>{});i=null,n=null,this.removeAttribute("available"),this.removeAttribute("connected")},a=()=>{let c=e.provider?.mediaElement,u=c instanceof HTMLMediaElement?c.remote??null:null;if(u===i)return;if(o(),!u)return;i=u;let v=s;i.addEventListener("connecting",r),i.addEventListener("connect",r),i.addEventListener("disconnect",r),r(),i.watchAvailability((g)=>{if(s===v&&i===u)this.toggleAttribute("available",g)}).then((g)=>{if(s===v&&i===u)n=g;else u.cancelWatchAvailability(g).catch(()=>{})}).catch(()=>this.removeAttribute("available"))},l=()=>{i?.prompt().catch(()=>{})};t.addEventListener("click",l);let d=e.subscribe(a);a(),this.cleanup=()=>{d(),t.removeEventListener("click",l),o()}}}var Mi=[["video-player",X],["video-skin",G],["media-play-button",J],["media-mute-button",Z],["media-fullscreen-button",ee],["media-pip-button",te],["media-time-display",ie],["media-time-group",ne],["media-time-separator",se],["media-preview-time",re],["media-progress-bar",ae],["media-volume-slider",oe],["media-settings-menu",le],["media-seek-button",de],["media-playback-rate-button",ce],["media-airplay-button",ue],["media-live-button",pe],["media-error-display",he],["media-remote-playback-button",me]];function Be(){for(let[e,t]of Mi)if(!customElements.get(e))customElements.define(e,t)}if(typeof window<"u")Be(),window.VideoPlayer={createPlayer:ct,Player:E,EventEmitter:x,StateStore:A,HTML5Provider:L,YouTubeProvider:_,HLSProvider:C,DASHProvider:R,applyTheme:ut,presetThemes:Pe,I18n:Y,t:pt,layouts:Me,createLayoutManager:mt,registerElements:Be,plugins:{VideoAnalytics:H,analyticsPlugin:Le,AdsManager:I,adsPlugin:Ce,SkipSegmentsManager:V,skipSegmentsPlugin:Re,EndScreenManager:B,endScreenPlugin:He,WatermarkManager:D,watermarkPlugin:Ie}};