@mux/mux-video 0.15.2 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,27 +1,39 @@
1
- "use strict";var de=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var st=(r,t,e)=>t in r?de(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var it=(r,t)=>{for(var e in t)de(r,e,{get:t[e],enumerable:!0})},rt=(r,t,e,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!tt.call(r,o)&&o!==e&&de(r,o,{get:()=>t[o],enumerable:!(c=Qe(t,o))||c.enumerable});return r};var at=r=>rt(de({},"__esModule",{value:!0}),r);var q=(r,t,e)=>(st(r,typeof t!="symbol"?t+"":t,e),e),ge=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)};var i=(r,t,e)=>(ge(r,t,"read from private field"),e?e.call(r):t.get(r)),u=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},d=(r,t,e,c)=>(ge(r,t,"write to private field"),c?c.call(r,e):t.set(r,e),e);var m=(r,t,e)=>(ge(r,t,"access private method"),e);var pt={};it(pt,{Attributes:()=>n,MediaError:()=>l.MediaError,VideoEvents:()=>Le,default:()=>ft});module.exports=at(pt);var G=class{addEventListener(){}removeEventListener(){}dispatchEvent(t){return!0}};if(typeof DocumentFragment=="undefined"){class r extends G{}globalThis.DocumentFragment=r}var $=class extends G{},be=class extends G{},nt={get(r){},define(r,t,e){},upgrade(r){},whenDefined(r){return Promise.resolve($)}},X,Te=class{constructor(t,e={}){u(this,X,void 0);d(this,X,e==null?void 0:e.detail)}get detail(){return i(this,X)}initCustomEvent(){}};X=new WeakMap;function ot(r,t){return new $}var Ye={document:{createElement:ot},DocumentFragment,customElements:nt,CustomEvent:Te,EventTarget:G,HTMLElement:$,HTMLVideoElement:be},Be=typeof window=="undefined"||typeof globalThis.customElements=="undefined",C=Be?Ye:globalThis,Ae=Be?Ye.document:globalThis.document;var l=require("@mux/playback-core");var ct=()=>{try{return"0.15.2"}catch{}return"UNKNOWN"},ut=ct(),We=()=>ut;var Ve=r=>{var t,e,c,o,E,Ke,p,he,v,O,x,me,F,Ee,ae,He,ne,je,W,ve,V,T,L,k,_,M,D,z,oe,qe,K,Pe,ce,$e,H,Se,ue,Xe,j,Ce;return t=class extends r{constructor(){super();u(this,D);u(this,oe);u(this,K);u(this,ce);u(this,H);u(this,ue);u(this,j);q(this,"castEnabled",!1);u(this,V,{paused:!1});u(this,T,void 0);u(this,L,{});u(this,k,void 0);u(this,_,void 0);u(this,M,void 0);t.instances.add(this),m(this,H,Se).call(this)}static get castElement(){return i(t,e)}static get castEnabled(){return i(t,c)}static get castState(){var s;return(s=i(t,v,O))==null?void 0:s.getCastState()}static async exitCast(){try{await i(t,v,O).endCurrentSession(!0)}catch(a){console.error(a);return}}get castPlayer(){if(t.castElement===this)return i(this,T)}attributeChangedCallback(s){if(!!this.castPlayer)switch(s){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(s={}){var a;m(a=t,W,ve).call(a,s),d(t,e,this),Object.entries(i(this,L)).forEach(([h,y])=>{i(this,T).controller.addEventListener(h,y)});try{await i(t,v,O).requestSession()}catch{d(t,e,void 0);return}i(this,V).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(h){console.error(h)}}async load(){var S,w;if(!this.castPlayer)return super.load();let s=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),a=[...this.querySelectorAll("track")].filter(({kind:P,src:A})=>A&&(P==="subtitles"||P==="captions")),h=[],y=0;a.length&&(s.tracks=a.map(P=>{let A=++y;h.length===0&&P.track.mode==="showing"&&h.push(A);let N=new chrome.cast.media.Track(A,chrome.cast.media.TrackType.TEXT);return N.trackContentId=P.src,N.trackContentType="text/vtt",N.subtype=P.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,N.name=P.label,N.language=P.srclang,N})),this.castStreamType==="live"?s.streamType=chrome.cast.media.StreamType.LIVE:s.streamType=chrome.cast.media.StreamType.BUFFERED,s.metadata=new chrome.cast.media.GenericMediaMetadata,s.metadata.title=this.title,s.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(s);g.currentTime=(S=super.currentTime)!=null?S:0,g.autoplay=!i(this,V).paused,g.activeTrackIds=h,await((w=i(t,x,me))==null?void 0:w.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var s;if(this.castPlayer){this.castPlayer.isPaused&&((s=this.castPlayer.controller)==null||s.playOrPause());return}return super.play()}pause(){var s;if(this.castPlayer){this.castPlayer.isPaused||(s=this.castPlayer.controller)==null||s.playOrPause();return}super.pause()}get castSrc(){var s,a,h;return(h=(a=this.getAttribute("cast-src"))!=null?a:(s=this.querySelector("source"))==null?void 0:s.src)!=null?h:this.currentSrc}set castSrc(s){this.castSrc!=s&&this.setAttribute("cast-src",`${s}`)}get castContentType(){var s;return(s=this.getAttribute("cast-content-type"))!=null?s:void 0}set castContentType(s){this.setAttribute("cast-content-type",`${s}`)}get castStreamType(){var s,a;return(a=(s=this.getAttribute("cast-stream-type"))!=null?s:this.streamType)!=null?a:void 0}set castStreamType(s){this.setAttribute("cast-stream-type",`${s}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var s;return this.castPlayer?(s=this.castPlayer)==null?void 0:s.isMuted:super.muted}set muted(s){var a;if(this.castPlayer){(s&&!this.castPlayer.isMuted||!s&&this.castPlayer.isMuted)&&((a=this.castPlayer.controller)==null||a.muteOrUnmute());return}super.muted=s}get volume(){var s,a;return this.castPlayer?(a=(s=this.castPlayer)==null?void 0:s.volumeLevel)!=null?a:1:super.volume}set volume(s){var a;if(this.castPlayer){this.castPlayer.volumeLevel=s,(a=this.castPlayer.controller)==null||a.setVolumeLevel();return}super.volume=s}get duration(){var s,a;return this.castPlayer&&i(this,D,z)?(a=(s=this.castPlayer)==null?void 0:s.duration)!=null?a:NaN:super.duration}get currentTime(){var s,a;return this.castPlayer&&i(this,D,z)?(a=(s=this.castPlayer)==null?void 0:s.currentTime)!=null?a:0:super.currentTime}set currentTime(s){var a;if(this.castPlayer){this.castPlayer.currentTime=s,(a=this.castPlayer.controller)==null||a.seek();return}super.currentTime=s}get onentercast(){return i(this,k)}set onentercast(s){i(this,k)&&(this.removeEventListener("entercast",i(this,k)),d(this,k,null)),typeof s=="function"&&(d(this,k,s),this.addEventListener("entercast",s))}get onleavecast(){return i(this,_)}set onleavecast(s){i(this,_)&&(this.removeEventListener("leavecast",i(this,_)),d(this,_,null)),typeof s=="function"&&(d(this,_,s),this.addEventListener("leavecast",s))}get oncastchange(){return i(this,M)}set oncastchange(s){i(this,M)&&(this.removeEventListener("castchange",i(this,M)),d(this,M,null)),typeof s=="function"&&(d(this,M,s),this.addEventListener("castchange",s))}},e=new WeakMap,c=new WeakMap,o=new WeakMap,E=new WeakSet,Ke=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},p=new WeakSet,he=function(){return typeof cast!="undefined"&&cast.framework},v=new WeakSet,O=function(){if(i(t,p,he))return cast.framework.CastContext.getInstance()},x=new WeakSet,me=function(){var s;return(s=i(t,v,O))==null?void 0:s.getCurrentSession()},F=new WeakSet,Ee=function(){var s;return(s=i(t,x,me))==null?void 0:s.getSessionObj().media[0]},ae=new WeakSet,He=function(s){return new Promise((a,h)=>{i(t,F,Ee).editTracksInfo(s,a,h)})},ne=new WeakSet,je=function(s){return new Promise((a,h)=>{i(t,F,Ee).getStatus(s,a,h)})},W=new WeakSet,ve=function(s){return i(t,v,O).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...s})},V=new WeakMap,T=new WeakMap,L=new WeakMap,k=new WeakMap,_=new WeakMap,M=new WeakMap,D=new WeakSet,z=function(){var s;return(s=this.castPlayer)==null?void 0:s.isMediaLoaded},oe=new WeakSet,qe=function(){i(t,e)===this&&(Object.entries(i(this,L)).forEach(([s,a])=>{i(this,T).controller.removeEventListener(s,a)}),d(t,e,void 0),this.muted=i(this,T).isMuted,this.currentTime=i(this,T).savedPlayerState.currentTime,i(this,T).savedPlayerState.isPaused===!1&&this.play())},K=new WeakSet,Pe=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:i(t,v,O).getCastState()}))},ce=new WeakSet,$e=async function(){var a,h;let{SESSION_RESUMED:s}=cast.framework.SessionState;if(i(t,v,O).getSessionState()===s&&this.castSrc===((a=i(t,F,Ee))==null?void 0:a.media.contentId)){d(t,e,this),Object.entries(i(this,L)).forEach(([y,g])=>{i(this,T).controller.addEventListener(y,g)});try{await m(h=t,ne,je).call(h,new chrome.cast.media.GetStatusRequest)}catch(y){console.error(y)}i(this,L)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),i(this,L)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},H=new WeakSet,Se=function(){var s;!i(t,p,he)||this.castEnabled||(this.castEnabled=!0,m(s=t,W,ve).call(s),this.textTracks.addEventListener("change",m(this,j,Ce).bind(this)),m(this,K,Pe).call(this),d(this,T,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(i(this,T)),d(this,L,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:a})=>{a===!1&&m(this,oe,qe).call(this),this.dispatchEvent(new Event(a?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!i(this,D,z)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var a,h;((a=this.castPlayer)==null?void 0:a.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(h=this.castPlayer)==null?void 0:h.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!i(this,D,z)||(await Promise.resolve(),m(this,ue,Xe).call(this))}}))},ue=new WeakSet,Xe=function(){m(this,j,Ce).call(this)},j=new WeakSet,Ce=async function(){var Me,Re,De,we,Ne,xe;if(!this.castPlayer)return;let a=((Re=(Me=i(this,T).mediaInfo)==null?void 0:Me.tracks)!=null?Re:[]).filter(({type:f})=>f===chrome.cast.media.TrackType.TEXT),h=[...this.textTracks].filter(({kind:f})=>f==="subtitles"||f==="captions"),y=a.map(({language:f,name:le,trackId:ye})=>{var Ge;let{mode:Fe}=(Ge=h.find(Ue=>Ue.language===f&&Ue.label===le))!=null?Ge:{};return Fe?{mode:Fe,trackId:ye}:!1}).filter(Boolean),S=y.filter(({mode:f})=>f!=="showing").map(({trackId:f})=>f),w=y.find(({mode:f})=>f==="showing"),P=(Ne=(we=(De=i(t,x,me))==null?void 0:De.getSessionObj().media[0])==null?void 0:we.activeTrackIds)!=null?Ne:[],A=P;if(P.length&&(A=A.filter(f=>!S.includes(f))),w!=null&&w.trackId&&(A=[...A,w.trackId]),A=[...new Set(A)],!((f,le)=>f.length===le.length&&f.every(ye=>le.includes(ye)))(P,A))try{let f=new chrome.cast.media.EditTracksInfoRequest(A);await m(xe=t,ae,He).call(xe,f)}catch(f){console.error(f)}},u(t,E),u(t,p),u(t,v),u(t,x),u(t,F),u(t,ae),u(t,ne),u(t,W),q(t,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),q(t,"instances",new Set),u(t,e,void 0),u(t,c,!1),q(t,"initCast",()=>{var s;i(t,E,Ke)?i(t,p,he)?i(s=t,o).call(s,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var a;return i(a=t,o).call(a,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var a;return i(a=t,o).call(a,chrome.cast.isAvailable)})}}),u(t,o,s=>{if(s){d(t,c,!0);let{CAST_STATE_CHANGED:a}=cast.framework.CastContextEventType;i(t,v,O).addEventListener(a,y=>{t.instances.forEach(g=>{var S;return m(S=g,K,Pe).call(S,y)})});let{SESSION_STATE_CHANGED:h}=cast.framework.CastContextEventType;i(t,v,O).addEventListener(h,y=>{t.instances.forEach(g=>{var S;return m(S=g,ce,$e).call(S,y)})}),t.instances.forEach(y=>{var g;return m(g=y,H,Se).call(g)})}}),t},Oe=globalThis.HTMLVideoElement?Ve(HTMLVideoElement):Ve(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Oe,{extends:"video"}),globalThis.CastableVideoElement=Oe);Oe.initCast();var Le=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],ze=Ae.createElement("template");ze.innerHTML=`
2
- <style>
3
- :host {
4
- display: inline-block;
5
- line-height: 0;
6
- width: auto;
7
- height: auto;
8
- }
1
+ "use strict";var ft=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var oe=(n,e,t)=>e in n?ft(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ce=(n,e)=>{for(var t in e)ft(n,t,{get:e[t],enumerable:!0})},ue=(n,e,t,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of ae(e))!ne.call(n,c)&&c!==t&&ft(n,c,{get:()=>e[c],enumerable:!(u=re(e,c))||u.enumerable});return n};var le=n=>ue(ft({},"__esModule",{value:!0}),n);var G=(n,e,t)=>(oe(n,typeof e!="symbol"?e+"":e,t),t),vt=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var i=(n,e,t)=>(vt(n,e,"read from private field"),t?t.call(n):e.get(n)),o=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},f=(n,e,t,u)=>(vt(n,e,"write to private field"),u?u.call(n,t):e.set(n,t),t);var p=(n,e,t)=>(vt(n,e,"access private method"),t);var Ae={};ce(Ae,{Attributes:()=>a,MediaError:()=>d.MediaError,VideoEvents:()=>bt,default:()=>be});module.exports=le(Ae);var V=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class n extends V{}globalThis.DocumentFragment=n}var J=class extends V{},St=class extends V{},de={get(n){},define(n,e,t){},upgrade(n){},whenDefined(n){return Promise.resolve(J)}},Q,Pt=class{constructor(e,t={}){o(this,Q,void 0);f(this,Q,t==null?void 0:t.detail)}get detail(){return i(this,Q)}initCustomEvent(){}};Q=new WeakMap;function he(n,e){return new J}var Vt={document:{createElement:he},DocumentFragment,customElements:de,CustomEvent:Pt,EventTarget:V,HTMLElement:J,HTMLVideoElement:St},Kt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Z=Kt?Vt:globalThis,Se=Kt?Vt.document:globalThis.document;var d=require("@mux/playback-core");var me=()=>{try{return"0.15.3"}catch{}return"UNKNOWN"},Ee=me(),Ht=()=>Ee;var jt=n=>{var e,t,u,c,I,qt,P,pt,v,w,R,yt,Y,gt,ct,$t,lt,Xt,B,Ct,l,y,b,m,E,T,k,tt,dt,zt,$,Ot,ht,Jt,X,Mt,mt,Qt,z,It;return e=class extends n{constructor(){super();o(this,k);o(this,dt);o(this,$);o(this,ht);o(this,X);o(this,mt);o(this,z);G(this,"castEnabled",!1);o(this,l,{paused:!1});o(this,y,void 0);o(this,b,{});o(this,m,void 0);o(this,E,void 0);o(this,T,void 0);e.instances.add(this),p(this,X,Mt).call(this)}static get castElement(){return i(e,t)}static get castEnabled(){return i(e,u)}static get castState(){var s;return(s=i(e,v,w))==null?void 0:s.getCastState()}static async exitCast(){try{await i(e,v,w).endCurrentSession(!0)}catch(r){console.error(r);return}}get castPlayer(){if(e.castElement===this)return i(this,y)}attributeChangedCallback(s){if(!!this.castPlayer)switch(s){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(s={}){var r;p(r=e,B,Ct).call(r,s),f(e,t,this),Object.entries(i(this,b)).forEach(([g,S])=>{i(this,y).controller.addEventListener(g,S)});try{await i(e,v,w).requestSession()}catch{f(e,t,void 0);return}i(this,l).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(g){console.error(g)}}async load(){var D,F;if(!this.castPlayer)return super.load();let s=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),r=[...this.querySelectorAll("track")].filter(({kind:_,src:L})=>L&&(_==="subtitles"||_==="captions")),g=[],S=0;r.length&&(s.tracks=r.map(_=>{let L=++S;g.length===0&&_.track.mode==="showing"&&g.push(L);let U=new chrome.cast.media.Track(L,chrome.cast.media.TrackType.TEXT);return U.trackContentId=_.src,U.trackContentType="text/vtt",U.subtype=_.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,U.name=_.label,U.language=_.srclang,U})),this.castStreamType==="live"?s.streamType=chrome.cast.media.StreamType.LIVE:s.streamType=chrome.cast.media.StreamType.BUFFERED,s.metadata=new chrome.cast.media.GenericMediaMetadata,s.metadata.title=this.title,s.metadata.images=[{url:this.poster}];let M=new chrome.cast.media.LoadRequest(s);M.currentTime=(D=super.currentTime)!=null?D:0,M.autoplay=!i(this,l).paused,M.activeTrackIds=g,await((F=i(e,R,yt))==null?void 0:F.loadMedia(M)),this.dispatchEvent(new Event("volumechange"))}play(){var s;if(this.castPlayer){this.castPlayer.isPaused&&((s=this.castPlayer.controller)==null||s.playOrPause());return}return super.play()}pause(){var s;if(this.castPlayer){this.castPlayer.isPaused||(s=this.castPlayer.controller)==null||s.playOrPause();return}super.pause()}get castSrc(){var s,r,g;return(g=(r=this.getAttribute("cast-src"))!=null?r:(s=this.querySelector("source"))==null?void 0:s.src)!=null?g:this.currentSrc}set castSrc(s){this.castSrc!=s&&this.setAttribute("cast-src",`${s}`)}get castContentType(){var s;return(s=this.getAttribute("cast-content-type"))!=null?s:void 0}set castContentType(s){this.setAttribute("cast-content-type",`${s}`)}get castStreamType(){var s,r;return(r=(s=this.getAttribute("cast-stream-type"))!=null?s:this.streamType)!=null?r:void 0}set castStreamType(s){this.setAttribute("cast-stream-type",`${s}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var s;return this.castPlayer?(s=this.castPlayer)==null?void 0:s.isMuted:super.muted}set muted(s){var r;if(this.castPlayer){(s&&!this.castPlayer.isMuted||!s&&this.castPlayer.isMuted)&&((r=this.castPlayer.controller)==null||r.muteOrUnmute());return}super.muted=s}get volume(){var s,r;return this.castPlayer?(r=(s=this.castPlayer)==null?void 0:s.volumeLevel)!=null?r:1:super.volume}set volume(s){var r;if(this.castPlayer){this.castPlayer.volumeLevel=s,(r=this.castPlayer.controller)==null||r.setVolumeLevel();return}super.volume=s}get duration(){var s,r;return this.castPlayer&&i(this,k,tt)?(r=(s=this.castPlayer)==null?void 0:s.duration)!=null?r:NaN:super.duration}get currentTime(){var s,r;return this.castPlayer&&i(this,k,tt)?(r=(s=this.castPlayer)==null?void 0:s.currentTime)!=null?r:0:super.currentTime}set currentTime(s){var r;if(this.castPlayer){this.castPlayer.currentTime=s,(r=this.castPlayer.controller)==null||r.seek();return}super.currentTime=s}get onentercast(){return i(this,m)}set onentercast(s){i(this,m)&&(this.removeEventListener("entercast",i(this,m)),f(this,m,null)),typeof s=="function"&&(f(this,m,s),this.addEventListener("entercast",s))}get onleavecast(){return i(this,E)}set onleavecast(s){i(this,E)&&(this.removeEventListener("leavecast",i(this,E)),f(this,E,null)),typeof s=="function"&&(f(this,E,s),this.addEventListener("leavecast",s))}get oncastchange(){return i(this,T)}set oncastchange(s){i(this,T)&&(this.removeEventListener("castchange",i(this,T)),f(this,T,null)),typeof s=="function"&&(f(this,T,s),this.addEventListener("castchange",s))}},t=new WeakMap,u=new WeakMap,c=new WeakMap,I=new WeakSet,qt=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},P=new WeakSet,pt=function(){return typeof cast!="undefined"&&cast.framework},v=new WeakSet,w=function(){if(i(e,P,pt))return cast.framework.CastContext.getInstance()},R=new WeakSet,yt=function(){var s;return(s=i(e,v,w))==null?void 0:s.getCurrentSession()},Y=new WeakSet,gt=function(){var s;return(s=i(e,R,yt))==null?void 0:s.getSessionObj().media[0]},ct=new WeakSet,$t=function(s){return new Promise((r,g)=>{i(e,Y,gt).editTracksInfo(s,r,g)})},lt=new WeakSet,Xt=function(s){return new Promise((r,g)=>{i(e,Y,gt).getStatus(s,r,g)})},B=new WeakSet,Ct=function(s){return i(e,v,w).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...s})},l=new WeakMap,y=new WeakMap,b=new WeakMap,m=new WeakMap,E=new WeakMap,T=new WeakMap,k=new WeakSet,tt=function(){var s;return(s=this.castPlayer)==null?void 0:s.isMediaLoaded},dt=new WeakSet,zt=function(){i(e,t)===this&&(Object.entries(i(this,b)).forEach(([s,r])=>{i(this,y).controller.removeEventListener(s,r)}),f(e,t,void 0),this.muted=i(this,y).isMuted,this.currentTime=i(this,y).savedPlayerState.currentTime,i(this,y).savedPlayerState.isPaused===!1&&this.play())},$=new WeakSet,Ot=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:i(e,v,w).getCastState()}))},ht=new WeakSet,Jt=async function(){var r,g;let{SESSION_RESUMED:s}=cast.framework.SessionState;if(i(e,v,w).getSessionState()===s&&this.castSrc===((r=i(e,Y,gt))==null?void 0:r.media.contentId)){f(e,t,this),Object.entries(i(this,b)).forEach(([S,M])=>{i(this,y).controller.addEventListener(S,M)});try{await p(g=e,lt,Xt).call(g,new chrome.cast.media.GetStatusRequest)}catch(S){console.error(S)}i(this,b)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),i(this,b)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},X=new WeakSet,Mt=function(){var s;!i(e,P,pt)||this.castEnabled||(this.castEnabled=!0,p(s=e,B,Ct).call(s),this.textTracks.addEventListener("change",p(this,z,It).bind(this)),p(this,$,Ot).call(this),f(this,y,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(i(this,y)),f(this,b,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:r})=>{r===!1&&p(this,dt,zt).call(this),this.dispatchEvent(new Event(r?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!i(this,k,tt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var r,g;((r=this.castPlayer)==null?void 0:r.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(g=this.castPlayer)==null?void 0:g.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!i(this,k,tt)||(await Promise.resolve(),p(this,mt,Qt).call(this))}}))},mt=new WeakSet,Qt=function(){p(this,z,It).call(this)},z=new WeakSet,It=async function(){var wt,Nt,xt,Gt,Ft,Ut;if(!this.castPlayer)return;let r=((Nt=(wt=i(this,y).mediaInfo)==null?void 0:wt.tracks)!=null?Nt:[]).filter(({type:A})=>A===chrome.cast.media.TrackType.TEXT),g=[...this.textTracks].filter(({kind:A})=>A==="subtitles"||A==="captions"),S=r.map(({language:A,name:Et,trackId:Tt})=>{var Bt;let{mode:Yt}=(Bt=g.find(Wt=>Wt.language===A&&Wt.label===Et))!=null?Bt:{};return Yt?{mode:Yt,trackId:Tt}:!1}).filter(Boolean),D=S.filter(({mode:A})=>A!=="showing").map(({trackId:A})=>A),F=S.find(({mode:A})=>A==="showing"),_=(Ft=(Gt=(xt=i(e,R,yt))==null?void 0:xt.getSessionObj().media[0])==null?void 0:Gt.activeTrackIds)!=null?Ft:[],L=_;if(_.length&&(L=L.filter(A=>!D.includes(A))),F!=null&&F.trackId&&(L=[...L,F.trackId]),L=[...new Set(L)],!((A,Et)=>A.length===Et.length&&A.every(Tt=>Et.includes(Tt)))(_,L))try{let A=new chrome.cast.media.EditTracksInfoRequest(L);await p(Ut=e,ct,$t).call(Ut,A)}catch(A){console.error(A)}},o(e,I),o(e,P),o(e,v),o(e,R),o(e,Y),o(e,ct),o(e,lt),o(e,B),G(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),G(e,"instances",new Set),o(e,t,void 0),o(e,u,!1),G(e,"initCast",()=>{var s;i(e,I,qt)?i(e,P,pt)?i(s=e,c).call(s,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=e,c).call(r,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=e,c).call(r,chrome.cast.isAvailable)})}}),o(e,c,s=>{if(s){f(e,u,!0);let{CAST_STATE_CHANGED:r}=cast.framework.CastContextEventType;i(e,v,w).addEventListener(r,S=>{e.instances.forEach(M=>{var D;return p(D=M,$,Ot).call(D,S)})});let{SESSION_STATE_CHANGED:g}=cast.framework.CastContextEventType;i(e,v,w).addEventListener(g,S=>{e.instances.forEach(M=>{var D;return p(D=M,ht,Jt).call(D,S)})}),e.instances.forEach(S=>{var M;return p(M=S,X,Mt).call(M)})}}),e},kt=globalThis.HTMLVideoElement?jt(HTMLVideoElement):jt(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",kt,{extends:"video"}),globalThis.CastableVideoElement=kt);kt.initCast();var bt=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Zt,Lt=(Zt=globalThis.document)==null?void 0:Zt.createElement("template");Lt&&(Lt.innerHTML=`
2
+ <style>
3
+ :host {
4
+ display: inline-block;
5
+ line-height: 0;
6
+ }
9
7
 
10
- video {
11
- max-width: 100%;
12
- max-height: 100%;
13
- min-width: 100%;
14
- min-height: 100%;
15
- object-fit: var(--media-object-fit, contain);
16
- object-position: var(--media-object-position, 50% 50%);
17
- }
8
+ audio {
9
+ max-width: 100%;
10
+ max-height: 100%;
11
+ min-width: 100%;
12
+ min-height: 100%;
13
+ }
14
+ </style>
15
+ <slot></slot>
16
+ `);var te,Rt=(te=globalThis.document)==null?void 0:te.createElement("template");Rt&&(Rt.innerHTML=`
17
+ <style>
18
+ :host {
19
+ display: inline-block;
20
+ line-height: 0;
21
+ }
18
22
 
19
- video::-webkit-media-text-track-container {
20
- transform: var(--media-webkit-text-track-transform);
21
- transition: var(--media-webkit-text-track-transition);
22
- }
23
- </style>
24
- <video is="castable-video" part="video" crossorigin></video>
25
- <slot></slot>
26
- `;var J,U,fe,Z,Ie,R=class extends C.HTMLElement{constructor(){super();u(this,U);u(this,Z);u(this,J,void 0);this.attachShadow({mode:"open"}),this.isConnected&&m(this,U,fe).call(this)}static get observedAttributes(){let e=[],c=E=>E.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(E=>{let b=!1;try{typeof this.prototype[E]=="function"&&(b=!0)}catch{}!b&&E!==E.toUpperCase()&&e.push(E.toLowerCase(),c(E))});let o=Object.getPrototypeOf(this).observedAttributes;return o&&(e=e.concat(o)),e}attributeChangedCallback(e,c,o){m(this,U,fe).call(this),m(this,Z,Ie).call(this,e,c,o)}connectedCallback(){m(this,U,fe).call(this)}};J=new WeakMap,U=new WeakSet,fe=function(){if(i(this,J))return;d(this,J,!0),this.shadowRoot.append(ze.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),Le.forEach(c=>{this.nativeEl.addEventListener(c,o=>{this.dispatchEvent(new CustomEvent(o.type,{detail:o.detail}))})});let e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",()=>{e.assignedElements().forEach(c=>{!["track","source"].includes(c.localName)||this.nativeEl.append(c)})}),Array.prototype.forEach.call(this.attributes,c=>{m(this,Z,Ie).call(this,c.name,null,c.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Z=new WeakSet,Ie=function(e,c,o){let E=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),b=dt(E,e),p=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;b&&!p?typeof this[b]=="boolean"?o===null?this[b]=!1:this[b]=!0:this[b]=o:o===null?this.nativeEl.removeAttribute(e):["id","class"].indexOf(e)===-1&&this.nativeEl.setAttribute(e,o)};var Je=[],Ze=Ae.createElement("video",{is:"castable-video"}),lt=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let r=Object.getPrototypeOf(Ze);r&&r!==C.HTMLElement.prototype;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(t=>{lt.indexOf(t)===-1&&Je.push(t)});Je.forEach(r=>{if(r in R.prototype)return;if(typeof Ze[r]=="function")R.prototype[r]=function(){return this.nativeEl[r].apply(this.nativeEl,arguments)};else{let e={get(){return this.nativeEl[r]}};r!==r.toUpperCase()&&(e.set=function(c){this.nativeEl[r]=c}),Object.defineProperty(R.prototype,r,e)}});function dt(r,t){let e=null;return r.forEach(c=>{c.toLowerCase()==t.toLowerCase()&&(e=c)}),e}C.customElements.get("custom-video")||(C.customElements.define("custom-video",R),C.CustomVideoElement=R);var ke=R;var n={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},ht=Object.values(n),mt=We(),Et="mux-video",I,Y,ee,B,te,se,ie,re,_e,Q=class extends ke{constructor(){super();u(this,re);u(this,I,void 0);u(this,Y,void 0);u(this,ee,void 0);u(this,B,{});u(this,te,void 0);u(this,se,void 0);u(this,ie,void 0);d(this,ee,(0,l.generatePlayerInitTime)())}static get observedAttributes(){var e;return[...ht,...(e=ke.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(n.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?l.CmcdTypeValues.includes(e)?this.setAttribute(n.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${l.CmcdTypeValues.join()}`):this.removeAttribute(n.PREFER_CMCD))}get playerInitTime(){return i(this,ee)}get playerSoftwareName(){var e;return(e=i(this,se))!=null?e:Et}set playerSoftwareName(e){d(this,se,e)}get playerSoftwareVersion(){var e;return(e=i(this,te))!=null?e:mt}set playerSoftwareVersion(e){d(this,te,e)}get _hls(){var e;return(e=i(this,I))==null?void 0:e.engine}get mux(){return this.nativeEl.mux}get error(){var e;return(e=(0,l.getError)(this.nativeEl))!=null?e:null}get errorTranslator(){return i(this,ie)}set errorTranslator(e){d(this,ie,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(n.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(n.TYPE,e):this.removeAttribute(n.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let c=this.autoplay;e!==c&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(n.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(n.DEBUG,""):this.removeAttribute(n.DEBUG))}get disableCookies(){return this.hasAttribute(n.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(n.DISABLE_COOKIES,""):this.removeAttribute(n.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(n.START_TIME);if(e==null)return;let c=+e;return Number.isNaN(c)?void 0:c}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(n.START_TIME):this.setAttribute(n.START_TIME,`${e}`))}get playbackId(){var e;return(e=this.getAttribute(n.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(n.PLAYBACK_ID,e):this.removeAttribute(n.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(n.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(n.MAX_RESOLUTION,e):this.removeAttribute(n.MAX_RESOLUTION))}get customDomain(){var e;return(e=this.getAttribute(n.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(n.CUSTOM_DOMAIN,e):this.removeAttribute(n.CUSTOM_DOMAIN))}get envKey(){var e;return(e=this.getAttribute(n.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(n.ENV_KEY,e):this.removeAttribute(n.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(n.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(n.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(n.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(n.STREAM_TYPE))!=null?e:(0,l.getStreamType)(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(n.STREAM_TYPE,e):this.removeAttribute(n.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(n.TARGET_LIVE_WINDOW)?+this.getAttribute(n.TARGET_LIVE_WINDOW):(0,l.getTargetLiveWindow)(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(n.TARGET_LIVE_WINDOW):this.setAttribute(n.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,c;if(this.hasAttribute(n.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:o}=this,E=(e=this.nativeEl.seekable.end(0))!=null?e:0,b=(c=this.nativeEl.seekable.start(0))!=null?c:0;return Math.max(b,E-o)}return(0,l.getLiveEdgeStart)(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(n.LIVE_EDGE_OFFSET))return+this.getAttribute(n.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(n.LIVE_EDGE_OFFSET):this.setAttribute(n.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return(0,l.getSeekable)(this.nativeEl)}async addCuePoints(e){return(0,l.addCuePoints)(this.nativeEl,e)}get activeCuePoint(){return(0,l.getActiveCuePoint)(this.nativeEl)}get cuePoints(){return(0,l.getCuePoints)(this.nativeEl)}getStartDate(){return(0,l.getStartDate)(this.nativeEl,this._hls)}get currentPdt(){return(0,l.getCurrentPdt)(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(n.PREFER_PLAYBACK);if(e===l.PlaybackTypes.MSE||e===l.PlaybackTypes.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===l.PlaybackTypes.MSE||e===l.PlaybackTypes.NATIVE?this.setAttribute(n.PREFER_PLAYBACK,e):this.removeAttribute(n.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(c=>c.startsWith("metadata-")&&![n.METADATA_URL].includes(c)).reduce((c,o)=>{let E=this.getAttribute(o);return E!=null&&(c[o.replace(/^metadata-/,"").replace(/-/g,"_")]=E),c},{}),...i(this,B)}}set metadata(e){d(this,B,e!=null?e:{}),this.mux&&this.mux.emit("hb",i(this,B))}load(){d(this,I,(0,l.initialize)(this,this.nativeEl,i(this,I)))}unload(){(0,l.teardown)(this.nativeEl,i(this,I)),d(this,I,void 0)}attributeChangedCallback(e,c,o){var E,b;switch(super.attributeChangedCallback(e,c,o),e){case n.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=o!=null?o:void 0;break;case n.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=o!=null?o:void 0;break;case"src":{let p=!!c,pe=!!o;!p&&pe?m(this,re,_e).call(this):p&&!pe?this.unload():p&&pe&&(this.unload(),m(this,re,_e).call(this));break}case"autoplay":if(o===c)break;(E=i(this,I))==null||E.setAutoplay(this.autoplay);break;case"preload":if(o===c)break;(b=i(this,I))==null||b.setPreload(o);break;case n.PLAYBACK_ID:this.src=(0,l.toMuxVideoURL)(o!=null?o:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case n.DEBUG:{let p=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=p);break}case n.METADATA_URL:o&&fetch(o).then(p=>p.json()).then(p=>this.metadata=p).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${o}!`));break;case n.STREAM_TYPE:(o==null||o!==c)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case n.TARGET_LIVE_WINDOW:(o==null||o!==c)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};I=new WeakMap,Y=new WeakMap,ee=new WeakMap,B=new WeakMap,te=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakSet,_e=async function(){i(this,Y)||(await d(this,Y,Promise.resolve()),d(this,Y,null),this.load())};C.customElements.get("mux-video")||(C.customElements.define("mux-video",Q),C.MuxVideoElement=Q);var ft=Q;
23
+ video {
24
+ max-width: 100%;
25
+ max-height: 100%;
26
+ min-width: 100%;
27
+ min-height: 100%;
28
+ object-fit: var(--media-object-fit, contain);
29
+ object-position: var(--media-object-position, 50% 50%);
30
+ }
31
+
32
+ video::-webkit-media-text-track-container {
33
+ transform: var(--media-webkit-text-track-transform);
34
+ transition: var(--media-webkit-text-track-transition);
35
+ }
36
+ </style>
37
+ <slot></slot>
38
+ `);var At=(n,{tag:e,is:t})=>{var I,C,P,O,ee,q,R,x,K,ot,se,ut,ie;let u=(I=globalThis.document)==null?void 0:I.createElement(e,{is:t}),c=u?fe(u):[];return C=class extends n{constructor(){super();o(this,x);o(this,ot);o(this,ut);o(this,q,void 0);o(this,R,void 0);this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var l,y,b;return p(l=C,O,ee).call(l),[...(b=(y=u==null?void 0:u.constructor)==null?void 0:y.observedAttributes)!=null?b:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var h,l;return(l=(h=i(this,R))!=null?h:this.shadowRoot.querySelector(e))!=null?l:this.querySelector(e)}set nativeEl(h){f(this,R,h)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(h){this.toggleAttribute("muted",Boolean(h))}get src(){return this.getAttribute("src")}set src(h){this.setAttribute("src",`${h}`)}get preload(){var h,l;return(l=this.getAttribute("preload"))!=null?l:(h=this.nativeEl)==null?void 0:h.preload}set preload(h){this.setAttribute("preload",`${h}`)}attributeChangedCallback(h,l,y){p(this,x,K).call(this),p(this,ut,ie).call(this,h,l,y)}connectedCallback(){p(this,x,K).call(this)}},P=new WeakMap,O=new WeakSet,ee=function(){if(i(this,P))return;f(this,P,!0);let h=new Set(this.observedAttributes);h.delete("muted");for(let l of c){if(l in this.prototype)continue;if(typeof u[l]=="function")this.prototype[l]=function(...b){return p(this,x,K).call(this),(()=>this.call?this.call(l,...b):this.nativeEl[l].apply(this.nativeEl,b))()};else{let b={get(){var E,T,k;p(this,x,K).call(this);let m=l.toLowerCase();if(h.has(m)){let W=this.getAttribute(m);return W===null?!1:W===""?!0:W}return(k=(E=this.get)==null?void 0:E.call(this,l))!=null?k:(T=this.nativeEl)==null?void 0:T[l]}};l!==l.toUpperCase()&&(b.set=function(m){p(this,x,K).call(this);let E=l.toLowerCase();if(h.has(E)){m===!0||m===!1||m==null?this.toggleAttribute(E,Boolean(m)):this.setAttribute(E,m);return}if(this.set){this.set(l,m);return}this.nativeEl[l]=m}),Object.defineProperty(this.prototype,l,b)}}},q=new WeakMap,R=new WeakMap,x=new WeakSet,K=function(){var y,b;if(i(this,q))return;if(f(this,q,!0),!this.nativeEl){let m=document.createElement(e,{is:t});m.part=e,this.shadowRoot.append(m)}this.nativeEl.muted=this.hasAttribute("muted");for(let m of c)p(this,ot,se).call(this,m);let h=new Map,l=this.shadowRoot.querySelector("slot:not([name])");l==null||l.addEventListener("slotchange",()=>{let m=new Map(h);l.assignedElements().filter(E=>["track","source"].includes(E.localName)).forEach(E=>{var k,W;m.delete(E);let T=h.get(E);T||(T=E.cloneNode(),h.set(E,T)),(W=(k=this.nativeEl).append)==null||W.call(k,T)}),m.forEach(E=>E.remove())});for(let m of this.constructor.Events)(b=(y=this.shadowRoot).addEventListener)==null||b.call(y,m,E=>{E.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(E.type,{detail:E.detail}))},!0)},ot=new WeakSet,se=function(h){if(Object.prototype.hasOwnProperty.call(this,h)){let l=this[h];delete this[h],this[h]=l}},ut=new WeakSet,ie=function(h,l,y){var b,m,E,T;["id","class"].includes(h)||(y===null?(m=(b=this.nativeEl).removeAttribute)==null||m.call(b,h):(T=(E=this.nativeEl).setAttribute)==null||T.call(E,h,y))},o(C,O),G(C,"Events",bt),G(C,"template",e.endsWith("audio")?Lt:Rt),o(C,P,void 0),C};function fe(n){let e=[];for(let t=Object.getPrototypeOf(n);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var ke=globalThis.document?At(HTMLElement,{tag:"video"}):class{},Le=globalThis.document?At(HTMLElement,{tag:"audio"}):class{};bt.push("castchange","entercast","leavecast");var _t=At(Z.HTMLElement,{tag:"video",is:"castable-video"}),a={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},pe=Object.values(a),ye=Ht(),ge="mux-video",N,H,st,j,it,rt,at,nt,Dt,et=class extends _t{constructor(){super();o(this,nt);o(this,N,void 0);o(this,H,void 0);o(this,st,void 0);o(this,j,{});o(this,it,void 0);o(this,rt,void 0);o(this,at,void 0);f(this,st,(0,d.generatePlayerInitTime)())}static get observedAttributes(){var t;return[...pe,...(t=_t.observedAttributes)!=null?t:[]]}get preferCmcd(){var t;return(t=this.getAttribute(a.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?d.CmcdTypeValues.includes(t)?this.setAttribute(a.PREFER_CMCD,t):console.warn(`Invalid value for preferCmcd. Must be one of ${d.CmcdTypeValues.join()}`):this.removeAttribute(a.PREFER_CMCD))}get playerInitTime(){return i(this,st)}get playerSoftwareName(){var t;return(t=i(this,rt))!=null?t:ge}set playerSoftwareName(t){f(this,rt,t)}get playerSoftwareVersion(){var t;return(t=i(this,it))!=null?t:ye}set playerSoftwareVersion(t){f(this,it,t)}get _hls(){var t;return(t=i(this,N))==null?void 0:t.engine}get mux(){return this.nativeEl.mux}get error(){var t;return(t=(0,d.getError)(this.nativeEl))!=null?t:null}get errorTranslator(){return i(this,at)}set errorTranslator(t){f(this,at,t)}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(a.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(a.TYPE,t):this.removeAttribute(a.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let u=this.autoplay;t!==u&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get preload(){let t=this.getAttribute("preload");return t===""?"auto":["none","metadata","auto"].includes(t)?t:super.preload}set preload(t){t!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(t)?this.setAttribute("preload",t):this.removeAttribute("preload"))}get debug(){return this.getAttribute(a.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(a.DEBUG,""):this.removeAttribute(a.DEBUG))}get disableCookies(){return this.hasAttribute(a.DISABLE_COOKIES)}set disableCookies(t){t!==this.disableCookies&&(t?this.setAttribute(a.DISABLE_COOKIES,""):this.removeAttribute(a.DISABLE_COOKIES))}get startTime(){let t=this.getAttribute(a.START_TIME);if(t==null)return;let u=+t;return Number.isNaN(u)?void 0:u}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(a.START_TIME):this.setAttribute(a.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(a.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(a.PLAYBACK_ID,t):this.removeAttribute(a.PLAYBACK_ID))}get maxResolution(){var t;return(t=this.getAttribute(a.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(a.MAX_RESOLUTION,t):this.removeAttribute(a.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(a.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(a.CUSTOM_DOMAIN,t):this.removeAttribute(a.CUSTOM_DOMAIN))}get envKey(){var t;return(t=this.getAttribute(a.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(a.ENV_KEY,t):this.removeAttribute(a.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(a.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(a.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(a.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(a.STREAM_TYPE))!=null?t:(0,d.getStreamType)(this.nativeEl)}set streamType(t){t!==this.streamType&&(t?this.setAttribute(a.STREAM_TYPE,t):this.removeAttribute(a.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(a.TARGET_LIVE_WINDOW)?+this.getAttribute(a.TARGET_LIVE_WINDOW):(0,d.getTargetLiveWindow)(this.nativeEl)}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(a.TARGET_LIVE_WINDOW):this.setAttribute(a.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t,u;if(this.hasAttribute(a.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:c}=this,I=(t=this.nativeEl.seekable.end(0))!=null?t:0,C=(u=this.nativeEl.seekable.start(0))!=null?u:0;return Math.max(C,I-c)}return(0,d.getLiveEdgeStart)(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(a.LIVE_EDGE_OFFSET))return+this.getAttribute(a.LIVE_EDGE_OFFSET)}set liveEdgeOffset(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(a.LIVE_EDGE_OFFSET):this.setAttribute(a.LIVE_EDGE_OFFSET,`${+t}`))}get seekable(){return(0,d.getSeekable)(this.nativeEl)}async addCuePoints(t){return(0,d.addCuePoints)(this.nativeEl,t)}get activeCuePoint(){return(0,d.getActiveCuePoint)(this.nativeEl)}get cuePoints(){return(0,d.getCuePoints)(this.nativeEl)}getStartDate(){return(0,d.getStartDate)(this.nativeEl,this._hls)}get currentPdt(){return(0,d.getCurrentPdt)(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(a.PREFER_PLAYBACK);if(t===d.PlaybackTypes.MSE||t===d.PlaybackTypes.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===d.PlaybackTypes.MSE||t===d.PlaybackTypes.NATIVE?this.setAttribute(a.PREFER_PLAYBACK,t):this.removeAttribute(a.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(u=>u.startsWith("metadata-")&&![a.METADATA_URL].includes(u)).reduce((u,c)=>{let I=this.getAttribute(c);return I!=null&&(u[c.replace(/^metadata-/,"").replace(/-/g,"_")]=I),u},{}),...i(this,j)}}set metadata(t){f(this,j,t!=null?t:{}),this.mux&&this.mux.emit("hb",i(this,j))}load(){f(this,N,(0,d.initialize)(this,this.nativeEl,i(this,N)))}unload(){(0,d.teardown)(this.nativeEl,i(this,N)),f(this,N,void 0)}attributeChangedCallback(t,u,c){var C,P;switch(_t.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,u,c),t){case a.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=c!=null?c:void 0;break;case a.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=c!=null?c:void 0;break;case"src":{let O=!!u,v=!!c;!O&&v?p(this,nt,Dt).call(this):O&&!v?this.unload():O&&v&&(this.unload(),p(this,nt,Dt).call(this));break}case"autoplay":if(c===u)break;(C=i(this,N))==null||C.setAutoplay(this.autoplay);break;case"preload":if(c===u)break;(P=i(this,N))==null||P.setPreload(c);break;case a.PLAYBACK_ID:this.src=(0,d.toMuxVideoURL)(c!=null?c:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case a.DEBUG:{let O=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=O);break}case a.METADATA_URL:c&&fetch(c).then(O=>O.json()).then(O=>this.metadata=O).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${c}!`));break;case a.STREAM_TYPE:(c==null||c!==u)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case a.TARGET_LIVE_WINDOW:(c==null||c!==u)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};N=new WeakMap,H=new WeakMap,st=new WeakMap,j=new WeakMap,it=new WeakMap,rt=new WeakMap,at=new WeakMap,nt=new WeakSet,Dt=async function(){i(this,H)||(await f(this,H,Promise.resolve()),f(this,H,null),this.load())};Z.customElements.get("mux-video")||(Z.customElements.define("mux-video",et),Z.MuxVideoElement=et);var be=et;
27
39
  //# sourceMappingURL=index.cjs.js.map