ts-video-player 0.1.0
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/LICENSE.md +21 -0
- package/README.md +438 -0
- package/dist/cdn.d.ts +10 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/cdn.min.js +1046 -0
- package/dist/cdn.min.js.map +54 -0
- package/dist/cdn.test.d.ts +2 -0
- package/dist/cdn.test.d.ts.map +1 -0
- package/dist/chunk-36x4yhjn.js +765 -0
- package/dist/chunk-36x4yhjn.js.map +12 -0
- package/dist/chunk-eajts2jv.js +4243 -0
- package/dist/chunk-eajts2jv.js.map +42 -0
- package/dist/chunk-z1ehbz9f.js +380 -0
- package/dist/chunk-z1ehbz9f.js.map +19 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/audio-gain.d.ts +67 -0
- package/dist/core/audio-gain.d.ts.map +1 -0
- package/dist/core/caption-styles.d.ts +121 -0
- package/dist/core/caption-styles.d.ts.map +1 -0
- package/dist/core/chapters.d.ts +150 -0
- package/dist/core/chapters.d.ts.map +1 -0
- package/dist/core/error-overlay.d.ts +71 -0
- package/dist/core/error-overlay.d.ts.map +1 -0
- package/dist/core/events.d.ts +119 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/features.d.ts +64 -0
- package/dist/core/features.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +132 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/index.d.ts +37 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/live.d.ts +130 -0
- package/dist/core/live.d.ts.map +1 -0
- package/dist/core/media-session.d.ts +38 -0
- package/dist/core/media-session.d.ts.map +1 -0
- package/dist/core/orientation.d.ts +22 -0
- package/dist/core/orientation.d.ts.map +1 -0
- package/dist/core/popover.d.ts +42 -0
- package/dist/core/popover.d.ts.map +1 -0
- package/dist/core/remote-playback.d.ts +195 -0
- package/dist/core/remote-playback.d.ts.map +1 -0
- package/dist/core/settings-menu.d.ts +132 -0
- package/dist/core/settings-menu.d.ts.map +1 -0
- package/dist/core/spinner.d.ts +67 -0
- package/dist/core/spinner.d.ts.map +1 -0
- package/dist/core/state.d.ts +142 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/text-tracks.d.ts +162 -0
- package/dist/core/text-tracks.d.ts.map +1 -0
- package/dist/core/themes.d.ts +213 -0
- package/dist/core/themes.d.ts.map +1 -0
- package/dist/core/thumbnails.d.ts +124 -0
- package/dist/core/thumbnails.d.ts.map +1 -0
- package/dist/core/tooltips.d.ts +100 -0
- package/dist/core/tooltips.d.ts.map +1 -0
- package/dist/elements/base.d.ts +3 -0
- package/dist/elements/base.d.ts.map +1 -0
- package/dist/elements/index.d.ts +33 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +55 -0
- package/dist/elements/index.js.map +9 -0
- package/dist/elements/media-airplay-button.d.ts +13 -0
- package/dist/elements/media-airplay-button.d.ts.map +1 -0
- package/dist/elements/media-error-display.d.ts +13 -0
- package/dist/elements/media-error-display.d.ts.map +1 -0
- package/dist/elements/media-fullscreen-button.d.ts +13 -0
- package/dist/elements/media-fullscreen-button.d.ts.map +1 -0
- package/dist/elements/media-live-button.d.ts +13 -0
- package/dist/elements/media-live-button.d.ts.map +1 -0
- package/dist/elements/media-mute-button.d.ts +13 -0
- package/dist/elements/media-mute-button.d.ts.map +1 -0
- package/dist/elements/media-pip-button.d.ts +13 -0
- package/dist/elements/media-pip-button.d.ts.map +1 -0
- package/dist/elements/media-play-button.d.ts +14 -0
- package/dist/elements/media-play-button.d.ts.map +1 -0
- package/dist/elements/media-playback-rate-button.d.ts +10 -0
- package/dist/elements/media-playback-rate-button.d.ts.map +1 -0
- package/dist/elements/media-preview-time.d.ts +18 -0
- package/dist/elements/media-preview-time.d.ts.map +1 -0
- package/dist/elements/media-progress-bar.d.ts +16 -0
- package/dist/elements/media-progress-bar.d.ts.map +1 -0
- package/dist/elements/media-remote-playback-button.d.ts +16 -0
- package/dist/elements/media-remote-playback-button.d.ts.map +1 -0
- package/dist/elements/media-seek-button.d.ts +9 -0
- package/dist/elements/media-seek-button.d.ts.map +1 -0
- package/dist/elements/media-settings-menu.d.ts +32 -0
- package/dist/elements/media-settings-menu.d.ts.map +1 -0
- package/dist/elements/media-time-display.d.ts +21 -0
- package/dist/elements/media-time-display.d.ts.map +1 -0
- package/dist/elements/media-time-group.d.ts +22 -0
- package/dist/elements/media-time-group.d.ts.map +1 -0
- package/dist/elements/media-time-separator.d.ts +13 -0
- package/dist/elements/media-time-separator.d.ts.map +1 -0
- package/dist/elements/media-volume-slider.d.ts +16 -0
- package/dist/elements/media-volume-slider.d.ts.map +1 -0
- package/dist/elements/utils.d.ts +27 -0
- package/dist/elements/utils.d.ts.map +1 -0
- package/dist/elements/video-player.d.ts +23 -0
- package/dist/elements/video-player.d.ts.map +1 -0
- package/dist/elements/video-skin.d.ts +23 -0
- package/dist/elements/video-skin.d.ts.map +1 -0
- package/dist/features/captions.d.ts +8 -0
- package/dist/features/captions.d.ts.map +1 -0
- package/dist/features/create-player.d.ts +45 -0
- package/dist/features/create-player.d.ts.map +1 -0
- package/dist/features/fullscreen.d.ts +8 -0
- package/dist/features/fullscreen.d.ts.map +1 -0
- package/dist/features/gestures.d.ts +8 -0
- package/dist/features/gestures.d.ts.map +1 -0
- package/dist/features/index.d.ts +26 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +31 -0
- package/dist/features/index.js.map +9 -0
- package/dist/features/keyboard.d.ts +8 -0
- package/dist/features/keyboard.d.ts.map +1 -0
- package/dist/features/pip.d.ts +8 -0
- package/dist/features/pip.d.ts.map +1 -0
- package/dist/features/playback.d.ts +8 -0
- package/dist/features/playback.d.ts.map +1 -0
- package/dist/features/quality.d.ts +8 -0
- package/dist/features/quality.d.ts.map +1 -0
- package/dist/features/types.d.ts +26 -0
- package/dist/features/types.d.ts.map +1 -0
- package/dist/features/volume.d.ts +8 -0
- package/dist/features/volume.d.ts.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8149 -0
- package/dist/index.js.map +31 -0
- package/dist/layouts/index.d.ts +58 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/player.d.ts +90 -0
- package/dist/player.d.ts.map +1 -0
- package/dist/plugins/ads.d.ts +311 -0
- package/dist/plugins/ads.d.ts.map +1 -0
- package/dist/plugins/analytics.d.ts +203 -0
- package/dist/plugins/analytics.d.ts.map +1 -0
- package/dist/plugins/end-screen.d.ts +184 -0
- package/dist/plugins/end-screen.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +13 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +20 -0
- package/dist/plugins/index.js.map +9 -0
- package/dist/plugins/skip-segments.d.ts +159 -0
- package/dist/plugins/skip-segments.d.ts.map +1 -0
- package/dist/plugins/watermark.d.ts +157 -0
- package/dist/plugins/watermark.d.ts.map +1 -0
- package/dist/providers/base.d.ts +56 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/dash.d.ts +94 -0
- package/dist/providers/dash.d.ts.map +1 -0
- package/dist/providers/hls.d.ts +182 -0
- package/dist/providers/hls.d.ts.map +1 -0
- package/dist/providers/html5.d.ts +64 -0
- package/dist/providers/html5.d.ts.map +1 -0
- package/dist/providers/index.d.ts +41 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/vimeo.d.ts +157 -0
- package/dist/providers/vimeo.d.ts.map +1 -0
- package/dist/providers/youtube.d.ts +134 -0
- package/dist/providers/youtube.d.ts.map +1 -0
- package/dist/stx/index.d.ts +59 -0
- package/dist/stx/index.d.ts.map +1 -0
- package/dist/stx/index.js +480 -0
- package/dist/stx/index.js.map +11 -0
- package/dist/types.d.ts +724 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/ui/components.d.ts +121 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +16 -0
- package/dist/ui/index.js.map +9 -0
- package/package.json +109 -0
- package/src/cdn.test.ts +10 -0
- package/src/cdn.ts +60 -0
- package/src/config.ts +25 -0
- package/src/core/audio-gain.ts +171 -0
- package/src/core/caption-styles.ts +568 -0
- package/src/core/chapters.ts +551 -0
- package/src/core/error-overlay.ts +354 -0
- package/src/core/events.ts +552 -0
- package/src/core/features.ts +287 -0
- package/src/core/i18n.ts +590 -0
- package/src/core/index.ts +249 -0
- package/src/core/live.ts +472 -0
- package/src/core/media-session.ts +137 -0
- package/src/core/orientation.ts +57 -0
- package/src/core/popover.ts +143 -0
- package/src/core/remote-playback.ts +661 -0
- package/src/core/settings-menu.ts +630 -0
- package/src/core/spinner.ts +310 -0
- package/src/core/state.ts +476 -0
- package/src/core/text-tracks.ts +599 -0
- package/src/core/themes.ts +607 -0
- package/src/core/thumbnails.ts +457 -0
- package/src/core/tooltips.ts +370 -0
- package/src/elements/base.ts +2 -0
- package/src/elements/index.ts +82 -0
- package/src/elements/media-airplay-button.ts +78 -0
- package/src/elements/media-error-display.ts +47 -0
- package/src/elements/media-fullscreen-button.ts +72 -0
- package/src/elements/media-live-button.ts +65 -0
- package/src/elements/media-mute-button.ts +69 -0
- package/src/elements/media-pip-button.ts +66 -0
- package/src/elements/media-play-button.ts +69 -0
- package/src/elements/media-playback-rate-button.ts +59 -0
- package/src/elements/media-preview-time.ts +75 -0
- package/src/elements/media-progress-bar.ts +200 -0
- package/src/elements/media-remote-playback-button.ts +108 -0
- package/src/elements/media-seek-button.ts +50 -0
- package/src/elements/media-settings-menu.ts +302 -0
- package/src/elements/media-time-display.ts +99 -0
- package/src/elements/media-time-group.ts +41 -0
- package/src/elements/media-time-separator.ts +35 -0
- package/src/elements/media-volume-slider.ts +140 -0
- package/src/elements/utils.ts +82 -0
- package/src/elements/video-player.ts +175 -0
- package/src/elements/video-skin.ts +127 -0
- package/src/features/captions.ts +56 -0
- package/src/features/create-player.ts +91 -0
- package/src/features/fullscreen.ts +44 -0
- package/src/features/gestures.ts +44 -0
- package/src/features/index.ts +44 -0
- package/src/features/keyboard.ts +89 -0
- package/src/features/pip.ts +47 -0
- package/src/features/playback.ts +68 -0
- package/src/features/quality.ts +19 -0
- package/src/features/types.ts +28 -0
- package/src/features/volume.ts +46 -0
- package/src/index.ts +635 -0
- package/src/layouts/index.ts +672 -0
- package/src/player.ts +821 -0
- package/src/plugins/ads.ts +1045 -0
- package/src/plugins/analytics.ts +673 -0
- package/src/plugins/end-screen.ts +793 -0
- package/src/plugins/index.ts +61 -0
- package/src/plugins/skip-segments.ts +537 -0
- package/src/plugins/watermark.ts +537 -0
- package/src/providers/base.ts +197 -0
- package/src/providers/dash.ts +588 -0
- package/src/providers/hls.ts +624 -0
- package/src/providers/html5.ts +473 -0
- package/src/providers/index.ts +97 -0
- package/src/providers/vimeo.ts +533 -0
- package/src/providers/youtube.ts +542 -0
- package/src/stx/index.ts +606 -0
- package/src/types.ts +874 -0
- package/src/ui/components.ts +910 -0
- package/src/ui/index.ts +29 -0
package/dist/cdn.min.js
ADDED
|
@@ -0,0 +1,1046 @@
|
|
|
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:`
|
|
4
|
+
.tsvp-layout-default {
|
|
5
|
+
--tsvp-controls-height: 48px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tsvp-layout-default .tsvp-controls {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
position: absolute;
|
|
12
|
+
bottom: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
right: 0;
|
|
15
|
+
background: var(--tsvp-controls-bg);
|
|
16
|
+
padding: var(--tsvp-controls-padding);
|
|
17
|
+
opacity: 0;
|
|
18
|
+
transition: opacity var(--tsvp-transition-normal) var(--tsvp-transition-easing);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tsvp-layout-default:hover .tsvp-controls,
|
|
22
|
+
.tsvp-layout-default.tsvp-controls-visible .tsvp-controls {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tsvp-layout-default .tsvp-controls-row {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: var(--tsvp-spacing-sm);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tsvp-layout-default .tsvp-controls-row-progress {
|
|
33
|
+
padding: 0 var(--tsvp-spacing-sm);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tsvp-layout-default .tsvp-controls-row-buttons {
|
|
37
|
+
height: var(--tsvp-controls-height);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.tsvp-layout-default .tsvp-controls-left,
|
|
41
|
+
.tsvp-layout-default .tsvp-controls-right {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: var(--tsvp-spacing-xs);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.tsvp-layout-default .tsvp-controls-center {
|
|
48
|
+
flex: 1;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tsvp-layout-default .tsvp-controls-spacer {
|
|
55
|
+
flex: 1;
|
|
56
|
+
}
|
|
57
|
+
`,template:`
|
|
58
|
+
<div class="tsvp-video-container">
|
|
59
|
+
<slot name="video"></slot>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="tsvp-poster"></div>
|
|
62
|
+
<div class="tsvp-captions"></div>
|
|
63
|
+
<div class="tsvp-gestures"></div>
|
|
64
|
+
<div class="tsvp-buffering-indicator"></div>
|
|
65
|
+
<div class="tsvp-controls">
|
|
66
|
+
<div class="tsvp-controls-row tsvp-controls-row-progress">
|
|
67
|
+
<slot name="progress"></slot>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="tsvp-controls-row tsvp-controls-row-buttons">
|
|
70
|
+
<div class="tsvp-controls-left">
|
|
71
|
+
<slot name="play-button"></slot>
|
|
72
|
+
<slot name="volume"></slot>
|
|
73
|
+
<slot name="time"></slot>
|
|
74
|
+
<slot name="live-indicator"></slot>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="tsvp-controls-spacer"></div>
|
|
77
|
+
<div class="tsvp-controls-right">
|
|
78
|
+
<slot name="captions-button"></slot>
|
|
79
|
+
<slot name="settings-button"></slot>
|
|
80
|
+
<slot name="pip-button"></slot>
|
|
81
|
+
<slot name="airplay-button"></slot>
|
|
82
|
+
<slot name="cast-button"></slot>
|
|
83
|
+
<slot name="fullscreen-button"></slot>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
`},_2={name:"minimal",description:"Clean, minimal layout with essential controls only",styles:`
|
|
88
|
+
.tsvp-layout-minimal {
|
|
89
|
+
--tsvp-controls-height: 36px;
|
|
90
|
+
--tsvp-slider-track-height: 2px;
|
|
91
|
+
--tsvp-slider-thumb-size: 10px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.tsvp-layout-minimal .tsvp-controls {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
position: absolute;
|
|
98
|
+
bottom: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
right: 0;
|
|
101
|
+
height: var(--tsvp-controls-height);
|
|
102
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.5));
|
|
103
|
+
padding: 0 var(--tsvp-spacing-sm);
|
|
104
|
+
opacity: 0;
|
|
105
|
+
transition: opacity var(--tsvp-transition-normal);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.tsvp-layout-minimal:hover .tsvp-controls {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.tsvp-layout-minimal .tsvp-progress {
|
|
113
|
+
flex: 1;
|
|
114
|
+
margin: 0 var(--tsvp-spacing-sm);
|
|
115
|
+
}
|
|
116
|
+
`,template:`
|
|
117
|
+
<div class="tsvp-video-container">
|
|
118
|
+
<slot name="video"></slot>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="tsvp-controls">
|
|
121
|
+
<slot name="play-button"></slot>
|
|
122
|
+
<slot name="progress"></slot>
|
|
123
|
+
<slot name="time"></slot>
|
|
124
|
+
<slot name="fullscreen-button"></slot>
|
|
125
|
+
</div>
|
|
126
|
+
`},$2={name:"cinema",description:"Immersive cinema-style layout with center play button",styles:`
|
|
127
|
+
.tsvp-layout-cinema {
|
|
128
|
+
--tsvp-controls-height: 60px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.tsvp-layout-cinema .tsvp-center-play {
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 50%;
|
|
134
|
+
left: 50%;
|
|
135
|
+
transform: translate(-50%, -50%);
|
|
136
|
+
width: 80px;
|
|
137
|
+
height: 80px;
|
|
138
|
+
border-radius: 50%;
|
|
139
|
+
background: rgba(0, 0, 0, 0.6);
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
opacity: 0;
|
|
145
|
+
transition: opacity var(--tsvp-transition-normal), transform var(--tsvp-transition-normal);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.tsvp-layout-cinema:hover .tsvp-center-play,
|
|
149
|
+
.tsvp-layout-cinema.tsvp-paused .tsvp-center-play {
|
|
150
|
+
opacity: 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.tsvp-layout-cinema .tsvp-center-play:hover {
|
|
154
|
+
transform: translate(-50%, -50%) scale(1.1);
|
|
155
|
+
background: rgba(0, 0, 0, 0.8);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.tsvp-layout-cinema .tsvp-center-play svg {
|
|
159
|
+
width: 40px;
|
|
160
|
+
height: 40px;
|
|
161
|
+
fill: white;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.tsvp-layout-cinema .tsvp-controls {
|
|
165
|
+
position: absolute;
|
|
166
|
+
bottom: 0;
|
|
167
|
+
left: 0;
|
|
168
|
+
right: 0;
|
|
169
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.8));
|
|
170
|
+
padding: var(--tsvp-spacing-lg);
|
|
171
|
+
opacity: 0;
|
|
172
|
+
transform: translateY(10px);
|
|
173
|
+
transition: all var(--tsvp-transition-slow);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.tsvp-layout-cinema:hover .tsvp-controls {
|
|
177
|
+
opacity: 1;
|
|
178
|
+
transform: translateY(0);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.tsvp-layout-cinema .tsvp-title {
|
|
182
|
+
color: white;
|
|
183
|
+
font-size: var(--tsvp-font-size-lg);
|
|
184
|
+
font-weight: var(--tsvp-font-weight-bold);
|
|
185
|
+
margin-bottom: var(--tsvp-spacing-md);
|
|
186
|
+
}
|
|
187
|
+
`,template:`
|
|
188
|
+
<div class="tsvp-video-container">
|
|
189
|
+
<slot name="video"></slot>
|
|
190
|
+
</div>
|
|
191
|
+
<div class="tsvp-poster"></div>
|
|
192
|
+
<div class="tsvp-captions"></div>
|
|
193
|
+
<div class="tsvp-center-play">
|
|
194
|
+
<svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>
|
|
195
|
+
</div>
|
|
196
|
+
<div class="tsvp-controls">
|
|
197
|
+
<div class="tsvp-title"></div>
|
|
198
|
+
<div class="tsvp-controls-row">
|
|
199
|
+
<slot name="progress"></slot>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="tsvp-controls-row">
|
|
202
|
+
<slot name="play-button"></slot>
|
|
203
|
+
<slot name="volume"></slot>
|
|
204
|
+
<slot name="time"></slot>
|
|
205
|
+
<div style="flex:1"></div>
|
|
206
|
+
<slot name="captions-button"></slot>
|
|
207
|
+
<slot name="settings-button"></slot>
|
|
208
|
+
<slot name="fullscreen-button"></slot>
|
|
209
|
+
</div>
|
|
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:`
|
|
212
|
+
.tsvp-layout-youtube {
|
|
213
|
+
--tsvp-color-primary: #ff0000;
|
|
214
|
+
--tsvp-slider-track-height: 3px;
|
|
215
|
+
--tsvp-slider-thumb-size: 13px;
|
|
216
|
+
--tsvp-controls-height: 48px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.tsvp-layout-youtube .tsvp-controls {
|
|
220
|
+
position: absolute;
|
|
221
|
+
bottom: 0;
|
|
222
|
+
left: 0;
|
|
223
|
+
right: 0;
|
|
224
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.7));
|
|
225
|
+
opacity: 0;
|
|
226
|
+
transition: opacity var(--tsvp-transition-normal);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.tsvp-layout-youtube:hover .tsvp-controls,
|
|
230
|
+
.tsvp-layout-youtube.tsvp-paused .tsvp-controls {
|
|
231
|
+
opacity: 1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.tsvp-layout-youtube .tsvp-progress-container {
|
|
235
|
+
position: relative;
|
|
236
|
+
padding: 0 12px;
|
|
237
|
+
margin-bottom: -4px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.tsvp-layout-youtube .tsvp-controls-row {
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
height: var(--tsvp-controls-height);
|
|
244
|
+
padding: 0 4px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.tsvp-layout-youtube .tsvp-chapter-markers {
|
|
248
|
+
position: absolute;
|
|
249
|
+
left: 12px;
|
|
250
|
+
right: 12px;
|
|
251
|
+
top: 0;
|
|
252
|
+
height: 100%;
|
|
253
|
+
pointer-events: none;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.tsvp-layout-youtube .tsvp-end-screen {
|
|
257
|
+
position: absolute;
|
|
258
|
+
inset: 0;
|
|
259
|
+
background: rgba(0, 0, 0, 0.85);
|
|
260
|
+
display: none;
|
|
261
|
+
align-items: center;
|
|
262
|
+
justify-content: center;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.tsvp-layout-youtube.tsvp-ended .tsvp-end-screen {
|
|
266
|
+
display: flex;
|
|
267
|
+
}
|
|
268
|
+
`,template:`
|
|
269
|
+
<div class="tsvp-video-container">
|
|
270
|
+
<slot name="video"></slot>
|
|
271
|
+
</div>
|
|
272
|
+
<div class="tsvp-poster"></div>
|
|
273
|
+
<div class="tsvp-captions"></div>
|
|
274
|
+
<div class="tsvp-controls">
|
|
275
|
+
<div class="tsvp-progress-container">
|
|
276
|
+
<slot name="progress"></slot>
|
|
277
|
+
<div class="tsvp-chapter-markers"></div>
|
|
278
|
+
<slot name="thumbnail-preview"></slot>
|
|
279
|
+
</div>
|
|
280
|
+
<div class="tsvp-controls-row">
|
|
281
|
+
<slot name="play-button"></slot>
|
|
282
|
+
<slot name="next-button"></slot>
|
|
283
|
+
<slot name="volume"></slot>
|
|
284
|
+
<slot name="time"></slot>
|
|
285
|
+
<div style="flex:1"></div>
|
|
286
|
+
<slot name="autoplay-toggle"></slot>
|
|
287
|
+
<slot name="captions-button"></slot>
|
|
288
|
+
<slot name="settings-button"></slot>
|
|
289
|
+
<slot name="miniplayer-button"></slot>
|
|
290
|
+
<slot name="theater-button"></slot>
|
|
291
|
+
<slot name="fullscreen-button"></slot>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
<div class="tsvp-end-screen">
|
|
295
|
+
<slot name="end-screen"></slot>
|
|
296
|
+
</div>
|
|
297
|
+
`},W2={name:"vimeo",description:"Vimeo-inspired clean layout",styles:`
|
|
298
|
+
.tsvp-layout-vimeo {
|
|
299
|
+
--tsvp-color-primary: #00adef;
|
|
300
|
+
--tsvp-controls-height: 44px;
|
|
301
|
+
--tsvp-slider-track-height: 4px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.tsvp-layout-vimeo .tsvp-controls {
|
|
305
|
+
position: absolute;
|
|
306
|
+
bottom: 0;
|
|
307
|
+
left: 0;
|
|
308
|
+
right: 0;
|
|
309
|
+
display: flex;
|
|
310
|
+
flex-direction: column;
|
|
311
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.6));
|
|
312
|
+
padding: var(--tsvp-spacing-sm);
|
|
313
|
+
opacity: 0;
|
|
314
|
+
transition: opacity var(--tsvp-transition-normal);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.tsvp-layout-vimeo:hover .tsvp-controls {
|
|
318
|
+
opacity: 1;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.tsvp-layout-vimeo .tsvp-controls-row {
|
|
322
|
+
display: flex;
|
|
323
|
+
align-items: center;
|
|
324
|
+
gap: var(--tsvp-spacing-sm);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.tsvp-layout-vimeo .tsvp-title-bar {
|
|
328
|
+
position: absolute;
|
|
329
|
+
top: 0;
|
|
330
|
+
left: 0;
|
|
331
|
+
right: 0;
|
|
332
|
+
padding: var(--tsvp-spacing-md);
|
|
333
|
+
background: linear-gradient(rgba(0,0,0,0.6), transparent);
|
|
334
|
+
color: white;
|
|
335
|
+
opacity: 0;
|
|
336
|
+
transition: opacity var(--tsvp-transition-normal);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.tsvp-layout-vimeo:hover .tsvp-title-bar {
|
|
340
|
+
opacity: 1;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.tsvp-layout-vimeo .tsvp-like-button,
|
|
344
|
+
.tsvp-layout-vimeo .tsvp-share-button {
|
|
345
|
+
position: absolute;
|
|
346
|
+
right: var(--tsvp-spacing-md);
|
|
347
|
+
background: rgba(0,0,0,0.5);
|
|
348
|
+
border-radius: var(--tsvp-radius-full);
|
|
349
|
+
padding: var(--tsvp-spacing-sm);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.tsvp-layout-vimeo .tsvp-like-button { top: var(--tsvp-spacing-md); }
|
|
353
|
+
.tsvp-layout-vimeo .tsvp-share-button { top: calc(var(--tsvp-spacing-md) + 48px); }
|
|
354
|
+
`,template:`
|
|
355
|
+
<div class="tsvp-video-container">
|
|
356
|
+
<slot name="video"></slot>
|
|
357
|
+
</div>
|
|
358
|
+
<div class="tsvp-poster"></div>
|
|
359
|
+
<div class="tsvp-captions"></div>
|
|
360
|
+
<div class="tsvp-title-bar">
|
|
361
|
+
<slot name="title"></slot>
|
|
362
|
+
</div>
|
|
363
|
+
<div class="tsvp-controls">
|
|
364
|
+
<div class="tsvp-controls-row">
|
|
365
|
+
<slot name="progress"></slot>
|
|
366
|
+
</div>
|
|
367
|
+
<div class="tsvp-controls-row">
|
|
368
|
+
<slot name="play-button"></slot>
|
|
369
|
+
<slot name="volume"></slot>
|
|
370
|
+
<slot name="time"></slot>
|
|
371
|
+
<div style="flex:1"></div>
|
|
372
|
+
<slot name="captions-button"></slot>
|
|
373
|
+
<slot name="settings-button"></slot>
|
|
374
|
+
<slot name="pip-button"></slot>
|
|
375
|
+
<slot name="fullscreen-button"></slot>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
`},N2={name:"audio",description:"Compact layout for audio-only playback",styles:`
|
|
379
|
+
.tsvp-layout-audio {
|
|
380
|
+
--tsvp-controls-height: 64px;
|
|
381
|
+
height: var(--tsvp-controls-height);
|
|
382
|
+
background: var(--tsvp-color-background);
|
|
383
|
+
border-radius: var(--tsvp-radius-lg);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.tsvp-layout-audio .tsvp-controls {
|
|
387
|
+
display: flex;
|
|
388
|
+
align-items: center;
|
|
389
|
+
height: 100%;
|
|
390
|
+
padding: 0 var(--tsvp-spacing-md);
|
|
391
|
+
gap: var(--tsvp-spacing-md);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.tsvp-layout-audio .tsvp-artwork {
|
|
395
|
+
width: 48px;
|
|
396
|
+
height: 48px;
|
|
397
|
+
border-radius: var(--tsvp-radius-sm);
|
|
398
|
+
background: rgba(255,255,255,0.1);
|
|
399
|
+
overflow: hidden;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.tsvp-layout-audio .tsvp-artwork img {
|
|
403
|
+
width: 100%;
|
|
404
|
+
height: 100%;
|
|
405
|
+
object-fit: cover;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.tsvp-layout-audio .tsvp-info {
|
|
409
|
+
flex: 0 0 auto;
|
|
410
|
+
max-width: 200px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.tsvp-layout-audio .tsvp-track-title {
|
|
414
|
+
color: var(--tsvp-color-text);
|
|
415
|
+
font-weight: var(--tsvp-font-weight-bold);
|
|
416
|
+
font-size: var(--tsvp-font-size);
|
|
417
|
+
white-space: nowrap;
|
|
418
|
+
overflow: hidden;
|
|
419
|
+
text-overflow: ellipsis;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.tsvp-layout-audio .tsvp-track-artist {
|
|
423
|
+
color: var(--tsvp-color-text);
|
|
424
|
+
opacity: 0.7;
|
|
425
|
+
font-size: var(--tsvp-font-size-sm);
|
|
426
|
+
white-space: nowrap;
|
|
427
|
+
overflow: hidden;
|
|
428
|
+
text-overflow: ellipsis;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.tsvp-layout-audio .tsvp-progress-section {
|
|
432
|
+
flex: 1;
|
|
433
|
+
display: flex;
|
|
434
|
+
align-items: center;
|
|
435
|
+
gap: var(--tsvp-spacing-sm);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.tsvp-layout-audio .tsvp-progress-bar {
|
|
439
|
+
flex: 1;
|
|
440
|
+
}
|
|
441
|
+
`,template:`
|
|
442
|
+
<div class="tsvp-controls">
|
|
443
|
+
<div class="tsvp-artwork">
|
|
444
|
+
<slot name="artwork"></slot>
|
|
445
|
+
</div>
|
|
446
|
+
<slot name="play-button"></slot>
|
|
447
|
+
<div class="tsvp-info">
|
|
448
|
+
<div class="tsvp-track-title"><slot name="title"></slot></div>
|
|
449
|
+
<div class="tsvp-track-artist"><slot name="artist"></slot></div>
|
|
450
|
+
</div>
|
|
451
|
+
<div class="tsvp-progress-section">
|
|
452
|
+
<slot name="current-time"></slot>
|
|
453
|
+
<div class="tsvp-progress-bar">
|
|
454
|
+
<slot name="progress"></slot>
|
|
455
|
+
</div>
|
|
456
|
+
<slot name="duration"></slot>
|
|
457
|
+
</div>
|
|
458
|
+
<slot name="volume"></slot>
|
|
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=`
|
|
461
|
+
position: absolute;
|
|
462
|
+
inset: 0;
|
|
463
|
+
z-index: 50;
|
|
464
|
+
display: none;
|
|
465
|
+
background: #000;
|
|
466
|
+
`,this.adVideo=document.createElement("video"),this.adVideo.style.cssText=`
|
|
467
|
+
width: 100%;
|
|
468
|
+
height: 100%;
|
|
469
|
+
object-fit: contain;
|
|
470
|
+
`,this.adVideo.playsInline=!0;let h=document.createElement("div");h.className="tsvp-ad-overlay",h.style.cssText=`
|
|
471
|
+
position: absolute;
|
|
472
|
+
inset: 0;
|
|
473
|
+
display: flex;
|
|
474
|
+
flex-direction: column;
|
|
475
|
+
pointer-events: none;
|
|
476
|
+
`;let b=document.createElement("div");b.className="tsvp-ad-info",b.style.cssText=`
|
|
477
|
+
position: absolute;
|
|
478
|
+
top: 12px;
|
|
479
|
+
left: 12px;
|
|
480
|
+
padding: 6px 12px;
|
|
481
|
+
background: rgba(0, 0, 0, 0.7);
|
|
482
|
+
color: #fff;
|
|
483
|
+
font-size: 12px;
|
|
484
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
485
|
+
border-radius: 4px;
|
|
486
|
+
`,b.textContent="Ad",this.skipButton=document.createElement("button"),this.skipButton.className="tsvp-ad-skip",this.skipButton.style.cssText=`
|
|
487
|
+
position: absolute;
|
|
488
|
+
bottom: 80px;
|
|
489
|
+
right: 12px;
|
|
490
|
+
padding: 10px 16px;
|
|
491
|
+
background: rgba(0, 0, 0, 0.8);
|
|
492
|
+
color: #fff;
|
|
493
|
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
494
|
+
border-radius: 4px;
|
|
495
|
+
font-size: 14px;
|
|
496
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
497
|
+
cursor: pointer;
|
|
498
|
+
pointer-events: auto;
|
|
499
|
+
display: none;
|
|
500
|
+
`,this.skipButton.addEventListener("click",()=>this.skipAd());let w=document.createElement("button");w.className="tsvp-ad-learn-more",w.style.cssText=`
|
|
501
|
+
position: absolute;
|
|
502
|
+
bottom: 80px;
|
|
503
|
+
left: 12px;
|
|
504
|
+
padding: 10px 16px;
|
|
505
|
+
background: var(--tsvp-color-primary, #00a8ff);
|
|
506
|
+
color: #fff;
|
|
507
|
+
border: none;
|
|
508
|
+
border-radius: 4px;
|
|
509
|
+
font-size: 14px;
|
|
510
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
511
|
+
cursor: pointer;
|
|
512
|
+
pointer-events: auto;
|
|
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=`
|
|
515
|
+
position: absolute;
|
|
516
|
+
${h}
|
|
517
|
+
padding: 12px 24px;
|
|
518
|
+
background: rgba(0, 0, 0, 0.85);
|
|
519
|
+
color: #fff;
|
|
520
|
+
border: 2px solid rgba(255, 255, 255, 0.8);
|
|
521
|
+
border-radius: 4px;
|
|
522
|
+
font-size: 16px;
|
|
523
|
+
font-weight: 600;
|
|
524
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
525
|
+
cursor: pointer;
|
|
526
|
+
z-index: 30;
|
|
527
|
+
display: none;
|
|
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=`
|
|
530
|
+
position: absolute;
|
|
531
|
+
left: 0;
|
|
532
|
+
right: 0;
|
|
533
|
+
top: 0;
|
|
534
|
+
bottom: 0;
|
|
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=`
|
|
537
|
+
position: absolute;
|
|
538
|
+
left: ${C}%;
|
|
539
|
+
width: ${M}%;
|
|
540
|
+
top: 0;
|
|
541
|
+
bottom: 0;
|
|
542
|
+
background: ${this.config.markerColor};
|
|
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=`
|
|
545
|
+
position: absolute;
|
|
546
|
+
inset: 0;
|
|
547
|
+
display: none;
|
|
548
|
+
flex-direction: column;
|
|
549
|
+
align-items: center;
|
|
550
|
+
justify-content: center;
|
|
551
|
+
z-index: 40;
|
|
552
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
553
|
+
color: var(--tsvp-color-text, #ffffff);
|
|
554
|
+
padding: 24px;
|
|
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=`
|
|
557
|
+
margin: 0 0 24px;
|
|
558
|
+
font-size: 24px;
|
|
559
|
+
font-weight: 600;
|
|
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=`
|
|
562
|
+
display: grid;
|
|
563
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
564
|
+
gap: 16px;
|
|
565
|
+
max-width: 900px;
|
|
566
|
+
width: 100%;
|
|
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=`
|
|
569
|
+
display: flex;
|
|
570
|
+
gap: 12px;
|
|
571
|
+
flex-wrap: wrap;
|
|
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">
|
|
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">
|
|
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=`
|
|
578
|
+
margin-top: 24px;
|
|
579
|
+
text-align: center;
|
|
580
|
+
font-size: 14px;
|
|
581
|
+
opacity: 0.8;
|
|
582
|
+
`,b.innerHTML=`
|
|
583
|
+
Next video in <strong>${this.state.countdown}</strong> seconds
|
|
584
|
+
<button class="tsvp-end-screen-cancel" style="
|
|
585
|
+
margin-left: 12px;
|
|
586
|
+
padding: 4px 12px;
|
|
587
|
+
border: 1px solid rgba(255,255,255,0.3);
|
|
588
|
+
border-radius: 4px;
|
|
589
|
+
background: transparent;
|
|
590
|
+
color: inherit;
|
|
591
|
+
cursor: pointer;
|
|
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=`
|
|
594
|
+
background: rgba(255, 255, 255, 0.1);
|
|
595
|
+
border-radius: 8px;
|
|
596
|
+
overflow: hidden;
|
|
597
|
+
cursor: pointer;
|
|
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=`
|
|
601
|
+
position: relative;
|
|
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=`
|
|
605
|
+
position: absolute;
|
|
606
|
+
bottom: 4px;
|
|
607
|
+
right: 4px;
|
|
608
|
+
padding: 2px 6px;
|
|
609
|
+
background: rgba(0, 0, 0, 0.8);
|
|
610
|
+
border-radius: 4px;
|
|
611
|
+
font-size: 12px;
|
|
612
|
+
font-weight: 500;
|
|
613
|
+
`,M.appendChild(_)}w.appendChild(M);let z=document.createElement("div");z.className="tsvp-end-screen-info",z.style.cssText=`
|
|
614
|
+
padding: 12px;
|
|
615
|
+
`;let $=document.createElement("h3");if($.className="tsvp-end-screen-card-title",$.textContent=h.title,$.style.cssText=`
|
|
616
|
+
margin: 0 0 4px;
|
|
617
|
+
font-size: 14px;
|
|
618
|
+
font-weight: 500;
|
|
619
|
+
overflow: hidden;
|
|
620
|
+
text-overflow: ellipsis;
|
|
621
|
+
display: -webkit-box;
|
|
622
|
+
-webkit-line-clamp: 2;
|
|
623
|
+
-webkit-box-orient: vertical;
|
|
624
|
+
`,z.appendChild($),h.channel){let _=document.createElement("p");_.className="tsvp-end-screen-channel",_.textContent=h.channel,_.style.cssText=`
|
|
625
|
+
margin: 0;
|
|
626
|
+
font-size: 12px;
|
|
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=`
|
|
629
|
+
margin: 4px 0 0;
|
|
630
|
+
font-size: 12px;
|
|
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=`
|
|
633
|
+
display: flex;
|
|
634
|
+
align-items: center;
|
|
635
|
+
gap: 8px;
|
|
636
|
+
padding: 10px 20px;
|
|
637
|
+
background: ${w};
|
|
638
|
+
border: 1px solid ${C};
|
|
639
|
+
border-radius: 6px;
|
|
640
|
+
color: #fff;
|
|
641
|
+
font-size: 14px;
|
|
642
|
+
font-weight: 500;
|
|
643
|
+
font-family: inherit;
|
|
644
|
+
cursor: pointer;
|
|
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=`
|
|
647
|
+
position: absolute;
|
|
648
|
+
${w}
|
|
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=`
|
|
655
|
+
display: block;
|
|
656
|
+
max-width: 100%;
|
|
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=`
|
|
660
|
+
font-family: var(--tsvp-font-family, sans-serif);
|
|
661
|
+
font-size: ${h.size||"14px"};
|
|
662
|
+
color: rgba(255, 255, 255, 0.8);
|
|
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=`
|
|
665
|
+
@keyframes tsvp-watermark-fade {
|
|
666
|
+
0%, 100% { opacity: 0.3; }
|
|
667
|
+
50% { opacity: 1; }
|
|
668
|
+
}
|
|
669
|
+
@keyframes tsvp-watermark-slide {
|
|
670
|
+
0% { transform: translateX(-10px); }
|
|
671
|
+
50% { transform: translateX(10px); }
|
|
672
|
+
100% { transform: translateX(-10px); }
|
|
673
|
+
}
|
|
674
|
+
@keyframes tsvp-watermark-bounce {
|
|
675
|
+
0%, 100% { transform: translateY(0); }
|
|
676
|
+
50% { transform: translateY(-10px); }
|
|
677
|
+
}
|
|
678
|
+
@keyframes tsvp-watermark-pulse {
|
|
679
|
+
0%, 100% { transform: scale(1); }
|
|
680
|
+
50% { transform: scale(1.1); }
|
|
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=`
|
|
683
|
+
<style>
|
|
684
|
+
:host {
|
|
685
|
+
display: flex;
|
|
686
|
+
flex-direction: column;
|
|
687
|
+
position: absolute;
|
|
688
|
+
inset: 0;
|
|
689
|
+
z-index: 1;
|
|
690
|
+
pointer-events: none;
|
|
691
|
+
color: white;
|
|
692
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
693
|
+
font-size: 14px;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/* Click-to-play overlay */
|
|
697
|
+
.overlay {
|
|
698
|
+
flex: 1;
|
|
699
|
+
display: flex;
|
|
700
|
+
align-items: center;
|
|
701
|
+
justify-content: center;
|
|
702
|
+
pointer-events: auto;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/* Bottom controls bar */
|
|
706
|
+
.controls {
|
|
707
|
+
display: flex;
|
|
708
|
+
align-items: center;
|
|
709
|
+
gap: 4px;
|
|
710
|
+
padding: 8px 12px;
|
|
711
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.7));
|
|
712
|
+
pointer-events: auto;
|
|
713
|
+
transition: opacity 0.3s, visibility 0.3s;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
:host([controls-hidden]) .controls {
|
|
717
|
+
opacity: 0;
|
|
718
|
+
visibility: hidden;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/* Spacer pushes right-aligned controls */
|
|
722
|
+
.spacer {
|
|
723
|
+
flex: 1;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/* Slots for left/center/right control groups */
|
|
727
|
+
::slotted(*) {
|
|
728
|
+
pointer-events: auto;
|
|
729
|
+
}
|
|
730
|
+
</style>
|
|
731
|
+
<div class="overlay" part="overlay">
|
|
732
|
+
<slot name="overlay"></slot>
|
|
733
|
+
</div>
|
|
734
|
+
<div class="controls" part="controls">
|
|
735
|
+
<slot name="left"></slot>
|
|
736
|
+
<slot name="center"></slot>
|
|
737
|
+
<div class="spacer"></div>
|
|
738
|
+
<slot name="right"></slot>
|
|
739
|
+
<slot></slot>
|
|
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=`
|
|
742
|
+
<style>
|
|
743
|
+
:host { display: inline-flex; }
|
|
744
|
+
button {
|
|
745
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
746
|
+
width: 40px; height: 40px; padding: 8px;
|
|
747
|
+
background: transparent; border: none; color: inherit; cursor: pointer;
|
|
748
|
+
}
|
|
749
|
+
button:hover { opacity: 0.8; }
|
|
750
|
+
</style>
|
|
751
|
+
<button part="button" type="button" aria-label="Play">
|
|
752
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
|
|
753
|
+
<path d="${L0}"/>
|
|
754
|
+
</svg>
|
|
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=`
|
|
757
|
+
<style>
|
|
758
|
+
:host { display: inline-flex; }
|
|
759
|
+
button {
|
|
760
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
761
|
+
width: 40px; height: 40px; padding: 8px;
|
|
762
|
+
background: transparent; border: none; color: inherit; cursor: pointer;
|
|
763
|
+
}
|
|
764
|
+
button:hover { opacity: 0.8; }
|
|
765
|
+
</style>
|
|
766
|
+
<button part="button" type="button" aria-label="Mute">
|
|
767
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
|
|
768
|
+
<path d="${V0}"/>
|
|
769
|
+
</svg>
|
|
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=`
|
|
772
|
+
<style>
|
|
773
|
+
:host { display: inline-flex; }
|
|
774
|
+
:host([hidden]) { display: none; }
|
|
775
|
+
button {
|
|
776
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
777
|
+
width: 40px; height: 40px; padding: 8px;
|
|
778
|
+
background: transparent; border: none; color: inherit; cursor: pointer;
|
|
779
|
+
}
|
|
780
|
+
button:hover { opacity: 0.8; }
|
|
781
|
+
button:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
782
|
+
</style>
|
|
783
|
+
<button part="button" type="button" aria-label="Enter fullscreen">
|
|
784
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
|
|
785
|
+
<path d="${F0}"/>
|
|
786
|
+
</svg>
|
|
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=`
|
|
789
|
+
<style>
|
|
790
|
+
:host { display: inline-flex; }
|
|
791
|
+
:host([hidden]) { display: none; }
|
|
792
|
+
button {
|
|
793
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
794
|
+
width: 40px; height: 40px; padding: 8px;
|
|
795
|
+
background: transparent; border: none; color: inherit; cursor: pointer;
|
|
796
|
+
}
|
|
797
|
+
button:hover { opacity: 0.8; }
|
|
798
|
+
button:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
799
|
+
</style>
|
|
800
|
+
<button part="button" type="button" aria-label="Picture in picture">
|
|
801
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
|
|
802
|
+
<path d="${V2}"/>
|
|
803
|
+
</svg>
|
|
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=`
|
|
806
|
+
<style>
|
|
807
|
+
:host {
|
|
808
|
+
display: inline-flex;
|
|
809
|
+
font-size: 14px;
|
|
810
|
+
font-variant-numeric: tabular-nums;
|
|
811
|
+
user-select: none;
|
|
812
|
+
cursor: pointer;
|
|
813
|
+
color: inherit;
|
|
814
|
+
}
|
|
815
|
+
time { color: inherit; }
|
|
816
|
+
.separator { margin: 0 2px; }
|
|
817
|
+
</style>
|
|
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=`
|
|
820
|
+
<style>
|
|
821
|
+
:host {
|
|
822
|
+
display: inline-flex;
|
|
823
|
+
align-items: center;
|
|
824
|
+
gap: 2px;
|
|
825
|
+
font-variant-numeric: tabular-nums;
|
|
826
|
+
font-family: inherit;
|
|
827
|
+
font-size: inherit;
|
|
828
|
+
color: inherit;
|
|
829
|
+
}
|
|
830
|
+
</style>
|
|
831
|
+
<slot></slot>
|
|
832
|
+
`}}}class Gh extends G{connectedCallback(){if(!this.shadowRoot){let h=this.attachShadow({mode:"open"});h.innerHTML=`
|
|
833
|
+
<style>
|
|
834
|
+
:host {
|
|
835
|
+
display: inline-flex;
|
|
836
|
+
align-items: center;
|
|
837
|
+
padding: 0 2px;
|
|
838
|
+
font-family: inherit;
|
|
839
|
+
font-size: inherit;
|
|
840
|
+
color: inherit;
|
|
841
|
+
opacity: 0.7;
|
|
842
|
+
}
|
|
843
|
+
</style>
|
|
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=`
|
|
846
|
+
<style>
|
|
847
|
+
:host {
|
|
848
|
+
display: inline-block;
|
|
849
|
+
font-variant-numeric: tabular-nums;
|
|
850
|
+
font-family: monospace;
|
|
851
|
+
font-size: 12px;
|
|
852
|
+
color: inherit;
|
|
853
|
+
pointer-events: none;
|
|
854
|
+
}
|
|
855
|
+
</style>
|
|
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=`
|
|
858
|
+
<style>
|
|
859
|
+
:host { display: flex; flex: 1; align-items: center; }
|
|
860
|
+
.container {
|
|
861
|
+
position: relative; width: 100%; height: 20px;
|
|
862
|
+
cursor: pointer; touch-action: none;
|
|
863
|
+
}
|
|
864
|
+
.track {
|
|
865
|
+
position: absolute; top: 50%; left: 0; right: 0;
|
|
866
|
+
height: 4px; background: rgba(255,255,255,0.3);
|
|
867
|
+
border-radius: 2px; transform: translateY(-50%);
|
|
868
|
+
}
|
|
869
|
+
:host([waveform]) .track { height: 20px; overflow: hidden; background: rgba(255,255,255,0.16); }
|
|
870
|
+
.waveform { position: absolute; inset: 0; background-position: center; background-repeat: no-repeat; background-size: 100% 100%; opacity: 0.65; }
|
|
871
|
+
.buffered {
|
|
872
|
+
position: absolute; top: 0; left: 0;
|
|
873
|
+
height: 100%; background: rgba(255,255,255,0.4);
|
|
874
|
+
border-radius: 2px; width: 0%;
|
|
875
|
+
}
|
|
876
|
+
.fill {
|
|
877
|
+
position: absolute; top: 0; left: 0;
|
|
878
|
+
height: 100%; background: #fff;
|
|
879
|
+
border-radius: 2px; width: 0%;
|
|
880
|
+
}
|
|
881
|
+
.thumb {
|
|
882
|
+
position: absolute; top: 50%; left: 0%;
|
|
883
|
+
width: 12px; height: 12px; background: #fff;
|
|
884
|
+
border-radius: 50%; transform: translate(-50%, -50%);
|
|
885
|
+
transition: transform 0.1s;
|
|
886
|
+
}
|
|
887
|
+
.container:hover .thumb { transform: translate(-50%, -50%) scale(1.2); }
|
|
888
|
+
.tooltip {
|
|
889
|
+
position: absolute; bottom: 100%; left: 0;
|
|
890
|
+
transform: translateX(-50%);
|
|
891
|
+
background: rgba(0,0,0,0.85); color: #fff;
|
|
892
|
+
padding: 4px 8px; border-radius: 3px;
|
|
893
|
+
font-size: 12px; font-family: monospace;
|
|
894
|
+
white-space: nowrap; pointer-events: none;
|
|
895
|
+
opacity: 0; transition: opacity 0.15s;
|
|
896
|
+
margin-bottom: 8px;
|
|
897
|
+
}
|
|
898
|
+
.tooltip::after {
|
|
899
|
+
content: ''; position: absolute;
|
|
900
|
+
top: 100%; left: 50%; transform: translateX(-50%);
|
|
901
|
+
border: 4px solid transparent;
|
|
902
|
+
border-top-color: rgba(0,0,0,0.85);
|
|
903
|
+
}
|
|
904
|
+
.container:hover .tooltip { opacity: 1; }
|
|
905
|
+
</style>
|
|
906
|
+
<div class="container" part="container" role="slider"
|
|
907
|
+
aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"
|
|
908
|
+
aria-label="Seek" tabindex="0">
|
|
909
|
+
<div class="tooltip" part="tooltip">0:00</div>
|
|
910
|
+
<div class="track" part="track">
|
|
911
|
+
<div class="waveform" part="waveform" aria-hidden="true"></div>
|
|
912
|
+
<div class="buffered" part="buffered"></div>
|
|
913
|
+
<div class="fill" part="fill"></div>
|
|
914
|
+
<div class="thumb" part="thumb"></div>
|
|
915
|
+
</div>
|
|
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=`
|
|
918
|
+
<style>
|
|
919
|
+
:host { display: inline-flex; align-items: center; width: 80px; }
|
|
920
|
+
:host([hidden]) { display: none; }
|
|
921
|
+
.container {
|
|
922
|
+
position: relative; width: 100%; height: 20px;
|
|
923
|
+
cursor: pointer; touch-action: none;
|
|
924
|
+
}
|
|
925
|
+
.track {
|
|
926
|
+
position: absolute; top: 50%; left: 0; right: 0;
|
|
927
|
+
height: 4px; background: rgba(255,255,255,0.3);
|
|
928
|
+
border-radius: 2px; transform: translateY(-50%);
|
|
929
|
+
}
|
|
930
|
+
.fill {
|
|
931
|
+
position: absolute; top: 0; left: 0;
|
|
932
|
+
height: 100%; background: #fff;
|
|
933
|
+
border-radius: 2px; width: 100%;
|
|
934
|
+
}
|
|
935
|
+
.thumb {
|
|
936
|
+
position: absolute; top: 50%; left: 100%;
|
|
937
|
+
width: 12px; height: 12px; background: #fff;
|
|
938
|
+
border-radius: 50%; transform: translate(-50%, -50%);
|
|
939
|
+
transition: transform 0.1s;
|
|
940
|
+
}
|
|
941
|
+
.container:hover .thumb { transform: translate(-50%, -50%) scale(1.2); }
|
|
942
|
+
</style>
|
|
943
|
+
<div class="container" part="container" role="slider"
|
|
944
|
+
aria-valuemin="0" aria-valuemax="100" aria-valuenow="100"
|
|
945
|
+
aria-label="Volume" tabindex="0">
|
|
946
|
+
<div class="track" part="track">
|
|
947
|
+
<div class="fill" part="fill"></div>
|
|
948
|
+
<div class="thumb" part="thumb"></div>
|
|
949
|
+
</div>
|
|
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=`
|
|
952
|
+
<style>
|
|
953
|
+
:host { display: inline-flex; position: relative; }
|
|
954
|
+
button.trigger {
|
|
955
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
956
|
+
width: 40px; height: 40px; padding: 8px;
|
|
957
|
+
background: transparent; border: none; color: inherit; cursor: pointer;
|
|
958
|
+
}
|
|
959
|
+
button.trigger:hover { opacity: 0.8; }
|
|
960
|
+
.menu {
|
|
961
|
+
position: fixed; z-index: 9999;
|
|
962
|
+
min-width: 160px; max-height: 250px; overflow-y: auto;
|
|
963
|
+
background: rgba(28,28,28,0.95); border-radius: 4px;
|
|
964
|
+
padding: 4px 0; opacity: 0; visibility: hidden;
|
|
965
|
+
transform: translateY(4px);
|
|
966
|
+
transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
|
|
967
|
+
}
|
|
968
|
+
:host([open]) .menu {
|
|
969
|
+
opacity: 1; visibility: visible; transform: translateY(0);
|
|
970
|
+
}
|
|
971
|
+
.item {
|
|
972
|
+
display: flex; align-items: center; gap: 8px;
|
|
973
|
+
width: 100%; padding: 8px 16px;
|
|
974
|
+
background: none; border: none; color: white;
|
|
975
|
+
text-align: left; cursor: pointer; font-size: 14px;
|
|
976
|
+
}
|
|
977
|
+
.item:hover { background: rgba(255,255,255,0.1); }
|
|
978
|
+
.item[aria-checked="true"]::before { content: '\\2713'; }
|
|
979
|
+
.item[aria-checked="false"]::before { content: ''; min-width: 12px; display: inline-block; }
|
|
980
|
+
.back { font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.2); }
|
|
981
|
+
</style>
|
|
982
|
+
<button class="trigger" part="trigger" type="button"
|
|
983
|
+
aria-label="Settings" aria-haspopup="true" aria-expanded="false">
|
|
984
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" part="icon">
|
|
985
|
+
<path d="${F2}"/>
|
|
986
|
+
</svg>
|
|
987
|
+
</button>
|
|
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=`
|
|
990
|
+
<style>
|
|
991
|
+
:host { display: inline-flex; }
|
|
992
|
+
button { min-width: 40px; height: 40px; padding: 0 8px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; }
|
|
993
|
+
button:hover { opacity: .8; }
|
|
994
|
+
button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
|
|
995
|
+
button:disabled { cursor: default; opacity: .45; }
|
|
996
|
+
</style>
|
|
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=`
|
|
999
|
+
<style>
|
|
1000
|
+
:host { display: inline-flex; }
|
|
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; }
|
|
1002
|
+
button:hover { opacity: .8; }
|
|
1003
|
+
button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
|
|
1004
|
+
</style>
|
|
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=`
|
|
1007
|
+
<style>
|
|
1008
|
+
:host { display: none; }
|
|
1009
|
+
:host([available]) { display: inline-flex; }
|
|
1010
|
+
button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 8px; background: transparent; border: 0; color: inherit; cursor: pointer; }
|
|
1011
|
+
button:hover { opacity: 0.8; }
|
|
1012
|
+
:host([connected]) button { color: var(--media-airplay-active-color, #38bdf8); }
|
|
1013
|
+
</style>
|
|
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>
|
|
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=`
|
|
1018
|
+
<style>
|
|
1019
|
+
:host { display: none; }
|
|
1020
|
+
:host([available]) { display: inline-flex; }
|
|
1021
|
+
button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px; background: transparent; border: 0; color: inherit; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
|
|
1022
|
+
i { width: 8px; height: 8px; border-radius: 9999px; background: #ef4444; }
|
|
1023
|
+
:host(:not([at-live-edge])) button { opacity: 0.72; }
|
|
1024
|
+
</style>
|
|
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=`
|
|
1027
|
+
<style>
|
|
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
|
+
:host([open]) { display: grid; }
|
|
1030
|
+
p { max-width: 42rem; margin: 0; font: 500 14px/1.5 system-ui, sans-serif; }
|
|
1031
|
+
</style>
|
|
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=`
|
|
1034
|
+
<style>
|
|
1035
|
+
:host { display: none; }
|
|
1036
|
+
:host([available]) { display: inline-flex; }
|
|
1037
|
+
button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 8px; background: transparent; border: 0; color: inherit; cursor: pointer; }
|
|
1038
|
+
button:hover { opacity: 0.8; }
|
|
1039
|
+
:host([connected]) button { color: var(--media-remote-active-color, #38bdf8); }
|
|
1040
|
+
</style>
|
|
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>
|
|
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}};
|
|
1045
|
+
|
|
1046
|
+
//# debugId=918E637EBFE6D21164756E2164756E21
|