var mt=Object.defineProperty;var X=s=>{throw TypeError(s)};var bt=(s,r,t)=>r in s?mt(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var S=(s,r,t)=>bt(s,typeof r!="symbol"?r+"":r,t),q=(s,r,t)=>r.has(s)||X("Cannot "+t);var a=(s,r,t)=>(q(s,r,"read from private field"),t?t.call(s):r.get(s)),m=(s,r,t)=>r.has(s)?X("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,t),b=(s,r,t,n)=>(q(s,r,"write to private field"),n?n.call(s,t):r.set(s,t),t),h=(s,r,t)=>(q(s,r,"access private method"),t);var O=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class s extends O{}globalThis.DocumentFragment=s}var w=class extends O{},F=class extends O{},At={get(s){},define(s,r,t){},getName(s){return null},upgrade(s){},whenDefined(s){return Promise.resolve(w)}},K,z=class{constructor(r,t={}){m(this,K);b(this,K,t==null?void 0:t.detail)}get detail(){return a(this,K)}initCustomEvent(){}};K=new WeakMap;function gt(s,r){return new w}var Z={document:{createElement:gt},DocumentFragment,customElements:At,CustomEvent:z,EventTarget:O,HTMLElement:w,HTMLVideoElement:F},tt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",j=tt?Z:globalThis,wt=tt?Z.document:globalThis.document;import{initialize as Ct,teardown as Pt,generatePlayerInitTime as St,PlaybackTypes as $,toMuxVideoURL as It,MediaError as Ft,getStartDate as kt,getCurrentPdt as Rt,getEnded as Nt,getCoreReference as Ot,toPlaybackIdParts as vt}from"@mux/playback-core";var Et=()=>{try{return"0.15.25"}catch{}return"UNKNOWN"},pt=Et(),et=()=>pt;var rt=["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"],nt=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function Tt(s){return`
    <style>
      :host {
        display: inline-flex;
        line-height: 0;
        flex-direction: column;
        justify-content: end;
      }

      audio {
        width: 100%;
      }
    </style>
    <slot name="media">
      <audio${ct(s)}></audio>
    </slot>
    <slot></slot>
  `}function yt(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${ct(s)}></video>
    </slot>
    <slot></slot>
  `}function lt(s,{tag:r,is:t}){var T,C,g,E,M,ot,D,R,y,P,_,c,I,W,J,at,Q,ut,dt;let n=(C=(T=globalThis.document)==null?void 0:T.createElement)==null?void 0:C.call(T,r,{is:t}),A=n?_t(n):[];return g=class extends s{constructor(){super(...arguments);m(this,c);m(this,D,!1);m(this,R,null);m(this,y,new Map);m(this,P);m(this,_);S(this,"get");S(this,"set");S(this,"call")}static get observedAttributes(){var o,l,u;return h(o=g,M,ot).call(o),[...(u=(l=n==null?void 0:n.constructor)==null?void 0:l.observedAttributes)!=null?u:[],...nt]}get nativeEl(){var i,o,l,u,d;return h(this,c,I).call(this),(d=(u=(o=(i=a(this,R))!=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){b(this,R,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=Mt(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 A)h(this,c,ut).call(this,i);h(this,c,W).call(this)}handleEvent(i){i.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(i.type,{detail:i.detail}))}attributeChangedCallback(i,o,l){h(this,c,I).call(this),h(this,c,dt).call(this,i,o,l)}connectedCallback(){h(this,c,I).call(this),a(this,_)||h(this,c,W).call(this)}disconnectedCallback(){var i,o,l;(i=a(this,P))==null||i.disconnect(),b(this,P,void 0),a(this,_)&&((o=this.shadowRoot)==null||o.removeEventListener("slotchange",a(this,_)),b(this,_,void 0));for(let u of this.constructor.Events)(l=this.shadowRoot)==null||l.removeEventListener(u,this,!0);a(this,y).forEach(u=>u.remove()),a(this,y).clear(),b(this,R,null)}},E=new WeakMap,M=new WeakSet,ot=function(){if(a(this,E))return;b(this,E,!0);let i=new Set(this.observedAttributes);i.delete("muted");for(let o of A)if(!(o in this.prototype))if(typeof n[o]=="function")this.prototype[o]=function(...l){return h(this,c,I).call(this),(()=>{var f;if(this.call)return this.call(o,...l);let d=(f=this.nativeEl)==null?void 0:f[o];return d==null?void 0:d.apply(this.nativeEl,l)})()};else{let l={get(){var d,f,x;h(this,c,I).call(this);let u=o.toLowerCase();if(i.has(u)){let N=this.getAttribute(u);return N===null?!1:N===""?!0:N}return(x=(d=this.get)==null?void 0:d.call(this,o))!=null?x:(f=this.nativeEl)==null?void 0:f[o]}};o!==o.toUpperCase()&&(l.set=function(u){h(this,c,I).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)}},D=new WeakMap,R=new WeakMap,y=new WeakMap,P=new WeakMap,_=new WeakMap,c=new WeakSet,I=function(){a(this,D)||(b(this,D,!0),this.init())},W=function(){var i,o;b(this,P,new MutationObserver(h(this,c,at).bind(this))),b(this,_,()=>h(this,c,J).call(this)),(i=this.shadowRoot)==null||i.addEventListener("slotchange",a(this,_)),h(this,c,J).call(this);for(let l of this.constructor.Events)(o=this.shadowRoot)==null||o.addEventListener(l,this,!0)},J=function(){var u;let i=new Map(a(this,y)),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 x,N;i.delete(d);let f=a(this,y).get(d);f||(f=d.cloneNode(),a(this,y).set(d,f),(x=a(this,P))==null||x.observe(d,{attributes:!0})),(N=this.nativeEl)==null||N.append(f),h(this,c,Q).call(this,f)}),i.forEach((d,f)=>{d.remove(),a(this,y).delete(f)})},at=function(i){var o;for(let l of i)if(l.type==="attributes"){let{target:u,attributeName:d}=l,f=a(this,y).get(u);f&&d&&(f.setAttribute(d,(o=u.getAttribute(d))!=null?o:""),h(this,c,Q).call(this,f))}},Q=function(i){i&&i.localName==="track"&&i.default&&(i.kind==="chapters"||i.kind==="metadata")&&i.track.mode==="disabled"&&(i.track.mode="hidden")},ut=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let o=this[i];delete this[i],this[i]=o}},dt=function(i,o,l){var u,d,f;["id","class"].includes(i)||!g.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&&((f=this.nativeEl)==null||f.setAttribute(i,l)))},m(g,M),S(g,"getTemplateHTML",r.endsWith("audio")?Tt:yt),S(g,"shadowRootOptions",{mode:"open"}),S(g,"Events",rt),m(g,E,!1),g}function _t(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 ct(s){let r="";for(let t in s){if(!nt.includes(t))continue;let n=s[t];n===""?r+=` ${t}`:r+=` ${t}="${n}"`}return r}function Mt(s){let r={};for(let t of s)r[t.name]=t.value;return r}var it,Gt=lt((it=globalThis.HTMLElement)!=null?it:class{},{tag:"video"}),st,H=lt((st=globalThis.HTMLElement)!=null?st: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"},Lt=Object.values(e),ht=et(),ft="mux-audio",v,Y,L,G,U,p,k,V,B=class extends H{constructor(){super();m(this,p);m(this,v);m(this,Y);m(this,L,{});m(this,G,{});m(this,U);b(this,Y,St())}static get NAME(){return ft}static get VERSION(){return ht}static get observedAttributes(){var t;return[...Lt,...(t=H.observedAttributes)!=null?t:[]]}get playerInitTime(){return this.hasAttribute(e.PLAYER_INIT_TIME)?+this.getAttribute(e.PLAYER_INIT_TIME):a(this,Y)}set playerInitTime(t){t!=this.playerInitTime&&(t==null?this.removeAttribute(e.PLAYER_INIT_TIME):this.setAttribute(e.PLAYER_INIT_TIME,`${+t}`))}get playerSoftwareName(){return ft}get playerSoftwareVersion(){return ht}get _hls(){var t;return(t=a(this,p,k))==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,A,T;if(this.hasAttribute(e.PLAYBACK_TOKEN))return(t=this.getAttribute(e.PLAYBACK_TOKEN))!=null?t:void 0;if(this.hasAttribute(e.PLAYBACK_ID)){let[,C]=vt((n=this.playbackId)!=null?n:"");return(A=new URLSearchParams(C).get("token"))!=null?A:void 0}if(this.src)return(T=new URLSearchParams(this.src).get("token"))!=null?T: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,G),...t!=null?{playback:t}:{}}}set tokens(t){b(this,G,t!=null?t:{})}get ended(){return Nt(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 kt(this.nativeEl,this._hls)}get currentPdt(){return Rt(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(e.PREFER_PLAYBACK);if(t===$.MSE||t===$.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===$.MSE||t===$.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,A)=>{let T=this.getAttribute(A);return T!=null&&(n[A.replace(/^metadata-/,"").replace(/-/g,"_")]=T),n},{}),...a(this,L)}}set metadata(t){b(this,L,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,L)))}get _hlsConfig(){return a(this,U)}set _hlsConfig(t){b(this,U,t)}load(){Ct(this,this.nativeEl,a(this,p,k))}unload(){Pt(this.nativeEl,a(this,p,k))}attributeChangedCallback(t,n,A){var C,g;switch(H.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,n,A),t){case"src":{let E=!!n,M=!!A;!E&&M?h(this,p,V).call(this):E&&!M?this.unload():E&&M&&(this.unload(),h(this,p,V).call(this));break}case"autoplay":if(A===n)break;(C=a(this,p,k))==null||C.setAutoplay(this.autoplay);break;case"preload":if(A===n)break;(g=a(this,p,k))==null||g.setPreload(A);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=It(this);break;case e.DEBUG:{let E=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=E);break}case e.METADATA_URL:A&&fetch(A).then(E=>E.json()).then(E=>this.metadata=E).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${A}!`));break;default:break}}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this.nativeEl&&this.src&&!a(this,p,k)&&h(this,p,V).call(this)}disconnectedCallback(){this.unload()}};v=new WeakMap,Y=new WeakMap,L=new WeakMap,G=new WeakMap,U=new WeakMap,p=new WeakSet,k=function(){return Ot(this.nativeEl)},V=async function(){a(this,v)||(await b(this,v,Promise.resolve()),b(this,v,null),this.load())};j.customElements.get("mux-audio")||(j.customElements.define("mux-audio",B),j.MuxAudioElement=B);var Jt=B;export{e as Attributes,rt as AudioEvents,Ft as MediaError,Jt as default,St as generatePlayerInitTime,ft as playerSoftwareName,ht as playerSoftwareVersion};
//# sourceMappingURL=index.mjs.map
