"use strict";var H=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var it=s=>{throw TypeError(s)};var Et=(s,r,t)=>r in s?H(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var pt=(s,r)=>{for(var t in r)H(s,t,{get:r[t],enumerable:!0})},Tt=(s,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of At(r))!gt.call(s,f)&&f!==t&&H(s,f,{get:()=>r[f],enumerable:!(n=bt(r,f))||n.enumerable});return s};var yt=s=>Tt(H({},"__esModule",{value:!0}),s);var I=(s,r,t)=>Et(s,typeof r!="symbol"?r+"":r,t),F=(s,r,t)=>r.has(s)||it("Cannot "+t);var a=(s,r,t)=>(F(s,r,"read from private field"),t?t.call(s):r.get(s)),A=(s,r,t)=>r.has(s)?it("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,t),g=(s,r,t,n)=>(F(s,r,"write to private field"),n?n.call(s,t):r.set(s,t),t),m=(s,r,t)=>(F(s,r,"access private method"),t);var vt={};pt(vt,{Attributes:()=>e,AudioEvents:()=>Z,MediaError:()=>c.MediaError,default:()=>Ot,generatePlayerInitTime:()=>c.generatePlayerInitTime,playerSoftwareName:()=>et,playerSoftwareVersion:()=>tt});module.exports=yt(vt);var v=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class s extends v{}globalThis.DocumentFragment=s}var K=class extends v{},z=class extends v{},_t={get(s){},define(s,r,t){},getName(s){return null},upgrade(s){},whenDefined(s){return Promise.resolve(K)}},B,W=class{constructor(r,t={}){A(this,B);g(this,B,t==null?void 0:t.detail)}get detail(){return a(this,B)}initCustomEvent(){}};B=new WeakMap;function Mt(s,r){return new K}var st={document:{createElement:Mt},DocumentFragment,customElements:_t,CustomEvent:W,EventTarget:v,HTMLElement:K,HTMLVideoElement:z},rt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",$=rt?st:globalThis,xt=rt?st.document:globalThis.document;var c=require("@mux/playback-core");var Ct=()=>{try{return"0.15.25"}catch{}return"UNKNOWN"},Pt=Ct(),nt=()=>Pt;var Z=["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"],ut=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function St(s){return`
    <style>
      :host {
        display: inline-flex;
        line-height: 0;
        flex-direction: column;
        justify-content: end;
      }

      audio {
        width: 100%;
      }
    </style>
    <slot name="media">
      <audio${mt(s)}></audio>
    </slot>
    <slot></slot>
  `}function It(s){return`
    <style>
      :host {
        display: inline-block;
        line-height: 0;
      }

      video {
        max-width: 100%;
        max-height: 100%;
        min-width: 100%;
        min-height: 100%;
        object-fit: var(--media-object-fit, contain);
        object-position: var(--media-object-position, 50% 50%);
      }

      video::-webkit-media-text-track-container {
        transform: var(--media-webkit-text-track-transform);
        transition: var(--media-webkit-text-track-transition);
      }
    </style>
    <slot name="media">
      <video${mt(s)}></video>
    </slot>
    <slot></slot>
  `}function ft(s,{tag:r,is:t}){var y,P,E,p,C,dt,x,N,_,S,M,h,k,J,Q,lt,X,ct,ht;let n=(P=(y=globalThis.document)==null?void 0:y.createElement)==null?void 0:P.call(y,r,{is:t}),f=n?kt(n):[];return E=class extends s{constructor(){super(...arguments);A(this,h);A(this,x,!1);A(this,N,null);A(this,_,new Map);A(this,S);A(this,M);I(this,"get");I(this,"set");I(this,"call")}static get observedAttributes(){var o,l,u;return m(o=E,C,dt).call(o),[...(u=(l=n==null?void 0:n.constructor)==null?void 0:l.observedAttributes)!=null?u:[],...ut]}get nativeEl(){var i,o,l,u,d;return m(this,h,k).call(this),(d=(u=(o=(i=a(this,N))!=null?i:this.querySelector(":scope > [slot=media]"))!=null?o:this.querySelector(r))!=null?u:(l=this.shadowRoot)==null?void 0:l.querySelector(r))!=null?d:null}set nativeEl(i){g(this,N,i)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(i){this.toggleAttribute("muted",i)}get src(){return this.getAttribute("src")}set src(i){this.setAttribute("src",`${i}`)}get preload(){var i,o;return(o=this.getAttribute("preload"))!=null?o:(i=this.nativeEl)==null?void 0:i.preload}set preload(i){this.setAttribute("preload",`${i}`)}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});let i=Rt(this.attributes);t&&(i.is=t),r&&(i.part=r),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(i)}this.nativeEl.muted=this.hasAttribute("muted");for(let i of f)m(this,h,ct).call(this,i);m(this,h,J).call(this)}handleEvent(i){i.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(i.type,{detail:i.detail}))}attributeChangedCallback(i,o,l){m(this,h,k).call(this),m(this,h,ht).call(this,i,o,l)}connectedCallback(){m(this,h,k).call(this),a(this,M)||m(this,h,J).call(this)}disconnectedCallback(){var i,o,l;(i=a(this,S))==null||i.disconnect(),g(this,S,void 0),a(this,M)&&((o=this.shadowRoot)==null||o.removeEventListener("slotchange",a(this,M)),g(this,M,void 0));for(let u of this.constructor.Events)(l=this.shadowRoot)==null||l.removeEventListener(u,this,!0);a(this,_).forEach(u=>u.remove()),a(this,_).clear(),g(this,N,null)}},p=new WeakMap,C=new WeakSet,dt=function(){if(a(this,p))return;g(this,p,!0);let i=new Set(this.observedAttributes);i.delete("muted");for(let o of f)if(!(o in this.prototype))if(typeof n[o]=="function")this.prototype[o]=function(...l){return m(this,h,k).call(this),(()=>{var b;if(this.call)return this.call(o,...l);let d=(b=this.nativeEl)==null?void 0:b[o];return d==null?void 0:d.apply(this.nativeEl,l)})()};else{let l={get(){var d,b,w;m(this,h,k).call(this);let u=o.toLowerCase();if(i.has(u)){let O=this.getAttribute(u);return O===null?!1:O===""?!0:O}return(w=(d=this.get)==null?void 0:d.call(this,o))!=null?w:(b=this.nativeEl)==null?void 0:b[o]}};o!==o.toUpperCase()&&(l.set=function(u){m(this,h,k).call(this);let d=o.toLowerCase();if(i.has(d)){u===!0||u===!1||u==null?this.toggleAttribute(d,!!u):this.setAttribute(d,u);return}if(this.set){this.set(o,u);return}this.nativeEl&&(this.nativeEl[o]=u)}),Object.defineProperty(this.prototype,o,l)}},x=new WeakMap,N=new WeakMap,_=new WeakMap,S=new WeakMap,M=new WeakMap,h=new WeakSet,k=function(){a(this,x)||(g(this,x,!0),this.init())},J=function(){var i,o;g(this,S,new MutationObserver(m(this,h,lt).bind(this))),g(this,M,()=>m(this,h,Q).call(this)),(i=this.shadowRoot)==null||i.addEventListener("slotchange",a(this,M)),m(this,h,Q).call(this);for(let l of this.constructor.Events)(o=this.shadowRoot)==null||o.addEventListener(l,this,!0)},Q=function(){var u;let i=new Map(a(this,_)),o=(u=this.shadowRoot)==null?void 0:u.querySelector("slot:not([name])");(o==null?void 0:o.assignedElements({flatten:!0}).filter(d=>["track","source"].includes(d.localName))).forEach(d=>{var w,O;i.delete(d);let b=a(this,_).get(d);b||(b=d.cloneNode(),a(this,_).set(d,b),(w=a(this,S))==null||w.observe(d,{attributes:!0})),(O=this.nativeEl)==null||O.append(b),m(this,h,X).call(this,b)}),i.forEach((d,b)=>{d.remove(),a(this,_).delete(b)})},lt=function(i){var o;for(let l of i)if(l.type==="attributes"){let{target:u,attributeName:d}=l,b=a(this,_).get(u);b&&d&&(b.setAttribute(d,(o=u.getAttribute(d))!=null?o:""),m(this,h,X).call(this,b))}},X=function(i){i&&i.localName==="track"&&i.default&&(i.kind==="chapters"||i.kind==="metadata")&&i.track.mode==="disabled"&&(i.track.mode="hidden")},ct=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let o=this[i];delete this[i],this[i]=o}},ht=function(i,o,l){var u,d,b;["id","class"].includes(i)||!E.observedAttributes.includes(i)&&this.constructor.observedAttributes.includes(i)||(l===null?(u=this.nativeEl)==null||u.removeAttribute(i):((d=this.nativeEl)==null?void 0:d.getAttribute(i))!==l&&((b=this.nativeEl)==null||b.setAttribute(i,l)))},A(E,C),I(E,"getTemplateHTML",r.endsWith("audio")?St:It),I(E,"shadowRootOptions",{mode:"open"}),I(E,"Events",Z),A(E,p,!1),E}function kt(s){let r=[];for(let t=Object.getPrototypeOf(s);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){let n=Object.getOwnPropertyNames(t);r.push(...n)}return r}function mt(s){let r="";for(let t in s){if(!ut.includes(t))continue;let n=s[t];n===""?r+=` ${t}`:r+=` ${t}="${n}"`}return r}function Rt(s){let r={};for(let t of s)r[t.name]=t.value;return r}var ot,Yt=ft((ot=globalThis.HTMLElement)!=null?ot:class{},{tag:"video"}),at,V=ft((at=globalThis.HTMLElement)!=null?at:class{},{tag:"audio"});var e={PLAYER_INIT_TIME:"player-init-time",ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",PLAYBACK_TOKEN:"playback-token",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",ASSET_START_TIME:"asset-start-time",ASSET_END_TIME:"asset-end-time",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",CUSTOM_DOMAIN:"custom-domain",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Nt=Object.values(e),tt=nt(),et="mux-audio",L,G,D,U,j,T,R,q,Y=class extends V{constructor(){super();A(this,T);A(this,L);A(this,G);A(this,D,{});A(this,U,{});A(this,j);g(this,G,(0,c.generatePlayerInitTime)())}static get NAME(){return et}static get VERSION(){return tt}static get observedAttributes(){var t;return[...Nt,...(t=V.observedAttributes)!=null?t:[]]}get playerInitTime(){return this.hasAttribute(e.PLAYER_INIT_TIME)?+this.getAttribute(e.PLAYER_INIT_TIME):a(this,G)}set playerInitTime(t){t!=this.playerInitTime&&(t==null?this.removeAttribute(e.PLAYER_INIT_TIME):this.setAttribute(e.PLAYER_INIT_TIME,`${+t}`))}get playerSoftwareName(){return et}get playerSoftwareVersion(){return tt}get _hls(){var t;return(t=a(this,T,R))==null?void 0:t.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}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(e.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(e.DEBUG,""):this.removeAttribute(e.DEBUG))}get disableTracking(){return this.hasAttribute(e.DISABLE_TRACKING)}set disableTracking(t){t!==this.disableTracking&&this.toggleAttribute(e.DISABLE_TRACKING,!!t)}get disableCookies(){return this.hasAttribute(e.DISABLE_COOKIES)}set disableCookies(t){t!==this.disableCookies&&(t?this.setAttribute(e.DISABLE_COOKIES,""):this.removeAttribute(e.DISABLE_COOKIES))}get startTime(){let t=this.getAttribute(e.START_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(e.START_TIME):this.setAttribute(e.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(e.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(e.PLAYBACK_ID,t):this.removeAttribute(e.PLAYBACK_ID))}get programStartTime(){let t=this.getAttribute(e.PROGRAM_START_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set programStartTime(t){t==null?this.removeAttribute(e.PROGRAM_START_TIME):this.setAttribute(e.PROGRAM_START_TIME,`${t}`)}get programEndTime(){let t=this.getAttribute(e.PROGRAM_END_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set programEndTime(t){t==null?this.removeAttribute(e.PROGRAM_END_TIME):this.setAttribute(e.PROGRAM_END_TIME,`${t}`)}get assetStartTime(){let t=this.getAttribute(e.ASSET_START_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set assetStartTime(t){t==null?this.removeAttribute(e.ASSET_START_TIME):this.setAttribute(e.ASSET_START_TIME,`${t}`)}get assetEndTime(){let t=this.getAttribute(e.ASSET_END_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set assetEndTime(t){t==null?this.removeAttribute(e.ASSET_END_TIME):this.setAttribute(e.ASSET_END_TIME,`${t}`)}get customDomain(){var t;return(t=this.getAttribute(e.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(e.CUSTOM_DOMAIN,t):this.removeAttribute(e.CUSTOM_DOMAIN))}get playbackToken(){var t,n,f,y;if(this.hasAttribute(e.PLAYBACK_TOKEN))return(t=this.getAttribute(e.PLAYBACK_TOKEN))!=null?t:void 0;if(this.hasAttribute(e.PLAYBACK_ID)){let[,P]=(0,c.toPlaybackIdParts)((n=this.playbackId)!=null?n:"");return(f=new URLSearchParams(P).get("token"))!=null?f:void 0}if(this.src)return(y=new URLSearchParams(this.src).get("token"))!=null?y:void 0}set playbackToken(t){t!==this.playbackToken&&(t?this.setAttribute(e.PLAYBACK_TOKEN,t):this.removeAttribute(e.PLAYBACK_TOKEN))}get tokens(){let t=this.getAttribute(e.PLAYBACK_TOKEN);return{...a(this,U),...t!=null?{playback:t}:{}}}set tokens(t){g(this,U,t!=null?t:{})}get ended(){return(0,c.getEnded)(this.nativeEl,this._hls)}get envKey(){var t;return(t=this.getAttribute(e.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(e.ENV_KEY,t):this.removeAttribute(e.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(e.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(e.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(e.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(e.STREAM_TYPE))!=null?t:void 0}set streamType(t){t!==this.streamType&&(t?this.setAttribute(e.STREAM_TYPE,t):this.removeAttribute(e.STREAM_TYPE))}getStartDate(){return(0,c.getStartDate)(this.nativeEl,this._hls)}get currentPdt(){return(0,c.getCurrentPdt)(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(e.PREFER_PLAYBACK);if(t===c.PlaybackTypes.MSE||t===c.PlaybackTypes.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===c.PlaybackTypes.MSE||t===c.PlaybackTypes.NATIVE?this.setAttribute(e.PREFER_PLAYBACK,t):this.removeAttribute(e.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(n=>n.startsWith("metadata-")&&![e.METADATA_URL].includes(n)).reduce((n,f)=>{let y=this.getAttribute(f);return y!=null&&(n[f.replace(/^metadata-/,"").replace(/-/g,"_")]=y),n},{}),...a(this,D)}}set metadata(t){g(this,D,t!=null?t:{}),this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",a(this,D)))}get _hlsConfig(){return a(this,j)}set _hlsConfig(t){g(this,j,t)}load(){(0,c.initialize)(this,this.nativeEl,a(this,T,R))}unload(){(0,c.teardown)(this.nativeEl,a(this,T,R))}attributeChangedCallback(t,n,f){var P,E;switch(V.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,n,f),t){case"src":{let p=!!n,C=!!f;!p&&C?m(this,T,q).call(this):p&&!C?this.unload():p&&C&&(this.unload(),m(this,T,q).call(this));break}case"autoplay":if(f===n)break;(P=a(this,T,R))==null||P.setAutoplay(this.autoplay);break;case"preload":if(f===n)break;(E=a(this,T,R))==null||E.setPreload(f);break;case e.PLAYBACK_ID:case e.CUSTOM_DOMAIN:case e.PROGRAM_START_TIME:case e.PROGRAM_END_TIME:case e.ASSET_START_TIME:case e.ASSET_END_TIME:case e.PLAYBACK_TOKEN:this.src=(0,c.toMuxVideoURL)(this);break;case e.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 e.METADATA_URL:f&&fetch(f).then(p=>p.json()).then(p=>this.metadata=p).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${f}!`));break;default:break}}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this.nativeEl&&this.src&&!a(this,T,R)&&m(this,T,q).call(this)}disconnectedCallback(){this.unload()}};L=new WeakMap,G=new WeakMap,D=new WeakMap,U=new WeakMap,j=new WeakMap,T=new WeakSet,R=function(){return(0,c.getCoreReference)(this.nativeEl)},q=async function(){a(this,L)||(await g(this,L,Promise.resolve()),g(this,L,null),this.load())};$.customElements.get("mux-audio")||($.customElements.define("mux-audio",Y),$.MuxAudioElement=Y);var Ot=Y;
//# sourceMappingURL=index.cjs.js.map
