@mux/mux-player 3.2.4 → 3.2.5-canary.1

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.
@@ -1,11 +1,11 @@
1
- "use strict";(()=>{var Fg=i=>{throw TypeError(i)};var fc=(i,e,t)=>e.has(i)||Fg("Cannot "+t);var _e=(i,e,t)=>(fc(i,e,"read from private field"),t?t.call(i):e.get(i)),kt=(i,e,t)=>e.has(i)?Fg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),$t=(i,e,t,r)=>(fc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Qe=(i,e,t)=>(fc(i,e,"access private method"),t);var $s=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends $s{}globalThis.DocumentFragment=i}var Wn=class extends $s{},mc=class extends $s{},V_={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Wn)}},Yn,pc=class{constructor(e,t={}){kt(this,Yn);$t(this,Yn,t==null?void 0:t.detail)}get detail(){return _e(this,Yn)}initCustomEvent(){}};Yn=new WeakMap;function W_(i,e){return new Wn}var Bg={document:{createElement:W_},DocumentFragment,customElements:V_,CustomEvent:pc,EventTarget:$s,HTMLElement:Wn,HTMLVideoElement:mc},$g=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ct=$g?Bg:globalThis,Hs=$g?Bg.document:globalThis.document;var $={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ue={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},gc={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_WIDTH:"mediaWidth"},Hg=Object.entries(gc),y=Hg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),Y_={USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Ki=Hg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...Y_}),cD=Object.entries(Ki).reduce((i,[e,t])=>{let r=y[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Gg=Object.entries(y).reduce((i,[e,t])=>{let r=Ki[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),wt={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},or={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var vc={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ht={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},Qt={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Kg={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};var j_={2:"Network Error",3:"Decode Error",4:"Source Not Supported",5:"Encryption Error"},z_={2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."},Ec=i=>{var e,t;return i.code===1?null:{title:(e=j_[i.code])!=null?e:`Error ${i.code}`,message:(t=z_[i.code])!=null?t:i.message}},he={ENTER_AIRPLAY:"Start airplay",EXIT_AIRPLAY:"Stop airplay",AUDIO_TRACK_MENU:"Audio",CAPTIONS:"Captions",ENABLE_CAPTIONS:"Enable captions",DISABLE_CAPTIONS:"Disable captions",START_CAST:"Start casting",STOP_CAST:"Stop casting",ENTER_FULLSCREEN:"Enter fullscreen mode",EXIT_FULLSCREEN:"Exit fullscreen mode",MUTE:"Mute",UNMUTE:"Unmute",ENTER_PIP:"Enter picture in picture mode",EXIT_PIP:"Enter picture in picture mode",PLAY:"Play",PAUSE:"Pause",PLAYBACK_RATE:"Playback rate",RENDITIONS:"Quality",SEEK_BACKWARD:"Seek backward",SEEK_FORWARD:"Seek forward",SETTINGS:"Settings"},Fe={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},Be={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},X_={...Fe,...Be};function Vg(i){return i==null?void 0:i.map(Q_).join(" ")}function Wg(i){return i==null?void 0:i.split(/\s+/).map(Z_)}function Q_(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function Z_(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function Yg(i){return i==null?void 0:i.map(J_).join(" ")}function qg(i){return i==null?void 0:i.split(/\s+/).map(eA)}function J_(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function eA(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function jg(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Gs(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Do(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Mo=i=>new Promise(e=>setTimeout(e,i));var zg=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],tA=(i,e)=>{let t=i===1?zg[e].singular:zg[e].plural;return`${i} ${t}`},Pr=i=>{if(!Gs(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&tA(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function fi(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var pD=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Po=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Oo=class extends Po{},No=class extends Oo{constructor(){super(...arguments),this.role=null}},bc=class{observe(){}unobserve(){}disconnect(){}},Xg={createElement:function(){return new qn.HTMLElement},createElementNS:function(){return new qn.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},qn={ResizeObserver:bc,document:Xg,Node:Oo,Element:No,HTMLElement:class extends No{constructor(){super(...arguments),this.innerHTML=""}get content(){return new qn.DocumentFragment}},DocumentFragment:class extends Po{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},Qg=typeof window=="undefined"||typeof window.customElements=="undefined",Zg=Object.keys(qn).every(i=>i in globalThis),R=Qg&&!Zg?qn:globalThis,F=Qg&&!Zg?Xg:globalThis.document;var Jg=new WeakMap,yc=i=>{let e=Jg.get(i);return e||Jg.set(i,e=new Set),e},e0=new R.ResizeObserver(i=>{for(let e of i)for(let t of yc(e.target))t(e)});function Vi(i,e){yc(i).add(e),e0.observe(i)}function Or(i,e){let t=yc(i);t.delete(e),t.size||e0.unobserve(i)}function t0(i){let e={};for(let t of i)e[t.name]=t.value;return e}function We(i){var e;return(e=Uo(i))!=null?e:mi(i,"media-controller")}function Uo(i){var e;let{MEDIA_CONTROLLER:t}=ue,r=i.getAttribute(t);if(r)return(e=Nr(i))==null?void 0:e.getElementById(r)}var Fo=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},rA=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Bo=(i,e)=>rA(i,e)[0],xt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:xt(i,e.getRootNode().host),mi=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||mi(i.getRootNode().host,e)};function jn(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=jn(t.shadowRoot))!=null?e:t:null}function Nr(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function $o(i,{depth:e=3,checkOpacity:t=!0,checkVisibilityCSS:r=!0}={}){if(i.checkVisibility)return i.checkVisibility({checkOpacity:t,checkVisibilityCSS:r});let s=i;for(;s&&e>0;){let n=getComputedStyle(s);if(t&&n.opacity==="0"||r&&n.visibility==="hidden"||n.display==="none")return!1;s=s.parentElement,e--}return!0}function i0(i,e,t,r){let s=Tc(t,r),n=Tc(t,{x:i,y:e}),a=Tc(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function Tc(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function we(i,e){let t=sA(i,r=>r===e);return t||_c(i,e)}function sA(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(let a of n!=null?n:[])if(e(a.selectorText))return a}}function _c(i,e){var t,r;let s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function fe(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function be(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}fe(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function xe(i,e){return i.hasAttribute(e)}function Ae(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}xe(i,e)!=t&&i.toggleAttribute(e,t)}function me(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function ce(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;me(i,e,void 0)!==r&&i.setAttribute(e,r)}var r0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},lr=(i,e,t)=>(r0(i,e,"read from private field"),t?t.call(i):e.get(i)),nA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ho=(i,e,t,r)=>(r0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Dt,s0=F.createElement("template");s0.innerHTML=`
1
+ "use strict";(()=>{var Hg=i=>{throw TypeError(i)};var mc=(i,e,t)=>e.has(i)||Hg("Cannot "+t);var _e=(i,e,t)=>(mc(i,e,"read from private field"),t?t.call(i):e.get(i)),kt=(i,e,t)=>e.has(i)?Hg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),$t=(i,e,t,r)=>(mc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Qe=(i,e,t)=>(mc(i,e,"access private method"),t);var $s=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends $s{}globalThis.DocumentFragment=i}var Wn=class extends $s{},pc=class extends $s{},W_={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Wn)}},Yn,gc=class{constructor(e,t={}){kt(this,Yn);$t(this,Yn,t==null?void 0:t.detail)}get detail(){return _e(this,Yn)}initCustomEvent(){}};Yn=new WeakMap;function Y_(i,e){return new Wn}var Gg={document:{createElement:Y_},DocumentFragment,customElements:W_,CustomEvent:gc,EventTarget:$s,HTMLElement:Wn,HTMLVideoElement:pc},Kg=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ct=Kg?Gg:globalThis,Hs=Kg?Gg.document:globalThis.document;var $={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ue={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},vc={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_WIDTH:"mediaWidth"},Vg=Object.entries(vc),y=Vg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),q_={USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Ki=Vg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...q_}),hD=Object.entries(Ki).reduce((i,[e,t])=>{let r=y[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Wg=Object.entries(y).reduce((i,[e,t])=>{let r=Ki[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),wt={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},or={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Ec={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ht={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},Qt={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Yg={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};var z_={2:"Network Error",3:"Decode Error",4:"Source Not Supported",5:"Encryption Error"},X_={2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."},bc=i=>{var e,t;return i.code===1?null:{title:(e=z_[i.code])!=null?e:`Error ${i.code}`,message:(t=X_[i.code])!=null?t:i.message}},he={ENTER_AIRPLAY:"Start airplay",EXIT_AIRPLAY:"Stop airplay",AUDIO_TRACK_MENU:"Audio",CAPTIONS:"Captions",ENABLE_CAPTIONS:"Enable captions",DISABLE_CAPTIONS:"Disable captions",START_CAST:"Start casting",STOP_CAST:"Stop casting",ENTER_FULLSCREEN:"Enter fullscreen mode",EXIT_FULLSCREEN:"Exit fullscreen mode",MUTE:"Mute",UNMUTE:"Unmute",ENTER_PIP:"Enter picture in picture mode",EXIT_PIP:"Enter picture in picture mode",PLAY:"Play",PAUSE:"Pause",PLAYBACK_RATE:"Playback rate",RENDITIONS:"Quality",SEEK_BACKWARD:"Seek backward",SEEK_FORWARD:"Seek forward",SETTINGS:"Settings"},Be={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},$e={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},Q_={...Be,...$e};function qg(i){return i==null?void 0:i.map(Z_).join(" ")}function jg(i){return i==null?void 0:i.split(/\s+/).map(J_)}function Z_(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function J_(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function zg(i){return i==null?void 0:i.map(eA).join(" ")}function Xg(i){return i==null?void 0:i.split(/\s+/).map(tA)}function eA(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function tA(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Qg(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Gs(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function wo(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Do=i=>new Promise(e=>setTimeout(e,i));var Zg=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],iA=(i,e)=>{let t=i===1?Zg[e].singular:Zg[e].plural;return`${i} ${t}`},Pr=i=>{if(!Gs(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&iA(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function fi(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var gD=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Mo=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Po=class extends Mo{},Oo=class extends Po{constructor(){super(...arguments),this.role=null}},yc=class{observe(){}unobserve(){}disconnect(){}},Jg={createElement:function(){return new qn.HTMLElement},createElementNS:function(){return new qn.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},qn={ResizeObserver:yc,document:Jg,Node:Po,Element:Oo,HTMLElement:class extends Oo{constructor(){super(...arguments),this.innerHTML=""}get content(){return new qn.DocumentFragment}},DocumentFragment:class extends Mo{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},e0=typeof window=="undefined"||typeof window.customElements=="undefined",t0=Object.keys(qn).every(i=>i in globalThis),R=e0&&!t0?qn:globalThis,F=e0&&!t0?Jg:globalThis.document;var i0=new WeakMap,Tc=i=>{let e=i0.get(i);return e||i0.set(i,e=new Set),e},r0=new R.ResizeObserver(i=>{for(let e of i)for(let t of Tc(e.target))t(e)});function Vi(i,e){Tc(i).add(e),r0.observe(i)}function Or(i,e){let t=Tc(i);t.delete(e),t.size||r0.unobserve(i)}function s0(i){let e={};for(let t of i)e[t.name]=t.value;return e}function We(i){var e;return(e=No(i))!=null?e:mi(i,"media-controller")}function No(i){var e;let{MEDIA_CONTROLLER:t}=ue,r=i.getAttribute(t);if(r)return(e=Nr(i))==null?void 0:e.getElementById(r)}var Uo=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},sA=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Fo=(i,e)=>sA(i,e)[0],xt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:xt(i,e.getRootNode().host),mi=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||mi(i.getRootNode().host,e)};function jn(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=jn(t.shadowRoot))!=null?e:t:null}function Nr(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function Bo(i,{depth:e=3,checkOpacity:t=!0,checkVisibilityCSS:r=!0}={}){if(i.checkVisibility)return i.checkVisibility({checkOpacity:t,checkVisibilityCSS:r});let s=i;for(;s&&e>0;){let n=getComputedStyle(s);if(t&&n.opacity==="0"||r&&n.visibility==="hidden"||n.display==="none")return!1;s=s.parentElement,e--}return!0}function n0(i,e,t,r){let s=_c(t,r),n=_c(t,{x:i,y:e}),a=_c(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function _c(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function De(i,e){let t=nA(i,r=>r===e);return t||Ac(i,e)}function nA(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(let a of n!=null?n:[])if(e(a.selectorText))return a}}function Ac(i,e){var t,r;let s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function fe(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function be(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}fe(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function xe(i,e){return i.hasAttribute(e)}function Ae(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}xe(i,e)!=t&&i.toggleAttribute(e,t)}function me(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function ce(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;me(i,e,void 0)!==r&&i.setAttribute(e,r)}var a0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},lr=(i,e,t)=>(a0(i,e,"read from private field"),t?t.call(i):e.get(i)),aA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$o=(i,e,t,r)=>(a0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Dt,o0=F.createElement("template");o0.innerHTML=`
2
2
  <style>
3
3
  :host {
4
4
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
5
5
  box-sizing: border-box;
6
6
  }
7
7
  </style>
8
- `;var Ac=class extends R.HTMLElement{constructor(e={}){if(super(),nA(this,Dt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=s0.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=F.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=lr(this,Dt))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ho(this,Dt,null)),r&&this.isConnected&&(Ho(this,Dt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=lr(this,Dt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),Ho(this,Dt,aA(this)),this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=lr(this,Dt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=lr(this,Dt))==null||r.addEventListener("pointerdown",this),(s=lr(this,Dt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=lr(this,Dt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=lr(this,Dt))==null||r.removeEventListener("pointerdown",this),(s=lr(this,Dt))==null||s.removeEventListener("click",this),Ho(this,Dt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===vc.TOUCH){this.handleTap(e);return}else if(f===vc.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(t,{composed:!0,bubbles:!0}))}};Dt=new WeakMap;function aA(i){var e;let t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):mi(i,"media-controller")}R.customElements.get("media-gesture-receiver")||R.customElements.define("media-gesture-receiver",Ac);var Rc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dr=(i,e,t)=>(Rc(i,e,"read from private field"),t?t.call(i):e.get(i)),Wi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},zn=(i,e,t,r)=>(Rc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Zt=(i,e,t)=>(Rc(i,e,"access private method"),t),Go,Ks,Xn,Vs,Sc,n0,xc,a0,Qn,Ko,Vo,Ic,Ws,Zn,ve={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},o0=F.createElement("template");o0.innerHTML=`
8
+ `;var Sc=class extends R.HTMLElement{constructor(e={}){if(super(),aA(this,Dt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=o0.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=F.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=lr(this,Dt))==null?void 0:s.unassociateElement)==null||n.call(s,this),$o(this,Dt,null)),r&&this.isConnected&&($o(this,Dt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=lr(this,Dt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),$o(this,Dt,oA(this)),this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=lr(this,Dt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=lr(this,Dt))==null||r.addEventListener("pointerdown",this),(s=lr(this,Dt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=lr(this,Dt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=lr(this,Dt))==null||r.removeEventListener("pointerdown",this),(s=lr(this,Dt))==null||s.removeEventListener("click",this),$o(this,Dt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Ec.TOUCH){this.handleTap(e);return}else if(f===Ec.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(t,{composed:!0,bubbles:!0}))}};Dt=new WeakMap;function oA(i){var e;let t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):mi(i,"media-controller")}R.customElements.get("media-gesture-receiver")||R.customElements.define("media-gesture-receiver",Sc);var Ic=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dr=(i,e,t)=>(Ic(i,e,"read from private field"),t?t.call(i):e.get(i)),Wi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},zn=(i,e,t,r)=>(Ic(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Zt=(i,e,t)=>(Ic(i,e,"access private method"),t),Ho,Ks,Xn,Vs,xc,l0,Rc,d0,Qn,Go,Ko,Lc,Ws,Zn,ve={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},u0=F.createElement("template");u0.innerHTML=`
9
9
  <style>
10
10
 
11
11
  :host([${y.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
@@ -145,7 +145,7 @@
145
145
  <slot part="bottom chrome"></slot>
146
146
  </span>
147
147
  <slot name="dialog" part="layer dialog-layer"></slot>
148
- `;var oA=Object.values(y),lA="sm:384 md:576 lg:768 xl:960";function dA(i){uA(i.target,i.contentRect.width)}function uA(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ve.BREAKPOINTS))!=null?t:lA,s=cA(r),n=hA(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Ki.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function cA(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function hA(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}var Jn=class extends R.HTMLElement{constructor(){super(),Wi(this,Sc),Wi(this,xc),Wi(this,Qn),Wi(this,Vo),Wi(this,Ws),Wi(this,Go,0),Wi(this,Ks,null),Wi(this,Xn,null),Wi(this,Vs,void 0),this.breakpointsComputed=!1,this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(o0.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;Vi(this,a=>{r||(setTimeout(()=>{dA(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Ki.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){dr(this,Ks)&&this.mediaUnsetCallback(dr(this,Ks));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ve.AUTOHIDE,ve.GESTURES_DISABLED].concat(oA).filter(e=>![y.MEDIA_RENDITION_LIST,y.MEDIA_AUDIO_TRACK_LIST,y.MEDIA_CHAPTERS_CUES,y.MEDIA_WIDTH,y.MEDIA_HEIGHT,y.MEDIA_ERROR,y.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ve.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(zn(this,Ks,e),e.localName.includes("-")&&await R.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;let r=this.getAttribute(ve.AUDIO)!=null?Fe.AUDIO_PLAYER():Fe.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(ve.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=R.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=R.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){zn(this,Ks,null)}handleEvent(e){switch(e.type){case"pointerdown":zn(this,Go,e.timeStamp);break;case"pointermove":Zt(this,Sc,n0).call(this,e);break;case"pointerup":Zt(this,xc,a0).call(this,e);break;case"mouseleave":Zt(this,Qn,Ko).call(this);break;case"mouseup":this.removeAttribute(ve.KEYBOARD_CONTROL);break;case"keyup":Zt(this,Ws,Zn).call(this),this.setAttribute(ve.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);zn(this,Vs,isNaN(t)?0:t)}get autohide(){return(dr(this,Vs)===void 0?2:dr(this,Vs)).toString()}};Go=new WeakMap;Ks=new WeakMap;Xn=new WeakMap;Vs=new WeakMap;Sc=new WeakSet;n0=function(i){i.pointerType!=="mouse"&&i.timeStamp-dr(this,Go)<250||(Zt(this,Vo,Ic).call(this),clearTimeout(dr(this,Xn)),[this,this.media].includes(i.target)&&Zt(this,Ws,Zn).call(this))};xc=new WeakSet;a0=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ve.USER_INACTIVE);[this,this.media].includes(i.target)&&e?Zt(this,Qn,Ko).call(this):Zt(this,Ws,Zn).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&Zt(this,Ws,Zn).call(this)};Qn=new WeakSet;Ko=function(){if(dr(this,Vs)<0||this.hasAttribute(ve.USER_INACTIVE))return;this.setAttribute(ve.USER_INACTIVE,"");let i=new R.CustomEvent(Ki.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Vo=new WeakSet;Ic=function(){if(!this.hasAttribute(ve.USER_INACTIVE))return;this.removeAttribute(ve.USER_INACTIVE);let i=new R.CustomEvent(Ki.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Ws=new WeakSet;Zn=function(){Zt(this,Vo,Ic).call(this),clearTimeout(dr(this,Xn));let i=parseInt(this.autohide);i<0||zn(this,Xn,setTimeout(()=>{Zt(this,Qn,Ko).call(this)},i*1e3))};R.customElements.get("media-container")||R.customElements.define("media-container",Jn);var l0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dt=(i,e,t)=>(l0(i,e,"read from private field"),t?t.call(i):e.get(i)),ea=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Wo=(i,e,t,r)=>(l0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ys,qs,Yo,Ur,Yi,ur,pi=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){ea(this,Yi),ea(this,Ys,void 0),ea(this,qs,void 0),ea(this,Yo,void 0),ea(this,Ur,new Set),Wo(this,Ys,e),Wo(this,qs,t),Wo(this,Yo,new Set(r))}[Symbol.iterator](){return dt(this,Yi,ur).values()}get length(){return dt(this,Yi,ur).size}get value(){var e;return(e=[...dt(this,Yi,ur)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Wo(this,Ur,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...dt(this,Yi,ur)][e]}values(){return dt(this,Yi,ur).values()}forEach(e,t){dt(this,Yi,ur).forEach(e,t)}add(...e){var t,r;e.forEach(s=>dt(this,Ur).add(s)),!(this.value===""&&!((t=dt(this,Ys))!=null&&t.hasAttribute(`${dt(this,qs)}`)))&&((r=dt(this,Ys))==null||r.setAttribute(`${dt(this,qs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>dt(this,Ur).delete(r)),(t=dt(this,Ys))==null||t.setAttribute(`${dt(this,qs)}`,`${this.value}`)}contains(e){return dt(this,Yi,ur).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Ys=new WeakMap;qs=new WeakMap;Yo=new WeakMap;Ur=new WeakMap;Yi=new WeakSet;ur=function(){return dt(this,Ur).size?dt(this,Ur):dt(this,Yo)};var fA=(i="")=>i.split(/\s+/),d0=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?wt.CAPTIONS:wt.SUBTITLES,language:t,label:s}},Fr=(i="",e={})=>fA(i).map(t=>{let r=d0(t);return{...e,...r}}),Lc=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?d0(e):e):typeof i=="string"?Fr(i):[i]:[],qo=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,qi=(i=[])=>Array.prototype.map.call(i,qo).join(" "),mA=(i,e)=>t=>t[i]===e,u0=i=>{let e=Object.entries(i).map(([t,r])=>mA(t,r));return t=>e.every(r=>r(t))},Br=(i,e=[],t=[])=>{let r=Lc(t).map(u0),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},$r=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:u0(e);return Array.from(i.textTracks).filter(t)},jo=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(y.MEDIA_SUBTITLES_SHOWING)};var h0=i=>{var e;let{media:t,fullscreenElement:r}=i,s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){let n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()},c0="exitFullscreen"in F?"exitFullscreen":"webkitExitFullscreen"in F?"webkitExitFullscreen":"webkitCancelFullScreen"in F?"webkitCancelFullScreen":void 0,f0=i=>{var e;let{documentElement:t}=i;if(c0){let r=(e=t==null?void 0:t[c0])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},ta="fullscreenElement"in F?"fullscreenElement":"webkitFullscreenElement"in F?"webkitFullscreenElement":void 0,pA=i=>{let{documentElement:e,media:t}=i,r=e==null?void 0:e[ta];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===Kg.FULLSCREEN?t:r},m0=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=pA(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(ta in a))return xt(n,s);for(;a!=null&&a[ta];){if(a[ta]===s)return!0;a=(e=a[ta])==null?void 0:e.shadowRoot}}return!1},gA="fullscreenEnabled"in F?"fullscreenEnabled":"webkitFullscreenEnabled"in F?"webkitFullscreenEnabled":void 0,p0=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[gA])||t&&"webkitSupportsFullscreen"in t};var zo,kc=()=>{var i,e;return zo||(zo=(e=(i=F)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),zo)},g0=async(i=kc())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([vA(i,t.signal),EA(i,e)]);return t.abort(),r},vA=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),EA=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await Mo(10)}return i.volume!==e},bA=/.*Version\/.*Safari\/.*/.test(R.navigator.userAgent),Cc=(i=kc())=>R.matchMedia("(display-mode: standalone)").matches&&bA?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",wc=(i=kc())=>p0({documentElement:F,media:i}),v0=wc(),E0=Cc(),b0=!!R.WebKitPlaybackTargetAvailabilityEvent,y0=!!R.chrome;var js=i=>$r(i.media,e=>[wt.SUBTITLES,wt.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Dc=i=>$r(i.media,e=>e.mode===or.SHOWING&&[wt.SUBTITLES,wt.CAPTIONS].includes(e.kind)),Xo=(i,e)=>{let t=js(i),r=Dc(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)Br(or.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;Br(or.DISABLED,t,r),Br(or.SHOWING,t,[{language:o,label:l,kind:d}])}}},Qo=(i,e)=>i===e?!0:i==null||e==null||typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?yA(i,e):Object.entries(i).every(([t,r])=>t in e&&Qo(r,e[t])),yA=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>Qo(s,e[n])):!0};var TA=Object.values(Qt),Zo,_A=g0().then(i=>(Zo=i,Zo)),T0=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof R.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=R.customElements.get(t);r&&e instanceof r||(await R.customElements.whenDefined(t),R.customElements.upgrade(e))}))},ia={mediaError:{get(i){let{media:e}=i;return e==null?void 0:e.error},mediaEvents:["emptied","error"]},mediaErrorCode:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.error)==null?void 0:e.code},mediaEvents:["emptied","error"]},mediaErrorMessage:{get(i){var e,t;let{media:r}=i;return(t=(e=r==null?void 0:r.error)==null?void 0:e.message)!=null?t:""},mediaEvents:["emptied","error"]},mediaWidth:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?R.localStorage.removeItem("media-chrome-pref-volume"):R.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let r=R.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;ia.mediaVolume.set(+r,e),i(+r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||!Gs(i)||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[Qt.LIVE,Qt.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(TA.includes(s))return s===Qt.UNKNOWN?r:s;let n=e.duration;return n===1/0?Qt.LIVE:Number.isFinite(n)?Qt.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=ia.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===Qt.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(ia.mediaStreamType.get(i)===Qt.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return js(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return Dc(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![wt.CAPTIONS,wt.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||Xo(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=$r(t,{kind:wt.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;if(!r)return;let s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?xt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!F.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else F.pictureInPictureElement&&F.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return m0(i)},set(i,e){i?h0(e):f0(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&R.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!v0||!wc(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!E0||!Cc(e))return Ht.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(Zo===!1||(e==null?void 0:e.volume)==null)return Ht.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{Zo==null&&_A.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!y0||!((t=r==null?void 0:r.remote)!=null&&t.state))return Ht.UNSUPPORTED;if(!(e==null||e==="available"))return Ht.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!b0)return Ht.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Ht.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Ht.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Ht.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var _0={[$.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=$r(a,{kind:wt.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(b=>+b),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[$.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[$.MEDIA_PLAY_REQUEST](i,e){var t;let r="mediaPaused";if(i.mediaStreamType.get(e)===Qt.LIVE){let a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[$.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[$.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[$.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[$.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[$.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[$.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;let r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))||i[r].set(s,e)},[$.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=js(e),a=Lc(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&R.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Br(or.SHOWING,n,a)},[$.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=js(e),s=t!=null?t:[];Br(or.DISABLED,r,s)},[$.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){Xo(e,t)},[$.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[$.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[$.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[$.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[$.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[$.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var AA=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=ia,requestMap:s=_0,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(Qo(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[E,{get:b}])=>(g[E]=b(l),g),{});u(p)},h={},f,m=async(p,g)=>{var E,b,T,_,A,x,S,w,M,k,P,N,B,X,z,V;let ne=!!f;if(f={...l,...f!=null?f:{},...p},ne)return;await T0(...Object.values(p));let le=o.length>0&&g===0&&a,W=l.media!==f.media,G=((E=l.media)==null?void 0:E.textTracks)!==((b=f.media)==null?void 0:b.textTracks),oe=((T=l.media)==null?void 0:T.videoRenditions)!==((_=f.media)==null?void 0:_.videoRenditions),J=((A=l.media)==null?void 0:A.audioTracks)!==((x=f.media)==null?void 0:x.audioTracks),Ee=((S=l.media)==null?void 0:S.remote)!==((w=f.media)==null?void 0:w.remote),Ge=l.documentElement!==f.documentElement,Ye=!!l.media&&(W||le),ze=!!((M=l.media)!=null&&M.textTracks)&&(G||le),St=!!((k=l.media)!=null&&k.videoRenditions)&&(oe||le),ar=!!((P=l.media)!=null&&P.audioTracks)&&(J||le),Fs=!!((N=l.media)!=null&&N.remote)&&(Ee||le),Lg=!!l.documentElement&&(Ge||le),kg=Ye||ze||St||ar||Fs||Lg,Bs=o.length===0&&g===1&&a,Cg=!!f.media&&(W||Bs),wg=!!((B=f.media)!=null&&B.textTracks)&&(G||Bs),Dg=!!((X=f.media)!=null&&X.videoRenditions)&&(oe||Bs),Mg=!!((z=f.media)!=null&&z.audioTracks)&&(J||Bs),Pg=!!((V=f.media)!=null&&V.remote)&&(Ee||Bs),Og=!!f.documentElement&&(Ge||Bs),Ng=Cg||wg||Dg||Mg||Pg||Og;if(!(kg||Ng)){Object.entries(f).forEach(([De,Vn])=>{l[De]=Vn}),c(),f=void 0;return}Object.entries(r).forEach(([De,{get:Vn,mediaEvents:U_=[],textTracksEvents:F_=[],videoRenditionsEvents:B_=[],audioTracksEvents:$_=[],remoteEvents:H_=[],rootEvents:G_=[],stateOwnersUpdateHandlers:K_=[]}])=>{h[De]||(h[De]={});let Ft=Xe=>{let Bt=Vn(l,Xe);u({[De]:Bt})},lt;lt=h[De].mediaEvents,U_.forEach(Xe=>{lt&&Ye&&(l.media.removeEventListener(Xe,lt),h[De].mediaEvents=void 0),Cg&&(f.media.addEventListener(Xe,Ft),h[De].mediaEvents=Ft)}),lt=h[De].textTracksEvents,F_.forEach(Xe=>{var Bt,Xt;lt&&ze&&((Bt=l.media.textTracks)==null||Bt.removeEventListener(Xe,lt),h[De].textTracksEvents=void 0),wg&&((Xt=f.media.textTracks)==null||Xt.addEventListener(Xe,Ft),h[De].textTracksEvents=Ft)}),lt=h[De].videoRenditionsEvents,B_.forEach(Xe=>{var Bt,Xt;lt&&St&&((Bt=l.media.videoRenditions)==null||Bt.removeEventListener(Xe,lt),h[De].videoRenditionsEvents=void 0),Dg&&((Xt=f.media.videoRenditions)==null||Xt.addEventListener(Xe,Ft),h[De].videoRenditionsEvents=Ft)}),lt=h[De].audioTracksEvents,$_.forEach(Xe=>{var Bt,Xt;lt&&ar&&((Bt=l.media.audioTracks)==null||Bt.removeEventListener(Xe,lt),h[De].audioTracksEvents=void 0),Mg&&((Xt=f.media.audioTracks)==null||Xt.addEventListener(Xe,Ft),h[De].audioTracksEvents=Ft)}),lt=h[De].remoteEvents,H_.forEach(Xe=>{var Bt,Xt;lt&&Fs&&((Bt=l.media.remote)==null||Bt.removeEventListener(Xe,lt),h[De].remoteEvents=void 0),Pg&&((Xt=f.media.remote)==null||Xt.addEventListener(Xe,Ft),h[De].remoteEvents=Ft)}),lt=h[De].rootEvents,G_.forEach(Xe=>{lt&&Lg&&(l.documentElement.removeEventListener(Xe,lt),h[De].rootEvents=void 0),Og&&(f.documentElement.addEventListener(Xe,Ft),h[De].rootEvents=Ft)});let Ug=h[De].stateOwnersUpdateHandlers;K_.forEach(Xe=>{Ug&&kg&&Ug(),Ng&&(h[De].stateOwnersUpdateHandlers=Xe(Ft,f))})}),Object.entries(f).forEach(([De,Vn])=>{l[De]=Vn}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:E}=p;if(s[g]&&d.mediaErrorCode==null){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E!=null?E:{}).forEach(([b,T])=>{l.options[b]=T})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}},A0=AA;var Nc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pe=(i,e,t)=>(Nc(i,e,"read from private field"),t?t.call(i):e.get(i)),ji=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cr=(i,e,t,r)=>(Nc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hr=(i,e,t)=>(Nc(i,e,"access private method"),t),fr,ra,Ke,sa,gi,Jo,el,Mc,zs,na,tl,Pc,L0=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],S0=10,ye={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"},il=class extends Jn{constructor(){super(),ji(this,el),ji(this,zs),ji(this,tl),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,ji(this,fr,new pi(this,ye.HOTKEYS)),ji(this,ra,void 0),ji(this,Ke,void 0),ji(this,sa,void 0),ji(this,gi,void 0),ji(this,Jo,t=>{var r;(r=pe(this,Ke))==null||r.dispatch(t)}),this.associateElement(this);let e={};cr(this,sa,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new R.CustomEvent(Gg[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(ye.NO_HOTKEYS,ye.HOTKEYS,ye.DEFAULT_STREAM_TYPE,ye.DEFAULT_SUBTITLES,ye.DEFAULT_DURATION)}get mediaStore(){return pe(this,Ke)}set mediaStore(e){var t,r;if(pe(this,Ke)&&((t=pe(this,gi))==null||t.call(this),cr(this,gi,void 0)),cr(this,Ke,e),!pe(this,Ke)&&!this.hasAttribute(ye.NO_DEFAULT_STORE)){hr(this,el,Mc).call(this);return}cr(this,gi,(r=pe(this,Ke))==null?void 0:r.subscribe(pe(this,sa)))}get fullscreenElement(){var e;return(e=pe(this,ra))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(ye.FULLSCREEN_ELEMENT)&&this.removeAttribute(ye.FULLSCREEN_ELEMENT),cr(this,ra,e),(t=pe(this,Ke))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===ye.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(ye.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===ye.HOTKEYS)pe(this,fr).value=r;else if(e===ye.DEFAULT_SUBTITLES&&r!==t)(s=pe(this,Ke))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(ye.DEFAULT_SUBTITLES)}});else if(e===ye.DEFAULT_STREAM_TYPE)(a=pe(this,Ke))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(ye.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===ye.LIVE_EDGE_OFFSET)(o=pe(this,Ke))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(ye.LIVE_EDGE_OFFSET)?+this.getAttribute(ye.LIVE_EDGE_OFFSET):void 0}});else if(e===ye.FULLSCREEN_ELEMENT){let u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;cr(this,ra,u),(d=pe(this,Ke))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!pe(this,Ke)&&!this.hasAttribute(ye.NO_DEFAULT_STORE)&&hr(this,el,Mc).call(this),(e=pe(this,Ke))==null||e.dispatch({type:"documentelementchangerequest",detail:F}),super.connectedCallback(),pe(this,Ke)&&!pe(this,gi)&&cr(this,gi,(t=pe(this,Ke))==null?void 0:t.subscribe(pe(this,sa))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),pe(this,Ke)&&((t=pe(this,Ke))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=pe(this,Ke))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),pe(this,gi)&&((s=pe(this,gi))==null||s.call(this),cr(this,gi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=pe(this,Ke))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=pe(this,Ke))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){I0(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=kA(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,pe(this,Jo))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values($).forEach(s=>{e.removeEventListener(s,pe(this,Jo))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),pe(this,Ke)&&Object.entries(pe(this,Ke).getState()).forEach(([s,n])=>{I0([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",hr(this,tl,Pc))}disableHotkeys(){this.removeEventListener("keydown",hr(this,tl,Pc)),this.removeEventListener("keyup",hr(this,zs,na))}get hotkeys(){return pe(this,fr)}keyboardShortcutHandler(e){var t,r,s,n,a;let o=e.target;if(((s=(r=(t=o.getAttribute(ye.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!pe(this,fr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&pe(this,fr).contains("nospace")))switch(e.key){case" ":case"k":d=pe(this,Ke).getState().mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new R.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(ye.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(ye.KEYBOARD_BACKWARD_SEEK_OFFSET):S0;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(ye.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(ye.KEYBOARD_FORWARD_SEEK_OFFSET):S0;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};fr=new WeakMap;ra=new WeakMap;Ke=new WeakMap;sa=new WeakMap;gi=new WeakMap;Jo=new WeakMap;el=new WeakSet;Mc=function(){var i;this.mediaStore=A0({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(ye.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(ye.DEFAULT_DURATION)?+this.getAttribute(ye.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(ye.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(ye.LIVE_EDGE_OFFSET)?+this.getAttribute(ye.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(ye.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(ye.NO_SUBTITLES_LANG_PREF)}})};zs=new WeakSet;na=function(i){let{key:e}=i;if(!L0.includes(e)){this.removeEventListener("keyup",hr(this,zs,na));return}this.keyboardShortcutHandler(i)};tl=new WeakSet;Pc=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!L0.includes(r)){this.removeEventListener("keyup",hr(this,zs,na));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(pe(this,fr).contains(`no${r.toLowerCase()}`)||r===" "&&pe(this,fr).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",hr(this,zs,na),{once:!0})};var SA=Object.values(y),xA=Object.values(gc),k0=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(R.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ue.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>SA.includes(o)):[]},RA=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&R.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof R.customElements.get(i.nodeName.toLowerCase()))&&R.customElements.upgrade(i),xA.some(r=>r in i)},Oc=i=>RA(i)||!!k0(i).length,x0=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},R0={[y.MEDIA_SUBTITLES_LIST]:qi,[y.MEDIA_SUBTITLES_SHOWING]:qi,[y.MEDIA_SEEKABLE]:x0,[y.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(x0).join(" "),[y.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[y.MEDIA_RENDITION_LIST]:Vg,[y.MEDIA_AUDIO_TRACK_LIST]:Yg},IA=async(i,e,t)=>{var r,s;if(i.isConnected||await Mo(0),typeof t=="boolean"||t==null)return Ae(i,e,t);if(typeof t=="number")return be(i,e,t);if(typeof t=="string")return ce(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=R0[e])==null?void 0:r.call(R0,t))!=null?s:t;return i.setAttribute(e,n)},LA=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Hr=(i,e)=>{if(LA(i))return;let t=(s,n)=>{var a,o;Oc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Hr(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Oc(i)){R.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},I0=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=k0(r),n=e.toLowerCase();s.includes(n)&&IA(r,n,t)})},kA=(i,e,t)=>{Hr(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>Hr(E,e)),Array.prototype.forEach.call(f,E=>Hr(E,t))):m==="attributes"&&g===ue.MEDIA_CHROME_ATTRIBUTES&&(Oc(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>Hr(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Hr(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Hr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};R.customElements.get("media-controller")||R.customElements.define("media-controller",il);var Uc=il;var Bc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ze=(i,e,t)=>(Bc(i,e,"read from private field"),t?t.call(i):e.get(i)),Xs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},rl=(i,e,t,r)=>(Bc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),CA=(i,e,t)=>(Bc(i,e,"access private method"),t),vi,Zs,mr,Qs,nl,Fc,C0,sl={TOOLTIP_PLACEMENT:"tooltipplacement"},w0=F.createElement("template");w0.innerHTML=`
148
+ `;var lA=Object.values(y),dA="sm:384 md:576 lg:768 xl:960";function uA(i){cA(i.target,i.contentRect.width)}function cA(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ve.BREAKPOINTS))!=null?t:dA,s=hA(r),n=fA(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Ki.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function hA(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function fA(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}var Jn=class extends R.HTMLElement{constructor(){super(),Wi(this,xc),Wi(this,Rc),Wi(this,Qn),Wi(this,Ko),Wi(this,Ws),Wi(this,Ho,0),Wi(this,Ks,null),Wi(this,Xn,null),Wi(this,Vs,void 0),this.breakpointsComputed=!1,this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(u0.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;Vi(this,a=>{r||(setTimeout(()=>{uA(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Ki.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){dr(this,Ks)&&this.mediaUnsetCallback(dr(this,Ks));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ve.AUTOHIDE,ve.GESTURES_DISABLED].concat(lA).filter(e=>![y.MEDIA_RENDITION_LIST,y.MEDIA_AUDIO_TRACK_LIST,y.MEDIA_CHAPTERS_CUES,y.MEDIA_WIDTH,y.MEDIA_HEIGHT,y.MEDIA_ERROR,y.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ve.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(zn(this,Ks,e),e.localName.includes("-")&&await R.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;let r=this.getAttribute(ve.AUDIO)!=null?Be.AUDIO_PLAYER():Be.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(ve.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=R.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=R.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){zn(this,Ks,null)}handleEvent(e){switch(e.type){case"pointerdown":zn(this,Ho,e.timeStamp);break;case"pointermove":Zt(this,xc,l0).call(this,e);break;case"pointerup":Zt(this,Rc,d0).call(this,e);break;case"mouseleave":Zt(this,Qn,Go).call(this);break;case"mouseup":this.removeAttribute(ve.KEYBOARD_CONTROL);break;case"keyup":Zt(this,Ws,Zn).call(this),this.setAttribute(ve.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);zn(this,Vs,isNaN(t)?0:t)}get autohide(){return(dr(this,Vs)===void 0?2:dr(this,Vs)).toString()}};Ho=new WeakMap;Ks=new WeakMap;Xn=new WeakMap;Vs=new WeakMap;xc=new WeakSet;l0=function(i){i.pointerType!=="mouse"&&i.timeStamp-dr(this,Ho)<250||(Zt(this,Ko,Lc).call(this),clearTimeout(dr(this,Xn)),[this,this.media].includes(i.target)&&Zt(this,Ws,Zn).call(this))};Rc=new WeakSet;d0=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ve.USER_INACTIVE);[this,this.media].includes(i.target)&&e?Zt(this,Qn,Go).call(this):Zt(this,Ws,Zn).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&Zt(this,Ws,Zn).call(this)};Qn=new WeakSet;Go=function(){if(dr(this,Vs)<0||this.hasAttribute(ve.USER_INACTIVE))return;this.setAttribute(ve.USER_INACTIVE,"");let i=new R.CustomEvent(Ki.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Ko=new WeakSet;Lc=function(){if(!this.hasAttribute(ve.USER_INACTIVE))return;this.removeAttribute(ve.USER_INACTIVE);let i=new R.CustomEvent(Ki.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Ws=new WeakSet;Zn=function(){Zt(this,Ko,Lc).call(this),clearTimeout(dr(this,Xn));let i=parseInt(this.autohide);i<0||zn(this,Xn,setTimeout(()=>{Zt(this,Qn,Go).call(this)},i*1e3))};R.customElements.get("media-container")||R.customElements.define("media-container",Jn);var c0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dt=(i,e,t)=>(c0(i,e,"read from private field"),t?t.call(i):e.get(i)),ea=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vo=(i,e,t,r)=>(c0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ys,qs,Wo,Ur,Yi,ur,pi=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){ea(this,Yi),ea(this,Ys,void 0),ea(this,qs,void 0),ea(this,Wo,void 0),ea(this,Ur,new Set),Vo(this,Ys,e),Vo(this,qs,t),Vo(this,Wo,new Set(r))}[Symbol.iterator](){return dt(this,Yi,ur).values()}get length(){return dt(this,Yi,ur).size}get value(){var e;return(e=[...dt(this,Yi,ur)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Vo(this,Ur,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...dt(this,Yi,ur)][e]}values(){return dt(this,Yi,ur).values()}forEach(e,t){dt(this,Yi,ur).forEach(e,t)}add(...e){var t,r;e.forEach(s=>dt(this,Ur).add(s)),!(this.value===""&&!((t=dt(this,Ys))!=null&&t.hasAttribute(`${dt(this,qs)}`)))&&((r=dt(this,Ys))==null||r.setAttribute(`${dt(this,qs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>dt(this,Ur).delete(r)),(t=dt(this,Ys))==null||t.setAttribute(`${dt(this,qs)}`,`${this.value}`)}contains(e){return dt(this,Yi,ur).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Ys=new WeakMap;qs=new WeakMap;Wo=new WeakMap;Ur=new WeakMap;Yi=new WeakSet;ur=function(){return dt(this,Ur).size?dt(this,Ur):dt(this,Wo)};var mA=(i="")=>i.split(/\s+/),h0=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?wt.CAPTIONS:wt.SUBTITLES,language:t,label:s}},Fr=(i="",e={})=>mA(i).map(t=>{let r=h0(t);return{...e,...r}}),kc=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?h0(e):e):typeof i=="string"?Fr(i):[i]:[],Yo=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,qi=(i=[])=>Array.prototype.map.call(i,Yo).join(" "),pA=(i,e)=>t=>t[i]===e,f0=i=>{let e=Object.entries(i).map(([t,r])=>pA(t,r));return t=>e.every(r=>r(t))},Br=(i,e=[],t=[])=>{let r=kc(t).map(f0),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},$r=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:f0(e);return Array.from(i.textTracks).filter(t)},qo=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(y.MEDIA_SUBTITLES_SHOWING)};var p0=i=>{var e;let{media:t,fullscreenElement:r}=i,s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){let n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()},m0="exitFullscreen"in F?"exitFullscreen":"webkitExitFullscreen"in F?"webkitExitFullscreen":"webkitCancelFullScreen"in F?"webkitCancelFullScreen":void 0,g0=i=>{var e;let{documentElement:t}=i;if(m0){let r=(e=t==null?void 0:t[m0])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},ta="fullscreenElement"in F?"fullscreenElement":"webkitFullscreenElement"in F?"webkitFullscreenElement":void 0,gA=i=>{let{documentElement:e,media:t}=i,r=e==null?void 0:e[ta];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===Yg.FULLSCREEN?t:r},v0=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=gA(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(ta in a))return xt(n,s);for(;a!=null&&a[ta];){if(a[ta]===s)return!0;a=(e=a[ta])==null?void 0:e.shadowRoot}}return!1},vA="fullscreenEnabled"in F?"fullscreenEnabled":"webkitFullscreenEnabled"in F?"webkitFullscreenEnabled":void 0,E0=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[vA])||t&&"webkitSupportsFullscreen"in t};var jo,Cc=()=>{var i,e;return jo||(jo=(e=(i=F)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),jo)},b0=async(i=Cc())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([EA(i,t.signal),bA(i,e)]);return t.abort(),r},EA=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),bA=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await Do(10)}return i.volume!==e},yA=/.*Version\/.*Safari\/.*/.test(R.navigator.userAgent),wc=(i=Cc())=>R.matchMedia("(display-mode: standalone)").matches&&yA?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Dc=(i=Cc())=>E0({documentElement:F,media:i}),y0=Dc(),T0=wc(),_0=!!R.WebKitPlaybackTargetAvailabilityEvent,A0=!!R.chrome;var js=i=>$r(i.media,e=>[wt.SUBTITLES,wt.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Mc=i=>$r(i.media,e=>e.mode===or.SHOWING&&[wt.SUBTITLES,wt.CAPTIONS].includes(e.kind)),zo=(i,e)=>{let t=js(i),r=Mc(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)Br(or.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;Br(or.DISABLED,t,r),Br(or.SHOWING,t,[{language:o,label:l,kind:d}])}}},Xo=(i,e)=>i===e?!0:i==null||e==null||typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?TA(i,e):Object.entries(i).every(([t,r])=>t in e&&Xo(r,e[t])),TA=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>Xo(s,e[n])):!0};var _A=Object.values(Qt),Qo,AA=b0().then(i=>(Qo=i,Qo)),S0=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof R.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=R.customElements.get(t);r&&e instanceof r||(await R.customElements.whenDefined(t),R.customElements.upgrade(e))}))},ia={mediaError:{get(i){let{media:e}=i;return e==null?void 0:e.error},mediaEvents:["emptied","error"]},mediaErrorCode:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.error)==null?void 0:e.code},mediaEvents:["emptied","error"]},mediaErrorMessage:{get(i){var e,t;let{media:r}=i;return(t=(e=r==null?void 0:r.error)==null?void 0:e.message)!=null?t:""},mediaEvents:["emptied","error"]},mediaWidth:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?R.localStorage.removeItem("media-chrome-pref-volume"):R.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let r=R.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;ia.mediaVolume.set(+r,e),i(+r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||!Gs(i)||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[Qt.LIVE,Qt.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(_A.includes(s))return s===Qt.UNKNOWN?r:s;let n=e.duration;return n===1/0?Qt.LIVE:Number.isFinite(n)?Qt.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=ia.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===Qt.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(ia.mediaStreamType.get(i)===Qt.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return js(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return Mc(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![wt.CAPTIONS,wt.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||zo(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=$r(t,{kind:wt.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;if(!r)return;let s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?xt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!F.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else F.pictureInPictureElement&&F.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return v0(i)},set(i,e){i?p0(e):g0(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&R.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!y0||!Dc(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!T0||!wc(e))return Ht.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(Qo===!1||(e==null?void 0:e.volume)==null)return Ht.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{Qo==null&&AA.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!A0||!((t=r==null?void 0:r.remote)!=null&&t.state))return Ht.UNSUPPORTED;if(!(e==null||e==="available"))return Ht.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!_0)return Ht.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Ht.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Ht.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Ht.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var x0={[$.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=$r(a,{kind:wt.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(b=>+b),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[$.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[$.MEDIA_PLAY_REQUEST](i,e){var t;let r="mediaPaused";if(i.mediaStreamType.get(e)===Qt.LIVE){let a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[$.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[$.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[$.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[$.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[$.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[$.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;let r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))||i[r].set(s,e)},[$.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=js(e),a=kc(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&R.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Br(or.SHOWING,n,a)},[$.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=js(e),s=t!=null?t:[];Br(or.DISABLED,r,s)},[$.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){zo(e,t)},[$.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[$.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[$.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[$.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[$.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[$.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var SA=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=ia,requestMap:s=x0,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(Xo(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[E,{get:b}])=>(g[E]=b(l),g),{});u(p)},h={},f,m=async(p,g)=>{var E,b,T,_,A,x,S,w,M,k,P,N,B,X,z,V;let ne=!!f;if(f={...l,...f!=null?f:{},...p},ne)return;await S0(...Object.values(p));let le=o.length>0&&g===0&&a,W=l.media!==f.media,G=((E=l.media)==null?void 0:E.textTracks)!==((b=f.media)==null?void 0:b.textTracks),oe=((T=l.media)==null?void 0:T.videoRenditions)!==((_=f.media)==null?void 0:_.videoRenditions),J=((A=l.media)==null?void 0:A.audioTracks)!==((x=f.media)==null?void 0:x.audioTracks),Ee=((S=l.media)==null?void 0:S.remote)!==((w=f.media)==null?void 0:w.remote),Ge=l.documentElement!==f.documentElement,Ye=!!l.media&&(W||le),ze=!!((M=l.media)!=null&&M.textTracks)&&(G||le),St=!!((k=l.media)!=null&&k.videoRenditions)&&(oe||le),ar=!!((P=l.media)!=null&&P.audioTracks)&&(J||le),Fs=!!((N=l.media)!=null&&N.remote)&&(Ee||le),wg=!!l.documentElement&&(Ge||le),Dg=Ye||ze||St||ar||Fs||wg,Bs=o.length===0&&g===1&&a,Mg=!!f.media&&(W||Bs),Pg=!!((B=f.media)!=null&&B.textTracks)&&(G||Bs),Og=!!((X=f.media)!=null&&X.videoRenditions)&&(oe||Bs),Ng=!!((z=f.media)!=null&&z.audioTracks)&&(J||Bs),Ug=!!((V=f.media)!=null&&V.remote)&&(Ee||Bs),Fg=!!f.documentElement&&(Ge||Bs),Bg=Mg||Pg||Og||Ng||Ug||Fg;if(!(Dg||Bg)){Object.entries(f).forEach(([Me,Vn])=>{l[Me]=Vn}),c(),f=void 0;return}Object.entries(r).forEach(([Me,{get:Vn,mediaEvents:F_=[],textTracksEvents:B_=[],videoRenditionsEvents:$_=[],audioTracksEvents:H_=[],remoteEvents:G_=[],rootEvents:K_=[],stateOwnersUpdateHandlers:V_=[]}])=>{h[Me]||(h[Me]={});let Ft=Xe=>{let Bt=Vn(l,Xe);u({[Me]:Bt})},lt;lt=h[Me].mediaEvents,F_.forEach(Xe=>{lt&&Ye&&(l.media.removeEventListener(Xe,lt),h[Me].mediaEvents=void 0),Mg&&(f.media.addEventListener(Xe,Ft),h[Me].mediaEvents=Ft)}),lt=h[Me].textTracksEvents,B_.forEach(Xe=>{var Bt,Xt;lt&&ze&&((Bt=l.media.textTracks)==null||Bt.removeEventListener(Xe,lt),h[Me].textTracksEvents=void 0),Pg&&((Xt=f.media.textTracks)==null||Xt.addEventListener(Xe,Ft),h[Me].textTracksEvents=Ft)}),lt=h[Me].videoRenditionsEvents,$_.forEach(Xe=>{var Bt,Xt;lt&&St&&((Bt=l.media.videoRenditions)==null||Bt.removeEventListener(Xe,lt),h[Me].videoRenditionsEvents=void 0),Og&&((Xt=f.media.videoRenditions)==null||Xt.addEventListener(Xe,Ft),h[Me].videoRenditionsEvents=Ft)}),lt=h[Me].audioTracksEvents,H_.forEach(Xe=>{var Bt,Xt;lt&&ar&&((Bt=l.media.audioTracks)==null||Bt.removeEventListener(Xe,lt),h[Me].audioTracksEvents=void 0),Ng&&((Xt=f.media.audioTracks)==null||Xt.addEventListener(Xe,Ft),h[Me].audioTracksEvents=Ft)}),lt=h[Me].remoteEvents,G_.forEach(Xe=>{var Bt,Xt;lt&&Fs&&((Bt=l.media.remote)==null||Bt.removeEventListener(Xe,lt),h[Me].remoteEvents=void 0),Ug&&((Xt=f.media.remote)==null||Xt.addEventListener(Xe,Ft),h[Me].remoteEvents=Ft)}),lt=h[Me].rootEvents,K_.forEach(Xe=>{lt&&wg&&(l.documentElement.removeEventListener(Xe,lt),h[Me].rootEvents=void 0),Fg&&(f.documentElement.addEventListener(Xe,Ft),h[Me].rootEvents=Ft)});let $g=h[Me].stateOwnersUpdateHandlers;V_.forEach(Xe=>{$g&&Dg&&$g(),Bg&&(h[Me].stateOwnersUpdateHandlers=Xe(Ft,f))})}),Object.entries(f).forEach(([Me,Vn])=>{l[Me]=Vn}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:E}=p;if(s[g]&&d.mediaErrorCode==null){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E!=null?E:{}).forEach(([b,T])=>{l.options[b]=T})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}},R0=SA;var Uc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pe=(i,e,t)=>(Uc(i,e,"read from private field"),t?t.call(i):e.get(i)),ji=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cr=(i,e,t,r)=>(Uc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hr=(i,e,t)=>(Uc(i,e,"access private method"),t),fr,ra,Ke,sa,gi,Zo,Jo,Pc,zs,na,el,Oc,w0=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],I0=10,ye={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"},tl=class extends Jn{constructor(){super(),ji(this,Jo),ji(this,zs),ji(this,el),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,ji(this,fr,new pi(this,ye.HOTKEYS)),ji(this,ra,void 0),ji(this,Ke,void 0),ji(this,sa,void 0),ji(this,gi,void 0),ji(this,Zo,t=>{var r;(r=pe(this,Ke))==null||r.dispatch(t)}),this.associateElement(this);let e={};cr(this,sa,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new R.CustomEvent(Wg[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(ye.NO_HOTKEYS,ye.HOTKEYS,ye.DEFAULT_STREAM_TYPE,ye.DEFAULT_SUBTITLES,ye.DEFAULT_DURATION)}get mediaStore(){return pe(this,Ke)}set mediaStore(e){var t,r;if(pe(this,Ke)&&((t=pe(this,gi))==null||t.call(this),cr(this,gi,void 0)),cr(this,Ke,e),!pe(this,Ke)&&!this.hasAttribute(ye.NO_DEFAULT_STORE)){hr(this,Jo,Pc).call(this);return}cr(this,gi,(r=pe(this,Ke))==null?void 0:r.subscribe(pe(this,sa)))}get fullscreenElement(){var e;return(e=pe(this,ra))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(ye.FULLSCREEN_ELEMENT)&&this.removeAttribute(ye.FULLSCREEN_ELEMENT),cr(this,ra,e),(t=pe(this,Ke))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===ye.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(ye.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===ye.HOTKEYS)pe(this,fr).value=r;else if(e===ye.DEFAULT_SUBTITLES&&r!==t)(s=pe(this,Ke))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(ye.DEFAULT_SUBTITLES)}});else if(e===ye.DEFAULT_STREAM_TYPE)(a=pe(this,Ke))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(ye.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===ye.LIVE_EDGE_OFFSET)(o=pe(this,Ke))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(ye.LIVE_EDGE_OFFSET)?+this.getAttribute(ye.LIVE_EDGE_OFFSET):void 0}});else if(e===ye.FULLSCREEN_ELEMENT){let u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;cr(this,ra,u),(d=pe(this,Ke))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!pe(this,Ke)&&!this.hasAttribute(ye.NO_DEFAULT_STORE)&&hr(this,Jo,Pc).call(this),(e=pe(this,Ke))==null||e.dispatch({type:"documentelementchangerequest",detail:F}),super.connectedCallback(),pe(this,Ke)&&!pe(this,gi)&&cr(this,gi,(t=pe(this,Ke))==null?void 0:t.subscribe(pe(this,sa))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),pe(this,Ke)&&((t=pe(this,Ke))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=pe(this,Ke))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),pe(this,gi)&&((s=pe(this,gi))==null||s.call(this),cr(this,gi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=pe(this,Ke))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=pe(this,Ke))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){C0(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=CA(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,pe(this,Zo))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values($).forEach(s=>{e.removeEventListener(s,pe(this,Zo))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),pe(this,Ke)&&Object.entries(pe(this,Ke).getState()).forEach(([s,n])=>{C0([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",hr(this,el,Oc))}disableHotkeys(){this.removeEventListener("keydown",hr(this,el,Oc)),this.removeEventListener("keyup",hr(this,zs,na))}get hotkeys(){return pe(this,fr)}keyboardShortcutHandler(e){var t,r,s,n,a;let o=e.target;if(((s=(r=(t=o.getAttribute(ye.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!pe(this,fr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&pe(this,fr).contains("nospace")))switch(e.key){case" ":case"k":d=pe(this,Ke).getState().mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new R.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(ye.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(ye.KEYBOARD_BACKWARD_SEEK_OFFSET):I0;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(ye.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(ye.KEYBOARD_FORWARD_SEEK_OFFSET):I0;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};fr=new WeakMap;ra=new WeakMap;Ke=new WeakMap;sa=new WeakMap;gi=new WeakMap;Zo=new WeakMap;Jo=new WeakSet;Pc=function(){var i;this.mediaStore=R0({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(ye.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(ye.DEFAULT_DURATION)?+this.getAttribute(ye.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(ye.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(ye.LIVE_EDGE_OFFSET)?+this.getAttribute(ye.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(ye.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(ye.NO_SUBTITLES_LANG_PREF)}})};zs=new WeakSet;na=function(i){let{key:e}=i;if(!w0.includes(e)){this.removeEventListener("keyup",hr(this,zs,na));return}this.keyboardShortcutHandler(i)};el=new WeakSet;Oc=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!w0.includes(r)){this.removeEventListener("keyup",hr(this,zs,na));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(pe(this,fr).contains(`no${r.toLowerCase()}`)||r===" "&&pe(this,fr).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",hr(this,zs,na),{once:!0})};var xA=Object.values(y),RA=Object.values(vc),D0=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(R.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ue.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>xA.includes(o)):[]},IA=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&R.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof R.customElements.get(i.nodeName.toLowerCase()))&&R.customElements.upgrade(i),RA.some(r=>r in i)},Nc=i=>IA(i)||!!D0(i).length,L0=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},k0={[y.MEDIA_SUBTITLES_LIST]:qi,[y.MEDIA_SUBTITLES_SHOWING]:qi,[y.MEDIA_SEEKABLE]:L0,[y.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(L0).join(" "),[y.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[y.MEDIA_RENDITION_LIST]:qg,[y.MEDIA_AUDIO_TRACK_LIST]:zg},LA=async(i,e,t)=>{var r,s;if(i.isConnected||await Do(0),typeof t=="boolean"||t==null)return Ae(i,e,t);if(typeof t=="number")return be(i,e,t);if(typeof t=="string")return ce(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=k0[e])==null?void 0:r.call(k0,t))!=null?s:t;return i.setAttribute(e,n)},kA=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Hr=(i,e)=>{if(kA(i))return;let t=(s,n)=>{var a,o;Nc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Hr(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Nc(i)){R.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},C0=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=D0(r),n=e.toLowerCase();s.includes(n)&&LA(r,n,t)})},CA=(i,e,t)=>{Hr(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>Hr(E,e)),Array.prototype.forEach.call(f,E=>Hr(E,t))):m==="attributes"&&g===ue.MEDIA_CHROME_ATTRIBUTES&&(Nc(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>Hr(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Hr(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Hr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};R.customElements.get("media-controller")||R.customElements.define("media-controller",tl);var Fc=tl;var $c=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ze=(i,e,t)=>($c(i,e,"read from private field"),t?t.call(i):e.get(i)),Xs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},il=(i,e,t,r)=>($c(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wA=(i,e,t)=>($c(i,e,"access private method"),t),vi,Zs,mr,Qs,sl,Bc,M0,rl={TOOLTIP_PLACEMENT:"tooltipplacement"},P0=F.createElement("template");P0.innerHTML=`
149
149
  <style>
150
150
  :host {
151
151
  position: relative;
@@ -220,10 +220,10 @@
220
220
  <slot name="tooltip-content"></slot>
221
221
  </media-tooltip>
222
222
  </slot>
223
- `;var Me=class extends R.HTMLElement{constructor(e={}){var t;if(super(),Xs(this,Fc),Xs(this,vi,void 0),this.preventClick=!1,this.tooltipEl=null,this.tooltipContent="",Xs(this,Zs,r=>{this.preventClick||this.handleClick(r),setTimeout(Ze(this,mr),0)}),Xs(this,mr,()=>{var r,s;(s=(r=this.tooltipEl)==null?void 0:r.updateXOffset)==null||s.call(r)}),Xs(this,Qs,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Ze(this,Qs));return}this.preventClick||this.handleClick(r)}),Xs(this,nl,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",Ze(this,Qs));return}this.addEventListener("keyup",Ze(this,Qs),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let r=w0.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=F.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),e.tooltipContent&&(r.querySelector('slot[name="tooltip-content"]').innerHTML=(t=e.tooltipContent)!=null?t:"",this.tooltipContent=e.tooltipContent),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",sl.TOOLTIP_PLACEMENT,ue.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Ze(this,Zs)),this.addEventListener("keydown",Ze(this,nl)),this.tabIndex=0}disable(){this.removeEventListener("click",Ze(this,Zs)),this.removeEventListener("keydown",Ze(this,nl)),this.removeEventListener("keyup",Ze(this,Qs)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(s=Ze(this,vi))==null?void 0:s.unassociateElement)==null||n.call(s,this),rl(this,vi,null)),r&&this.isConnected&&(rl(this,vi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ze(this,vi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t?r==null?this.enable():this.disable():e===sl.TOOLTIP_PLACEMENT&&this.tooltipEl&&r!==t&&(this.tooltipEl.placement=r),Ze(this,mr).call(this)}connectedCallback(){var e,t,r;let{style:s}=we(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(rl(this,vi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Ze(this,vi))==null?void 0:t.associateElement)==null||r.call(t,this)),R.customElements.whenDefined("media-tooltip").then(()=>CA(this,Fc,C0).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Ze(this,vi))==null?void 0:e.unassociateElement)==null||t.call(e,this),rl(this,vi,null),this.removeEventListener("mouseenter",Ze(this,mr)),this.removeEventListener("focus",Ze(this,mr)),this.removeEventListener("click",Ze(this,Zs))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return me(this,sl.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){ce(this,sl.TOOLTIP_PLACEMENT,e)}handleClick(e){}};vi=new WeakMap;Zs=new WeakMap;mr=new WeakMap;Qs=new WeakMap;nl=new WeakMap;Fc=new WeakSet;C0=function(){this.addEventListener("mouseenter",Ze(this,mr)),this.addEventListener("focus",Ze(this,mr)),this.addEventListener("click",Ze(this,Zs));let i=this.tooltipPlacement;i&&this.tooltipEl&&(this.tooltipEl.placement=i)};R.customElements.get("media-chrome-button")||R.customElements.define("media-chrome-button",Me);var D0=`<svg aria-hidden="true" viewBox="0 0 26 24">
223
+ `;var Pe=class extends R.HTMLElement{constructor(e={}){var t;if(super(),Xs(this,Bc),Xs(this,vi,void 0),this.preventClick=!1,this.tooltipEl=null,this.tooltipContent="",Xs(this,Zs,r=>{this.preventClick||this.handleClick(r),setTimeout(Ze(this,mr),0)}),Xs(this,mr,()=>{var r,s;(s=(r=this.tooltipEl)==null?void 0:r.updateXOffset)==null||s.call(r)}),Xs(this,Qs,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Ze(this,Qs));return}this.preventClick||this.handleClick(r)}),Xs(this,sl,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",Ze(this,Qs));return}this.addEventListener("keyup",Ze(this,Qs),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let r=P0.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=F.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),e.tooltipContent&&(r.querySelector('slot[name="tooltip-content"]').innerHTML=(t=e.tooltipContent)!=null?t:"",this.tooltipContent=e.tooltipContent),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",rl.TOOLTIP_PLACEMENT,ue.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Ze(this,Zs)),this.addEventListener("keydown",Ze(this,sl)),this.tabIndex=0}disable(){this.removeEventListener("click",Ze(this,Zs)),this.removeEventListener("keydown",Ze(this,sl)),this.removeEventListener("keyup",Ze(this,Qs)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(s=Ze(this,vi))==null?void 0:s.unassociateElement)==null||n.call(s,this),il(this,vi,null)),r&&this.isConnected&&(il(this,vi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ze(this,vi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t?r==null?this.enable():this.disable():e===rl.TOOLTIP_PLACEMENT&&this.tooltipEl&&r!==t&&(this.tooltipEl.placement=r),Ze(this,mr).call(this)}connectedCallback(){var e,t,r;let{style:s}=De(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(il(this,vi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Ze(this,vi))==null?void 0:t.associateElement)==null||r.call(t,this)),R.customElements.whenDefined("media-tooltip").then(()=>wA(this,Bc,M0).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Ze(this,vi))==null?void 0:e.unassociateElement)==null||t.call(e,this),il(this,vi,null),this.removeEventListener("mouseenter",Ze(this,mr)),this.removeEventListener("focus",Ze(this,mr)),this.removeEventListener("click",Ze(this,Zs))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return me(this,rl.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){ce(this,rl.TOOLTIP_PLACEMENT,e)}handleClick(e){}};vi=new WeakMap;Zs=new WeakMap;mr=new WeakMap;Qs=new WeakMap;sl=new WeakMap;Bc=new WeakSet;M0=function(){this.addEventListener("mouseenter",Ze(this,mr)),this.addEventListener("focus",Ze(this,mr)),this.addEventListener("click",Ze(this,Zs));let i=this.tooltipPlacement;i&&this.tooltipEl&&(this.tooltipEl.placement=i)};R.customElements.get("media-chrome-button")||R.customElements.define("media-chrome-button",Pe);var O0=`<svg aria-hidden="true" viewBox="0 0 26 24">
224
224
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
225
225
  </svg>
226
- `,P0=F.createElement("template");P0.innerHTML=`
226
+ `,U0=F.createElement("template");U0.innerHTML=`
227
227
  <style>
228
228
  :host([${y.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
229
229
  display: none !important;
@@ -241,17 +241,17 @@
241
241
  </style>
242
242
 
243
243
  <slot name="icon">
244
- <slot name="enter">${D0}</slot>
245
- <slot name="exit">${D0}</slot>
244
+ <slot name="enter">${O0}</slot>
245
+ <slot name="exit">${O0}</slot>
246
246
  </slot>
247
- `;var wA=`
247
+ `;var DA=`
248
248
  <slot name="tooltip-enter">${he.ENTER_AIRPLAY}</slot>
249
249
  <slot name="tooltip-exit">${he.EXIT_AIRPLAY}</slot>
250
- `,M0=i=>{let e=i.mediaIsAirplaying?Be.EXIT_AIRPLAY():Be.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},$c=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_AIRPLAYING,y.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:P0,tooltipContent:wA,...e})}connectedCallback(){super.connectedCallback(),M0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_AIRPLAYING&&M0(this)}get mediaIsAirplaying(){return xe(this,y.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ae(this,y.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return me(this,y.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ce(this,y.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new R.CustomEvent($.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};R.customElements.get("media-airplay-button")||R.customElements.define("media-airplay-button",$c);var DA=`<svg aria-hidden="true" viewBox="0 0 26 24">
250
+ `,N0=i=>{let e=i.mediaIsAirplaying?$e.EXIT_AIRPLAY():$e.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},Hc=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_AIRPLAYING,y.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:U0,tooltipContent:DA,...e})}connectedCallback(){super.connectedCallback(),N0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_AIRPLAYING&&N0(this)}get mediaIsAirplaying(){return xe(this,y.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ae(this,y.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return me(this,y.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ce(this,y.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new R.CustomEvent($.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};R.customElements.get("media-airplay-button")||R.customElements.define("media-airplay-button",Hc);var MA=`<svg aria-hidden="true" viewBox="0 0 26 24">
251
251
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
252
- </svg>`,MA=`<svg aria-hidden="true" viewBox="0 0 26 24">
252
+ </svg>`,PA=`<svg aria-hidden="true" viewBox="0 0 26 24">
253
253
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
254
- </svg>`,F0=F.createElement("template");F0.innerHTML=`
254
+ </svg>`,H0=F.createElement("template");H0.innerHTML=`
255
255
  <style>
256
256
  :host([aria-checked="true"]) slot[name=off] {
257
257
  display: none !important;
@@ -269,13 +269,13 @@
269
269
  </style>
270
270
 
271
271
  <slot name="icon">
272
- <slot name="on">${DA}</slot>
273
- <slot name="off">${MA}</slot>
272
+ <slot name="on">${MA}</slot>
273
+ <slot name="off">${PA}</slot>
274
274
  </slot>
275
- `;var PA=`
275
+ `;var OA=`
276
276
  <slot name="tooltip-enable">${he.ENABLE_CAPTIONS}</slot>
277
277
  <slot name="tooltip-disable">${he.DISABLE_CAPTIONS}</slot>
278
- `,O0=i=>{i.setAttribute("aria-checked",jo(i).toString())},Hc=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:F0,tooltipContent:PA,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Fe.CLOSED_CAPTIONS()),O0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_SHOWING&&O0(this)}get mediaSubtitlesList(){return N0(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){U0(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return N0(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){U0(this,y.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new R.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},N0=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},U0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-button")||R.customElements.define("media-captions-button",Hc);var OA='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',NA='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',$0=F.createElement("template");$0.innerHTML=`
278
+ `,F0=i=>{i.setAttribute("aria-checked",qo(i).toString())},Gc=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:H0,tooltipContent:OA,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Be.CLOSED_CAPTIONS()),F0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_SHOWING&&F0(this)}get mediaSubtitlesList(){return B0(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){$0(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return B0(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){$0(this,y.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new R.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},B0=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},$0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-button")||R.customElements.define("media-captions-button",Gc);var NA='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',UA='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',K0=F.createElement("template");K0.innerHTML=`
279
279
  <style>
280
280
  :host([${y.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
281
281
  display: none !important;
@@ -293,13 +293,13 @@
293
293
  </style>
294
294
 
295
295
  <slot name="icon">
296
- <slot name="enter">${OA}</slot>
297
- <slot name="exit">${NA}</slot>
296
+ <slot name="enter">${NA}</slot>
297
+ <slot name="exit">${UA}</slot>
298
298
  </slot>
299
- `;var UA=`
299
+ `;var FA=`
300
300
  <slot name="tooltip-enter">${he.START_CAST}</slot>
301
301
  <slot name="tooltip-exit">${he.STOP_CAST}</slot>
302
- `,B0=i=>{let e=i.mediaIsCasting?Be.EXIT_CAST():Be.ENTER_CAST();i.setAttribute("aria-label",e)},Gc=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_CASTING,y.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:$0,tooltipContent:UA,...e})}connectedCallback(){super.connectedCallback(),B0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_CASTING&&B0(this)}get mediaIsCasting(){return xe(this,y.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ae(this,y.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return me(this,y.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ce(this,y.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?$.MEDIA_EXIT_CAST_REQUEST:$.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-cast-button")||R.customElements.define("media-cast-button",Gc);var zc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kr=(i,e,t)=>(zc(i,e,"read from private field"),t?t.call(i):e.get(i)),zi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xc=(i,e,t,r)=>(zc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gr=(i,e,t)=>(zc(i,e,"access private method"),t),ol,oa,Vr,al,Kc,Vc,H0,Wc,G0,Yc,K0,qc,V0,jc,W0;function FA(i){return`
302
+ `,G0=i=>{let e=i.mediaIsCasting?$e.EXIT_CAST():$e.ENTER_CAST();i.setAttribute("aria-label",e)},Kc=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_CASTING,y.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:K0,tooltipContent:FA,...e})}connectedCallback(){super.connectedCallback(),G0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_CASTING&&G0(this)}get mediaIsCasting(){return xe(this,y.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ae(this,y.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return me(this,y.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ce(this,y.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?$.MEDIA_EXIT_CAST_REQUEST:$.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-cast-button")||R.customElements.define("media-cast-button",Kc);var Xc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kr=(i,e,t)=>(Xc(i,e,"read from private field"),t?t.call(i):e.get(i)),zi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qc=(i,e,t,r)=>(Xc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gr=(i,e,t)=>(Xc(i,e,"access private method"),t),al,oa,Vr,nl,Vc,Wc,V0,Yc,W0,qc,Y0,jc,q0,zc,j0;function BA(i){return`
303
303
  <style>
304
304
  :host {
305
305
  font: var(--media-font,
@@ -339,11 +339,11 @@
339
339
  }
340
340
  </style>
341
341
  ${this.getSlotTemplateHTML(i)}
342
- `}function BA(i){return`
342
+ `}function $A(i){return`
343
343
  <slot id="content"></slot>
344
- `}var aa={OPEN:"open",ANCHOR:"anchor"},Wr=class extends R.HTMLElement{constructor(){super(),zi(this,al),zi(this,Vc),zi(this,Wc),zi(this,Yc),zi(this,qc),zi(this,jc),zi(this,ol,!1),zi(this,oa,null),zi(this,Vr,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[aa.OPEN,aa.ANCHOR]}get open(){return xe(this,aa.OPEN)}set open(e){Ae(this,aa.OPEN,e)}handleEvent(e){switch(e.type){case"invoke":Gr(this,Yc,K0).call(this,e);break;case"focusout":Gr(this,qc,V0).call(this,e);break;case"keydown":Gr(this,jc,W0).call(this,e);break}}connectedCallback(){Gr(this,al,Kc).call(this),this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){Gr(this,al,Kc).call(this),e===aa.OPEN&&r!==t&&(this.open?Gr(this,Vc,H0).call(this):Gr(this,Wc,G0).call(this))}focus(){Xc(this,oa,jn());let e=!this.dispatchEvent(new Event("focus",{composed:!0,cancelable:!0})),t=!this.dispatchEvent(new Event("focusin",{composed:!0,bubbles:!0,cancelable:!0}));if(e||t)return;let r=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');r==null||r.focus()}get keysUsed(){return["Escape","Tab"]}};ol=new WeakMap;oa=new WeakMap;Vr=new WeakMap;al=new WeakSet;Kc=function(){if(!Kr(this,ol)&&(Xc(this,ol,!0),!this.shadowRoot)){this.attachShadow({mode:"open"});let i=t0(this.attributes);this.shadowRoot.innerHTML=`
344
+ `}var aa={OPEN:"open",ANCHOR:"anchor"},Wr=class extends R.HTMLElement{constructor(){super(),zi(this,nl),zi(this,Wc),zi(this,Yc),zi(this,qc),zi(this,jc),zi(this,zc),zi(this,al,!1),zi(this,oa,null),zi(this,Vr,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[aa.OPEN,aa.ANCHOR]}get open(){return xe(this,aa.OPEN)}set open(e){Ae(this,aa.OPEN,e)}handleEvent(e){switch(e.type){case"invoke":Gr(this,qc,Y0).call(this,e);break;case"focusout":Gr(this,jc,q0).call(this,e);break;case"keydown":Gr(this,zc,j0).call(this,e);break}}connectedCallback(){Gr(this,nl,Vc).call(this),this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){Gr(this,nl,Vc).call(this),e===aa.OPEN&&r!==t&&(this.open?Gr(this,Wc,V0).call(this):Gr(this,Yc,W0).call(this))}focus(){Qc(this,oa,jn());let e=!this.dispatchEvent(new Event("focus",{composed:!0,cancelable:!0})),t=!this.dispatchEvent(new Event("focusin",{composed:!0,bubbles:!0,cancelable:!0}));if(e||t)return;let r=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');r==null||r.focus()}get keysUsed(){return["Escape","Tab"]}};al=new WeakMap;oa=new WeakMap;Vr=new WeakMap;nl=new WeakSet;Vc=function(){if(!Kr(this,al)&&(Qc(this,al,!0),!this.shadowRoot)){this.attachShadow({mode:"open"});let i=s0(this.attributes);this.shadowRoot.innerHTML=`
345
345
  ${this.constructor.getTemplateHTML(i)}
346
- `}};Vc=new WeakSet;H0=function(){var i;(i=Kr(this,Vr))==null||i.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Wc=new WeakSet;G0=function(){var i;(i=Kr(this,Vr))==null||i.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))};Yc=new WeakSet;K0=function(i){Xc(this,Vr,i.relatedTarget),xt(this,i.relatedTarget)||(this.open=!this.open)};qc=new WeakSet;V0=function(i){var e;xt(this,i.relatedTarget)||((e=Kr(this,oa))==null||e.focus(),Kr(this,Vr)&&Kr(this,Vr)!==i.relatedTarget&&this.open&&(this.open=!1))};jc=new WeakSet;W0=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=Kr(this,oa))==null||n.focus(),this.open=!1))};Wr.getTemplateHTML=FA;Wr.getSlotTemplateHTML=BA;R.customElements.get("media-chrome-dialog")||R.customElements.define("media-chrome-dialog",Wr);var rh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},qe=(i,e,t)=>(rh(i,e,"read from private field"),t?t.call(i):e.get(i)),Et=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},pr=(i,e,t,r)=>(rh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Jt=(i,e,t)=>(rh(i,e,"access private method"),t),Ei,vl,ll,dl,ei,pl,ul,cl,hl,sh,Y0,fl,Qc,ml,Zc,gl,nh,Jc,q0,eh,j0,th,z0,ih,X0,Q0=F.createElement("template");Q0.innerHTML=`
346
+ `}};Wc=new WeakSet;V0=function(){var i;(i=Kr(this,Vr))==null||i.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Yc=new WeakSet;W0=function(){var i;(i=Kr(this,Vr))==null||i.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))};qc=new WeakSet;Y0=function(i){Qc(this,Vr,i.relatedTarget),xt(this,i.relatedTarget)||(this.open=!this.open)};jc=new WeakSet;q0=function(i){var e;xt(this,i.relatedTarget)||((e=Kr(this,oa))==null||e.focus(),Kr(this,Vr)&&Kr(this,Vr)!==i.relatedTarget&&this.open&&(this.open=!1))};zc=new WeakSet;j0=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=Kr(this,oa))==null||n.focus(),this.open=!1))};Wr.getTemplateHTML=BA;Wr.getSlotTemplateHTML=$A;R.customElements.get("media-chrome-dialog")||R.customElements.define("media-chrome-dialog",Wr);var sh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},qe=(i,e,t)=>(sh(i,e,"read from private field"),t?t.call(i):e.get(i)),Et=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},pr=(i,e,t,r)=>(sh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Jt=(i,e,t)=>(sh(i,e,"access private method"),t),Ei,gl,ol,ll,ei,ml,dl,ul,cl,nh,z0,hl,Zc,fl,Jc,pl,ah,eh,X0,th,Q0,ih,Z0,rh,J0,ev=F.createElement("template");ev.innerHTML=`
347
347
  <style>
348
348
  :host {
349
349
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -565,7 +565,7 @@
565
565
  <input id="range" type="range" min="0" max="1" step="any" value="0">
566
566
  </div>
567
567
  <div id="rightgap"></div>
568
- `;var Yr=class extends R.HTMLElement{constructor(){super(),Et(this,sh),Et(this,fl),Et(this,ml),Et(this,gl),Et(this,Jc),Et(this,eh),Et(this,th),Et(this,ih),Et(this,Ei,void 0),Et(this,vl,void 0),Et(this,ll,void 0),Et(this,dl,void 0),Et(this,ei,{}),Et(this,pl,[]),Et(this,ul,()=>{if(this.range.matches(":focus-visible")){let{style:e}=we(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Et(this,cl,()=>{let{style:e}=we(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),Et(this,hl,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Q0.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),pr(this,ll,this.shadowRoot.querySelector("#startpoint")),pr(this,dl,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(s=qe(this,Ei))==null?void 0:s.unassociateElement)==null||n.call(s,this),pr(this,Ei,null)),r&&this.isConnected&&(pr(this,Ei,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=qe(this,Ei))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Jt(this,fl,Qc).call(this)):(this.range.setAttribute(e,r),Jt(this,ml,Zc).call(this)))}connectedCallback(){var e,t,r;let{style:s}=we(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),qe(this,ei).pointer=we(this.shadowRoot,"#pointer"),qe(this,ei).progress=we(this.shadowRoot,"#progress"),qe(this,ei).thumb=we(this.shadowRoot,"#thumb"),qe(this,ei).activeSegment=we(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(pr(this,Ei,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=qe(this,Ei))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",qe(this,ul)),this.shadowRoot.addEventListener("focusout",qe(this,cl)),Jt(this,fl,Qc).call(this),Vi(this.container,qe(this,hl))}disconnectedCallback(){var e,t;Jt(this,ml,Zc).call(this),(t=(e=qe(this,Ei))==null?void 0:e.unassociateElement)==null||t.call(e,this),pr(this,Ei,null),this.shadowRoot.removeEventListener("focusin",qe(this,ul)),this.shadowRoot.removeEventListener("focusout",qe(this,cl)),Or(this.container,qe(this,hl))}updatePointerBar(e){var t;(t=qe(this,ei).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=qe(this,ei).progress)==null||e.style.setProperty("width",`${r}%`),(t=qe(this,ei).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];pr(this,pl,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=F.createElementNS("http://www.w3.org/2000/svg","rect"),f=we(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){let t=i0(e.clientX,e.clientY,qe(this,ll).getBoundingClientRect(),qe(this,dl).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Jt(this,ih,X0).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Jt(this,Jc,q0).call(this,e);break;case"pointerdown":Jt(this,gl,nh).call(this,e);break;case"pointerup":Jt(this,eh,j0).call(this);break;case"pointerleave":Jt(this,th,z0).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Ei=new WeakMap;vl=new WeakMap;ll=new WeakMap;dl=new WeakMap;ei=new WeakMap;pl=new WeakMap;ul=new WeakMap;cl=new WeakMap;hl=new WeakMap;sh=new WeakSet;Y0=function(i){let e=qe(this,ei).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${qe(this,pl).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};fl=new WeakSet;Qc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};ml=new WeakSet;Zc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=R.window)==null||i.removeEventListener("pointerup",this),(e=R.window)==null||e.removeEventListener("pointermove",this)};gl=new WeakSet;nh=function(i){var e;pr(this,vl,i.composedPath().includes(this.range)),(e=R.window)==null||e.addEventListener("pointerup",this)};Jc=new WeakSet;q0=function(i){var e;i.pointerType!=="mouse"&&Jt(this,gl,nh).call(this,i),this.addEventListener("pointerleave",this),(e=R.window)==null||e.addEventListener("pointermove",this)};eh=new WeakSet;j0=function(){var i;(i=R.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};th=new WeakSet;z0=function(){var i,e;this.removeEventListener("pointerleave",this),(i=R.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=qe(this,ei).activeSegment)==null||e.style.removeProperty("transform")};ih=new WeakSet;X0=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Jt(this,sh,Y0).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!qe(this,vl))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};R.customElements.get("media-chrome-range")||R.customElements.define("media-chrome-range",Yr);var Z0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},El=(i,e,t)=>(Z0(i,e,"read from private field"),t?t.call(i):e.get(i)),$A=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},bl=(i,e,t,r)=>(Z0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),bi,J0=F.createElement("template");J0.innerHTML=`
568
+ `;var Yr=class extends R.HTMLElement{constructor(){super(),Et(this,nh),Et(this,hl),Et(this,fl),Et(this,pl),Et(this,eh),Et(this,th),Et(this,ih),Et(this,rh),Et(this,Ei,void 0),Et(this,gl,void 0),Et(this,ol,void 0),Et(this,ll,void 0),Et(this,ei,{}),Et(this,ml,[]),Et(this,dl,()=>{if(this.range.matches(":focus-visible")){let{style:e}=De(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Et(this,ul,()=>{let{style:e}=De(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),Et(this,cl,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ev.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),pr(this,ol,this.shadowRoot.querySelector("#startpoint")),pr(this,ll,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(s=qe(this,Ei))==null?void 0:s.unassociateElement)==null||n.call(s,this),pr(this,Ei,null)),r&&this.isConnected&&(pr(this,Ei,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=qe(this,Ei))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Jt(this,hl,Zc).call(this)):(this.range.setAttribute(e,r),Jt(this,fl,Jc).call(this)))}connectedCallback(){var e,t,r;let{style:s}=De(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),qe(this,ei).pointer=De(this.shadowRoot,"#pointer"),qe(this,ei).progress=De(this.shadowRoot,"#progress"),qe(this,ei).thumb=De(this.shadowRoot,"#thumb"),qe(this,ei).activeSegment=De(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(pr(this,Ei,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=qe(this,Ei))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",qe(this,dl)),this.shadowRoot.addEventListener("focusout",qe(this,ul)),Jt(this,hl,Zc).call(this),Vi(this.container,qe(this,cl))}disconnectedCallback(){var e,t;Jt(this,fl,Jc).call(this),(t=(e=qe(this,Ei))==null?void 0:e.unassociateElement)==null||t.call(e,this),pr(this,Ei,null),this.shadowRoot.removeEventListener("focusin",qe(this,dl)),this.shadowRoot.removeEventListener("focusout",qe(this,ul)),Or(this.container,qe(this,cl))}updatePointerBar(e){var t;(t=qe(this,ei).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=qe(this,ei).progress)==null||e.style.setProperty("width",`${r}%`),(t=qe(this,ei).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];pr(this,ml,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=F.createElementNS("http://www.w3.org/2000/svg","rect"),f=De(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){let t=n0(e.clientX,e.clientY,qe(this,ol).getBoundingClientRect(),qe(this,ll).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Jt(this,rh,J0).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Jt(this,eh,X0).call(this,e);break;case"pointerdown":Jt(this,pl,ah).call(this,e);break;case"pointerup":Jt(this,th,Q0).call(this);break;case"pointerleave":Jt(this,ih,Z0).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Ei=new WeakMap;gl=new WeakMap;ol=new WeakMap;ll=new WeakMap;ei=new WeakMap;ml=new WeakMap;dl=new WeakMap;ul=new WeakMap;cl=new WeakMap;nh=new WeakSet;z0=function(i){let e=qe(this,ei).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${qe(this,ml).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};hl=new WeakSet;Zc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};fl=new WeakSet;Jc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=R.window)==null||i.removeEventListener("pointerup",this),(e=R.window)==null||e.removeEventListener("pointermove",this)};pl=new WeakSet;ah=function(i){var e;pr(this,gl,i.composedPath().includes(this.range)),(e=R.window)==null||e.addEventListener("pointerup",this)};eh=new WeakSet;X0=function(i){var e;i.pointerType!=="mouse"&&Jt(this,pl,ah).call(this,i),this.addEventListener("pointerleave",this),(e=R.window)==null||e.addEventListener("pointermove",this)};th=new WeakSet;Q0=function(){var i;(i=R.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};ih=new WeakSet;Z0=function(){var i,e;this.removeEventListener("pointerleave",this),(i=R.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=qe(this,ei).activeSegment)==null||e.style.removeProperty("transform")};rh=new WeakSet;J0=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Jt(this,nh,z0).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!qe(this,gl))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};R.customElements.get("media-chrome-range")||R.customElements.define("media-chrome-range",Yr);var tv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vl=(i,e,t)=>(tv(i,e,"read from private field"),t?t.call(i):e.get(i)),HA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},El=(i,e,t,r)=>(tv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),bi,iv=F.createElement("template");iv.innerHTML=`
569
569
  <style>
570
570
  :host {
571
571
 
@@ -591,7 +591,7 @@
591
591
  </style>
592
592
 
593
593
  <slot></slot>
594
- `;var ah=class extends R.HTMLElement{constructor(){super(),$A(this,bi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(J0.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=El(this,bi))==null?void 0:s.unassociateElement)==null||n.call(s,this),bl(this,bi,null)),r&&this.isConnected&&(bl(this,bi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=El(this,bi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(bl(this,bi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=El(this,bi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=El(this,bi))==null?void 0:e.unassociateElement)==null||t.call(e,this),bl(this,bi,null)}};bi=new WeakMap;R.customElements.get("media-control-bar")||R.customElements.define("media-control-bar",ah);var ev=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},yl=(i,e,t)=>(ev(i,e,"read from private field"),t?t.call(i):e.get(i)),HA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Tl=(i,e,t,r)=>(ev(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),yi,tv=F.createElement("template");tv.innerHTML=`
594
+ `;var oh=class extends R.HTMLElement{constructor(){super(),HA(this,bi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(iv.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=vl(this,bi))==null?void 0:s.unassociateElement)==null||n.call(s,this),El(this,bi,null)),r&&this.isConnected&&(El(this,bi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=vl(this,bi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(El(this,bi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=vl(this,bi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=vl(this,bi))==null?void 0:e.unassociateElement)==null||t.call(e,this),El(this,bi,null)}};bi=new WeakMap;R.customElements.get("media-control-bar")||R.customElements.define("media-control-bar",oh);var rv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bl=(i,e,t)=>(rv(i,e,"read from private field"),t?t.call(i):e.get(i)),GA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yl=(i,e,t,r)=>(rv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),yi,sv=F.createElement("template");sv.innerHTML=`
595
595
  <style>
596
596
  :host {
597
597
  font: var(--media-font,
@@ -624,7 +624,7 @@
624
624
  }
625
625
  </style>
626
626
  <slot></slot>
627
- `;var ti=class extends R.HTMLElement{constructor(){super(),HA(this,yi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(tv.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=yl(this,yi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Tl(this,yi,null)),r&&this.isConnected&&(Tl(this,yi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=yl(this,yi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=we(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(Tl(this,yi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=yl(this,yi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=yl(this,yi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Tl(this,yi,null)}};yi=new WeakMap;R.customElements.get("media-text-display")||R.customElements.define("media-text-display",ti);var rv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},iv=(i,e,t)=>(rv(i,e,"read from private field"),t?t.call(i):e.get(i)),GA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},KA=(i,e,t,r)=>(rv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),la,oh=class extends ti{constructor(){super(),GA(this,la,void 0),KA(this,la,this.shadowRoot.querySelector("slot")),iv(this,la).textContent=fi(0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===y.MEDIA_DURATION&&(iv(this,la).textContent=fi(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}};la=new WeakMap;R.customElements.get("media-duration-display")||R.customElements.define("media-duration-display",oh);var nv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},VA=(i,e,t)=>(nv(i,e,"read from private field"),t?t.call(i):e.get(i)),WA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},YA=(i,e,t,r)=>(nv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_l;function qA(i){return`
627
+ `;var ti=class extends R.HTMLElement{constructor(){super(),GA(this,yi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sv.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=bl(this,yi))==null?void 0:s.unassociateElement)==null||n.call(s,this),yl(this,yi,null)),r&&this.isConnected&&(yl(this,yi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=bl(this,yi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=De(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(yl(this,yi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=bl(this,yi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=bl(this,yi))==null?void 0:e.unassociateElement)==null||t.call(e,this),yl(this,yi,null)}};yi=new WeakMap;R.customElements.get("media-text-display")||R.customElements.define("media-text-display",ti);var av=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nv=(i,e,t)=>(av(i,e,"read from private field"),t?t.call(i):e.get(i)),KA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},VA=(i,e,t,r)=>(av(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),la,lh=class extends ti{constructor(){super(),KA(this,la,void 0),VA(this,la,this.shadowRoot.querySelector("slot")),nv(this,la).textContent=fi(0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===y.MEDIA_DURATION&&(nv(this,la).textContent=fi(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}};la=new WeakMap;R.customElements.get("media-duration-display")||R.customElements.define("media-duration-display",lh);var lv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},WA=(i,e,t)=>(lv(i,e,"read from private field"),t?t.call(i):e.get(i)),YA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qA=(i,e,t,r)=>(lv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Tl;function jA(i){return`
628
628
  <style>
629
629
  :host {
630
630
  background: rgb(20 20 30 / .8);
@@ -641,13 +641,13 @@
641
641
  }
642
642
  </style>
643
643
  <slot name="error-${i.mediaerrorcode}" id="content">
644
- ${av({code:+i.mediaerrorcode,message:i.mediaerrormessage})}
644
+ ${dv({code:+i.mediaerrorcode,message:i.mediaerrormessage})}
645
645
  </slot>
646
- `}function jA(i){return i.code&&Ec(i)!==null}function av(i){var e;let{title:t,message:r}=(e=Ec(i))!=null?e:{},s="";return t&&(s+=`<slot name="error-${i.code}-title"><h3>${t}</h3></slot>`),r&&(s+=`<slot name="error-${i.code}-message"><p>${r}</p></slot>`),s}var sv=[y.MEDIA_ERROR_CODE,y.MEDIA_ERROR_MESSAGE],Js=class extends Wr{constructor(){super(...arguments),WA(this,_l,null)}static get observedAttributes(){return[...super.observedAttributes,...sv]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),!sv.includes(e))return;let n=(s=this.mediaError)!=null?s:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=jA(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n))}get mediaError(){return VA(this,_l)}set mediaError(e){YA(this,_l,e)}get mediaErrorCode(){return fe(this,"mediaerrorcode")}set mediaErrorCode(e){be(this,"mediaerrorcode",e)}get mediaErrorMessage(){return me(this,"mediaerrormessage")}set mediaErrorMessage(e){ce(this,"mediaerrormessage",e)}};_l=new WeakMap;Js.getSlotTemplateHTML=qA;Js.formatErrorMessage=av;R.customElements.get("media-error-dialog")||R.customElements.define("media-error-dialog",Js);var Al=Js;var zA=`<svg aria-hidden="true" viewBox="0 0 26 24">
646
+ `}function zA(i){return i.code&&bc(i)!==null}function dv(i){var e;let{title:t,message:r}=(e=bc(i))!=null?e:{},s="";return t&&(s+=`<slot name="error-${i.code}-title"><h3>${t}</h3></slot>`),r&&(s+=`<slot name="error-${i.code}-message"><p>${r}</p></slot>`),s}var ov=[y.MEDIA_ERROR_CODE,y.MEDIA_ERROR_MESSAGE],Js=class extends Wr{constructor(){super(...arguments),YA(this,Tl,null)}static get observedAttributes(){return[...super.observedAttributes,...ov]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),!ov.includes(e))return;let n=(s=this.mediaError)!=null?s:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=zA(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n))}get mediaError(){return WA(this,Tl)}set mediaError(e){qA(this,Tl,e)}get mediaErrorCode(){return fe(this,"mediaerrorcode")}set mediaErrorCode(e){be(this,"mediaerrorcode",e)}get mediaErrorMessage(){return me(this,"mediaerrormessage")}set mediaErrorMessage(e){ce(this,"mediaerrormessage",e)}};Tl=new WeakMap;Js.getSlotTemplateHTML=jA;Js.formatErrorMessage=dv;R.customElements.get("media-error-dialog")||R.customElements.define("media-error-dialog",Js);var _l=Js;var XA=`<svg aria-hidden="true" viewBox="0 0 26 24">
647
647
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
648
- </svg>`,XA=`<svg aria-hidden="true" viewBox="0 0 26 24">
648
+ </svg>`,QA=`<svg aria-hidden="true" viewBox="0 0 26 24">
649
649
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
650
- </svg>`,lv=F.createElement("template");lv.innerHTML=`
650
+ </svg>`,cv=F.createElement("template");cv.innerHTML=`
651
651
  <style>
652
652
  :host([${y.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
653
653
  display: none !important;
@@ -665,13 +665,13 @@
665
665
  </style>
666
666
 
667
667
  <slot name="icon">
668
- <slot name="enter">${zA}</slot>
669
- <slot name="exit">${XA}</slot>
668
+ <slot name="enter">${XA}</slot>
669
+ <slot name="exit">${QA}</slot>
670
670
  </slot>
671
- `;var QA=`
671
+ `;var ZA=`
672
672
  <slot name="tooltip-enter">${he.ENTER_FULLSCREEN}</slot>
673
673
  <slot name="tooltip-exit">${he.EXIT_FULLSCREEN}</slot>
674
- `,ov=i=>{let e=i.mediaIsFullscreen?Be.EXIT_FULLSCREEN():Be.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},lh=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_FULLSCREEN,y.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:lv,tooltipContent:QA,...e})}connectedCallback(){super.connectedCallback(),ov(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_FULLSCREEN&&ov(this)}get mediaFullscreenUnavailable(){return me(this,y.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ce(this,y.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return xe(this,y.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ae(this,y.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-fullscreen-button")||R.customElements.define("media-fullscreen-button",lh);var{MEDIA_TIME_IS_LIVE:Sl,MEDIA_PAUSED:da}=y,{MEDIA_SEEK_TO_LIVE_REQUEST:ZA,MEDIA_PLAY_REQUEST:JA}=$,eS='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',uv=F.createElement("template");uv.innerHTML=`
674
+ `,uv=i=>{let e=i.mediaIsFullscreen?$e.EXIT_FULLSCREEN():$e.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},dh=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_FULLSCREEN,y.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:cv,tooltipContent:ZA,...e})}connectedCallback(){super.connectedCallback(),uv(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_IS_FULLSCREEN&&uv(this)}get mediaFullscreenUnavailable(){return me(this,y.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ce(this,y.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return xe(this,y.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ae(this,y.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-fullscreen-button")||R.customElements.define("media-fullscreen-button",dh);var{MEDIA_TIME_IS_LIVE:Al,MEDIA_PAUSED:da}=y,{MEDIA_SEEK_TO_LIVE_REQUEST:JA,MEDIA_PLAY_REQUEST:eS}=$,tS='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',fv=F.createElement("template");fv.innerHTML=`
675
675
  <style>
676
676
  :host { --media-tooltip-display: none; }
677
677
 
@@ -683,22 +683,22 @@
683
683
  color: var(--media-live-button-icon-color, rgb(140, 140, 140));
684
684
  }
685
685
 
686
- :host([${Sl}]:not([${da}])) slot[name=indicator] > *,
687
- :host([${Sl}]:not([${da}])) ::slotted([slot=indicator]) {
686
+ :host([${Al}]:not([${da}])) slot[name=indicator] > *,
687
+ :host([${Al}]:not([${da}])) ::slotted([slot=indicator]) {
688
688
  fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
689
689
  color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
690
690
  }
691
691
 
692
- :host([${Sl}]:not([${da}])) {
692
+ :host([${Al}]:not([${da}])) {
693
693
  cursor: not-allowed;
694
694
  }
695
695
 
696
696
  </style>
697
697
 
698
- <slot name="indicator">${eS}</slot>
698
+ <slot name="indicator">${tS}</slot>
699
699
 
700
700
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
701
- `;var dv=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Be.SEEK_LIVE():Be.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},dh=class extends Me{static get observedAttributes(){return[...super.observedAttributes,da,Sl]}constructor(e={}){super({slotTemplate:uv,...e})}connectedCallback(){dv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),dv(this)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return xe(this,y.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ae(this,y.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new R.CustomEvent(ZA,{composed:!0,bubbles:!0})),this.hasAttribute(da)&&this.dispatchEvent(new R.CustomEvent(JA,{composed:!0,bubbles:!0})))}};R.customElements.get("media-live-button")||R.customElements.define("media-live-button",dh);var fv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ua=(i,e,t)=>(fv(i,e,"read from private field"),t?t.call(i):e.get(i)),cv=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ca=(i,e,t,r)=>(fv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ti,xl,hv={LOADING_DELAY:"loadingdelay"},mv=500,pv=F.createElement("template"),tS=`
701
+ `;var hv=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?$e.SEEK_LIVE():$e.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},uh=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,da,Al]}constructor(e={}){super({slotTemplate:fv,...e})}connectedCallback(){hv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),hv(this)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return xe(this,y.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ae(this,y.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new R.CustomEvent(JA,{composed:!0,bubbles:!0})),this.hasAttribute(da)&&this.dispatchEvent(new R.CustomEvent(eS,{composed:!0,bubbles:!0})))}};R.customElements.get("media-live-button")||R.customElements.define("media-live-button",uh);var gv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ua=(i,e,t)=>(gv(i,e,"read from private field"),t?t.call(i):e.get(i)),mv=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ca=(i,e,t,r)=>(gv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ti,Sl,pv={LOADING_DELAY:"loadingdelay"},vv=500,Ev=F.createElement("template"),iS=`
702
702
  <svg aria-hidden="true" viewBox="0 0 100 100">
703
703
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
704
704
  <animateTransform
@@ -711,13 +711,13 @@
711
711
  repeatCount="indefinite" />
712
712
  </path>
713
713
  </svg>
714
- `;pv.innerHTML=`
714
+ `;Ev.innerHTML=`
715
715
  <style>
716
716
  :host {
717
717
  display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
718
718
  vertical-align: middle;
719
719
  box-sizing: border-box;
720
- --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${mv}ms);
720
+ --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${vv}ms);
721
721
  }
722
722
 
723
723
  #status {
@@ -756,15 +756,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
756
756
  }
757
757
  </style>
758
758
 
759
- <slot name="icon">${tS}</slot>
760
- <div id="status" role="status" aria-live="polite">${Fe.MEDIA_LOADING()}</div>
761
- `;var uh=class extends R.HTMLElement{constructor(){if(super(),cv(this,Ti,void 0),cv(this,xl,mv),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=pv.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PAUSED,y.MEDIA_LOADING,hv.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===hv.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=ua(this,Ti))==null?void 0:s.unassociateElement)==null||n.call(s,this),ca(this,Ti,null)),r&&this.isConnected&&(ca(this,Ti,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ua(this,Ti))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(ca(this,Ti,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ua(this,Ti))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ua(this,Ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),ca(this,Ti,null)}get loadingDelay(){return ua(this,xl)}set loadingDelay(e){ca(this,xl,e);let{style:t}=we(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaLoading(){return xe(this,y.MEDIA_LOADING)}set mediaLoading(e){Ae(this,y.MEDIA_LOADING,e)}};Ti=new WeakMap;xl=new WeakMap;R.customElements.get("media-loading-indicator")||R.customElements.define("media-loading-indicator",uh);var{MEDIA_VOLUME_LEVEL:qr}=y,iS=`<svg aria-hidden="true" viewBox="0 0 24 24">
759
+ <slot name="icon">${iS}</slot>
760
+ <div id="status" role="status" aria-live="polite">${Be.MEDIA_LOADING()}</div>
761
+ `;var ch=class extends R.HTMLElement{constructor(){if(super(),mv(this,Ti,void 0),mv(this,Sl,vv),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=Ev.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PAUSED,y.MEDIA_LOADING,pv.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pv.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=ua(this,Ti))==null?void 0:s.unassociateElement)==null||n.call(s,this),ca(this,Ti,null)),r&&this.isConnected&&(ca(this,Ti,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ua(this,Ti))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(ca(this,Ti,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ua(this,Ti))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ua(this,Ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),ca(this,Ti,null)}get loadingDelay(){return ua(this,Sl)}set loadingDelay(e){ca(this,Sl,e);let{style:t}=De(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaLoading(){return xe(this,y.MEDIA_LOADING)}set mediaLoading(e){Ae(this,y.MEDIA_LOADING,e)}};Ti=new WeakMap;Sl=new WeakMap;R.customElements.get("media-loading-indicator")||R.customElements.define("media-loading-indicator",ch);var{MEDIA_VOLUME_LEVEL:qr}=y,rS=`<svg aria-hidden="true" viewBox="0 0 24 24">
762
762
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
763
- </svg>`,gv=`<svg aria-hidden="true" viewBox="0 0 24 24">
763
+ </svg>`,bv=`<svg aria-hidden="true" viewBox="0 0 24 24">
764
764
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
765
- </svg>`,rS=`<svg aria-hidden="true" viewBox="0 0 24 24">
765
+ </svg>`,sS=`<svg aria-hidden="true" viewBox="0 0 24 24">
766
766
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
767
- </svg>`,Ev=F.createElement("template");Ev.innerHTML=`
767
+ </svg>`,Tv=F.createElement("template");Tv.innerHTML=`
768
768
  <style>
769
769
 
770
770
  :host(:not([${qr}])) slot[name=icon] slot:not([name=high]),
@@ -791,17 +791,17 @@ svg, img, ::slotted(svg), ::slotted(img) {
791
791
  </style>
792
792
 
793
793
  <slot name="icon">
794
- <slot name="off">${iS}</slot>
795
- <slot name="low">${gv}</slot>
796
- <slot name="medium">${gv}</slot>
797
- <slot name="high">${rS}</slot>
794
+ <slot name="off">${rS}</slot>
795
+ <slot name="low">${bv}</slot>
796
+ <slot name="medium">${bv}</slot>
797
+ <slot name="high">${sS}</slot>
798
798
  </slot>
799
- `;var sS=`
799
+ `;var nS=`
800
800
  <slot name="tooltip-mute">${he.MUTE}</slot>
801
801
  <slot name="tooltip-unmute">${he.UNMUTE}</slot>
802
- `,vv=i=>{let t=i.mediaVolumeLevel==="off"?Be.UNMUTE():Be.MUTE();i.setAttribute("aria-label",t)},ch=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Ev,tooltipContent:sS,...e})}connectedCallback(){vv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_VOLUME_LEVEL&&vv(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return me(this,y.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ce(this,y.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-mute-button")||R.customElements.define("media-mute-button",ch);var bv=`<svg aria-hidden="true" viewBox="0 0 28 24">
802
+ `,yv=i=>{let t=i.mediaVolumeLevel==="off"?$e.UNMUTE():$e.MUTE();i.setAttribute("aria-label",t)},hh=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Tv,tooltipContent:nS,...e})}connectedCallback(){yv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_VOLUME_LEVEL&&yv(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return me(this,y.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ce(this,y.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-mute-button")||R.customElements.define("media-mute-button",hh);var _v=`<svg aria-hidden="true" viewBox="0 0 28 24">
803
803
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
804
- </svg>`,Tv=F.createElement("template");Tv.innerHTML=`
804
+ </svg>`,Sv=F.createElement("template");Sv.innerHTML=`
805
805
  <style>
806
806
  :host([${y.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
807
807
  display: none !important;
@@ -819,13 +819,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
819
819
  </style>
820
820
 
821
821
  <slot name="icon">
822
- <slot name="enter">${bv}</slot>
823
- <slot name="exit">${bv}</slot>
822
+ <slot name="enter">${_v}</slot>
823
+ <slot name="exit">${_v}</slot>
824
824
  </slot>
825
- `;var nS=`
825
+ `;var aS=`
826
826
  <slot name="tooltip-enter">${he.ENTER_PIP}</slot>
827
827
  <slot name="tooltip-exit">${he.EXIT_PIP}</slot>
828
- `,yv=i=>{let e=i.mediaIsPip?Be.EXIT_PIP():Be.ENTER_PIP();i.setAttribute("aria-label",e)},hh=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_PIP,y.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Tv,tooltipContent:nS,...e})}connectedCallback(){yv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_IS_PIP&&yv(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return me(this,y.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ce(this,y.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return xe(this,y.MEDIA_IS_PIP)}set mediaIsPip(e){Ae(this,y.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?$.MEDIA_EXIT_PIP_REQUEST:$.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-pip-button")||R.customElements.define("media-pip-button",hh);var aS=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Rl=(i,e,t)=>(aS(i,e,"read from private field"),t?t.call(i):e.get(i)),oS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},en,fh={RATES:"rates"},ph=[1,1.2,1.5,1.7,2],tn=1,_v=F.createElement("template");_v.innerHTML=`
828
+ `,Av=i=>{let e=i.mediaIsPip?$e.EXIT_PIP():$e.ENTER_PIP();i.setAttribute("aria-label",e)},fh=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_IS_PIP,y.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Sv,tooltipContent:aS,...e})}connectedCallback(){Av(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_IS_PIP&&Av(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return me(this,y.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ce(this,y.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return xe(this,y.MEDIA_IS_PIP)}set mediaIsPip(e){Ae(this,y.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?$.MEDIA_EXIT_PIP_REQUEST:$.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-pip-button")||R.customElements.define("media-pip-button",fh);var oS=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xl=(i,e,t)=>(oS(i,e,"read from private field"),t?t.call(i):e.get(i)),lS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},en,mh={RATES:"rates"},gh=[1,1.2,1.5,1.7,2],tn=1,xv=F.createElement("template");xv.innerHTML=`
829
829
  <style>
830
830
  :host {
831
831
  min-width: 5ch;
@@ -833,11 +833,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
833
833
  }
834
834
  </style>
835
835
  <slot name="icon"></slot>
836
- `;var mh=class extends Me{constructor(e={}){super({slotTemplate:_v,tooltipContent:he.PLAYBACK_RATE,...e}),oS(this,en,new pi(this,fh.RATES,{defaultValue:ph})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${tn}x`}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,fh.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===fh.RATES&&(Rl(this,en).value=r),e===y.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?tn:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Fe.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return Rl(this,en)}set rates(e){e?Array.isArray(e)&&(Rl(this,en).value=e.join(" ")):Rl(this,en).value=""}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,tn)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:tn,n=new R.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};en=new WeakMap;R.customElements.get("media-playback-rate-button")||R.customElements.define("media-playback-rate-button",mh);var lS=`<svg aria-hidden="true" viewBox="0 0 24 24">
836
+ `;var ph=class extends Pe{constructor(e={}){super({slotTemplate:xv,tooltipContent:he.PLAYBACK_RATE,...e}),lS(this,en,new pi(this,mh.RATES,{defaultValue:gh})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${tn}x`}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,mh.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===mh.RATES&&(xl(this,en).value=r),e===y.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?tn:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Be.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return xl(this,en)}set rates(e){e?Array.isArray(e)&&(xl(this,en).value=e.join(" ")):xl(this,en).value=""}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,tn)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:tn,n=new R.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};en=new WeakMap;R.customElements.get("media-playback-rate-button")||R.customElements.define("media-playback-rate-button",ph);var dS=`<svg aria-hidden="true" viewBox="0 0 24 24">
837
837
  <path d="m6 21 15-9L6 3v18Z"/>
838
- </svg>`,dS=`<svg aria-hidden="true" viewBox="0 0 24 24">
838
+ </svg>`,uS=`<svg aria-hidden="true" viewBox="0 0 24 24">
839
839
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
840
- </svg>`,Sv=F.createElement("template");Sv.innerHTML=`
840
+ </svg>`,Iv=F.createElement("template");Iv.innerHTML=`
841
841
  <style>
842
842
  :host([${y.MEDIA_PAUSED}]) slot[name=pause],
843
843
  :host(:not([${y.MEDIA_PAUSED}])) slot[name=play] {
@@ -851,13 +851,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
851
851
  </style>
852
852
 
853
853
  <slot name="icon">
854
- <slot name="play">${lS}</slot>
855
- <slot name="pause">${dS}</slot>
854
+ <slot name="play">${dS}</slot>
855
+ <slot name="pause">${uS}</slot>
856
856
  </slot>
857
- `;var uS=`
857
+ `;var cS=`
858
858
  <slot name="tooltip-play">${he.PLAY}</slot>
859
859
  <slot name="tooltip-pause">${he.PAUSE}</slot>
860
- `,Av=i=>{let e=i.mediaPaused?Be.PLAY():Be.PAUSE();i.setAttribute("aria-label",e)},gh=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PAUSED,y.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:Sv,tooltipContent:uS,...e})}connectedCallback(){Av(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_PAUSED&&Av(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-play-button")||R.customElements.define("media-play-button",gh);var _i={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},xv=F.createElement("template");xv.innerHTML=`
860
+ `,Rv=i=>{let e=i.mediaPaused?$e.PLAY():$e.PAUSE();i.setAttribute("aria-label",e)},vh=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PAUSED,y.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:Iv,tooltipContent:cS,...e})}connectedCallback(){Rv(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===y.MEDIA_PAUSED&&Rv(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}};R.customElements.get("media-play-button")||R.customElements.define("media-play-button",vh);var _i={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},Lv=F.createElement("template");Lv.innerHTML=`
861
861
  <style>
862
862
  :host {
863
863
  pointer-events: none;
@@ -879,7 +879,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
879
879
  </style>
880
880
 
881
881
  <img part="poster img" aria-hidden="true" id="image"/>
882
- `;var cS=i=>{i.style.removeProperty("background-image")},hS=(i,e)=>{i.style["background-image"]=`url('${e}')`},vh=class extends R.HTMLElement{static get observedAttributes(){return[_i.PLACEHOLDER_SRC,_i.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(xv.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===_i.SRC&&(r==null?this.image.removeAttribute(_i.SRC):this.image.setAttribute(_i.SRC,r)),e===_i.PLACEHOLDER_SRC&&(r==null?cS(this.image):hS(this.image,r))}get placeholderSrc(){return me(this,_i.PLACEHOLDER_SRC)}set placeholderSrc(e){ce(this,_i.SRC,e)}get src(){return me(this,_i.SRC)}set src(e){ce(this,_i.SRC,e)}};R.customElements.get("media-poster-image")||R.customElements.define("media-poster-image",vh);var Rv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fS=(i,e,t)=>(Rv(i,e,"read from private field"),t?t.call(i):e.get(i)),mS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},pS=(i,e,t,r)=>(Rv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Il,Eh=class extends ti{constructor(){super(),mS(this,Il,void 0),pS(this,Il,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(fS(this,Il).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return me(this,y.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ce(this,y.MEDIA_PREVIEW_CHAPTER,e)}};Il=new WeakMap;R.customElements.get("media-preview-chapter-display")||R.customElements.define("media-preview-chapter-display",Eh);var Iv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ll=(i,e,t)=>(Iv(i,e,"read from private field"),t?t.call(i):e.get(i)),gS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kl=(i,e,t,r)=>(Iv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ai,Lv=F.createElement("template");Lv.innerHTML=`
882
+ `;var hS=i=>{i.style.removeProperty("background-image")},fS=(i,e)=>{i.style["background-image"]=`url('${e}')`},Eh=class extends R.HTMLElement{static get observedAttributes(){return[_i.PLACEHOLDER_SRC,_i.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Lv.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===_i.SRC&&(r==null?this.image.removeAttribute(_i.SRC):this.image.setAttribute(_i.SRC,r)),e===_i.PLACEHOLDER_SRC&&(r==null?hS(this.image):fS(this.image,r))}get placeholderSrc(){return me(this,_i.PLACEHOLDER_SRC)}set placeholderSrc(e){ce(this,_i.SRC,e)}get src(){return me(this,_i.SRC)}set src(e){ce(this,_i.SRC,e)}};R.customElements.get("media-poster-image")||R.customElements.define("media-poster-image",Eh);var kv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},mS=(i,e,t)=>(kv(i,e,"read from private field"),t?t.call(i):e.get(i)),pS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},gS=(i,e,t,r)=>(kv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Rl,bh=class extends ti{constructor(){super(),pS(this,Rl,void 0),gS(this,Rl,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(mS(this,Rl).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return me(this,y.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ce(this,y.MEDIA_PREVIEW_CHAPTER,e)}};Rl=new WeakMap;R.customElements.get("media-preview-chapter-display")||R.customElements.define("media-preview-chapter-display",bh);var Cv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Il=(i,e,t)=>(Cv(i,e,"read from private field"),t?t.call(i):e.get(i)),vS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ll=(i,e,t,r)=>(Cv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ai,wv=F.createElement("template");wv.innerHTML=`
883
883
  <style>
884
884
  :host {
885
885
  box-sizing: border-box;
@@ -893,11 +893,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
893
893
  }
894
894
  </style>
895
895
  <img crossorigin loading="eager" decoding="async">
896
- `;var bh=class extends R.HTMLElement{constructor(){super(),gS(this,Ai,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Lv.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(kl(this,Ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Ll(this,Ai))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ll(this,Ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),kl(this,Ai,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=Ll(this,Ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),kl(this,Ai,null)),r&&this.isConnected&&(kl(this,Ai,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ll(this,Ai))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return me(this,y.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ce(this,y.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(y.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(y.MEDIA_PREVIEW_COORDS);return}this.setAttribute(y.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=we(this.shadowRoot,":host"),b=we(this.shadowRoot,"img").style,T=this.shadowRoot.querySelector("img"),_=p?"min":"max";E.setProperty(`${_}-width`,"initial","important"),E.setProperty(`${_}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;let A=()=>{b.width=`${this.imgWidth*g}px`,b.height=`${this.imgHeight*g}px`,b.display="block"};T.src!==o&&(T.onload=()=>{this.imgWidth=T.naturalWidth,this.imgHeight=T.naturalHeight,A()},T.src=o,A()),A(),b.transform=`translate(-${r*g}px, -${s*g}px)`}};Ai=new WeakMap;R.customElements.get("media-preview-thumbnail")||R.customElements.define("media-preview-thumbnail",bh);var Cv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},kv=(i,e,t)=>(Cv(i,e,"read from private field"),t?t.call(i):e.get(i)),vS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ES=(i,e,t,r)=>(Cv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ha,yh=class extends ti{constructor(){super(),vS(this,ha,void 0),ES(this,ha,this.shadowRoot.querySelector("slot")),kv(this,ha).textContent=fi(0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PREVIEW_TIME&&r!=null&&(kv(this,ha).textContent=fi(parseFloat(r)))}get mediaPreviewTime(){return fe(this,y.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){be(this,y.MEDIA_PREVIEW_TIME,e)}};ha=new WeakMap;R.customElements.get("media-preview-time-display")||R.customElements.define("media-preview-time-display",yh);var rn={SEEK_OFFSET:"seekoffset"},Cl=30,bS=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${Cl}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,wv=F.createElement("template");wv.innerHTML=`
897
- <slot name="icon">${bS}</slot>
898
- `;var yS=0,Th=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_CURRENT_TIME,rn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:wv,tooltipContent:he.SEEK_BACKWARD,...e})}connectedCallback(){this.seekOffset=fe(this,rn.SEEK_OFFSET,Cl),super.connectedCallback()}attributeChangedCallback(e,t,r){e===rn.SEEK_OFFSET&&(this.seekOffset=fe(this,rn.SEEK_OFFSET,Cl)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return fe(this,rn.SEEK_OFFSET,Cl)}set seekOffset(e){be(this,rn.SEEK_OFFSET,e),this.setAttribute("aria-label",Be.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Fo(Bo(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME,yS)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};R.customElements.get("media-seek-backward-button")||R.customElements.define("media-seek-backward-button",Th);var sn={SEEK_OFFSET:"seekoffset"},wl=30,TS=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${wl}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Dv=F.createElement("template");Dv.innerHTML=`
899
- <slot name="icon">${TS}</slot>
900
- `;var _S=0,_h=class extends Me{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_CURRENT_TIME,sn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Dv,tooltipContent:he.SEEK_FORWARD,...e})}connectedCallback(){this.seekOffset=fe(this,sn.SEEK_OFFSET,wl),super.connectedCallback()}attributeChangedCallback(e,t,r){e===sn.SEEK_OFFSET&&(this.seekOffset=fe(this,sn.SEEK_OFFSET,wl)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return fe(this,sn.SEEK_OFFSET,wl)}set seekOffset(e){be(this,sn.SEEK_OFFSET,e),this.setAttribute("aria-label",Be.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Fo(Bo(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME,_S)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};R.customElements.get("media-seek-forward-button")||R.customElements.define("media-seek-forward-button",_h);var Nv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ah=(i,e,t)=>(Nv(i,e,"read from private field"),t?t.call(i):e.get(i)),AS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},SS=(i,e,t,r)=>(Nv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),nn,ii={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Mv=[...Object.values(ii),y.MEDIA_CURRENT_TIME,y.MEDIA_DURATION,y.MEDIA_SEEKABLE],Pv=["Enter"," "],xS="&nbsp;/&nbsp;",Ov=(i,{timesSep:e=xS}={})=>{var t,r;let s=i.hasAttribute(ii.REMAINING),n=i.hasAttribute(ii.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[],l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);let d=s?fi(0-(l-a)):fi(a);return n?`${d}${e}${fi(l)}`:d},RS="video not loaded, unknown time.",IS=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",RS);return}let n=i.hasAttribute(ii.REMAINING),a=i.hasAttribute(ii.SHOW_DURATION),o=n?Pr(0-(s-t)):Pr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Pr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},Sh=class extends ti{constructor(){super(),AS(this,nn,void 0),SS(this,nn,this.shadowRoot.querySelector("slot")),Ah(this,nn).innerHTML=`${Ov(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Mv,"disabled"]}connectedCallback(){let{style:e}=we(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Fe.PLAYBACK_TIME());let t=r=>{let{key:s}=r;if(!Pv.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Pv.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Mv.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return xe(this,ii.REMAINING)}set remaining(e){Ae(this,ii.REMAINING,e)}get showDuration(){return xe(this,ii.SHOW_DURATION)}set showDuration(e){Ae(this,ii.SHOW_DURATION,e)}get noToggle(){return xe(this,ii.NO_TOGGLE)}set noToggle(e){Ae(this,ii.NO_TOGGLE,e)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(y.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(y.MEDIA_SEEKABLE);return}this.setAttribute(y.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Ov(this);IS(this),e!==Ah(this,nn).innerHTML&&(Ah(this,nn).innerHTML=e)}};nn=new WeakMap;R.customElements.get("media-time-display")||R.customElements.define("media-time-display",Sh);var Uv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ut=(i,e,t)=>(Uv(i,e,"read from private field"),t?t.call(i):e.get(i)),Si=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gt=(i,e,t,r)=>(Uv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),LS=(i,e,t,r)=>({set _(s){Gt(i,e,s,t)},get _(){return ut(i,e,r)}}),an,Dl,on,fa,Ml,Pl,Ol,ln,jr,Nl,Ul=class{constructor(e,t,r){Si(this,an,void 0),Si(this,Dl,void 0),Si(this,on,void 0),Si(this,fa,void 0),Si(this,Ml,void 0),Si(this,Pl,void 0),Si(this,Ol,void 0),Si(this,ln,void 0),Si(this,jr,0),Si(this,Nl,(s=performance.now())=>{Gt(this,jr,requestAnimationFrame(ut(this,Nl))),Gt(this,fa,performance.now()-ut(this,on));let n=1e3/this.fps;if(ut(this,fa)>n){Gt(this,on,s-ut(this,fa)%n);let a=1e3/((s-ut(this,Dl))/++LS(this,Ml)._),o=(s-ut(this,Pl))/1e3/this.duration,l=ut(this,Ol)+o*this.playbackRate;l-ut(this,an).valueAsNumber>0?Gt(this,ln,this.playbackRate/this.duration/a):(Gt(this,ln,.995*ut(this,ln)),l=ut(this,an).valueAsNumber+ut(this,ln)),this.callback(l)}}),Gt(this,an,e),this.callback=t,this.fps=r}start(){ut(this,jr)===0&&(Gt(this,on,performance.now()),Gt(this,Dl,ut(this,on)),Gt(this,Ml,0),ut(this,Nl).call(this))}stop(){ut(this,jr)!==0&&(cancelAnimationFrame(ut(this,jr)),Gt(this,jr,0))}update({start:e,duration:t,playbackRate:r}){let s=e-ut(this,an).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),Gt(this,Ol,e),Gt(this,Pl,performance.now()),this.duration=t,this.playbackRate=r}};an=new WeakMap;Dl=new WeakMap;on=new WeakMap;fa=new WeakMap;Ml=new WeakMap;Pl=new WeakMap;Ol=new WeakMap;ln=new WeakMap;jr=new WeakMap;Nl=new WeakMap;var kh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},st=(i,e,t)=>(kh(i,e,"read from private field"),t?t.call(i):e.get(i)),ct=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xi=(i,e,t,r)=>(kh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Tt=(i,e,t)=>(kh(i,e,"access private method"),t),dn,zr,$l,pa,Hl,Bl,ga,va,un,cn,ma,Ch,Fv,xh,Gl,wh,Kl,Dh,Vl,Mh,Rh,Bv,Ea,Wl,Ih,$v,kS="video not loaded, unknown time.",CS=i=>{let e=i.range,t=Pr(+Gv(i)),r=Pr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:kS;e.setAttribute("aria-valuetext",s)},Hv=F.createElement("template");Hv.innerHTML=`
896
+ `;var yh=class extends R.HTMLElement{constructor(){super(),vS(this,Ai,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(wv.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(ue.MEDIA_CONTROLLER);s&&(Ll(this,Ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Il(this,Ai))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Il(this,Ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ll(this,Ai,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ue.MEDIA_CONTROLLER&&(t&&((n=(s=Il(this,Ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ll(this,Ai,null)),r&&this.isConnected&&(Ll(this,Ai,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Il(this,Ai))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return me(this,y.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ce(this,y.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(y.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(y.MEDIA_PREVIEW_COORDS);return}this.setAttribute(y.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=De(this.shadowRoot,":host"),b=De(this.shadowRoot,"img").style,T=this.shadowRoot.querySelector("img"),_=p?"min":"max";E.setProperty(`${_}-width`,"initial","important"),E.setProperty(`${_}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;let A=()=>{b.width=`${this.imgWidth*g}px`,b.height=`${this.imgHeight*g}px`,b.display="block"};T.src!==o&&(T.onload=()=>{this.imgWidth=T.naturalWidth,this.imgHeight=T.naturalHeight,A()},T.src=o,A()),A(),b.transform=`translate(-${r*g}px, -${s*g}px)`}};Ai=new WeakMap;R.customElements.get("media-preview-thumbnail")||R.customElements.define("media-preview-thumbnail",yh);var Mv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Dv=(i,e,t)=>(Mv(i,e,"read from private field"),t?t.call(i):e.get(i)),ES=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},bS=(i,e,t,r)=>(Mv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ha,Th=class extends ti{constructor(){super(),ES(this,ha,void 0),bS(this,ha,this.shadowRoot.querySelector("slot")),Dv(this,ha).textContent=fi(0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PREVIEW_TIME&&r!=null&&(Dv(this,ha).textContent=fi(parseFloat(r)))}get mediaPreviewTime(){return fe(this,y.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){be(this,y.MEDIA_PREVIEW_TIME,e)}};ha=new WeakMap;R.customElements.get("media-preview-time-display")||R.customElements.define("media-preview-time-display",Th);var rn={SEEK_OFFSET:"seekoffset"},kl=30,yS=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${kl}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,Pv=F.createElement("template");Pv.innerHTML=`
897
+ <slot name="icon">${yS}</slot>
898
+ `;var TS=0,_h=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_CURRENT_TIME,rn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Pv,tooltipContent:he.SEEK_BACKWARD,...e})}connectedCallback(){this.seekOffset=fe(this,rn.SEEK_OFFSET,kl),super.connectedCallback()}attributeChangedCallback(e,t,r){e===rn.SEEK_OFFSET&&(this.seekOffset=fe(this,rn.SEEK_OFFSET,kl)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return fe(this,rn.SEEK_OFFSET,kl)}set seekOffset(e){be(this,rn.SEEK_OFFSET,e),this.setAttribute("aria-label",$e.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Uo(Fo(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME,TS)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};R.customElements.get("media-seek-backward-button")||R.customElements.define("media-seek-backward-button",_h);var sn={SEEK_OFFSET:"seekoffset"},Cl=30,_S=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Cl}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Ov=F.createElement("template");Ov.innerHTML=`
899
+ <slot name="icon">${_S}</slot>
900
+ `;var AS=0,Ah=class extends Pe{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_CURRENT_TIME,sn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Ov,tooltipContent:he.SEEK_FORWARD,...e})}connectedCallback(){this.seekOffset=fe(this,sn.SEEK_OFFSET,Cl),super.connectedCallback()}attributeChangedCallback(e,t,r){e===sn.SEEK_OFFSET&&(this.seekOffset=fe(this,sn.SEEK_OFFSET,Cl)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return fe(this,sn.SEEK_OFFSET,Cl)}set seekOffset(e){be(this,sn.SEEK_OFFSET,e),this.setAttribute("aria-label",$e.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Uo(Fo(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME,AS)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};R.customElements.get("media-seek-forward-button")||R.customElements.define("media-seek-forward-button",Ah);var Bv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Sh=(i,e,t)=>(Bv(i,e,"read from private field"),t?t.call(i):e.get(i)),SS=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xS=(i,e,t,r)=>(Bv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),nn,ii={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Nv=[...Object.values(ii),y.MEDIA_CURRENT_TIME,y.MEDIA_DURATION,y.MEDIA_SEEKABLE],Uv=["Enter"," "],RS="&nbsp;/&nbsp;",Fv=(i,{timesSep:e=RS}={})=>{var t,r;let s=i.hasAttribute(ii.REMAINING),n=i.hasAttribute(ii.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[],l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);let d=s?fi(0-(l-a)):fi(a);return n?`${d}${e}${fi(l)}`:d},IS="video not loaded, unknown time.",LS=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",IS);return}let n=i.hasAttribute(ii.REMAINING),a=i.hasAttribute(ii.SHOW_DURATION),o=n?Pr(0-(s-t)):Pr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Pr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},xh=class extends ti{constructor(){super(),SS(this,nn,void 0),xS(this,nn,this.shadowRoot.querySelector("slot")),Sh(this,nn).innerHTML=`${Fv(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Nv,"disabled"]}connectedCallback(){let{style:e}=De(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Be.PLAYBACK_TIME());let t=r=>{let{key:s}=r;if(!Uv.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Uv.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Nv.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return xe(this,ii.REMAINING)}set remaining(e){Ae(this,ii.REMAINING,e)}get showDuration(){return xe(this,ii.SHOW_DURATION)}set showDuration(e){Ae(this,ii.SHOW_DURATION,e)}get noToggle(){return xe(this,ii.NO_TOGGLE)}set noToggle(e){Ae(this,ii.NO_TOGGLE,e)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(y.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(y.MEDIA_SEEKABLE);return}this.setAttribute(y.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Fv(this);LS(this),e!==Sh(this,nn).innerHTML&&(Sh(this,nn).innerHTML=e)}};nn=new WeakMap;R.customElements.get("media-time-display")||R.customElements.define("media-time-display",xh);var $v=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ut=(i,e,t)=>($v(i,e,"read from private field"),t?t.call(i):e.get(i)),Si=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gt=(i,e,t,r)=>($v(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),kS=(i,e,t,r)=>({set _(s){Gt(i,e,s,t)},get _(){return ut(i,e,r)}}),an,wl,on,fa,Dl,Ml,Pl,ln,jr,Ol,Nl=class{constructor(e,t,r){Si(this,an,void 0),Si(this,wl,void 0),Si(this,on,void 0),Si(this,fa,void 0),Si(this,Dl,void 0),Si(this,Ml,void 0),Si(this,Pl,void 0),Si(this,ln,void 0),Si(this,jr,0),Si(this,Ol,(s=performance.now())=>{Gt(this,jr,requestAnimationFrame(ut(this,Ol))),Gt(this,fa,performance.now()-ut(this,on));let n=1e3/this.fps;if(ut(this,fa)>n){Gt(this,on,s-ut(this,fa)%n);let a=1e3/((s-ut(this,wl))/++kS(this,Dl)._),o=(s-ut(this,Ml))/1e3/this.duration,l=ut(this,Pl)+o*this.playbackRate;l-ut(this,an).valueAsNumber>0?Gt(this,ln,this.playbackRate/this.duration/a):(Gt(this,ln,.995*ut(this,ln)),l=ut(this,an).valueAsNumber+ut(this,ln)),this.callback(l)}}),Gt(this,an,e),this.callback=t,this.fps=r}start(){ut(this,jr)===0&&(Gt(this,on,performance.now()),Gt(this,wl,ut(this,on)),Gt(this,Dl,0),ut(this,Ol).call(this))}stop(){ut(this,jr)!==0&&(cancelAnimationFrame(ut(this,jr)),Gt(this,jr,0))}update({start:e,duration:t,playbackRate:r}){let s=e-ut(this,an).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),Gt(this,Pl,e),Gt(this,Ml,performance.now()),this.duration=t,this.playbackRate=r}};an=new WeakMap;wl=new WeakMap;on=new WeakMap;fa=new WeakMap;Dl=new WeakMap;Ml=new WeakMap;Pl=new WeakMap;ln=new WeakMap;jr=new WeakMap;Ol=new WeakMap;var Ch=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},st=(i,e,t)=>(Ch(i,e,"read from private field"),t?t.call(i):e.get(i)),ct=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xi=(i,e,t,r)=>(Ch(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Tt=(i,e,t)=>(Ch(i,e,"access private method"),t),dn,zr,Bl,pa,$l,Fl,ga,va,un,cn,ma,wh,Hv,Rh,Hl,Dh,Gl,Mh,Kl,Ph,Ih,Gv,Ea,Vl,Lh,Kv,CS="video not loaded, unknown time.",wS=i=>{let e=i.range,t=Pr(+Wv(i)),r=Pr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:CS;e.setAttribute("aria-valuetext",s)},Vv=F.createElement("template");Vv.innerHTML=`
901
901
  <style>
902
902
  :host {
903
903
  --media-box-border-radius: 4px;
@@ -1110,7 +1110,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1110
1110
 
1111
1111
  </slot>
1112
1112
  </div>
1113
- `;var Fl=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Gv=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},Lh=class extends Yr{constructor(){super(),ct(this,cn),ct(this,Ch),ct(this,Gl),ct(this,Kl),ct(this,Vl),ct(this,Rh),ct(this,Ea),ct(this,Ih),ct(this,dn,void 0),ct(this,zr,void 0),ct(this,$l,void 0),ct(this,pa,void 0),ct(this,Hl,void 0),ct(this,Bl,void 0),ct(this,ga,void 0),ct(this,va,void 0),ct(this,un,void 0),ct(this,xh,r=>{this.dragging||(Gs(r)&&(this.range.valueAsNumber=r),this.updateBar())}),this.container.appendChild(Hv.content.cloneNode(!0)),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),xi(this,$l,this.shadowRoot.querySelectorAll('[part~="box"]')),xi(this,Hl,this.shadowRoot.querySelector('[part~="preview-box"]')),xi(this,Bl,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);xi(this,ga,parseInt(t.getPropertyValue("--media-box-padding-left"))),xi(this,va,parseInt(t.getPropertyValue("--media-box-padding-right"))),xi(this,zr,new Ul(this.range,st(this,xh),60))}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PAUSED,y.MEDIA_DURATION,y.MEDIA_SEEKABLE,y.MEDIA_CURRENT_TIME,y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_TIME,y.MEDIA_PREVIEW_CHAPTER,y.MEDIA_BUFFERED,y.MEDIA_PLAYBACK_RATE,y.MEDIA_LOADING,y.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Fe.SEEK()),Tt(this,cn,ma).call(this),xi(this,dn,this.getRootNode()),(e=st(this,dn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),Tt(this,cn,ma).call(this),(e=st(this,dn))==null||e.removeEventListener("transitionstart",this),xi(this,dn,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===y.MEDIA_CURRENT_TIME||e===y.MEDIA_PAUSED||e===y.MEDIA_ENDED||e===y.MEDIA_LOADING||e===y.MEDIA_DURATION||e===y.MEDIA_SEEKABLE?(st(this,zr).update({start:Fl(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),Tt(this,cn,ma).call(this),CS(this)):e===y.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===y.MEDIA_DURATION||e===y.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=st(this,un),this.updateBar()))}get mediaChaptersCues(){return st(this,un)}set mediaChaptersCues(e){var t;xi(this,un,e),this.updateSegments((t=st(this,un))==null?void 0:t.map(r=>({start:Fl(this,r.startTime),end:Fl(this,r.endTime)})))}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaLoading(){return xe(this,y.MEDIA_LOADING)}set mediaLoading(e){Ae(this,y.MEDIA_LOADING,e)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(y.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(y.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(y.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(y.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(y.MEDIA_SEEKABLE);return}this.setAttribute(y.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return me(this,y.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ce(this,y.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return fe(this,y.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){be(this,y.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return xe(this,y.MEDIA_ENDED)}set mediaEnded(e){Ae(this,y.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=Fl(this,a)}let{style:s}=we(this.shadowRoot,"#buffered");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=we(this.shadowRoot,"#current-rail"),r=we(this.shadowRoot,'[part~="current-box"]'),s=Tt(this,Gl,wh).call(this,st(this,Bl)),n=Tt(this,Kl,Dh).call(this,s,this.range.valueAsNumber),a=Tt(this,Vl,Mh).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":Tt(this,Ih,$v).call(this);break;case"pointermove":Tt(this,Rh,Bv).call(this,e);break;case"pointerup":case"pointerleave":Tt(this,Ea,Wl).call(this,null);break;case"transitionstart":xt(e.target,this)&&setTimeout(()=>Tt(this,cn,ma).call(this),0);break}}};dn=new WeakMap;zr=new WeakMap;$l=new WeakMap;pa=new WeakMap;Hl=new WeakMap;Bl=new WeakMap;ga=new WeakMap;va=new WeakMap;un=new WeakMap;cn=new WeakSet;ma=function(){Tt(this,Ch,Fv).call(this)?st(this,zr).start():st(this,zr).stop()};Ch=new WeakSet;Fv=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&$o(this)};xh=new WeakMap;Gl=new WeakSet;wh=function(i){var e;let r=((e=this.getAttribute("bounds")?mi(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};Kl=new WeakSet;Dh=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};Vl=new WeakSet;Mh=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+st(this,ga)){let a=i.range.left-i.bounds.left-st(this,ga);return`${n-t/2+a}px`}if(n>s-st(this,va)){let a=i.bounds.right-i.range.right-st(this,va);return`${n+t/2-a-i.range.width}px`}return 0};Rh=new WeakSet;Bv=function(i){let e=[...st(this,$l)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){Tt(this,Ea,Wl).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=we(this.shadowRoot,"#preview-rail"),s=we(this.shadowRoot,'[part~="preview-box"]'),n=Tt(this,Gl,wh).call(this,st(this,Hl)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=Tt(this,Kl,Dh).call(this,n,a),l=Tt(this,Vl,Mh).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(st(this,pa))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(xi(this,pa,a*t),Tt(this,Ea,Wl).call(this,st(this,pa)))};Ea=new WeakSet;Wl=function(i){this.dispatchEvent(new R.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Ih=new WeakSet;$v=function(){st(this,zr).stop();let i=Gv(this);this.dispatchEvent(new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};R.customElements.get("media-time-range")||R.customElements.define("media-time-range",Lh);var hn={PLACEMENT:"placement",BOUNDS:"bounds"},Kv=F.createElement("template");Kv.innerHTML=`
1113
+ `;var Ul=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Wv=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},kh=class extends Yr{constructor(){super(),ct(this,cn),ct(this,wh),ct(this,Hl),ct(this,Gl),ct(this,Kl),ct(this,Ih),ct(this,Ea),ct(this,Lh),ct(this,dn,void 0),ct(this,zr,void 0),ct(this,Bl,void 0),ct(this,pa,void 0),ct(this,$l,void 0),ct(this,Fl,void 0),ct(this,ga,void 0),ct(this,va,void 0),ct(this,un,void 0),ct(this,Rh,r=>{this.dragging||(Gs(r)&&(this.range.valueAsNumber=r),this.updateBar())}),this.container.appendChild(Vv.content.cloneNode(!0)),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),xi(this,Bl,this.shadowRoot.querySelectorAll('[part~="box"]')),xi(this,$l,this.shadowRoot.querySelector('[part~="preview-box"]')),xi(this,Fl,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);xi(this,ga,parseInt(t.getPropertyValue("--media-box-padding-left"))),xi(this,va,parseInt(t.getPropertyValue("--media-box-padding-right"))),xi(this,zr,new Nl(this.range,st(this,Rh),60))}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PAUSED,y.MEDIA_DURATION,y.MEDIA_SEEKABLE,y.MEDIA_CURRENT_TIME,y.MEDIA_PREVIEW_IMAGE,y.MEDIA_PREVIEW_TIME,y.MEDIA_PREVIEW_CHAPTER,y.MEDIA_BUFFERED,y.MEDIA_PLAYBACK_RATE,y.MEDIA_LOADING,y.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Be.SEEK()),Tt(this,cn,ma).call(this),xi(this,dn,this.getRootNode()),(e=st(this,dn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),Tt(this,cn,ma).call(this),(e=st(this,dn))==null||e.removeEventListener("transitionstart",this),xi(this,dn,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===y.MEDIA_CURRENT_TIME||e===y.MEDIA_PAUSED||e===y.MEDIA_ENDED||e===y.MEDIA_LOADING||e===y.MEDIA_DURATION||e===y.MEDIA_SEEKABLE?(st(this,zr).update({start:Ul(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),Tt(this,cn,ma).call(this),wS(this)):e===y.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===y.MEDIA_DURATION||e===y.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=st(this,un),this.updateBar()))}get mediaChaptersCues(){return st(this,un)}set mediaChaptersCues(e){var t;xi(this,un,e),this.updateSegments((t=st(this,un))==null?void 0:t.map(r=>({start:Ul(this,r.startTime),end:Ul(this,r.endTime)})))}get mediaPaused(){return xe(this,y.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,y.MEDIA_PAUSED,e)}get mediaLoading(){return xe(this,y.MEDIA_LOADING)}set mediaLoading(e){Ae(this,y.MEDIA_LOADING,e)}get mediaDuration(){return fe(this,y.MEDIA_DURATION)}set mediaDuration(e){be(this,y.MEDIA_DURATION,e)}get mediaCurrentTime(){return fe(this,y.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){be(this,y.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(y.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(y.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(y.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(y.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(y.MEDIA_SEEKABLE);return}this.setAttribute(y.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return me(this,y.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ce(this,y.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return fe(this,y.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){be(this,y.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return xe(this,y.MEDIA_ENDED)}set mediaEnded(e){Ae(this,y.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=Ul(this,a)}let{style:s}=De(this.shadowRoot,"#buffered");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=De(this.shadowRoot,"#current-rail"),r=De(this.shadowRoot,'[part~="current-box"]'),s=Tt(this,Hl,Dh).call(this,st(this,Fl)),n=Tt(this,Gl,Mh).call(this,s,this.range.valueAsNumber),a=Tt(this,Kl,Ph).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":Tt(this,Lh,Kv).call(this);break;case"pointermove":Tt(this,Ih,Gv).call(this,e);break;case"pointerup":case"pointerleave":Tt(this,Ea,Vl).call(this,null);break;case"transitionstart":xt(e.target,this)&&setTimeout(()=>Tt(this,cn,ma).call(this),0);break}}};dn=new WeakMap;zr=new WeakMap;Bl=new WeakMap;pa=new WeakMap;$l=new WeakMap;Fl=new WeakMap;ga=new WeakMap;va=new WeakMap;un=new WeakMap;cn=new WeakSet;ma=function(){Tt(this,wh,Hv).call(this)?st(this,zr).start():st(this,zr).stop()};wh=new WeakSet;Hv=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&Bo(this)};Rh=new WeakMap;Hl=new WeakSet;Dh=function(i){var e;let r=((e=this.getAttribute("bounds")?mi(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};Gl=new WeakSet;Mh=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};Kl=new WeakSet;Ph=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+st(this,ga)){let a=i.range.left-i.bounds.left-st(this,ga);return`${n-t/2+a}px`}if(n>s-st(this,va)){let a=i.bounds.right-i.range.right-st(this,va);return`${n+t/2-a-i.range.width}px`}return 0};Ih=new WeakSet;Gv=function(i){let e=[...st(this,Bl)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){Tt(this,Ea,Vl).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=De(this.shadowRoot,"#preview-rail"),s=De(this.shadowRoot,'[part~="preview-box"]'),n=Tt(this,Hl,Dh).call(this,st(this,$l)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=Tt(this,Gl,Mh).call(this,n,a),l=Tt(this,Kl,Ph).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(st(this,pa))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(xi(this,pa,a*t),Tt(this,Ea,Vl).call(this,st(this,pa)))};Ea=new WeakSet;Vl=function(i){this.dispatchEvent(new R.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Lh=new WeakSet;Kv=function(){st(this,zr).stop();let i=Wv(this);this.dispatchEvent(new R.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};R.customElements.get("media-time-range")||R.customElements.define("media-time-range",kh);var hn={PLACEMENT:"placement",BOUNDS:"bounds"},Yv=F.createElement("template");Yv.innerHTML=`
1114
1114
  <style>
1115
1115
  :host {
1116
1116
  --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
@@ -1220,9 +1220,9 @@ svg, img, ::slotted(svg), ::slotted(img) {
1220
1220
  </style>
1221
1221
  <slot></slot>
1222
1222
  <div id="arrow"></div>
1223
- `;var Ph=class extends R.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!$o(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;let t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}let r=getComputedStyle(this),s=(e=mi(this,"#"+this.bounds))!=null?e:We(this);if(!s)return;let{x:n,width:a}=s.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,u=n+a,c=r.getPropertyValue("--media-tooltip-offset-x"),h=c?parseFloat(c.replace("px","")):0,f=r.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,p=o-n+h-m,g=d-u+h+m;if(p<0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}if(g>0){this.style.setProperty("--media-tooltip-offset-x",`${g}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Kv.content.cloneNode(!0))),this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){let e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[hn.PLACEMENT,hn.BOUNDS]}get placement(){return me(this,hn.PLACEMENT)}set placement(e){ce(this,hn.PLACEMENT,e)}get bounds(){return me(this,hn.BOUNDS)}set bounds(e){ce(this,hn.BOUNDS,e)}};R.customElements.get("media-tooltip")||R.customElements.define("media-tooltip",Ph);var wS=1,DS=i=>i.mediaMuted?0:i.mediaVolume,MS=i=>`${Math.round(i*100)}%`,Oh=class extends Yr{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_VOLUME,y.MEDIA_MUTED,y.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new R.CustomEvent($.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Fe.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===y.MEDIA_VOLUME||e===y.MEDIA_MUTED)&&(this.range.valueAsNumber=DS(this),this.range.setAttribute("aria-valuetext",MS(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return fe(this,y.MEDIA_VOLUME,wS)}set mediaVolume(e){be(this,y.MEDIA_VOLUME,e)}get mediaMuted(){return xe(this,y.MEDIA_MUTED)}set mediaMuted(e){Ae(this,y.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return me(this,y.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ce(this,y.MEDIA_VOLUME_UNAVAILABLE,e)}};R.customElements.get("media-volume-range")||R.customElements.define("media-volume-range",Oh);var PS=Object.create,Zv=Object.defineProperty,OS=Object.getOwnPropertyDescriptor,NS=Object.getOwnPropertyNames,US=Object.getPrototypeOf,FS=Object.prototype.hasOwnProperty,Jv=function(i,e){return function(){return i&&(e=i(i=0)),e}},Mt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},BS=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=NS(e),n=0,a=s.length,o;n<a;n++)o=s[n],!FS.call(i,o)&&o!==t&&Zv(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=OS(e,o))||r.enumerable});return i},Vt=function(i,e,t){return t=i!=null?PS(US(i)):{},BS(e||!i||!i.__esModule?Zv(t,"default",{value:i,enumerable:!0}):t,i)},ai=Mt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function Jr(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):Jr(i,e)}var es=Jv(function(){es()});function eE(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var tE=Jv(function(){}),iE=Mt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),$S=Mt(function(i,e){es(),e.exports=t;function t(r,s){if(!Jr(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),HS=Mt(function(i,e){es(),e.exports=t;function t(r,s){if(!Jr(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),rE=Mt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),sE=Mt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),nE=Mt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),GS=Mt(function(i,e){tE(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=eE(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],b=(E.prefix?E.prefix+":":"")+g;f.push({name:b,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),aE=Mt(function(i,e){es();var t=iE(),r=rE(),s=sE(),n=nE(),a=GS(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!Jr(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),KS=Mt(function(i,e){es();var t=aE();e.exports=r;function r(s){if(!Jr(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),VS=Mt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),WS=Mt(function(i,e){es();var t=iE(),r=$S(),s=HS(),n=aE(),a=KS(),o=VS(),l=rE(),d=sE(),u=nE();e.exports=c;function c(){if(!Jr(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),YS=Mt(function(i,e){var t=WS();e.exports=new t}),qS=Mt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=YS(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function jS(i){if(Array.isArray(i))return i}function zS(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function XS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1224
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hh(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function oE(i,e){if(i){if(typeof i=="string")return Hh(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Hh(i,e)}}function Xi(i,e){return jS(i)||zS(i,e)||oE(i,e)||XS()}var Ta=Vt(ai()),Vv=Vt(ai()),QS=Vt(ai()),ZS={now:function(){var i=QS.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=ZS,Aa=function(){var i,e,t;if(typeof((i=Vv.default.crypto)===null||i===void 0?void 0:i.getRandomValues)=="function"){t=new Uint8Array(32),Vv.default.crypto.getRandomValues(t);for(var r=0;r<32;r++)t[r]=t[r]%16}else{t=[];for(var s=0;s<32;s++)t[s]=Math.random()*16|0}var n=0;e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){var d=l==="x"?t[n]:t[n]&3|8;return n++,d.toString(16)});var a=tt.now(),o=a==null?void 0:a.toString(16).substring(3);return o?e.substring(0,28)+o:e},lE=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ri=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=lE()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},jl=function(i){var e;i&&typeof i.nodeName!="undefined"?(e=i,i=ri(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]};function JS(i){if(Array.isArray(i))return Hh(i)}function e1(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function t1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1225
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function si(i){return JS(i)||e1(i)||oE(i)||t1()}var Qr={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i1=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=i?[console,i]:[console],l=(t=console.trace).bind.apply(t,si(o)),d=(r=console.info).bind.apply(r,si(o)),u=(s=console.debug).bind.apply(s,si(o)),c=(n=console.warn).bind.apply(n,si(o)),h=(a=console.error).bind.apply(a,si(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.TRACE))return l.apply(void 0,si(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.DEBUG))return u.apply(void 0,si(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.INFO))return d.apply(void 0,si(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.WARN))return c.apply(void 0,si(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.ERROR))return h.apply(void 0,si(p))},get level(){return f},set level(m){m!==this.level&&(f=m!=null?m:e)}}},Pe=i1("[mux]"),Nh=Vt(ai());function Gh(){var i=Nh.default.doNotTrack||Nh.default.navigator&&Nh.default.navigator.doNotTrack;return i==="1"}function se(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}es();function ht(i,e){if(!Jr(i,e))throw new TypeError("Cannot call a class as a function")}function Wv(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ri(i,e,t){return e&&Wv(i.prototype,e),t&&Wv(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function mn(i){return mn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},mn(i)}function r1(i,e){for(;!Object.prototype.hasOwnProperty.call(i,e)&&(i=mn(i),i!==null););return i}function ql(i,e,t){return typeof Reflect!="undefined"&&Reflect.get?ql=Reflect.get:ql=function(r,s,n){var a=r1(r,s);if(a){var o=Object.getOwnPropertyDescriptor(a,s);return o.get?o.get.call(n||r):o.value}},ql(i,e,t||i)}function Kh(i,e){return Kh=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},Kh(i,e)}function s1(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Kh(i,e)}function n1(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}tE();function a1(i,e){return e&&(eE(e)==="object"||typeof e=="function")?e:se(i)}function o1(i){var e=n1();return function(){var t=mn(i),r;if(e){var s=mn(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return a1(this,r)}}var ni=function(i){return Sa(i)[0]},Sa=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},Uh=Vt(ai()),l1={exists:function(){var i=Uh.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Uh.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Uh.default.performance,e=i&&i.timing;return e&&e.navigationStart}},zl=l1;function et(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Xl(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function d1(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Wh(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):d1(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var u1=["x-cdn","content-type"],dE=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],c1=u1.concat(dE);function Yh(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(c1.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function Ql(i){if(i){var e=dE.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var h1=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},uE=h1,Yl=function(i){if(!i)return{};var e=zl.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},ba=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return Yh(i.getAllResponseHeaders())},f1=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(E){var b=parseInt(s.version),T;return b===1&&E.programDateTime!==null&&(T=E.programDateTime),b===0&&E.pdt!==null&&(T=E.pdt),T};if(!zl.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(E,b){return i.emit(e,E,b)},d=function(E,b){var T=b.levels,_=b.audioTracks,A=b.url,x=b.stats,S=b.networkDetails,w=b.sessionData,M={},k={};T.forEach(function(V,ne){M[ne]={width:V.width,height:V.height,bitrate:V.bitrate,attrs:V.attrs}}),_.forEach(function(V,ne){k[ne]={name:V.name,language:V.lang,bitrate:V.bitrate}});var P=Yl(x),N=P.bytesLoaded,B=P.requestStart,X=P.responseStart,z=P.responseEnd;l("requestcompleted",Wh(Xl({},uE(w)),{request_event_type:E,request_bytes_loaded:N,request_start:B,request_response_start:X,request_response_end:z,request_type:"manifest",request_hostname:ni(A),request_response_headers:ba(S),request_rendition_lists:{media:M,audio:k,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(E,b){var T=b.details,_=b.level,A=b.networkDetails,x=b.stats,S=Yl(x),w=S.bytesLoaded,M=S.requestStart,k=S.responseStart,P=S.responseEnd,N=T.fragments[T.fragments.length-1],B=o(N)+a(N.duration);l("requestcompleted",{request_event_type:E,request_bytes_loaded:w,request_start:M,request_response_start:k,request_response_end:P,request_current_level:_,request_type:"manifest",request_hostname:ni(T.url),request_response_headers:ba(A),video_holdback:T.holdBack&&a(T.holdBack),video_part_holdback:T.partHoldBack&&a(T.partHoldBack),video_part_target_duration:T.partTarget&&a(T.partTarget),video_target_duration:T.targetduration&&a(T.targetduration),video_source_is_live:T.live,player_manifest_newest_program_time:isNaN(B)?void 0:B})};t.on(s.Events.LEVEL_LOADED,u);var c=function(E,b){var T=b.details,_=b.networkDetails,A=b.stats,x=Yl(A),S=x.bytesLoaded,w=x.requestStart,M=x.responseStart,k=x.responseEnd;l("requestcompleted",{request_event_type:E,request_bytes_loaded:S,request_start:w,request_response_start:M,request_response_end:k,request_type:"manifest",request_hostname:ni(T.url),request_response_headers:ba(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(E,b){var T=b.stats,_=b.networkDetails,A=b.frag;T=T||A.stats;var x=Yl(T),S=x.bytesLoaded,w=x.requestStart,M=x.responseStart,k=x.responseEnd,P=_?ba(_):void 0,N={request_event_type:E,request_bytes_loaded:S,request_start:w,request_response_start:M,request_response_end:k,request_hostname:_?ni(_.responseURL):void 0,request_id:P?Ql(P):void 0,request_response_headers:P,request_media_duration:A.duration,request_url:_==null?void 0:_.responseURL};A.type==="main"?(N.request_type="media",N.request_current_level=A.level,N.request_video_width=(t.levels[A.level]||{}).width,N.request_video_height=(t.levels[A.level]||{}).height,N.request_labeled_bitrate=(t.levels[A.level]||{}).bitrate):N.request_type=A.type,l("requestcompleted",N)};t.on(s.Events.FRAG_LOADED,h);var f=function(E,b){var T=b.frag,_=T.start,A=o(T),x={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",x)};t.on(s.Events.FRAG_CHANGED,f);var m=function(E,b){var T=b.type,_=b.details,A=b.response,x=b.fatal,S=b.frag,w=b.networkDetails,M=(S==null?void 0:S.url)||b.url||"",k=w?ba(w):void 0;if((_===s.ErrorDetails.MANIFEST_LOAD_ERROR||_===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT||_===s.ErrorDetails.LEVEL_LOAD_ERROR||_===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:_,request_url:M,request_hostname:ni(M),request_id:k?Ql(k):void 0,request_type:_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:A==null?void 0:A.code,request_error_text:A==null?void 0:A.text}),x){var P,N="".concat(M?"url: ".concat(M,`
1223
+ `;var Oh=class extends R.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!Bo(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;let t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}let r=getComputedStyle(this),s=(e=mi(this,"#"+this.bounds))!=null?e:We(this);if(!s)return;let{x:n,width:a}=s.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,u=n+a,c=r.getPropertyValue("--media-tooltip-offset-x"),h=c?parseFloat(c.replace("px","")):0,f=r.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,p=o-n+h-m,g=d-u+h+m;if(p<0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}if(g>0){this.style.setProperty("--media-tooltip-offset-x",`${g}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Yv.content.cloneNode(!0))),this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){let e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[hn.PLACEMENT,hn.BOUNDS]}get placement(){return me(this,hn.PLACEMENT)}set placement(e){ce(this,hn.PLACEMENT,e)}get bounds(){return me(this,hn.BOUNDS)}set bounds(e){ce(this,hn.BOUNDS,e)}};R.customElements.get("media-tooltip")||R.customElements.define("media-tooltip",Oh);var DS=1,MS=i=>i.mediaMuted?0:i.mediaVolume,PS=i=>`${Math.round(i*100)}%`,Nh=class extends Yr{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_VOLUME,y.MEDIA_MUTED,y.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new R.CustomEvent($.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Be.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===y.MEDIA_VOLUME||e===y.MEDIA_MUTED)&&(this.range.valueAsNumber=MS(this),this.range.setAttribute("aria-valuetext",PS(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return fe(this,y.MEDIA_VOLUME,DS)}set mediaVolume(e){be(this,y.MEDIA_VOLUME,e)}get mediaMuted(){return xe(this,y.MEDIA_MUTED)}set mediaMuted(e){Ae(this,y.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return me(this,y.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ce(this,y.MEDIA_VOLUME_UNAVAILABLE,e)}};R.customElements.get("media-volume-range")||R.customElements.define("media-volume-range",Nh);var OS=Object.create,tE=Object.defineProperty,NS=Object.getOwnPropertyDescriptor,US=Object.getOwnPropertyNames,FS=Object.getPrototypeOf,BS=Object.prototype.hasOwnProperty,iE=function(i,e){return function(){return i&&(e=i(i=0)),e}},Mt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},$S=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=US(e),n=0,a=s.length,o;n<a;n++)o=s[n],!BS.call(i,o)&&o!==t&&tE(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=NS(e,o))||r.enumerable});return i},Vt=function(i,e,t){return t=i!=null?OS(FS(i)):{},$S(e||!i||!i.__esModule?tE(t,"default",{value:i,enumerable:!0}):t,i)},ai=Mt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function Jr(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):Jr(i,e)}var es=iE(function(){es()});function rE(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var sE=iE(function(){}),nE=Mt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),HS=Mt(function(i,e){es(),e.exports=t;function t(r,s){if(!Jr(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),GS=Mt(function(i,e){es(),e.exports=t;function t(r,s){if(!Jr(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),aE=Mt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),oE=Mt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),lE=Mt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),KS=Mt(function(i,e){sE(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=rE(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],b=(E.prefix?E.prefix+":":"")+g;f.push({name:b,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),dE=Mt(function(i,e){es();var t=nE(),r=aE(),s=oE(),n=lE(),a=KS(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!Jr(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),VS=Mt(function(i,e){es();var t=dE();e.exports=r;function r(s){if(!Jr(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),WS=Mt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),YS=Mt(function(i,e){es();var t=nE(),r=HS(),s=GS(),n=dE(),a=VS(),o=WS(),l=aE(),d=oE(),u=lE();e.exports=c;function c(){if(!Jr(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),qS=Mt(function(i,e){var t=YS();e.exports=new t}),jS=Mt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=qS(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function zS(i){if(Array.isArray(i))return i}function XS(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function QS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1224
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gh(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function uE(i,e){if(i){if(typeof i=="string")return Gh(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Gh(i,e)}}function Xi(i,e){return zS(i)||XS(i,e)||uE(i,e)||QS()}var Ta=Vt(ai()),qv=Vt(ai()),ZS=Vt(ai()),JS={now:function(){var i=ZS.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=JS,Aa=function(){var i,e,t;if(typeof((i=qv.default.crypto)===null||i===void 0?void 0:i.getRandomValues)=="function"){t=new Uint8Array(32),qv.default.crypto.getRandomValues(t);for(var r=0;r<32;r++)t[r]=t[r]%16}else{t=[];for(var s=0;s<32;s++)t[s]=Math.random()*16|0}var n=0;e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){var d=l==="x"?t[n]:t[n]&3|8;return n++,d.toString(16)});var a=tt.now(),o=a==null?void 0:a.toString(16).substring(3);return o?e.substring(0,28)+o:e},cE=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ri=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=cE()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},ql=function(i){var e;i&&typeof i.nodeName!="undefined"?(e=i,i=ri(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]};function e1(i){if(Array.isArray(i))return Gh(i)}function t1(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function i1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1225
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function si(i){return e1(i)||t1(i)||uE(i)||i1()}var Qr={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},r1=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=i?[console,i]:[console],l=(t=console.trace).bind.apply(t,si(o)),d=(r=console.info).bind.apply(r,si(o)),u=(s=console.debug).bind.apply(s,si(o)),c=(n=console.warn).bind.apply(n,si(o)),h=(a=console.error).bind.apply(a,si(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.TRACE))return l.apply(void 0,si(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.DEBUG))return u.apply(void 0,si(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.INFO))return d.apply(void 0,si(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.WARN))return c.apply(void 0,si(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Qr.ERROR))return h.apply(void 0,si(p))},get level(){return f},set level(m){m!==this.level&&(f=m!=null?m:e)}}},Oe=r1("[mux]"),Uh=Vt(ai());function Kh(){var i=Uh.default.doNotTrack||Uh.default.navigator&&Uh.default.navigator.doNotTrack;return i==="1"}function se(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}es();function ht(i,e){if(!Jr(i,e))throw new TypeError("Cannot call a class as a function")}function jv(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ri(i,e,t){return e&&jv(i.prototype,e),t&&jv(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function mn(i){return mn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},mn(i)}function s1(i,e){for(;!Object.prototype.hasOwnProperty.call(i,e)&&(i=mn(i),i!==null););return i}function Yl(i,e,t){return typeof Reflect!="undefined"&&Reflect.get?Yl=Reflect.get:Yl=function(r,s,n){var a=s1(r,s);if(a){var o=Object.getOwnPropertyDescriptor(a,s);return o.get?o.get.call(n||r):o.value}},Yl(i,e,t||i)}function Vh(i,e){return Vh=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},Vh(i,e)}function n1(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Vh(i,e)}function a1(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}sE();function o1(i,e){return e&&(rE(e)==="object"||typeof e=="function")?e:se(i)}function l1(i){var e=a1();return function(){var t=mn(i),r;if(e){var s=mn(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return o1(this,r)}}var ni=function(i){return Sa(i)[0]},Sa=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},Fh=Vt(ai()),d1={exists:function(){var i=Fh.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Fh.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Fh.default.performance,e=i&&i.timing;return e&&e.navigationStart}},jl=d1;function et(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function zl(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function u1(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Yh(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):u1(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var c1=["x-cdn","content-type"],hE=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],h1=c1.concat(hE);function qh(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(h1.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function Xl(i){if(i){var e=hE.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var f1=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},fE=f1,Wl=function(i){if(!i)return{};var e=jl.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},ba=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return qh(i.getAllResponseHeaders())},m1=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(E){var b=parseInt(s.version),T;return b===1&&E.programDateTime!==null&&(T=E.programDateTime),b===0&&E.pdt!==null&&(T=E.pdt),T};if(!jl.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(E,b){return i.emit(e,E,b)},d=function(E,b){var T=b.levels,_=b.audioTracks,A=b.url,x=b.stats,S=b.networkDetails,w=b.sessionData,M={},k={};T.forEach(function(V,ne){M[ne]={width:V.width,height:V.height,bitrate:V.bitrate,attrs:V.attrs}}),_.forEach(function(V,ne){k[ne]={name:V.name,language:V.lang,bitrate:V.bitrate}});var P=Wl(x),N=P.bytesLoaded,B=P.requestStart,X=P.responseStart,z=P.responseEnd;l("requestcompleted",Yh(zl({},fE(w)),{request_event_type:E,request_bytes_loaded:N,request_start:B,request_response_start:X,request_response_end:z,request_type:"manifest",request_hostname:ni(A),request_response_headers:ba(S),request_rendition_lists:{media:M,audio:k,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(E,b){var T=b.details,_=b.level,A=b.networkDetails,x=b.stats,S=Wl(x),w=S.bytesLoaded,M=S.requestStart,k=S.responseStart,P=S.responseEnd,N=T.fragments[T.fragments.length-1],B=o(N)+a(N.duration);l("requestcompleted",{request_event_type:E,request_bytes_loaded:w,request_start:M,request_response_start:k,request_response_end:P,request_current_level:_,request_type:"manifest",request_hostname:ni(T.url),request_response_headers:ba(A),video_holdback:T.holdBack&&a(T.holdBack),video_part_holdback:T.partHoldBack&&a(T.partHoldBack),video_part_target_duration:T.partTarget&&a(T.partTarget),video_target_duration:T.targetduration&&a(T.targetduration),video_source_is_live:T.live,player_manifest_newest_program_time:isNaN(B)?void 0:B})};t.on(s.Events.LEVEL_LOADED,u);var c=function(E,b){var T=b.details,_=b.networkDetails,A=b.stats,x=Wl(A),S=x.bytesLoaded,w=x.requestStart,M=x.responseStart,k=x.responseEnd;l("requestcompleted",{request_event_type:E,request_bytes_loaded:S,request_start:w,request_response_start:M,request_response_end:k,request_type:"manifest",request_hostname:ni(T.url),request_response_headers:ba(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(E,b){var T=b.stats,_=b.networkDetails,A=b.frag;T=T||A.stats;var x=Wl(T),S=x.bytesLoaded,w=x.requestStart,M=x.responseStart,k=x.responseEnd,P=_?ba(_):void 0,N={request_event_type:E,request_bytes_loaded:S,request_start:w,request_response_start:M,request_response_end:k,request_hostname:_?ni(_.responseURL):void 0,request_id:P?Xl(P):void 0,request_response_headers:P,request_media_duration:A.duration,request_url:_==null?void 0:_.responseURL};A.type==="main"?(N.request_type="media",N.request_current_level=A.level,N.request_video_width=(t.levels[A.level]||{}).width,N.request_video_height=(t.levels[A.level]||{}).height,N.request_labeled_bitrate=(t.levels[A.level]||{}).bitrate):N.request_type=A.type,l("requestcompleted",N)};t.on(s.Events.FRAG_LOADED,h);var f=function(E,b){var T=b.frag,_=T.start,A=o(T),x={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",x)};t.on(s.Events.FRAG_CHANGED,f);var m=function(E,b){var T=b.type,_=b.details,A=b.response,x=b.fatal,S=b.frag,w=b.networkDetails,M=(S==null?void 0:S.url)||b.url||"",k=w?ba(w):void 0;if((_===s.ErrorDetails.MANIFEST_LOAD_ERROR||_===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT||_===s.ErrorDetails.LEVEL_LOAD_ERROR||_===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:_,request_url:M,request_hostname:ni(M),request_id:k?Xl(k):void 0,request_type:_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:A==null?void 0:A.code,request_error_text:A==null?void 0:A.text}),x){var P,N="".concat(M?"url: ".concat(M,`
1226
1226
  `):"")+"".concat(A&&(A.code||A.text)?"response: ".concat(A.code,", ").concat(A.text,`
1227
1227
  `):"")+"".concat(b.reason?"failure reason: ".concat(b.reason,`
1228
1228
  `):"")+"".concat(b.level?"level: ".concat(b.level,`
@@ -1231,38 +1231,38 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1231
1231
  `):"")+"".concat(b.error?"error: ".concat(b.error,`
1232
1232
  `):"")+"".concat(b.event?"event: ".concat(b.event,`
1233
1233
  `):"")+"".concat(b.err?"error message: ".concat((P=b.err)===null||P===void 0?void 0:P.message,`
1234
- `):"");l("error",{player_error_code:T,player_error_message:_,player_error_context:N})}};t.on(s.Events.ERROR,m);var p=function(E,b){var T=b.frag,_=T&&T._url||"";l("requestcanceled",{request_event_type:E,request_url:_,request_type:"media",request_hostname:ni(_)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(E,b){var T=b.level,_=t.levels[T];if(_&&_.attrs&&_.attrs.BANDWIDTH){var A=_.attrs.BANDWIDTH,x,S=parseFloat(_.attrs["FRAME-RATE"]);isNaN(S)||(x=S),A?l("renditionchange",{video_source_fps:x,video_source_bitrate:A,video_source_width:_.width,video_source_height:_.height,video_source_rendition_name:_.name,video_source_codec:_==null?void 0:_.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},m1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Yv=function(i,e){if(!i||!i.requestEndDate)return{};var t=ni(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=Yh(d[d.length-1]._responseHeaders||""));var c=u?Ql(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},p1=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},g1=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},v1=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},E1=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var n=v1(t),a=function(T,_){return i.emit(e,T,_)},o=function(T){var _=T.type,A=T.data,x=(A||{}).url;a("requestcompleted",{request_event_type:_,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:ni(x),request_url:x})};t.on("manifestLoaded",o);var l={},d=function(T){if(typeof T.getRequests!="function")return null;var _=T.getRequests({state:"executed"});return _.length===0?null:_[_.length-1]},u=function(T){var _=T.type,A=T.fragmentModel,x=T.chunk,S=d(A);c({type:_,request:S,chunk:x})},c=function(T){var _=T.type,A=T.chunk,x=T.request,S=(A||{}).mediaInfo,w=S||{},M=w.type,k=w.bitrateList;k=k||[];var P={};k.forEach(function(oe,J){P[J]={},P[J].width=oe.width,P[J].height=oe.height,P[J].bitrate=oe.bandwidth,P[J].attrs={}}),M==="video"?l.video=P:M==="audio"?l.audio=P:l.media=P;var N=Yv(x,t),B=N.requestStart,X=N.requestResponseStart,z=N.requestResponseEnd,V=N.requestResponseHeaders,ne=N.requestMediaDuration,le=N.requestHostname,W=N.requestUrl,G=N.requestId;a("requestcompleted",{request_event_type:_,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:-1,request_type:M+"_init",request_response_headers:V,request_hostname:le,request_id:G,request_url:W,request_media_duration:ne,request_rendition_lists:l})};n>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",u);var h=function(T){var _=T.type,A=T.fragmentModel,x=T.chunk,S=d(A);f({type:_,request:S,chunk:x})},f=function(T){var _=T.type,A=T.chunk,x=T.request,S=A||{},w=S.mediaInfo,M=S.start,k=w||{},P=k.type,N=Yv(x,t),B=N.requestStart,X=N.requestResponseStart,z=N.requestResponseEnd,V=N.requestBytesLoaded,ne=N.requestResponseHeaders,le=N.requestMediaDuration,W=N.requestHostname,G=N.requestUrl,oe=N.requestId,J=p1(P,t),Ee=J.currentLevel,Ge=J.renditionWidth,Ye=J.renditionHeight,ze=J.renditionBitrate;a("requestcompleted",{request_event_type:_,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:V,request_type:P,request_response_headers:ne,request_hostname:W,request_id:oe,request_url:G,request_media_start_time:M,request_media_duration:le,request_current_level:Ee,request_labeled_bitrate:ze,request_video_width:Ge,request_video_height:Ye})};n>=4?t.on("mediaFragmentLoaded",f):t.on("mediaFragmentLoaded",h);var m={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(m.video&&typeof m.video.bitrate=="number"){if(!(m.video.width&&m.video.height)){s.warn("have bitrate info for video but missing width/height");return}var T=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(T+=m.audio.bitrate),T!==m.totalBitrate)return m.totalBitrate=T,{video_source_bitrate:T,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:g1(m.video.codec)}}},g=function(T,_,A){if(typeof T.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",T);return}var x=T.mediaType;if(x==="audio"||x==="video"){var S=t.getBitrateInfoListFor(x).find(function(M){var k=M.qualityIndex;return k===T.newQuality});if(!(S&&typeof S.bitrate=="number")){s.warn("missing bitrate info for ".concat(x));return}m[x]=Wh(Xl({},S),{codec:t.getCurrentTrackFor(x).codec});var w=p();w&&a("renditionchange",w)}};t.on("qualityChangeRendered",g);var E=function(T){var _=T.request,A=T.mediaType;_=_||{},a("requestcanceled",{request_event_type:_.type+"_"+_.action,request_url:_.url,request_type:A,request_hostname:ni(_.url)})};t.on("fragmentLoadingAbandoned",E);var b=function(T){var _=T.error,A,x,S=(_==null||(A=_.data)===null||A===void 0?void 0:A.request)||{},w=(_==null||(x=_.data)===null||x===void 0?void 0:x.response)||{};(_==null?void 0:_.code)===27&&a("requestfailed",{request_error:S.type+"_"+S.action,request_url:S.url,request_hostname:ni(S.url),request_type:S.mediaType,request_error_code:w.status,request_error_text:w.statusText});var M="".concat(S!=null&&S.url?"url: ".concat(S.url,`
1234
+ `):"");l("error",{player_error_code:T,player_error_message:_,player_error_context:N})}};t.on(s.Events.ERROR,m);var p=function(E,b){var T=b.frag,_=T&&T._url||"";l("requestcanceled",{request_event_type:E,request_url:_,request_type:"media",request_hostname:ni(_)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(E,b){var T=b.level,_=t.levels[T];if(_&&_.attrs&&_.attrs.BANDWIDTH){var A=_.attrs.BANDWIDTH,x,S=parseFloat(_.attrs["FRAME-RATE"]);isNaN(S)||(x=S),A?l("renditionchange",{video_source_fps:x,video_source_bitrate:A,video_source_width:_.width,video_source_height:_.height,video_source_rendition_name:_.name,video_source_codec:_==null?void 0:_.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},p1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},zv=function(i,e){if(!i||!i.requestEndDate)return{};var t=ni(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=qh(d[d.length-1]._responseHeaders||""));var c=u?Xl(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},g1=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},v1=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},E1=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},b1=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var n=E1(t),a=function(T,_){return i.emit(e,T,_)},o=function(T){var _=T.type,A=T.data,x=(A||{}).url;a("requestcompleted",{request_event_type:_,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:ni(x),request_url:x})};t.on("manifestLoaded",o);var l={},d=function(T){if(typeof T.getRequests!="function")return null;var _=T.getRequests({state:"executed"});return _.length===0?null:_[_.length-1]},u=function(T){var _=T.type,A=T.fragmentModel,x=T.chunk,S=d(A);c({type:_,request:S,chunk:x})},c=function(T){var _=T.type,A=T.chunk,x=T.request,S=(A||{}).mediaInfo,w=S||{},M=w.type,k=w.bitrateList;k=k||[];var P={};k.forEach(function(oe,J){P[J]={},P[J].width=oe.width,P[J].height=oe.height,P[J].bitrate=oe.bandwidth,P[J].attrs={}}),M==="video"?l.video=P:M==="audio"?l.audio=P:l.media=P;var N=zv(x,t),B=N.requestStart,X=N.requestResponseStart,z=N.requestResponseEnd,V=N.requestResponseHeaders,ne=N.requestMediaDuration,le=N.requestHostname,W=N.requestUrl,G=N.requestId;a("requestcompleted",{request_event_type:_,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:-1,request_type:M+"_init",request_response_headers:V,request_hostname:le,request_id:G,request_url:W,request_media_duration:ne,request_rendition_lists:l})};n>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",u);var h=function(T){var _=T.type,A=T.fragmentModel,x=T.chunk,S=d(A);f({type:_,request:S,chunk:x})},f=function(T){var _=T.type,A=T.chunk,x=T.request,S=A||{},w=S.mediaInfo,M=S.start,k=w||{},P=k.type,N=zv(x,t),B=N.requestStart,X=N.requestResponseStart,z=N.requestResponseEnd,V=N.requestBytesLoaded,ne=N.requestResponseHeaders,le=N.requestMediaDuration,W=N.requestHostname,G=N.requestUrl,oe=N.requestId,J=g1(P,t),Ee=J.currentLevel,Ge=J.renditionWidth,Ye=J.renditionHeight,ze=J.renditionBitrate;a("requestcompleted",{request_event_type:_,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:V,request_type:P,request_response_headers:ne,request_hostname:W,request_id:oe,request_url:G,request_media_start_time:M,request_media_duration:le,request_current_level:Ee,request_labeled_bitrate:ze,request_video_width:Ge,request_video_height:Ye})};n>=4?t.on("mediaFragmentLoaded",f):t.on("mediaFragmentLoaded",h);var m={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(m.video&&typeof m.video.bitrate=="number"){if(!(m.video.width&&m.video.height)){s.warn("have bitrate info for video but missing width/height");return}var T=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(T+=m.audio.bitrate),T!==m.totalBitrate)return m.totalBitrate=T,{video_source_bitrate:T,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:v1(m.video.codec)}}},g=function(T,_,A){if(typeof T.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",T);return}var x=T.mediaType;if(x==="audio"||x==="video"){var S=t.getBitrateInfoListFor(x).find(function(M){var k=M.qualityIndex;return k===T.newQuality});if(!(S&&typeof S.bitrate=="number")){s.warn("missing bitrate info for ".concat(x));return}m[x]=Yh(zl({},S),{codec:t.getCurrentTrackFor(x).codec});var w=p();w&&a("renditionchange",w)}};t.on("qualityChangeRendered",g);var E=function(T){var _=T.request,A=T.mediaType;_=_||{},a("requestcanceled",{request_event_type:_.type+"_"+_.action,request_url:_.url,request_type:A,request_hostname:ni(_.url)})};t.on("fragmentLoadingAbandoned",E);var b=function(T){var _=T.error,A,x,S=(_==null||(A=_.data)===null||A===void 0?void 0:A.request)||{},w=(_==null||(x=_.data)===null||x===void 0?void 0:x.response)||{};(_==null?void 0:_.code)===27&&a("requestfailed",{request_error:S.type+"_"+S.action,request_url:S.url,request_hostname:ni(S.url),request_type:S.mediaType,request_error_code:w.status,request_error_text:w.statusText});var M="".concat(S!=null&&S.url?"url: ".concat(S.url,`
1235
1235
  `):"")+"".concat(w!=null&&w.status||w!=null&&w.statusText?"response: ".concat(w==null?void 0:w.status,", ").concat(w==null?void 0:w.statusText,`
1236
- `):"");a("error",{player_error_code:_==null?void 0:_.code,player_error_message:_==null?void 0:_.message,player_error_context:M})};t.on("error",b),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",b),t.off("fragmentLoadingAbandoned",E),delete t._stopMuxMonitor}},b1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},qv=0,y1=function(){"use strict";function i(){ht(this,i),H(this,"_listeners",void 0)}return Ri(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++qv,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++qv;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),T1=y1,Fh=Vt(ai()),_1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(Fh.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ri(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=Fh.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(Fh.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),A1=_1,S1=function i(e){"use strict";var t=this;ht(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},x1=S1,R1=function(){"use strict";function i(e){ht(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ri(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),et(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),I1=R1,L1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ri(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&et(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),k1=L1,C1=function(){"use strict";function i(e){ht(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ri(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),w1=C1,jv=5*60*1e3,D1=function i(e){"use strict";if(ht(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;et(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>jv&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(jv,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(et(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},M1=D1,P1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return Ri(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),O1=P1,N1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ri(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),U1=N1,F1=function i(e){"use strict";var t=this;ht(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),et(e.data,"view_total_content_playback_time",a),et(e.data,"view_total_upscaling",l*a),et(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},B1=F1,$1=2e3,H1=function i(e){"use strict";var t=this;ht(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);et(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=$1){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,et(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},G1=H1,zv=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},K1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],V1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),K1.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),zv(t._adRequests,n),et(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||et(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),zv(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&et(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,et(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ri(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=Xi(Sa(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Xi(Sa(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),W1=V1,Xv=Vt(ai()),Y1=function i(e){"use strict";ht(this,i);var t,r,s=function(){e.disableRebufferTracking||(et(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=Xv.default.setInterval(function(){if(t){var d=tt.now();et(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(et(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,Xv.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},q1=Y1,j1=function i(e){"use strict";var t=this;ht(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},z1=j1,Bh=Vt(ai()),cE=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document!="undefined"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),hE="muxData",X1=function(i){return Object.entries(i).map(function(e){var t=Xi(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},Q1=function(i){return i.split("&").reduce(function(e,t){var r=Xi(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},fE=function(){var i;try{i=Q1(cE.get(hE)||"")}catch{i={}}return i},mE=function(i){try{cE.set(hE,X1(i),{expires:365})}catch{}},Z1=function(){var i=fE();return i.mux_viewer_id=i.mux_viewer_id||Aa(),i.msn=i.msn||Math.random(),mE(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},J1=function(){var i=fE(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=Aa(),i.sst=e),i.sex=e+25*60*1e3,mE(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function ex(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var tx=Vt(ai()),pE=function(){var i;switch(gE()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},gE=function(){var i=tx.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};pE.getConnectionFromAPI=gE;var ix=pE,rx={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},sx=vE(rx),nx={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},Qv=vE(nx);function vE(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function Vh(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=sx[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),Qv[l]?o+=Qv[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var Zr=Vt(ai()),ax={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ox=56*1024,lx=["hb","requestcompleted","requestfailed","requestcanceled"],dx="https://img.litix.io",Qi=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||dx,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ax,e)};Qi.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Qi.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Qi.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),Zr.default.clearTimeout(this._sendTimeout)};Qi.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],Vh({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);EE(this._beaconUrl,t,!0,function(){})};Qi.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();EE(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1})}};Qi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Qi.prototype._startBeaconSending=function(){var i=this;Zr.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=Zr.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Qi.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return lx.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var ux=function(i){return i.length<=ox},EE=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(Zr.default.fetch){Zr.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:ux(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(Zr.default.XMLHttpRequest){var s=new Zr.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},cx=Qi,hx=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],fx=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],mx=["ad_id","ad_creative_id","ad_universal_id"],px=["viewstart","error","ended","viewend"],gx=10*60*1e3,vx=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ht(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new cx(ex(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var b;this.respectDoNotTrack=(b=this.options.respectDoNotTrack)!==null&&b!==void 0?b:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:ix(),page_url:Bh.default===null||Bh.default===void 0||(p=Bh.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:Z1()}return Ri(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Gh())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:J1(),s=Wh(Xl({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=Vh(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Pe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):px.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=Vh(s),this.eventQueue.queueEvent(s.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=gx)s=Xl({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Xi(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||hx.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||mx.includes(t)&&fx.includes(e))}}]),i}(),Ex=function i(e){"use strict";ht(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var b,T;if(p?(b=p-(m!=null?m:0),T=(g!=null?g:0)-p):T=(g!=null?g:0)-(m!=null?m:0),T>0&&E&&E>0){var _=E/T*8e3;a++,r+=E,s+=T,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,_),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,b>0&&(t+=b,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,b),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},bx=Ex,yx=60*60*1e3,Tx=function i(e){"use strict";var t=this;ht(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>yx){var l=Object.keys(e.data).reduce(function(u,c){return c.indexOf("video_")===0?Object.assign(u,H({},c,e.data[c])):u},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view");var d=e.playbackHeartbeat._playheadShouldBeProgressing;e._resetView(Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing=d,e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},_x=Tx,Ax=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Sx=new Set(["requestcompleted","requestfailed","requestcanceled"]),xx=function(i){"use strict";s1(t,i);var e=o1(t);function t(r,s,n){ht(this,t);var a;a=e.call(this),H(se(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(se(a),"NAVIGATION_START",void 0),H(se(a),"_destroyed",void 0),H(se(a),"_heartBeatTimeout",void 0),H(se(a),"adTracker",void 0),H(se(a),"dashjs",void 0),H(se(a),"data",void 0),H(se(a),"disablePlayheadRebufferTracking",void 0),H(se(a),"disableRebufferTracking",void 0),H(se(a),"errorTracker",void 0),H(se(a),"errorTranslator",void 0),H(se(a),"emitTranslator",void 0),H(se(a),"getAdData",void 0),H(se(a),"getPlayheadTime",void 0),H(se(a),"getStateData",void 0),H(se(a),"stateDataTranslator",void 0),H(se(a),"hlsjs",void 0),H(se(a),"id",void 0),H(se(a),"longResumeTracker",void 0),H(se(a),"minimumRebufferDuration",void 0),H(se(a),"mux",void 0),H(se(a),"playbackEventDispatcher",void 0),H(se(a),"playbackHeartbeat",void 0),H(se(a),"playbackHeartbeatTime",void 0),H(se(a),"playheadTime",void 0),H(se(a),"seekingTracker",void 0),H(se(a),"sustainedRebufferThreshold",void 0),H(se(a),"watchTimeTracker",void 0),H(se(a),"currentFragmentPDT",void 0),H(se(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=zl.domContentLoadedEventEnd(),a.NAVIGATION_START=zl.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(h){return h},emitTranslator:function(){for(var h=arguments.length,f=new Array(h),m=0;m<h;m++)f[m]=arguments[m];return f},stateDataTranslator:function(h){return h}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.level=n.debug?Qr.DEBUG:Qr.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.emitTranslator=n.emitTranslator,a.stateDataTranslator=n.stateDataTranslator,a.playbackEventDispatcher=new vx(r,n.data.env_key,n),a.data={player_instance_id:Aa(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(se(a));if(a.on("viewinit",function(h,f){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,f),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)}),a.on("videochange",function(h,f){this._resetView(f)}),a.on("programchange",function(h,f){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(f,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(h,f){this.currentFragmentPDT=f.currentFragmentPDT,this.currentFragmentStart=f.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var d=function(){var h=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",h&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",d,!1);var u=function(h){h.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",d),window.removeEventListener("pagehide",u)})}a.on("playerready",function(h,f){Object.assign(this.data,f)}),Ax.forEach(function(h){a.on(h,function(f,m){h.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,m),this._sanitizeData()}),a.on("after"+h,function(){(h!=="error"||this.errorTracker.viewErrored)&&this.send(h)})}),a.on("viewend",function(h,f){Object.assign(a.data,f)});var c=function(h){var f=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=f-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",c),a.longResumeTracker=new _x(se(a)),a.errorTracker=new x1(se(a)),new z1(se(a)),a.seekingTracker=new G1(se(a)),a.playheadTime=new w1(se(a)),a.playbackHeartbeat=new A1(se(a)),new B1(se(a)),a.watchTimeTracker=new I1(se(a)),new k1(se(a)),a.adTracker=new W1(se(a)),new O1(se(a)),new M1(se(a)),new U1(se(a)),new q1(se(a)),new bx(se(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ri(t,[{key:"emit",value:function(r,s){var n,a=Object.assign({viewer_time:this.mux.utils.now()},s),o=[r,a];if(this.emitTranslator)try{o=this.emitTranslator(r,a)}catch(l){this.mux.log.warn("Exception in emit translator callback.",l)}o!=null&&o.length&&(n=ql(mn(t.prototype),"emit",this)).call.apply(n,[this].concat(si(o)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=Xi(Sa(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,Sx.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_resetView",value:function(r){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",r)}},{key:"_updateStateData",value:function(){var r=this.getStateData();if(typeof this.stateDataTranslator=="function")try{r=this.stateDataTranslator(r)}catch(s){this.mux.log.warn("Exception in stateDataTranslator translator callback.",s)}Object.assign(this.data,r),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=Aa(),n=function(){s===r.data.view_id&&et(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,f1(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(m1(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,E1(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(b1(this.dashjs),this.dashjs=void 0)}}]),t}(T1),Rx=xx,ya=Vt(qS());function Ix(){return ya.default&&!!(ya.default.fullscreenElement||ya.default.webkitFullscreenElement||ya.default.mozFullScreenElement||ya.default.msFullscreenElement)}var Lx=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],kx={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function Cx(i,e,t){var r=Xi(jl(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var c={getPlayheadTime:function(){return d(s.currentTime)},getStateData:function(){var f,m,p,g=((f=(m=this).getPlayheadTime)===null||f===void 0?void 0:f.call(m))||d(s.currentTime),E=this.hlsjs&&this.hlsjs.url,b=this.dashjs&&typeof this.dashjs.getSource=="function"&&this.dashjs.getSource(),T={player_is_paused:s.paused,player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:Ix(),video_poster_url:s.poster,video_source_url:E||b||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(p=s.getVideoPlaybackQuality)===null||p===void 0?void 0:p.call(s).droppedVideoFrames};if(s.getStartDate&&g>0){var _=s.getStartDate();if(_&&typeof _.getTime=="function"&&_.getTime()){var A=_.getTime();if(T.player_program_time=A+g,s.seekable.length>0){var x=A+s.seekable.end(s.seekable.length-1);T.player_live_edge_program_time=x}}}return T}};t=Object.assign(u,t,c),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(f,m){i.emit(n,f,m)},s.mux.updateData=function(f){s.mux.emit("hb",f)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(f){s.removeEventListener(f,s.mux.listeners[f],!1)}),delete s.mux.listeners,s.mux.destroy=h,s.mux.swapElement=h,s.mux.emit=h,s.mux.addHLSJS=h,s.mux.addDashJS=h,s.mux.removeHLSJS=h,s.mux.removeDashJS=h,s.mux.updateData=h,s.mux.setEmitTranslator=h,s.mux.setStateDataTranslator=h,s.mux.setGetPlayheadTime=h,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(f){var m=Xi(jl(f),3),p=m[0],g=m[1],E=m[2];if(p){if(E!=="video"&&E!=="audio")return i.log.error("The element of `"+g+"` was not a media element.")}else return i.log.error("No element was found with the `"+g+"` query selector.");p.muxId=s.muxId,delete s.muxId,p.mux=p.mux||{},p.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(p.mux.listeners).forEach(function(b){s.removeEventListener(b,p.mux.listeners[b],!1),p.addEventListener(b,p.mux.listeners[b],!1)}),p.mux.swapElement=s.mux.swapElement,p.mux.destroy=s.mux.destroy,delete s.mux,s=p},s.mux.addHLSJS=function(f){i.addHLSJS(n,f)},s.mux.addDashJS=function(f){i.addDashJS(n,f)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},s.mux.setEmitTranslator=function(f){i.setEmitTranslator(n,f)},s.mux.setStateDataTranslator=function(f){i.setStateDataTranslator(n,f)},s.mux.setGetPlayheadTime=function(f){f||(f=t.getPlayheadTime),i.setGetPlayheadTime(n,f)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},Lx.forEach(function(f){f==="error"&&!t.automaticErrorTracking||(s.mux.listeners[f]=function(){var m={};if(f==="error"){if(!s.error||s.error.code===1)return;m.player_error_code=s.error.code,m.player_error_message=kx[s.error.code]||s.error.message}i.emit(n,f,m)},s.addEventListener(f,s.mux.listeners[f],!1))})}function wx(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return s}var _a=Vt(ai()),fn;_a.default&&_a.default.WeakMap&&(fn=new WeakMap);function Dx(i,e){if(!i||!e||!_a.default||typeof _a.default.getComputedStyle!="function")return"";var t;return fn&&fn.has(i)&&(t=fn.get(i)),t||(t=_a.default.getComputedStyle(i,null),fn&&fn.set(i,t)),t.getPropertyValue(e)}function Mx(i){return Math.floor(i*1e3)}var Xr={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Zl=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Zl.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
1236
+ `):"");a("error",{player_error_code:_==null?void 0:_.code,player_error_message:_==null?void 0:_.message,player_error_context:M})};t.on("error",b),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",b),t.off("fragmentLoadingAbandoned",E),delete t._stopMuxMonitor}},y1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Xv=0,T1=function(){"use strict";function i(){ht(this,i),H(this,"_listeners",void 0)}return Ri(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++Xv,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++Xv;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),_1=T1,Bh=Vt(ai()),A1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(Bh.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ri(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=Bh.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(Bh.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),S1=A1,x1=function i(e){"use strict";var t=this;ht(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},R1=x1,I1=function(){"use strict";function i(e){ht(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ri(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),et(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),L1=I1,k1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ri(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&et(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),C1=k1,w1=function(){"use strict";function i(e){ht(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ri(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),D1=w1,Qv=5*60*1e3,M1=function i(e){"use strict";if(ht(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;et(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>Qv&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(Qv,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(et(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},P1=M1,O1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return Ri(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),N1=O1,U1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ri(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),F1=U1,B1=function i(e){"use strict";var t=this;ht(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),et(e.data,"view_total_content_playback_time",a),et(e.data,"view_total_upscaling",l*a),et(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},$1=B1,H1=2e3,G1=function i(e){"use strict";var t=this;ht(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);et(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=H1){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,et(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},K1=G1,Zv=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},V1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],W1=function(){"use strict";function i(e){var t=this;ht(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),V1.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),Zv(t._adRequests,n),et(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||et(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),Zv(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&et(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,et(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ri(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=Xi(Sa(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Xi(Sa(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),Y1=W1,Jv=Vt(ai()),q1=function i(e){"use strict";ht(this,i);var t,r,s=function(){e.disableRebufferTracking||(et(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=Jv.default.setInterval(function(){if(t){var d=tt.now();et(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(et(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,Jv.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},j1=q1,z1=function i(e){"use strict";var t=this;ht(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},X1=z1,$h=Vt(ai()),mE=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document!="undefined"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),pE="muxData",Q1=function(i){return Object.entries(i).map(function(e){var t=Xi(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},Z1=function(i){return i.split("&").reduce(function(e,t){var r=Xi(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},gE=function(){var i;try{i=Z1(mE.get(pE)||"")}catch{i={}}return i},vE=function(i){try{mE.set(pE,Q1(i),{expires:365})}catch{}},J1=function(){var i=gE();return i.mux_viewer_id=i.mux_viewer_id||Aa(),i.msn=i.msn||Math.random(),vE(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},ex=function(){var i=gE(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=Aa(),i.sst=e),i.sex=e+25*60*1e3,vE(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function tx(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var ix=Vt(ai()),EE=function(){var i;switch(bE()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},bE=function(){var i=ix.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};EE.getConnectionFromAPI=bE;var rx=EE,sx={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},nx=yE(sx),ax={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},eE=yE(ax);function yE(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function Wh(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=nx[a];o||(Oe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),eE[l]?o+=eE[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Oe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var Zr=Vt(ai()),ox={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},lx=56*1024,dx=["hb","requestcompleted","requestfailed","requestcanceled"],ux="https://img.litix.io",Qi=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||ux,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ox,e)};Qi.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Qi.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Qi.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),Zr.default.clearTimeout(this._sendTimeout)};Qi.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],Wh({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);TE(this._beaconUrl,t,!0,function(){})};Qi.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();TE(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Oe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1})}};Qi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Qi.prototype._startBeaconSending=function(){var i=this;Zr.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=Zr.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Qi.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Oe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return dx.indexOf(l.e)===-1}),a()),o()||(Oe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var cx=function(i){return i.length<=lx},TE=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(Zr.default.fetch){Zr.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:cx(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(Zr.default.XMLHttpRequest){var s=new Zr.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},hx=Qi,fx=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],mx=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],px=["ad_id","ad_creative_id","ad_universal_id"],gx=["viewstart","error","ended","viewend"],vx=10*60*1e3,Ex=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ht(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new hx(tx(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var b;this.respectDoNotTrack=(b=this.options.respectDoNotTrack)!==null&&b!==void 0?b:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:rx(),page_url:$h.default===null||$h.default===void 0||(p=$h.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:J1()}return Ri(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Kh())return Oe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Oe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:ex(),s=Yh(zl({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=Wh(o);if(this.lastEventTime=this.mux.utils.now(),a)return Oe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Oe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Oe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):gx.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=Wh(s),this.eventQueue.queueEvent(s.event,l),Oe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=vx)s=zl({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Xi(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||fx.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||px.includes(t)&&mx.includes(e))}}]),i}(),bx=function i(e){"use strict";ht(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var b,T;if(p?(b=p-(m!=null?m:0),T=(g!=null?g:0)-p):T=(g!=null?g:0)-(m!=null?m:0),T>0&&E&&E>0){var _=E/T*8e3;a++,r+=E,s+=T,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,_),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,b>0&&(t+=b,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,b),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},yx=bx,Tx=60*60*1e3,_x=function i(e){"use strict";var t=this;ht(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>Tx){var l=Object.keys(e.data).reduce(function(u,c){return c.indexOf("video_")===0?Object.assign(u,H({},c,e.data[c])):u},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view");var d=e.playbackHeartbeat._playheadShouldBeProgressing;e._resetView(Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing=d,e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},Ax=_x,Sx=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],xx=new Set(["requestcompleted","requestfailed","requestcanceled"]),Rx=function(i){"use strict";n1(t,i);var e=l1(t);function t(r,s,n){ht(this,t);var a;a=e.call(this),H(se(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(se(a),"NAVIGATION_START",void 0),H(se(a),"_destroyed",void 0),H(se(a),"_heartBeatTimeout",void 0),H(se(a),"adTracker",void 0),H(se(a),"dashjs",void 0),H(se(a),"data",void 0),H(se(a),"disablePlayheadRebufferTracking",void 0),H(se(a),"disableRebufferTracking",void 0),H(se(a),"errorTracker",void 0),H(se(a),"errorTranslator",void 0),H(se(a),"emitTranslator",void 0),H(se(a),"getAdData",void 0),H(se(a),"getPlayheadTime",void 0),H(se(a),"getStateData",void 0),H(se(a),"stateDataTranslator",void 0),H(se(a),"hlsjs",void 0),H(se(a),"id",void 0),H(se(a),"longResumeTracker",void 0),H(se(a),"minimumRebufferDuration",void 0),H(se(a),"mux",void 0),H(se(a),"playbackEventDispatcher",void 0),H(se(a),"playbackHeartbeat",void 0),H(se(a),"playbackHeartbeatTime",void 0),H(se(a),"playheadTime",void 0),H(se(a),"seekingTracker",void 0),H(se(a),"sustainedRebufferThreshold",void 0),H(se(a),"watchTimeTracker",void 0),H(se(a),"currentFragmentPDT",void 0),H(se(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=jl.domContentLoadedEventEnd(),a.NAVIGATION_START=jl.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(h){return h},emitTranslator:function(){for(var h=arguments.length,f=new Array(h),m=0;m<h;m++)f[m]=arguments[m];return f},stateDataTranslator:function(h){return h}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Oe.level=n.debug?Qr.DEBUG:Qr.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.emitTranslator=n.emitTranslator,a.stateDataTranslator=n.stateDataTranslator,a.playbackEventDispatcher=new Ex(r,n.data.env_key,n),a.data={player_instance_id:Aa(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(se(a));if(a.on("viewinit",function(h,f){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,f),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)}),a.on("videochange",function(h,f){this._resetView(f)}),a.on("programchange",function(h,f){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(f,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(h,f){this.currentFragmentPDT=f.currentFragmentPDT,this.currentFragmentStart=f.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var d=function(){var h=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",h&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",d,!1);var u=function(h){h.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",d),window.removeEventListener("pagehide",u)})}a.on("playerready",function(h,f){Object.assign(this.data,f)}),Sx.forEach(function(h){a.on(h,function(f,m){h.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,m),this._sanitizeData()}),a.on("after"+h,function(){(h!=="error"||this.errorTracker.viewErrored)&&this.send(h)})}),a.on("viewend",function(h,f){Object.assign(a.data,f)});var c=function(h){var f=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=f-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",c),a.longResumeTracker=new Ax(se(a)),a.errorTracker=new R1(se(a)),new X1(se(a)),a.seekingTracker=new K1(se(a)),a.playheadTime=new D1(se(a)),a.playbackHeartbeat=new S1(se(a)),new $1(se(a)),a.watchTimeTracker=new L1(se(a)),new C1(se(a)),a.adTracker=new Y1(se(a)),new N1(se(a)),new P1(se(a)),new F1(se(a)),new j1(se(a)),new yx(se(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ri(t,[{key:"emit",value:function(r,s){var n,a=Object.assign({viewer_time:this.mux.utils.now()},s),o=[r,a];if(this.emitTranslator)try{o=this.emitTranslator(r,a)}catch(l){this.mux.log.warn("Exception in emit translator callback.",l)}o!=null&&o.length&&(n=Yl(mn(t.prototype),"emit",this)).call.apply(n,[this].concat(si(o)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=Xi(Sa(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,xx.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_resetView",value:function(r){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",r)}},{key:"_updateStateData",value:function(){var r=this.getStateData();if(typeof this.stateDataTranslator=="function")try{r=this.stateDataTranslator(r)}catch(s){this.mux.log.warn("Exception in stateDataTranslator translator callback.",s)}Object.assign(this.data,r),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=Aa(),n=function(){s===r.data.view_id&&et(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,m1(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(p1(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,b1(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(y1(this.dashjs),this.dashjs=void 0)}}]),t}(_1),Ix=Rx,ya=Vt(jS());function Lx(){return ya.default&&!!(ya.default.fullscreenElement||ya.default.webkitFullscreenElement||ya.default.mozFullScreenElement||ya.default.msFullscreenElement)}var kx=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Cx={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function wx(i,e,t){var r=Xi(ql(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var c={getPlayheadTime:function(){return d(s.currentTime)},getStateData:function(){var f,m,p,g=((f=(m=this).getPlayheadTime)===null||f===void 0?void 0:f.call(m))||d(s.currentTime),E=this.hlsjs&&this.hlsjs.url,b=this.dashjs&&typeof this.dashjs.getSource=="function"&&this.dashjs.getSource(),T={player_is_paused:s.paused,player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:Lx(),video_poster_url:s.poster,video_source_url:E||b||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(p=s.getVideoPlaybackQuality)===null||p===void 0?void 0:p.call(s).droppedVideoFrames};if(s.getStartDate&&g>0){var _=s.getStartDate();if(_&&typeof _.getTime=="function"&&_.getTime()){var A=_.getTime();if(T.player_program_time=A+g,s.seekable.length>0){var x=A+s.seekable.end(s.seekable.length-1);T.player_live_edge_program_time=x}}}return T}};t=Object.assign(u,t,c),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(f,m){i.emit(n,f,m)},s.mux.updateData=function(f){s.mux.emit("hb",f)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(f){s.removeEventListener(f,s.mux.listeners[f],!1)}),delete s.mux.listeners,s.mux.destroy=h,s.mux.swapElement=h,s.mux.emit=h,s.mux.addHLSJS=h,s.mux.addDashJS=h,s.mux.removeHLSJS=h,s.mux.removeDashJS=h,s.mux.updateData=h,s.mux.setEmitTranslator=h,s.mux.setStateDataTranslator=h,s.mux.setGetPlayheadTime=h,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(f){var m=Xi(ql(f),3),p=m[0],g=m[1],E=m[2];if(p){if(E!=="video"&&E!=="audio")return i.log.error("The element of `"+g+"` was not a media element.")}else return i.log.error("No element was found with the `"+g+"` query selector.");p.muxId=s.muxId,delete s.muxId,p.mux=p.mux||{},p.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(p.mux.listeners).forEach(function(b){s.removeEventListener(b,p.mux.listeners[b],!1),p.addEventListener(b,p.mux.listeners[b],!1)}),p.mux.swapElement=s.mux.swapElement,p.mux.destroy=s.mux.destroy,delete s.mux,s=p},s.mux.addHLSJS=function(f){i.addHLSJS(n,f)},s.mux.addDashJS=function(f){i.addDashJS(n,f)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},s.mux.setEmitTranslator=function(f){i.setEmitTranslator(n,f)},s.mux.setStateDataTranslator=function(f){i.setStateDataTranslator(n,f)},s.mux.setGetPlayheadTime=function(f){f||(f=t.getPlayheadTime),i.setGetPlayheadTime(n,f)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},kx.forEach(function(f){f==="error"&&!t.automaticErrorTracking||(s.mux.listeners[f]=function(){var m={};if(f==="error"){if(!s.error||s.error.code===1)return;m.player_error_code=s.error.code,m.player_error_message=Cx[s.error.code]||s.error.message}i.emit(n,f,m)},s.addEventListener(f,s.mux.listeners[f],!1))})}function Dx(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Oe.info("safeCall error",n)}return s}var _a=Vt(ai()),fn;_a.default&&_a.default.WeakMap&&(fn=new WeakMap);function Mx(i,e){if(!i||!e||!_a.default||typeof _a.default.getComputedStyle!="function")return"";var t;return fn&&fn.has(i)&&(t=fn.get(i)),t||(t=_a.default.getComputedStyle(i,null),fn&&fn.set(i,t)),t.getPropertyValue(e)}function Px(i){return Math.floor(i*1e3)}var Xr={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Ql=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Ql.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
1237
1237
  `);e>-1;e=this.buffer.indexOf(`
1238
- `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Zl.prototype.processLine=function(i){var e=i.indexOf(":"),t=Ux(i,e),r=t[0],s=t.length===2?qh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case Xr.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case Xr.PART_INF:{$h(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case Xr.SERVER_CONTROL:{$h(this.manifest,t),this.setHoldBack();break}case Xr.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case Xr.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case Xr.VERSION:{$h(this.manifest,t);break}case Xr.SESSION_DATA:{var o=Fx(t[1]),l=uE(o);Object.assign(this.manifest.sessionData,l)}}};Zl.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var $h=function(i,e){var t=bE(e[0].replace("#EXT-X-","")),r;Nx(e[1])?(r={},r=Object.assign(Ox(e[1]),r)):r=qh(e[1]),i[t]=r},bE=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},qh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},Px=function(i){var e={},t=i.split("=");if(t.length>1){var r=bE(t[0]);e[r]=qh(t[1])}return e},Ox=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=Px(s);t=Object.assign(n,t)}return t},Nx=function(i){return i.indexOf("=")>-1},Ux=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},Fx=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},Bx=Zl,$x={safeCall:wx,safeIncrement:et,getComputedStyle:Dx,secondsToMs:Mx,assign:Object.assign,headersStringToObject:Yh,cdnHeadersToRequestId:Ql,extractHostnameAndDomain:Sa,extractHostname:ni,manifestParser:Bx,generateShortID:lE,generateUUID:Aa,now:tt.now,findMediaElement:jl},Hx=$x,Gx={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled",HEARTBEAT:"hb",DESTROY:"destroy"},Kx=Gx,Vx="mux-embed",Wx="5.5.0",Yx="2.1",Je={},gr=function(i){var e=arguments;typeof i=="string"?gr.hasOwnProperty(i)?Ta.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),gr[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ta.default.setTimeout(function(){i(gr)},0):Pe.warn("`"+i+"` is invalid.")},qx={loaded:tt.now(),NAME:Vx,VERSION:Wx,API_VERSION:Yx,PLAYER_TRACKED:!1,monitor:function(i,e){return Cx(gr,i,e)},destroyMonitor:function(i){var e=Xi(jl(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=ri(i);Je[t]?Je[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=ri(i);Je[t]?Je[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=ri(i);Je[e]?Je[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=ri(i);Je[e]?Je[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Gh()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=ri(i);Je[t]=new Rx(gr,t,e)},emit:function(i,e,t){var r=ri(i);Je[r]?(Je[r].emit(e,t),e==="destroy"&&delete Je[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(i,e){var t=ri(i);Je[t]?Je[t].emit("hb",e):Pe.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(i,e){var t=ri(i);Je[t]?Je[t].emitTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(i,e){var t=ri(i);Je[t]?Je[t].stateDataTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(i,e){var t=ri(i);Je[t]?Je[t].getPlayheadTime=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:Gh,log:Pe,utils:Hx,events:Kx,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(gr,qx);typeof Ta.default!="undefined"&&typeof Ta.default.addEventListener=="function"&&Ta.default.addEventListener("pagehide",function(i){i.persisted||(gr.WINDOW_UNLOADING=!0)},!1);var Jl=gr;function jx(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var pb={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(pb);var Am=pb.exports;function yE(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function gt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?yE(Object(t),!0).forEach(function(r){Qx(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):yE(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function zx(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Xx(i){var e=zx(i,"string");return typeof e=="symbol"?e:String(e)}function Qx(i,e,t){return e=Xx(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function it(){return it=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},it.apply(this,arguments)}var q=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},Zx=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=Jx},Jx=Number.MAX_SAFE_INTEGER||9007199254740991,v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),re=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),D=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),is=function(){},mf={trace:is,debug:is,log:is,warn:is,info:is,error:is},Ia=mf;function eR(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):is}function tR(i,...e){e.forEach(function(t){Ia[t]=i[t]?i[t].bind(i):eR(t)})}function iR(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){tR(i,"debug","log","info","warn","error");try{Ia.log(`Debug logs enabled for "${e}" in hls.js version 1.5.18`)}catch{Ia=mf}}else Ia=mf}var L=Ia,rR=/^(\d+)x(\d+)$/,TE=/(.+?)=(".*?"|.*?)(?:,|$)/g,je=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),it(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=rR.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(TE.lastIndex=0;(t=TE.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function sR(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function nR(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var vd=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){L.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=it(new je({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);q(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(q(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&q(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},An=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},Ce={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Ed=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ce.AUDIO]:null,[Ce.VIDEO]:null,[Ce.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Am.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},La=class extends Ed{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new An,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!q(this.programDateTime))return null;let e=q(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ce.AUDIO]=null,e[Ce.VIDEO]=null,e[Ce.AUDIOVIDEO]=null}},pf=class extends Ed{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new An,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},aR=10,gf=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?q(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||aR}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Sm(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function oR(i){let e=vf(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function lR(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function dR(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Sm(a)):t=oR(a)}}return t}function vf(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var Sn=typeof self!="undefined"?self:void 0,$e={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Nt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function _E(i){switch(i){case Nt.FAIRPLAY:return $e.FAIRPLAY;case Nt.PLAYREADY:return $e.PLAYREADY;case Nt.WIDEVINE:return $e.WIDEVINE;case Nt.CLEARKEY:return $e.CLEARKEY}}var Ra={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function AE(i){if(i===Ra.WIDEVINE)return $e.WIDEVINE;if(i===Ra.PLAYREADY)return $e.PLAYREADY;if(i===Ra.CENC||i===Ra.CLEARKEY)return $e.CLEARKEY}function SE(i){switch(i){case $e.FAIRPLAY:return Nt.FAIRPLAY;case $e.PLAYREADY:return Nt.PLAYREADY;case $e.WIDEVINE:return Nt.WIDEVINE;case $e.CLEARKEY:return Nt.CLEARKEY}}function jh(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[$e.FAIRPLAY,$e.WIDEVINE,$e.PLAYREADY,$e.CLEARKEY].filter(s=>!!e[s]):[];return!r[$e.WIDEVINE]&&t&&r.push($e.WIDEVINE),r}var gb=function(i){return Sn!=null&&(i=Sn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function uR(i,e,t,r){let s;switch(i){case $e.FAIRPLAY:s=["cenc","sinf"];break;case $e.WIDEVINE:case $e.PLAYREADY:s=["cenc"];break;case $e.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return cR(s,e,t,r)}function cR(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function ns(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var xm=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,vb=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ca=(i,e)=>{let t=e,r=0;for(;xm(i,e);){r+=10;let s=Vd(i,e+6);r+=s,vb(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},Vd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},hR=(i,e)=>xm(i,e)&&Vd(i,e+6)+10<=i.length-e,Rm=i=>{let e=bb(i);for(let t=0;t<e.length;t++){let r=e[t];if(Eb(r))return ER(r)}},Eb=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",fR=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Vd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},bb=i=>{let e=0,t=[];for(;xm(i,e);){let r=Vd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=fR(i.subarray(e)),a=mR(n);a&&t.push(a),e+=n.size+10}vb(i,e)&&(e+=10)}return t},mR=i=>i.type==="PRIV"?pR(i):i.type[0]==="W"?vR(i):gR(i),pR=i=>{if(i.size<2)return;let e=wi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},gR=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=wi(i.data.subarray(t),!0);t+=r.length+1;let s=wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=wi(i.data.subarray(1));return{key:i.type,data:e}},vR=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=wi(i.data.subarray(t),!0);t+=r.length+1;let s=wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=wi(i.data);return{key:i.type,data:e}},ER=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},wi=(i,e=!1)=>{let t=bR();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},zh;function bR(){if(!navigator.userAgent.includes("PlayStation 4"))return!zh&&typeof self.TextDecoder!="undefined"&&(zh=new self.TextDecoder("utf-8")),zh}var Li={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},bd=Math.pow(2,32)-1,yR=[].push,yb={video:1,audio:2,id3:3,text:4};function nt(i){return String.fromCharCode.apply(null,i)}function Tb(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function ee(i,e){let t=_b(i,e);return t<0?4294967296+t:t}function xE(i,e){let t=ee(i,e);return t*=Math.pow(2,32),t+=ee(i,e+4),t}function _b(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Xh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function TR(i){let e=i.byteLength;for(let t=0;t<e;){let r=ee(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function ae(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=ee(i,s),a=nt(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=ae(i.subarray(s+8,o),e.slice(1));l.length&&yR.apply(t,l)}s=o}return t}function _R(i){let e=[],t=i[0],r=8,s=ee(i,r);r+=4;let n=0,a=0;t===0?(n=ee(i,r),a=ee(i,r+4),r+=8):(n=xE(i,r),a=xE(i,r+8),r+=16),r+=2;let o=i.length+a,l=Tb(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=ee(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return L.warn("SIDX has hierarchical references (not supported)"),null;let m=ee(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Ab(i){let e=[],t=ae(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=ae(n,["tkhd"])[0];if(a){let o=a[0],l=ee(a,o===0?12:20),d=ae(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=ee(d,o===0?12:20),c=ae(n,["mdia","hdlr"])[0];if(c){let h=nt(c.subarray(8,12)),f={soun:Ce.AUDIO,vide:Ce.VIDEO}[h];if(f){let m=ae(n,["mdia","minf","stbl","stsd"])[0],p=AR(m);e[l]={timescale:u,type:f},e[f]=gt({timescale:u,id:l},p)}}}}}return ae(i,["moov","mvex","trex"]).forEach(s=>{let n=ee(s,4),a=e[n];a&&(a.default={duration:ee(s,12),flags:ee(s,20)})}),e}function AR(i){let e=i.subarray(8),t=e.subarray(86),r=nt(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=ae(e,[r])[0].subarray(r==="enca"?28:78);ae(o,["sinf"]).forEach(d=>{let u=ae(d,["schm"])[0];if(u){let c=nt(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=ae(d,["frma"])[0];h&&(s=nt(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=ae(t,["avcC"])[0];s+="."+ed(a[1])+ed(a[2])+ed(a[3]);break}case"mp4a":{let a=ae(e,[r])[0],o=ae(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=Qh(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=Qh(o,l);let u=o[l++];if(u===64)s+="."+ed(u);else break;if(l+=12,o[l++]!==5)break;l=Qh(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=ae(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=ee(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=ae(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Ii(o)+"."+Ii(l);break}case"vp09":{let a=ae(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Ii(o)+"."+Ii(l)+"."+Ii(d);break}case"av01":{let a=ae(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Ii(l)+d+"."+Ii(h)+"."+f+"."+m+p+g+"."+Ii(1)+"."+Ii(1)+"."+Ii(1)+"."+0;break}}return{codec:s,encrypted:n}}function Qh(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function ed(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Ii(i){return(i<10?"0":"")+i}function SR(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&ae(i,["moov","trak"]).forEach(s=>{let a=ae(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=ae(a,["enca"]),l=o.length>0;l||(o=ae(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);ae(u,["sinf"]).forEach(h=>{let f=Sb(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(L.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Li.hexDump(m)} -> ${Li.hexDump(t)}`),f.set(t,8))}})})}),i}function Sb(i){let e=ae(i,["schm"])[0];if(e){let t=nt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return ae(i,["schi","tenc"])[0]}return null}function xR(i,e){return ae(e,["moof","traf"]).reduce((t,r)=>{let s=ae(r,["tfdt"])[0],n=s[0],a=ae(r,["tfhd"]).reduce((o,l)=>{let d=ee(l,4),u=i[d];if(u){let c=ee(s,4);if(n===1){if(c===bd)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=bd+1,c+=ee(s,8)}let h=u.timescale||9e4,f=c/h;if(q(f)&&(o===null||f<o))return f}return o},null);return a!==null&&q(a)&&(t===null||a<t)?a:t},null)}function RR(i,e){let t=0,r=0,s=0,n=ae(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=ae(o,["tfhd"])[0],d=ee(l,4),u=e[d];if(!u)continue;let c=u.default,h=ee(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=ee(l,12):f=ee(l,8));let m=u.timescale||9e4,p=ae(o,["trun"]);for(let g=0;g<p.length;g++){if(t=IR(p[g]),!t&&f){let E=ee(p[g],4);t=f*E}u.type===Ce.VIDEO?r+=t/m:u.type===Ce.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=ae(i,["sidx"]);for(let u=0;u<d.length;u++){let c=_R(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&q(l))return l}return r||s}function IR(i){let e=ee(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=ee(i,4);for(let n=0;n<s;n++){if(e&256){let a=ee(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function LR(i,e,t){ae(e,["moof","traf"]).forEach(r=>{ae(r,["tfhd"]).forEach(s=>{let n=ee(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;ae(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=ee(l,4);if(d===0)c-=u,c=Math.max(c,0),Xh(l,4,c);else{c*=Math.pow(2,32),c+=ee(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(bd+1)),f=Math.floor(c%(bd+1));Xh(l,4,h),Xh(l,8,f)}}})})})}function kR(i){let e={valid:null,remainder:null},t=ae(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=ns(i,0,r.byteOffset-8),e.remainder=ns(i,r.byteOffset-8),e}function Yt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function RE(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return ae(r,["moof"]).map(l=>{let d=l.byteOffset-8;ae(l,["traf"]).map(c=>{let h=ae(c,["tfdt"]).map(f=>{let m=f[0],p=ee(f,4);return m===1&&(p*=Math.pow(2,32),p+=ee(f,8)),p/s})[0];return h!==void 0&&(i=h),ae(c,["tfhd"]).map(f=>{let m=ee(f,4),p=ee(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,b=(p&8)!==0,T=0,_=(p&16)!==0,A=0,x=(p&32)!==0,S=8;m===n&&(g&&(S+=8),E&&(S+=4),b&&(T=ee(f,S),S+=4),_&&(A=ee(f,S),S+=4),x&&(S+=4),e.type==="video"&&(a=CR(e.codec)),ae(c,["trun"]).map(w=>{let M=w[0],k=ee(w,0)&16777215,P=(k&1)!==0,N=0,B=(k&4)!==0,X=(k&256)!==0,z=0,V=(k&512)!==0,ne=0,le=(k&1024)!==0,W=(k&2048)!==0,G=0,oe=ee(w,4),J=8;P&&(N=ee(w,J),J+=4),B&&(J+=4);let Ee=N+d;for(let Ge=0;Ge<oe;Ge++){if(X?(z=ee(w,J),J+=4):z=T,V?(ne=ee(w,J),J+=4):ne=A,le&&(J+=4),W&&(M===0?G=ee(w,J):G=_b(w,J),J+=4),e.type===Ce.VIDEO){let Ye=0;for(;Ye<ne;){let ze=ee(r,Ee);if(Ee+=4,wR(a,r[Ee])){let St=r.subarray(Ee,Ee+ze);xb(St,a?2:1,i+G/s,t)}Ee+=ze,Ye+=ze+4}}i+=z/s}}))})})}),t}function CR(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function wR(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function xb(i,e,t,r){let s=Rb(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){L.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=Tb(s,u);if(u+=2,h===49){let f=ee(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,E=64&p,b=E?2+g*3:0,T=new Uint8Array(b);if(E){T[0]=p;for(let _=1;_<b;_++)T[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:T})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:wi(f),userDataBytes:f})}}}function Rb(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function DR(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;nt(i.subarray(d,d+1))!=="\0";)t+=nt(i.subarray(d,d+1)),d+=1;for(t+=nt(i.subarray(d,d+1)),d+=1;nt(i.subarray(d,d+1))!=="\0";)r+=nt(i.subarray(d,d+1)),d+=1;r+=nt(i.subarray(d,d+1)),d+=1,s=ee(i,12),n=ee(i,16),o=ee(i,20),l=ee(i,24),d=28}else if(e===1){d+=4,s=ee(i,d),d+=4;let c=ee(i,d);d+=4;let h=ee(i,d);for(d+=4,a=2**32*c+h,Zx(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ee(i,d),d+=4,l=ee(i,d),d+=4;nt(i.subarray(d,d+1))!=="\0";)t+=nt(i.subarray(d,d+1)),d+=1;for(t+=nt(i.subarray(d,d+1)),d+=1;nt(i.subarray(d,d+1))!=="\0";)r+=nt(i.subarray(d,d+1)),d+=1;r+=nt(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function MR(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function PR(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),MR([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function OR(i){let e=[];if(i instanceof ArrayBuffer){let t=i.byteLength,r=0;for(;r+32<t;){let s=new DataView(i,r),n=NR(s);e.push(n),r+=n.size}}return e}function NR(i){let e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};let n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};let a=i.buffer,o=Li.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28),d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}var td={},wa=class i{static clearKeyUriToKeyIdMap(){td={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Nt.FAIRPLAY:case Nt.WIDEVINE:case Nt.PLAYREADY:case Nt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=UR(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=dR(this.uri);if(t)switch(this.keyFormat){case Nt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Nt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=PR(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){let c=Sm(u).subarray(0,16);lR(c),this.keyId=c}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=td[this.uri];if(!r){let s=Object.keys(td).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),td[this.uri]=r}this.keyId=r}return this}};function UR(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Ib=/\{\$([a-zA-Z0-9-_]+)\}/g;function IE(i){return Ib.test(i)}function Pt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Ef(i,n))}}function Ef(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Ib,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function LE(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function FR(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function as(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function BR(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var yd={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function $R(i,e){let t=yd[e];return!!t&&!!t[i.slice(0,4)]}function Zh(i,e,t=!0){return!i.split(",").some(r=>!Lb(r,e,t))}function Lb(i,e,t=!0){var r;let s=as(t);return(r=s==null?void 0:s.isTypeSupported(Da(i,e)))!=null?r:!1}function Da(i,e){return`${e}/mp4;codecs="${i}"`}function kE(i){if(i){let e=i.substring(0,4);return yd.video[e]}return 2}function Td(i){return i.split(",").reduce((e,t)=>{let r=yd.video[t];return r?(r*2+e)/(e?3:2):(yd.audio[t]+e)/(e?2:1)},0)}var Jh={};function HR(i,e=!0){if(Jh[i])return Jh[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(Lb(t[r],"audio",e))return Jh[i]=t[r],t[r];return i}var GR=/flac|opus/i;function _d(i,e=!0){return i.replace(GR,t=>HR(t.toLowerCase(),e))}function CE(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function KR(i){let e=i.split(",");for(let t=0;t<e.length;t++){let r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}var wE=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,DE=/#EXT-X-MEDIA:(.*)/g,VR=/^#EXT(?:INF|-X-TARGETDURATION):/m,ME=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),WR=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),rs=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return Am.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return VR.test(e)}static parseMasterPlaylist(e,t){let r=IE(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];wE.lastIndex=0;let a;for(;(a=wE.exec(e))!=null;)if(a[1]){var o;let d=new je(a[1]);Pt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Ef(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),YR(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new je(u);Pt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=PE(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new je(u);Pt(s,c,["NAME","VALUE","QUERYPARAM"]),LE(s,c,t)}break}case"CONTENT-STEERING":{let c=new je(u);Pt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=OE(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(DE.lastIndex=0;(s=DE.exec(e))!==null;){let d=new je(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,Pt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],b={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(b.assocLang=m),p&&(b.channels=p),g&&(b.characteristics=g),E&&(b.instreamId=E),c!=null&&c.length){let T=i.findGroup(c,b.groupId)||c[0];NE(b,T,"audioCodec"),NE(b,T,"textCodec")}h.push(b)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new gf(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new La(s,t),g,E,b,T=-1,_=!1,A=null;for(ME.lastIndex=0,o.m3u8=e,o.hasVariableRefs=IE(e);(g=ME.exec(e))!==null;){_&&(_=!1,p=new La(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,A&&(p.setByteRange(A),A=null)));let M=g[1];if(M){p.duration=parseFloat(M);let k=(" "+g[2]).slice(1);p.title=k||null,p.tagList.push(k?["INF",M,k]:["INF",M])}else if(g[3]){if(q(p.duration)){p.start=h,b&&BE(p,b,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let k=(" "+g[3]).slice(1);p.relurl=Ef(o,k),UE(p,m),m=p,h+=p.duration,u++,c=0,_=!0}}else if(g[4]){let k=(" "+g[4]).slice(1);m?p.setByteRange(k,m):p.setByteRange(k)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),T===-1&&(T=l.length);else{if(g=g[0].match(WR),!g){L.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&typeof g[E]=="undefined";E++);let k=(" "+g[E]).slice(1),P=(" "+g[E+1]).slice(1),N=g[E+2]?(" "+g[E+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(P);break;case"SKIP":{let B=new je(P);Pt(o,B,["RECENTLY-REMOVED-DATERANGES"]);let X=B.decimalInteger("SKIPPED-SEGMENTS");if(q(X)){o.skippedSegments=X;for(let V=X;V--;)l.unshift(null);u+=X}let z=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(o.recentlyRemovedDateranges=z.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(P),1);break;case"VERSION":o.version=parseInt(P);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(P||N)&&p.tagList.push(N?[P,N]:[P]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([k]);break;case"BITRATE":p.tagList.push([k,P]);break;case"DATERANGE":{let B=new je(P);Pt(o,B,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Pt(o,B,B.clientAttrs);let X=new vd(B,o.dateRanges[B.ID]);X.isValid||o.skippedSegments?o.dateRanges[X.id]=X:L.warn(`Ignoring invalid DATERANGE tag: "${P}"`),p.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":{{let B=new je(P);Pt(o,B,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in B?FR(o,B,a):LE(o,B,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(P);break;case"KEY":{let B=PE(P,t,o);if(B.isSupported()){if(B.method==="NONE"){b=void 0;break}b||(b={}),b[B.keyFormat]&&(b=it({},b)),b[B.keyFormat]=B}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=OE(P);break;case"MAP":{let B=new je(P);if(Pt(o,B,["BYTERANGE","URI"]),p.duration){let X=new La(s,t);FE(X,B,r,b),d=X,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let X=p.byteRangeEndOffset;if(X){let z=p.byteRangeStartOffset;A=`${X-z}@${z}`}else A=null;FE(p,B,r,b),d=p,_=!0}break}case"SERVER-CONTROL":{let B=new je(P);o.canBlockReload=B.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=B.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&B.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=B.optionalFloat("PART-HOLD-BACK",0),o.holdBack=B.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let B=new je(P);o.partTarget=B.decimalFloatingPoint("PART-TARGET");break}case"PART":{let B=o.partList;B||(B=o.partList=[]);let X=c>0?B[B.length-1]:void 0,z=c++,V=new je(P);Pt(o,V,["BYTERANGE","URI"]);let ne=new pf(V,p,t,z,X);B.push(ne),p.duration+=ne.duration;break}case"PRELOAD-HINT":{let B=new je(P);Pt(o,B,["URI"]),o.preloadHint=B;break}case"RENDITION-REPORT":{let B=new je(P);Pt(o,B,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(B);break}default:L.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(UE(p,m),p.cc=f,o.fragmentHint=p,b&&BE(p,b,o));let x=l.length,S=l[0],w=l[x-1];if(h+=o.skippedSegments*o.targetduration,h>0&&x&&w){o.averagetargetduration=h/x;let M=w.sn;o.endSN=M!=="initSegment"?M:0,o.live||(w.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,T>0&&qR(l,T),o}};function PE(i,e,t){var r,s;let n=new je(i);Pt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&L.error(`Invalid IV: ${n.IV}`);let c=o?rs.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new wa(a,c,u,h,l)}function OE(i){let t=new je(i).decimalFloatingPoint("TIME-OFFSET");return q(t)?t:null}function YR(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>$R(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function NE(i,e,t){let r=e[t];r&&(i[t]=r)}function qR(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function UE(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),q(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function FE(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function BE(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},te={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function $E(i){let{type:e}=i;switch(e){case Te.AUDIO_TRACK:return te.AUDIO;case Te.SUBTITLE_TRACK:return te.SUBTITLE;default:return te.MAIN}}function ef(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var bf=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Te.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:Te.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){L.trace("[playlist-loader]: playlist request ongoing");return}L.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Te.MANIFEST?n=r.manifestLoadPolicy.default:n=it({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),q((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Te.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Te.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Te.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=it({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),rs.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=ef(e,r),l=rs.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=rs.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(T=>!T.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(L.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new je({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=ef(e,r),c=0,h=q(l)?l:q(o)?o:0,f=$E(r),m=rs.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===Te.MANIFEST){let p={attrs:new je({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===Te.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Te.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Te.AUDIO_TRACK||e.type===Te.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);L.warn(`[playlist-loader]: ${a}`);let l=D.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case Te.MANIFEST:l=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case Te.LEVEL:l=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case Te.AUDIO_TRACK:l=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Te.SUBTITLE_TRACK:l=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:re.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=gt({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=ef(t,s),m=$E(s),p=typeof s.level=="number"&&m===te.MAIN?d:void 0;if(!e.fragments.length){let E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Te.MANIFEST:case Te.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Te.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Te.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function kb(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Cb(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){L.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function bn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function yf(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=zR(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function jR(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function zR(i,e,t){let r=[],s=jR(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function ud(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var ui={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},XR=.25;function Tf(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function HE(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?gt({type:s},r):r))}return n}var id=(()=>{let i=Tf();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function tf(i,e){return i.getTime()/1e3-e}function QR(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var _f=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(bn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return kb(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Tf();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===ui.emsg&&!r||!s)continue;let d=bb(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>id&&(c=id),c-u<=0&&(c=u+XR);for(let f=0;f<d.length;f++){let m=d[f];if(!Eb(m)){this.updateId3CueEnds(u,l);let p=HE(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===id&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===ui.audioId3&&l:s==="video"?d=u=>u.type===ui.emsg&&o:d=u=>u.type===ui.audioId3&&l||u.type===ui.emsg&&o,yf(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!q(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Tf();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=tf(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,E=id,b=h.endDate;if(b)E=tf(b,l),g=!0;else if(h.endOnNext&&!g){let _=a.reduce((A,x)=>{if(x!==h.id){let S=n[x];if(S.class===h.class&&S.startDate>h.startDate&&(!A||h.startDate<A.startDate))return S}return A},null);_&&(E=tf(_.startDate,l),g=!0)}let T=Object.keys(h.attr);for(let _=0;_<T.length;_++){let A=T[_];if(!sR(A))continue;let x=p[A];if(x)g&&!m.durationKnown&&(x.endTime=E);else if(d){let S=h.attr[A];nR(A)&&(S=QR(S));let w=HE(d,f,E,{key:A,data:S},ui.dateRange);w&&(w.id=c,this.id3Track.addCue(w),p[A]=w)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},Af=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&L.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Sf=["NONE","TYPE-0","TYPE-1",null];function ZR(i){return Sf.indexOf(i)>-1}var Ad=["SDR","PQ","HLG"];function JR(i){return!!i&&Ad.indexOf(i)>-1}var cd={No:"",Yes:"YES",v2:"v2"};function GE(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?cd.v2:cd.Yes:cd.No}var Sd=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},br=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return KE(this._audioGroups,e)}hasSubtitleGroup(e){return KE(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function KE(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function rf(i,e){let t=e.startPTS;if(q(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function wb(i,e,t,r,s,n){r-t<=0&&(L.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(q(d)){let g=Math.abs(d-t);q(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)rf(p[f],p[f-1]);for(f=m;f<p.length-1;f++)rf(p[f],p[f+1]);return i.fragmentHint&&rf(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function eI(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(rI(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),q(l.startPTS)&&q(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var u;d&&(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=tI(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){L.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),iI(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?wb(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Db(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function tI(i,e,t){let r=it({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new vd(e[s].attr,r[s]);n.isValid?r[s]=n:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function iI(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function rI(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function Db(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||xf(e,r[t].start)}function xf(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function sI(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments;if(r.length&&t*4>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function nI(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function VE(i,e,t){var r;return i!=null&&i.details?Mb((r=i.details)==null?void 0:r.partList,e,t):null}function Mb(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Pb(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function xd(i){switch(i.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function WE(i,e){let t=xd(e);return i.default[`${t?"timeout":"error"}Retry`]}function Im(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function YE(i){return gt(gt({},i),{errorRetry:null,timeoutRetry:null})}function Rd(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(aI(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function aI(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Ob={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function oI(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!q(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(dI(e,t,a))return a}return null}function Id(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;let o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&Rf(t,r,n)===0||lI(n,i,Math.min(s,r))))return n;let a=Ob.search(e,Rf.bind(null,t,r));return a&&(a!==i||!n)?a:n}function lI(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){let r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function Rf(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function dI(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function uI(i,e){return Ob.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var mt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},oi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},If=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===te.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:mt.DoNothing,flags:oi.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=mt.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===te.MAIN?t.level:n.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Te.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Te.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=mt.SendAlternateToPenaltyBox,t.errorAction.flags=oi.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:mt.SendAlternateToPenaltyBox,flags:oi.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:mt.DoNothing,flags:oi.None};return}t.type===re.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=WE(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Rd(s,n,xd(e),e.response))return{action:mt.RetryRequest,flags:oi.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=WE(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==D.FRAG_GAP&&s.fragmentError++,Rd(o,l,xd(e),e.response)))return{action:mt.RetryRequest,flags:oi.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===D.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,E=(p===te.AUDIO&&d===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:x})=>s.audioCodec!==x),T=e.sourceBufferName==="video"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR)&&c.some(({codecSet:x,audioCodec:S})=>s.codecSet!==x&&s.audioCodec===S),{type:_,groupId:A}=(a=e.context)!=null?a:{};for(let x=c.length;x--;){let S=(x+h)%c.length;if(S!==h&&S>=f&&S<=m&&c[S].loadError===0){var o,l;let w=c[S];if(d===D.FRAG_GAP&&p===te.MAIN&&e.frag){let M=c[S].details;if(M){let k=Id(e.frag,M.fragments,e.frag.start);if(k!=null&&k.gap)continue}}else{if(_===Te.AUDIO_TRACK&&w.hasAudioGroup(A)||_===Te.SUBTITLE_TRACK&&w.hasSubtitleGroup(A))continue;if(p===te.AUDIO&&(o=s.audioGroups)!=null&&o.some(M=>w.hasAudioGroup(M))||p===te.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(M=>w.hasSubtitleGroup(M))||E&&s.audioCodec===w.audioCodec||!E&&s.audioCodec!==w.audioCodec||T&&s.codecSet===w.codecSet)continue}u=S;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:mt.SendAlternateToPenaltyBox,flags:oi.None,nextAutoLevel:u}}return{action:mt.SendAlternateToPenaltyBox,flags:oi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case mt.DoNothing:break;case mt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case mt.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case oi.None:this.switchLevel(e,a);break;case oi.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Sf[Sf.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},Ma=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=L.log.bind(L,`${t}:`),this.warn=L.warn.bind(L,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){L.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&GE(r);return new Sd(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&eI(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,E=s.lastPartSn,b=s.endSN,T=s.lastPartIndex,_=T!==-1,A=E===b,x=g?0:T;_?(d=A?b+1:E,u=A?x:T+1):d=b+1;let S=s.age,w=S+s.ageHeader,M=Math.min(w-s.partTarget,s.targetduration*1.5);if(M>0){if(r&&M>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${M} with playlist age: ${s.age}`),M=0;else{let k=Math.floor(M/s.targetduration);if(d+=k,u!==void 0){let P=Math.round(M%s.targetduration/s.partTarget);u+=P}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${S.toFixed(2)}s goal: ${M} skip sn ${k} to part ${u}`)}s.tuneInGoal=M}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!A){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=sI(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=GE(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=cd.No),new Sd(r,s,n)}checkRetry(e){let t=e.details,r=xd(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===mt.RetryRequest||!s.resolved&&n===mt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Im(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Er=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Lf=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Er(e),this.fast_=new Er(t),this.defaultTTFB_=s,this.ttfb_=new Er(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Er(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Er(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Er(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},Nb={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},qE={};function cI(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&q(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function hI(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(Nb);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:gt(gt({},n),{},{contentType:Da(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);q(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:Da(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=fI(l);return qE[d]||(qE[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function fI(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function mI(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function pI(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||Ad.slice(0),t=e.preferHDR!==void 0?e.preferHDR:mI(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function gI(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:E}=pI(e,s);for(let A=n.length;A--;){let x=i[n[A]];d=x.channels[2]>0,c=Math.min(c,x.minHeight),h=Math.min(h,x.minFramerate),f=Math.min(f,x.minBitrate);let S=E.filter(w=>x.videoRanges[w]>0);S.length>0&&(u=!0,p=S)}c=q(c)?c:0,h=q(h)?h:0;let b=Math.max(1080,c),T=Math.max(30,h);return f=q(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((A,x)=>{let S=i[x];if(x===A)return A;if(S.minBitrate>t)return Zi(x,`min bitrate of ${S.minBitrate} > current estimate of ${t}`),A;if(!S.hasDefaultAudio)return Zi(x,"no renditions with default or auto-select sound found"),A;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Zi(x,`audio codec preference "${o}" not found`),A;if(a&&!l){if(!S.channels[a])return Zi(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(S.channels)})`),A}else if((!o||l)&&d&&S.channels[2]===0)return Zi(x,"no renditions with stereo sound found"),A;return S.minHeight>b?(Zi(x,`min resolution of ${S.minHeight} > maximum of ${b}`),A):S.minFramerate>T?(Zi(x,`min framerate of ${S.minFramerate} > maximum of ${T}`),A):p.some(w=>S.videoRanges[w]>0)?S.maxScore<m?(Zi(x,`max score of ${S.maxScore} < selected max of ${m}`),A):A&&(Td(x)>=Td(A)||S.fragmentError>i[A].fragmentError)?A:(m=S.maxScore,x):(Zi(x,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),A)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Zi(i,e){L.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function vI(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function EI(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function Ci(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(Tn(i,s,t))return r}return-1}function Tn(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||bI(o,e.characteristics))&&(t===void 0||t(i,e))}function bI(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function pn(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function yI(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=jE(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Ci(i,m,s)>-1});return c>-1?c:jE(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Ci(i,m,s)>-1})}function jE(i,e,t){for(let r=e;r>-1;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var kf=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,b=this.getBwEstimate(),T=s.levels,_=T[t.level],A=l.total||Math.max(l.loaded,Math.round(d*_.averageBitrate/8)),x=E?u-g:u;x<1&&E&&(x=Math.min(u,l.loaded*8/b));let S=E?l.loaded*1e3/x:0,w=S?(A-l.loaded)/S:A*8/b+f/1e3;if(w<=p)return;let M=S?S*8:b,k=Number.POSITIVE_INFINITY,P;for(P=t.level-1;P>c;P--){let B=T[P].maxBitrate;if(k=this.getTimeToLoadFrag(f/1e3,M,d*B,!T[P].details),k<p)break}if(k>=w||k>d*10)return;s.nextLoadLevel=s.nextAutoLevel=P,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let N=T[P].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>N&&this.resetEstimator(N),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
1238
+ `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Ql.prototype.processLine=function(i){var e=i.indexOf(":"),t=Fx(i,e),r=t[0],s=t.length===2?jh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case Xr.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case Xr.PART_INF:{Hh(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case Xr.SERVER_CONTROL:{Hh(this.manifest,t),this.setHoldBack();break}case Xr.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case Xr.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case Xr.VERSION:{Hh(this.manifest,t);break}case Xr.SESSION_DATA:{var o=Bx(t[1]),l=fE(o);Object.assign(this.manifest.sessionData,l)}}};Ql.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var Hh=function(i,e){var t=_E(e[0].replace("#EXT-X-","")),r;Ux(e[1])?(r={},r=Object.assign(Nx(e[1]),r)):r=jh(e[1]),i[t]=r},_E=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},jh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},Ox=function(i){var e={},t=i.split("=");if(t.length>1){var r=_E(t[0]);e[r]=jh(t[1])}return e},Nx=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=Ox(s);t=Object.assign(n,t)}return t},Ux=function(i){return i.indexOf("=")>-1},Fx=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},Bx=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},$x=Ql,Hx={safeCall:Dx,safeIncrement:et,getComputedStyle:Mx,secondsToMs:Px,assign:Object.assign,headersStringToObject:qh,cdnHeadersToRequestId:Xl,extractHostnameAndDomain:Sa,extractHostname:ni,manifestParser:$x,generateShortID:cE,generateUUID:Aa,now:tt.now,findMediaElement:ql},Gx=Hx,Kx={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled",HEARTBEAT:"hb",DESTROY:"destroy"},Vx=Kx,Wx="mux-embed",Yx="5.5.0",qx="2.1",Je={},gr=function(i){var e=arguments;typeof i=="string"?gr.hasOwnProperty(i)?Ta.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),gr[i].apply(null,e)},0):Oe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ta.default.setTimeout(function(){i(gr)},0):Oe.warn("`"+i+"` is invalid.")},jx={loaded:tt.now(),NAME:Wx,VERSION:Yx,API_VERSION:qx,PLAYER_TRACKED:!1,monitor:function(i,e){return wx(gr,i,e)},destroyMonitor:function(i){var e=Xi(ql(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Oe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=ri(i);Je[t]?Je[t].addHLSJS(e):Oe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=ri(i);Je[t]?Je[t].addDashJS(e):Oe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=ri(i);Je[e]?Je[e].removeHLSJS():Oe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=ri(i);Je[e]?Je[e].removeDashJS():Oe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Kh()&&e&&e.respectDoNotTrack&&Oe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=ri(i);Je[t]=new Ix(gr,t,e)},emit:function(i,e,t){var r=ri(i);Je[r]?(Je[r].emit(e,t),e==="destroy"&&delete Je[r]):Oe.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(i,e){var t=ri(i);Je[t]?Je[t].emit("hb",e):Oe.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(i,e){var t=ri(i);Je[t]?Je[t].emitTranslator=e:Oe.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(i,e){var t=ri(i);Je[t]?Je[t].stateDataTranslator=e:Oe.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(i,e){var t=ri(i);Je[t]?Je[t].getPlayheadTime=e:Oe.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:Kh,log:Oe,utils:Gx,events:Vx,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(gr,jx);typeof Ta.default!="undefined"&&typeof Ta.default.addEventListener=="function"&&Ta.default.addEventListener("pagehide",function(i){i.persisted||(gr.WINDOW_UNLOADING=!0)},!1);var Zl=gr;function zx(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var pb={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(pb);var Rm=pb.exports;function AE(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function gt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?AE(Object(t),!0).forEach(function(r){Zx(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):AE(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function Xx(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Qx(i){var e=Xx(i,"string");return typeof e=="symbol"?e:String(e)}function Zx(i,e,t){return e=Qx(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function it(){return it=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},it.apply(this,arguments)}var q=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},Jx=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=eR},eR=Number.MAX_SAFE_INTEGER||9007199254740991,v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),re=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),D=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),is=function(){},vf={trace:is,debug:is,log:is,warn:is,info:is,error:is},Ra=vf;function tR(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):is}function iR(i,...e){e.forEach(function(t){Ra[t]=i[t]?i[t].bind(i):tR(t)})}function rR(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){iR(i,"debug","log","info","warn","error");try{Ra.log(`Debug logs enabled for "${e}" in hls.js version 1.5.19`)}catch{Ra=vf}}else Ra=vf}var L=Ra,sR=/^(\d+)x(\d+)$/,SE=/(.+?)=(".*?"|.*?)(?:,|$)/g,je=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),it(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=sR.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(SE.lastIndex=0;(t=SE.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function nR(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function aR(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Ed=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){L.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=it(new je({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);q(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(q(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&q(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},An=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},we={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},bd=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[we.AUDIO]:null,[we.VIDEO]:null,[we.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Rm.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Ia=class extends bd{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new An,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!q(this.programDateTime))return null;let e=q(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[we.AUDIO]=null,e[we.VIDEO]=null,e[we.AUDIOVIDEO]=null}},Ef=class extends bd{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new An,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},oR=10,bf=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?q(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||oR}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Im(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function lR(i){let e=yf(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function dR(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function uR(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Im(a)):t=lR(a)}}return t}function yf(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var Sn=typeof self!="undefined"?self:void 0,Ie={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Nt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function zh(i){switch(i){case Nt.FAIRPLAY:return Ie.FAIRPLAY;case Nt.PLAYREADY:return Ie.PLAYREADY;case Nt.WIDEVINE:return Ie.WIDEVINE;case Nt.CLEARKEY:return Ie.CLEARKEY}}var Jl={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Xh(i){if(i===Jl.WIDEVINE)return Ie.WIDEVINE;if(i===Jl.PLAYREADY)return Ie.PLAYREADY;if(i===Jl.CENC||i===Jl.CLEARKEY)return Ie.CLEARKEY}function Qh(i){switch(i){case Ie.FAIRPLAY:return Nt.FAIRPLAY;case Ie.PLAYREADY:return Nt.PLAYREADY;case Ie.WIDEVINE:return Nt.WIDEVINE;case Ie.CLEARKEY:return Nt.CLEARKEY}}function ed(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Ie.FAIRPLAY,Ie.WIDEVINE,Ie.PLAYREADY,Ie.CLEARKEY].filter(s=>!!e[s]):[];return!r[Ie.WIDEVINE]&&t&&r.push(Ie.WIDEVINE),r}var gb=function(i){return Sn!=null&&(i=Sn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function cR(i,e,t,r){let s;switch(i){case Ie.FAIRPLAY:s=["cenc","sinf"];break;case Ie.WIDEVINE:case Ie.PLAYREADY:s=["cenc"];break;case Ie.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return hR(s,e,t,r)}function hR(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function vb(i){let e=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),r=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let l=Im(o).subarray(0,16);return dR(l),l}}return null}function ns(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Lm=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Eb=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,ka=(i,e)=>{let t=e,r=0;for(;Lm(i,e);){r+=10;let s=Wd(i,e+6);r+=s,Eb(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},Wd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},fR=(i,e)=>Lm(i,e)&&Wd(i,e+6)+10<=i.length-e,km=i=>{let e=yb(i);for(let t=0;t<e.length;t++){let r=e[t];if(bb(r))return bR(r)}},bb=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",mR=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Wd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},yb=i=>{let e=0,t=[];for(;Lm(i,e);){let r=Wd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=mR(i.subarray(e)),a=pR(n);a&&t.push(a),e+=n.size+10}Eb(i,e)&&(e+=10)}return t},pR=i=>i.type==="PRIV"?gR(i):i.type[0]==="W"?ER(i):vR(i),gR=i=>{if(i.size<2)return;let e=wi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},vR=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=wi(i.data.subarray(t),!0);t+=r.length+1;let s=wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=wi(i.data.subarray(1));return{key:i.type,data:e}},ER=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=wi(i.data.subarray(t),!0);t+=r.length+1;let s=wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=wi(i.data);return{key:i.type,data:e}},bR=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},wi=(i,e=!1)=>{let t=yR();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Zh;function yR(){if(!navigator.userAgent.includes("PlayStation 4"))return!Zh&&typeof self.TextDecoder!="undefined"&&(Zh=new self.TextDecoder("utf-8")),Zh}var Li={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},yd=Math.pow(2,32)-1,TR=[].push,Tb={video:1,audio:2,id3:3,text:4};function nt(i){return String.fromCharCode.apply(null,i)}function _b(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function ee(i,e){let t=Ab(i,e);return t<0?4294967296+t:t}function xE(i,e){let t=ee(i,e);return t*=Math.pow(2,32),t+=ee(i,e+4),t}function Ab(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Jh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function _R(i){let e=i.byteLength;for(let t=0;t<e;){let r=ee(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function ae(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=ee(i,s),a=nt(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=ae(i.subarray(s+8,o),e.slice(1));l.length&&TR.apply(t,l)}s=o}return t}function AR(i){let e=[],t=i[0],r=8,s=ee(i,r);r+=4;let n=0,a=0;t===0?(n=ee(i,r),a=ee(i,r+4),r+=8):(n=xE(i,r),a=xE(i,r+8),r+=16),r+=2;let o=i.length+a,l=_b(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=ee(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return L.warn("SIDX has hierarchical references (not supported)"),null;let m=ee(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Sb(i){let e=[],t=ae(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=ae(n,["tkhd"])[0];if(a){let o=a[0],l=ee(a,o===0?12:20),d=ae(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=ee(d,o===0?12:20),c=ae(n,["mdia","hdlr"])[0];if(c){let h=nt(c.subarray(8,12)),f={soun:we.AUDIO,vide:we.VIDEO}[h];if(f){let m=ae(n,["mdia","minf","stbl","stsd"])[0],p=SR(m);e[l]={timescale:u,type:f},e[f]=gt({timescale:u,id:l},p)}}}}}return ae(i,["moov","mvex","trex"]).forEach(s=>{let n=ee(s,4),a=e[n];a&&(a.default={duration:ee(s,12),flags:ee(s,20)})}),e}function SR(i){let e=i.subarray(8),t=e.subarray(86),r=nt(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=ae(e,[r])[0].subarray(r==="enca"?28:78);ae(o,["sinf"]).forEach(d=>{let u=ae(d,["schm"])[0];if(u){let c=nt(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=ae(d,["frma"])[0];h&&(s=nt(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=ae(t,["avcC"])[0];s+="."+td(a[1])+td(a[2])+td(a[3]);break}case"mp4a":{let a=ae(e,[r])[0],o=ae(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=ef(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=ef(o,l);let u=o[l++];if(u===64)s+="."+td(u);else break;if(l+=12,o[l++]!==5)break;l=ef(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=ae(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=ee(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=ae(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Ii(o)+"."+Ii(l);break}case"vp09":{let a=ae(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Ii(o)+"."+Ii(l)+"."+Ii(d);break}case"av01":{let a=ae(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Ii(l)+d+"."+Ii(h)+"."+f+"."+m+p+g+"."+Ii(1)+"."+Ii(1)+"."+Ii(1)+"."+0;break}}return{codec:s,encrypted:n}}function ef(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function td(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Ii(i){return(i<10?"0":"")+i}function xR(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&ae(i,["moov","trak"]).forEach(s=>{let a=ae(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=ae(a,["enca"]),l=o.length>0;l||(o=ae(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);ae(u,["sinf"]).forEach(h=>{let f=xb(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(L.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Li.hexDump(m)} -> ${Li.hexDump(t)}`),f.set(t,8))}})})}),i}function xb(i){let e=ae(i,["schm"])[0];if(e){let t=nt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return ae(i,["schi","tenc"])[0]}return null}function RR(i,e){return ae(e,["moof","traf"]).reduce((t,r)=>{let s=ae(r,["tfdt"])[0],n=s[0],a=ae(r,["tfhd"]).reduce((o,l)=>{let d=ee(l,4),u=i[d];if(u){let c=ee(s,4);if(n===1){if(c===yd)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=yd+1,c+=ee(s,8)}let h=u.timescale||9e4,f=c/h;if(q(f)&&(o===null||f<o))return f}return o},null);return a!==null&&q(a)&&(t===null||a<t)?a:t},null)}function IR(i,e){let t=0,r=0,s=0,n=ae(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=ae(o,["tfhd"])[0],d=ee(l,4),u=e[d];if(!u)continue;let c=u.default,h=ee(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=ee(l,12):f=ee(l,8));let m=u.timescale||9e4,p=ae(o,["trun"]);for(let g=0;g<p.length;g++){if(t=LR(p[g]),!t&&f){let E=ee(p[g],4);t=f*E}u.type===we.VIDEO?r+=t/m:u.type===we.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=ae(i,["sidx"]);for(let u=0;u<d.length;u++){let c=AR(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&q(l))return l}return r||s}function LR(i){let e=ee(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=ee(i,4);for(let n=0;n<s;n++){if(e&256){let a=ee(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function kR(i,e,t){ae(e,["moof","traf"]).forEach(r=>{ae(r,["tfhd"]).forEach(s=>{let n=ee(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;ae(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=ee(l,4);if(d===0)c-=u,c=Math.max(c,0),Jh(l,4,c);else{c*=Math.pow(2,32),c+=ee(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(yd+1)),f=Math.floor(c%(yd+1));Jh(l,4,h),Jh(l,8,f)}}})})})}function CR(i){let e={valid:null,remainder:null},t=ae(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=ns(i,0,r.byteOffset-8),e.remainder=ns(i,r.byteOffset-8),e}function Yt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function RE(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return ae(r,["moof"]).map(l=>{let d=l.byteOffset-8;ae(l,["traf"]).map(c=>{let h=ae(c,["tfdt"]).map(f=>{let m=f[0],p=ee(f,4);return m===1&&(p*=Math.pow(2,32),p+=ee(f,8)),p/s})[0];return h!==void 0&&(i=h),ae(c,["tfhd"]).map(f=>{let m=ee(f,4),p=ee(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,b=(p&8)!==0,T=0,_=(p&16)!==0,A=0,x=(p&32)!==0,S=8;m===n&&(g&&(S+=8),E&&(S+=4),b&&(T=ee(f,S),S+=4),_&&(A=ee(f,S),S+=4),x&&(S+=4),e.type==="video"&&(a=wR(e.codec)),ae(c,["trun"]).map(w=>{let M=w[0],k=ee(w,0)&16777215,P=(k&1)!==0,N=0,B=(k&4)!==0,X=(k&256)!==0,z=0,V=(k&512)!==0,ne=0,le=(k&1024)!==0,W=(k&2048)!==0,G=0,oe=ee(w,4),J=8;P&&(N=ee(w,J),J+=4),B&&(J+=4);let Ee=N+d;for(let Ge=0;Ge<oe;Ge++){if(X?(z=ee(w,J),J+=4):z=T,V?(ne=ee(w,J),J+=4):ne=A,le&&(J+=4),W&&(M===0?G=ee(w,J):G=Ab(w,J),J+=4),e.type===we.VIDEO){let Ye=0;for(;Ye<ne;){let ze=ee(r,Ee);if(Ee+=4,DR(a,r[Ee])){let St=r.subarray(Ee,Ee+ze);Rb(St,a?2:1,i+G/s,t)}Ee+=ze,Ye+=ze+4}}i+=z/s}}))})})}),t}function wR(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function DR(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Rb(i,e,t,r){let s=Ib(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){L.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=_b(s,u);if(u+=2,h===49){let f=ee(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,E=64&p,b=E?2+g*3:0,T=new Uint8Array(b);if(E){T[0]=p;for(let _=1;_<b;_++)T[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:T})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:wi(f),userDataBytes:f})}}}function Ib(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function MR(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;nt(i.subarray(d,d+1))!=="\0";)t+=nt(i.subarray(d,d+1)),d+=1;for(t+=nt(i.subarray(d,d+1)),d+=1;nt(i.subarray(d,d+1))!=="\0";)r+=nt(i.subarray(d,d+1)),d+=1;r+=nt(i.subarray(d,d+1)),d+=1,s=ee(i,12),n=ee(i,16),o=ee(i,20),l=ee(i,24),d=28}else if(e===1){d+=4,s=ee(i,d),d+=4;let c=ee(i,d);d+=4;let h=ee(i,d);for(d+=4,a=2**32*c+h,Jx(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ee(i,d),d+=4,l=ee(i,d),d+=4;nt(i.subarray(d,d+1))!=="\0";)t+=nt(i.subarray(d,d+1)),d+=1;for(t+=nt(i.subarray(d,d+1)),d+=1;nt(i.subarray(d,d+1))!=="\0";)r+=nt(i.subarray(d,d+1)),d+=1;r+=nt(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function PR(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function OR(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),PR([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function NR(i){let e=[];if(i instanceof ArrayBuffer){let t=i.byteLength,r=0;for(;r+32<t;){let s=new DataView(i,r),n=UR(s);e.push(n),r+=n.size}}return e}function UR(i){let e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};let n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};let a=i.buffer,o=Li.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28),d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}var id={},Ca=class i{static clearKeyUriToKeyIdMap(){id={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Nt.FAIRPLAY:case Nt.WIDEVINE:case Nt.PLAYREADY:case Nt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=FR(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=uR(this.uri);if(t)switch(this.keyFormat){case Nt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Nt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=OR(r,null,t),this.keyId=vb(t);break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=id[this.uri];if(!r){let s=Object.keys(id).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),id[this.uri]=r}this.keyId=r}return this}};function FR(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Lb=/\{\$([a-zA-Z0-9-_]+)\}/g;function IE(i){return Lb.test(i)}function Pt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Tf(i,n))}}function Tf(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Lb,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function LE(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function BR(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function as(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function $R(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var Td={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function HR(i,e){let t=Td[e];return!!t&&!!t[i.slice(0,4)]}function tf(i,e,t=!0){return!i.split(",").some(r=>!kb(r,e,t))}function kb(i,e,t=!0){var r;let s=as(t);return(r=s==null?void 0:s.isTypeSupported(wa(i,e)))!=null?r:!1}function wa(i,e){return`${e}/mp4;codecs="${i}"`}function kE(i){if(i){let e=i.substring(0,4);return Td.video[e]}return 2}function _d(i){return i.split(",").reduce((e,t)=>{let r=Td.video[t];return r?(r*2+e)/(e?3:2):(Td.audio[t]+e)/(e?2:1)},0)}var rf={};function GR(i,e=!0){if(rf[i])return rf[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(kb(t[r],"audio",e))return rf[i]=t[r],t[r];return i}var KR=/flac|opus/i;function Ad(i,e=!0){return i.replace(KR,t=>GR(t.toLowerCase(),e))}function CE(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function VR(i){let e=i.split(",");for(let t=0;t<e.length;t++){let r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}var wE=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,DE=/#EXT-X-MEDIA:(.*)/g,WR=/^#EXT(?:INF|-X-TARGETDURATION):/m,ME=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),YR=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),rs=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return Rm.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return WR.test(e)}static parseMasterPlaylist(e,t){let r=IE(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];wE.lastIndex=0;let a;for(;(a=wE.exec(e))!=null;)if(a[1]){var o;let d=new je(a[1]);Pt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Tf(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),qR(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new je(u);Pt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=PE(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new je(u);Pt(s,c,["NAME","VALUE","QUERYPARAM"]),LE(s,c,t)}break}case"CONTENT-STEERING":{let c=new je(u);Pt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=OE(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(DE.lastIndex=0;(s=DE.exec(e))!==null;){let d=new je(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,Pt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],b={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(b.assocLang=m),p&&(b.channels=p),g&&(b.characteristics=g),E&&(b.instreamId=E),c!=null&&c.length){let T=i.findGroup(c,b.groupId)||c[0];NE(b,T,"audioCodec"),NE(b,T,"textCodec")}h.push(b)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new bf(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new Ia(s,t),g,E,b,T=-1,_=!1,A=null;for(ME.lastIndex=0,o.m3u8=e,o.hasVariableRefs=IE(e);(g=ME.exec(e))!==null;){_&&(_=!1,p=new Ia(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,A&&(p.setByteRange(A),A=null)));let M=g[1];if(M){p.duration=parseFloat(M);let k=(" "+g[2]).slice(1);p.title=k||null,p.tagList.push(k?["INF",M,k]:["INF",M])}else if(g[3]){if(q(p.duration)){p.start=h,b&&BE(p,b,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let k=(" "+g[3]).slice(1);p.relurl=Tf(o,k),UE(p,m),m=p,h+=p.duration,u++,c=0,_=!0}}else if(g[4]){let k=(" "+g[4]).slice(1);m?p.setByteRange(k,m):p.setByteRange(k)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),T===-1&&(T=l.length);else{if(g=g[0].match(YR),!g){L.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&typeof g[E]=="undefined";E++);let k=(" "+g[E]).slice(1),P=(" "+g[E+1]).slice(1),N=g[E+2]?(" "+g[E+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(P);break;case"SKIP":{let B=new je(P);Pt(o,B,["RECENTLY-REMOVED-DATERANGES"]);let X=B.decimalInteger("SKIPPED-SEGMENTS");if(q(X)){o.skippedSegments=X;for(let V=X;V--;)l.unshift(null);u+=X}let z=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(o.recentlyRemovedDateranges=z.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(P),1);break;case"VERSION":o.version=parseInt(P);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(P||N)&&p.tagList.push(N?[P,N]:[P]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([k]);break;case"BITRATE":p.tagList.push([k,P]);break;case"DATERANGE":{let B=new je(P);Pt(o,B,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Pt(o,B,B.clientAttrs);let X=new Ed(B,o.dateRanges[B.ID]);X.isValid||o.skippedSegments?o.dateRanges[X.id]=X:L.warn(`Ignoring invalid DATERANGE tag: "${P}"`),p.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":{{let B=new je(P);Pt(o,B,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in B?BR(o,B,a):LE(o,B,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(P);break;case"KEY":{let B=PE(P,t,o);if(B.isSupported()){if(B.method==="NONE"){b=void 0;break}b||(b={}),b[B.keyFormat]&&(b=it({},b)),b[B.keyFormat]=B}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=OE(P);break;case"MAP":{let B=new je(P);if(Pt(o,B,["BYTERANGE","URI"]),p.duration){let X=new Ia(s,t);FE(X,B,r,b),d=X,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let X=p.byteRangeEndOffset;if(X){let z=p.byteRangeStartOffset;A=`${X-z}@${z}`}else A=null;FE(p,B,r,b),d=p,_=!0}break}case"SERVER-CONTROL":{let B=new je(P);o.canBlockReload=B.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=B.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&B.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=B.optionalFloat("PART-HOLD-BACK",0),o.holdBack=B.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let B=new je(P);o.partTarget=B.decimalFloatingPoint("PART-TARGET");break}case"PART":{let B=o.partList;B||(B=o.partList=[]);let X=c>0?B[B.length-1]:void 0,z=c++,V=new je(P);Pt(o,V,["BYTERANGE","URI"]);let ne=new Ef(V,p,t,z,X);B.push(ne),p.duration+=ne.duration;break}case"PRELOAD-HINT":{let B=new je(P);Pt(o,B,["URI"]),o.preloadHint=B;break}case"RENDITION-REPORT":{let B=new je(P);Pt(o,B,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(B);break}default:L.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(UE(p,m),p.cc=f,o.fragmentHint=p,b&&BE(p,b,o));let x=l.length,S=l[0],w=l[x-1];if(h+=o.skippedSegments*o.targetduration,h>0&&x&&w){o.averagetargetduration=h/x;let M=w.sn;o.endSN=M!=="initSegment"?M:0,o.live||(w.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,T>0&&jR(l,T),o}};function PE(i,e,t){var r,s;let n=new je(i);Pt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&L.error(`Invalid IV: ${n.IV}`);let c=o?rs.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Ca(a,c,u,h,l)}function OE(i){let t=new je(i).decimalFloatingPoint("TIME-OFFSET");return q(t)?t:null}function qR(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>HR(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function NE(i,e,t){let r=e[t];r&&(i[t]=r)}function jR(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function UE(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),q(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function FE(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function BE(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},te={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function $E(i){let{type:e}=i;switch(e){case Te.AUDIO_TRACK:return te.AUDIO;case Te.SUBTITLE_TRACK:return te.SUBTITLE;default:return te.MAIN}}function sf(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var _f=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Te.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:Te.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){L.trace("[playlist-loader]: playlist request ongoing");return}L.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Te.MANIFEST?n=r.manifestLoadPolicy.default:n=it({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),q((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Te.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Te.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Te.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=it({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),rs.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=sf(e,r),l=rs.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=rs.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(T=>!T.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(L.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new je({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=sf(e,r),c=0,h=q(l)?l:q(o)?o:0,f=$E(r),m=rs.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===Te.MANIFEST){let p={attrs:new je({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===Te.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Te.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Te.AUDIO_TRACK||e.type===Te.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);L.warn(`[playlist-loader]: ${a}`);let l=D.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case Te.MANIFEST:l=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case Te.LEVEL:l=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case Te.AUDIO_TRACK:l=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Te.SUBTITLE_TRACK:l=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:re.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=gt({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=sf(t,s),m=$E(s),p=typeof s.level=="number"&&m===te.MAIN?d:void 0;if(!e.fragments.length){let E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:re.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Te.MANIFEST:case Te.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Te.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Te.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function Cb(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function wb(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){L.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function bn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Af(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=XR(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function zR(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function XR(i,e,t){let r=[],s=zR(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function cd(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var ui={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},QR=.25;function Sf(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function HE(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?gt({type:s},r):r))}return n}var rd=(()=>{let i=Sf();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function nf(i,e){return i.getTime()/1e3-e}function ZR(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var xf=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(bn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Cb(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Sf();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===ui.emsg&&!r||!s)continue;let d=yb(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>rd&&(c=rd),c-u<=0&&(c=u+QR);for(let f=0;f<d.length;f++){let m=d[f];if(!bb(m)){this.updateId3CueEnds(u,l);let p=HE(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===rd&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===ui.audioId3&&l:s==="video"?d=u=>u.type===ui.emsg&&o:d=u=>u.type===ui.audioId3&&l||u.type===ui.emsg&&o,Af(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!q(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Sf();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=nf(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,E=rd,b=h.endDate;if(b)E=nf(b,l),g=!0;else if(h.endOnNext&&!g){let _=a.reduce((A,x)=>{if(x!==h.id){let S=n[x];if(S.class===h.class&&S.startDate>h.startDate&&(!A||h.startDate<A.startDate))return S}return A},null);_&&(E=nf(_.startDate,l),g=!0)}let T=Object.keys(h.attr);for(let _=0;_<T.length;_++){let A=T[_];if(!nR(A))continue;let x=p[A];if(x)g&&!m.durationKnown&&(x.endTime=E);else if(d){let S=h.attr[A];aR(A)&&(S=ZR(S));let w=HE(d,f,E,{key:A,data:S},ui.dateRange);w&&(w.id=c,this.id3Track.addCue(w),p[A]=w)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},Rf=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&L.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},If=["NONE","TYPE-0","TYPE-1",null];function JR(i){return If.indexOf(i)>-1}var Sd=["SDR","PQ","HLG"];function eI(i){return!!i&&Sd.indexOf(i)>-1}var hd={No:"",Yes:"YES",v2:"v2"};function GE(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?hd.v2:hd.Yes:hd.No}var xd=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},br=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return KE(this._audioGroups,e)}hasSubtitleGroup(e){return KE(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function KE(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function af(i,e){let t=e.startPTS;if(q(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Db(i,e,t,r,s,n){r-t<=0&&(L.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(q(d)){let g=Math.abs(d-t);q(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)af(p[f],p[f-1]);for(f=m;f<p.length-1;f++)af(p[f],p[f+1]);return i.fragmentHint&&af(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function tI(i,e){let t=null,r=i.fragments;for(let o=r.length-1;o>=0;o--){let l=r[o].initSegment;if(l){t=l;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s;sI(i,e,(o,l,d,u)=>{if(e.skippedSegments&&l.cc!==o.cc){let c=o.cc-l.cc;for(let h=d;h<u.length;h++)u[h].cc+=c}q(o.startPTS)&&q(o.endPTS)&&(l.start=l.startPTS=o.startPTS,l.startDTS=o.startDTS,l.maxStartPTS=o.maxStartPTS,l.endPTS=o.endPTS,l.endDTS=o.endDTS,l.minEndPTS=o.minEndPTS,l.duration=o.endPTS-o.startPTS,l.duration&&(s=l),e.PTSKnown=e.alignedSliding=!0),l.elementaryStreams=o.elementaryStreams,l.loader=o.loader,l.stats=o.stats,o.initSegment&&(l.initSegment=o.initSegment,t=o.initSegment)});let n=e.fragments;if(t&&(e.fragmentHint?n.concat(e.fragmentHint):n).forEach(l=>{var d;l&&(!l.initSegment||l.initSegment.relurl===((d=t)==null?void 0:d.relurl))&&(l.initSegment=t)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(o=>!o),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let o=e.skippedSegments;o--;)n.shift();e.startSN=n[0].sn}else e.canSkipDateRanges&&(e.dateRanges=iI(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));e.startCC=e.fragments[0].cc,e.endCC=n[n.length-1].cc}rI(i.partList,e.partList,(o,l)=>{l.elementaryStreams=o.elementaryStreams,l.stats=o.stats}),s?Db(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Mb(i,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let a=e.advancedDateTime;if(e.advanced&&a){let o=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=o),e.driftEndTime=a,e.driftEnd=o}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function iI(i,e,t){let r=it({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Ed(e[s].attr,r[s]);n.isValid?r[s]=n:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function rI(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function sI(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c,d,o)}}function Mb(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Lf(e,r[t].start)}function Lf(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function nI(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments;if(r.length&&t*4>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function aI(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function VE(i,e,t){var r;return i!=null&&i.details?Pb((r=i.details)==null?void 0:r.partList,e,t):null}function Pb(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Ob(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Rd(i){switch(i.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function WE(i,e){let t=Rd(e);return i.default[`${t?"timeout":"error"}Retry`]}function Cm(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function YE(i){return gt(gt({},i),{errorRetry:null,timeoutRetry:null})}function Id(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(oI(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function oI(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Nb={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function lI(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!q(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(uI(e,t,a))return a}return null}function Ld(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;let o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&kf(t,r,n)===0||dI(n,i,Math.min(s,r))))return n;let a=Nb.search(e,kf.bind(null,t,r));return a&&(a!==i||!n)?a:n}function dI(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){let r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function kf(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function uI(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function cI(i,e){return Nb.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var mt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},oi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Cf=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===te.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:mt.DoNothing,flags:oi.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=mt.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===te.MAIN?t.level:n.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Te.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Te.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=mt.SendAlternateToPenaltyBox,t.errorAction.flags=oi.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:mt.SendAlternateToPenaltyBox,flags:oi.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:mt.DoNothing,flags:oi.None};return}t.type===re.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=WE(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Id(s,n,Rd(e),e.response))return{action:mt.RetryRequest,flags:oi.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=WE(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==D.FRAG_GAP&&s.fragmentError++,Id(o,l,Rd(e),e.response)))return{action:mt.RetryRequest,flags:oi.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===D.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,E=(p===te.AUDIO&&d===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:x})=>s.audioCodec!==x),T=e.sourceBufferName==="video"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR)&&c.some(({codecSet:x,audioCodec:S})=>s.codecSet!==x&&s.audioCodec===S),{type:_,groupId:A}=(a=e.context)!=null?a:{};for(let x=c.length;x--;){let S=(x+h)%c.length;if(S!==h&&S>=f&&S<=m&&c[S].loadError===0){var o,l;let w=c[S];if(d===D.FRAG_GAP&&p===te.MAIN&&e.frag){let M=c[S].details;if(M){let k=Ld(e.frag,M.fragments,e.frag.start);if(k!=null&&k.gap)continue}}else{if(_===Te.AUDIO_TRACK&&w.hasAudioGroup(A)||_===Te.SUBTITLE_TRACK&&w.hasSubtitleGroup(A))continue;if(p===te.AUDIO&&(o=s.audioGroups)!=null&&o.some(M=>w.hasAudioGroup(M))||p===te.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(M=>w.hasSubtitleGroup(M))||E&&s.audioCodec===w.audioCodec||!E&&s.audioCodec!==w.audioCodec||T&&s.codecSet===w.codecSet)continue}u=S;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:mt.SendAlternateToPenaltyBox,flags:oi.None,nextAutoLevel:u}}return{action:mt.SendAlternateToPenaltyBox,flags:oi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case mt.DoNothing:break;case mt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case mt.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case oi.None:this.switchLevel(e,a);break;case oi.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=If[If.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},Da=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=L.log.bind(L,`${t}:`),this.warn=L.warn.bind(L,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){L.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&GE(r);return new xd(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&tI(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,E=s.lastPartSn,b=s.endSN,T=s.lastPartIndex,_=T!==-1,A=E===b,x=g?0:T;_?(d=A?b+1:E,u=A?x:T+1):d=b+1;let S=s.age,w=S+s.ageHeader,M=Math.min(w-s.partTarget,s.targetduration*1.5);if(M>0){if(r&&M>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${M} with playlist age: ${s.age}`),M=0;else{let k=Math.floor(M/s.targetduration);if(d+=k,u!==void 0){let P=Math.round(M%s.targetduration/s.partTarget);u+=P}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${S.toFixed(2)}s goal: ${M} skip sn ${k} to part ${u}`)}s.tuneInGoal=M}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!A){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=nI(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=GE(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=hd.No),new xd(r,s,n)}checkRetry(e){let t=e.details,r=Rd(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===mt.RetryRequest||!s.resolved&&n===mt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Cm(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Er=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},wf=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Er(e),this.fast_=new Er(t),this.defaultTTFB_=s,this.ttfb_=new Er(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Er(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Er(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Er(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},Ub={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},qE={};function hI(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&q(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function fI(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(Ub);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:gt(gt({},n),{},{contentType:wa(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);q(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:wa(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=mI(l);return qE[d]||(qE[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function mI(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function pI(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function gI(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||Sd.slice(0),t=e.preferHDR!==void 0?e.preferHDR:pI(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function vI(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:E}=gI(e,s);for(let A=n.length;A--;){let x=i[n[A]];d=x.channels[2]>0,c=Math.min(c,x.minHeight),h=Math.min(h,x.minFramerate),f=Math.min(f,x.minBitrate);let S=E.filter(w=>x.videoRanges[w]>0);S.length>0&&(u=!0,p=S)}c=q(c)?c:0,h=q(h)?h:0;let b=Math.max(1080,c),T=Math.max(30,h);return f=q(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((A,x)=>{let S=i[x];if(x===A)return A;if(S.minBitrate>t)return Zi(x,`min bitrate of ${S.minBitrate} > current estimate of ${t}`),A;if(!S.hasDefaultAudio)return Zi(x,"no renditions with default or auto-select sound found"),A;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Zi(x,`audio codec preference "${o}" not found`),A;if(a&&!l){if(!S.channels[a])return Zi(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(S.channels)})`),A}else if((!o||l)&&d&&S.channels[2]===0)return Zi(x,"no renditions with stereo sound found"),A;return S.minHeight>b?(Zi(x,`min resolution of ${S.minHeight} > maximum of ${b}`),A):S.minFramerate>T?(Zi(x,`min framerate of ${S.minFramerate} > maximum of ${T}`),A):p.some(w=>S.videoRanges[w]>0)?S.maxScore<m?(Zi(x,`max score of ${S.maxScore} < selected max of ${m}`),A):A&&(_d(x)>=_d(A)||S.fragmentError>i[A].fragmentError)?A:(m=S.maxScore,x):(Zi(x,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),A)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Zi(i,e){L.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function EI(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function bI(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function Ci(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(Tn(i,s,t))return r}return-1}function Tn(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||yI(o,e.characteristics))&&(t===void 0||t(i,e))}function yI(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function pn(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function TI(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=jE(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Ci(i,m,s)>-1});return c>-1?c:jE(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Ci(i,m,s)>-1})}function jE(i,e,t){for(let r=e;r>-1;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var Df=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,b=this.getBwEstimate(),T=s.levels,_=T[t.level],A=l.total||Math.max(l.loaded,Math.round(d*_.averageBitrate/8)),x=E?u-g:u;x<1&&E&&(x=Math.min(u,l.loaded*8/b));let S=E?l.loaded*1e3/x:0,w=S?(A-l.loaded)/S:A*8/b+f/1e3;if(w<=p)return;let M=S?S*8:b,k=Number.POSITIVE_INFINITY,P;for(P=t.level-1;P>c;P--){let B=T[P].maxBitrate;if(k=this.getTimeToLoadFrag(f/1e3,M,d*B,!T[P].details),k<p)break}if(k>=w||k>d*10)return;s.nextLoadLevel=s.nextAutoLevel=P,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let N=T[P].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>N&&this.resetEstimator(N),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
1239
1239
  Time to underbuffer: ${p.toFixed(3)} s
1240
1240
  Estimated load time for current fragment: ${w.toFixed(3)} s
1241
1241
  Estimated load time for down switch fragment: ${k.toFixed(3)} s
1242
1242
  TTFB estimate: ${g|0} ms
1243
1243
  Current BW estimate: ${q(b)?b|0:"Unknown"} bps
1244
1244
  New BW estimate: ${this.getBwEstimate()|0} bps
1245
- Switching to level ${P} @ ${N|0} bps`),s.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new Lf(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{let r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){let a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;q(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===te.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==te.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){let g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,L.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}let f=this.findBestLevel(l,a,s,d,h,u,c);if(L.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;let d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:E}=this.hls;if(m.length===1)return 0;let b=m[c],T=!!(b!=null&&(l=b.details)!=null&&l.live),_=g===-1||u===-1,A,x="SDR",S=(b==null?void 0:b.frameRate)||0,{audioPreference:w,videoPreference:M}=E,k=this.audioTracksByGroup||(this.audioTracksByGroup=vI(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=EI(m,k,t,r)),V=gI(z,x,e,w,M),{codecSet:ne,videoRanges:le,minFramerate:W,minBitrate:G,preferHDR:oe}=V;A=ne,x=oe?le[le.length-1]:le[0],S=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(V)}`)}else A=b==null?void 0:b.codecSet,x=b==null?void 0:b.videoRange;let P=f?f.duration:h?h.duration:0,N=this.bwEstimator.getEstimateTTFB()/1e3,B=[];for(let z=r;z>=t;z--){var X;let V=m[z],ne=z>c;if(!V)continue;if(E.useMediaCapabilities&&!V.supportedResult&&!V.supportedPromise){let Ge=navigator.mediaCapabilities;typeof(Ge==null?void 0:Ge.decodingInfo)=="function"&&cI(V,k,x,S,e,w)?(V.supportedPromise=hI(V,k,Ge),V.supportedPromise.then(Ye=>{if(!this.hls)return;V.supportedResult=Ye;let ze=this.hls.levels,St=ze.indexOf(V);Ye.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${Ye.error}" for level ${St} ${JSON.stringify(Ye)}`):Ye.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${St} ${JSON.stringify(Ye)}`),St>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${St}`),this.hls.removeLevel(St)))})):V.supportedResult=Nb}if(A&&V.codecSet!==A||x&&V.videoRange!==x||ne&&S>V.frameRate||!ne&&S>0&&S<V.frameRate||V.supportedResult&&!((X=V.supportedResult.decodingInfoResults)!=null&&X[0].smooth)){B.push(z);continue}let le=V.details,W=(f?le==null?void 0:le.partTarget:le==null?void 0:le.averagetargetduration)||P,G;ne?G=o*e:G=a*e;let oe=P&&s>=P*2&&n===0?m[z].averageBitrate:m[z].maxBitrate,J=this.getTimeToLoadFrag(N,G,oe*W,le===void 0);if(G>=oe&&(z===u||V.loadError===0&&V.fragmentError===0)&&(J<=N||!q(J)||T&&!this.bitrateTestDelay||J<d)){let Ge=this.forcedAutoLevel;return z!==g&&(Ge===-1||Ge!==g)&&(B.length&&L.trace(`[abr] Skipped level(s) ${B.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[B[0]].codecs}" ${m[B[0]].videoRange}; not compatible with "${b.codecs}" ${x}`),L.info(`[abr] switch candidate:${c}->${z} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-oe)} ttfb:${N.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${J.toFixed(1)} firstSelection:${_} codecSet:${A} videoRange:${x} hls.loadLevel:${g}`)),_&&(this.firstSelection=z),z}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},Cf=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},pt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},wf=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=gn(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),rd(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=gn(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&rd(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||rd(t))}getState(e){let t=gn(e),r=this.fragments[t];return r?r.buffered?rd(r)?pt.PARTIAL:pt.OK:pt.APPENDING:pt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=gn(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=gn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=gn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function rd(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function gn(i){return`${i.type}_${i.level}_${i.sn}`}var TI={length:0,start:()=>0,end:()=>0},Ve=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),TI}}},Pa=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=sd(),this.buffering={audio:sd(),video:sd(),audiovideo:sd()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function sd(){return{start:0,executeStart:0,executeEnd:0,end:0}}function hd(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function _I(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function AI(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){L.log("No fragments to align");return}let s=hd(t,r[0].cc);if(!s||s&&!s.startPTS){L.log("No frag in previous level to align on");return}return s}function zE(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Ub(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)zE(t[r],i);e.fragmentHint&&zE(e.fragmentHint,i),e.alignedSliding=!0}function SI(i,e,t){e&&(xI(i,t,e),!t.alignedSliding&&e&&Ld(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Db(e,t))}function xI(i,e,t){if(_I(i,t,e)){let r=AI(t,e);r&&q(r.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Ub(r.start,e))}}function Ld(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=hd(r,a),n=hd(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=hd(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);Ub(d,i)}var XE=Math.pow(2,17),Df=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(ZE(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=QE(e),c=YE(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:XE};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:gt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(ZE(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=QE(e,t),c=YE(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:XE};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:gt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function QE(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(q(s)&&q(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function ZE(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:re.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new di(r)}var di=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Mf=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Pf=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function RI(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ns(i,0,e-t):i}var Of=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;let b=f[m],T=f[b],_=f[T],A=f[E]*257^E*16843008;s[m]=A<<24|A>>>8,n[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,o[m]=A,A=_*16843009^T*65537^b*257^m*16843008,d[E]=A<<24|A>>>8,u[E]=A<<16|A>>>16,c[E]=A<<8|A>>>24,h[E]=A,m?(m=b^f[f[f[_^b]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3],b,T;for(o=0;o<a;o++){if(o<n){b=d[o]=t[o];continue}T=b,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=h[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),d[o]=b=(d[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=d[o]:T=d[o-4],l<4||o<=4?u[l]=T:u[l]=m[c[T>>>24]]^p[c[T>>>16&255]]^g[c[T>>>8&255]]^E[c[T&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],E=new Int32Array(e),b=new Int32Array(E.length),T,_,A,x,S,w,M,k,P,N,B,X,z,V,ne=this.networkToHostOrderSwap;for(;t<E.length;){for(P=ne(E[t]),N=ne(E[t+1]),B=ne(E[t+2]),X=ne(E[t+3]),S=P^n[0],w=X^n[1],M=B^n[2],k=N^n[3],z=4,V=1;V<s;V++)T=l[S>>>24]^d[w>>16&255]^u[M>>8&255]^c[k&255]^n[z],_=l[w>>>24]^d[M>>16&255]^u[k>>8&255]^c[S&255]^n[z+1],A=l[M>>>24]^d[k>>16&255]^u[S>>8&255]^c[w&255]^n[z+2],x=l[k>>>24]^d[S>>16&255]^u[w>>8&255]^c[M&255]^n[z+3],S=T,w=_,M=A,k=x,z=z+4;T=a[S>>>24]<<24^a[w>>16&255]<<16^a[M>>8&255]<<8^a[k&255]^n[z],_=a[w>>>24]<<24^a[M>>16&255]<<16^a[k>>8&255]<<8^a[S&255]^n[z+1],A=a[M>>>24]<<24^a[k>>16&255]<<16^a[S>>8&255]<<8^a[w&255]^n[z+2],x=a[k>>>24]<<24^a[S>>16&255]<<16^a[w>>8&255]<<8^a[M&255]^n[z+3],b[t]=ne(T^f),b[t+1]=ne(x^m),b[t+2]=ne(A^p),b[t+3]=ne(_^g),f=P,m=N,p=B,g=X,t=t+4}return b.buffer}},II=16,Oa=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?RI(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Yt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Of),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=ns(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Pf(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Mf(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%II;return r!==e.length&&(t=ns(e,0,r),this.remainderData=ns(e,r)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},LI={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},O={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},Na=class extends Cf{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=O.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=L.log.bind(L,`${s}:`),this.warn=L.warn.bind(L,`${s}:`),this.hls=e,this.fragmentLoader=new Df(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Oa(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=O.STOPPED}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ve.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===O.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ve.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${q(a)?a.toFixed(3):a}, state: ${n}`),this.state===O.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=O.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===O.FRAG_LOADING||!this.fragCurrent&&a===O.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=O.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===O.STOPPED||this.state===O.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===pt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===pt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===O.STOPPED||this.state===O.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=O.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===te.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?LI.toString(Ve.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==te.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=O.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=O.IDLE,o&&(!this.loadedmetadata&&e.type==te.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Pa(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=O.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===O.KEY_LOADING&&(this.state=O.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=O.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),q(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=O.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(v.FRAG_LOADED,h);let m=VE(r,e.sn,c.index+1)||Mb(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==O.PARSING){!this.fragCurrent&&this.state!==O.STOPPED&&this.state!==O.ERROR&&(this.state=O.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?VE(o,n,a):null,d=l?l.fragment:nI(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==O.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Yt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ve.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ve.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return q(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ve.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ve.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=te.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,te.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===pt.OK||r===pt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=oI(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=uI(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Id(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===pt.OK||m===pt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==pt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&q(n);if(a||!o&&!n){let{fragPrevious:l}=this;SI(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&q(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==O.FRAG_LOADING_WAITING_RETRY)&&(this.state=O.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===D.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===mt.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=Im(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=O.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==mt.RemoveAlternatePermanently&&(a.resolved=!0);else{L.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===mt.SendAlternateToPenaltyBox?this.state=O.WAITING_LEVEL:this.state=O.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===O.PARSING||this.state===O.PARSED){let t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===te.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==O.STOPPED&&(this.state=O.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ve.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===O.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=O.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:wb(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=O.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},kd=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=kI(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function kI(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function CI(){return typeof __HLS_WORKER_BUNDLE__=="function"}function wI(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function DI(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ki(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Ua=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Yt(this.cachedData,e),this.cachedData=null);let r=Ca(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Rm(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&q(l))&&(this.basePTS=MI(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ui.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else hR(e,s)?(r=Ca(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ui.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=ns(e,n);this.cachedData?this.cachedData=Yt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:ki(),id3Track:o,textTrack:ki()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ki(),id3Track:this._id3Track,textTrack:ki()}}destroy(){}},MI=(i,e,t)=>{if(q(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function PI(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,L.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Fb(i,e){return i[e]===255&&(i[e+1]&246)===240}function Bb(i,e){return i[e+1]&1?7:9}function Lm(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function OI(i,e){return e+5<i.length}function Cd(i,e){return e+1<i.length&&Fb(i,e)}function NI(i,e){return OI(i,e)&&Fb(i,e)&&Lm(i,e)<=i.length-e}function UI(i,e){if(Cd(i,e)){let t=Bb(i,e);if(e+t>=i.length)return!1;let r=Lm(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||Cd(i,s)}return!1}function $b(i,e,t,r,s){if(!i.samplerate){let n=PI(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,L.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Hb(i){return 1024*9e4/i}function FI(i,e){let t=Bb(i,e);if(e+t<=i.length){let r=Lm(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Gb(i,e,t,r,s){let n=Hb(i.samplerate),a=r+s*n,o=FI(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var nd=null,BI=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],$I=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],HI=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],GI=[0,1,1,4];function Kb(i,e,t,r,s){if(t+24>e.length)return;let n=Vb(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Vb(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=BI[l*14+s-1]*1e3,c=$I[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=HI[t][r],m=GI[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(nd===null){let T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);nd=T?parseInt(T[1]):0}return!!nd&&nd<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function km(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Wb(i,e){return e+1<i.length&&km(i,e)}function KI(i,e){return km(i,e)&&4<=i.length-e}function Yb(i,e){if(e+1<i.length&&km(i,e)){let r=Vb(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||Wb(i,n)}return!1}var Nf=class extends Ua{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Ca(e,0),r=(t==null?void 0:t.length)||0;if(Yb(e,r))return!1;for(let s=e.length;r<s;r++)if(UI(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return NI(e,t)}appendFrame(e,t,r){$b(e,this.observer,t,r,e.manifestCodec);let s=Gb(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},VI=/\/emsg[-/]ID3/i,Uf=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=ki("video",1),a=this.audioTrack=ki("audio",1),o=this.txtTrack=ki("text",1);if(this.id3Track=ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Ab(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=yb.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return TR(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Yt(this.remainderData,e));let o=kR(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=RE(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=RE(e,t),{videoTrack:t,audioTrack:ki(),id3Track:s,textTrack:ki()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=ae(e.samples,["emsg"]);s&&s.forEach(n=>{let a=DR(n);if(VI.test(a.schemeIdUri)){let o=q(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:ui.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},qb=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},Ff=class extends Ua{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=jb(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=Ca(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&Rm(t)!==void 0&&qb(e,r)<16}};function jb(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,b=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),T=1536/o*9e4,_=r+s*T,A=e.subarray(t,t+u);return i.config=b,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:_}),u}var Bf=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&L.log(e.pts+"/"+e.dts+":"+e.debug)}},wd=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let x=u();if(x===3&&h(1),m(),m(),h(1),c())for(a=x!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let b=u(),T=u(),_=d(1);_===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let A=[1,1];if(c()&&c())switch(l()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((b+1)*16-e*2-t*2),height:(2-_)*(T+1)*16-(_?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},$f=class extends Bf{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let E=new wd(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,xb(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,E=new wd(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;let b=p.subarray(1,4),T="avc1.";for(let _=0;_<3;_++){let A=b[_].toString(16);A.length<2&&(A="0"+A),T+=A}e.codec=T}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Yt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=Yt(f.data,t))}return e.naluState=s,a}},Hf=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Oa(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Rb(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ft=188,Gf=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new $f}static probe(e){let t=i.syncOffset(e);return t>0&&L.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ft*5,t-ft)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ft)if(e[l]===71&&(t-l===ft||e[l+ft]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ft*99,e.length-ft)+1)),n||(n=Kf(e,l)===0),n&&o>1&&(a===0&&o>2||l+ft>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:yb[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,b=this._pmtId,T=e.length;if(this.remainderData&&(e=Yt(this.remainderData,e),T=e.length,this.remainderData=null),T<ft&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));T-=(T-_)%ft,T<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let A=0;for(let S=_;S<T;S+=ft)if(e[S]===71){let w=!!(e[S+1]&64),M=Kf(e,S),k=(e[S+3]&48)>>4,P;if(k>1){if(P=S+5+e[S+4],P===S+ft)continue}else P=S+4;switch(M){case u:w&&(c&&(n=vn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(P,S+ft)),c.size+=S+ft-P);break;case h:if(w){if(m&&(n=vn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(P,S+ft)),m.size+=S+ft-P);break;case f:w&&(p&&(n=vn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(P,S+ft)),p.size+=S+ft-P);break;case 0:w&&(P+=e[P]+1),b=this._pmtId=WI(e,P);break;case b:{w&&(P+=e[P]+1);let N=YI(e,P,this.typeSupported,r,this.observer);u=N.videoPid,u>0&&(a.pid=u,a.segmentCodec=N.segmentVideoCodec),h=N.audioPid,h>0&&(o.pid=h,o.segmentCodec=N.segmentAudioCodec),f=N.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(L.warn(`MPEG-TS PMT found at ${S} after unknown PID '${g}'. Backtracking to sync byte @${_} to parse all TS packets.`),g=null,S=_-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=M;break}}else A++;A>0&&Dd(this.observer,new Error(`Found ${A} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;let x={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(x),x}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=vn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=vn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=vn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Hf(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Yt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!Cd(n,a);a++);if(a!==r){let c,h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",Dd(this.observer,new Error(c),h),!h)return}$b(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Hb(e.samplerate);l=s.sample.pts+c}else{L.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Gb(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!Cd(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){L.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Wb(r,a)){let l=Kb(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){L.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=jb(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){L.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=it({},t,{type:this._videoTrack?ui.emsg:ui.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Kf(i,e){return((i[e+1]&31)<<8)+i[e+2]}function WI(i,e){return(i[e+10]&31)<<8|i[e+11]}function YI(i,e,t,r,s){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){let d=Kf(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){sf("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){sf("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?L.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){sf("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?L.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return Dd(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return Dd(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function Dd(i,e,t){L.warn(`parsing error: ${e.message}`),i.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function sf(i){L.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function vn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Yt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(L.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var Vf=class extends Ua{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Ca(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Rm(t)!==void 0&&qb(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(Yb(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return KI(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Kb(e,t,r,this.basePTS,this.frameIndex)}},Md=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},vr=Math.pow(2,32)-1,at=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(vr+1)),o=Math.floor(r%(vr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(vr+1)),a=Math.floor(t%(vr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e);return Yt(i.FTYP,t)}};at.types=void 0;at.HDLR_TYPES=void 0;at.STTS=void 0;at.STSC=void 0;at.STCO=void 0;at.STSZ=void 0;at.VMHD=void 0;at.SMHD=void 0;at.STSD=void 0;at.FTYP=void 0;at.DINF=void 0;var zb=9e4;function Cm(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function qI(i,e,t=1,r=!1){return Cm(i,e,1/t,r)}function xa(i,e=!1){return Cm(i,1e3,1/zb,e)}function jI(i,e=1){return Cm(i,zb,1/e)}var zI=10*1e3,JE=1024,XI=1152,QI=1536,En=null,nf=null,_n=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,En===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);En=a?parseInt(a[1]):0}if(nf===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);nf=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e[0].pts,s=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Wt(o,r),l=o-n),l>0?n:o},r);return t&&L.debug("PTS rollover detected"),s}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n,E=e.pid>-1,b=t.pid>-1,T=t.samples.length,_=e.samples.length>0,A=o&&T>0||T>1;if((!E||_)&&(!b||A)||this.ISGenerated||o){if(this.ISGenerated){var S,w,M,k;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((S=t.pixelRatio)==null?void 0:S[0])!==((w=X.pixelRatio)==null?void 0:w[0])||((M=t.pixelRatio)==null?void 0:M[1])!==((k=X.pixelRatio)==null?void 0:k[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let P=this.isVideoContiguous,N=-1,B;if(A&&(N=ZI(t.samples),!P&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,N>0){L.warn(`[mp4-remuxer]: Dropped ${N} out of ${T} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(N),t.dropped+=N,g+=(t.samples[0].pts-X)/t.inputTimeScale,B=g}else N===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),m=!1);if(this.ISGenerated){if(_&&A){let X=this.getVideoStartPts(t.samples),V=(Wt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,V),g+=Math.max(0,-V)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,b||A||l===te.AUDIO?g:void 0),A){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,P,X)}}else A&&(d=this.remuxVideo(t,g,P,0));d&&(d.firstKeyFrame=N,d.independent=N!==-1,d.firstKeyFramePTS=B)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Xb(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Qb(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):at.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:at.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){let p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Wt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,E=!1;if(!r||u===null){let W=t*n,G=a[0].pts-Wt(a[0].dts,a[0].pts);En&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let b=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Wt(G.pts-b,u),G.dts=Wt(G.dts-b,u),G.dts<a[W>0?W-1:W].dts&&(E=!0)}E&&a.sort(function(W,G){let oe=W.dts-G.dts,J=W.pts-G.pts;return oe||J}),f=a[0].dts,m=a[a.length-1].dts;let T=m-f,_=T?Math.round(T/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>_,oe=W<-1;if((G||oe)&&(G?L.warn(`AVC: ${xa(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${xa(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!oe||u>=a[0].pts||En)){f=u;let J=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=J;else for(let Ee=0;Ee<a.length&&!(a[Ee].dts>J);Ee++)a[Ee].dts-=W,a[Ee].pts-=W;L.log(`Video: Initial PTS/DTS adjusted: ${xa(J,!0)}/${xa(f,!0)}, delta: ${xa(W,!0)} ms`)}}f=Math.max(0,f);let A=0,x=0,S=f;for(let W=0;W<l;W++){let G=a[W],oe=G.units,J=oe.length,Ee=0;for(let Ge=0;Ge<J;Ge++)Ee+=oe[Ge].data.length;x+=Ee,A+=J,G.length=Ee,G.dts<S?(G.dts=S,S+=_/4|0||1):S=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let w=x+4*A+8,M;try{M=new Uint8Array(w)}catch(W){this.observer.emit(v.ERROR,v.ERROR,{type:re.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:w,reason:`fail allocating video mdat ${w}`});return}let k=new DataView(M.buffer);k.setUint32(0,w),M.set(at.types.mdat,4);let P=!1,N=Number.POSITIVE_INFINITY,B=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],oe=G.units,J=0;for(let Ye=0,ze=oe.length;Ye<ze;Ye++){let St=oe[Ye],ar=St.data,Fs=St.data.byteLength;k.setUint32(c,Fs),c+=4,M.set(ar,c),c+=Fs,J+=4+Fs}let Ee;if(W<l-1)h=a[W+1].dts-G.dts,Ee=a[W+1].pts-G.pts;else{let Ye=this.config,ze=W>0?G.dts-a[W-1].dts:_;if(Ee=W>0?G.pts-a[W-1].pts:_,Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){let St=Math.floor(Ye.maxBufferHole*n),ar=(s?p+s*n:this.nextAudioPts)-G.pts;ar>St?(h=ar-ze,h<0?h=ze:P=!0,L.log(`[mp4-remuxer]: It is approximately ${ar/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=ze}else h=ze}let Ge=Math.round(G.pts-G.dts);N=Math.min(N,h),X=Math.max(X,h),B=Math.min(B,Ee),z=Math.max(z,Ee),o.push(new Pd(G.key,h,J,Ge))}if(o.length){if(En){if(En<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(nf&&z-B<X-N&&_/X<.025&&o[0].cts===0){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,oe=o.length;G<oe;G++){let J=W+o[G].duration,Ee=W+o[G].cts;if(G<oe-1){let Ge=J+o[G+1].cts;o[G].duration=Ge-Ee}else o[G].duration=G?o[G-1].duration:_;o[G].cts=0,W=J}}}h=P||!h?_:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let le={data1:at.moof(e.sequenceNumber++,f,it({},e,{samples:o})),data2:M,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,le}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return XI;case"ac3":return QI;default:return JE}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,E=this.nextAudioPts||-1,b=t*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(b-E)<9e3||Math.abs(Wt(p[0].pts-T,b)-E)<20*u),p.forEach(function(V){V.pts=Wt(V.pts-T,b)}),!r||E<0){if(p=p.filter(V=>V.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,b):E=p[0].pts}if(e.segmentCodec==="aac"){let V=this.config.maxAudioFramesDrift;for(let ne=0,le=E;ne<p.length;ne++){let W=p[ne],G=W.pts,oe=G-le,J=Math.abs(1e3*oe/a);if(oe<=-V*u&&m)ne===0&&(L.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*oe/a)} ms.`),this.nextAudioPts=E=le=G);else if(oe>=V*u&&J<zI&&m){let Ee=Math.round(oe/u);le=G-Ee*u,le<0&&(Ee--,le+=u),ne===0&&(this.nextAudioPts=E=le),L.warn(`[mp4-remuxer]: Injecting ${Ee} audio frame @ ${(le/a).toFixed(3)}s due to ${Math.round(1e3*oe/a)} ms gap.`);for(let Ge=0;Ge<Ee;Ge++){let Ye=Math.max(le,0),ze=Md.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ze||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ze=W.unit.subarray()),p.splice(ne,0,{unit:ze,pts:Ye}),le+=u,ne++}}W.pts=le,le+=u}}let _=null,A=null,x,S=0,w=p.length;for(;w--;)S+=p[w].unit.byteLength;for(let V=0,ne=p.length;V<ne;V++){let le=p[V],W=le.unit,G=le.pts;if(A!==null){let J=f[V-1];J.duration=Math.round((G-A)/l)}else if(r&&e.segmentCodec==="aac"&&(G=E),_=G,S>0){S+=g;try{x=new Uint8Array(S)}catch(J){this.observer.emit(v.ERROR,v.ERROR,{type:re.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:S,reason:`fail allocating audio mdat ${S}`});return}h||(new DataView(x.buffer).setUint32(0,S),x.set(at.types.mdat,4))}else return;x.set(W,g);let oe=W.byteLength;g+=oe,f.push(new Pd(!0,d,oe,0)),A=G}let M=f.length;if(!M)return;let k=f[f.length-1];this.nextAudioPts=E=A+l*k.duration;let P=h?new Uint8Array(0):at.moof(e.sequenceNumber++,_/l,it({},e,{samples:f}));e.samples=[];let N=_/a,B=E/a,z={data1:P,data2:x,startPTS:N,endPTS:B,startDTS:N,endDTS:B,type:"audio",hasAudio:!0,hasVideo:!1,nb:M};return this.isAudioContiguous=!0,z}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*JE,m=Math.ceil((h-c)/f),p=Md.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!p){L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let E=0;E<m;E++){let b=c+E*f;g.push({unit:p,pts:b,dts:b})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Wt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function ZI(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Xb(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Wt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Wt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function Qb(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Wt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var Pd=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},Wf=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(SR(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Ab(e);s.audio&&(t=eb(s.audio,Ce.AUDIO)),s.video&&(r=eb(s.video,Ce.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};q(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=RR(h,m),g=xR(m,h),E=g===null?n:g;(JI(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&L.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let b=e?E-d.baseTime/d.timescale:u,T=b+p;LR(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=T:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let _=!!m.audio,A=!!m.video,x="";_&&(x+="audio"),A&&(x+="video");let S={data1:h,startPTS:b,startDTS:b,endPTS:T,endDTS:T,type:x,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=S.type==="audio"?S:void 0,c.video=S.type!=="audio"?S:void 0,c.initSegment=f,c.id3=Xb(r,n,d,d),s.samples.length&&(c.text=Qb(s,n,d)),c}};function JI(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function eb(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===Ce.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return _d(t,!1);let r="mp4a.40.5";return L.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return L.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var er;try{er=self.performance.now.bind(self.performance)}catch{L.debug("Unable to use Performance API on this environment"),er=Sn==null?void 0:Sn.Date.now}var fd=[{demux:Uf,remux:Wf},{demux:Gf,remux:_n},{demux:Nf,remux:_n},{demux:Vf,remux:_n}];fd.splice(2,0,{demux:Ff,remux:_n});var Od=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=er();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:b,initSegmentData:T}=l,_=eL(a,t);if(_&&_.method==="AES-128"){let w=this.getDecrypter();if(w.isSync()){let M=w.softwareDecrypt(a,_.key.buffer,_.iv.buffer);if(r.part>-1&&(M=w.flush()),!M)return n.executeEnd=er(),af(r);a=new Uint8Array(M)}else return this.decryptionPromise=w.webCryptoDecrypt(a,_.key.buffer,_.iv.buffer).then(M=>{let k=this.push(M,null,r);return this.decryptionPromise=null,k}),this.decryptionPromise}let A=this.needsProbing(u,c);if(A){let w=this.configureTransmuxer(a);if(w)return L.warn(`[transmuxer] ${w.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),n.executeEnd=er(),af(r)}(u||c||m||A)&&this.resetInitSegment(T,p,g,b,t),(u||m||A)&&this.resetInitialTimestamp(E),d||this.resetContiguity();let x=this.transmux(a,_,f,h,r),S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=er(),x}flush(e){let t=e.transmuxing;t.executeStart=er();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=er(),[af(e)];let u=l.flush(o);return md(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=er()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=fd.length;h<f;h++){var o;if((o=fd[h].demux)!=null&&o.probe(e)){a=fd[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Oa(this.config)),e}};function eL(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var af=i=>({remuxResult:{},chunkMeta:i});function md(i){return"then"in i&&i.then instanceof Function}var Yf=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},qf=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},Zb={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,b,T;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(T=1,b=new Array(E-1);T<E;T++)b[T-1]=arguments[T];g.fn.apply(g.context,b)}else{var _=g.length,A;for(T=0;T<_;T++)switch(g[T].once&&this.removeListener(d,g[T].fn,void 0,!0),E){case 1:g[T].fn.call(g[T].context);break;case 2:g[T].fn.call(g[T].context,u);break;case 3:g[T].fn.call(g[T].context,u,c);break;case 4:g[T].fn.call(g[T].context,u,c,h);break;default:if(!b)for(A=1,b=new Array(E-1);A<E;A++)b[A-1]=arguments[A];g[T].fn.apply(g[T].context,b)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Zb);var tL=Zb.exports,wm=jx(tL),Nd=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===v.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new wm,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);let o=as(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||CI())){try{n.workerPath?(L.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=DI(n.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=wI()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new Od(this.observer,l,n,"",t)}return}this.transmuxer=new Od(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),b=!(g&&d.level===g.level),T=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=T===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),x=!b&&(T===1||T===0&&(_===1||A&&_<=0)),S=self.performance.now();(b||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=S),a&&(_||!x)&&(a.stats.parsing.start=S);let w=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),M=new qf(E,x,l,b,m,w);if(!x||E||w){L.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1245
+ Switching to level ${P} @ ${N|0} bps`),s.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new wf(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{let r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){let a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;q(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===te.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==te.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){let g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,L.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}let f=this.findBestLevel(l,a,s,d,h,u,c);if(L.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;let d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:E}=this.hls;if(m.length===1)return 0;let b=m[c],T=!!(b!=null&&(l=b.details)!=null&&l.live),_=g===-1||u===-1,A,x="SDR",S=(b==null?void 0:b.frameRate)||0,{audioPreference:w,videoPreference:M}=E,k=this.audioTracksByGroup||(this.audioTracksByGroup=EI(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=bI(m,k,t,r)),V=vI(z,x,e,w,M),{codecSet:ne,videoRanges:le,minFramerate:W,minBitrate:G,preferHDR:oe}=V;A=ne,x=oe?le[le.length-1]:le[0],S=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(V)}`)}else A=b==null?void 0:b.codecSet,x=b==null?void 0:b.videoRange;let P=f?f.duration:h?h.duration:0,N=this.bwEstimator.getEstimateTTFB()/1e3,B=[];for(let z=r;z>=t;z--){var X;let V=m[z],ne=z>c;if(!V)continue;if(E.useMediaCapabilities&&!V.supportedResult&&!V.supportedPromise){let Ge=navigator.mediaCapabilities;typeof(Ge==null?void 0:Ge.decodingInfo)=="function"&&hI(V,k,x,S,e,w)?(V.supportedPromise=fI(V,k,Ge),V.supportedPromise.then(Ye=>{if(!this.hls)return;V.supportedResult=Ye;let ze=this.hls.levels,St=ze.indexOf(V);Ye.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${Ye.error}" for level ${St} ${JSON.stringify(Ye)}`):Ye.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${St} ${JSON.stringify(Ye)}`),St>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${St}`),this.hls.removeLevel(St)))})):V.supportedResult=Ub}if(A&&V.codecSet!==A||x&&V.videoRange!==x||ne&&S>V.frameRate||!ne&&S>0&&S<V.frameRate||V.supportedResult&&!((X=V.supportedResult.decodingInfoResults)!=null&&X[0].smooth)){B.push(z);continue}let le=V.details,W=(f?le==null?void 0:le.partTarget:le==null?void 0:le.averagetargetduration)||P,G;ne?G=o*e:G=a*e;let oe=P&&s>=P*2&&n===0?m[z].averageBitrate:m[z].maxBitrate,J=this.getTimeToLoadFrag(N,G,oe*W,le===void 0);if(G>=oe&&(z===u||V.loadError===0&&V.fragmentError===0)&&(J<=N||!q(J)||T&&!this.bitrateTestDelay||J<d)){let Ge=this.forcedAutoLevel;return z!==g&&(Ge===-1||Ge!==g)&&(B.length&&L.trace(`[abr] Skipped level(s) ${B.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[B[0]].codecs}" ${m[B[0]].videoRange}; not compatible with "${b.codecs}" ${x}`),L.info(`[abr] switch candidate:${c}->${z} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-oe)} ttfb:${N.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${J.toFixed(1)} firstSelection:${_} codecSet:${A} videoRange:${x} hls.loadLevel:${g}`)),_&&(this.firstSelection=z),z}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},Mf=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},pt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Pf=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=gn(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),sd(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=gn(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&sd(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||sd(t))}getState(e){let t=gn(e),r=this.fragments[t];return r?r.buffered?sd(r)?pt.PARTIAL:pt.OK:pt.APPENDING:pt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=gn(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=gn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=gn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function sd(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function gn(i){return`${i.type}_${i.level}_${i.sn}`}var _I={length:0,start:()=>0,end:()=>0},Ve=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),_I}}},Ma=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=nd(),this.buffering={audio:nd(),video:nd(),audiovideo:nd()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function nd(){return{start:0,executeStart:0,executeEnd:0,end:0}}function fd(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function AI(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function SI(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){L.log("No fragments to align");return}let s=fd(t,r[0].cc);if(!s||s&&!s.startPTS){L.log("No frag in previous level to align on");return}return s}function zE(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Fb(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)zE(t[r],i);e.fragmentHint&&zE(e.fragmentHint,i),e.alignedSliding=!0}function xI(i,e,t){e&&(RI(i,t,e),!t.alignedSliding&&e&&kd(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Mb(e,t))}function RI(i,e,t){if(AI(i,t,e)){let r=SI(t,e);r&&q(r.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Fb(r.start,e))}}function kd(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=fd(r,a),n=fd(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=fd(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);Fb(d,i)}var XE=Math.pow(2,17),Of=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(ZE(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=QE(e),c=YE(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:XE};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:gt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(ZE(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=QE(e,t),c=YE(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:XE};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:gt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new di({type:re.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function QE(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(q(s)&&q(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function ZE(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:re.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new di(r)}var di=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Nf=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Uf=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function II(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ns(i,0,e-t):i}var Ff=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;let b=f[m],T=f[b],_=f[T],A=f[E]*257^E*16843008;s[m]=A<<24|A>>>8,n[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,o[m]=A,A=_*16843009^T*65537^b*257^m*16843008,d[E]=A<<24|A>>>8,u[E]=A<<16|A>>>16,c[E]=A<<8|A>>>24,h[E]=A,m?(m=b^f[f[f[_^b]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3],b,T;for(o=0;o<a;o++){if(o<n){b=d[o]=t[o];continue}T=b,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=h[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),d[o]=b=(d[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=d[o]:T=d[o-4],l<4||o<=4?u[l]=T:u[l]=m[c[T>>>24]]^p[c[T>>>16&255]]^g[c[T>>>8&255]]^E[c[T&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],E=new Int32Array(e),b=new Int32Array(E.length),T,_,A,x,S,w,M,k,P,N,B,X,z,V,ne=this.networkToHostOrderSwap;for(;t<E.length;){for(P=ne(E[t]),N=ne(E[t+1]),B=ne(E[t+2]),X=ne(E[t+3]),S=P^n[0],w=X^n[1],M=B^n[2],k=N^n[3],z=4,V=1;V<s;V++)T=l[S>>>24]^d[w>>16&255]^u[M>>8&255]^c[k&255]^n[z],_=l[w>>>24]^d[M>>16&255]^u[k>>8&255]^c[S&255]^n[z+1],A=l[M>>>24]^d[k>>16&255]^u[S>>8&255]^c[w&255]^n[z+2],x=l[k>>>24]^d[S>>16&255]^u[w>>8&255]^c[M&255]^n[z+3],S=T,w=_,M=A,k=x,z=z+4;T=a[S>>>24]<<24^a[w>>16&255]<<16^a[M>>8&255]<<8^a[k&255]^n[z],_=a[w>>>24]<<24^a[M>>16&255]<<16^a[k>>8&255]<<8^a[S&255]^n[z+1],A=a[M>>>24]<<24^a[k>>16&255]<<16^a[S>>8&255]<<8^a[w&255]^n[z+2],x=a[k>>>24]<<24^a[S>>16&255]<<16^a[w>>8&255]<<8^a[M&255]^n[z+3],b[t]=ne(T^f),b[t+1]=ne(x^m),b[t+2]=ne(A^p),b[t+3]=ne(_^g),f=P,m=N,p=B,g=X,t=t+4}return b.buffer}},LI=16,Pa=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?II(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Yt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Ff),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=ns(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Uf(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Nf(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%LI;return r!==e.length&&(t=ns(e,0,r),this.remainderData=ns(e,r)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},kI={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},O={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},Oa=class extends Mf{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=O.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=L.log.bind(L,`${s}:`),this.warn=L.warn.bind(L,`${s}:`),this.hls=e,this.fragmentLoader=new Of(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Pa(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=O.STOPPED}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ve.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===O.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ve.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${q(a)?a.toFixed(3):a}, state: ${n}`),this.state===O.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=O.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===O.FRAG_LOADING||!this.fragCurrent&&a===O.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=O.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===O.STOPPED||this.state===O.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===pt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===pt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===O.STOPPED||this.state===O.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=O.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===te.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?kI.toString(Ve.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==te.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=O.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=O.IDLE,o&&(!this.loadedmetadata&&e.type==te.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Ma(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=O.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===O.KEY_LOADING&&(this.state=O.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=O.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),q(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=O.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(v.FRAG_LOADED,h);let m=VE(r,e.sn,c.index+1)||Pb(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==O.PARSING){!this.fragCurrent&&this.state!==O.STOPPED&&this.state!==O.ERROR&&(this.state=O.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?VE(o,n,a):null,d=l?l.fragment:aI(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==O.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Yt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ve.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ve.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return q(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ve.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ve.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=te.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,te.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===pt.OK||r===pt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=lI(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=cI(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Ld(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===pt.OK||m===pt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==pt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&q(n);if(a||!o&&!n){let{fragPrevious:l}=this;xI(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&q(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==O.FRAG_LOADING_WAITING_RETRY)&&(this.state=O.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===D.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===mt.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=Cm(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=O.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==mt.RemoveAlternatePermanently&&(a.resolved=!0);else{L.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===mt.SendAlternateToPenaltyBox?this.state=O.WAITING_LEVEL:this.state=O.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===O.PARSING||this.state===O.PARSED){let t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===te.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==O.STOPPED&&(this.state=O.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ve.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===O.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=O.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:Db(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=O.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},Cd=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=CI(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function CI(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function wI(){return typeof __HLS_WORKER_BUNDLE__=="function"}function DI(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function MI(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ki(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Na=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Yt(this.cachedData,e),this.cachedData=null);let r=ka(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?km(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&q(l))&&(this.basePTS=PI(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ui.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else fR(e,s)?(r=ka(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ui.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=ns(e,n);this.cachedData?this.cachedData=Yt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:ki(),id3Track:o,textTrack:ki()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ki(),id3Track:this._id3Track,textTrack:ki()}}destroy(){}},PI=(i,e,t)=>{if(q(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function OI(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,L.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Bb(i,e){return i[e]===255&&(i[e+1]&246)===240}function $b(i,e){return i[e+1]&1?7:9}function wm(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function NI(i,e){return e+5<i.length}function wd(i,e){return e+1<i.length&&Bb(i,e)}function UI(i,e){return NI(i,e)&&Bb(i,e)&&wm(i,e)<=i.length-e}function FI(i,e){if(wd(i,e)){let t=$b(i,e);if(e+t>=i.length)return!1;let r=wm(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||wd(i,s)}return!1}function Hb(i,e,t,r,s){if(!i.samplerate){let n=OI(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,L.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Gb(i){return 1024*9e4/i}function BI(i,e){let t=$b(i,e);if(e+t<=i.length){let r=wm(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Kb(i,e,t,r,s){let n=Gb(i.samplerate),a=r+s*n,o=BI(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var ad=null,$I=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],HI=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],GI=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],KI=[0,1,1,4];function Vb(i,e,t,r,s){if(t+24>e.length)return;let n=Wb(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Wb(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=$I[l*14+s-1]*1e3,c=HI[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=GI[t][r],m=KI[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(ad===null){let T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ad=T?parseInt(T[1]):0}return!!ad&&ad<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function Dm(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Yb(i,e){return e+1<i.length&&Dm(i,e)}function VI(i,e){return Dm(i,e)&&4<=i.length-e}function qb(i,e){if(e+1<i.length&&Dm(i,e)){let r=Wb(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||Yb(i,n)}return!1}var Bf=class extends Na{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=ka(e,0),r=(t==null?void 0:t.length)||0;if(qb(e,r))return!1;for(let s=e.length;r<s;r++)if(FI(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return UI(e,t)}appendFrame(e,t,r){Hb(e,this.observer,t,r,e.manifestCodec);let s=Kb(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},WI=/\/emsg[-/]ID3/i,$f=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=ki("video",1),a=this.audioTrack=ki("audio",1),o=this.txtTrack=ki("text",1);if(this.id3Track=ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Sb(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=Tb.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return _R(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Yt(this.remainderData,e));let o=CR(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=RE(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=RE(e,t),{videoTrack:t,audioTrack:ki(),id3Track:s,textTrack:ki()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=ae(e.samples,["emsg"]);s&&s.forEach(n=>{let a=MR(n);if(WI.test(a.schemeIdUri)){let o=q(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:ui.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},jb=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},Hf=class extends Na{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=zb(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=ka(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&km(t)!==void 0&&jb(e,r)<16}};function zb(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,b=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),T=1536/o*9e4,_=r+s*T,A=e.subarray(t,t+u);return i.config=b,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:_}),u}var Gf=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&L.log(e.pts+"/"+e.dts+":"+e.debug)}},Dd=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let x=u();if(x===3&&h(1),m(),m(),h(1),c())for(a=x!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let b=u(),T=u(),_=d(1);_===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let A=[1,1];if(c()&&c())switch(l()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((b+1)*16-e*2-t*2),height:(2-_)*(T+1)*16-(_?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},Kf=class extends Gf{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let E=new Dd(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,Rb(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,E=new Dd(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;let b=p.subarray(1,4),T="avc1.";for(let _=0;_<3;_++){let A=b[_].toString(16);A.length<2&&(A="0"+A),T+=A}e.codec=T}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Yt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=Yt(f.data,t))}return e.naluState=s,a}},Vf=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Pa(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Ib(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ft=188,Wf=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Kf}static probe(e){let t=i.syncOffset(e);return t>0&&L.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ft*5,t-ft)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ft)if(e[l]===71&&(t-l===ft||e[l+ft]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ft*99,e.length-ft)+1)),n||(n=Yf(e,l)===0),n&&o>1&&(a===0&&o>2||l+ft>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Tb[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,b=this._pmtId,T=e.length;if(this.remainderData&&(e=Yt(this.remainderData,e),T=e.length,this.remainderData=null),T<ft&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));T-=(T-_)%ft,T<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let A=0;for(let S=_;S<T;S+=ft)if(e[S]===71){let w=!!(e[S+1]&64),M=Yf(e,S),k=(e[S+3]&48)>>4,P;if(k>1){if(P=S+5+e[S+4],P===S+ft)continue}else P=S+4;switch(M){case u:w&&(c&&(n=vn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(P,S+ft)),c.size+=S+ft-P);break;case h:if(w){if(m&&(n=vn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(P,S+ft)),m.size+=S+ft-P);break;case f:w&&(p&&(n=vn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(P,S+ft)),p.size+=S+ft-P);break;case 0:w&&(P+=e[P]+1),b=this._pmtId=YI(e,P);break;case b:{w&&(P+=e[P]+1);let N=qI(e,P,this.typeSupported,r,this.observer);u=N.videoPid,u>0&&(a.pid=u,a.segmentCodec=N.segmentVideoCodec),h=N.audioPid,h>0&&(o.pid=h,o.segmentCodec=N.segmentAudioCodec),f=N.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(L.warn(`MPEG-TS PMT found at ${S} after unknown PID '${g}'. Backtracking to sync byte @${_} to parse all TS packets.`),g=null,S=_-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=M;break}}else A++;A>0&&Md(this.observer,new Error(`Found ${A} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;let x={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(x),x}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=vn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=vn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=vn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Vf(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Yt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!wd(n,a);a++);if(a!==r){let c,h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",Md(this.observer,new Error(c),h),!h)return}Hb(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Gb(e.samplerate);l=s.sample.pts+c}else{L.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Kb(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!wd(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){L.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Yb(r,a)){let l=Vb(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){L.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=zb(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){L.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=it({},t,{type:this._videoTrack?ui.emsg:ui.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Yf(i,e){return((i[e+1]&31)<<8)+i[e+2]}function YI(i,e){return(i[e+10]&31)<<8|i[e+11]}function qI(i,e,t,r,s){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){let d=Yf(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){of("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){of("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?L.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){of("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?L.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return Md(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return Md(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function Md(i,e,t){L.warn(`parsing error: ${e.message}`),i.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function of(i){L.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function vn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Yt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(L.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var qf=class extends Na{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=ka(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&km(t)!==void 0&&jb(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(qb(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return VI(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Vb(e,t,r,this.basePTS,this.frameIndex)}},Pd=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},vr=Math.pow(2,32)-1,at=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(vr+1)),o=Math.floor(r%(vr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(vr+1)),a=Math.floor(t%(vr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e);return Yt(i.FTYP,t)}};at.types=void 0;at.HDLR_TYPES=void 0;at.STTS=void 0;at.STSC=void 0;at.STCO=void 0;at.STSZ=void 0;at.VMHD=void 0;at.SMHD=void 0;at.STSD=void 0;at.FTYP=void 0;at.DINF=void 0;var Xb=9e4;function Mm(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function jI(i,e,t=1,r=!1){return Mm(i,e,1/t,r)}function xa(i,e=!1){return Mm(i,1e3,1/Xb,e)}function zI(i,e=1){return Mm(i,Xb,1/e)}var XI=10*1e3,JE=1024,QI=1152,ZI=1536,En=null,lf=null,_n=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,En===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);En=a?parseInt(a[1]):0}if(lf===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);lf=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e[0].pts,s=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Wt(o,r),l=o-n),l>0?n:o},r);return t&&L.debug("PTS rollover detected"),s}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n,E=e.pid>-1,b=t.pid>-1,T=t.samples.length,_=e.samples.length>0,A=o&&T>0||T>1;if((!E||_)&&(!b||A)||this.ISGenerated||o){if(this.ISGenerated){var S,w,M,k;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((S=t.pixelRatio)==null?void 0:S[0])!==((w=X.pixelRatio)==null?void 0:w[0])||((M=t.pixelRatio)==null?void 0:M[1])!==((k=X.pixelRatio)==null?void 0:k[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let P=this.isVideoContiguous,N=-1,B;if(A&&(N=JI(t.samples),!P&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,N>0){L.warn(`[mp4-remuxer]: Dropped ${N} out of ${T} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(N),t.dropped+=N,g+=(t.samples[0].pts-X)/t.inputTimeScale,B=g}else N===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),m=!1);if(this.ISGenerated){if(_&&A){let X=this.getVideoStartPts(t.samples),V=(Wt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,V),g+=Math.max(0,-V)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,b||A||l===te.AUDIO?g:void 0),A){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,P,X)}}else A&&(d=this.remuxVideo(t,g,P,0));d&&(d.firstKeyFrame=N,d.independent=N!==-1,d.firstKeyFramePTS=B)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Qb(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Zb(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):at.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:at.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){let p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Wt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,E=!1;if(!r||u===null){let W=t*n,G=a[0].pts-Wt(a[0].dts,a[0].pts);En&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let b=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Wt(G.pts-b,u),G.dts=Wt(G.dts-b,u),G.dts<a[W>0?W-1:W].dts&&(E=!0)}E&&a.sort(function(W,G){let oe=W.dts-G.dts,J=W.pts-G.pts;return oe||J}),f=a[0].dts,m=a[a.length-1].dts;let T=m-f,_=T?Math.round(T/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>_,oe=W<-1;if((G||oe)&&(G?L.warn(`AVC: ${xa(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${xa(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!oe||u>=a[0].pts||En)){f=u;let J=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=J;else for(let Ee=0;Ee<a.length&&!(a[Ee].dts>J);Ee++)a[Ee].dts-=W,a[Ee].pts-=W;L.log(`Video: Initial PTS/DTS adjusted: ${xa(J,!0)}/${xa(f,!0)}, delta: ${xa(W,!0)} ms`)}}f=Math.max(0,f);let A=0,x=0,S=f;for(let W=0;W<l;W++){let G=a[W],oe=G.units,J=oe.length,Ee=0;for(let Ge=0;Ge<J;Ge++)Ee+=oe[Ge].data.length;x+=Ee,A+=J,G.length=Ee,G.dts<S?(G.dts=S,S+=_/4|0||1):S=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let w=x+4*A+8,M;try{M=new Uint8Array(w)}catch(W){this.observer.emit(v.ERROR,v.ERROR,{type:re.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:w,reason:`fail allocating video mdat ${w}`});return}let k=new DataView(M.buffer);k.setUint32(0,w),M.set(at.types.mdat,4);let P=!1,N=Number.POSITIVE_INFINITY,B=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],oe=G.units,J=0;for(let Ye=0,ze=oe.length;Ye<ze;Ye++){let St=oe[Ye],ar=St.data,Fs=St.data.byteLength;k.setUint32(c,Fs),c+=4,M.set(ar,c),c+=Fs,J+=4+Fs}let Ee;if(W<l-1)h=a[W+1].dts-G.dts,Ee=a[W+1].pts-G.pts;else{let Ye=this.config,ze=W>0?G.dts-a[W-1].dts:_;if(Ee=W>0?G.pts-a[W-1].pts:_,Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){let St=Math.floor(Ye.maxBufferHole*n),ar=(s?p+s*n:this.nextAudioPts)-G.pts;ar>St?(h=ar-ze,h<0?h=ze:P=!0,L.log(`[mp4-remuxer]: It is approximately ${ar/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=ze}else h=ze}let Ge=Math.round(G.pts-G.dts);N=Math.min(N,h),X=Math.max(X,h),B=Math.min(B,Ee),z=Math.max(z,Ee),o.push(new Od(G.key,h,J,Ge))}if(o.length){if(En){if(En<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(lf&&z-B<X-N&&_/X<.025&&o[0].cts===0){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,oe=o.length;G<oe;G++){let J=W+o[G].duration,Ee=W+o[G].cts;if(G<oe-1){let Ge=J+o[G+1].cts;o[G].duration=Ge-Ee}else o[G].duration=G?o[G-1].duration:_;o[G].cts=0,W=J}}}h=P||!h?_:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let le={data1:at.moof(e.sequenceNumber++,f,it({},e,{samples:o})),data2:M,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,le}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return QI;case"ac3":return ZI;default:return JE}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,E=this.nextAudioPts||-1,b=t*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(b-E)<9e3||Math.abs(Wt(p[0].pts-T,b)-E)<20*u),p.forEach(function(V){V.pts=Wt(V.pts-T,b)}),!r||E<0){if(p=p.filter(V=>V.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,b):E=p[0].pts}if(e.segmentCodec==="aac"){let V=this.config.maxAudioFramesDrift;for(let ne=0,le=E;ne<p.length;ne++){let W=p[ne],G=W.pts,oe=G-le,J=Math.abs(1e3*oe/a);if(oe<=-V*u&&m)ne===0&&(L.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*oe/a)} ms.`),this.nextAudioPts=E=le=G);else if(oe>=V*u&&J<XI&&m){let Ee=Math.round(oe/u);le=G-Ee*u,le<0&&(Ee--,le+=u),ne===0&&(this.nextAudioPts=E=le),L.warn(`[mp4-remuxer]: Injecting ${Ee} audio frame @ ${(le/a).toFixed(3)}s due to ${Math.round(1e3*oe/a)} ms gap.`);for(let Ge=0;Ge<Ee;Ge++){let Ye=Math.max(le,0),ze=Pd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ze||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ze=W.unit.subarray()),p.splice(ne,0,{unit:ze,pts:Ye}),le+=u,ne++}}W.pts=le,le+=u}}let _=null,A=null,x,S=0,w=p.length;for(;w--;)S+=p[w].unit.byteLength;for(let V=0,ne=p.length;V<ne;V++){let le=p[V],W=le.unit,G=le.pts;if(A!==null){let J=f[V-1];J.duration=Math.round((G-A)/l)}else if(r&&e.segmentCodec==="aac"&&(G=E),_=G,S>0){S+=g;try{x=new Uint8Array(S)}catch(J){this.observer.emit(v.ERROR,v.ERROR,{type:re.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:S,reason:`fail allocating audio mdat ${S}`});return}h||(new DataView(x.buffer).setUint32(0,S),x.set(at.types.mdat,4))}else return;x.set(W,g);let oe=W.byteLength;g+=oe,f.push(new Od(!0,d,oe,0)),A=G}let M=f.length;if(!M)return;let k=f[f.length-1];this.nextAudioPts=E=A+l*k.duration;let P=h?new Uint8Array(0):at.moof(e.sequenceNumber++,_/l,it({},e,{samples:f}));e.samples=[];let N=_/a,B=E/a,z={data1:P,data2:x,startPTS:N,endPTS:B,startDTS:N,endDTS:B,type:"audio",hasAudio:!0,hasVideo:!1,nb:M};return this.isAudioContiguous=!0,z}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*JE,m=Math.ceil((h-c)/f),p=Pd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!p){L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let E=0;E<m;E++){let b=c+E*f;g.push({unit:p,pts:b,dts:b})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Wt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function JI(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Qb(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Wt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Wt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function Zb(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Wt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var Od=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},jf=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(xR(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Sb(e);s.audio&&(t=eb(s.audio,we.AUDIO)),s.video&&(r=eb(s.video,we.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};q(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=IR(h,m),g=RR(m,h),E=g===null?n:g;(eL(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&L.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let b=e?E-d.baseTime/d.timescale:u,T=b+p;kR(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=T:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let _=!!m.audio,A=!!m.video,x="";_&&(x+="audio"),A&&(x+="video");let S={data1:h,startPTS:b,startDTS:b,endPTS:T,endDTS:T,type:x,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=S.type==="audio"?S:void 0,c.video=S.type!=="audio"?S:void 0,c.initSegment=f,c.id3=Qb(r,n,d,d),s.samples.length&&(c.text=Zb(s,n,d)),c}};function eL(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function eb(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===we.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Ad(t,!1);let r="mp4a.40.5";return L.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return L.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var er;try{er=self.performance.now.bind(self.performance)}catch{L.debug("Unable to use Performance API on this environment"),er=Sn==null?void 0:Sn.Date.now}var md=[{demux:$f,remux:jf},{demux:Wf,remux:_n},{demux:Bf,remux:_n},{demux:qf,remux:_n}];md.splice(2,0,{demux:Hf,remux:_n});var Nd=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=er();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:b,initSegmentData:T}=l,_=tL(a,t);if(_&&_.method==="AES-128"){let w=this.getDecrypter();if(w.isSync()){let M=w.softwareDecrypt(a,_.key.buffer,_.iv.buffer);if(r.part>-1&&(M=w.flush()),!M)return n.executeEnd=er(),df(r);a=new Uint8Array(M)}else return this.decryptionPromise=w.webCryptoDecrypt(a,_.key.buffer,_.iv.buffer).then(M=>{let k=this.push(M,null,r);return this.decryptionPromise=null,k}),this.decryptionPromise}let A=this.needsProbing(u,c);if(A){let w=this.configureTransmuxer(a);if(w)return L.warn(`[transmuxer] ${w.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),n.executeEnd=er(),df(r)}(u||c||m||A)&&this.resetInitSegment(T,p,g,b,t),(u||m||A)&&this.resetInitialTimestamp(E),d||this.resetContiguity();let x=this.transmux(a,_,f,h,r),S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=er(),x}flush(e){let t=e.transmuxing;t.executeStart=er();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=er(),[df(e)];let u=l.flush(o);return pd(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=er()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=md.length;h<f;h++){var o;if((o=md[h].demux)!=null&&o.probe(e)){a=md[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Pa(this.config)),e}};function tL(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var df=i=>({remuxResult:{},chunkMeta:i});function pd(i){return"then"in i&&i.then instanceof Function}var zf=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},Xf=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},Jb={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,b,T;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(T=1,b=new Array(E-1);T<E;T++)b[T-1]=arguments[T];g.fn.apply(g.context,b)}else{var _=g.length,A;for(T=0;T<_;T++)switch(g[T].once&&this.removeListener(d,g[T].fn,void 0,!0),E){case 1:g[T].fn.call(g[T].context);break;case 2:g[T].fn.call(g[T].context,u);break;case 3:g[T].fn.call(g[T].context,u,c);break;case 4:g[T].fn.call(g[T].context,u,c,h);break;default:if(!b)for(A=1,b=new Array(E-1);A<E;A++)b[A-1]=arguments[A];g[T].fn.apply(g[T].context,b)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Jb);var iL=Jb.exports,Pm=zx(iL),Ud=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===v.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new Pm,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);let o=as(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||wI())){try{n.workerPath?(L.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=MI(n.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=DI()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new Nd(this.observer,l,n,"",t)}return}this.transmuxer=new Nd(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),b=!(g&&d.level===g.level),T=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=T===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),x=!b&&(T===1||T===0&&(_===1||A&&_<=0)),S=self.performance.now();(b||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=S),a&&(_||!x)&&(a.stats.parsing.start=S);let w=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),M=new Xf(E,x,l,b,m,w);if(!x||E||w){L.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1246
1246
  discontinuity: ${E}
1247
1247
  trackSwitch: ${b}
1248
1248
  contiguous: ${x}
1249
1249
  accurateTimeOffset: ${l}
1250
1250
  timeOffset: ${m}
1251
- initSegmentChange: ${w}`);let k=new Yf(r,s,t,o,u);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:M},e instanceof ArrayBuffer?[e]:[]);else if(f){let k=f.push(e,p,d,M);md(k)?(f.async=!0,k.then(P=>{this.handleTransmuxComplete(P)}).catch(P=>{this.transmuxerError(P,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(k))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);md(r)||t.async?(md(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){L.warn(`worker message received with no ${t?"event name":"data"}`);return}let r=this.hls;if(this.hls)switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":L[t.data.logType]&&L[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}};function Jb(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!xn(i[t].attrs,e[t].attrs))return!1;return!0}function xn(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function jf(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var tb=100,zf=class extends Na{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",te.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===O.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=O.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(tb),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=O.IDLE):(this.loadedmetadata=!1,this.state=O.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case O.IDLE:this.doTickIdle();break;case O.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=O.WAITING_INIT_PTS}break}case O.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=O.IDLE}break}case O.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=O.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ve.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Rf(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=O.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=O.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!this.buffering||!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=O.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ce.AUDIO,te.AUDIO));let d=this.getFwdBufferInfo(l,te.AUDIO);if(d===null)return;let{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=O.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,te.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start,E=this.flushing?this.getLoadPosition():d.end;if(c&&r){let A=this.getLoadPosition();u&&!xn(c.attrs,u.attrs)&&(E=A),o.PTSKnown&&A<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let b=this.getNextFragment(E,o),T=!1;if(b&&this.isLoopLoading(b,E)&&(T=!!b.gap,b=this.getNextFragmentLoopLoading(b,o,d,te.MAIN,m)),!b){this.bufferFlushed=!0;return}let _=h&&b.start>h.end+o.targetduration;if(_||!(h!=null&&h.len)&&d.len){let A=this.getAppendedFrag(b.start,te.MAIN);if(A===null||(T||(T=!!A.gap||!!_&&h.len===0),_&&!T||T&&d.nextStart&&d.nextStart<A.end))return}this.loadFragment(b,a,E)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new br(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(tb):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=O.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=O.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)Ld(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===O.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=O.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Nd(this.hls,te.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,E=g!==-1,b=new Pa(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,b,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new kd,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=O.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==te.AUDIO){if(!this.loadedmetadata&&r.type===te.MAIN){let n=this.videoBuffer||this.media;n&&Ve.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,gt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=O.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===O.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Te.AUDIO_TRACK&&(this.state=O.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Ce.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Ce.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===O.ENDED&&(this.state=O.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,te.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=O.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:E,startDTS:b,endDTS:T}=h;d&&(d.elementaryStreams[Ce.AUDIO]={startPTS:g,endPTS:E,startDTS:b,endDTS:T}),l.setElementaryStreamInfo(Ce.AUDIO,g,E,b,T),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=it({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){let g=it({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==O.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===pt.NOT_LOADED||s===pt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=O.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Ld(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){let{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,gt({},e))}},Xf=class extends Ma{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=Ci(l,o,pn);if(h>-1)n=o[h];else{let f=Ci(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Te.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&Tn(e,s,pn))return s;let n=Ci(e,this.tracksInGroup,pn);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=yI(e,t.levels,r,a,pn);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=Ci(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,gt({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Tn(e,s,pn)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(Tn({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,pn))return d}for(let d=0;d<t.length;d++){let u=t[d];if(xn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(xn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},ib=500,Qf=class extends Na{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",te.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=O.IDLE,this.setInterval(ib),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=O.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,te.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===te.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===te.SUBTITLE&&(t.details===D.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==O.STOPPED&&(this.state=O.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Jb(this.levels,t)){this.levels=t.map(r=>new br(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new br(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,te.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(ib)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(Ld(a,c),d=a.fragments[0].start):h&&(d=h.start,xf(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,xf(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===O.IDLE&&(Id(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=O.IDLE})}}doTick(){if(!this.media){this.state=O.IDLE;return}if(this.state===O.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,te.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let E=s.maxFragLookUpTolerance,b=o>m-E?0:E;p=Id(g,h,Math.max(h[0].start,o),b),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let E=p.sn-u.startSN,b=h[E-1];b&&b.cc===p.cc&&this.fragmentTracker.getState(b)===pt.NOT_LOADED&&(p=b)}this.fragmentTracker.getState(p)===pt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Zf(this.tracksBuffered[this.currentTrackId]||[])}},Zf=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Jf=class extends Ma{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=ud(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),ud(this.media.textTracks).forEach(t=>{bn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=Ci(o,a);if(u>-1)n=a[u];else{let c=Ci(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||Tn(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(xn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(xn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(jf(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Te.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&Tn(e,r))return r;let s=Ci(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=Ci(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=ud(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>jf(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!q(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},em=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},rb=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,tm=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&L.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=BR(as(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new em(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=as(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,sb(r),iL(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&sb(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer(),this.hls.resumeBuffering()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=CE(l.codec,l.levelCodec),p=m==null?void 0:m.replace(rb,"$1"),g=CE(u,c),E=(o=g)==null?void 0:o.replace(rb,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=_d(g,this.appendSource));let b=`${h};codecs=${g}`;this.appendChangeType(a,b),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let E=l.start,b={execute:()=>{if(c.executeStart=self.performance.now(),g){let T=this.sourceBuffer[o];if(T){let _=E-T.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${_}) sn: ${l.sn})`),T.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),m&&m.first===0&&(m.first=T);let{sourceBuffer:_}=this,A={};for(let x in _)A[x]=Ve.getBuffered(_[x]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:A})},onError:T=>{let _={type:re.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:T,err:T,fatal:!1};if(T.code===DOMException.QUOTA_EXCEEDED_ERR)_.details=D.BUFFER_FULL_ERROR;else{let A=++this.appendErrors[o];_.details=D.BUFFER_APPEND_ERROR,this.warn(`Failed ${A}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),A>=r.config.appendErrorMaxRetry&&(_.fatal=!0)}r.trigger(v.ERROR,_)}};s.append(b,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[Ce.AUDIOVIDEO]?n.push("audiovideo"):(a[Ce.AUDIO]&&n.push("audio"),a[Ce.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(q(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(q(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ve.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ve.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=q(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!q(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=_d(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;let r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=q(s.duration)?s.duration:1/0,u=q(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function sb(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function iL(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var rL={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ey=i=>String.fromCharCode(rL[i]||i),li=15,Ji=100,sL={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},nL={17:2,18:4,21:6,22:8,23:10,19:13,20:15},aL={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},oL={25:2,26:4,29:6,30:8,31:10,27:13,28:15},lL=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],im=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;L.log(`${this.time} [${e}] ${r}`)}}},ts=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Ud=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},rm=class{constructor(){this.uchar=" ",this.penState=new Ud}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},sm=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Ud,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Ji;t++)this.chars.push(new rm);this.logger=e}equals(e){for(let t=0;t<Ji;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Ji;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Ji;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Ji&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Ji)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=ey(e);if(this.pos>=Ji){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Ji;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Ji;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},ka=class{constructor(e){this.rows=[],this.currRow=li-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<li;t++)this.rows.push(new sm(e));this.logger=e}reset(){for(let e=0;e<li;e++)this.rows[e].clear();this.currRow=li-1}equals(e){let t=!0;for(let r=0;r<li;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<li;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<li;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<li;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<li;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1252
- `)),r}getTextAndFormat(){return this.rows}},Fd=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ka(r),this.nonDisplayedMemory=new ka(r),this.lastOutputScreen=new ka(r),this.currRollUpRow=this.displayedMemory.rows[li-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[li-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},Bd=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=uL(),this.logger=void 0;let s=this.logger=new im;this.channels=[null,new Fd(e,t,s),new Fd(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){let s=t[r]&127,n=t[r+1]&127,a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+ts([t[r],t[r+1]])+"] -> ("+ts([s,n])+")");let l=this.cmdHistory;if(s>=16&&s<=31){if(dL(s,n,l)){ad(null,null,l),this.logger.log(3,()=>"Repeated command ("+ts([s,n])+") is dropped");continue}ad(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else ad(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){let u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ts([s,n])+" orig: "+ts([t[r],t[r+1]]))}}parseCmd(e,t){let r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+ts([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;let a=e<=23?1:2;t>=64&&t<=95?r=a===1?sL[e]:aL[e]:r=a===1?nL[e]:oL[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+ey(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+ts(s).join(",")),s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=lL[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}ad(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function ad(i,e,t){t.a=i,t.b=e}function dL(i,e,t){return t.a===i&&t.b===e}function uL(){return{a:null,b:null}}var yn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},Dm=function(){if(Sn!=null&&Sn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,b="",T=!0,_="auto",A="start",x=50,S="middle",w=50,M="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(k){h=""+k}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(k){f=!!k}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(k){if(typeof k!="number")throw new TypeError("Start time must be set to a number.");m=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(k){if(typeof k!="number")throw new TypeError("End time must be set to a number.");p=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(k){g=""+k,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(k){E=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return b},set:function(k){let P=r(k);if(P===!1)throw new SyntaxError("An invalid or illegal string was specified.");b=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return T},set:function(k){T=!!k,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return _},set:function(k){if(typeof k!="number"&&k!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return A},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");A=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return x},set:function(k){if(k<0||k>100)throw new Error("Position must be between 0 and 100.");x=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return S},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");S=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return w},set:function(k){if(k<0||k>100)throw new Error("Size must be between 0 and 100.");w=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return M},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");M=P,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),nm=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function ty(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var am=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function iy(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var om=new Dm(0,0,""),od=om.align==="middle"?"middle":"center";function cL(i,e,t){let r=i;function s(){let o=ty(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new am;iy(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",od,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",od,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",od,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&om.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",od);let c=d.get("position","auto");c==="auto"&&om.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function ry(i){return i.replace(/<br(?: \/)?>/gi,`
1253
- `)}var lm=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new nm,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=ry(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1251
+ initSegmentChange: ${w}`);let k=new zf(r,s,t,o,u);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:M},e instanceof ArrayBuffer?[e]:[]);else if(f){let k=f.push(e,p,d,M);pd(k)?(f.async=!0,k.then(P=>{this.handleTransmuxComplete(P)}).catch(P=>{this.transmuxerError(P,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(k))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);pd(r)||t.async?(pd(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){L.warn(`worker message received with no ${t?"event name":"data"}`);return}let r=this.hls;if(this.hls)switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":L[t.data.logType]&&L[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}};function ey(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!xn(i[t].attrs,e[t].attrs))return!1;return!0}function xn(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function Qf(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var tb=100,Zf=class extends Oa{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",te.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===O.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=O.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(tb),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=O.IDLE):(this.loadedmetadata=!1,this.state=O.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case O.IDLE:this.doTickIdle();break;case O.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=O.WAITING_INIT_PTS}break}case O.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=O.IDLE}break}case O.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=O.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ve.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);kf(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=O.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=O.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!this.buffering||!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=O.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,we.AUDIO,te.AUDIO));let d=this.getFwdBufferInfo(l,te.AUDIO);if(d===null)return;let{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=O.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,te.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start,E=this.flushing?this.getLoadPosition():d.end;if(c&&r){let A=this.getLoadPosition();u&&!xn(c.attrs,u.attrs)&&(E=A),o.PTSKnown&&A<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let b=this.getNextFragment(E,o),T=!1;if(b&&this.isLoopLoading(b,E)&&(T=!!b.gap,b=this.getNextFragmentLoopLoading(b,o,d,te.MAIN,m)),!b){this.bufferFlushed=!0;return}let _=h&&b.start>h.end+o.targetduration;if(_||!(h!=null&&h.len)&&d.len){let A=this.getAppendedFrag(b.start,te.MAIN);if(A===null||(T||(T=!!A.gap||!!_&&h.len===0),_&&!T||T&&d.nextStart&&d.nextStart<A.end))return}this.loadFragment(b,a,E)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new br(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(tb):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=O.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=O.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)kd(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===O.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=O.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Ud(this.hls,te.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,E=g!==-1,b=new Ma(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,b,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new Cd,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=O.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==te.AUDIO){if(!this.loadedmetadata&&r.type===te.MAIN){let n=this.videoBuffer||this.media;n&&Ve.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,gt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=O.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===O.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Te.AUDIO_TRACK&&(this.state=O.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==we.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==we.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===O.ENDED&&(this.state=O.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,te.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=O.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:E,startDTS:b,endDTS:T}=h;d&&(d.elementaryStreams[we.AUDIO]={startPTS:g,endPTS:E,startDTS:b,endDTS:T}),l.setElementaryStreamInfo(we.AUDIO,g,E,b,T),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=it({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){let g=it({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==O.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===pt.NOT_LOADED||s===pt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=O.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&kd(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){let{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,gt({},e))}},Jf=class extends Da{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=Ci(l,o,pn);if(h>-1)n=o[h];else{let f=Ci(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Te.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&Tn(e,s,pn))return s;let n=Ci(e,this.tracksInGroup,pn);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=TI(e,t.levels,r,a,pn);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=Ci(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,gt({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Tn(e,s,pn)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(Tn({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,pn))return d}for(let d=0;d<t.length;d++){let u=t[d];if(xn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(xn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},ib=500,em=class extends Oa{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",te.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=O.IDLE,this.setInterval(ib),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=O.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,te.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===te.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===te.SUBTITLE&&(t.details===D.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==O.STOPPED&&(this.state=O.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&ey(this.levels,t)){this.levels=t.map(r=>new br(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new br(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,te.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(ib)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(kd(a,c),d=a.fragments[0].start):h&&(d=h.start,Lf(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,Lf(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===O.IDLE&&(Ld(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=O.IDLE})}}doTick(){if(!this.media){this.state=O.IDLE;return}if(this.state===O.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,te.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let E=s.maxFragLookUpTolerance,b=o>m-E?0:E;p=Ld(g,h,Math.max(h[0].start,o),b),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let E=p.sn-u.startSN,b=h[E-1];b&&b.cc===p.cc&&this.fragmentTracker.getState(b)===pt.NOT_LOADED&&(p=b)}this.fragmentTracker.getState(p)===pt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new tm(this.tracksBuffered[this.currentTrackId]||[])}},tm=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},im=class extends Da{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=cd(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),cd(this.media.textTracks).forEach(t=>{bn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=Ci(o,a);if(u>-1)n=a[u];else{let c=Ci(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||Tn(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(xn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(xn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(Qf(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Te.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&Tn(e,r))return r;let s=Ci(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=Ci(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=cd(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>Qf(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!q(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},rm=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},rb=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,sm=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&L.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=$R(as(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new rm(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=as(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,sb(r),rL(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&sb(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer(),this.hls.resumeBuffering()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=CE(l.codec,l.levelCodec),p=m==null?void 0:m.replace(rb,"$1"),g=CE(u,c),E=(o=g)==null?void 0:o.replace(rb,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=Ad(g,this.appendSource));let b=`${h};codecs=${g}`;this.appendChangeType(a,b),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let E=l.start,b={execute:()=>{if(c.executeStart=self.performance.now(),g){let T=this.sourceBuffer[o];if(T){let _=E-T.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${_}) sn: ${l.sn})`),T.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),m&&m.first===0&&(m.first=T);let{sourceBuffer:_}=this,A={};for(let x in _)A[x]=Ve.getBuffered(_[x]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:A})},onError:T=>{let _={type:re.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:T,err:T,fatal:!1};if(T.code===DOMException.QUOTA_EXCEEDED_ERR)_.details=D.BUFFER_FULL_ERROR;else{let A=++this.appendErrors[o];_.details=D.BUFFER_APPEND_ERROR,this.warn(`Failed ${A}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),A>=r.config.appendErrorMaxRetry&&(_.fatal=!0)}r.trigger(v.ERROR,_)}};s.append(b,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[we.AUDIOVIDEO]?n.push("audiovideo"):(a[we.AUDIO]&&n.push("audio"),a[we.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(q(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(q(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ve.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ve.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=q(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!q(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Ad(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;let r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=q(s.duration)?s.duration:1/0,u=q(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function sb(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function rL(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var sL={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ty=i=>String.fromCharCode(sL[i]||i),li=15,Ji=100,nL={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},aL={17:2,18:4,21:6,22:8,23:10,19:13,20:15},oL={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},lL={25:2,26:4,29:6,30:8,31:10,27:13,28:15},dL=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],nm=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;L.log(`${this.time} [${e}] ${r}`)}}},ts=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Fd=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},am=class{constructor(){this.uchar=" ",this.penState=new Fd}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},om=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Fd,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Ji;t++)this.chars.push(new am);this.logger=e}equals(e){for(let t=0;t<Ji;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Ji;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Ji;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Ji&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Ji)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=ty(e);if(this.pos>=Ji){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Ji;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Ji;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},La=class{constructor(e){this.rows=[],this.currRow=li-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<li;t++)this.rows.push(new om(e));this.logger=e}reset(){for(let e=0;e<li;e++)this.rows[e].clear();this.currRow=li-1}equals(e){let t=!0;for(let r=0;r<li;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<li;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<li;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<li;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<li;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1252
+ `)),r}getTextAndFormat(){return this.rows}},Bd=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new La(r),this.nonDisplayedMemory=new La(r),this.lastOutputScreen=new La(r),this.currRollUpRow=this.displayedMemory.rows[li-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[li-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},$d=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=cL(),this.logger=void 0;let s=this.logger=new nm;this.channels=[null,new Bd(e,t,s),new Bd(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){let s=t[r]&127,n=t[r+1]&127,a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+ts([t[r],t[r+1]])+"] -> ("+ts([s,n])+")");let l=this.cmdHistory;if(s>=16&&s<=31){if(uL(s,n,l)){od(null,null,l),this.logger.log(3,()=>"Repeated command ("+ts([s,n])+") is dropped");continue}od(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else od(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){let u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ts([s,n])+" orig: "+ts([t[r],t[r+1]]))}}parseCmd(e,t){let r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+ts([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;let a=e<=23?1:2;t>=64&&t<=95?r=a===1?nL[e]:oL[e]:r=a===1?aL[e]:lL[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+ty(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+ts(s).join(",")),s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=dL[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}od(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function od(i,e,t){t.a=i,t.b=e}function uL(i,e,t){return t.a===i&&t.b===e}function cL(){return{a:null,b:null}}var yn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},Om=function(){if(Sn!=null&&Sn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,b="",T=!0,_="auto",A="start",x=50,S="middle",w=50,M="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(k){h=""+k}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(k){f=!!k}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(k){if(typeof k!="number")throw new TypeError("Start time must be set to a number.");m=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(k){if(typeof k!="number")throw new TypeError("End time must be set to a number.");p=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(k){g=""+k,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(k){E=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return b},set:function(k){let P=r(k);if(P===!1)throw new SyntaxError("An invalid or illegal string was specified.");b=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return T},set:function(k){T=!!k,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return _},set:function(k){if(typeof k!="number"&&k!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return A},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");A=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return x},set:function(k){if(k<0||k>100)throw new Error("Position must be between 0 and 100.");x=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return S},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");S=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return w},set:function(k){if(k<0||k>100)throw new Error("Size must be between 0 and 100.");w=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return M},set:function(k){let P=s(k);if(!P)throw new SyntaxError("An invalid or illegal string was specified.");M=P,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),lm=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function iy(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var dm=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function ry(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var um=new Om(0,0,""),ld=um.align==="middle"?"middle":"center";function hL(i,e,t){let r=i;function s(){let o=iy(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new dm;ry(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",ld,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",ld,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",ld,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&um.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",ld);let c=d.get("position","auto");c==="auto"&&um.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function sy(i){return i.replace(/<br(?: \/)?>/gi,`
1253
+ `)}var cm=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new lm,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=sy(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1254
1254
  `;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
1255
- `&&++a,t.buffer=n.slice(a),o}function s(n){iy(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Dm(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{cL(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1255
+ `&&++a,t.buffer=n.slice(a),o}function s(n){ry(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Om(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{hL(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1256
1256
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
1257
1257
 
1258
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},hL=/\r\n|\n\r|\n|\r/g,of=function(e,t,r=0){return e.slice(r,r+t.length)===t},fL=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!q(t)||!q(r)||!q(s)||!q(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},lf=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Mm(i,e,t){return lf(i.toString())+lf(e.toString())+lf(t)}var mL=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function pL(i,e,t,r,s,n,a){let o=new lm,l=wi(new Uint8Array(i)).trim().replace(hL,`
1258
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},fL=/\r\n|\n\r|\n|\r/g,uf=function(e,t,r=0){return e.slice(r,r+t.length)===t},mL=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!q(t)||!q(r)||!q(s)||!q(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},cf=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Nm(i,e,t){return cf(i.toString())+cf(e.toString())+cf(t)}var pL=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function gL(i,e,t,r,s,n,a){let o=new cm,l=wi(new Uint8Array(i)).trim().replace(fL,`
1259
1259
  `).split(`
1260
- `),d=[],u=e?jI(e.baseTime,e.timescale):0,c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){let E=t[r],b=t.ccOffset,T=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?b=t.ccOffset=E.start:mL(t,r,T)),T){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}b=T-t.presentationOffset}let _=g.endTime-g.startTime,A=Wt((g.startTime+b-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(A,0),g.endTime=Math.max(A+_,0);let x=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(x)),g.id||(g.id=Mm(g.startTime,g.endTime,x)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(of(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{of(E,"LOCAL:")?c=E.slice(6):of(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=fL(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
1261
- `)}),o.flush()}var df="stpp.ttml.im1t",sy=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ny=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,gL={left:"start",center:"center",right:"end",start:"start",end:"end"};function nb(i,e,t,r){let s=ae(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>wi(o)),a=qI(e.baseTime,1,e.timescale);try{n.forEach(o=>t(vL(o,a)))}catch(o){r(o)}}function vL(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=ab(uf(s,"styling","style")),d=ab(uf(s,"layout","region")),u=uf(s,"body","[begin]");return[].map.call(u,c=>{let h=ay(c,o);if(!h||!c.hasAttribute("begin"))return null;let f=hf(c.getAttribute("begin"),a),m=hf(c.getAttribute("dur"),a),p=hf(c.getAttribute("end"),a);if(f===null)throw ob(c);if(p===null){if(m===null)throw ob(c);p=f+m}let g=new Dm(f-e,p-e,h);g.id=Mm(g.startTime,g.endTime,g.text);let E=d[c.getAttribute("region")],b=l[c.getAttribute("style")],T=EL(E,b,l),{textAlign:_}=T;if(_){let A=gL[_];A&&(g.lineAlign=A),g.align=_}return it(g,T),g}).filter(c=>c!==null)}function uf(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function ab(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function ay(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1262
- `:(n=r.childNodes)!=null&&n.length?ay(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function EL(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=cf(e,r,l)||cf(i,r,l)||cf(s,r,l);return d&&(o[l]=d),o},{})}function cf(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function ob(i){return new Error(`Could not parse ttml timestamp ${i}`)}function hf(i,e){if(!i)return null;let t=ty(i);return t===null&&(sy.test(i)?t=bL(i,e):ny.test(i)&&(t=yL(i,e))),t}function bL(i,e){let t=sy.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function yL(i,e){let t=ny.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var dm=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=db(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new yn(this,"textTrack1"),t=new yn(this,"textTrack2"),r=new yn(this,"textTrack3"),s=new yn(this,"textTrack4");this.cea608Parser1=new Bd(1,e,t),this.cea608Parser2=new Bd(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=TL(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(lb(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,bn(r[e]),kb(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{bn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=db(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)bn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===df);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Jb(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?ud(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&lb(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)bn(u);else{let c=oy(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===te.MAIN){var r,s;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===te.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===df?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;nb(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{L.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Yt(r.initSegment.data,new Uint8Array(s)):s;pL(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),L.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||nb(t,this.initPTS[e.cc],()=>{r.textCodec=df,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Cb(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===te.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===te.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>yf(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>yf(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function oy(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function lb(i,e){return!!i&&i.kind===oy(e)&&jf(e,i)}function TL(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function db(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var um=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&q(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},cm=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},ld="[eme]",$d=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=L.debug.bind(L,ld),this.log=L.log.bind(L,ld),this.warn=L.warn.bind(L,ld),this.error=L.error.bind(L,ld),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===$e.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Ot?o(c):o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return gb===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=uR(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Li.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Li.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Li.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1263
- } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=jh(this.config),n=e.map(_E).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=SE(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ot?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=_E(e.keyFormat),n=s?[s]:jh(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=jh(this.config)),e.length===0)throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e,s=`"${e.type}" event: init data type: "${t}"`;if(this.debug(s),r===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[$e.FAIRPLAY]){let c=nt(new Uint8Array(r));try{let h=Sm(JSON.parse(c).sinf),f=Sb(new Uint8Array(h));if(!f)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");n=f.subarray(8,24),a=$e.FAIRPLAY}catch(h){this.warn(`${s} Failed to parse sinf: ${h}`);return}}else{let c=OR(r),h=c.filter(f=>f.systemId===Ra.WIDEVINE)[0];if(!h){c.length===0||c.some(f=>!f.systemId)?this.warn(`${s} contains incomplete or invalid pssh data`):this.log(`ignoring ${s} for ${c.map(f=>AE(f.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(a=AE(h.systemId),h.version===0&&h.data){let f=h.data.length-22;n=h.data.subarray(f,f+16)}}if(!a||!n)return;let o=Li.hexDump(n),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this,u=l[o];for(let c=0;c<d.length;c++){let h=d[c],f=h.decryptdata;if(!f.keyId)continue;let m=Li.hexDump(f.keyId);if(o===m||f.uri.replace(/-/g,"").indexOf(o)!==-1){if(u=l[m],f.pssh)break;delete l[m],f.pssh=new Uint8Array(r),f.keyId=n,u=l[o]=u.then(()=>this.generateRequestWithPreferredKeySession(h,t,r,"encrypted-event-key-match"));break}}u||(u=l[o]=this.getKeySystemSelectionPromise([a]).then(({keySystem:c,mediaKeys:h})=>{var f;this.throwIfDestroyed();let m=new wa("ISO-23001-7",o,(f=SE(c))!=null?f:"");return m.pssh=new Uint8Array(r),m.keyId=n,this.attemptSetMediaKeys(c,h).then(()=>{this.throwIfDestroyed();let p=this.createMediaKeySessionContext({decryptdata:m,keySystem:c,mediaKeys:h});return this.generateRequestWithPreferredKeySession(p,t,r,"encrypted-event-no-match")})})),u.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new wm,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(b=>{this.handleError(b),u.emit("error",b)}):g==="license-release"?e.keySystem===$e.FAIRPLAY&&(this.updateKeySession(e,vf("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Li.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Li.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:gt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return vf(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==$e.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},wa.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};$d.CDMCleanupPromise=void 0;var Ot=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},_t;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(_t||(_t={}));var hm;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(hm||(hm={}));var ss;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(ss||(ss={}));var _L={[ss.OBJECT]:["br","d","ot","tb"],[ss.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[ss.SESSION]:["cid","pr","sf","sid","st","v"],[ss.STATUS]:["bs","rtp"]},Fa=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},Hd=class{constructor(e){this.description=void 0,this.description=e}},AL="Dict";function SL(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function xL(i,e,t,r){return new Error(`failed to ${i} "${SL(e)}" as ${t}`,{cause:r})}var ub="Bare Item",RL="Boolean",IL="Byte Sequence",LL="Decimal",kL="Integer";function CL(i){return i<-999999999999999||999999999999999<i}var wL=/[\x00-\x1f\x7f]+/,DL="Token",ML="Key";function Di(i,e,t){return xL("serialize",i,e,t)}function PL(i){if(typeof i!="boolean")throw Di(i,RL);return i?"?1":"?0"}function OL(i){return btoa(String.fromCharCode(...i))}function NL(i){if(ArrayBuffer.isView(i)===!1)throw Di(i,IL);return`:${OL(i)}:`}function ly(i){if(CL(i))throw Di(i,kL);return i.toString()}function UL(i){return`@${ly(i.getTime()/1e3)}`}function dy(i,e){if(i<0)return-dy(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function FL(i){let e=dy(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Di(i,LL);let t=e.toString();return t.includes(".")?t:`${t}.0`}var BL="String";function $L(i){if(wL.test(i))throw Di(i,BL);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function HL(i){return i.description||i.toString().slice(7,-1)}function cb(i){let e=HL(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Di(e,DL);return e}function fm(i){switch(typeof i){case"number":if(!q(i))throw Di(i,ub);return Number.isInteger(i)?ly(i):FL(i);case"string":return $L(i);case"symbol":return cb(i);case"boolean":return PL(i);case"object":if(i instanceof Date)return UL(i);if(i instanceof Uint8Array)return NL(i);if(i instanceof Hd)return cb(i);default:throw Di(i,ub)}}function mm(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Di(i,ML);return i}function Pm(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${mm(e)}`:`;${mm(e)}=${fm(t)}`).join("")}function uy(i){return i instanceof Fa?`${fm(i.value)}${Pm(i.params)}`:fm(i)}function GL(i){return`(${i.value.map(uy).join(" ")})${Pm(i.params)}`}function KL(i,e={whitespace:!0}){if(typeof i!="object")throw Di(i,AL);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Fa||(n=new Fa(n));let a=mm(s);return n.value===!0?a+=Pm(n.params):(a+="=",Array.isArray(n.value)?a+=GL(n):a+=uy(n)),a}).join(`,${r}`)}function VL(i,e){return KL(i,e)}var WL=i=>i==="ot"||i==="sf"||i==="st",YL=i=>typeof i=="number"?q(i):i!=null&&i!==""&&i!==!1;function qL(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function jL(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var pd=i=>Math.round(i),zL=(i,e)=>(e!=null&&e.baseUrl&&(i=qL(i,e.baseUrl)),encodeURIComponent(i)),dd=i=>pd(i/100)*100,XL={br:pd,d:pd,bl:dd,dl:dd,mtp:dd,nor:zL,rtp:dd,tb:pd};function QL(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=it({},XL,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||YL(o)&&(WL(a)&&typeof o=="string"&&(o=new Hd(o)),t[a]=o))}),t}function cy(i,e={}){return i?VL(QL(i,e),it({whitespace:!1},e)):""}function ZL(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(_L).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||ss.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=cy(o,e),n),{})}function JL(i,e,t){return it(i,ZL(e,t))}var ek="CMCD";function tk(i,e={}){if(!i)return"";let t=cy(i,e);return`${ek}=${encodeURIComponent(t)}`}var hb=/CMCD=[^&#]+/;function ik(i,e,t){let r=tk(e,t);if(!r)return i;if(hb.test(i))return i.replace(hb,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var pm=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:_t.MANIFEST,su:!this.initialized})}catch(n){L.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===_t.VIDEO||o===_t.AUDIO||o==_t.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){L.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||jL(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:hm.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){it(t,this.createData());let r=t.ot===_t.INIT||t.ot===_t.VIDEO||t.ot===_t.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),JL(e.headers,t)):e.url=ik(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return _t.TIMED_TEXT;if(e.sn==="initSegment")return _t.INIT;if(t==="audio")return _t.AUDIO;if(t==="main")return this.hls.audioTracks.length?_t.VIDEO:_t.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===_t.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===_t.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ve.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},rk=3e5,gm=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===mt.SendAlternateToPenaltyBox&&r.flags===oi.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>rk&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Pb(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===Te.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===Te.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new je(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=hy(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new br({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),fb(this.audioTracks,r,l,a),fb(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let b={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,b),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function fb(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=it({},a);return o.details=void 0,o.attrs=new je(o.attrs),o.url=o.attrs.URI=hy(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function hy(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var sk=/^age:\s*[\d.]+\s*$/im,Gd=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new An,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&q(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){let c=o!=null?o:t.response;if(c!=null){r.loading.end=Math.max(self.performance.now(),r.loading.first);let h=t.responseType==="arraybuffer"?c.byteLength:c.length;if(r.loaded=r.total=h,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let f=this.callbacks.onProgress;if(f&&f(r,e,c,t),!this.callbacks)return;let m={url:t.responseURL,data:c,code:a};this.callbacks.onSuccess(m,r,e,t);return}}let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Rd(l,d,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Rd(e,t,!0))this.retry(e);else{var r;L.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Im(e,r.retry),r.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&sk.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function nk(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var ak=/(\d+)-(\d+)\/(\d+)/,Kd=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||uk,this.controller=new self.AbortController,this.stats=new An}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=ok(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&q(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new vm(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=dk(c.headers)||s.total,a&&q(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!q(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new kd,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function ok(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(it({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function lk(i){let e=ak.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function dk(i){let e=i.get("Content-Range");if(e){let r=lk(e);if(q(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function uk(i,e){return new self.Request(i.url,e)}var vm=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},ck=/\s/,hk={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)ck.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=ry(d.trim()),m=Mm(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Cb(i,h))),s}},fk={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},fy=gt(gt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Gd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:kf,bufferController:tm,capLevelController:um,errorController:If,fpsController:cm,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:gb,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:fk},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},mk()),{},{subtitleStreamController:Qf,subtitleTrackController:Jf,timelineController:dm,audioStreamController:zf,audioTrackController:Xf,emeController:$d,cmcdController:pm,contentSteeringController:gm});function mk(){return{cueHandler:hk,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function pk(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Em(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),gt(gt({},t),e)}function Em(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Em):Object.keys(i).reduce((e,t)=>(e[t]=Em(i[t]),e),{}):i}function gk(i){let e=i.loader;e!==Kd&&e!==Gd?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):nk()&&(i.loader=Kd,i.progressive=!0,i.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ff,bm=class extends Ma{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(ff||(ff=/chrome|firefox/i.test(navigator.userAgent)),ff&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=_d(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=KR(p));let{width:g,height:E,unknownCodecs:b}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),b!=null&&b.length||m&&!Zh(m,"audio",r)||p&&!Zh(p,"video",r))return;let{CODECS:T,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":x,RESOLUTION:S,"VIDEO-RANGE":w}=f,k=`${`${x||"."}-`}${u.bitrate}-${S}-${_}-${T}-${w}-${A}`;if(n[k])if(n[k].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let P=a[k]+=1;u.attrs["PATHWAY-ID"]=new Array(P+1).join(".");let N=new br(u);n[k]=N,s.push(N)}else n[k].addGroupId("audio",f.AUDIO),n[k].addGroupId("text",f.SUBTITLES);else{let P=new br(u);n[k]=P,a[k]=1,s.push(P)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&JR(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Zh(p.audioCodec,"audio",m)),mb(a)}t.subtitles&&(o=t.subtitles,mb(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Ad.indexOf(m.videoRange)-Ad.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=kE(m.videoCodec),E=kE(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=Td(m.codecSet),E=Td(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===fy.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Te.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===te.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));Pb(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function mb(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var ym=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,s,n){return new di({type:re.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:E,url:b}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[b])return o(this.createKeyLoadError(g,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,gt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function my(){return self.SourceBuffer||self.WebKitSourceBuffer}function py(){if(!as())return!1;let e=my();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function vk(){if(!py())return!1;let i=as();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(Da(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(Da(e,"audio"))))}function Ek(){var i;let e=my();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var bk=250,gd=2,yk=.1,Tk=.05,Tm=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;L.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ve.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ve.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>gd,E=!c||t&&t.start<=a||c-a>gd&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let E=Math.max(c,u.start||0)-a,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(b==null||(h=b.details)==null?void 0:h.live)?b.details.targetduration*2:gd,A=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=_||A)){s.paused||this._trySkipBufferHole(A);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=bk&&(this._reportStall(u),!this.media))return;let p=Ve.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(n.message),t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ve.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,te.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,te.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+Tk,n+yk);if(L.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);L.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},_k=100,_m=class extends Na{constructor(e,t,r){super(e,t,r,"[stream-controller]",te.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(_k),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=O.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=O.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case O.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=O.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=O.IDLE;break}break}case O.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=O.IDLE}}break}this.state===O.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=O.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===O.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=O.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==pt.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let g=this.audioOnly&&!this.altAudio?Ce.AUDIO:Ce.VIDEO,E=(g===Ce.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,te.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,te.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===pt.NOT_LOADED||s===pt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,te.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case O.KEY_LOADING:case O.FRAG_LOADING:case O.FRAG_LOADING_WAITING_RETRY:case O.PARSING:case O.PARSED:this.state=O.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Tm(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;q(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!Ek(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==O.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=O.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===O.FRAG_LOADING||this.state===O.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===O.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=O.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Nd(this.hls,te.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new Pa(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==te.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===O.PARSED&&(this.state=O.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=O.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===O.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Te.LEVEL&&(this.state=O.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ve.getBuffered(e).length){let r=this.state!==O.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=O.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ce.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===Ce.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,te.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ve.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=O.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=O.PARSING,m){if(m!=null&&m.tracks){let T=l.initSegment||l;this._bufferInitSegment(u,m.tracks,T,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:m.tracks})}let E=m.initPTS,b=m.timescale;q(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:b},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:b}))}if(c&&p&&l.sn!=="initSegment"){let E=p.fragments[l.sn-1-p.startSN],b=l.sn===p.startSN,T=!E||l.cc>E.cc;if(n.independent!==!1){let{startPTS:_,endPTS:A,startDTS:x,endDTS:S}=c;if(d)d.elementaryStreams[c.type]={startPTS:_,endPTS:A,startDTS:x,endDTS:S};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){let w=this.getMainFwdBufferInfo(),M=(w?w.end:this.getLoadPosition())+this.config.maxBufferHole,k=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!b&&M<k-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,S,!0)}else b&&_>gd&&(l.gap=!0);l.setElementaryStreamInfo(c.type,_,A,x,S),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,b||T)}else if(b||T)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:E,endPTS:b,startDTS:T,endDTS:_}=g;d&&(d.elementaryStreams[Ce.AUDIO]={startPTS:E,endPTS:b,startDTS:T,endDTS:_}),l.setElementaryStreamInfo(Ce.AUDIO,E,b,T,_),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){let E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==O.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,te.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=O.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ve.isBuffered(e,r)?t=this.getAppendedFrag(r):Ve.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&q(t)&&q(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Ba=class i{static get version(){return"1.5.18"}static isMSESupported(){return py()}static isSupported(){return vk()}static getMediaSource(){return as()}static get Events(){return v}static get ErrorTypes(){return re}static get ErrorDetails(){return D}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:fy}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new wm,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,iR(e.debug||!1,"Hls instance");let t=this.config=pk(i.DefaultConfig,e);this.userConfig=e,t.progressive&&gk(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new bf(this),m=new _f(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new bm(this,g),b=new wf(this),T=new ym(this.config),_=this.streamController=new _m(this,b,T);c.setStreamController(_),h.setStreamController(_);let A=[f,E,_];g&&A.splice(1,0,g),this.networkControllers=A;let x=[d,u,c,h,m,b];this.audioTrackController=this.createController(t.audioTrackController,A);let S=t.audioStreamController;S&&A.push(new S(this,b,T)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let w=t.subtitleStreamController;w&&A.push(new w(this,b,T)),this.createController(t.timelineController,x),T.emeController=this.emeController=this.createController(t.emeController,x),this.cmcdController=this.createController(t.cmcdController,x),this.latencyController=this.createController(Af,x),this.coreComponents=x,A.push(l);let M=l.onErrorOut;typeof M=="function"&&this.on(v.ERROR,M,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===v.ERROR;this.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){L.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Am.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){L.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){L.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){ZR(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};Ba.defaultConfig=void 0;var ge=Ba,Oe={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},Z={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},Ha=i=>i===Oe.VIDEO?"playback":i,yr=class $a extends Error{constructor(e,t=$a.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=$a.MEDIA_ERR_NETWORK&&t<=$a.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=$a.defaultMessages[this.code])!=null?n:"")}};yr.MEDIA_ERR_ABORTED=1,yr.MEDIA_ERR_NETWORK=2,yr.MEDIA_ERR_DECODE=3,yr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,yr.MEDIA_ERR_ENCRYPTED=5,yr.MEDIA_ERR_CUSTOM=100,yr.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var K=yr,Ak=i=>i==null,Km=(i,e)=>Ak(e)?!1:i in e,Um={ANY:"any",MUTED:"muted"},Re={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},qt={MSE:"mse",NATIVE:"native"},Wd={HEADER:"header",QUERY:"query",NONE:"none"},In=Object.values(Wd),_r={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Fm={HLS:_r.M3U8},b2=Object.keys(Fm),y2=[...Object.values(_r),"hls","HLS"];var Sk="en",Bm={code:Sk},rt=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function xk(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var Xd=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},Qd=i=>{let e=i.type;if(e){let r=e.toUpperCase();return Km(r,Fm)?Fm[r]:e}let{src:t}=i;return t?Rk(t):""},xy=i=>i==="VOD"?Re.ON_DEMAND:Re.LIVE,Ry=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,Rk=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return Km(r,_r)?_r[r]:""},Ar=i=>{let e=(i!=null?i:"").split(".")[1];if(e)try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}catch{return}},Ik=({exp:i},e=Date.now())=>!i||i*1e3<e,Lk=({sub:i},e)=>i!==e,kk=({aud:i},e)=>!i,Ck=({aud:i},e)=>i!==e,Iy="en";function j(i,e=!0){var t,r;let s=e&&(r=(t=Bm)==null?void 0:t[i])!=null?r:i,n=e?Bm.code:Iy;return new wk(s,n)}var wk=class{constructor(i,e=(t=>(t=Bm)!=null?t:Iy)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}},Dk=Object.values(Um),gy=i=>typeof i=="boolean"||typeof i=="string"&&Dk.includes(i),Mk=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=gy(r)?r:!!r,o=()=>{s||rt(e,"playing",()=>{s=!0},{once:!0})};if(o(),rt(e,"loadstart",()=>{s=!1,o(),Om(e,a)},{once:!0}),rt(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==Re.UNKNOWN?n=i.streamType===Re.LIVE:n=!Number.isFinite(e.duration)),Om(e,a)},{once:!0}),t&&t.once(ge.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==Re.UNKNOWN?n=i.streamType===Re.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&rt(e,"play",()=>{e.preload==="metadata"?t.once(ge.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=gy(l)?l:!!l,Om(e,a))}},Om=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case Um.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case Um.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},Pk=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return rt(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function Ok(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(ge.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(ge.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(ge.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(ge.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(ge.Events.BUFFER_FLUSHING,h),c||e.trigger(ge.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(ge.Events.DESTROYING,l)}var Nm=i=>"time"in i?i.time:i.startTime;function Nk(i,e){e.on(ge.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o,l;let d=(o=a.subtitleTrack)!=null?o:a.closedCaptions,u=e.subtitleTracks.findIndex(({lang:h,name:f,type:m})=>h==(d==null?void 0:d.lang)&&f===a.label&&m.toLowerCase()===a.kind),c=((l=a._id)!=null?l:a.default)?"default":`${a.kind}${u}`;Zd(i,a.kind,a.label,d==null?void 0:d.lang,c,a.default)})});let t=()=>{if(!e.subtitleTracks.length)return;let s=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind));if(!s)return;let n=e.subtitleTracks[e.subtitleTrack],a=n?n.default?"default":`${e.subtitleTracks[e.subtitleTrack].type.toLowerCase()}${e.subtitleTrack}`:void 0;if(e.subtitleTrack<0||(s==null?void 0:s.id)!==a){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u,default:c})=>s.id==="default"&&c||l==s.language&&d===s.label&&u.toLowerCase()===s.kind);e.subtitleTrack=o}(s==null?void 0:s.id)===a&&s.cues&&Array.from(s.cues).forEach(o=>{s.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(ge.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(ge.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&(s.label==="thumbnails"||s.kind==="chapters")){if(!((n=s.cues)!=null&&n.length)){let o="track";s.kind&&(o+=`[kind="${s.kind}"]`),s.label&&(o+=`[label="${s.label}"]`);let l=i.querySelector(o),d=(a=l==null?void 0:l.getAttribute("src"))!=null?a:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",d)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(ge.Events.MANIFEST_LOADED,r),e.once(ge.Events.MEDIA_ATTACHED,r)}function Zd(i,e,t,r,s,n){let a=document.createElement("track");return a.kind=e,a.label=t,r&&(a.srclang=r),s&&(a.id=s),n&&(a.default=!0),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),i.append(a),a.track}function Ly(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function Ga(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function ky(i,e,t,r){let s=Ga(i,t,r);return s||(s=Zd(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>Nm(a)-Nm(n)).forEach(n=>{var a,o;let l=n.value,d=Nm(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var Vm="cuepoints",Cy=Object.freeze({label:Vm});async function Wm(i,e,t=Cy){return ky(i,e,t.label,"metadata")}var $m=i=>({time:i.startTime,value:JSON.parse(i.text)});function wy(i,e={label:Vm}){let t=Ga(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>$m(r)):[]}function Ym(i,e={label:Vm}){var t,r;let s=Ga(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return $m(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return $m(a||s.activeCues[0])}async function Uk(i,e=Cy){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await Wm(i,[],e);rt(i,"cuechange",()=>{let s=Ym(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var qm="chapters",Dy=Object.freeze({label:qm}),Hm=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function jm(i,e,t=Dy){return ky(i,e,t.label,"chapters")}function My(i,e={label:qm}){var t;let r=Ga(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>Hm(s)):[]}function zm(i,e={label:qm}){var t,r;let s=Ga(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return Hm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return Hm(a||s.activeCues[0])}async function Fk(i,e=Dy){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await jm(i,[],e);rt(i,"cuechange",()=>{let s=zm(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function Py(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function Oy(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var Rn={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},Bk=i=>{if(i===Oe.VIDEO)return Rn.VIDEO;if(i===Oe.DRM)return Rn.DRM},$k=(i,e)=>{var t,r;let s=Ha(i),n=`${s}Token`;return(t=e.tokens)!=null&&t[s]?(r=e.tokens)==null?void 0:r[s]:Km(n,e)?e[n]:void 0},jd=(i,e,t,r=!1,s=!(n=>(n=globalThis.navigator)==null?void 0:n.onLine)())=>{var n,a;if(s){let g=j("Your device appears to be offline",r),E,b=K.MEDIA_ERR_NETWORK,T=new K(g,b,!0,E);return T.errorCategory=e,T.muxCode=Z.NETWORK_OFFLINE,T.data=i,T}let o="status"in i?i.status:i.code,l=Date.now(),d=K.MEDIA_ERR_NETWORK;if(o===200)return;let u=Ha(e),c=$k(e,t),h=Bk(e),[f]=Xd((n=t.playbackId)!=null?n:"");if(!o||!f)return;let m=Ar(c);if(c&&!m){let g=j("The {tokenNamePrefix}-token provided is invalid or malformed.",r).format({tokenNamePrefix:u}),E=j("Compact JWT string: {token}",r).format({token:c}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_MALFORMED,b.data=i,b}if(o>=500){let g=new K("",d,!0);return g.errorCategory=e,g.muxCode=Z.NETWORK_UNKNOWN_ERROR,g}if(o===403)if(m){if(Ik(m,l)){let g={timeStyle:"medium",dateStyle:"medium"},E=j("The video\u2019s secured {tokenNamePrefix}-token has expired.",r).format({tokenNamePrefix:u}),b=j("Expired at: {expiredDate}. Current time: {currentDate}.",r).format({expiredDate:new Intl.DateTimeFormat("en",g).format((a=m.exp)!=null?a:0*1e3),currentDate:new Intl.DateTimeFormat("en",g).format(l)}),T=new K(E,d,!0,b);return T.errorCategory=e,T.muxCode=Z.NETWORK_TOKEN_EXPIRED,T.data=i,T}if(Lk(m,f)){let g=j("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",r).format({tokenNamePrefix:u}),E=j("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",r).format({tokenNamePrefix:u,playbackId:f,tokenPlaybackId:m.sub}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_SUB_MISMATCH,b.data=i,b}if(kk(m,h)){let g=j("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:u}),E=j("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",r).format({tokenNamePrefix:u,expectedAud:h}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_AUD_MISSING,b.data=i,b}if(Ck(m,h)){let g=j("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:u}),E=j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",r).format({tokenNamePrefix:u,expectedAud:h,aud:m.aud}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_AUD_MISMATCH,b.data=i,b}}else{let g=j("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",r).format({tokenNamePrefix:u,category:e}),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_MISSING,b.data=i,b}if(o===412){let g=j("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",r),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_NOT_READY,b.data=i,b}if(o===404){let g=j("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",r),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_NOT_FOUND,b.data=i,b}if(o===400){let g=j("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_INVALID_URL,b.data=i,b}let p=new K("",d,!0);return p.errorCategory=e,p.muxCode=Z.NETWORK_UNKNOWN_ERROR,p.data=i,p},vy=ge.DefaultConfig.capLevelController,Ny=class Uy extends vy{constructor(e){super(e)}get levels(){var e;return(e=this.hls.levels)!=null?e:[]}getValidLevels(e){return this.levels.filter((t,r)=>this.isLevelAllowed(t)&&r<=e)}getMaxLevel(e){let t=super.getMaxLevel(e),r=this.getValidLevels(e);if(!r[t])return t;let s=Math.min(r[t].width,r[t].height),n=Uy.minMaxResolution;return s>=n?t:vy.getMaxLevelByMediaSize(r,n*(16/9),n)}};Ny.minMaxResolution=720;var Hk=Ny,Gk=Hk,Yd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},Kk=i=>{if(i.includes("fps"))return Yd.FAIRPLAY;if(i.includes("playready"))return Yd.PLAYREADY;if(i.includes("widevine"))return Yd.WIDEVINE},Vk=async i=>fetch(i).then(e=>e.status!==200?Promise.reject(e):e.text()).then(e=>{let t=e.split(`
1260
+ `),d=[],u=e?zI(e.baseTime,e.timescale):0,c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){let E=t[r],b=t.ccOffset,T=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?b=t.ccOffset=E.start:pL(t,r,T)),T){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}b=T-t.presentationOffset}let _=g.endTime-g.startTime,A=Wt((g.startTime+b-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(A,0),g.endTime=Math.max(A+_,0);let x=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(x)),g.id||(g.id=Nm(g.startTime,g.endTime,x)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(uf(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{uf(E,"LOCAL:")?c=E.slice(6):uf(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=mL(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
1261
+ `)}),o.flush()}var hf="stpp.ttml.im1t",ny=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ay=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,vL={left:"start",center:"center",right:"end",start:"start",end:"end"};function nb(i,e,t,r){let s=ae(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>wi(o)),a=jI(e.baseTime,1,e.timescale);try{n.forEach(o=>t(EL(o,a)))}catch(o){r(o)}}function EL(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=ab(ff(s,"styling","style")),d=ab(ff(s,"layout","region")),u=ff(s,"body","[begin]");return[].map.call(u,c=>{let h=oy(c,o);if(!h||!c.hasAttribute("begin"))return null;let f=pf(c.getAttribute("begin"),a),m=pf(c.getAttribute("dur"),a),p=pf(c.getAttribute("end"),a);if(f===null)throw ob(c);if(p===null){if(m===null)throw ob(c);p=f+m}let g=new Om(f-e,p-e,h);g.id=Nm(g.startTime,g.endTime,g.text);let E=d[c.getAttribute("region")],b=l[c.getAttribute("style")],T=bL(E,b,l),{textAlign:_}=T;if(_){let A=vL[_];A&&(g.lineAlign=A),g.align=_}return it(g,T),g}).filter(c=>c!==null)}function ff(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function ab(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function oy(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1262
+ `:(n=r.childNodes)!=null&&n.length?oy(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function bL(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=mf(e,r,l)||mf(i,r,l)||mf(s,r,l);return d&&(o[l]=d),o},{})}function mf(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function ob(i){return new Error(`Could not parse ttml timestamp ${i}`)}function pf(i,e){if(!i)return null;let t=iy(i);return t===null&&(ny.test(i)?t=yL(i,e):ay.test(i)&&(t=TL(i,e))),t}function yL(i,e){let t=ny.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function TL(i,e){let t=ay.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var hm=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=db(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new yn(this,"textTrack1"),t=new yn(this,"textTrack2"),r=new yn(this,"textTrack3"),s=new yn(this,"textTrack4");this.cea608Parser1=new $d(1,e,t),this.cea608Parser2=new $d(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=_L(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(lb(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,bn(r[e]),Cb(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{bn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=db(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)bn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===hf);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(ey(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?cd(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&lb(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)bn(u);else{let c=ly(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===te.MAIN){var r,s;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===te.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===hf?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;nb(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{L.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Yt(r.initSegment.data,new Uint8Array(s)):s;gL(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),L.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||nb(t,this.initPTS[e.cc],()=>{r.textCodec=hf,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>wb(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===te.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===te.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Af(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Af(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function ly(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function lb(i,e){return!!i&&i.kind===ly(e)&&Qf(e,i)}function _L(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function db(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var fm=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&q(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},mm=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},dd="[eme]",Hd=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.debug=L.debug.bind(L,dd),this.log=L.log.bind(L,dd),this.warn=L.warn.bind(L,dd),this.error=L.error.bind(L,dd),this.onMediaEncrypted=t=>{let{initDataType:r,initData:s}=t,n=`"${t.type}" event: init data type: "${r}"`;if(this.debug(n),s!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=ed(this.config));let o=a.map(Qh).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o=zh(a),l,d;if(r==="sinf"){if(o!==Ie.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=nt(new Uint8Array(s));try{let p=Im(JSON.parse(m).sinf),g=xb(p);if(!g)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=g.subarray(8,24),d=Ie.FAIRPLAY}catch(p){this.warn(`${n} Failed to parse sinf: ${p}`);return}}else{if(o!==Ie.WIDEVINE&&o!==Ie.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=NR(s),p=m.filter(E=>!!E.systemId&&Xh(E.systemId)===o);p.length>1&&this.warn(`${n} Using first of ${p.length} pssh found for selected key-system ${o}`);let g=p[0];if(!g){m.length===0||m.some(E=>!E.systemId)?this.warn(`${n} contains incomplete or invalid pssh data`):this.log(`ignoring ${n} for ${m.map(E=>Xh(E.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(d=Xh(g.systemId),g.version===0&&g.data)if(d===Ie.WIDEVINE){let E=g.data.length-22;l=g.data.subarray(E,E+16)}else d===Ie.PLAYREADY&&(l=vb(g.data))}if(!d||!l){this.log(`Unable to handle ${n} with key-system ${o}`);return}let u=Li.hexDump(l),{keyIdToKeySessionPromise:c,mediaKeySessions:h}=this,f=c[u];for(let m=0;m<h.length;m++){let p=h[m],g=p.decryptdata;if(!g.keyId)continue;let E=Li.hexDump(g.keyId);if(u===E||g.uri.replace(/-/g,"").indexOf(u)!==-1){if(f=c[E],g.pssh)break;delete c[E],g.pssh=new Uint8Array(s),g.keyId=l,f=c[u]=f.then(()=>this.generateRequestWithPreferredKeySession(p,r,s,"encrypted-event-key-match")),f.catch(b=>this.handleError(b));break}}if(!f){if(d!==o){this.log(`Ignoring "${n}" with ${d} init data for selected key-system ${o}`);return}f=c[u]=this.getKeySystemSelectionPromise([d]).then(({keySystem:m,mediaKeys:p})=>{var g;this.throwIfDestroyed();let E=new Ca("ISO-23001-7",u,(g=Qh(m))!=null?g:"");return E.pssh=new Uint8Array(s),E.keyId=l,this.attemptSetMediaKeys(m,p).then(()=>{this.throwIfDestroyed();let b=this.createMediaKeySessionContext({decryptdata:E,keySystem:m,mediaKeys:p});return this.generateRequestWithPreferredKeySession(b,r,s,"encrypted-event-no-match")})}),f.catch(m=>this.handleError(m))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Ie.WIDEVINE&&r)return r}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Ot?o(c):o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return gb===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=cR(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Li.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Li.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Li.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1263
+ } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=ed(this.config),n=e.map(zh).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Qh(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ot?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=zh(e.keyFormat),n=s?[s]:ed(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ed(this.config)),e.length===0)throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new Pm,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(b=>{this.handleError(b),u.emit("error",b)}):g==="license-release"?e.keySystem===Ie.FAIRPLAY&&(this.updateKeySession(e,yf("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Li.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Li.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:gt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return yf(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Ot({type:re.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==Ie.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Ca.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};Hd.CDMCleanupPromise=void 0;var Ot=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},_t;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(_t||(_t={}));var pm;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(pm||(pm={}));var ss;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(ss||(ss={}));var AL={[ss.OBJECT]:["br","d","ot","tb"],[ss.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[ss.SESSION]:["cid","pr","sf","sid","st","v"],[ss.STATUS]:["bs","rtp"]},Ua=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},Gd=class{constructor(e){this.description=void 0,this.description=e}},SL="Dict";function xL(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function RL(i,e,t,r){return new Error(`failed to ${i} "${xL(e)}" as ${t}`,{cause:r})}var ub="Bare Item",IL="Boolean",LL="Byte Sequence",kL="Decimal",CL="Integer";function wL(i){return i<-999999999999999||999999999999999<i}var DL=/[\x00-\x1f\x7f]+/,ML="Token",PL="Key";function Di(i,e,t){return RL("serialize",i,e,t)}function OL(i){if(typeof i!="boolean")throw Di(i,IL);return i?"?1":"?0"}function NL(i){return btoa(String.fromCharCode(...i))}function UL(i){if(ArrayBuffer.isView(i)===!1)throw Di(i,LL);return`:${NL(i)}:`}function dy(i){if(wL(i))throw Di(i,CL);return i.toString()}function FL(i){return`@${dy(i.getTime()/1e3)}`}function uy(i,e){if(i<0)return-uy(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function BL(i){let e=uy(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Di(i,kL);let t=e.toString();return t.includes(".")?t:`${t}.0`}var $L="String";function HL(i){if(DL.test(i))throw Di(i,$L);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function GL(i){return i.description||i.toString().slice(7,-1)}function cb(i){let e=GL(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Di(e,ML);return e}function gm(i){switch(typeof i){case"number":if(!q(i))throw Di(i,ub);return Number.isInteger(i)?dy(i):BL(i);case"string":return HL(i);case"symbol":return cb(i);case"boolean":return OL(i);case"object":if(i instanceof Date)return FL(i);if(i instanceof Uint8Array)return UL(i);if(i instanceof Gd)return cb(i);default:throw Di(i,ub)}}function vm(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Di(i,PL);return i}function Um(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${vm(e)}`:`;${vm(e)}=${gm(t)}`).join("")}function cy(i){return i instanceof Ua?`${gm(i.value)}${Um(i.params)}`:gm(i)}function KL(i){return`(${i.value.map(cy).join(" ")})${Um(i.params)}`}function VL(i,e={whitespace:!0}){if(typeof i!="object")throw Di(i,SL);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Ua||(n=new Ua(n));let a=vm(s);return n.value===!0?a+=Um(n.params):(a+="=",Array.isArray(n.value)?a+=KL(n):a+=cy(n)),a}).join(`,${r}`)}function WL(i,e){return VL(i,e)}var YL=i=>i==="ot"||i==="sf"||i==="st",qL=i=>typeof i=="number"?q(i):i!=null&&i!==""&&i!==!1;function jL(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function zL(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var gd=i=>Math.round(i),XL=(i,e)=>(e!=null&&e.baseUrl&&(i=jL(i,e.baseUrl)),encodeURIComponent(i)),ud=i=>gd(i/100)*100,QL={br:gd,d:gd,bl:ud,dl:ud,mtp:ud,nor:XL,rtp:ud,tb:gd};function ZL(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=it({},QL,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||qL(o)&&(YL(a)&&typeof o=="string"&&(o=new Gd(o)),t[a]=o))}),t}function hy(i,e={}){return i?WL(ZL(i,e),it({whitespace:!1},e)):""}function JL(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(AL).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||ss.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=hy(o,e),n),{})}function ek(i,e,t){return it(i,JL(e,t))}var tk="CMCD";function ik(i,e={}){if(!i)return"";let t=hy(i,e);return`${tk}=${encodeURIComponent(t)}`}var hb=/CMCD=[^&#]+/;function rk(i,e,t){let r=ik(e,t);if(!r)return i;if(hb.test(i))return i.replace(hb,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var Em=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:_t.MANIFEST,su:!this.initialized})}catch(n){L.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===_t.VIDEO||o===_t.AUDIO||o==_t.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){L.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||zL(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:pm.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){it(t,this.createData());let r=t.ot===_t.INIT||t.ot===_t.VIDEO||t.ot===_t.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),ek(e.headers,t)):e.url=rk(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return _t.TIMED_TEXT;if(e.sn==="initSegment")return _t.INIT;if(t==="audio")return _t.AUDIO;if(t==="main")return this.hls.audioTracks.length?_t.VIDEO:_t.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===_t.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===_t.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ve.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},sk=3e5,bm=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===mt.SendAlternateToPenaltyBox&&r.flags===oi.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>sk&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Ob(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===Te.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===Te.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new je(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=fy(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new br({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),fb(this.audioTracks,r,l,a),fb(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let b={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,b),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function fb(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=it({},a);return o.details=void 0,o.attrs=new je(o.attrs),o.url=o.attrs.URI=fy(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function fy(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var nk=/^age:\s*[\d.]+\s*$/im,Kd=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new An,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&q(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){let c=o!=null?o:t.response;if(c!=null){r.loading.end=Math.max(self.performance.now(),r.loading.first);let h=t.responseType==="arraybuffer"?c.byteLength:c.length;if(r.loaded=r.total=h,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let f=this.callbacks.onProgress;if(f&&f(r,e,c,t),!this.callbacks)return;let m={url:t.responseURL,data:c,code:a};this.callbacks.onSuccess(m,r,e,t);return}}let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Id(l,d,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Id(e,t,!0))this.retry(e);else{var r;L.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Cm(e,r.retry),r.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&nk.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function ak(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var ok=/(\d+)-(\d+)\/(\d+)/,Vd=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||ck,this.controller=new self.AbortController,this.stats=new An}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=lk(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&q(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new ym(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=uk(c.headers)||s.total,a&&q(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!q(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new Cd,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function lk(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(it({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function dk(i){let e=ok.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function uk(i){let e=i.get("Content-Range");if(e){let r=dk(e);if(q(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function ck(i,e){return new self.Request(i.url,e)}var ym=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},hk=/\s/,fk={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)hk.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=sy(d.trim()),m=Nm(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>wb(i,h))),s}},mk={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},my=gt(gt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Kd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Df,bufferController:sm,capLevelController:fm,errorController:Cf,fpsController:mm,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:gb,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:mk},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},pk()),{},{subtitleStreamController:em,subtitleTrackController:im,timelineController:hm,audioStreamController:Zf,audioTrackController:Jf,emeController:Hd,cmcdController:Em,contentSteeringController:bm});function pk(){return{cueHandler:fk,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function gk(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Tm(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),gt(gt({},t),e)}function Tm(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Tm):Object.keys(i).reduce((e,t)=>(e[t]=Tm(i[t]),e),{}):i}function vk(i){let e=i.loader;e!==Vd&&e!==Kd?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):ak()&&(i.loader=Vd,i.progressive=!0,i.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var gf,_m=class extends Da{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(gf||(gf=/chrome|firefox/i.test(navigator.userAgent)),gf&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Ad(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=VR(p));let{width:g,height:E,unknownCodecs:b}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),b!=null&&b.length||m&&!tf(m,"audio",r)||p&&!tf(p,"video",r))return;let{CODECS:T,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":x,RESOLUTION:S,"VIDEO-RANGE":w}=f,k=`${`${x||"."}-`}${u.bitrate}-${S}-${_}-${T}-${w}-${A}`;if(n[k])if(n[k].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let P=a[k]+=1;u.attrs["PATHWAY-ID"]=new Array(P+1).join(".");let N=new br(u);n[k]=N,s.push(N)}else n[k].addGroupId("audio",f.AUDIO),n[k].addGroupId("text",f.SUBTITLES);else{let P=new br(u);n[k]=P,a[k]=1,s.push(P)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&eI(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||tf(p.audioCodec,"audio",m)),mb(a)}t.subtitles&&(o=t.subtitles,mb(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Sd.indexOf(m.videoRange)-Sd.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=kE(m.videoCodec),E=kE(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=_d(m.codecSet),E=_d(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===my.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Te.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===te.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));Ob(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function mb(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Am=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,s,n){return new di({type:re.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:E,url:b}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[b])return o(this.createKeyLoadError(g,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,gt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function py(){return self.SourceBuffer||self.WebKitSourceBuffer}function gy(){if(!as())return!1;let e=py();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Ek(){if(!gy())return!1;let i=as();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(wa(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(wa(e,"audio"))))}function bk(){var i;let e=py();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var yk=250,vd=2,Tk=.1,_k=.05,Sm=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;L.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ve.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ve.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>vd,E=!c||t&&t.start<=a||c-a>vd&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let E=Math.max(c,u.start||0)-a,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(b==null||(h=b.details)==null?void 0:h.live)?b.details.targetduration*2:vd,A=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=_||A)){s.paused||this._trySkipBufferHole(A);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=yk&&(this._reportStall(u),!this.media))return;let p=Ve.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(n.message),t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ve.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,te.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,te.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+_k,n+Tk);if(L.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);L.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(v.ERROR,{type:re.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},Ak=100,xm=class extends Oa{constructor(e,t,r){super(e,t,r,"[stream-controller]",te.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(Ak),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=O.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=O.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case O.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=O.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=O.IDLE;break}break}case O.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=O.IDLE}}break}this.state===O.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=O.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===O.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=O.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==pt.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let g=this.audioOnly&&!this.altAudio?we.AUDIO:we.VIDEO,E=(g===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,te.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,te.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===pt.NOT_LOADED||s===pt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,te.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case O.KEY_LOADING:case O.FRAG_LOADING:case O.FRAG_LOADING_WAITING_RETRY:case O.PARSING:case O.PARSED:this.state=O.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Sm(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;q(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!bk(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==O.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=O.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===O.FRAG_LOADING||this.state===O.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===O.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=O.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Ud(this.hls,te.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new Ma(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==te.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===O.PARSED&&(this.state=O.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=O.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===O.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Te.LEVEL&&(this.state=O.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ve.getBuffered(e).length){let r=this.state!==O.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=O.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==we.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,te.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ve.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=O.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=O.PARSING,m){if(m!=null&&m.tracks){let T=l.initSegment||l;this._bufferInitSegment(u,m.tracks,T,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:m.tracks})}let E=m.initPTS,b=m.timescale;q(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:b},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:b}))}if(c&&p&&l.sn!=="initSegment"){let E=p.fragments[l.sn-1-p.startSN],b=l.sn===p.startSN,T=!E||l.cc>E.cc;if(n.independent!==!1){let{startPTS:_,endPTS:A,startDTS:x,endDTS:S}=c;if(d)d.elementaryStreams[c.type]={startPTS:_,endPTS:A,startDTS:x,endDTS:S};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){let w=this.getMainFwdBufferInfo(),M=(w?w.end:this.getLoadPosition())+this.config.maxBufferHole,k=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!b&&M<k-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,S,!0)}else b&&_>vd&&(l.gap=!0);l.setElementaryStreamInfo(c.type,_,A,x,S),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,b||T)}else if(b||T)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:E,endPTS:b,startDTS:T,endDTS:_}=g;d&&(d.elementaryStreams[we.AUDIO]={startPTS:E,endPTS:b,startDTS:T,endDTS:_}),l.setElementaryStreamInfo(we.AUDIO,E,b,T,_),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){let E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==O.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,te.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=O.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ve.isBuffered(e,r)?t=this.getAppendedFrag(r):Ve.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&q(t)&&q(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Fa=class i{static get version(){return"1.5.19"}static isMSESupported(){return gy()}static isSupported(){return Ek()}static getMediaSource(){return as()}static get Events(){return v}static get ErrorTypes(){return re}static get ErrorDetails(){return D}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:my}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Pm,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,rR(e.debug||!1,"Hls instance");let t=this.config=gk(i.DefaultConfig,e);this.userConfig=e,t.progressive&&vk(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new _f(this),m=new xf(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new _m(this,g),b=new Pf(this),T=new Am(this.config),_=this.streamController=new xm(this,b,T);c.setStreamController(_),h.setStreamController(_);let A=[f,E,_];g&&A.splice(1,0,g),this.networkControllers=A;let x=[d,u,c,h,m,b];this.audioTrackController=this.createController(t.audioTrackController,A);let S=t.audioStreamController;S&&A.push(new S(this,b,T)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let w=t.subtitleStreamController;w&&A.push(new w(this,b,T)),this.createController(t.timelineController,x),T.emeController=this.emeController=this.createController(t.emeController,x),this.cmcdController=this.createController(t.cmcdController,x),this.latencyController=this.createController(Rf,x),this.coreComponents=x,A.push(l);let M=l.onErrorOut;typeof M=="function"&&this.on(v.ERROR,M,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===v.ERROR;this.trigger(v.ERROR,{type:re.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){L.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Rm.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){L.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){L.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){JR(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};Fa.defaultConfig=void 0;var ge=Fa,Ne={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},Z={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},$a=i=>i===Ne.VIDEO?"playback":i,yr=class Ba extends Error{constructor(e,t=Ba.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Ba.MEDIA_ERR_NETWORK&&t<=Ba.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Ba.defaultMessages[this.code])!=null?n:"")}};yr.MEDIA_ERR_ABORTED=1,yr.MEDIA_ERR_NETWORK=2,yr.MEDIA_ERR_DECODE=3,yr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,yr.MEDIA_ERR_ENCRYPTED=5,yr.MEDIA_ERR_CUSTOM=100,yr.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var K=yr,Sk=i=>i==null,Ym=(i,e)=>Sk(e)?!1:i in e,$m={ANY:"any",MUTED:"muted"},Re={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},qt={MSE:"mse",NATIVE:"native"},Yd={HEADER:"header",QUERY:"query",NONE:"none"},In=Object.values(Yd),_r={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Hm={HLS:_r.M3U8},y2=Object.keys(Hm),T2=[...Object.values(_r),"hls","HLS"];var xk="en",Gm={code:xk},rt=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function Rk(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var Qd=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},Zd=i=>{let e=i.type;if(e){let r=e.toUpperCase();return Ym(r,Hm)?Hm[r]:e}let{src:t}=i;return t?Ik(t):""},Ry=i=>i==="VOD"?Re.ON_DEMAND:Re.LIVE,Iy=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,Ik=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return Ym(r,_r)?_r[r]:""},Ar=i=>{let e=(i!=null?i:"").split(".")[1];if(e)try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}catch{return}},Lk=({exp:i},e=Date.now())=>!i||i*1e3<e,kk=({sub:i},e)=>i!==e,Ck=({aud:i},e)=>!i,wk=({aud:i},e)=>i!==e,Ly="en";function j(i,e=!0){var t,r;let s=e&&(r=(t=Gm)==null?void 0:t[i])!=null?r:i,n=e?Gm.code:Ly;return new Dk(s,n)}var Dk=class{constructor(i,e=(t=>(t=Gm)!=null?t:Ly)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}},Mk=Object.values($m),vy=i=>typeof i=="boolean"||typeof i=="string"&&Mk.includes(i),Pk=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=vy(r)?r:!!r,o=()=>{s||rt(e,"playing",()=>{s=!0},{once:!0})};if(o(),rt(e,"loadstart",()=>{s=!1,o(),Fm(e,a)},{once:!0}),rt(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==Re.UNKNOWN?n=i.streamType===Re.LIVE:n=!Number.isFinite(e.duration)),Fm(e,a)},{once:!0}),t&&t.once(ge.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==Re.UNKNOWN?n=i.streamType===Re.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&rt(e,"play",()=>{e.preload==="metadata"?t.once(ge.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=vy(l)?l:!!l,Fm(e,a))}},Fm=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case $m.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case $m.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},Ok=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return rt(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function Nk(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(ge.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(ge.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(ge.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(ge.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(ge.Events.BUFFER_FLUSHING,h),c||e.trigger(ge.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(ge.Events.DESTROYING,l)}var Bm=i=>"time"in i?i.time:i.startTime;function Uk(i,e){e.on(ge.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o,l;let d=(o=a.subtitleTrack)!=null?o:a.closedCaptions,u=e.subtitleTracks.findIndex(({lang:h,name:f,type:m})=>h==(d==null?void 0:d.lang)&&f===a.label&&m.toLowerCase()===a.kind),c=((l=a._id)!=null?l:a.default)?"default":`${a.kind}${u}`;Jd(i,a.kind,a.label,d==null?void 0:d.lang,c,a.default)})});let t=()=>{if(!e.subtitleTracks.length)return;let s=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind));if(!s)return;let n=e.subtitleTracks[e.subtitleTrack],a=n?n.default?"default":`${e.subtitleTracks[e.subtitleTrack].type.toLowerCase()}${e.subtitleTrack}`:void 0;if(e.subtitleTrack<0||(s==null?void 0:s.id)!==a){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u,default:c})=>s.id==="default"&&c||l==s.language&&d===s.label&&u.toLowerCase()===s.kind);e.subtitleTrack=o}(s==null?void 0:s.id)===a&&s.cues&&Array.from(s.cues).forEach(o=>{s.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(ge.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(ge.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&(s.label==="thumbnails"||s.kind==="chapters")){if(!((n=s.cues)!=null&&n.length)){let o="track";s.kind&&(o+=`[kind="${s.kind}"]`),s.label&&(o+=`[label="${s.label}"]`);let l=i.querySelector(o),d=(a=l==null?void 0:l.getAttribute("src"))!=null?a:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",d)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(ge.Events.MANIFEST_LOADED,r),e.once(ge.Events.MEDIA_ATTACHED,r)}function Jd(i,e,t,r,s,n){let a=document.createElement("track");return a.kind=e,a.label=t,r&&(a.srclang=r),s&&(a.id=s),n&&(a.default=!0),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),i.append(a),a.track}function ky(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function Ha(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function Cy(i,e,t,r){let s=Ha(i,t,r);return s||(s=Jd(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>Bm(a)-Bm(n)).forEach(n=>{var a,o;let l=n.value,d=Bm(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var qm="cuepoints",wy=Object.freeze({label:qm});async function jm(i,e,t=wy){return Cy(i,e,t.label,"metadata")}var Km=i=>({time:i.startTime,value:JSON.parse(i.text)});function Dy(i,e={label:qm}){let t=Ha(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>Km(r)):[]}function zm(i,e={label:qm}){var t,r;let s=Ha(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return Km(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return Km(a||s.activeCues[0])}async function Fk(i,e=wy){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await jm(i,[],e);rt(i,"cuechange",()=>{let s=zm(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var Xm="chapters",My=Object.freeze({label:Xm}),Vm=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function Qm(i,e,t=My){return Cy(i,e,t.label,"chapters")}function Py(i,e={label:Xm}){var t;let r=Ha(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>Vm(s)):[]}function Zm(i,e={label:Xm}){var t,r;let s=Ha(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return Vm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return Vm(a||s.activeCues[0])}async function Bk(i,e=My){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await Qm(i,[],e);rt(i,"cuechange",()=>{let s=Zm(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function Oy(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function Ny(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var Rn={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},$k=i=>{if(i===Ne.VIDEO)return Rn.VIDEO;if(i===Ne.DRM)return Rn.DRM},Hk=(i,e)=>{var t,r;let s=$a(i),n=`${s}Token`;return(t=e.tokens)!=null&&t[s]?(r=e.tokens)==null?void 0:r[s]:Ym(n,e)?e[n]:void 0},zd=(i,e,t,r=!1,s=!(n=>(n=globalThis.navigator)==null?void 0:n.onLine)())=>{var n,a;if(s){let g=j("Your device appears to be offline",r),E,b=K.MEDIA_ERR_NETWORK,T=new K(g,b,!0,E);return T.errorCategory=e,T.muxCode=Z.NETWORK_OFFLINE,T.data=i,T}let o="status"in i?i.status:i.code,l=Date.now(),d=K.MEDIA_ERR_NETWORK;if(o===200)return;let u=$a(e),c=Hk(e,t),h=$k(e),[f]=Qd((n=t.playbackId)!=null?n:"");if(!o||!f)return;let m=Ar(c);if(c&&!m){let g=j("The {tokenNamePrefix}-token provided is invalid or malformed.",r).format({tokenNamePrefix:u}),E=j("Compact JWT string: {token}",r).format({token:c}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_MALFORMED,b.data=i,b}if(o>=500){let g=new K("",d,!0);return g.errorCategory=e,g.muxCode=Z.NETWORK_UNKNOWN_ERROR,g}if(o===403)if(m){if(Lk(m,l)){let g={timeStyle:"medium",dateStyle:"medium"},E=j("The video\u2019s secured {tokenNamePrefix}-token has expired.",r).format({tokenNamePrefix:u}),b=j("Expired at: {expiredDate}. Current time: {currentDate}.",r).format({expiredDate:new Intl.DateTimeFormat("en",g).format((a=m.exp)!=null?a:0*1e3),currentDate:new Intl.DateTimeFormat("en",g).format(l)}),T=new K(E,d,!0,b);return T.errorCategory=e,T.muxCode=Z.NETWORK_TOKEN_EXPIRED,T.data=i,T}if(kk(m,f)){let g=j("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",r).format({tokenNamePrefix:u}),E=j("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",r).format({tokenNamePrefix:u,playbackId:f,tokenPlaybackId:m.sub}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_SUB_MISMATCH,b.data=i,b}if(Ck(m,h)){let g=j("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:u}),E=j("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",r).format({tokenNamePrefix:u,expectedAud:h}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_AUD_MISSING,b.data=i,b}if(wk(m,h)){let g=j("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:u}),E=j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",r).format({tokenNamePrefix:u,expectedAud:h,aud:m.aud}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_AUD_MISMATCH,b.data=i,b}}else{let g=j("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",r).format({tokenNamePrefix:u,category:e}),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_TOKEN_MISSING,b.data=i,b}if(o===412){let g=j("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",r),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_NOT_READY,b.data=i,b}if(o===404){let g=j("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",r),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_NOT_FOUND,b.data=i,b}if(o===400){let g=j("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),E=j("Specified playback ID: {playbackId}",r).format({playbackId:f}),b=new K(g,d,!0,E);return b.errorCategory=e,b.muxCode=Z.NETWORK_INVALID_URL,b.data=i,b}let p=new K("",d,!0);return p.errorCategory=e,p.muxCode=Z.NETWORK_UNKNOWN_ERROR,p.data=i,p},Ey=ge.DefaultConfig.capLevelController,Uy=class Fy extends Ey{constructor(e){super(e)}get levels(){var e;return(e=this.hls.levels)!=null?e:[]}getValidLevels(e){return this.levels.filter((t,r)=>this.isLevelAllowed(t)&&r<=e)}getMaxLevel(e){let t=super.getMaxLevel(e),r=this.getValidLevels(e);if(!r[t])return t;let s=Math.min(r[t].width,r[t].height),n=Fy.minMaxResolution;return s>=n?t:Ey.getMaxLevelByMediaSize(r,n*(16/9),n)}};Uy.minMaxResolution=720;var Gk=Uy,Kk=Gk,qd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},Vk=i=>{if(i.includes("fps"))return qd.FAIRPLAY;if(i.includes("playready"))return qd.PLAYREADY;if(i.includes("widevine"))return qd.WIDEVINE},Wk=async i=>fetch(i).then(e=>e.status!==200?Promise.reject(e):e.text()).then(e=>{let t=e.split(`
1264
1264
  `).find((r,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(r=>r.status!==200?Promise.reject(r):r.text()).then(r=>r.split(`
1265
- `))}),Wk=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=xy(s),a=Ry(s),o;if(n===Re.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u!=null?u:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},Yk=async(i,e)=>{if(e===_r.MP4)return{streamType:Re.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===_r.M3U8){let t=await Vk(i);return Wk(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},qk=async(i,e,t=Qd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await Yk(i,t);((r=vt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=vt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=vt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},jk=i=>{var e;let t=i.type,r=xy(t),s=Ry(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Re.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},zk=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=jk(i);if(c===Re.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=vt.get(e))!=null?o:{}).seekable=p}((l=vt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=vt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=vt.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Ey,by,Xk=(by=(Ey=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ey.userAgent)!=null?by:"",yy,Ty,_y,Qk=(_y=(Ty=(yy=globalThis==null?void 0:globalThis.navigator)==null?void 0:yy.userAgentData)==null?void 0:Ty.platform)!=null?_y:"",Zk=Xk.toLowerCase().includes("android")||["x11","android"].some(i=>Qk.toLowerCase().includes(i)),vt=new WeakMap,Tr="mux.com",Ay,Sy,Fy=(Sy=(Ay=ge).isSupported)==null?void 0:Sy.call(Ay),Jk=Zk,Jd=()=>Jl.utils.now(),eC=Jl.utils.generateUUID,Ka=({playbackId:i,customDomain:e=Tr,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=Xd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},eu=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},Xm=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},tC=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:Yy(i)&&(r=(t=eu(i.playbackId))!=null?t:Xm(i.src))!=null?r:i.src},Qm=i=>{var e;return(e=vt.get(i))==null?void 0:e.error},zd=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.streamType)!=null?t:Re.UNKNOWN},By=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},tu=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},$y=i=>{var e;let t=(e=vt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=tu(i);return r.length?r.end(r.length-1)-t:Number.NaN},Zm=.034,iC=(i,e,t=Zm)=>Math.abs(i-e)<=t,Hy=(i,e,t=Zm)=>i>e||iC(i,e,t),rC=(i,e=Zm)=>i.paused&&Hy(i.currentTime,i.duration,e),Gy=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Jm=(i,e)=>i.ended||i.loop?i.ended:e&&Gy(i,e)?!0:rC(i),Ky=(i,e,t)=>{ep(e,t);let{metadata:r={}}=i,{view_session_id:s=eC()}=r,n=tC(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,vt.set(e,{});let o=sC(i,e),l=Pk(i,e,o);uC(i,e,o),cC(i,e,o),Uk(e),Fk(e);let d=Mk(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},ep=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",jy),i.removeEventListener("error",Gm),i.removeEventListener("durationchange",qy),vt.delete(i),i.dispatchEvent(new Event("teardown")))};function Vy(i,e){var t;let r=Qd(i);if(r!==_r.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===qt.MSE,o=n===qt.NATIVE;return s&&(o||!(Fy&&(a||Jk)))}var sC=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Qd(i)===_r.M3U8,d=Vy(i,e);if(l&&!d&&Fy){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=nC(r),h=aC(i),f=a!==Wd.NONE?{useHeaders:a===Wd.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new ge({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,E;if(a&&a!==Wd.QUERY)return;let b=new URL(p);if(!b.searchParams.has("CMCD"))return;let T=((E=(g=b.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?E:[]).filter(_=>_.startsWith("sid")||_.startsWith("cid")).join(",");b.searchParams.set("CMCD",T),m.open("GET",b)},capLevelController:Gk,...u,...c,...h,...o})}},nC=i=>i===Re.LIVE?{backBufferLength:8}:{},aC=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=eu(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:qd(i,"fairplay"),serverCertificateUrl:Wy(i,"fairplay")},"com.widevine.alpha":{licenseUrl:qd(i,"widevine")},"com.microsoft.playready":{licenseUrl:qd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=Kk(n);return r==null||r(l),o}))}},oC=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},lC=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},dC=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,Yd.FAIRPLAY),u}).catch(()=>{let u=j("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Oe.DRM,c.muxCode=Z.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,Mi(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await oC(Wy(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=jd(c,Oe.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=j("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Oe.DRM,h.muxCode=Z.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){Mi(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=j("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Oe.DRM,d.muxCode=Z.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=j("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Oe.DRM,d.muxCode=Z.ENCRYPTED_OUTPUT_RESTRICTED}d&&Mi(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=j("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Oe.DRM,d.muxCode=Z.ENCRYPTED_GENERATE_REQUEST_FAILED,Mi(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l);n.generateRequest(r,s);let o=await lC(a,qd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=jd(l,Oe.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=j("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Oe.DRM,d.muxCode=Z.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){Mi(e,r);return}})},qd=({playbackId:i,tokens:{drm:e}={},customDomain:t=Tr},r)=>{let s=eu(i);return`https://license.${t.toLocaleLowerCase().endsWith(Tr)?t:Tr}/license/${r}/${s}?token=${e}`},Wy=({playbackId:i,tokens:{drm:e}={},customDomain:t=Tr},r)=>{let s=eu(i);return`https://license.${t.toLocaleLowerCase().endsWith(Tr)?t:Tr}/appcert/${r}/${s}?token=${e}`},Yy=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(Tr)||!!t&&s.includes(t.toLocaleLowerCase())},uC=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=Yy(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;Jl.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?ge:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},cC=(i,e,t)=>{var r,s;let n=Vy(i,e),{src:a}=i,o=()=>{e.ended||!Jm(e,t)||(Gy(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},l,d,u=()=>{let c=tu(e),h,f;c.length>0&&(h=c.start(0),f=c.end(0)),(d!==f||l!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),l=h,d=f};if(rt(e,"durationchange",u),e&&n){let c=Qd(i);if(typeof a=="string"){let h=()=>{if(zd(e)!==Re.LIVE||Number.isFinite(e.duration))return;let m=setInterval(u,1e3);e.addEventListener("teardown",()=>{clearInterval(m)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(m)})},f=async()=>qk(a,e,c).then(h).catch(m=>{if(m instanceof Response){let p=jd(m,Oe.VIDEO,i);if(p){Mi(e,p);return}}else m instanceof Error});if(e.preload==="none"){let m=()=>{f(),e.removeEventListener("loadedmetadata",p)},p=()=>{f(),e.removeEventListener("play",m)};rt(e,"play",m,{once:!0}),rt(e,"loadedmetadata",p,{once:!0})}else f();(r=i.tokens)!=null&&r.drm?dC(i,e):rt(e,"encrypted",()=>{let m=j("Attempting to play DRM-protected content without providing a DRM token."),p=new K(m,K.MEDIA_ERR_ENCRYPTED,!0);p.errorCategory=Oe.DRM,p.muxCode=Z.ENCRYPTED_MISSING_TOKEN,Mi(e,p)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=vt.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",qy,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",jy),e.addEventListener("error",Gm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(h=>{h.remove()})},{once:!0}),rt(e,"pause",o),rt(e,"seeked",o),rt(e,"play",()=>{e.ended||Hy(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ge.Events.LEVEL_LOADED,(c,h)=>{zk(h.details,e,t),u(),zd(e)===Re.LIVE&&!Number.isFinite(e.duration)&&(t.on(ge.Events.LEVEL_UPDATED,u),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ge.Events.LEVELS_UPDATED,u)}))}),t.on(ge.Events.ERROR,(c,h)=>{Mi(e,hC(h,i))}),e.addEventListener("error",Gm),rt(e,"waiting",o),Ok(i,t),Nk(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function qy(i){var e;let t=i.target,r=(e=vt.get(t))==null?void 0:e.startTime;if(r&&xk(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function jy(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=Qm(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&Mi(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}Mi(e,s)}function Mi(i,e){var t;e.fatal&&(((t=vt.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function Gm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=vt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var hC=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ge.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ge.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ge.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ge.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ge.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ge.ErrorTypes.KEY_SYSTEM_ERROR)return Oe.DRM;if(u.type===ge.ErrorTypes.NETWORK_ERROR)return Oe.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Oe.VIDEO;l=(r=jd(i.response,u,e))!=null?r:new K("",d)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=j("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_MISSING_TOKEN}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=j("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=j("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=j("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=j("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=j("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_CDM_ERROR}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=j("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Oe.DRM,l.muxCode=Z.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
1265
+ `))}),Yk=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=Ry(s),a=Iy(s),o;if(n===Re.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u!=null?u:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},qk=async(i,e)=>{if(e===_r.MP4)return{streamType:Re.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===_r.M3U8){let t=await Wk(i);return Yk(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},jk=async(i,e,t=Zd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await qk(i,t);((r=vt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=vt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=vt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},zk=i=>{var e;let t=i.type,r=Ry(t),s=Iy(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Re.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},Xk=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=zk(i);if(c===Re.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=vt.get(e))!=null?o:{}).seekable=p}((l=vt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=vt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=vt.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},by,yy,Qk=(yy=(by=globalThis==null?void 0:globalThis.navigator)==null?void 0:by.userAgent)!=null?yy:"",Ty,_y,Ay,Zk=(Ay=(_y=(Ty=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ty.userAgentData)==null?void 0:_y.platform)!=null?Ay:"",Jk=Qk.toLowerCase().includes("android")||["x11","android"].some(i=>Zk.toLowerCase().includes(i)),vt=new WeakMap,Tr="mux.com",Sy,xy,By=(xy=(Sy=ge).isSupported)==null?void 0:xy.call(Sy),eC=Jk,eu=()=>Zl.utils.now(),tC=Zl.utils.generateUUID,Ga=({playbackId:i,customDomain:e=Tr,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=Qd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},tu=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},Jm=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},iC=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:qy(i)&&(r=(t=tu(i.playbackId))!=null?t:Jm(i.src))!=null?r:i.src},ep=i=>{var e;return(e=vt.get(i))==null?void 0:e.error},Xd=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.streamType)!=null?t:Re.UNKNOWN},$y=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},iu=i=>{var e,t;return(t=(e=vt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},Hy=i=>{var e;let t=(e=vt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=iu(i);return r.length?r.end(r.length-1)-t:Number.NaN},tp=.034,rC=(i,e,t=tp)=>Math.abs(i-e)<=t,Gy=(i,e,t=tp)=>i>e||rC(i,e,t),sC=(i,e=tp)=>i.paused&&Gy(i.currentTime,i.duration,e),Ky=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},ip=(i,e)=>i.ended||i.loop?i.ended:e&&Ky(i,e)?!0:sC(i),Vy=(i,e,t)=>{rp(e,t);let{metadata:r={}}=i,{view_session_id:s=tC()}=r,n=iC(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,vt.set(e,{});let o=nC(i,e),l=Ok(i,e,o);cC(i,e,o),hC(i,e,o),Fk(e),Bk(e);let d=Pk(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},rp=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",zy),i.removeEventListener("error",Wm),i.removeEventListener("durationchange",jy),vt.delete(i),i.dispatchEvent(new Event("teardown")))};function Wy(i,e){var t;let r=Zd(i);if(r!==_r.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===qt.MSE,o=n===qt.NATIVE;return s&&(o||!(By&&(a||eC)))}var nC=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Zd(i)===_r.M3U8,d=Wy(i,e);if(l&&!d&&By){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=aC(r),h=oC(i),f=a!==Yd.NONE?{useHeaders:a===Yd.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new ge({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,E;if(a&&a!==Yd.QUERY)return;let b=new URL(p);if(!b.searchParams.has("CMCD"))return;let T=((E=(g=b.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?E:[]).filter(_=>_.startsWith("sid")||_.startsWith("cid")).join(",");b.searchParams.set("CMCD",T),m.open("GET",b)},capLevelController:Kk,...u,...c,...h,...o})}},aC=i=>i===Re.LIVE?{backBufferLength:8}:{},oC=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=tu(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:jd(i,"fairplay"),serverCertificateUrl:Yy(i,"fairplay")},"com.widevine.alpha":{licenseUrl:jd(i,"widevine")},"com.microsoft.playready":{licenseUrl:jd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=Vk(n);return r==null||r(l),o}))}},lC=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},dC=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},uC=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,qd.FAIRPLAY),u}).catch(()=>{let u=j("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Ne.DRM,c.muxCode=Z.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,Mi(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await lC(Yy(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=zd(c,Ne.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=j("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Ne.DRM,h.muxCode=Z.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){Mi(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=j("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Ne.DRM,d.muxCode=Z.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=j("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Ne.DRM,d.muxCode=Z.ENCRYPTED_OUTPUT_RESTRICTED}d&&Mi(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=j("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Ne.DRM,d.muxCode=Z.ENCRYPTED_GENERATE_REQUEST_FAILED,Mi(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l);n.generateRequest(r,s);let o=await dC(a,jd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=zd(l,Ne.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=j("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Ne.DRM,d.muxCode=Z.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){Mi(e,r);return}})},jd=({playbackId:i,tokens:{drm:e}={},customDomain:t=Tr},r)=>{let s=tu(i);return`https://license.${t.toLocaleLowerCase().endsWith(Tr)?t:Tr}/license/${r}/${s}?token=${e}`},Yy=({playbackId:i,tokens:{drm:e}={},customDomain:t=Tr},r)=>{let s=tu(i);return`https://license.${t.toLocaleLowerCase().endsWith(Tr)?t:Tr}/appcert/${r}/${s}?token=${e}`},qy=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(Tr)||!!t&&s.includes(t.toLocaleLowerCase())},cC=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=qy(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;Zl.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?ge:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},hC=(i,e,t)=>{var r,s;let n=Wy(i,e),{src:a}=i,o=()=>{e.ended||!ip(e,t)||(Ky(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},l,d,u=()=>{let c=iu(e),h,f;c.length>0&&(h=c.start(0),f=c.end(0)),(d!==f||l!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),l=h,d=f};if(rt(e,"durationchange",u),e&&n){let c=Zd(i);if(typeof a=="string"){let h=()=>{if(Xd(e)!==Re.LIVE||Number.isFinite(e.duration))return;let m=setInterval(u,1e3);e.addEventListener("teardown",()=>{clearInterval(m)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(m)})},f=async()=>jk(a,e,c).then(h).catch(m=>{if(m instanceof Response){let p=zd(m,Ne.VIDEO,i);if(p){Mi(e,p);return}}else m instanceof Error});if(e.preload==="none"){let m=()=>{f(),e.removeEventListener("loadedmetadata",p)},p=()=>{f(),e.removeEventListener("play",m)};rt(e,"play",m,{once:!0}),rt(e,"loadedmetadata",p,{once:!0})}else f();(r=i.tokens)!=null&&r.drm?uC(i,e):rt(e,"encrypted",()=>{let m=j("Attempting to play DRM-protected content without providing a DRM token."),p=new K(m,K.MEDIA_ERR_ENCRYPTED,!0);p.errorCategory=Ne.DRM,p.muxCode=Z.ENCRYPTED_MISSING_TOKEN,Mi(e,p)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=vt.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",jy,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",zy),e.addEventListener("error",Wm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(h=>{h.remove()})},{once:!0}),rt(e,"pause",o),rt(e,"seeked",o),rt(e,"play",()=>{e.ended||Gy(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ge.Events.LEVEL_LOADED,(c,h)=>{Xk(h.details,e,t),u(),Xd(e)===Re.LIVE&&!Number.isFinite(e.duration)&&(t.on(ge.Events.LEVEL_UPDATED,u),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ge.Events.LEVELS_UPDATED,u)}))}),t.on(ge.Events.ERROR,(c,h)=>{Mi(e,fC(h,i))}),e.addEventListener("error",Wm),rt(e,"waiting",o),Nk(i,t),Uk(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function jy(i){var e;let t=i.target,r=(e=vt.get(t))==null?void 0:e.startTime;if(r&&Rk(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function zy(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=ep(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&Mi(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}Mi(e,s)}function Mi(i,e){var t;e.fatal&&(((t=vt.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function Wm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=vt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var fC=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ge.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ge.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ge.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ge.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ge.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ge.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===ge.ErrorTypes.NETWORK_ERROR)return Ne.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Ne.VIDEO;l=(r=zd(i.response,u,e))!=null?r:new K("",d)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=j("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_MISSING_TOKEN}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=j("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=j("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=j("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=j("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=j("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_CDM_ERROR}else if(i.details===ge.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=j("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=Z.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
1266
1266
  `:""}${i.response&&(i.response.code||i.response.text)?`response: ${i.response.code}, ${i.response.text}
1267
1267
  `:""}${i.reason?`failure reason: ${i.reason}
1268
1268
  `:""}${i.level?`level: ${i.level}
@@ -1271,7 +1271,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1271
1271
  `:""}${i.error?`error: ${i.error}
1272
1272
  `:""}${i.event?`event: ${i.event}
1273
1273
  `:""}${i.err?`error message: ${(s=i.err)==null?void 0:s.message}
1274
- `:""}`),l.data=i,l};var fC=Object.defineProperty,mC=Object.getPrototypeOf,pC=Reflect.get,sT=i=>{throw TypeError(i)},gC=(i,e,t)=>e in i?fC(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Le=(i,e,t)=>gC(i,typeof e!="symbol"?e+"":e,t),bp=(i,e,t)=>e.has(i)||sT("Cannot "+t),I=(i,e,t)=>(bp(i,e,"read from private field"),t?t.call(i):e.get(i)),ie=(i,e,t)=>e.has(i)?sT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Q=(i,e,t,r)=>(bp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ne=(i,e,t)=>(bp(i,e,"access private method"),t),tp=(i,e,t)=>pC(mC(i),t,e),pu=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends pu{}globalThis.DocumentFragment=i}var yp=class extends pu{},vC=class extends pu{},EC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(yp)}},iu,bC=class{constructor(i,e={}){ie(this,iu),Q(this,iu,e==null?void 0:e.detail)}get detail(){return I(this,iu)}initCustomEvent(){}};iu=new WeakMap;function yC(i,e){return new yp}var nT={document:{createElement:yC},DocumentFragment,customElements:EC,CustomEvent:bC,EventTarget:pu,HTMLElement:yp,HTMLVideoElement:vC},aT=typeof window=="undefined"||typeof globalThis.customElements=="undefined",ip=aT?nT:globalThis,A2=aT?nT.document:globalThis.document,TC=()=>{try{return"0.24.2"}catch{}return"UNKNOWN"},_C=TC(),AC=()=>_C,gu=["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"],oT=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function SC(i){return`
1274
+ `:""}`),l.data=i,l};var mC=Object.defineProperty,pC=Object.getPrototypeOf,gC=Reflect.get,nT=i=>{throw TypeError(i)},vC=(i,e,t)=>e in i?mC(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ke=(i,e,t)=>vC(i,typeof e!="symbol"?e+"":e,t),_p=(i,e,t)=>e.has(i)||nT("Cannot "+t),I=(i,e,t)=>(_p(i,e,"read from private field"),t?t.call(i):e.get(i)),ie=(i,e,t)=>e.has(i)?nT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Q=(i,e,t,r)=>(_p(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ue=(i,e,t)=>(_p(i,e,"access private method"),t),sp=(i,e,t)=>gC(pC(i),t,e),gu=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends gu{}globalThis.DocumentFragment=i}var Ap=class extends gu{},EC=class extends gu{},bC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Ap)}},ru,yC=class{constructor(i,e={}){ie(this,ru),Q(this,ru,e==null?void 0:e.detail)}get detail(){return I(this,ru)}initCustomEvent(){}};ru=new WeakMap;function TC(i,e){return new Ap}var aT={document:{createElement:TC},DocumentFragment,customElements:bC,CustomEvent:yC,EventTarget:gu,HTMLElement:Ap,HTMLVideoElement:EC},oT=typeof window=="undefined"||typeof globalThis.customElements=="undefined",np=oT?aT:globalThis,S2=oT?aT.document:globalThis.document,_C=()=>{try{return"0.24.2"}catch{}return"UNKNOWN"},AC=_C(),SC=()=>AC,vu=["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"],lT=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function xC(i){return`
1275
1275
  <style>
1276
1276
  :host {
1277
1277
  display: inline-flex;
@@ -1285,10 +1285,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1285
1285
  }
1286
1286
  </style>
1287
1287
  <slot name="media">
1288
- <audio${dT(i)}></audio>
1288
+ <audio${uT(i)}></audio>
1289
1289
  </slot>
1290
1290
  <slot></slot>
1291
- `}function xC(i){return`
1291
+ `}function RC(i){return`
1292
1292
  <style>
1293
1293
  :host {
1294
1294
  display: inline-block;
@@ -1310,11 +1310,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1310
1310
  }
1311
1311
  </style>
1312
1312
  <slot name="media">
1313
- <video${dT(i)}></video>
1313
+ <video${uT(i)}></video>
1314
1314
  </slot>
1315
1315
  <slot></slot>
1316
- `}function lT(i,{tag:e,is:t}){var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,b,T;let _=(s=(r=globalThis.document)==null?void 0:r.createElement)==null?void 0:s.call(r,e,{is:t}),A=_?RC(_):[];return n=class extends i{constructor(){super(...arguments),ie(this,f),ie(this,d,!1),ie(this,u,null),ie(this,c,new Map),ie(this,h),Le(this,"get"),Le(this,"set"),Le(this,"call")}static get observedAttributes(){var x,S,w;return Ne(x=n,o,l).call(x),[...(w=(S=_==null?void 0:_.constructor)==null?void 0:S.observedAttributes)!=null?w:[],...oT]}get nativeEl(){var x,S,w,M,k;return Ne(this,f,m).call(this),(k=(M=(S=(x=I(this,u))!=null?x:this.querySelector(":scope > [slot=media]"))!=null?S:this.querySelector(e))!=null?M:(w=this.shadowRoot)==null?void 0:w.querySelector(e))!=null?k:null}set nativeEl(x){Q(this,u,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,S;return(S=this.getAttribute("preload"))!=null?S:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){var x;if(!this.shadowRoot){this.attachShadow({mode:"open"});let S=IC(this.attributes);t&&(S.is=t),e&&(S.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(S)}this.nativeEl.muted=this.hasAttribute("muted");for(let S of A)Ne(this,f,b).call(this,S);Q(this,h,new MutationObserver(Ne(this,f,g).bind(this))),this.shadowRoot.addEventListener("slotchange",this),Ne(this,f,p).call(this);for(let S of this.constructor.Events)(x=this.shadowRoot)==null||x.addEventListener(S,this,!0)}handleEvent(x){if(x.type==="slotchange"){Ne(this,f,p).call(this);return}x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,S,w){Ne(this,f,m).call(this),Ne(this,f,T).call(this,x,S,w)}connectedCallback(){Ne(this,f,m).call(this)}},a=new WeakMap,o=new WeakSet,l=function(){if(I(this,a))return;Q(this,a,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let S of A)if(!(S in this.prototype))if(typeof _[S]=="function")this.prototype[S]=function(...w){return Ne(this,f,m).call(this),(()=>{var M;if(this.call)return this.call(S,...w);let k=(M=this.nativeEl)==null?void 0:M[S];return k==null?void 0:k.apply(this.nativeEl,w)})()};else{let w={get(){var M,k,P;Ne(this,f,m).call(this);let N=S.toLowerCase();if(x.has(N)){let B=this.getAttribute(N);return B===null?!1:B===""?!0:B}return(P=(M=this.get)==null?void 0:M.call(this,S))!=null?P:(k=this.nativeEl)==null?void 0:k[S]}};S!==S.toUpperCase()&&(w.set=function(M){Ne(this,f,m).call(this);let k=S.toLowerCase();if(x.has(k)){M===!0||M===!1||M==null?this.toggleAttribute(k,!!M):this.setAttribute(k,M);return}if(this.set){this.set(S,M);return}this.nativeEl&&(this.nativeEl[S]=M)}),Object.defineProperty(this.prototype,S,w)}},d=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakSet,m=function(){I(this,d)||(Q(this,d,!0),this.init())},p=function(){var x;let S=new Map(I(this,c)),w=(x=this.shadowRoot)==null?void 0:x.querySelector("slot:not([name])");(w==null?void 0:w.assignedElements({flatten:!0}).filter(M=>["track","source"].includes(M.localName))).forEach(M=>{var k,P;S.delete(M);let N=I(this,c).get(M);N||(N=M.cloneNode(),I(this,c).set(M,N),(k=I(this,h))==null||k.observe(M,{attributes:!0})),(P=this.nativeEl)==null||P.append(N),Ne(this,f,E).call(this,N)}),S.forEach((M,k)=>{M.remove(),I(this,c).delete(k)})},g=function(x){var S;for(let w of x)if(w.type==="attributes"){let{target:M,attributeName:k}=w,P=I(this,c).get(M);P&&k&&(P.setAttribute(k,(S=M.getAttribute(k))!=null?S:""),Ne(this,f,E).call(this,P))}},E=function(x){x&&x.localName==="track"&&x.default&&(x.kind==="chapters"||x.kind==="metadata")&&x.track.mode==="disabled"&&(x.track.mode="hidden")},b=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let S=this[x];delete this[x],this[x]=S}},T=function(x,S,w){var M,k,P;["id","class"].includes(x)||!n.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(w===null?(M=this.nativeEl)==null||M.removeAttribute(x):((k=this.nativeEl)==null?void 0:k.getAttribute(x))!==w&&((P=this.nativeEl)==null||P.setAttribute(x,w)))},ie(n,o),Le(n,"getTemplateHTML",e.endsWith("audio")?SC:xC),Le(n,"shadowRootOptions",{mode:"open"}),Le(n,"Events",gu),ie(n,a,!1),n}function RC(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){let r=Object.getOwnPropertyNames(t);e.push(...r)}return e}function dT(i){let e="";for(let t in i){if(!oT.includes(t))continue;let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function IC(i){let e={};for(let t of i)e[t.name]=t.value;return e}var zy,rp=lT((zy=globalThis.HTMLElement)!=null?zy:class{},{tag:"video"}),Xy,x2=lT((Xy=globalThis.HTMLElement)!=null?Xy:class{},{tag:"audio"}),Ts=new WeakMap,sp=class extends Error{},LC=class extends Error{},kC=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function CC(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function wC(){return globalThis.chrome}function DC(){var i;let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((i=globalThis.chrome)!=null&&i.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}function _s(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function Tp(){var i;return(i=_s())==null?void 0:i.getCurrentSession()}function _p(){var i;return(i=Tp())==null?void 0:i.getSessionObj().media[0]}function MC(i){return new Promise((e,t)=>{_p().editTracksInfo(i,e,t)})}function PC(i){return new Promise((e,t)=>{_p().getStatus(i,e,t)})}function uT(i){return _s().setOptions({...cT(),...i})}function cT(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var ru=new kC,xr=new WeakSet,ot;CC(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}ot||(ot=cast.framework,_s().addEventListener(ot.CastContextEventType.CAST_STATE_CHANGED,s=>{ru.forEach(n=>{var a,o;return(o=(a=Ts.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),_s().addEventListener(ot.CastContextEventType.SESSION_STATE_CHANGED,s=>{ru.forEach(n=>{var a,o;return(o=(a=Ts.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),ru.forEach(s=>{var n,a;return(a=(n=Ts.get(s)).init)==null?void 0:a.call(n)}))});var Qy=0,Ie,su,jt,Sr,Dn,Ln,ys,ap,bt,os,Zy,op,hT,lp,Jy,np,OC=class extends EventTarget{constructor(i){super(),ie(this,bt),ie(this,Ie),ie(this,su),ie(this,jt),ie(this,Sr),ie(this,Dn,"disconnected"),ie(this,Ln,!1),ie(this,ys,new Set),ie(this,ap,new WeakMap),Q(this,Ie,i),ru.add(this),Ts.set(this,{init:()=>Ne(this,bt,lp).call(this),onCastStateChanged:()=>Ne(this,bt,op).call(this),onSessionStateChanged:()=>Ne(this,bt,hT).call(this),getCastPlayer:()=>I(this,bt,os)}),Ne(this,bt,lp).call(this)}get state(){return I(this,Dn)}async watchAvailability(i){if(I(this,Ie).disableRemotePlayback)throw new sp("disableRemotePlayback attribute is present.");return I(this,ap).set(i,++Qy),I(this,ys).add(i),Qy}async cancelWatchAvailability(i){if(I(this,Ie).disableRemotePlayback)throw new sp("disableRemotePlayback attribute is present.");i?I(this,ys).delete(i):I(this,ys).clear()}async prompt(){var i,e,t,r;if(I(this,Ie).disableRemotePlayback)throw new sp("disableRemotePlayback attribute is present.");if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable))throw new LC("The RemotePlayback API is disabled on this platform.");let s=xr.has(I(this,Ie));xr.add(I(this,Ie)),uT(I(this,Ie).castOptions),Object.entries(I(this,Sr)).forEach(([n,a])=>{I(this,jt).controller.addEventListener(n,a)});try{await _s().requestSession()}catch(n){if(n==="cancel"){s||xr.delete(I(this,Ie));return}throw new Error(n)}(r=(t=Ts.get(I(this,Ie)))==null?void 0:t.loadOnPrompt)==null||r.call(t)}};Ie=new WeakMap,su=new WeakMap,jt=new WeakMap,Sr=new WeakMap,Dn=new WeakMap,Ln=new WeakMap,ys=new WeakMap,ap=new WeakMap,bt=new WeakSet,os=function(){if(xr.has(I(this,Ie)))return I(this,jt)},Zy=function(){xr.has(I(this,Ie))&&(Object.entries(I(this,Sr)).forEach(([i,e])=>{I(this,jt).controller.removeEventListener(i,e)}),xr.delete(I(this,Ie)),I(this,Ie).muted=I(this,jt).isMuted,I(this,Ie).currentTime=I(this,jt).savedPlayerState.currentTime,I(this,jt).savedPlayerState.isPaused===!1&&I(this,Ie).play())},op=function(){let i=_s().getCastState();if(xr.has(I(this,Ie))&&i==="CONNECTING"&&(Q(this,Dn,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,Ln)&&i!=null&&i.includes("CONNECT")){Q(this,Ln,!0);for(let e of I(this,ys))e(!0)}else if(I(this,Ln)&&(!i||i==="NO_DEVICES_AVAILABLE")){Q(this,Ln,!1);for(let e of I(this,ys))e(!1)}},hT=async function(){var i;let{SESSION_RESUMED:e}=ot.SessionState;if(_s().getSessionState()===e&&I(this,Ie).castSrc===((i=_p())==null?void 0:i.media.contentId)){xr.add(I(this,Ie)),Object.entries(I(this,Sr)).forEach(([t,r])=>{I(this,jt).controller.addEventListener(t,r)});try{await PC(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}I(this,Sr)[ot.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,Sr)[ot.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},lp=function(){!ot||I(this,su)||(Q(this,su,!0),uT(I(this,Ie).castOptions),I(this,Ie).textTracks.addEventListener("change",()=>Ne(this,bt,np).call(this)),Ne(this,bt,op).call(this),Q(this,jt,new ot.RemotePlayer),new ot.RemotePlayerController(I(this,jt)),Q(this,Sr,{[ot.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(Q(this,Dn,"connected"),this.dispatchEvent(new Event("connect"))):(Ne(this,bt,Zy).call(this),Q(this,Dn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[ot.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("durationchange"))},[ot.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[ot.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[ot.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=I(this,bt,os))!=null&&i.isMediaLoaded&&I(this,Ie).dispatchEvent(new Event("timeupdate"))},[ot.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("resize"))},[ot.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event(this.paused?"pause":"play"))},[ot.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=I(this,bt,os))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,Ie).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=I(this,bt,os))==null?void 0:e.playerState]))},[ot.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=I(this,bt,os))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Ne(this,bt,Jy).call(this))}}))},Jy=function(){Ne(this,bt,np).call(this)},np=async function(){var i,e,t,r,s;if(!I(this,bt,os))return;let n=((e=(i=I(this,jt).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...I(this,Ie).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=Tp())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await MC(h)}catch(h){console.error(h)}};var NC=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),ie(this,o),ie(this,r,{paused:!1}),ie(this,s,cT()),ie(this,n),ie(this,a)}get remote(){return I(this,a)?I(this,a):wC()?(this.disableRemotePlayback||DC(),Ts.set(this,{loadOnPrompt:()=>Ne(this,o,d).call(this)}),Q(this,a,new OC(this))):super.remote}attributeChangedCallback(u,c,h){if(super.attributeChangedCallback(u,c,h),u==="cast-receiver"&&h){I(this,s).receiverApplicationId=h;return}if(I(this,o,l))switch(u){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var u,c;if(!I(this,o,l))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);h.customData=this.castCustomData;let f=[...this.querySelectorAll("track")].filter(({kind:E,src:b})=>b&&(E==="subtitles"||E==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(E=>{let b=++p;m.length===0&&E.track.mode==="showing"&&m.push(b);let T=new chrome.cast.media.Track(b,chrome.cast.media.TrackType.TEXT);return T.trackContentId=E.src,T.trackContentType="text/vtt",T.subtype=E.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,T.name=E.label,T.language=E.srclang,T})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(u=super.currentTime)!=null?u:0,g.autoplay=!I(this,r).paused,g.activeTrackIds=m,await((c=Tp())==null?void 0:c.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var u;if(I(this,o,l)){I(this,o,l).isPaused&&((u=I(this,o,l).controller)==null||u.playOrPause());return}return super.play()}pause(){var u;if(I(this,o,l)){I(this,o,l).isPaused||(u=I(this,o,l).controller)==null||u.playOrPause();return}super.pause()}get castOptions(){return I(this,s)}get castReceiver(){var u;return(u=this.getAttribute("cast-receiver"))!=null?u:void 0}set castReceiver(u){this.castReceiver!=u&&this.setAttribute("cast-receiver",`${u}`)}get castSrc(){var u,c,h;return(h=(c=this.getAttribute("cast-src"))!=null?c:(u=this.querySelector("source"))==null?void 0:u.src)!=null?h:this.currentSrc}set castSrc(u){this.castSrc!=u&&this.setAttribute("cast-src",`${u}`)}get castContentType(){var u;return(u=this.getAttribute("cast-content-type"))!=null?u:void 0}set castContentType(u){this.setAttribute("cast-content-type",`${u}`)}get castStreamType(){var u,c;return(c=(u=this.getAttribute("cast-stream-type"))!=null?u:this.streamType)!=null?c:void 0}set castStreamType(u){this.setAttribute("cast-stream-type",`${u}`)}get castCustomData(){return I(this,n)}set castCustomData(u){let c=typeof u;if(!["object","undefined"].includes(c)){console.error(`castCustomData must be nullish or an object but value was of type ${c}`);return}Q(this,n,u)}get readyState(){if(I(this,o,l))switch(I(this,o,l).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 I(this,o,l)?I(this,o,l).isPaused:super.paused}get muted(){var u;return I(this,o,l)?(u=I(this,o,l))==null?void 0:u.isMuted:super.muted}set muted(u){var c;if(I(this,o,l)){(u&&!I(this,o,l).isMuted||!u&&I(this,o,l).isMuted)&&((c=I(this,o,l).controller)==null||c.muteOrUnmute());return}super.muted=u}get volume(){var u,c;return I(this,o,l)?(c=(u=I(this,o,l))==null?void 0:u.volumeLevel)!=null?c:1:super.volume}set volume(u){var c;if(I(this,o,l)){I(this,o,l).volumeLevel=+u,(c=I(this,o,l).controller)==null||c.setVolumeLevel();return}super.volume=u}get duration(){var u,c,h;return I(this,o,l)&&(u=I(this,o,l))!=null&&u.isMediaLoaded?(h=(c=I(this,o,l))==null?void 0:c.duration)!=null?h:NaN:super.duration}get currentTime(){var u,c,h;return I(this,o,l)&&(u=I(this,o,l))!=null&&u.isMediaLoaded?(h=(c=I(this,o,l))==null?void 0:c.currentTime)!=null?h:0:super.currentTime}set currentTime(u){var c;if(I(this,o,l)){I(this,o,l).currentTime=u,(c=I(this,o,l).controller)==null||c.seek();return}super.currentTime=u}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){var u,c;return(c=(u=Ts.get(this.remote))==null?void 0:u.getCastPlayer)==null?void 0:c.call(u)},d=async function(){I(this,r).paused=tp(t.prototype,this,"paused"),tp(t.prototype,this,"pause").call(this),this.muted=tp(t.prototype,this,"muted");try{await this.load()}catch(u){console.error(u)}},Le(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},vu=class extends Event{constructor(i,e){super(i),Le(this,"track"),this.track=e.track}},dp=new WeakMap;function Y(i){var e;return(e=dp.get(i))!=null?e:UC(i,{})}function UC(i,e){let t=dp.get(i);return t||dp.set(i,t={}),Object.assign(t,e)}function up(i,e){let t=i.videoTracks;Y(e).media=i,Y(e).renditionSet||(Y(e).renditionSet=new Set);let r=Y(t).trackSet;r.add(e);let s=r.size-1;s in hp.prototype||Object.defineProperty(hp.prototype,s,{get(){return[...Y(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new vu("addtrack",{track:e}))})}function cp(i){var e;let t=(e=Y(i).media)==null?void 0:e.videoTracks;t&&(Y(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new vu("removetrack",{track:i}))}))}function FC(i){var e;let t=(e=Y(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(Y(t).changeRequested)return;Y(t).changeRequested=!0,queueMicrotask(()=>{delete Y(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var ls,ds,us,kn,Va,hp=class extends EventTarget{constructor(){super(),ie(this,kn),ie(this,ls),ie(this,ds),ie(this,us),Y(this).trackSet=new Set}[Symbol.iterator](){return I(this,kn,Va).values()}get length(){return I(this,kn,Va).size}getTrackById(i){var e;return(e=[...I(this,kn,Va)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...I(this,kn,Va)].findIndex(i=>i.selected)}get onaddtrack(){return I(this,ls)}set onaddtrack(i){I(this,ls)&&(this.removeEventListener("addtrack",I(this,ls)),Q(this,ls,void 0)),typeof i=="function"&&(Q(this,ls,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,ds)}set onremovetrack(i){I(this,ds)&&(this.removeEventListener("removetrack",I(this,ds)),Q(this,ds,void 0)),typeof i=="function"&&(Q(this,ds,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,us)}set onchange(i){I(this,us)&&(this.removeEventListener("change",I(this,us)),Q(this,us,void 0)),typeof i=="function"&&(Q(this,us,i),this.addEventListener("change",i))}};ls=new WeakMap,ds=new WeakMap,us=new WeakMap,kn=new WeakSet,Va=function(){return Y(this).trackSet};var Eu=class extends Event{constructor(i,e){super(i),Le(this,"rendition"),this.rendition=e.rendition}};function BC(i,e){let t=Y(i).media.videoRenditions;Y(e).media=Y(i).media,Y(e).track=i;let r=Y(i).renditionSet;r.add(e);let s=r.size-1;s in fp.prototype||Object.defineProperty(fp.prototype,s,{get(){return Cn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Eu("addrendition",{rendition:e}))})}function $C(i){let e=Y(i).media.videoRenditions,t=Y(i).track;Y(t).renditionSet.delete(i),queueMicrotask(()=>{Y(i).track.selected&&e.dispatchEvent(new Eu("removerendition",{rendition:i}))})}function HC(i){let e=Y(i).media.videoRenditions;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,Y(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Cn(i){return[...Y(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...Y(e).renditionSet])}var cs,hs,fs,fp=class extends EventTarget{constructor(){super(...arguments),ie(this,cs),ie(this,hs),ie(this,fs)}[Symbol.iterator](){return Cn(this).values()}get length(){return Cn(this).length}getRenditionById(i){var e;return(e=Cn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Cn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Cn(this).entries())t.selected=e===i}get onaddrendition(){return I(this,cs)}set onaddrendition(i){I(this,cs)&&(this.removeEventListener("addrendition",I(this,cs)),Q(this,cs,void 0)),typeof i=="function"&&(Q(this,cs,i),this.addEventListener("addrendition",i))}get onremoverendition(){return I(this,hs)}set onremoverendition(i){I(this,hs)&&(this.removeEventListener("removerendition",I(this,hs)),Q(this,hs,void 0)),typeof i=="function"&&(Q(this,hs,i),this.addEventListener("removerendition",i))}get onchange(){return I(this,fs)}set onchange(i){I(this,fs)&&(this.removeEventListener("change",I(this,fs)),Q(this,fs,void 0)),typeof i=="function"&&(Q(this,fs,i),this.addEventListener("change",i))}};cs=new WeakMap,hs=new WeakMap,fs=new WeakMap;var Wa,GC=class{constructor(){Le(this,"src"),Le(this,"id"),Le(this,"width"),Le(this,"height"),Le(this,"bitrate"),Le(this,"frameRate"),Le(this,"codec"),ie(this,Wa,!1)}get selected(){return I(this,Wa)}set selected(i){I(this,Wa)!==i&&(Q(this,Wa,i),HC(this))}};Wa=new WeakMap;var Ya,fT=class{constructor(){Le(this,"id"),Le(this,"kind"),Le(this,"label",""),Le(this,"language",""),Le(this,"sourceBuffer"),ie(this,Ya,!1)}addRendition(i,e,t,r,s,n){let a=new GC;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,BC(this,a),a}removeRendition(i){$C(i)}get selected(){return I(this,Ya)}set selected(i){I(this,Ya)!==i&&(Q(this,Ya,i),i===!0&&FC(this))}};Ya=new WeakMap;function KC(i,e){let t=Y(i).media.audioRenditions;Y(e).media=Y(i).media,Y(e).track=i;let r=Y(i).renditionSet;r.add(e);let s=r.size-1;s in mp.prototype||Object.defineProperty(mp.prototype,s,{get(){return wn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Eu("addrendition",{rendition:e}))})}function VC(i){let e=Y(i).media.audioRenditions,t=Y(i).track;Y(t).renditionSet.delete(i),queueMicrotask(()=>{Y(i).track.enabled&&e.dispatchEvent(new Eu("removerendition",{rendition:i}))})}function WC(i){let e=Y(i).media.audioRenditions;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,Y(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function wn(i){return[...Y(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...Y(e).renditionSet])}var ms,ps,gs,mp=class extends EventTarget{constructor(){super(...arguments),ie(this,ms),ie(this,ps),ie(this,gs)}[Symbol.iterator](){return wn(this).values()}get length(){return wn(this).length}getRenditionById(i){var e;return(e=wn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return wn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of wn(this).entries())t.selected=e===i}get onaddrendition(){return I(this,ms)}set onaddrendition(i){I(this,ms)&&(this.removeEventListener("addrendition",I(this,ms)),Q(this,ms,void 0)),typeof i=="function"&&(Q(this,ms,i),this.addEventListener("addrendition",i))}get onremoverendition(){return I(this,ps)}set onremoverendition(i){I(this,ps)&&(this.removeEventListener("removerendition",I(this,ps)),Q(this,ps,void 0)),typeof i=="function"&&(Q(this,ps,i),this.addEventListener("removerendition",i))}get onchange(){return I(this,gs)}set onchange(i){I(this,gs)&&(this.removeEventListener("change",I(this,gs)),Q(this,gs,void 0)),typeof i=="function"&&(Q(this,gs,i),this.addEventListener("change",i))}};ms=new WeakMap,ps=new WeakMap,gs=new WeakMap;var qa,YC=class{constructor(){Le(this,"src"),Le(this,"id"),Le(this,"bitrate"),Le(this,"codec"),ie(this,qa,!1)}get selected(){return I(this,qa)}set selected(i){I(this,qa)!==i&&(Q(this,qa,i),WC(this))}};qa=new WeakMap;function pp(i,e){let t=i.audioTracks;Y(e).media=i,Y(e).renditionSet||(Y(e).renditionSet=new Set);let r=Y(t).trackSet;r.add(e);let s=r.size-1;s in vp.prototype||Object.defineProperty(vp.prototype,s,{get(){return[...Y(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new vu("addtrack",{track:e}))})}function gp(i){var e;let t=(e=Y(i).media)==null?void 0:e.audioTracks;t&&(Y(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new vu("removetrack",{track:i}))}))}function qC(i){let e=Y(i).media.audioTracks;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var vs,Es,bs,ja,nu,vp=class extends EventTarget{constructor(){super(),ie(this,ja),ie(this,vs),ie(this,Es),ie(this,bs),Y(this).trackSet=new Set}[Symbol.iterator](){return I(this,ja,nu).values()}get length(){return I(this,ja,nu).size}getTrackById(i){var e;return(e=[...I(this,ja,nu)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return I(this,vs)}set onaddtrack(i){I(this,vs)&&(this.removeEventListener("addtrack",I(this,vs)),Q(this,vs,void 0)),typeof i=="function"&&(Q(this,vs,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,Es)}set onremovetrack(i){I(this,Es)&&(this.removeEventListener("removetrack",I(this,Es)),Q(this,Es,void 0)),typeof i=="function"&&(Q(this,Es,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,bs)}set onchange(i){I(this,bs)&&(this.removeEventListener("change",I(this,bs)),Q(this,bs,void 0)),typeof i=="function"&&(Q(this,bs,i),this.addEventListener("change",i))}};vs=new WeakMap,Es=new WeakMap,bs=new WeakMap,ja=new WeakSet,nu=function(){return Y(this).trackSet};var za,mT=class{constructor(){Le(this,"id"),Le(this,"kind"),Le(this,"label",""),Le(this,"language",""),Le(this,"sourceBuffer"),ie(this,za,!1)}addRendition(i,e,t){let r=new YC;return r.src=i,r.codec=e,r.bitrate=t,KC(this,r),r}removeRendition(i){VC(i)}get enabled(){return I(this,za)}set enabled(i){I(this,za)!==i&&(Q(this,za,i),qC(this))}};za=new WeakMap;var eT=mu(globalThis.HTMLMediaElement,"video"),tT=mu(globalThis.HTMLMediaElement,"audio");function jC(i){if(!(i!=null&&i.prototype))return i;let e=mu(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return zC(this)}});let t=mu(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return XC(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new fT;return l.kind=n,l.label=a,l.language=o,up(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=cp),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new mT;return l.kind=n,l.label=a,l.language=o,pp(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=gp),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=Y(n).videoRenditions;return a||(a=new fp,Y(a).media=n,Y(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=Y(n).audioRenditions;return a||(a=new mp,Y(a).media=n,Y(n).audioRenditions=a),a};return i}function mu(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function zC(i){var e;let t=Y(i).videoTracks;if(!t&&(t=new hp,Y(i).videoTracks=t,eT)){let r=eT.call((e=i.nativeEl)!=null?e:i);for(let s of r)up(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof fT)){for(let n of r)cp(n);return}up(i,s.track)}),r.addEventListener("removetrack",s=>{cp(s.track)})}return t}function XC(i){var e;let t=Y(i).audioTracks;if(!t&&(t=new vp,Y(i).audioTracks=t,tT)){let r=tT.call((e=i.nativeEl)!=null?e:i);for(let s of r)pp(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof mT)){for(let n of r)gp(n);return}pp(i,s.track)}),r.addEventListener("removetrack",s=>{gp(s.track)})}return t}gu.push("castchange","entercast","leavecast");var C={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",PLAYBACK_TOKEN:"playback-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",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",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_INIT_TIME:"player-init-time",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"},QC=Object.values(C),iT=AC(),rT="mux-video",Pi,Xa,au,Qa,ou,lu,du,uu,cu,Za,hu,ZC=class extends rp{constructor(){super(),ie(this,Za),ie(this,Pi),ie(this,Xa),ie(this,au),ie(this,Qa,{}),ie(this,ou,{}),ie(this,lu),ie(this,du),ie(this,uu),ie(this,cu),Q(this,au,Jd())}static get NAME(){return rT}static get VERSION(){return iT}static get observedAttributes(){var i;return[...QC,...(i=rp.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(C.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?In.includes(i)?this.setAttribute(C.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${In.join()}`):this.removeAttribute(C.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(C.PLAYER_INIT_TIME)?+this.getAttribute(C.PLAYER_INIT_TIME):I(this,au)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(C.PLAYER_INIT_TIME):this.setAttribute(C.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=I(this,uu))!=null?i:rT}set playerSoftwareName(i){Q(this,uu,i)}get playerSoftwareVersion(){var i;return(i=I(this,du))!=null?i:iT}set playerSoftwareVersion(i){Q(this,du,i)}get _hls(){var i;return(i=I(this,Pi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=Qm(this.nativeEl))!=null?i:null}get errorTranslator(){return I(this,cu)}set errorTranslator(i){Q(this,cu,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(C.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(C.TYPE,i):this.removeAttribute(C.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(C.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(C.DEBUG,""):this.removeAttribute(C.DEBUG))}get disableTracking(){return this.hasAttribute(C.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(C.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(C.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(C.DISABLE_COOKIES,""):this.removeAttribute(C.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(C.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(C.START_TIME):this.setAttribute(C.START_TIME,`${i}`))}get playbackId(){var i;return this.hasAttribute(C.PLAYBACK_ID)?this.getAttribute(C.PLAYBACK_ID):(i=Xm(this.src))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(C.PLAYBACK_ID,i):this.removeAttribute(C.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(C.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(C.MAX_RESOLUTION,i):this.removeAttribute(C.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(C.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(C.MIN_RESOLUTION,i):this.removeAttribute(C.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(C.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(C.RENDITION_ORDER,i):this.removeAttribute(C.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(C.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(C.PROGRAM_START_TIME):this.setAttribute(C.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(C.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(C.PROGRAM_END_TIME):this.setAttribute(C.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){let i=this.getAttribute(C.ASSET_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetStartTime(i){i==null?this.removeAttribute(C.ASSET_START_TIME):this.setAttribute(C.ASSET_START_TIME,`${i}`)}get assetEndTime(){let i=this.getAttribute(C.ASSET_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetEndTime(i){i==null?this.removeAttribute(C.ASSET_END_TIME):this.setAttribute(C.ASSET_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(C.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(C.CUSTOM_DOMAIN,i):this.removeAttribute(C.CUSTOM_DOMAIN))}get drmToken(){var i;return(i=this.getAttribute(C.DRM_TOKEN))!=null?i:void 0}set drmToken(i){i!==this.drmToken&&(i?this.setAttribute(C.DRM_TOKEN,i):this.removeAttribute(C.DRM_TOKEN))}get playbackToken(){var i,e,t,r;if(this.hasAttribute(C.PLAYBACK_TOKEN))return(i=this.getAttribute(C.PLAYBACK_TOKEN))!=null?i:void 0;if(this.hasAttribute(C.PLAYBACK_ID)){let[,s]=Xd((e=this.playbackId)!=null?e:"");return(t=new URLSearchParams(s).get("token"))!=null?t:void 0}if(this.src)return(r=new URLSearchParams(this.src).get("token"))!=null?r:void 0}set playbackToken(i){i!==this.playbackToken&&(i?this.setAttribute(C.PLAYBACK_TOKEN,i):this.removeAttribute(C.PLAYBACK_TOKEN))}get tokens(){let i=this.getAttribute(C.PLAYBACK_TOKEN),e=this.getAttribute(C.DRM_TOKEN);return{...I(this,ou),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{}}}set tokens(i){Q(this,ou,i!=null?i:{})}get ended(){return Jm(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(C.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(C.ENV_KEY,i):this.removeAttribute(C.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(C.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(C.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(C.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(C.STREAM_TYPE))!=null?i:zd(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(C.STREAM_TYPE,i):this.removeAttribute(C.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(C.TARGET_LIVE_WINDOW)?+this.getAttribute(C.TARGET_LIVE_WINDOW):By(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(C.TARGET_LIVE_WINDOW):this.setAttribute(C.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(C.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return $y(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(C.LIVE_EDGE_OFFSET))return+this.getAttribute(C.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.liveEdgeOffset&&(i==null?this.removeAttribute(C.LIVE_EDGE_OFFSET):this.setAttribute(C.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return tu(this.nativeEl)}async addCuePoints(i){return Wm(this.nativeEl,i)}get activeCuePoint(){return Ym(this.nativeEl)}get cuePoints(){return wy(this.nativeEl)}async addChapters(i){return jm(this.nativeEl,i)}get activeChapter(){return zm(this.nativeEl)}get chapters(){return My(this.nativeEl)}getStartDate(){return Py(this.nativeEl,this._hls)}get currentPdt(){return Oy(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(C.PREFER_PLAYBACK);if(i===qt.MSE||i===qt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===qt.MSE||i===qt.NATIVE?this.setAttribute(C.PREFER_PLAYBACK,i):this.removeAttribute(C.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![C.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...I(this,Qa)}}set metadata(i){Q(this,Qa,i!=null?i:{}),this.mux&&this.mux.emit("hb",I(this,Qa))}get _hlsConfig(){return I(this,lu)}set _hlsConfig(i){Q(this,lu,i)}load(){Q(this,Pi,Ky(this,this.nativeEl,I(this,Pi)))}unload(){ep(this.nativeEl,I(this,Pi)),Q(this,Pi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(rp.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case C.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case C.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Ne(this,Za,hu).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Ne(this,Za,hu).call(this));break}case"autoplay":if(t===e)break;(r=I(this,Pi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=I(this,Pi))==null||s.setPreload(t);break;case C.PLAYBACK_ID:this.src=Ka(this);break;case C.DEBUG:{let n=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=n);break}case C.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case C.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case C.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!I(this,Pi)&&Ne(this,Za,hu).call(this)}disconnectedCallback(){this.unload()}};Pi=new WeakMap,Xa=new WeakMap,au=new WeakMap,Qa=new WeakMap,ou=new WeakMap,lu=new WeakMap,du=new WeakMap,uu=new WeakMap,cu=new WeakMap,Za=new WeakSet,hu=async function(){I(this,Xa)||(await Q(this,Xa,Promise.resolve()),Q(this,Xa,null),this.load())};var fu,Ep=class extends NC(jC(ZC)){constructor(){super(...arguments),ie(this,fu)}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var i;return(i=I(this,fu))!=null?i:this.muxCastCustomData}set castCustomData(i){Q(this,fu,i)}};fu=new WeakMap;ip.customElements.get("mux-video")||(ip.customElements.define("mux-video",Ep),ip.MuxVideoElement=Ep);var pT=Ep;function gT(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${bu(t)}: ${r}; `)}),e?e.trim():void 0}function bu(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function yu(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Rt(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function Ap(i){let e=JC(i).toString();return e?"?"+e:""}function JC(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}var Sp=(i,e)=>!i||!e?!1:i.contains(e)?!0:Sp(i,e.getRootNode().host);var vT="mux.com",ew=()=>{try{return"3.2.4"}catch{}return"UNKNOWN"},tw=ew(),_u=()=>tw,ET=(i,{token:e,customDomain:t=vT,thumbnailTime:r,programTime:s}={})=>{var o;let n=e==null?r:void 0,{aud:a}=(o=Ar(e))!=null?o:{};if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${Ap({token:e,time:n,program_time:s})}`},bT=(i,{token:e,customDomain:t=vT,programStartTime:r,programEndTime:s}={})=>{var a;let{aud:n}=(a=Ar(e))!=null?a:{};if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${Ap({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Ja=i=>{if(i){if([Re.LIVE,Re.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return Re.LIVE}};var iw={crossorigin:"crossOrigin",playsinline:"playsInline"};function yT(i){var e;return(e=iw[i])!=null?e:yu(i)}var As,Ss,It,Tu=class{constructor(e,t){kt(this,As);kt(this,Ss);kt(this,It,[]);$t(this,As,e),$t(this,Ss,t)}[Symbol.iterator](){return _e(this,It).values()}get length(){return _e(this,It).length}get value(){var e;return(e=_e(this,It).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&($t(this,It,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return _e(this,It)[e]}values(){return _e(this,It).values()}keys(){return _e(this,It).keys()}forEach(e){_e(this,It).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||_e(this,It).push(s)}),!(this.value===""&&!((t=_e(this,As))!=null&&t.hasAttribute(`${_e(this,Ss)}`)))&&((r=_e(this,As))==null||r.setAttribute(`${_e(this,Ss)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{_e(this,It).splice(_e(this,It).indexOf(r),1)}),(t=_e(this,As))==null||t.setAttribute(`${_e(this,Ss)}`,`${this.value}`)}contains(e){return _e(this,It).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};As=new WeakMap,Ss=new WeakMap,It=new WeakMap;var TT=`[mux-player ${_u()}]`;function Oi(...i){console.warn(TT,...i)}function Ut(...i){console.error(TT,...i)}function xp(i){var t;let e=(t=i.message)!=null?t:"";i.context&&(e+=` ${i.context}`),i.file&&(e+=` ${j("Read more: ")}
1317
- https://github.com/muxinc/elements/blob/main/errors/${i.file}`),Oi(e)}var At={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},xs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},AT=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),rw=gu.filter(i=>i!=="error"),sw=Object.values(At).filter(i=>![At.PLAYSINLINE].includes(i)),nw=Object.values(xs),Rp=class extends Ct.HTMLElement{static get observedAttributes(){return[...sw,...nw]}constructor(){super()}init(){rw.forEach(e=>{var t;(t=this.media)==null||t.addEventListener(e,r=>{this.dispatchEvent(new Event(r.type))})})}attributeChangedCallback(e,t,r){var s,n;switch(e){case xs.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case xs.VOLUME:{let a=(s=Rt(r))!=null?s:1;this.media&&(this.media.volume=a);return}case xs.PLAYBACKRATE:{let a=(n=Rt(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}load(){var e;(e=this.media)==null||e.load()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:AT}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:AT}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentSrc(){var e,t;return(t=(e=this.media)==null?void 0:e.currentSrc)!=null?t:""}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=Rt(this.getAttribute(xs.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(xs.PLAYBACKRATE,`${e}`):this.removeAttribute(xs.PLAYBACKRATE)}get crossOrigin(){return eo(this,At.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(At.CROSSORIGIN,`${e}`)}get autoplay(){return eo(this,At.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(At.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(At.AUTOPLAY)}get loop(){return eo(this,At.LOOP)!=null}set loop(e){e?this.setAttribute(At.LOOP,""):this.removeAttribute(At.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return eo(this,At.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(At.MUTED,""):this.removeAttribute(At.MUTED)}get playsInline(){return eo(this,At.PLAYSINLINE)!=null}set playsInline(e){Ut("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(At.PRELOAD,e):this.removeAttribute(At.PRELOAD)}};function eo(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Ip=Rp;var LT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(LT(i,e,"read from private field"),t?t.call(i):e.get(i)),Ni=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},tr=(i,e,t,r)=>(LT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,Au,Rs,to,Rr,Ir,Lr,Is,Pn,Su,ci,ST=1,xT=0,aw=1,ow={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Lt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Lt?s.element[s.attributeName]=n:s.value=n}}}},ir=class extends R.DocumentFragment{constructor(e,t,r=ow){var s;super(),Ni(this,Mn,void 0),Ni(this,Au,void 0),this.append(e.content.cloneNode(!0)),tr(this,Mn,kT(this)),tr(this,Au,r),(s=r.createCallback)==null||s.call(r,this,de(this,Mn),t),r.processCallback(this,de(this,Mn),t)}update(e){de(this,Au).processCallback(this,de(this,Mn),e)}};Mn=new WeakMap;Au=new WeakMap;var kT=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Lp;for([t,r]of IT(s.value))if(!t)n.append(r);else{let a=new Lt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===ST&&!(s instanceof HTMLTemplateElement))kT(s,e);else{let n=s.data;if(s.nodeType===ST||n.includes("{{")){let a=[];if(n)for([t,r]of IT(n))if(!t)a.push(new Text(r));else{let o=new rr(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){let o=new io(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},RT={},IT=i=>{let e="",t=0,r=RT[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([xT,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([aw,e.trim()]),e="",s++):e+=n||"";return e&&r.push([xT,(t>0?"{{":"")+e]),RT[i]=r},lw=11,xu=class{get value(){return""}set value(e){}toString(){return this.value}},CT=new WeakMap,Lp=class{constructor(){Ni(this,Rs,[])}[Symbol.iterator](){return de(this,Rs).values()}get length(){return de(this,Rs).length}item(e){return de(this,Rs)[e]}append(...e){for(let t of e)t instanceof Lt&&CT.set(t,this),de(this,Rs).push(t)}toString(){return de(this,Rs).join("")}};Rs=new WeakMap;var Lt=class extends xu{constructor(e,t,r){super(),Ni(this,Is),Ni(this,to,""),Ni(this,Rr,void 0),Ni(this,Ir,void 0),Ni(this,Lr,void 0),tr(this,Rr,e),tr(this,Ir,t),tr(this,Lr,r)}get attributeName(){return de(this,Ir)}get attributeNamespace(){return de(this,Lr)}get element(){return de(this,Rr)}get value(){return de(this,to)}set value(e){de(this,to)!==e&&(tr(this,to,e),!de(this,Is,Pn)||de(this,Is,Pn).length===1?e==null?de(this,Rr).removeAttributeNS(de(this,Lr),de(this,Ir)):de(this,Rr).setAttributeNS(de(this,Lr),de(this,Ir),e):de(this,Rr).setAttributeNS(de(this,Lr),de(this,Ir),de(this,Is,Pn).toString()))}get booleanValue(){return de(this,Rr).hasAttributeNS(de(this,Lr),de(this,Ir))}set booleanValue(e){if(!de(this,Is,Pn)||de(this,Is,Pn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};to=new WeakMap;Rr=new WeakMap;Ir=new WeakMap;Lr=new WeakMap;Is=new WeakSet;Pn=function(){return CT.get(this)};var rr=class extends xu{constructor(e,t){super(),Ni(this,Su,void 0),Ni(this,ci,void 0),tr(this,Su,e),tr(this,ci,t?[...t]:[new Text])}get replacementNodes(){return de(this,ci)}get parentNode(){return de(this,Su)}get nextSibling(){return de(this,ci)[de(this,ci).length-1].nextSibling}get previousSibling(){return de(this,ci)[0].previousSibling}get value(){return de(this,ci).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===lw?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),tr(this,ci,dw(de(this,ci)[0].parentNode,de(this,ci),t,this.nextSibling))}};Su=new WeakMap;ci=new WeakMap;var io=class extends rr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}};function dw(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var wT={string:i=>String(i)},Iu=class{constructor(e){this.template=e,this.state=void 0}},Ls=new WeakMap,ks=new WeakMap,kp={partial:(i,e)=>{e[i.expression]=new Iu(i.template)},if:(i,e)=>{var t;if(MT(i.expression,e))if(Ls.get(i)!==i.template){Ls.set(i,i.template);let r=new ir(i.template,e,Lu);i.replace(r),ks.set(i,r)}else(t=ks.get(i))==null||t.update(e);else i.replace(""),Ls.delete(i),ks.delete(i)}},uw=Object.keys(kp),Lu={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof io){if(!a.directive){let l=uw.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=kp[a.directive])==null||r.call(kp,a,t);continue}let o=MT(n,t);if(o instanceof Iu){Ls.get(a)!==o.template?(Ls.set(a,o.template),o=new ir(o.template,o.state,Lu),a.value=o,ks.set(a,o)):(s=ks.get(a))==null||s.update(o.state);continue}o?(a instanceof Lt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Lt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Ls.delete(a),ks.delete(a))):a instanceof Lt?a.value=void 0:(a.value=void 0,Ls.delete(a),ks.delete(a))}}},DT={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=wT[e])==null?void 0:t.call(wT,i)}};function cw(i){return hw(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function MT(i,e={}){var t,r,s,n,a,o,l;let d=cw(i);if(d.length===0||d.some(({type:u})=>!u))return ro(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return ro(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=so(g,e))}return u}if(d.length===1)return Ru(d[0])?so(d[0].token,e):ro(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=DT[u];if(!c||!Ru(d[1]))return ro(i);let h=so(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=DT[u];if(!c||!Ru(d[0])||!Ru(d[2]))return ro(i);let h=so(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=so(d[2].token,e);return c(h,f)}}function ro(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Ru({type:i}){return["number","boolean","string","param"].includes(i)}function so(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Do(i)?parseFloat(i):e[i]}function hw(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Op=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Dp=(i,e,t)=>(Op(i,e,"read from private field"),t?t.call(i):e.get(i)),no=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Cs=(i,e,t,r)=>(Op(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Cp=(i,e,t)=>(Op(i,e,"access private method"),t),On,ku,Nn,Mp,PT,Cu,Pp,wp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},OT=F.createElement("template");OT.innerHTML=`
1316
+ `}function dT(i,{tag:e,is:t}){var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,b,T;let _=(s=(r=globalThis.document)==null?void 0:r.createElement)==null?void 0:s.call(r,e,{is:t}),A=_?IC(_):[];return n=class extends i{constructor(){super(...arguments),ie(this,f),ie(this,d,!1),ie(this,u,null),ie(this,c,new Map),ie(this,h),ke(this,"get"),ke(this,"set"),ke(this,"call")}static get observedAttributes(){var x,S,w;return Ue(x=n,o,l).call(x),[...(w=(S=_==null?void 0:_.constructor)==null?void 0:S.observedAttributes)!=null?w:[],...lT]}get nativeEl(){var x,S,w,M,k;return Ue(this,f,m).call(this),(k=(M=(S=(x=I(this,u))!=null?x:this.querySelector(":scope > [slot=media]"))!=null?S:this.querySelector(e))!=null?M:(w=this.shadowRoot)==null?void 0:w.querySelector(e))!=null?k:null}set nativeEl(x){Q(this,u,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,S;return(S=this.getAttribute("preload"))!=null?S:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){var x;if(!this.shadowRoot){this.attachShadow({mode:"open"});let S=LC(this.attributes);t&&(S.is=t),e&&(S.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(S)}this.nativeEl.muted=this.hasAttribute("muted");for(let S of A)Ue(this,f,b).call(this,S);Q(this,h,new MutationObserver(Ue(this,f,g).bind(this))),this.shadowRoot.addEventListener("slotchange",this),Ue(this,f,p).call(this);for(let S of this.constructor.Events)(x=this.shadowRoot)==null||x.addEventListener(S,this,!0)}handleEvent(x){if(x.type==="slotchange"){Ue(this,f,p).call(this);return}x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,S,w){Ue(this,f,m).call(this),Ue(this,f,T).call(this,x,S,w)}connectedCallback(){Ue(this,f,m).call(this)}},a=new WeakMap,o=new WeakSet,l=function(){if(I(this,a))return;Q(this,a,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let S of A)if(!(S in this.prototype))if(typeof _[S]=="function")this.prototype[S]=function(...w){return Ue(this,f,m).call(this),(()=>{var M;if(this.call)return this.call(S,...w);let k=(M=this.nativeEl)==null?void 0:M[S];return k==null?void 0:k.apply(this.nativeEl,w)})()};else{let w={get(){var M,k,P;Ue(this,f,m).call(this);let N=S.toLowerCase();if(x.has(N)){let B=this.getAttribute(N);return B===null?!1:B===""?!0:B}return(P=(M=this.get)==null?void 0:M.call(this,S))!=null?P:(k=this.nativeEl)==null?void 0:k[S]}};S!==S.toUpperCase()&&(w.set=function(M){Ue(this,f,m).call(this);let k=S.toLowerCase();if(x.has(k)){M===!0||M===!1||M==null?this.toggleAttribute(k,!!M):this.setAttribute(k,M);return}if(this.set){this.set(S,M);return}this.nativeEl&&(this.nativeEl[S]=M)}),Object.defineProperty(this.prototype,S,w)}},d=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakSet,m=function(){I(this,d)||(Q(this,d,!0),this.init())},p=function(){var x;let S=new Map(I(this,c)),w=(x=this.shadowRoot)==null?void 0:x.querySelector("slot:not([name])");(w==null?void 0:w.assignedElements({flatten:!0}).filter(M=>["track","source"].includes(M.localName))).forEach(M=>{var k,P;S.delete(M);let N=I(this,c).get(M);N||(N=M.cloneNode(),I(this,c).set(M,N),(k=I(this,h))==null||k.observe(M,{attributes:!0})),(P=this.nativeEl)==null||P.append(N),Ue(this,f,E).call(this,N)}),S.forEach((M,k)=>{M.remove(),I(this,c).delete(k)})},g=function(x){var S;for(let w of x)if(w.type==="attributes"){let{target:M,attributeName:k}=w,P=I(this,c).get(M);P&&k&&(P.setAttribute(k,(S=M.getAttribute(k))!=null?S:""),Ue(this,f,E).call(this,P))}},E=function(x){x&&x.localName==="track"&&x.default&&(x.kind==="chapters"||x.kind==="metadata")&&x.track.mode==="disabled"&&(x.track.mode="hidden")},b=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let S=this[x];delete this[x],this[x]=S}},T=function(x,S,w){var M,k,P;["id","class"].includes(x)||!n.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(w===null?(M=this.nativeEl)==null||M.removeAttribute(x):((k=this.nativeEl)==null?void 0:k.getAttribute(x))!==w&&((P=this.nativeEl)==null||P.setAttribute(x,w)))},ie(n,o),ke(n,"getTemplateHTML",e.endsWith("audio")?xC:RC),ke(n,"shadowRootOptions",{mode:"open"}),ke(n,"Events",vu),ie(n,a,!1),n}function IC(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){let r=Object.getOwnPropertyNames(t);e.push(...r)}return e}function uT(i){let e="";for(let t in i){if(!lT.includes(t))continue;let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function LC(i){let e={};for(let t of i)e[t.name]=t.value;return e}var Xy,ap=dT((Xy=globalThis.HTMLElement)!=null?Xy:class{},{tag:"video"}),Qy,R2=dT((Qy=globalThis.HTMLElement)!=null?Qy:class{},{tag:"audio"}),Ts=new WeakMap,op=class extends Error{},kC=class extends Error{},CC=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function wC(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function DC(){return globalThis.chrome}function MC(){var i;let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((i=globalThis.chrome)!=null&&i.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}function _s(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function Sp(){var i;return(i=_s())==null?void 0:i.getCurrentSession()}function xp(){var i;return(i=Sp())==null?void 0:i.getSessionObj().media[0]}function PC(i){return new Promise((e,t)=>{xp().editTracksInfo(i,e,t)})}function OC(i){return new Promise((e,t)=>{xp().getStatus(i,e,t)})}function cT(i){return _s().setOptions({...hT(),...i})}function hT(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var su=new CC,xr=new WeakSet,ot;wC(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}ot||(ot=cast.framework,_s().addEventListener(ot.CastContextEventType.CAST_STATE_CHANGED,s=>{su.forEach(n=>{var a,o;return(o=(a=Ts.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),_s().addEventListener(ot.CastContextEventType.SESSION_STATE_CHANGED,s=>{su.forEach(n=>{var a,o;return(o=(a=Ts.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),su.forEach(s=>{var n,a;return(a=(n=Ts.get(s)).init)==null?void 0:a.call(n)}))});var Zy=0,Le,nu,jt,Sr,Dn,Ln,ys,dp,bt,os,Jy,up,fT,cp,eT,lp,NC=class extends EventTarget{constructor(i){super(),ie(this,bt),ie(this,Le),ie(this,nu),ie(this,jt),ie(this,Sr),ie(this,Dn,"disconnected"),ie(this,Ln,!1),ie(this,ys,new Set),ie(this,dp,new WeakMap),Q(this,Le,i),su.add(this),Ts.set(this,{init:()=>Ue(this,bt,cp).call(this),onCastStateChanged:()=>Ue(this,bt,up).call(this),onSessionStateChanged:()=>Ue(this,bt,fT).call(this),getCastPlayer:()=>I(this,bt,os)}),Ue(this,bt,cp).call(this)}get state(){return I(this,Dn)}async watchAvailability(i){if(I(this,Le).disableRemotePlayback)throw new op("disableRemotePlayback attribute is present.");return I(this,dp).set(i,++Zy),I(this,ys).add(i),Zy}async cancelWatchAvailability(i){if(I(this,Le).disableRemotePlayback)throw new op("disableRemotePlayback attribute is present.");i?I(this,ys).delete(i):I(this,ys).clear()}async prompt(){var i,e,t,r;if(I(this,Le).disableRemotePlayback)throw new op("disableRemotePlayback attribute is present.");if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable))throw new kC("The RemotePlayback API is disabled on this platform.");let s=xr.has(I(this,Le));xr.add(I(this,Le)),cT(I(this,Le).castOptions),Object.entries(I(this,Sr)).forEach(([n,a])=>{I(this,jt).controller.addEventListener(n,a)});try{await _s().requestSession()}catch(n){if(n==="cancel"){s||xr.delete(I(this,Le));return}throw new Error(n)}(r=(t=Ts.get(I(this,Le)))==null?void 0:t.loadOnPrompt)==null||r.call(t)}};Le=new WeakMap,nu=new WeakMap,jt=new WeakMap,Sr=new WeakMap,Dn=new WeakMap,Ln=new WeakMap,ys=new WeakMap,dp=new WeakMap,bt=new WeakSet,os=function(){if(xr.has(I(this,Le)))return I(this,jt)},Jy=function(){xr.has(I(this,Le))&&(Object.entries(I(this,Sr)).forEach(([i,e])=>{I(this,jt).controller.removeEventListener(i,e)}),xr.delete(I(this,Le)),I(this,Le).muted=I(this,jt).isMuted,I(this,Le).currentTime=I(this,jt).savedPlayerState.currentTime,I(this,jt).savedPlayerState.isPaused===!1&&I(this,Le).play())},up=function(){let i=_s().getCastState();if(xr.has(I(this,Le))&&i==="CONNECTING"&&(Q(this,Dn,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,Ln)&&i!=null&&i.includes("CONNECT")){Q(this,Ln,!0);for(let e of I(this,ys))e(!0)}else if(I(this,Ln)&&(!i||i==="NO_DEVICES_AVAILABLE")){Q(this,Ln,!1);for(let e of I(this,ys))e(!1)}},fT=async function(){var i;let{SESSION_RESUMED:e}=ot.SessionState;if(_s().getSessionState()===e&&I(this,Le).castSrc===((i=xp())==null?void 0:i.media.contentId)){xr.add(I(this,Le)),Object.entries(I(this,Sr)).forEach(([t,r])=>{I(this,jt).controller.addEventListener(t,r)});try{await OC(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}I(this,Sr)[ot.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,Sr)[ot.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},cp=function(){!ot||I(this,nu)||(Q(this,nu,!0),cT(I(this,Le).castOptions),I(this,Le).textTracks.addEventListener("change",()=>Ue(this,bt,lp).call(this)),Ue(this,bt,up).call(this),Q(this,jt,new ot.RemotePlayer),new ot.RemotePlayerController(I(this,jt)),Q(this,Sr,{[ot.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(Q(this,Dn,"connected"),this.dispatchEvent(new Event("connect"))):(Ue(this,bt,Jy).call(this),Q(this,Dn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[ot.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,Le).dispatchEvent(new Event("durationchange"))},[ot.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,Le).dispatchEvent(new Event("volumechange"))},[ot.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,Le).dispatchEvent(new Event("volumechange"))},[ot.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=I(this,bt,os))!=null&&i.isMediaLoaded&&I(this,Le).dispatchEvent(new Event("timeupdate"))},[ot.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,Le).dispatchEvent(new Event("resize"))},[ot.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,Le).dispatchEvent(new Event(this.paused?"pause":"play"))},[ot.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=I(this,bt,os))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,Le).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=I(this,bt,os))==null?void 0:e.playerState]))},[ot.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=I(this,bt,os))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Ue(this,bt,eT).call(this))}}))},eT=function(){Ue(this,bt,lp).call(this)},lp=async function(){var i,e,t,r,s;if(!I(this,bt,os))return;let n=((e=(i=I(this,jt).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...I(this,Le).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=Sp())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await PC(h)}catch(h){console.error(h)}};var UC=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),ie(this,o),ie(this,r,{paused:!1}),ie(this,s,hT()),ie(this,n),ie(this,a)}get remote(){return I(this,a)?I(this,a):DC()?(this.disableRemotePlayback||MC(),Ts.set(this,{loadOnPrompt:()=>Ue(this,o,d).call(this)}),Q(this,a,new NC(this))):super.remote}attributeChangedCallback(u,c,h){if(super.attributeChangedCallback(u,c,h),u==="cast-receiver"&&h){I(this,s).receiverApplicationId=h;return}if(I(this,o,l))switch(u){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var u,c;if(!I(this,o,l))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);h.customData=this.castCustomData;let f=[...this.querySelectorAll("track")].filter(({kind:E,src:b})=>b&&(E==="subtitles"||E==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(E=>{let b=++p;m.length===0&&E.track.mode==="showing"&&m.push(b);let T=new chrome.cast.media.Track(b,chrome.cast.media.TrackType.TEXT);return T.trackContentId=E.src,T.trackContentType="text/vtt",T.subtype=E.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,T.name=E.label,T.language=E.srclang,T})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(u=super.currentTime)!=null?u:0,g.autoplay=!I(this,r).paused,g.activeTrackIds=m,await((c=Sp())==null?void 0:c.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var u;if(I(this,o,l)){I(this,o,l).isPaused&&((u=I(this,o,l).controller)==null||u.playOrPause());return}return super.play()}pause(){var u;if(I(this,o,l)){I(this,o,l).isPaused||(u=I(this,o,l).controller)==null||u.playOrPause();return}super.pause()}get castOptions(){return I(this,s)}get castReceiver(){var u;return(u=this.getAttribute("cast-receiver"))!=null?u:void 0}set castReceiver(u){this.castReceiver!=u&&this.setAttribute("cast-receiver",`${u}`)}get castSrc(){var u,c,h;return(h=(c=this.getAttribute("cast-src"))!=null?c:(u=this.querySelector("source"))==null?void 0:u.src)!=null?h:this.currentSrc}set castSrc(u){this.castSrc!=u&&this.setAttribute("cast-src",`${u}`)}get castContentType(){var u;return(u=this.getAttribute("cast-content-type"))!=null?u:void 0}set castContentType(u){this.setAttribute("cast-content-type",`${u}`)}get castStreamType(){var u,c;return(c=(u=this.getAttribute("cast-stream-type"))!=null?u:this.streamType)!=null?c:void 0}set castStreamType(u){this.setAttribute("cast-stream-type",`${u}`)}get castCustomData(){return I(this,n)}set castCustomData(u){let c=typeof u;if(!["object","undefined"].includes(c)){console.error(`castCustomData must be nullish or an object but value was of type ${c}`);return}Q(this,n,u)}get readyState(){if(I(this,o,l))switch(I(this,o,l).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 I(this,o,l)?I(this,o,l).isPaused:super.paused}get muted(){var u;return I(this,o,l)?(u=I(this,o,l))==null?void 0:u.isMuted:super.muted}set muted(u){var c;if(I(this,o,l)){(u&&!I(this,o,l).isMuted||!u&&I(this,o,l).isMuted)&&((c=I(this,o,l).controller)==null||c.muteOrUnmute());return}super.muted=u}get volume(){var u,c;return I(this,o,l)?(c=(u=I(this,o,l))==null?void 0:u.volumeLevel)!=null?c:1:super.volume}set volume(u){var c;if(I(this,o,l)){I(this,o,l).volumeLevel=+u,(c=I(this,o,l).controller)==null||c.setVolumeLevel();return}super.volume=u}get duration(){var u,c,h;return I(this,o,l)&&(u=I(this,o,l))!=null&&u.isMediaLoaded?(h=(c=I(this,o,l))==null?void 0:c.duration)!=null?h:NaN:super.duration}get currentTime(){var u,c,h;return I(this,o,l)&&(u=I(this,o,l))!=null&&u.isMediaLoaded?(h=(c=I(this,o,l))==null?void 0:c.currentTime)!=null?h:0:super.currentTime}set currentTime(u){var c;if(I(this,o,l)){I(this,o,l).currentTime=u,(c=I(this,o,l).controller)==null||c.seek();return}super.currentTime=u}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){var u,c;return(c=(u=Ts.get(this.remote))==null?void 0:u.getCastPlayer)==null?void 0:c.call(u)},d=async function(){I(this,r).paused=sp(t.prototype,this,"paused"),sp(t.prototype,this,"pause").call(this),this.muted=sp(t.prototype,this,"muted");try{await this.load()}catch(u){console.error(u)}},ke(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Eu=class extends Event{constructor(i,e){super(i),ke(this,"track"),this.track=e.track}},hp=new WeakMap;function Y(i){var e;return(e=hp.get(i))!=null?e:FC(i,{})}function FC(i,e){let t=hp.get(i);return t||hp.set(i,t={}),Object.assign(t,e)}function fp(i,e){let t=i.videoTracks;Y(e).media=i,Y(e).renditionSet||(Y(e).renditionSet=new Set);let r=Y(t).trackSet;r.add(e);let s=r.size-1;s in pp.prototype||Object.defineProperty(pp.prototype,s,{get(){return[...Y(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Eu("addtrack",{track:e}))})}function mp(i){var e;let t=(e=Y(i).media)==null?void 0:e.videoTracks;t&&(Y(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Eu("removetrack",{track:i}))}))}function BC(i){var e;let t=(e=Y(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(Y(t).changeRequested)return;Y(t).changeRequested=!0,queueMicrotask(()=>{delete Y(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var ls,ds,us,kn,Ka,pp=class extends EventTarget{constructor(){super(),ie(this,kn),ie(this,ls),ie(this,ds),ie(this,us),Y(this).trackSet=new Set}[Symbol.iterator](){return I(this,kn,Ka).values()}get length(){return I(this,kn,Ka).size}getTrackById(i){var e;return(e=[...I(this,kn,Ka)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...I(this,kn,Ka)].findIndex(i=>i.selected)}get onaddtrack(){return I(this,ls)}set onaddtrack(i){I(this,ls)&&(this.removeEventListener("addtrack",I(this,ls)),Q(this,ls,void 0)),typeof i=="function"&&(Q(this,ls,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,ds)}set onremovetrack(i){I(this,ds)&&(this.removeEventListener("removetrack",I(this,ds)),Q(this,ds,void 0)),typeof i=="function"&&(Q(this,ds,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,us)}set onchange(i){I(this,us)&&(this.removeEventListener("change",I(this,us)),Q(this,us,void 0)),typeof i=="function"&&(Q(this,us,i),this.addEventListener("change",i))}};ls=new WeakMap,ds=new WeakMap,us=new WeakMap,kn=new WeakSet,Ka=function(){return Y(this).trackSet};var bu=class extends Event{constructor(i,e){super(i),ke(this,"rendition"),this.rendition=e.rendition}};function $C(i,e){let t=Y(i).media.videoRenditions;Y(e).media=Y(i).media,Y(e).track=i;let r=Y(i).renditionSet;r.add(e);let s=r.size-1;s in gp.prototype||Object.defineProperty(gp.prototype,s,{get(){return Cn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new bu("addrendition",{rendition:e}))})}function HC(i){let e=Y(i).media.videoRenditions,t=Y(i).track;Y(t).renditionSet.delete(i),queueMicrotask(()=>{Y(i).track.selected&&e.dispatchEvent(new bu("removerendition",{rendition:i}))})}function GC(i){let e=Y(i).media.videoRenditions;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,Y(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Cn(i){return[...Y(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...Y(e).renditionSet])}var cs,hs,fs,gp=class extends EventTarget{constructor(){super(...arguments),ie(this,cs),ie(this,hs),ie(this,fs)}[Symbol.iterator](){return Cn(this).values()}get length(){return Cn(this).length}getRenditionById(i){var e;return(e=Cn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Cn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Cn(this).entries())t.selected=e===i}get onaddrendition(){return I(this,cs)}set onaddrendition(i){I(this,cs)&&(this.removeEventListener("addrendition",I(this,cs)),Q(this,cs,void 0)),typeof i=="function"&&(Q(this,cs,i),this.addEventListener("addrendition",i))}get onremoverendition(){return I(this,hs)}set onremoverendition(i){I(this,hs)&&(this.removeEventListener("removerendition",I(this,hs)),Q(this,hs,void 0)),typeof i=="function"&&(Q(this,hs,i),this.addEventListener("removerendition",i))}get onchange(){return I(this,fs)}set onchange(i){I(this,fs)&&(this.removeEventListener("change",I(this,fs)),Q(this,fs,void 0)),typeof i=="function"&&(Q(this,fs,i),this.addEventListener("change",i))}};cs=new WeakMap,hs=new WeakMap,fs=new WeakMap;var Va,KC=class{constructor(){ke(this,"src"),ke(this,"id"),ke(this,"width"),ke(this,"height"),ke(this,"bitrate"),ke(this,"frameRate"),ke(this,"codec"),ie(this,Va,!1)}get selected(){return I(this,Va)}set selected(i){I(this,Va)!==i&&(Q(this,Va,i),GC(this))}};Va=new WeakMap;var Wa,mT=class{constructor(){ke(this,"id"),ke(this,"kind"),ke(this,"label",""),ke(this,"language",""),ke(this,"sourceBuffer"),ie(this,Wa,!1)}addRendition(i,e,t,r,s,n){let a=new KC;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,$C(this,a),a}removeRendition(i){HC(i)}get selected(){return I(this,Wa)}set selected(i){I(this,Wa)!==i&&(Q(this,Wa,i),i===!0&&BC(this))}};Wa=new WeakMap;function VC(i,e){let t=Y(i).media.audioRenditions;Y(e).media=Y(i).media,Y(e).track=i;let r=Y(i).renditionSet;r.add(e);let s=r.size-1;s in vp.prototype||Object.defineProperty(vp.prototype,s,{get(){return wn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new bu("addrendition",{rendition:e}))})}function WC(i){let e=Y(i).media.audioRenditions,t=Y(i).track;Y(t).renditionSet.delete(i),queueMicrotask(()=>{Y(i).track.enabled&&e.dispatchEvent(new bu("removerendition",{rendition:i}))})}function YC(i){let e=Y(i).media.audioRenditions;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,Y(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function wn(i){return[...Y(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...Y(e).renditionSet])}var ms,ps,gs,vp=class extends EventTarget{constructor(){super(...arguments),ie(this,ms),ie(this,ps),ie(this,gs)}[Symbol.iterator](){return wn(this).values()}get length(){return wn(this).length}getRenditionById(i){var e;return(e=wn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return wn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of wn(this).entries())t.selected=e===i}get onaddrendition(){return I(this,ms)}set onaddrendition(i){I(this,ms)&&(this.removeEventListener("addrendition",I(this,ms)),Q(this,ms,void 0)),typeof i=="function"&&(Q(this,ms,i),this.addEventListener("addrendition",i))}get onremoverendition(){return I(this,ps)}set onremoverendition(i){I(this,ps)&&(this.removeEventListener("removerendition",I(this,ps)),Q(this,ps,void 0)),typeof i=="function"&&(Q(this,ps,i),this.addEventListener("removerendition",i))}get onchange(){return I(this,gs)}set onchange(i){I(this,gs)&&(this.removeEventListener("change",I(this,gs)),Q(this,gs,void 0)),typeof i=="function"&&(Q(this,gs,i),this.addEventListener("change",i))}};ms=new WeakMap,ps=new WeakMap,gs=new WeakMap;var Ya,qC=class{constructor(){ke(this,"src"),ke(this,"id"),ke(this,"bitrate"),ke(this,"codec"),ie(this,Ya,!1)}get selected(){return I(this,Ya)}set selected(i){I(this,Ya)!==i&&(Q(this,Ya,i),YC(this))}};Ya=new WeakMap;function Ep(i,e){let t=i.audioTracks;Y(e).media=i,Y(e).renditionSet||(Y(e).renditionSet=new Set);let r=Y(t).trackSet;r.add(e);let s=r.size-1;s in yp.prototype||Object.defineProperty(yp.prototype,s,{get(){return[...Y(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Eu("addtrack",{track:e}))})}function bp(i){var e;let t=(e=Y(i).media)==null?void 0:e.audioTracks;t&&(Y(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Eu("removetrack",{track:i}))}))}function jC(i){let e=Y(i).media.audioTracks;!e||Y(e).changeRequested||(Y(e).changeRequested=!0,queueMicrotask(()=>{delete Y(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var vs,Es,bs,qa,au,yp=class extends EventTarget{constructor(){super(),ie(this,qa),ie(this,vs),ie(this,Es),ie(this,bs),Y(this).trackSet=new Set}[Symbol.iterator](){return I(this,qa,au).values()}get length(){return I(this,qa,au).size}getTrackById(i){var e;return(e=[...I(this,qa,au)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return I(this,vs)}set onaddtrack(i){I(this,vs)&&(this.removeEventListener("addtrack",I(this,vs)),Q(this,vs,void 0)),typeof i=="function"&&(Q(this,vs,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,Es)}set onremovetrack(i){I(this,Es)&&(this.removeEventListener("removetrack",I(this,Es)),Q(this,Es,void 0)),typeof i=="function"&&(Q(this,Es,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,bs)}set onchange(i){I(this,bs)&&(this.removeEventListener("change",I(this,bs)),Q(this,bs,void 0)),typeof i=="function"&&(Q(this,bs,i),this.addEventListener("change",i))}};vs=new WeakMap,Es=new WeakMap,bs=new WeakMap,qa=new WeakSet,au=function(){return Y(this).trackSet};var ja,pT=class{constructor(){ke(this,"id"),ke(this,"kind"),ke(this,"label",""),ke(this,"language",""),ke(this,"sourceBuffer"),ie(this,ja,!1)}addRendition(i,e,t){let r=new qC;return r.src=i,r.codec=e,r.bitrate=t,VC(this,r),r}removeRendition(i){WC(i)}get enabled(){return I(this,ja)}set enabled(i){I(this,ja)!==i&&(Q(this,ja,i),jC(this))}};ja=new WeakMap;var tT=pu(globalThis.HTMLMediaElement,"video"),iT=pu(globalThis.HTMLMediaElement,"audio");function zC(i){if(!(i!=null&&i.prototype))return i;let e=pu(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return XC(this)}});let t=pu(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return QC(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new mT;return l.kind=n,l.label=a,l.language=o,fp(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=mp),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new pT;return l.kind=n,l.label=a,l.language=o,Ep(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=bp),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=Y(n).videoRenditions;return a||(a=new gp,Y(a).media=n,Y(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=Y(n).audioRenditions;return a||(a=new vp,Y(a).media=n,Y(n).audioRenditions=a),a};return i}function pu(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function XC(i){var e;let t=Y(i).videoTracks;if(!t&&(t=new pp,Y(i).videoTracks=t,tT)){let r=tT.call((e=i.nativeEl)!=null?e:i);for(let s of r)fp(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof mT)){for(let n of r)mp(n);return}fp(i,s.track)}),r.addEventListener("removetrack",s=>{mp(s.track)})}return t}function QC(i){var e;let t=Y(i).audioTracks;if(!t&&(t=new yp,Y(i).audioTracks=t,iT)){let r=iT.call((e=i.nativeEl)!=null?e:i);for(let s of r)Ep(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof pT)){for(let n of r)bp(n);return}Ep(i,s.track)}),r.addEventListener("removetrack",s=>{bp(s.track)})}return t}vu.push("castchange","entercast","leavecast");var C={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",PLAYBACK_TOKEN:"playback-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",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",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_INIT_TIME:"player-init-time",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"},ZC=Object.values(C),rT=SC(),sT="mux-video",Pi,za,ou,Xa,lu,du,uu,cu,hu,Qa,fu,JC=class extends ap{constructor(){super(),ie(this,Qa),ie(this,Pi),ie(this,za),ie(this,ou),ie(this,Xa,{}),ie(this,lu,{}),ie(this,du),ie(this,uu),ie(this,cu),ie(this,hu),Q(this,ou,eu())}static get NAME(){return sT}static get VERSION(){return rT}static get observedAttributes(){var i;return[...ZC,...(i=ap.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(C.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?In.includes(i)?this.setAttribute(C.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${In.join()}`):this.removeAttribute(C.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(C.PLAYER_INIT_TIME)?+this.getAttribute(C.PLAYER_INIT_TIME):I(this,ou)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(C.PLAYER_INIT_TIME):this.setAttribute(C.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=I(this,cu))!=null?i:sT}set playerSoftwareName(i){Q(this,cu,i)}get playerSoftwareVersion(){var i;return(i=I(this,uu))!=null?i:rT}set playerSoftwareVersion(i){Q(this,uu,i)}get _hls(){var i;return(i=I(this,Pi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=ep(this.nativeEl))!=null?i:null}get errorTranslator(){return I(this,hu)}set errorTranslator(i){Q(this,hu,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(C.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(C.TYPE,i):this.removeAttribute(C.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(C.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(C.DEBUG,""):this.removeAttribute(C.DEBUG))}get disableTracking(){return this.hasAttribute(C.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(C.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(C.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(C.DISABLE_COOKIES,""):this.removeAttribute(C.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(C.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(C.START_TIME):this.setAttribute(C.START_TIME,`${i}`))}get playbackId(){var i;return this.hasAttribute(C.PLAYBACK_ID)?this.getAttribute(C.PLAYBACK_ID):(i=Jm(this.src))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(C.PLAYBACK_ID,i):this.removeAttribute(C.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(C.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(C.MAX_RESOLUTION,i):this.removeAttribute(C.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(C.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(C.MIN_RESOLUTION,i):this.removeAttribute(C.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(C.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(C.RENDITION_ORDER,i):this.removeAttribute(C.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(C.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(C.PROGRAM_START_TIME):this.setAttribute(C.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(C.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(C.PROGRAM_END_TIME):this.setAttribute(C.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){let i=this.getAttribute(C.ASSET_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetStartTime(i){i==null?this.removeAttribute(C.ASSET_START_TIME):this.setAttribute(C.ASSET_START_TIME,`${i}`)}get assetEndTime(){let i=this.getAttribute(C.ASSET_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetEndTime(i){i==null?this.removeAttribute(C.ASSET_END_TIME):this.setAttribute(C.ASSET_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(C.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(C.CUSTOM_DOMAIN,i):this.removeAttribute(C.CUSTOM_DOMAIN))}get drmToken(){var i;return(i=this.getAttribute(C.DRM_TOKEN))!=null?i:void 0}set drmToken(i){i!==this.drmToken&&(i?this.setAttribute(C.DRM_TOKEN,i):this.removeAttribute(C.DRM_TOKEN))}get playbackToken(){var i,e,t,r;if(this.hasAttribute(C.PLAYBACK_TOKEN))return(i=this.getAttribute(C.PLAYBACK_TOKEN))!=null?i:void 0;if(this.hasAttribute(C.PLAYBACK_ID)){let[,s]=Qd((e=this.playbackId)!=null?e:"");return(t=new URLSearchParams(s).get("token"))!=null?t:void 0}if(this.src)return(r=new URLSearchParams(this.src).get("token"))!=null?r:void 0}set playbackToken(i){i!==this.playbackToken&&(i?this.setAttribute(C.PLAYBACK_TOKEN,i):this.removeAttribute(C.PLAYBACK_TOKEN))}get tokens(){let i=this.getAttribute(C.PLAYBACK_TOKEN),e=this.getAttribute(C.DRM_TOKEN);return{...I(this,lu),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{}}}set tokens(i){Q(this,lu,i!=null?i:{})}get ended(){return ip(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(C.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(C.ENV_KEY,i):this.removeAttribute(C.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(C.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(C.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(C.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(C.STREAM_TYPE))!=null?i:Xd(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(C.STREAM_TYPE,i):this.removeAttribute(C.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(C.TARGET_LIVE_WINDOW)?+this.getAttribute(C.TARGET_LIVE_WINDOW):$y(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(C.TARGET_LIVE_WINDOW):this.setAttribute(C.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(C.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return Hy(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(C.LIVE_EDGE_OFFSET))return+this.getAttribute(C.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.liveEdgeOffset&&(i==null?this.removeAttribute(C.LIVE_EDGE_OFFSET):this.setAttribute(C.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return iu(this.nativeEl)}async addCuePoints(i){return jm(this.nativeEl,i)}get activeCuePoint(){return zm(this.nativeEl)}get cuePoints(){return Dy(this.nativeEl)}async addChapters(i){return Qm(this.nativeEl,i)}get activeChapter(){return Zm(this.nativeEl)}get chapters(){return Py(this.nativeEl)}getStartDate(){return Oy(this.nativeEl,this._hls)}get currentPdt(){return Ny(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(C.PREFER_PLAYBACK);if(i===qt.MSE||i===qt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===qt.MSE||i===qt.NATIVE?this.setAttribute(C.PREFER_PLAYBACK,i):this.removeAttribute(C.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![C.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...I(this,Xa)}}set metadata(i){Q(this,Xa,i!=null?i:{}),this.mux&&this.mux.emit("hb",I(this,Xa))}get _hlsConfig(){return I(this,du)}set _hlsConfig(i){Q(this,du,i)}load(){Q(this,Pi,Vy(this,this.nativeEl,I(this,Pi)))}unload(){rp(this.nativeEl,I(this,Pi)),Q(this,Pi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(ap.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case C.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case C.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Ue(this,Qa,fu).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Ue(this,Qa,fu).call(this));break}case"autoplay":if(t===e)break;(r=I(this,Pi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=I(this,Pi))==null||s.setPreload(t);break;case C.PLAYBACK_ID:this.src=Ga(this);break;case C.DEBUG:{let n=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=n);break}case C.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case C.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case C.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!I(this,Pi)&&Ue(this,Qa,fu).call(this)}disconnectedCallback(){this.unload()}};Pi=new WeakMap,za=new WeakMap,ou=new WeakMap,Xa=new WeakMap,lu=new WeakMap,du=new WeakMap,uu=new WeakMap,cu=new WeakMap,hu=new WeakMap,Qa=new WeakSet,fu=async function(){I(this,za)||(await Q(this,za,Promise.resolve()),Q(this,za,null),this.load())};var mu,Tp=class extends UC(zC(JC)){constructor(){super(...arguments),ie(this,mu)}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var i;return(i=I(this,mu))!=null?i:this.muxCastCustomData}set castCustomData(i){Q(this,mu,i)}};mu=new WeakMap;np.customElements.get("mux-video")||(np.customElements.define("mux-video",Tp),np.MuxVideoElement=Tp);var gT=Tp;function vT(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${yu(t)}: ${r}; `)}),e?e.trim():void 0}function yu(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Tu(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Rt(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function Rp(i){let e=ew(i).toString();return e?"?"+e:""}function ew(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}var Ip=(i,e)=>!i||!e?!1:i.contains(e)?!0:Ip(i,e.getRootNode().host);var ET="mux.com",tw=()=>{try{return"3.2.4"}catch{}return"UNKNOWN"},iw=tw(),Au=()=>iw,bT=(i,{token:e,customDomain:t=ET,thumbnailTime:r,programTime:s}={})=>{var o;let n=e==null?r:void 0,{aud:a}=(o=Ar(e))!=null?o:{};if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${Rp({token:e,time:n,program_time:s})}`},yT=(i,{token:e,customDomain:t=ET,programStartTime:r,programEndTime:s}={})=>{var a;let{aud:n}=(a=Ar(e))!=null?a:{};if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${Rp({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Za=i=>{if(i){if([Re.LIVE,Re.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return Re.LIVE}};var rw={crossorigin:"crossOrigin",playsinline:"playsInline"};function TT(i){var e;return(e=rw[i])!=null?e:Tu(i)}var As,Ss,It,_u=class{constructor(e,t){kt(this,As);kt(this,Ss);kt(this,It,[]);$t(this,As,e),$t(this,Ss,t)}[Symbol.iterator](){return _e(this,It).values()}get length(){return _e(this,It).length}get value(){var e;return(e=_e(this,It).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&($t(this,It,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return _e(this,It)[e]}values(){return _e(this,It).values()}keys(){return _e(this,It).keys()}forEach(e){_e(this,It).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||_e(this,It).push(s)}),!(this.value===""&&!((t=_e(this,As))!=null&&t.hasAttribute(`${_e(this,Ss)}`)))&&((r=_e(this,As))==null||r.setAttribute(`${_e(this,Ss)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{_e(this,It).splice(_e(this,It).indexOf(r),1)}),(t=_e(this,As))==null||t.setAttribute(`${_e(this,Ss)}`,`${this.value}`)}contains(e){return _e(this,It).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};As=new WeakMap,Ss=new WeakMap,It=new WeakMap;var _T=`[mux-player ${Au()}]`;function Oi(...i){console.warn(_T,...i)}function Ut(...i){console.error(_T,...i)}function Lp(i){var t;let e=(t=i.message)!=null?t:"";i.context&&(e+=` ${i.context}`),i.file&&(e+=` ${j("Read more: ")}
1317
+ https://github.com/muxinc/elements/blob/main/errors/${i.file}`),Oi(e)}var At={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},xs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},ST=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),sw=vu.filter(i=>i!=="error"),nw=Object.values(At).filter(i=>![At.PLAYSINLINE].includes(i)),aw=Object.values(xs),kp=class extends Ct.HTMLElement{static get observedAttributes(){return[...nw,...aw]}constructor(){super()}init(){sw.forEach(e=>{var t;(t=this.media)==null||t.addEventListener(e,r=>{this.dispatchEvent(new Event(r.type))})})}attributeChangedCallback(e,t,r){var s,n;switch(e){case xs.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case xs.VOLUME:{let a=(s=Rt(r))!=null?s:1;this.media&&(this.media.volume=a);return}case xs.PLAYBACKRATE:{let a=(n=Rt(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}load(){var e;(e=this.media)==null||e.load()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:ST}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:ST}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentSrc(){var e,t;return(t=(e=this.media)==null?void 0:e.currentSrc)!=null?t:""}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=Rt(this.getAttribute(xs.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(xs.PLAYBACKRATE,`${e}`):this.removeAttribute(xs.PLAYBACKRATE)}get crossOrigin(){return Ja(this,At.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(At.CROSSORIGIN,`${e}`)}get autoplay(){return Ja(this,At.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(At.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(At.AUTOPLAY)}get loop(){return Ja(this,At.LOOP)!=null}set loop(e){e?this.setAttribute(At.LOOP,""):this.removeAttribute(At.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return Ja(this,At.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(At.MUTED,""):this.removeAttribute(At.MUTED)}get playsInline(){return Ja(this,At.PLAYSINLINE)!=null}set playsInline(e){Ut("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(At.PRELOAD,e):this.removeAttribute(At.PRELOAD)}};function Ja(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Cp=kp;var kT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(kT(i,e,"read from private field"),t?t.call(i):e.get(i)),Ni=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},tr=(i,e,t,r)=>(kT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,Su,Rs,eo,Rr,Ir,Lr,Is,Pn,xu,ci,xT=1,RT=0,ow=1,lw={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Lt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Lt?s.element[s.attributeName]=n:s.value=n}}}},ir=class extends R.DocumentFragment{constructor(e,t,r=lw){var s;super(),Ni(this,Mn,void 0),Ni(this,Su,void 0),this.append(e.content.cloneNode(!0)),tr(this,Mn,CT(this)),tr(this,Su,r),(s=r.createCallback)==null||s.call(r,this,de(this,Mn),t),r.processCallback(this,de(this,Mn),t)}update(e){de(this,Su).processCallback(this,de(this,Mn),e)}};Mn=new WeakMap;Su=new WeakMap;var CT=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new wp;for([t,r]of LT(s.value))if(!t)n.append(r);else{let a=new Lt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===xT&&!(s instanceof HTMLTemplateElement))CT(s,e);else{let n=s.data;if(s.nodeType===xT||n.includes("{{")){let a=[];if(n)for([t,r]of LT(n))if(!t)a.push(new Text(r));else{let o=new rr(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){let o=new to(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},IT={},LT=i=>{let e="",t=0,r=IT[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([RT,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([ow,e.trim()]),e="",s++):e+=n||"";return e&&r.push([RT,(t>0?"{{":"")+e]),IT[i]=r},dw=11,Ru=class{get value(){return""}set value(e){}toString(){return this.value}},wT=new WeakMap,wp=class{constructor(){Ni(this,Rs,[])}[Symbol.iterator](){return de(this,Rs).values()}get length(){return de(this,Rs).length}item(e){return de(this,Rs)[e]}append(...e){for(let t of e)t instanceof Lt&&wT.set(t,this),de(this,Rs).push(t)}toString(){return de(this,Rs).join("")}};Rs=new WeakMap;var Lt=class extends Ru{constructor(e,t,r){super(),Ni(this,Is),Ni(this,eo,""),Ni(this,Rr,void 0),Ni(this,Ir,void 0),Ni(this,Lr,void 0),tr(this,Rr,e),tr(this,Ir,t),tr(this,Lr,r)}get attributeName(){return de(this,Ir)}get attributeNamespace(){return de(this,Lr)}get element(){return de(this,Rr)}get value(){return de(this,eo)}set value(e){de(this,eo)!==e&&(tr(this,eo,e),!de(this,Is,Pn)||de(this,Is,Pn).length===1?e==null?de(this,Rr).removeAttributeNS(de(this,Lr),de(this,Ir)):de(this,Rr).setAttributeNS(de(this,Lr),de(this,Ir),e):de(this,Rr).setAttributeNS(de(this,Lr),de(this,Ir),de(this,Is,Pn).toString()))}get booleanValue(){return de(this,Rr).hasAttributeNS(de(this,Lr),de(this,Ir))}set booleanValue(e){if(!de(this,Is,Pn)||de(this,Is,Pn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};eo=new WeakMap;Rr=new WeakMap;Ir=new WeakMap;Lr=new WeakMap;Is=new WeakSet;Pn=function(){return wT.get(this)};var rr=class extends Ru{constructor(e,t){super(),Ni(this,xu,void 0),Ni(this,ci,void 0),tr(this,xu,e),tr(this,ci,t?[...t]:[new Text])}get replacementNodes(){return de(this,ci)}get parentNode(){return de(this,xu)}get nextSibling(){return de(this,ci)[de(this,ci).length-1].nextSibling}get previousSibling(){return de(this,ci)[0].previousSibling}get value(){return de(this,ci).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===dw?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),tr(this,ci,uw(de(this,ci)[0].parentNode,de(this,ci),t,this.nextSibling))}};xu=new WeakMap;ci=new WeakMap;var to=class extends rr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}};function uw(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var DT={string:i=>String(i)},Lu=class{constructor(e){this.template=e,this.state=void 0}},Ls=new WeakMap,ks=new WeakMap,Dp={partial:(i,e)=>{e[i.expression]=new Lu(i.template)},if:(i,e)=>{var t;if(PT(i.expression,e))if(Ls.get(i)!==i.template){Ls.set(i,i.template);let r=new ir(i.template,e,ku);i.replace(r),ks.set(i,r)}else(t=ks.get(i))==null||t.update(e);else i.replace(""),Ls.delete(i),ks.delete(i)}},cw=Object.keys(Dp),ku={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof to){if(!a.directive){let l=cw.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Dp[a.directive])==null||r.call(Dp,a,t);continue}let o=PT(n,t);if(o instanceof Lu){Ls.get(a)!==o.template?(Ls.set(a,o.template),o=new ir(o.template,o.state,ku),a.value=o,ks.set(a,o)):(s=ks.get(a))==null||s.update(o.state);continue}o?(a instanceof Lt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Lt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Ls.delete(a),ks.delete(a))):a instanceof Lt?a.value=void 0:(a.value=void 0,Ls.delete(a),ks.delete(a))}}},MT={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=DT[e])==null?void 0:t.call(DT,i)}};function hw(i){return fw(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function PT(i,e={}){var t,r,s,n,a,o,l;let d=hw(i);if(d.length===0||d.some(({type:u})=>!u))return io(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return io(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=ro(g,e))}return u}if(d.length===1)return Iu(d[0])?ro(d[0].token,e):io(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=MT[u];if(!c||!Iu(d[1]))return io(i);let h=ro(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=MT[u];if(!c||!Iu(d[0])||!Iu(d[2]))return io(i);let h=ro(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=ro(d[2].token,e);return c(h,f)}}function io(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Iu({type:i}){return["number","boolean","string","param"].includes(i)}function ro(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):wo(i)?parseFloat(i):e[i]}function fw(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Fp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Op=(i,e,t)=>(Fp(i,e,"read from private field"),t?t.call(i):e.get(i)),so=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Cs=(i,e,t,r)=>(Fp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mp=(i,e,t)=>(Fp(i,e,"access private method"),t),On,Cu,Nn,Np,OT,wu,Up,Pp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},NT=F.createElement("template");NT.innerHTML=`
1318
1318
  <style>
1319
1319
  :host {
1320
1320
  display: inline-block;
@@ -1344,7 +1344,7 @@ https://github.com/muxinc/elements/blob/main/errors/${i.file}`),Oi(e)}var At={AU
1344
1344
  display: none;
1345
1345
  }
1346
1346
  </style>
1347
- `;var ws=class extends R.HTMLElement{constructor(){super(),no(this,Mp),no(this,Cu),no(this,On,void 0),no(this,ku,void 0),no(this,Nn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(wp[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Ki.BREAKPOINTS_COMPUTED,this.render),Cp(this,Mp,PT).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Dp(this,On))!=null?e:this.constructor.template}set template(e){Cs(this,Nn,null),Cs(this,On,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>wp[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=wp[a.name])!=null?r:jg(a.name),{value:l}=a;l!=null?(Do(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Cp(this,Cu,Pp).call(this)}connectedCallback(){Cp(this,Cu,Pp).call(this)}createRenderer(){this.template&&this.template!==Dp(this,ku)&&(Cs(this,ku,this.template),this.renderer=new ir(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(OT.content.cloneNode(!0),this.renderer))}render(){var e;if((e=this.renderer)==null||e.update(this.props),this.renderRoot.isConnected){let{style:t}=we(this.renderRoot,":host");t.visibility==="hidden"&&t.removeProperty("visibility")}}};On=new WeakMap;ku=new WeakMap;Nn=new WeakMap;Mp=new WeakSet;PT=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Cu=new WeakSet;Pp=function(){var i;let e=this.getAttribute("template");if(!e||e===Dp(this,Nn))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){Cs(this,Nn,e),Cs(this,On,r),this.createRenderer();return}fw(e)&&(Cs(this,Nn,e),mw(e).then(s=>{let n=F.createElement("template");n.innerHTML=s,Cs(this,On,n),this.createRenderer()}).catch(console.error))};ws.observedAttributes=["template"];ws.processor=Lu;function fw(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function mw(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}R.customElements.get("media-theme")||R.customElements.define("media-theme",ws);var NT=`:host {
1347
+ `;var ws=class extends R.HTMLElement{constructor(){super(),so(this,Np),so(this,wu),so(this,On,void 0),so(this,Cu,void 0),so(this,Nn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Pp[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Ki.BREAKPOINTS_COMPUTED,this.render),Mp(this,Np,OT).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Op(this,On))!=null?e:this.constructor.template}set template(e){Cs(this,Nn,null),Cs(this,On,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Pp[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Pp[a.name])!=null?r:Qg(a.name),{value:l}=a;l!=null?(wo(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Mp(this,wu,Up).call(this)}connectedCallback(){Mp(this,wu,Up).call(this)}createRenderer(){this.template&&this.template!==Op(this,Cu)&&(Cs(this,Cu,this.template),this.renderer=new ir(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(NT.content.cloneNode(!0),this.renderer))}render(){var e;if((e=this.renderer)==null||e.update(this.props),this.renderRoot.isConnected){let{style:t}=De(this.renderRoot,":host");t.visibility==="hidden"&&t.removeProperty("visibility")}}};On=new WeakMap;Cu=new WeakMap;Nn=new WeakMap;Np=new WeakSet;OT=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};wu=new WeakSet;Up=function(){var i;let e=this.getAttribute("template");if(!e||e===Op(this,Nn))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){Cs(this,Nn,e),Cs(this,On,r),this.createRenderer();return}mw(e)&&(Cs(this,Nn,e),pw(e).then(s=>{let n=F.createElement("template");n.innerHTML=s,Cs(this,On,n),this.createRenderer()}).catch(console.error))};ws.observedAttributes=["template"];ws.processor=ku;function mw(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function pw(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}R.customElements.get("media-theme")||R.customElements.define("media-theme",ws);var UT=`:host {
1348
1348
  --media-control-display: var(--controls);
1349
1349
  --media-loading-indicator-display: var(--loading-indicator);
1350
1350
  --media-dialog-display: var(--dialog);
@@ -1495,23 +1495,23 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1495
1495
  :host([no-tooltips]) {
1496
1496
  --media-tooltip-display: none;
1497
1497
  }
1498
- `;var ao=new WeakMap,Up=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=ao.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=ao.get(this.element);t&&t.delete(this.type)}}static for(e){ao.has(e.element)||ao.set(e.element,new Map);let t=e.attributeName.slice(2),r=ao.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function gw(i,e){return i instanceof Lt&&i.attributeName.startsWith("on")?(Up.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function vw(i,e){return e instanceof wu&&i instanceof rr?(e.renderInto(i),!0):!1}function Ew(i,e){return e instanceof DocumentFragment&&i instanceof rr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function bw(i,e){if(i instanceof Lt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function yw(i,e){if(i instanceof Lt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function Tw(i,e){if(typeof e=="boolean"&&i instanceof Lt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function _w(i,e){return e===!1&&i instanceof rr?(i.replace(""),!0):!1}function Aw(i,e){yw(i,e)||Tw(i,e)||gw(i,e)||_w(i,e)||vw(i,e)||Ew(i,e)||bw(i,e)}var Np=new Map,UT=new WeakMap,FT=new WeakMap,wu=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(Np.has(this.stringsKey))return Np.get(this.stringsKey);{let e=Hs.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),Np.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(UT.get(e)!==t){UT.set(e,t);let n=new ir(t,this.values,this.processor);FT.set(e,n),e instanceof rr?e.replace(...n.children):e.appendChild(n);return}let r=FT.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},Sw={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";Aw(n,a)}}}};function oo(i,...e){return new wu(i,e,Sw)}function BT(i,e){i.renderInto(e)}var xw=i=>{let{tokens:e}=i;return e.drm?":host { --_cast-button-drm-display: none; }":""},$T=i=>oo`
1498
+ `;var no=new WeakMap,$p=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=no.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=no.get(this.element);t&&t.delete(this.type)}}static for(e){no.has(e.element)||no.set(e.element,new Map);let t=e.attributeName.slice(2),r=no.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function vw(i,e){return i instanceof Lt&&i.attributeName.startsWith("on")?($p.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function Ew(i,e){return e instanceof Du&&i instanceof rr?(e.renderInto(i),!0):!1}function bw(i,e){return e instanceof DocumentFragment&&i instanceof rr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function yw(i,e){if(i instanceof Lt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function Tw(i,e){if(i instanceof Lt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function _w(i,e){if(typeof e=="boolean"&&i instanceof Lt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function Aw(i,e){return e===!1&&i instanceof rr?(i.replace(""),!0):!1}function Sw(i,e){Tw(i,e)||_w(i,e)||vw(i,e)||Aw(i,e)||Ew(i,e)||bw(i,e)||yw(i,e)}var Bp=new Map,FT=new WeakMap,BT=new WeakMap,Du=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(Bp.has(this.stringsKey))return Bp.get(this.stringsKey);{let e=Hs.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),Bp.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(FT.get(e)!==t){FT.set(e,t);let n=new ir(t,this.values,this.processor);BT.set(e,n),e instanceof rr?e.replace(...n.children):e.appendChild(n);return}let r=BT.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},xw={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";Sw(n,a)}}}};function ao(i,...e){return new Du(i,e,xw)}function $T(i,e){i.renderInto(e)}var Rw=i=>{let{tokens:e}=i;return e.drm?":host { --_cast-button-drm-display: none; }":""},HT=i=>ao`
1499
1499
  <style>
1500
- ${xw(i)}
1501
- ${NT}
1500
+ ${Rw(i)}
1501
+ ${UT}
1502
1502
  </style>
1503
- ${kw(i)}
1504
- `,Rw=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Ja(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},Iw={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",MENU_BUTTON:"menu-button",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},Lw=Object.values(Iw).join(", "),kw=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,b,T,_,A,x,S,w,M,k,P,N,B,X,z,V,ne;return oo`
1503
+ ${Cw(i)}
1504
+ `,Iw=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Za(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},Lw={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",MENU_BUTTON:"menu-button",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},kw=Object.values(Lw).join(", "),Cw=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,b,T,_,A,x,S,w,M,k,P,N,B,X,z,V,ne;return ao`
1505
1505
  <media-theme
1506
1506
  template="${i.themeTemplate||!1}"
1507
1507
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1508
- hotkeys="${Rw(i)||!1}"
1508
+ hotkeys="${Iw(i)||!1}"
1509
1509
  nohotkeys="${i.noHotKeys||!i.hasSrc||!1}"
1510
1510
  noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(Re.LIVE))&&i.targetLiveWindow!==0}"
1511
1511
  novolumepref="${i.novolumepref||!1}"
1512
1512
  disabled="${!i.hasSrc||i.isDialogOpen}"
1513
1513
  audio="${(r=i.audio)!=null?r:!1}"
1514
- style="${(s=gT({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1514
+ style="${(s=vT({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1515
1515
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1516
1516
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1517
1517
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
@@ -1520,14 +1520,14 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1520
1520
  defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1521
1521
  hideduration="${(u=i.hideDuration)!=null?u:!1}"
1522
1522
  title="${(c=i.title)!=null?c:!1}"
1523
- exportparts="${Lw}"
1523
+ exportparts="${kw}"
1524
1524
  onclose="${i.onCloseErrorDialog}"
1525
1525
  onfocusin="${i.onFocusInErrorDialog}"
1526
1526
  >
1527
1527
  <mux-video
1528
1528
  slot="media"
1529
1529
  target-live-window="${(h=i.targetLiveWindow)!=null?h:!1}"
1530
- stream-type="${(f=Ja(i.streamType))!=null?f:!1}"
1530
+ stream-type="${(f=Za(i.streamType))!=null?f:!1}"
1531
1531
  crossorigin="${(m=i.crossOrigin)!=null?m:""}"
1532
1532
  playsinline
1533
1533
  autoplay="${(p=i.autoplay)!=null?p:!1}"
@@ -1546,13 +1546,13 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1546
1546
  player-software-version="${(P=i.playerSoftwareVersion)!=null?P:!1}"
1547
1547
  env-key="${(N=i.envKey)!=null?N:!1}"
1548
1548
  custom-domain="${(B=i.customDomain)!=null?B:!1}"
1549
- src="${i.src?i.src:i.playbackId?Ka(i):!1}"
1550
- cast-src="${i.src?i.src:i.playbackId?Ka(i):!1}"
1549
+ src="${i.src?i.src:i.playbackId?Ga(i):!1}"
1550
+ cast-src="${i.src?i.src:i.playbackId?Ga(i):!1}"
1551
1551
  cast-receiver="${(X=i.castReceiver)!=null?X:!1}"
1552
1552
  drm-token="${(V=(z=i.tokens)==null?void 0:z.drm)!=null?V:!1}"
1553
1553
  exportparts="video"
1554
1554
  >
1555
- ${i.storyboard?oo`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:oo``}
1555
+ ${i.storyboard?ao`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:ao``}
1556
1556
  <slot></slot>
1557
1557
  </mux-video>
1558
1558
  <slot name="poster" slot="poster">
@@ -1564,7 +1564,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1564
1564
  ></media-poster-image>
1565
1565
  </slot>
1566
1566
  </media-theme>
1567
- `};var HT=i=>i.charAt(0).toUpperCase()+i.slice(1),Cw=(i,e=!1)=>{var t,r;if(i.muxCode){let s=HT((t=i.errorCategory)!=null?t:"video"),n=Ha((r=i.errorCategory)!=null?r:Oe.VIDEO);if(i.muxCode===Z.NETWORK_OFFLINE)return j("Your device appears to be offline",e);if(i.muxCode===Z.NETWORK_TOKEN_EXPIRED)return j("{category} URL has expired",e).format({category:s});if([Z.NETWORK_TOKEN_SUB_MISMATCH,Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING,Z.NETWORK_TOKEN_MALFORMED].includes(i.muxCode))return j("{category} URL is formatted incorrectly",e).format({category:s});if(i.muxCode===Z.NETWORK_TOKEN_MISSING)return j("Invalid {categoryName} URL",e).format({categoryName:n});if(i.muxCode===Z.NETWORK_NOT_FOUND)return j("{category} does not exist",e).format({category:s});if(i.muxCode===Z.NETWORK_NOT_READY)return j("{category} is not currently available",e).format({category:s})}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return j("Network Error",e);if(i.code===K.MEDIA_ERR_DECODE)return j("Media Error",e);if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return j("Source Not Supported",e)}return j("Error",e)},ww=(i,e=!1)=>{var t,r;if(i.muxCode){let s=HT((t=i.errorCategory)!=null?t:"video"),n=Ha((r=i.errorCategory)!=null?r:Oe.VIDEO);return i.muxCode===Z.NETWORK_OFFLINE?j("Check your internet connection and try reloading this video.",e):i.muxCode===Z.NETWORK_TOKEN_EXPIRED?j("The video\u2019s secured {tokenNamePrefix}-token has expired.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_TOKEN_SUB_MISMATCH?j("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_TOKEN_MALFORMED?j("{category} URL is formatted incorrectly",e).format({category:s}):[Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode)?j("The {tokenNamePrefix}-token is formatted with incorrect information.",e).format({tokenNamePrefix:n}):[Z.NETWORK_TOKEN_MISSING,Z.NETWORK_INVALID_URL].includes(i.muxCode)?j("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_NOT_FOUND?"":i.muxCode===Z.NETWORK_NOT_READY?j("The live stream or video file are not yet ready.",e):i.message}return i.code&&(i.code===K.MEDIA_ERR_NETWORK||i.code===K.MEDIA_ERR_DECODE||i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED),i.message},GT=(i,e=!1)=>{let t=Cw(i,e),r=ww(i,e);return{title:t,message:r}},Dw=i=>{if(i.muxCode){if(i.muxCode===Z.NETWORK_TOKEN_EXPIRED)return"403-expired-token.md";if(i.muxCode===Z.NETWORK_TOKEN_MALFORMED)return"403-malformatted-token.md";if([Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode))return"403-incorrect-aud-value.md";if(i.muxCode===Z.NETWORK_TOKEN_SUB_MISMATCH)return"403-playback-id-mismatch.md";if(i.muxCode===Z.NETWORK_TOKEN_MISSING)return"missing-signed-tokens.md";if(i.muxCode===Z.NETWORK_NOT_FOUND)return"404-not-found.md";if(i.muxCode===Z.NETWORK_NOT_READY)return"412-not-playable.md"}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return"";if(i.code===K.MEDIA_ERR_DECODE)return"media-decode-error.md";if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return"media-src-not-supported.md"}return""},Fp=(i,e)=>{let t=Dw(i);return{message:i.message,context:i.context,file:t}};var KT=`<template id="media-theme-gerwig">
1567
+ `};var GT=i=>i.charAt(0).toUpperCase()+i.slice(1),ww=(i,e=!1)=>{var t,r;if(i.muxCode){let s=GT((t=i.errorCategory)!=null?t:"video"),n=$a((r=i.errorCategory)!=null?r:Ne.VIDEO);if(i.muxCode===Z.NETWORK_OFFLINE)return j("Your device appears to be offline",e);if(i.muxCode===Z.NETWORK_TOKEN_EXPIRED)return j("{category} URL has expired",e).format({category:s});if([Z.NETWORK_TOKEN_SUB_MISMATCH,Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING,Z.NETWORK_TOKEN_MALFORMED].includes(i.muxCode))return j("{category} URL is formatted incorrectly",e).format({category:s});if(i.muxCode===Z.NETWORK_TOKEN_MISSING)return j("Invalid {categoryName} URL",e).format({categoryName:n});if(i.muxCode===Z.NETWORK_NOT_FOUND)return j("{category} does not exist",e).format({category:s});if(i.muxCode===Z.NETWORK_NOT_READY)return j("{category} is not currently available",e).format({category:s})}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return j("Network Error",e);if(i.code===K.MEDIA_ERR_DECODE)return j("Media Error",e);if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return j("Source Not Supported",e)}return j("Error",e)},Dw=(i,e=!1)=>{var t,r;if(i.muxCode){let s=GT((t=i.errorCategory)!=null?t:"video"),n=$a((r=i.errorCategory)!=null?r:Ne.VIDEO);return i.muxCode===Z.NETWORK_OFFLINE?j("Check your internet connection and try reloading this video.",e):i.muxCode===Z.NETWORK_TOKEN_EXPIRED?j("The video\u2019s secured {tokenNamePrefix}-token has expired.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_TOKEN_SUB_MISMATCH?j("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_TOKEN_MALFORMED?j("{category} URL is formatted incorrectly",e).format({category:s}):[Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode)?j("The {tokenNamePrefix}-token is formatted with incorrect information.",e).format({tokenNamePrefix:n}):[Z.NETWORK_TOKEN_MISSING,Z.NETWORK_INVALID_URL].includes(i.muxCode)?j("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.",e).format({tokenNamePrefix:n}):i.muxCode===Z.NETWORK_NOT_FOUND?"":i.muxCode===Z.NETWORK_NOT_READY?j("The live stream or video file are not yet ready.",e):i.message}return i.code&&(i.code===K.MEDIA_ERR_NETWORK||i.code===K.MEDIA_ERR_DECODE||i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED),i.message},KT=(i,e=!1)=>{let t=ww(i,e),r=Dw(i,e);return{title:t,message:r}},Mw=i=>{if(i.muxCode){if(i.muxCode===Z.NETWORK_TOKEN_EXPIRED)return"403-expired-token.md";if(i.muxCode===Z.NETWORK_TOKEN_MALFORMED)return"403-malformatted-token.md";if([Z.NETWORK_TOKEN_AUD_MISMATCH,Z.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode))return"403-incorrect-aud-value.md";if(i.muxCode===Z.NETWORK_TOKEN_SUB_MISMATCH)return"403-playback-id-mismatch.md";if(i.muxCode===Z.NETWORK_TOKEN_MISSING)return"missing-signed-tokens.md";if(i.muxCode===Z.NETWORK_NOT_FOUND)return"404-not-found.md";if(i.muxCode===Z.NETWORK_NOT_READY)return"412-not-playable.md"}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return"";if(i.code===K.MEDIA_ERR_DECODE)return"media-decode-error.md";if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return"media-src-not-supported.md"}return""},Hp=(i,e)=>{let t=Mw(i);return{message:i.message,context:i.context,file:t}};var VT=`<template id="media-theme-gerwig">
1568
1568
  <style>
1569
1569
  @keyframes pre-play-hide {
1570
1570
  0% {
@@ -2571,7 +2571,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2571
2571
  <slot></slot>
2572
2572
  </media-controller>
2573
2573
  </template>
2574
- `;function VT({anchor:i,floating:e,placement:t}){let r=Pw({anchor:i,floating:e}),{x:s,y:n}=Nw(r,t);return{x:s,y:n}}function Pw({anchor:i,floating:e}){return{anchor:Ow(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Ow(i,e){var t;let r=i.getBoundingClientRect(),s=(t=e==null?void 0:e.getBoundingClientRect())!=null?t:{x:0,y:0};return{x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}function Nw({anchor:i,floating:e},t){let r=Uw(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=WT(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2,d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function WT(i){return i.split("-")[0]}function Uw(i){return["top","bottom"].includes(WT(i))?"y":"x"}var kr=class extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),this.action=e,this.relatedTarget=t}},Du=class extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),this.newState=e,this.oldState=t}};var Xp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(Xp(i,e,"read from private field"),t?t.call(i):e.get(i)),Ue=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ui=(i,e,t,r)=>(Xp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),He=(i,e,t)=>(Xp(i,e,"access private method"),t),Fi,Ms,Cr,Mu,Pu,Ps,co,Bp,YT,Uu,Ou,$p,Hp,qT,Gp,jT,Kp,zT,Un,Fn,Bn,ho,Fu,Qp,Vp,XT,Zp,QT,Wp,ZT,Jp,JT,Yp,e_,qp,t_,lo,Bu,jp,i_,uo,$u,Nu,zp;function Bi({type:i,text:e,value:t,checked:r}){let s=F.createElement("media-chrome-menu-item");s.type=i!=null?i:"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;let n=F.createElement("span");return n.textContent=e,s.append(n),s}function hi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}var r_=F.createElement("template");r_.innerHTML=`
2574
+ `;function WT({anchor:i,floating:e,placement:t}){let r=Ow({anchor:i,floating:e}),{x:s,y:n}=Uw(r,t);return{x:s,y:n}}function Ow({anchor:i,floating:e}){return{anchor:Nw(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Nw(i,e){var t;let r=i.getBoundingClientRect(),s=(t=e==null?void 0:e.getBoundingClientRect())!=null?t:{x:0,y:0};return{x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}function Uw({anchor:i,floating:e},t){let r=Fw(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=YT(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2,d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function YT(i){return i.split("-")[0]}function Fw(i){return["top","bottom"].includes(YT(i))?"y":"x"}var kr=class extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),this.action=e,this.relatedTarget=t}},Mu=class extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),this.newState=e,this.oldState=t}};var Jp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(Jp(i,e,"read from private field"),t?t.call(i):e.get(i)),Fe=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ui=(i,e,t,r)=>(Jp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),He=(i,e,t)=>(Jp(i,e,"access private method"),t),Fi,Ms,Cr,Pu,Ou,Ps,uo,Gp,qT,Fu,Nu,Kp,Vp,jT,Wp,zT,Yp,XT,Un,Fn,Bn,co,Bu,eg,qp,QT,tg,ZT,jp,JT,ig,e_,zp,t_,Xp,i_,oo,$u,Qp,r_,lo,Hu,Uu,Zp;function Bi({type:i,text:e,value:t,checked:r}){let s=F.createElement("media-chrome-menu-item");s.type=i!=null?i:"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;let n=F.createElement("span");return n.textContent=e,s.append(n),s}function hi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}var s_=F.createElement("template");s_.innerHTML=`
2575
2575
  <style>
2576
2576
  :host {
2577
2577
  font: var(--media-font,
@@ -2738,7 +2738,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2738
2738
  <slot></slot>
2739
2739
  </div>
2740
2740
  <slot name="checked-indicator" hidden></slot>
2741
- `;var Ds={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},yt=class extends R.HTMLElement{constructor(){super(),Ue(this,Bp),Ue(this,Ou),Ue(this,Hp),Ue(this,Gp),Ue(this,Kp),Ue(this,Bn),Ue(this,Fu),Ue(this,Vp),Ue(this,Zp),Ue(this,Wp),Ue(this,Jp),Ue(this,Yp),Ue(this,qp),Ue(this,lo),Ue(this,jp),Ue(this,uo),Ue(this,Nu),Ue(this,Fi,null),Ue(this,Ms,null),Ue(this,Cr,null),Ue(this,Mu,new Set),Ue(this,Pu,void 0),Ue(this,Ps,!1),Ue(this,co,null),Ue(this,Uu,()=>{let e=Se(this,Mu),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));Ui(this,Mu,t)}),Ue(this,Un,()=>{He(this,Bn,ho).call(this),He(this,Fu,Qp).call(this,!1)}),Ue(this,Fn,()=>{He(this,Bn,ho).call(this)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Ui(this,Pu,new MutationObserver(Se(this,Uu))),Se(this,Pu).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[Ds.DISABLED,Ds.HIDDEN,Ds.STYLE,Ds.ANCHOR,ue.MEDIA_CONTROLLER]}static formatMenuItemText(e,t){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":He(this,Bp,YT).call(this,e);break;case"invoke":He(this,Hp,qT).call(this,e);break;case"click":He(this,Vp,XT).call(this,e);break;case"toggle":He(this,Wp,ZT).call(this,e);break;case"focusout":He(this,Yp,e_).call(this,e);break;case"keydown":He(this,qp,t_).call(this,e);break}}connectedCallback(){var e,t;Ui(this,co,_c(this.shadowRoot,":host")),He(this,Ou,$p).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Ui(this,Fi,Uo(this)),(t=(e=Se(this,Fi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(Vi(fo(this),Se(this,Un)),Vi(this,Se(this,Fn)))}disconnectedCallback(){var e,t;Or(fo(this),Se(this,Un)),Or(this,Se(this,Fn)),this.disable(),(t=(e=Se(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ui(this,Fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===Ds.HIDDEN&&r!==t?(Se(this,Ps)||Ui(this,Ps,!0),this.hidden?He(this,Kp,zT).call(this):He(this,Gp,jT).call(this),this.dispatchEvent(new Du({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===ue.MEDIA_CONTROLLER?(t&&((n=(s=Se(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ui(this,Fi,null)),r&&this.isConnected&&(Ui(this,Fi,Uo(this)),(o=(a=Se(this,Fi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===Ds.DISABLED&&r!==t?r==null?this.enable():this.disable():e===Ds.STYLE&&r!==t&&He(this,Ou,$p).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Nr(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(Fw)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&He(this,Nu,zp).call(this,t)}focus(){if(Ui(this,Ms,jn()),this.items.length){He(this,uo,$u).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=He(this,lo,Bu).call(this,e);r&&(He(this,Nu,zp).call(this,r,r.type==="checkbox"),Se(this,Cr)&&!this.hidden&&((t=Se(this,Ms))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=He(this,lo,Bu).call(this,e))!=null?t:He(this,jp,i_).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),He(this,uo,$u).call(this,n[l]),n[l].focus()}};Fi=new WeakMap;Ms=new WeakMap;Cr=new WeakMap;Mu=new WeakMap;Pu=new WeakMap;Ps=new WeakMap;co=new WeakMap;Bp=new WeakSet;YT=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Se(this,Uu).call(this)};Uu=new WeakMap;Ou=new WeakSet;$p=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Hp=new WeakSet;qT=function(i){Ui(this,Cr,i.relatedTarget),xt(this,i.relatedTarget)||(this.hidden=!this.hidden)};Gp=new WeakSet;jT=function(){var i;(i=Se(this,Cr))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),Vi(fo(this),Se(this,Un)),Vi(this,Se(this,Fn))};Kp=new WeakSet;zT=function(){var i;(i=Se(this,Cr))==null||i.setAttribute("aria-expanded","false"),Or(fo(this),Se(this,Un)),Or(this,Se(this,Fn))};Un=new WeakMap;Fn=new WeakMap;Bn=new WeakSet;ho=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=VT({anchor:this.anchorElement,floating:this,placement:"top-start"});i!=null||(i=this.offsetWidth);let s=fo(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=Se(this,co);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);let l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};Fu=new WeakSet;Qp=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Se(this,co);if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),He(this,Bn,ho).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),He(this,Bn,ho).call(this);r.removeProperty("--media-menu-transition-in")};Vp=new WeakSet;XT=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Se(this,Zp,QT))){(e=Se(this,Ms))==null||e.focus(),this.hidden=!0;return}let t=He(this,lo,Bu).call(this,i);!t||t.hasAttribute("disabled")||(He(this,uo,$u).call(this,t),this.handleSelect(i))};Zp=new WeakSet;QT=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};Wp=new WeakSet;ZT=function(i){if(i.target===this)return;He(this,Jp,JT).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new kr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);He(this,Fu,Qp).call(this,!0)};Jp=new WeakSet;JT=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};Yp=new WeakSet;e_=function(i){var e;xt(this,i.relatedTarget)||(Se(this,Ps)&&((e=Se(this,Ms))==null||e.focus()),Se(this,Cr)&&Se(this,Cr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};qp=new WeakSet;t_=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Se(this,Ps)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Se(this,Ms))==null||n.focus(),Se(this,Ps)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};lo=new WeakSet;Bu=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};jp=new WeakSet;i_=function(){return this.items.find(i=>i.tabIndex===0)};uo=new WeakSet;$u=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Nu=new WeakSet;zp=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};yt.template=r_;function Fw(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function fo(i){var e;return(e=i.getAttribute("bounds")?mi(i,`#${i.getAttribute("bounds")}`):We(i)||i.parentElement)!=null?e:i}R.customElements.get("media-chrome-menu")||R.customElements.define("media-chrome-menu",yt);var ng=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Hi=(i,e,t)=>(ng(i,e,"read from private field"),t?t.call(i):e.get(i)),sr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},eg=(i,e,t,r)=>(ng(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),$i=(i,e,t)=>(ng(i,e,"access private method"),t),Hu,po,tg,s_,ag,n_,og,a_,Gi,$n,go,ig,o_,Gu,rg,l_=F.createElement("template");l_.innerHTML=`
2741
+ `;var Ds={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},yt=class extends R.HTMLElement{constructor(){super(),Fe(this,Gp),Fe(this,Nu),Fe(this,Vp),Fe(this,Wp),Fe(this,Yp),Fe(this,Bn),Fe(this,Bu),Fe(this,qp),Fe(this,tg),Fe(this,jp),Fe(this,ig),Fe(this,zp),Fe(this,Xp),Fe(this,oo),Fe(this,Qp),Fe(this,lo),Fe(this,Uu),Fe(this,Fi,null),Fe(this,Ms,null),Fe(this,Cr,null),Fe(this,Pu,new Set),Fe(this,Ou,void 0),Fe(this,Ps,!1),Fe(this,uo,null),Fe(this,Fu,()=>{let e=Se(this,Pu),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));Ui(this,Pu,t)}),Fe(this,Un,()=>{He(this,Bn,co).call(this),He(this,Bu,eg).call(this,!1)}),Fe(this,Fn,()=>{He(this,Bn,co).call(this)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Ui(this,Ou,new MutationObserver(Se(this,Fu))),Se(this,Ou).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[Ds.DISABLED,Ds.HIDDEN,Ds.STYLE,Ds.ANCHOR,ue.MEDIA_CONTROLLER]}static formatMenuItemText(e,t){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":He(this,Gp,qT).call(this,e);break;case"invoke":He(this,Vp,jT).call(this,e);break;case"click":He(this,qp,QT).call(this,e);break;case"toggle":He(this,jp,JT).call(this,e);break;case"focusout":He(this,zp,t_).call(this,e);break;case"keydown":He(this,Xp,i_).call(this,e);break}}connectedCallback(){var e,t;Ui(this,uo,Ac(this.shadowRoot,":host")),He(this,Nu,Kp).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Ui(this,Fi,No(this)),(t=(e=Se(this,Fi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(Vi(ho(this),Se(this,Un)),Vi(this,Se(this,Fn)))}disconnectedCallback(){var e,t;Or(ho(this),Se(this,Un)),Or(this,Se(this,Fn)),this.disable(),(t=(e=Se(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ui(this,Fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===Ds.HIDDEN&&r!==t?(Se(this,Ps)||Ui(this,Ps,!0),this.hidden?He(this,Yp,XT).call(this):He(this,Wp,zT).call(this),this.dispatchEvent(new Mu({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===ue.MEDIA_CONTROLLER?(t&&((n=(s=Se(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ui(this,Fi,null)),r&&this.isConnected&&(Ui(this,Fi,No(this)),(o=(a=Se(this,Fi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===Ds.DISABLED&&r!==t?r==null?this.enable():this.disable():e===Ds.STYLE&&r!==t&&He(this,Nu,Kp).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Nr(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(Bw)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&He(this,Uu,Zp).call(this,t)}focus(){if(Ui(this,Ms,jn()),this.items.length){He(this,lo,Hu).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=He(this,oo,$u).call(this,e);r&&(He(this,Uu,Zp).call(this,r,r.type==="checkbox"),Se(this,Cr)&&!this.hidden&&((t=Se(this,Ms))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=He(this,oo,$u).call(this,e))!=null?t:He(this,Qp,r_).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),He(this,lo,Hu).call(this,n[l]),n[l].focus()}};Fi=new WeakMap;Ms=new WeakMap;Cr=new WeakMap;Pu=new WeakMap;Ou=new WeakMap;Ps=new WeakMap;uo=new WeakMap;Gp=new WeakSet;qT=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Se(this,Fu).call(this)};Fu=new WeakMap;Nu=new WeakSet;Kp=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Vp=new WeakSet;jT=function(i){Ui(this,Cr,i.relatedTarget),xt(this,i.relatedTarget)||(this.hidden=!this.hidden)};Wp=new WeakSet;zT=function(){var i;(i=Se(this,Cr))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),Vi(ho(this),Se(this,Un)),Vi(this,Se(this,Fn))};Yp=new WeakSet;XT=function(){var i;(i=Se(this,Cr))==null||i.setAttribute("aria-expanded","false"),Or(ho(this),Se(this,Un)),Or(this,Se(this,Fn))};Un=new WeakMap;Fn=new WeakMap;Bn=new WeakSet;co=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=WT({anchor:this.anchorElement,floating:this,placement:"top-start"});i!=null||(i=this.offsetWidth);let s=ho(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=Se(this,uo);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);let l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};Bu=new WeakSet;eg=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Se(this,uo);if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),He(this,Bn,co).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),He(this,Bn,co).call(this);r.removeProperty("--media-menu-transition-in")};qp=new WeakSet;QT=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Se(this,tg,ZT))){(e=Se(this,Ms))==null||e.focus(),this.hidden=!0;return}let t=He(this,oo,$u).call(this,i);!t||t.hasAttribute("disabled")||(He(this,lo,Hu).call(this,t),this.handleSelect(i))};tg=new WeakSet;ZT=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};jp=new WeakSet;JT=function(i){if(i.target===this)return;He(this,ig,e_).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new kr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);He(this,Bu,eg).call(this,!0)};ig=new WeakSet;e_=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};zp=new WeakSet;t_=function(i){var e;xt(this,i.relatedTarget)||(Se(this,Ps)&&((e=Se(this,Ms))==null||e.focus()),Se(this,Cr)&&Se(this,Cr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Xp=new WeakSet;i_=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Se(this,Ps)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Se(this,Ms))==null||n.focus(),Se(this,Ps)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};oo=new WeakSet;$u=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};Qp=new WeakSet;r_=function(){return this.items.find(i=>i.tabIndex===0)};lo=new WeakSet;Hu=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Uu=new WeakSet;Zp=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};yt.template=s_;function Bw(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function ho(i){var e;return(e=i.getAttribute("bounds")?mi(i,`#${i.getAttribute("bounds")}`):We(i)||i.parentElement)!=null?e:i}R.customElements.get("media-chrome-menu")||R.customElements.define("media-chrome-menu",yt);var lg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Hi=(i,e,t)=>(lg(i,e,"read from private field"),t?t.call(i):e.get(i)),sr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},rg=(i,e,t,r)=>(lg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),$i=(i,e,t)=>(lg(i,e,"access private method"),t),Gu,mo,sg,n_,dg,a_,ug,o_,Gi,$n,po,ng,l_,Ku,ag,d_=F.createElement("template");d_.innerHTML=`
2742
2742
  <style>
2743
2743
  :host {
2744
2744
  transition: var(--media-menu-item-transition,
@@ -2854,7 +2854,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2854
2854
  <slot name="description"></slot>
2855
2855
  <slot name="suffix"></slot>
2856
2856
  <slot name="submenu"></slot>
2857
- `;var zt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},wr=class extends R.HTMLElement{constructor(){super(),sr(this,tg),sr(this,ag),sr(this,og),sr(this,$n),sr(this,ig),sr(this,Gu),sr(this,Hu,!1),sr(this,po,void 0),sr(this,Gi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let r=this.shadowRoot.querySelector('slot[name="description"]'),s=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=s==null?void 0:s.dataset.description)!=null?t:s==null?void 0:s.text,a=F.createElement("span");a.textContent=n!=null?n:"",r.replaceChildren(a)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[zt.TYPE,zt.DISABLED,zt.CHECKED,zt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),mo(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":$i(this,tg,s_).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":$i(this,ig,o_).call(this,e);break;case"keyup":$i(this,$n,go).call(this,e);break}}attributeChangedCallback(e,t,r){e===zt.CHECKED&&mo(this)&&!Hi(this,Hu)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===zt.TYPE&&r!==t?this.role="menuitem"+r:e===zt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(zt.DISABLED)||this.enable(),this.role="menuitem"+this.type,eg(this,po,sg(this,this.parentNode)),$i(this,Gu,rg).call(this)}disconnectedCallback(){this.disable(),$i(this,Gu,rg).call(this),eg(this,po,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Nr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(zt.TYPE))!=null?e:""}set type(e){this.setAttribute(zt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(zt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(zt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(mo(this))return this.getAttribute("aria-checked")==="true"}set checked(e){mo(this)&&(eg(this,Hu,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){mo(this)||this.invokeTargetElement&&xt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new kr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};Hu=new WeakMap;po=new WeakMap;tg=new WeakSet;s_=function(i){let e=i.target;if(!(e!=null&&e.name))for(let r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?$i(this,ag,n_).call(this):$i(this,og,a_).call(this))};ag=new WeakSet;n_=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Hi(this,Gi)),this.submenuElement.addEventListener("addmenuitem",Hi(this,Gi)),this.submenuElement.addEventListener("removemenuitem",Hi(this,Gi)),Hi(this,Gi).call(this)};og=new WeakSet;a_=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Hi(this,Gi)),this.submenuElement.removeEventListener("addmenuitem",Hi(this,Gi)),this.submenuElement.removeEventListener("removemenuitem",Hi(this,Gi)),Hi(this,Gi).call(this)};Gi=new WeakMap;$n=new WeakSet;go=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",$i(this,$n,go));return}this.handleClick(i)};ig=new WeakSet;o_=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",$i(this,$n,go));return}this.addEventListener("keyup",$i(this,$n,go),{once:!0})};Gu=new WeakSet;rg=function(){var i;let e=(i=Hi(this,po))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};wr.template=l_;function mo(i){return i.type==="radio"||i.type==="checkbox"}function sg(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?sg(i,t):e!=null&&e.items?e:sg(e,e==null?void 0:e.parentNode)}R.customElements.get("media-chrome-menu-item")||R.customElements.define("media-chrome-menu-item",wr);var d_=F.createElement("template");d_.innerHTML=yt.template.innerHTML+`
2857
+ `;var zt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},wr=class extends R.HTMLElement{constructor(){super(),sr(this,sg),sr(this,dg),sr(this,ug),sr(this,$n),sr(this,ng),sr(this,Ku),sr(this,Gu,!1),sr(this,mo,void 0),sr(this,Gi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let r=this.shadowRoot.querySelector('slot[name="description"]'),s=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=s==null?void 0:s.dataset.description)!=null?t:s==null?void 0:s.text,a=F.createElement("span");a.textContent=n!=null?n:"",r.replaceChildren(a)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[zt.TYPE,zt.DISABLED,zt.CHECKED,zt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),fo(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":$i(this,sg,n_).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":$i(this,ng,l_).call(this,e);break;case"keyup":$i(this,$n,po).call(this,e);break}}attributeChangedCallback(e,t,r){e===zt.CHECKED&&fo(this)&&!Hi(this,Gu)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===zt.TYPE&&r!==t?this.role="menuitem"+r:e===zt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(zt.DISABLED)||this.enable(),this.role="menuitem"+this.type,rg(this,mo,og(this,this.parentNode)),$i(this,Ku,ag).call(this)}disconnectedCallback(){this.disable(),$i(this,Ku,ag).call(this),rg(this,mo,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Nr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(zt.TYPE))!=null?e:""}set type(e){this.setAttribute(zt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(zt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(zt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(fo(this))return this.getAttribute("aria-checked")==="true"}set checked(e){fo(this)&&(rg(this,Gu,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){fo(this)||this.invokeTargetElement&&xt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new kr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};Gu=new WeakMap;mo=new WeakMap;sg=new WeakSet;n_=function(i){let e=i.target;if(!(e!=null&&e.name))for(let r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?$i(this,dg,a_).call(this):$i(this,ug,o_).call(this))};dg=new WeakSet;a_=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Hi(this,Gi)),this.submenuElement.addEventListener("addmenuitem",Hi(this,Gi)),this.submenuElement.addEventListener("removemenuitem",Hi(this,Gi)),Hi(this,Gi).call(this)};ug=new WeakSet;o_=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Hi(this,Gi)),this.submenuElement.removeEventListener("addmenuitem",Hi(this,Gi)),this.submenuElement.removeEventListener("removemenuitem",Hi(this,Gi)),Hi(this,Gi).call(this)};Gi=new WeakMap;$n=new WeakSet;po=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",$i(this,$n,po));return}this.handleClick(i)};ng=new WeakSet;l_=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",$i(this,$n,po));return}this.addEventListener("keyup",$i(this,$n,po),{once:!0})};Ku=new WeakSet;ag=function(){var i;let e=(i=Hi(this,mo))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};wr.template=d_;function fo(i){return i.type==="radio"||i.type==="checkbox"}function og(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?og(i,t):e!=null&&e.items?e:og(e,e==null?void 0:e.parentNode)}R.customElements.get("media-chrome-menu-item")||R.customElements.define("media-chrome-menu-item",wr);var u_=F.createElement("template");u_.innerHTML=yt.template.innerHTML+`
2858
2858
  <style>
2859
2859
  :host {
2860
2860
  background: var(--media-settings-menu-background,
@@ -2881,7 +2881,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2881
2881
  --media-settings-menu-item-opacity: 0;
2882
2882
  }
2883
2883
  </style>
2884
- `;var vo=class extends yt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-settings-menu-button")}};vo.template=d_;R.customElements.get("media-settings-menu")||R.customElements.define("media-settings-menu",vo);var u_,Ku=F.createElement("template");Ku.innerHTML=wr.template.innerHTML+`
2884
+ `;var go=class extends yt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-settings-menu-button")}};go.template=u_;R.customElements.get("media-settings-menu")||R.customElements.define("media-settings-menu",go);var c_,Vu=F.createElement("template");Vu.innerHTML=wr.template.innerHTML+`
2885
2885
  <style>
2886
2886
  slot:not([name="submenu"]) {
2887
2887
  opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
@@ -2891,11 +2891,11 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2891
2891
  background: transparent;
2892
2892
  }
2893
2893
  </style>
2894
- `;(u_=Ku.content)!=null&&u_.querySelector&&(Ku.content.querySelector('slot[name="suffix"]').innerHTML=`
2894
+ `;(c_=Vu.content)!=null&&c_.querySelector&&(Vu.content.querySelector('slot[name="suffix"]').innerHTML=`
2895
2895
  <svg aria-hidden="true" viewBox="0 0 20 24">
2896
2896
  <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
2897
2897
  </svg>
2898
- `);var Eo=class extends wr{};Eo.template=Ku;R.customElements.get("media-settings-menu-item")||R.customElements.define("media-settings-menu-item",Eo);var Kt=class extends Me{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Nr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new kr({relatedTarget:this}))}};R.customElements.get("media-chrome-menu-button")||R.customElements.define("media-chrome-menu-button",Kt);var c_=F.createElement("template");c_.innerHTML=`
2898
+ `);var vo=class extends wr{};vo.template=Vu;R.customElements.get("media-settings-menu-item")||R.customElements.define("media-settings-menu-item",vo);var Kt=class extends Pe{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Nr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new kr({relatedTarget:this}))}};R.customElements.get("media-chrome-menu-button")||R.customElements.define("media-chrome-menu-button",Kt);var h_=F.createElement("template");h_.innerHTML=`
2899
2899
  <style>
2900
2900
  :host([aria-expanded="true"]) slot[name=tooltip] {
2901
2901
  display: none;
@@ -2906,25 +2906,25 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2906
2906
  <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
2907
2907
  </svg>
2908
2908
  </slot>
2909
- `;var Vu=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:c_,tooltipContent:he.SETTINGS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Fe.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-settings-menu")}};R.customElements.get("media-settings-menu-button")||R.customElements.define("media-settings-menu-button",Vu);var cg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},h_=(i,e,t)=>(cg(i,e,"read from private field"),t?t.call(i):e.get(i)),Wu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},lg=(i,e,t,r)=>(cg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Yu=(i,e,t)=>(cg(i,e,"access private method"),t),bo,zu,qu,dg,ju,ug,Xu=class extends yt{constructor(){super(...arguments),Wu(this,qu),Wu(this,ju),Wu(this,bo,[]),Wu(this,zu,void 0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_AUDIO_TRACK_LIST,y.MEDIA_AUDIO_TRACK_ENABLED,y.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===y.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(lg(this,bo,qg(r!=null?r:"")),Yu(this,qu,dg).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Yu(this,ju,ug))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Yu(this,ju,ug))}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return h_(this,bo)}set mediaAudioTrackList(e){lg(this,bo,e),Yu(this,qu,dg).call(this)}get mediaAudioTrackEnabled(){var e;return(e=me(this,y.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ce(this,y.MEDIA_AUDIO_TRACK_ENABLED,e)}};bo=new WeakMap;zu=new WeakMap;qu=new WeakSet;dg=function(){if(h_(this,zu)===JSON.stringify(this.mediaAudioTrackList))return;lg(this,zu,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of i){let t=this.formatMenuItemText(e.label,e),r=Bi({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(r)}};ju=new WeakSet;ug=function(){if(this.value==null)return;let i=new R.CustomEvent($.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-audio-track-menu")||R.customElements.define("media-audio-track-menu",Xu);var Bw=`<svg aria-hidden="true" viewBox="0 0 24 24">
2909
+ `;var Wu=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:h_,tooltipContent:he.SETTINGS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Be.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-settings-menu")}};R.customElements.get("media-settings-menu-button")||R.customElements.define("media-settings-menu-button",Wu);var mg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},f_=(i,e,t)=>(mg(i,e,"read from private field"),t?t.call(i):e.get(i)),Yu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cg=(i,e,t,r)=>(mg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),qu=(i,e,t)=>(mg(i,e,"access private method"),t),Eo,Xu,ju,hg,zu,fg,Qu=class extends yt{constructor(){super(...arguments),Yu(this,ju),Yu(this,zu),Yu(this,Eo,[]),Yu(this,Xu,void 0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_AUDIO_TRACK_LIST,y.MEDIA_AUDIO_TRACK_ENABLED,y.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===y.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(cg(this,Eo,Xg(r!=null?r:"")),qu(this,ju,hg).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",qu(this,zu,fg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",qu(this,zu,fg))}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return f_(this,Eo)}set mediaAudioTrackList(e){cg(this,Eo,e),qu(this,ju,hg).call(this)}get mediaAudioTrackEnabled(){var e;return(e=me(this,y.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ce(this,y.MEDIA_AUDIO_TRACK_ENABLED,e)}};Eo=new WeakMap;Xu=new WeakMap;ju=new WeakSet;hg=function(){if(f_(this,Xu)===JSON.stringify(this.mediaAudioTrackList))return;cg(this,Xu,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of i){let t=this.formatMenuItemText(e.label,e),r=Bi({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(r)}};zu=new WeakSet;fg=function(){if(this.value==null)return;let i=new R.CustomEvent($.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-audio-track-menu")||R.customElements.define("media-audio-track-menu",Qu);var $w=`<svg aria-hidden="true" viewBox="0 0 24 24">
2910
2910
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
2911
2911
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
2912
- </svg>`,f_=F.createElement("template");f_.innerHTML=`
2912
+ </svg>`,m_=F.createElement("template");m_.innerHTML=`
2913
2913
  <style>
2914
2914
  :host([aria-expanded="true"]) slot[name=tooltip] {
2915
2915
  display: none;
2916
2916
  }
2917
2917
  </style>
2918
- <slot name="icon">${Bw}</slot>
2919
- `;var Qu=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_AUDIO_TRACK_ENABLED,y.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:f_,tooltipContent:he.AUDIO_TRACK_MENU})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Fe.AUDIO_TRACKS())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return(e=me(this,y.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ce(this,y.MEDIA_AUDIO_TRACK_ENABLED,e)}};R.customElements.get("media-audio-track-menu-button")||R.customElements.define("media-audio-track-menu-button",Qu);var gg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$w=(i,e,t)=>(gg(i,e,"read from private field"),t?t.call(i):e.get(i)),hg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hw=(i,e,t,r)=>(gg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fg=(i,e,t)=>(gg(i,e,"access private method"),t),Ju,mg,g_,Zu,pg,Gw=`
2918
+ <slot name="icon">${$w}</slot>
2919
+ `;var Zu=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_AUDIO_TRACK_ENABLED,y.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:m_,tooltipContent:he.AUDIO_TRACK_MENU})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Be.AUDIO_TRACKS())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return(e=me(this,y.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ce(this,y.MEDIA_AUDIO_TRACK_ENABLED,e)}};R.customElements.get("media-audio-track-menu-button")||R.customElements.define("media-audio-track-menu-button",Zu);var bg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Hw=(i,e,t)=>(bg(i,e,"read from private field"),t?t.call(i):e.get(i)),pg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gw=(i,e,t,r)=>(bg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),gg=(i,e,t)=>(bg(i,e,"access private method"),t),ec,vg,v_,Ju,Eg,Kw=`
2920
2920
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
2921
2921
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
2922
- </svg>`,v_=F.createElement("template");v_.innerHTML=yt.template.innerHTML+`
2923
- <slot name="captions-indicator" hidden>${Gw}</slot>`;var yo=class extends yt{constructor(){super(...arguments),hg(this,mg),hg(this,Zu),hg(this,Ju,void 0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_LIST&&t!==r?fg(this,mg,g_).call(this):e===y.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",fg(this,Zu,pg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",fg(this,Zu,pg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return m_(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){p_(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return m_(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){p_(this,y.MEDIA_SUBTITLES_SHOWING,e)}};Ju=new WeakMap;mg=new WeakSet;g_=function(){var i;if($w(this,Ju)===JSON.stringify(this.mediaSubtitlesList))return;Hw(this,Ju,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=Bi({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(t);let r=this.mediaSubtitlesList;for(let s of r){let n=Bi({type:"radio",text:this.formatMenuItemText(s.label,s),value:qo(s),checked:this.value==qo(s)});n.prepend(hi(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(hi(this,"captions-indicator")),this.defaultSlot.append(n)}};Zu=new WeakSet;pg=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(y.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new R.CustomEvent($.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new R.CustomEvent($.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};yo.template=v_;var m_=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},p_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu")||R.customElements.define("media-captions-menu",yo);var Kw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ww=(i,e,t,r)=>(Kw(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),vg,Yw=`<svg aria-hidden="true" viewBox="0 0 26 24">
2922
+ </svg>`,E_=F.createElement("template");E_.innerHTML=yt.template.innerHTML+`
2923
+ <slot name="captions-indicator" hidden>${Kw}</slot>`;var bo=class extends yt{constructor(){super(...arguments),pg(this,vg),pg(this,Ju),pg(this,ec,void 0)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_LIST&&t!==r?gg(this,vg,v_).call(this):e===y.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",gg(this,Ju,Eg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",gg(this,Ju,Eg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return p_(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){g_(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return p_(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){g_(this,y.MEDIA_SUBTITLES_SHOWING,e)}};ec=new WeakMap;vg=new WeakSet;v_=function(){var i;if(Hw(this,ec)===JSON.stringify(this.mediaSubtitlesList))return;Gw(this,ec,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=Bi({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(t);let r=this.mediaSubtitlesList;for(let s of r){let n=Bi({type:"radio",text:this.formatMenuItemText(s.label,s),value:Yo(s),checked:this.value==Yo(s)});n.prepend(hi(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(hi(this,"captions-indicator")),this.defaultSlot.append(n)}};Ju=new WeakSet;Eg=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(y.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new R.CustomEvent($.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new R.CustomEvent($.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};bo.template=E_;var p_=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},g_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu")||R.customElements.define("media-captions-menu",bo);var Vw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ww=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Yw=(i,e,t,r)=>(Vw(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),yg,qw=`<svg aria-hidden="true" viewBox="0 0 26 24">
2924
2924
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
2925
- </svg>`,qw=`<svg aria-hidden="true" viewBox="0 0 26 24">
2925
+ </svg>`,jw=`<svg aria-hidden="true" viewBox="0 0 26 24">
2926
2926
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
2927
- </svg>`,T_=F.createElement("template");T_.innerHTML=`
2927
+ </svg>`,__=F.createElement("template");__.innerHTML=`
2928
2928
  <style>
2929
2929
  :host([aria-checked="true"]) slot[name=off] {
2930
2930
  display: none !important;
@@ -2941,10 +2941,10 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2941
2941
  </style>
2942
2942
 
2943
2943
  <slot name="icon">
2944
- <slot name="on">${Yw}</slot>
2945
- <slot name="off">${qw}</slot>
2944
+ <slot name="on">${qw}</slot>
2945
+ <slot name="off">${jw}</slot>
2946
2946
  </slot>
2947
- `;var E_=i=>{i.setAttribute("aria-checked",jo(i).toString())},ec=class extends Kt{constructor(e={}){super({slotTemplate:T_,tooltipContent:he.CAPTIONS,...e}),Vw(this,vg,void 0),Ww(this,vg,!1)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Fe.CLOSED_CAPTIONS()),E_(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_SHOWING&&E_(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return b_(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){y_(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return b_(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){y_(this,y.MEDIA_SUBTITLES_SHOWING,e)}};vg=new WeakMap;var b_=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},y_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu-button")||R.customElements.define("media-captions-menu-button",ec);var __=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tc=(i,e,t)=>(__(i,e,"read from private field"),t?t.call(i):e.get(i)),Eg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},To=(i,e,t)=>(__(i,e,"access private method"),t),Hn,_o,ic,rc,yg,bg={RATES:"rates"},sc=class extends yt{constructor(){super(),Eg(this,_o),Eg(this,rc),Eg(this,Hn,new pi(this,bg.RATES,{defaultValue:ph})),To(this,_o,ic).call(this)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,bg.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===bg.RATES&&t!=r&&(tc(this,Hn).value=r,To(this,_o,ic).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",To(this,rc,yg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",To(this,rc,yg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-playback-rate-menu-button")}get rates(){return tc(this,Hn)}set rates(e){e?Array.isArray(e)&&(tc(this,Hn).value=e.join(" ")):tc(this,Hn).value="",To(this,_o,ic).call(this)}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,tn)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}};Hn=new WeakMap;_o=new WeakSet;ic=function(){this.defaultSlot.textContent="";for(let i of this.rates){let e=Bi({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(e)}};rc=new WeakSet;yg=function(){if(!this.value)return;let i=new R.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-playback-rate-menu")||R.customElements.define("media-playback-rate-menu",sc);var jw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nc=(i,e,t)=>(jw(i,e,"read from private field"),t?t.call(i):e.get(i)),zw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gn,Tg={RATES:"rates"},Xw=[1,1.2,1.5,1.7,2],_g=1,A_=F.createElement("template");A_.innerHTML=`
2947
+ `;var b_=i=>{i.setAttribute("aria-checked",qo(i).toString())},tc=class extends Kt{constructor(e={}){super({slotTemplate:__,tooltipContent:he.CAPTIONS,...e}),Ww(this,yg,void 0),Yw(this,yg,!1)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_SUBTITLES_LIST,y.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Be.CLOSED_CAPTIONS()),b_(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_SUBTITLES_SHOWING&&b_(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return y_(this,y.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){T_(this,y.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return y_(this,y.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){T_(this,y.MEDIA_SUBTITLES_SHOWING,e)}};yg=new WeakMap;var y_=(i,e)=>{let t=i.getAttribute(e);return t?Fr(t):[]},T_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=qi(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu-button")||R.customElements.define("media-captions-menu-button",tc);var A_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ic=(i,e,t)=>(A_(i,e,"read from private field"),t?t.call(i):e.get(i)),Tg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yo=(i,e,t)=>(A_(i,e,"access private method"),t),Hn,To,rc,sc,Ag,_g={RATES:"rates"},nc=class extends yt{constructor(){super(),Tg(this,To),Tg(this,sc),Tg(this,Hn,new pi(this,_g.RATES,{defaultValue:gh})),yo(this,To,rc).call(this)}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,_g.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===_g.RATES&&t!=r&&(ic(this,Hn).value=r,yo(this,To,rc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yo(this,sc,Ag))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yo(this,sc,Ag))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-playback-rate-menu-button")}get rates(){return ic(this,Hn)}set rates(e){e?Array.isArray(e)&&(ic(this,Hn).value=e.join(" ")):ic(this,Hn).value="",yo(this,To,rc).call(this)}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,tn)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}};Hn=new WeakMap;To=new WeakSet;rc=function(){this.defaultSlot.textContent="";for(let i of this.rates){let e=Bi({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(e)}};sc=new WeakSet;Ag=function(){if(!this.value)return;let i=new R.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-playback-rate-menu")||R.customElements.define("media-playback-rate-menu",nc);var zw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ac=(i,e,t)=>(zw(i,e,"read from private field"),t?t.call(i):e.get(i)),Xw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gn,Sg={RATES:"rates"},Qw=[1,1.2,1.5,1.7,2],xg=1,S_=F.createElement("template");S_.innerHTML=`
2948
2948
  <style>
2949
2949
  :host {
2950
2950
  min-width: 5ch;
@@ -2956,16 +2956,16 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2956
2956
  }
2957
2957
  </style>
2958
2958
  <slot name="icon"></slot>
2959
- `;var ac=class extends Kt{constructor(e={}){super({slotTemplate:A_,tooltipContent:he.PLAYBACK_RATE,...e}),zw(this,Gn,new pi(this,Tg.RATES,{defaultValue:Xw})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${_g}x`}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,Tg.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Tg.RATES&&(nc(this,Gn).value=r),e===y.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?_g:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Fe.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-playback-rate-menu")}get rates(){return nc(this,Gn)}set rates(e){e?Array.isArray(e)&&(nc(this,Gn).value=e.join(" ")):nc(this,Gn).value=""}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,_g)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}};Gn=new WeakMap;R.customElements.get("media-playback-rate-menu-button")||R.customElements.define("media-playback-rate-menu-button",ac);var Sg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},So=(i,e,t)=>(Sg(i,e,"read from private field"),t?t.call(i):e.get(i)),oc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},S_=(i,e,t,r)=>(Sg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ao=(i,e,t)=>(Sg(i,e,"access private method"),t),xo,Kn,Ro,lc,dc,Ag,uc=class extends yt{constructor(){super(...arguments),oc(this,Ro),oc(this,dc),oc(this,xo,[]),oc(this,Kn,{})}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_RENDITION_LIST,y.MEDIA_RENDITION_SELECTED,y.MEDIA_RENDITION_UNAVAILABLE,y.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===y.MEDIA_RENDITION_LIST&&t!==r?(S_(this,xo,Wg(r)),Ao(this,Ro,lc).call(this)):e===y.MEDIA_HEIGHT&&t!==r&&Ao(this,Ro,lc).call(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ao(this,dc,Ag))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ao(this,dc,Ag))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return So(this,xo)}set mediaRenditionList(e){S_(this,xo,e),Ao(this,Ro,lc).call(this)}get mediaRenditionSelected(){return me(this,y.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ce(this,y.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return fe(this,y.MEDIA_HEIGHT)}set mediaHeight(e){be(this,y.MEDIA_HEIGHT,e)}};xo=new WeakMap;Kn=new WeakMap;Ro=new WeakSet;lc=function(){if(So(this,Kn).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&So(this,Kn).mediaHeight===this.mediaHeight)return;So(this,Kn).mediaRenditionList=JSON.stringify(this.mediaRenditionList),So(this,Kn).mediaHeight=this.mediaHeight;let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height);for(let s of i)s.selected=s.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let s of i){let n=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),a=Bi({type:"radio",text:n,value:`${s.id}`,checked:s.selected&&!e});a.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(a)}let t=Bi({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e}),r=this.mediaHeight>0?`Auto (${this.mediaHeight}p)`:"Auto";t.dataset.description=r,t.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(t)};dc=new WeakSet;Ag=function(){if(this.value==null)return;let i=new R.CustomEvent($.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-rendition-menu")||R.customElements.define("media-rendition-menu",uc);var Qw=`<svg aria-hidden="true" viewBox="0 0 24 24">
2959
+ `;var oc=class extends Kt{constructor(e={}){super({slotTemplate:S_,tooltipContent:he.PLAYBACK_RATE,...e}),Xw(this,Gn,new pi(this,Sg.RATES,{defaultValue:Qw})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${xg}x`}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_PLAYBACK_RATE,Sg.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Sg.RATES&&(ac(this,Gn).value=r),e===y.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?xg:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Be.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-playback-rate-menu")}get rates(){return ac(this,Gn)}set rates(e){e?Array.isArray(e)&&(ac(this,Gn).value=e.join(" ")):ac(this,Gn).value=""}get mediaPlaybackRate(){return fe(this,y.MEDIA_PLAYBACK_RATE,xg)}set mediaPlaybackRate(e){be(this,y.MEDIA_PLAYBACK_RATE,e)}};Gn=new WeakMap;R.customElements.get("media-playback-rate-menu-button")||R.customElements.define("media-playback-rate-menu-button",oc);var Ig=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ao=(i,e,t)=>(Ig(i,e,"read from private field"),t?t.call(i):e.get(i)),lc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},x_=(i,e,t,r)=>(Ig(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_o=(i,e,t)=>(Ig(i,e,"access private method"),t),So,Kn,xo,dc,uc,Rg,cc=class extends yt{constructor(){super(...arguments),lc(this,xo),lc(this,uc),lc(this,So,[]),lc(this,Kn,{})}static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_RENDITION_LIST,y.MEDIA_RENDITION_SELECTED,y.MEDIA_RENDITION_UNAVAILABLE,y.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===y.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===y.MEDIA_RENDITION_LIST&&t!==r?(x_(this,So,jg(r)),_o(this,xo,dc).call(this)):e===y.MEDIA_HEIGHT&&t!==r&&_o(this,xo,dc).call(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",_o(this,uc,Rg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",_o(this,uc,Rg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Ao(this,So)}set mediaRenditionList(e){x_(this,So,e),_o(this,xo,dc).call(this)}get mediaRenditionSelected(){return me(this,y.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ce(this,y.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return fe(this,y.MEDIA_HEIGHT)}set mediaHeight(e){be(this,y.MEDIA_HEIGHT,e)}};So=new WeakMap;Kn=new WeakMap;xo=new WeakSet;dc=function(){if(Ao(this,Kn).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&Ao(this,Kn).mediaHeight===this.mediaHeight)return;Ao(this,Kn).mediaRenditionList=JSON.stringify(this.mediaRenditionList),Ao(this,Kn).mediaHeight=this.mediaHeight;let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height);for(let s of i)s.selected=s.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let s of i){let n=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),a=Bi({type:"radio",text:n,value:`${s.id}`,checked:s.selected&&!e});a.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(a)}let t=Bi({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e}),r=this.mediaHeight>0?`Auto (${this.mediaHeight}p)`:"Auto";t.dataset.description=r,t.prepend(hi(this,"checked-indicator")),this.defaultSlot.append(t)};uc=new WeakSet;Rg=function(){if(this.value==null)return;let i=new R.CustomEvent($.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-rendition-menu")||R.customElements.define("media-rendition-menu",cc);var Zw=`<svg aria-hidden="true" viewBox="0 0 24 24">
2960
2960
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
2961
- </svg>`,x_=F.createElement("template");x_.innerHTML=`
2961
+ </svg>`,R_=F.createElement("template");R_.innerHTML=`
2962
2962
  <style>
2963
2963
  :host([aria-expanded="true"]) slot[name=tooltip] {
2964
2964
  display: none;
2965
2965
  }
2966
2966
  </style>
2967
- <slot name="icon">${Qw}</slot>
2968
- `;var cc=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_RENDITION_SELECTED,y.MEDIA_RENDITION_UNAVAILABLE,y.MEDIA_HEIGHT]}constructor(){super({slotTemplate:x_,tooltipContent:he.RENDITIONS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Fe.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return me(this,y.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ce(this,y.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return fe(this,y.MEDIA_HEIGHT)}set mediaHeight(e){be(this,y.MEDIA_HEIGHT,e)}};R.customElements.get("media-rendition-menu-button")||R.customElements.define("media-rendition-menu-button",cc);var xg=Hs.createElement("template");"innerHTML"in xg&&(xg.innerHTML=KT);var R_,I_,hc=class extends ws{};hc.template=(I_=(R_=xg.content)==null?void 0:R_.children)==null?void 0:I_[0];Ct.customElements.get("media-theme-gerwig")||Ct.customElements.define("media-theme-gerwig",hc);var Zw="gerwig";var nr={SRC:"src",POSTER:"poster"},U={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips"},Rg=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function Jw(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src||!!i.currentSrc,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(U.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:tD(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(U.NOHOTKEYS),hotKeys:i.getAttribute(U.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,assetStartTime:i.assetStartTime,assetEndTime:i.assetEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerInitTime:i.playerInitTime,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(C.TARGET_LIVE_WINDOW),streamType:Ja(i.getAttribute(C.STREAM_TYPE)),primaryColor:i.getAttribute(U.PRIMARY_COLOR),secondaryColor:i.getAttribute(U.SECONDARY_COLOR),accentColor:i.getAttribute(U.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:iD(i),playbackRates:i.getAttribute(U.PLAYBACK_RATES),customDomain:(r=i.getAttribute(C.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(U.TITLE),novolumepref:i.hasAttribute(U.NO_VOLUME_PREF),castReceiver:i.castReceiver,...e,extraSourceParams:i.extraSourceParams}}var eD=Al.formatErrorMessage;Al.formatErrorMessage=i=>{var e,t;if(i instanceof K){let r=GT(i,!1);return`
2967
+ <slot name="icon">${Zw}</slot>
2968
+ `;var hc=class extends Kt{static get observedAttributes(){return[...super.observedAttributes,y.MEDIA_RENDITION_SELECTED,y.MEDIA_RENDITION_UNAVAILABLE,y.MEDIA_HEIGHT]}constructor(){super({slotTemplate:R_,tooltipContent:he.RENDITIONS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Be.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return me(this,y.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ce(this,y.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return fe(this,y.MEDIA_HEIGHT)}set mediaHeight(e){be(this,y.MEDIA_HEIGHT,e)}};R.customElements.get("media-rendition-menu-button")||R.customElements.define("media-rendition-menu-button",hc);var Lg=Hs.createElement("template");"innerHTML"in Lg&&(Lg.innerHTML=VT);var I_,L_,fc=class extends ws{};fc.template=(L_=(I_=Lg.content)==null?void 0:I_.children)==null?void 0:L_[0];Ct.customElements.get("media-theme-gerwig")||Ct.customElements.define("media-theme-gerwig",fc);var Jw="gerwig";var nr={SRC:"src",POSTER:"poster"},U={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips"},kg=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function eD(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src||!!i.currentSrc,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(U.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:iD(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(U.NOHOTKEYS),hotKeys:i.getAttribute(U.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,assetStartTime:i.assetStartTime,assetEndTime:i.assetEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerInitTime:i.playerInitTime,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(C.TARGET_LIVE_WINDOW),streamType:Za(i.getAttribute(C.STREAM_TYPE)),primaryColor:i.getAttribute(U.PRIMARY_COLOR),secondaryColor:i.getAttribute(U.SECONDARY_COLOR),accentColor:i.getAttribute(U.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:rD(i),playbackRates:i.getAttribute(U.PLAYBACK_RATES),customDomain:(r=i.getAttribute(C.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(U.TITLE),novolumepref:i.hasAttribute(U.NO_VOLUME_PREF),castReceiver:i.castReceiver,...e,extraSourceParams:i.extraSourceParams}}var tD=_l.formatErrorMessage;_l.formatErrorMessage=i=>{var e,t;if(i instanceof K){let r=KT(i,!1);return`
2969
2969
  ${r!=null&&r.title?`<h3>${r.title}</h3>`:""}
2970
2970
  ${r!=null&&r.message||r!=null&&r.linkUrl?`<p>
2971
2971
  ${r==null?void 0:r.message}
@@ -2977,8 +2977,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2977
2977
  >${(t=r.linkText)!=null?t:r.linkUrl}</a
2978
2978
  >`:""}
2979
2979
  </p>`:""}
2980
- `}return eD(i)};function tD(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=Ct.customElements.get(e);if(n!=null&&n.template)return n.template}}function iD(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function L_(i){let e=i.hasAttribute(U.TITLE)?{video_title:i.getAttribute(U.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var rD=Object.values(C),sD=Object.values(nr),nD=Object.values(U),k_=_u(),C_="mux-player",w_={isDialogOpen:!1},aD={redundant_streams:!0},Lo,ko,Co,Mr,wo,Us,ke,Dr,D_,Ig,Ns,M_,P_,O_,N_,Io=class extends Ip{constructor(){super();kt(this,ke);kt(this,Lo);kt(this,ko,!1);kt(this,Co,{});kt(this,Mr,!0);kt(this,wo,new Tu(this,"hotkeys"));kt(this,Us,{...w_,onCloseErrorDialog:t=>{var s;((s=t.composedPath()[0])==null?void 0:s.localName)==="media-error-dialog"&&Qe(this,ke,Ig).call(this,{isDialogOpen:!1})},onFocusInErrorDialog:t=>{var n;if(((n=t.composedPath()[0])==null?void 0:n.localName)!=="media-error-dialog")return;Sp(this,Hs.activeElement)||t.preventDefault()}});$t(this,Lo,Jd()),this.attachShadow({mode:"open"}),Qe(this,ke,D_).call(this),this.isConnected&&Qe(this,ke,Dr).call(this)}static get NAME(){return C_}static get VERSION(){return k_}static get observedAttributes(){var t;return[...(t=Ip.observedAttributes)!=null?t:[],...sD,...rD,...nD]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=L_(this))}attributeChangedCallback(t,r,s){switch(Qe(this,ke,Dr).call(this),super.attributeChangedCallback(t,r,s),t){case U.HOTKEYS:_e(this,wo).value=s;break;case U.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Oi(j("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time."));break}case U.THUMBNAIL_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.THUMBNAIL;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"thumbnail"}))}}break}case U.STORYBOARD_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.STORYBOARD;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"storyboard"}))}}break}case U.DRM_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.DRM;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"drm"}))}}break}case C.PLAYBACK_ID:{s!=null&&s.includes("?token")&&Ut(j("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case C.STREAM_TYPE:s&&![Re.LIVE,Re.ON_DEMAND,Re.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:xp({file:"invalid-stream-type.md",message:j("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===Re.LIVE?this.getAttribute(U.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[C.PLAYBACK_ID,nr.SRC,U.PLAYBACK_TOKEN].includes(t)&&r!==s&&$t(this,Us,{..._e(this,Us),...w_}),Qe(this,ke,Ns).call(this,{[yT(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(C.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?In.includes(t)?this.setAttribute(C.PREFER_CMCD,t):Oi(`Invalid value for preferCmcd. Must be one of ${In.join()}`):this.removeAttribute(C.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(y.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(y.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(U.THEME))!=null?t:Zw}set theme(t){this.setAttribute(U.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(Rg.includes(s))continue;let n=t.getAttribute(s);r[yu(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;Qe(this,ke,Dr).call(this);let r={...this.themeProps,...t};for(let a in r){if(Rg.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(bu(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(bu(a),o)}}get playbackId(){var t;return(t=this.getAttribute(C.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(C.PLAYBACK_ID,t):this.removeAttribute(C.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=Os(this,nr.SRC))!=null?t:void 0:(r=this.getAttribute(nr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(nr.SRC,t):this.removeAttribute(nr.SRC)}get poster(){var s;let t=this.getAttribute(nr.POSTER);if(t!=null)return t;let{tokens:r}=this;if(r.playback&&!r.thumbnail){Oi("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return ET(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(s=this.thumbnailTime)!=null?s:this.startTime,programTime:this.programStartTime,token:r.thumbnail})}set poster(t){t||t===""?this.setAttribute(nr.POSTER,t):this.removeAttribute(nr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(U.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(U.STORYBOARD_SRC,t):this.removeAttribute(U.STORYBOARD_SRC)}get storyboard(){let{tokens:t}=this;if(this.storyboardSrc&&!t.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Re.LIVE,Re.UNKNOWN].includes(this.streamType)||t.playback&&!t.storyboard))return bT(this.playbackId,{customDomain:this.customDomain,token:t.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(U.AUDIO)}set audio(t){if(!t){this.removeAttribute(U.AUDIO);return}this.setAttribute(U.AUDIO,"")}get hotkeys(){return _e(this,wo)}get nohotkeys(){return this.hasAttribute(U.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(U.NOHOTKEYS);return}this.setAttribute(U.NOHOTKEYS,"")}get thumbnailTime(){return Rt(this.getAttribute(U.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(U.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(U.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(U.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=Os(this,U.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(U.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(U.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(U.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(U.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(U.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(U.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(U.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(U.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(U.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(U.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(U.PLAYBACK_RATES))return this.getAttribute(U.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(U.PLAYBACK_RATES);return}this.setAttribute(U.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Rt(this.getAttribute(U.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(U.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Rt(this.getAttribute(U.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(U.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(U.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(U.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(U.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Rt(this.getAttribute(U.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute(U.DEFAULT_DURATION):this.setAttribute(U.DEFAULT_DURATION,`${t}`)}get playerInitTime(){return this.hasAttribute(C.PLAYER_INIT_TIME)?Rt(this.getAttribute(C.PLAYER_INIT_TIME)):_e(this,Lo)}set playerInitTime(t){t!=this.playerInitTime&&(t==null?this.removeAttribute(C.PLAYER_INIT_TIME):this.setAttribute(C.PLAYER_INIT_TIME,`${+t}`))}get playerSoftwareName(){var t;return(t=this.getAttribute(C.PLAYER_SOFTWARE_NAME))!=null?t:C_}get playerSoftwareVersion(){var t;return(t=this.getAttribute(C.PLAYER_SOFTWARE_VERSION))!=null?t:k_}get beaconCollectionDomain(){var t;return(t=this.getAttribute(C.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(C.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(C.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(C.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(C.MAX_RESOLUTION,t):this.removeAttribute(C.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(C.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(C.MIN_RESOLUTION,t):this.removeAttribute(C.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(C.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(C.RENDITION_ORDER,t):this.removeAttribute(C.RENDITION_ORDER))}get programStartTime(){return Rt(this.getAttribute(C.PROGRAM_START_TIME))}set programStartTime(t){t==null?this.removeAttribute(C.PROGRAM_START_TIME):this.setAttribute(C.PROGRAM_START_TIME,`${t}`)}get programEndTime(){return Rt(this.getAttribute(C.PROGRAM_END_TIME))}set programEndTime(t){t==null?this.removeAttribute(C.PROGRAM_END_TIME):this.setAttribute(C.PROGRAM_END_TIME,`${t}`)}get assetStartTime(){return Rt(this.getAttribute(C.ASSET_START_TIME))}set assetStartTime(t){t==null?this.removeAttribute(C.ASSET_START_TIME):this.setAttribute(C.ASSET_START_TIME,`${t}`)}get assetEndTime(){return Rt(this.getAttribute(C.ASSET_END_TIME))}set assetEndTime(t){t==null?this.removeAttribute(C.ASSET_END_TIME):this.setAttribute(C.ASSET_END_TIME,`${t}`)}get extraSourceParams(){return this.hasAttribute(U.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(U.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):aD}set extraSourceParams(t){t==null?this.removeAttribute(U.EXTRA_SOURCE_PARAMS):this.setAttribute(U.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(C.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(C.CUSTOM_DOMAIN,t):this.removeAttribute(C.CUSTOM_DOMAIN))}get envKey(){var t;return(t=Os(this,C.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(C.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(U.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(U.NO_VOLUME_PREF,""):this.removeAttribute(U.NO_VOLUME_PREF)}get debug(){return Os(this,C.DEBUG)!=null}set debug(t){t?this.setAttribute(C.DEBUG,""):this.removeAttribute(C.DEBUG)}get disableTracking(){return Os(this,C.DISABLE_TRACKING)!=null}set disableTracking(t){this.toggleAttribute(C.DISABLE_TRACKING,!!t)}get disableCookies(){return Os(this,C.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(C.DISABLE_COOKIES,""):this.removeAttribute(C.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(C.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:Re.UNKNOWN}set streamType(t){this.setAttribute(C.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?s:Re.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(U.DEFAULT_STREAM_TYPE,t):this.removeAttribute(U.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(U.TARGET_LIVE_WINDOW)?+this.getAttribute(U.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute(U.TARGET_LIVE_WINDOW):this.setAttribute(U.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Rt(Os(this,C.START_TIME))}set startTime(t){this.setAttribute(C.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(C.PREFER_PLAYBACK);if(t===qt.MSE||t===qt.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===qt.MSE||t===qt.NATIVE?this.setAttribute(C.PREFER_PLAYBACK,t):this.removeAttribute(C.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(Qe(this,ke,Dr).call(this),!this.media){Ut("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...L_(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(Qe(this,ke,Dr).call(this),!this.media){Ut("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(Qe(this,ke,Dr).call(this),!this.media){Ut("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}addChapters(t){var r;if(Qe(this,ke,Dr).call(this),!this.media){Ut("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(r=this.media)==null?void 0:r.addChapters(t)}get activeChapter(){var t;return(t=this.media)==null?void 0:t.activeChapter}get chapters(){var t,r;return(r=(t=this.media)==null?void 0:t.chapters)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(U.PLAYBACK_TOKEN),r=this.getAttribute(U.DRM_TOKEN),s=this.getAttribute(U.THUMBNAIL_TOKEN),n=this.getAttribute(U.STORYBOARD_TOKEN);return{..._e(this,Co),...t!=null?{playback:t}:{},...r!=null?{drm:r}:{},...s!=null?{thumbnail:s}:{},...n!=null?{storyboard:n}:{}}}set tokens(t){$t(this,Co,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(U.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(U.PLAYBACK_TOKEN,`${t}`)}get drmToken(){var t;return(t=this.getAttribute(U.DRM_TOKEN))!=null?t:void 0}set drmToken(t){this.setAttribute(U.DRM_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(U.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(U.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(U.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(U.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return Zd(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return Ly(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}get castReceiver(){var t;return(t=this.getAttribute(U.CAST_RECEIVER))!=null?t:void 0}set castReceiver(t){t!==this.castReceiver&&(t?this.setAttribute(U.CAST_RECEIVER,t):this.removeAttribute(U.CAST_RECEIVER))}get castCustomData(){var t;return(t=this.media)==null?void 0:t.castCustomData}set castCustomData(t){if(!this.media){Ut("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=t}get noTooltips(){return this.hasAttribute(U.NO_TOOLTIPS)}set noTooltips(t){if(!t){this.removeAttribute(U.NO_TOOLTIPS);return}this.setAttribute(U.NO_TOOLTIPS,"")}};Lo=new WeakMap,ko=new WeakMap,Co=new WeakMap,Mr=new WeakMap,wo=new WeakMap,Us=new WeakMap,ke=new WeakSet,Dr=function(){var t,r,s,n;if(!_e(this,ko)){$t(this,ko,!0),Qe(this,ke,Ns).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Ct.HTMLElement))throw""}catch{Ut("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof pT))throw""}catch{Ut("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Uc))throw""}catch{Ut("<media-controller> failed to upgrade!")}this.init(),Qe(this,ke,M_).call(this),Qe(this,ke,P_).call(this),Qe(this,ke,O_).call(this),$t(this,Mr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(ve.USER_INACTIVE))!=null?r:!0),Qe(this,ke,N_).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>Qe(this,ke,Ns).call(this)),(n=this.media)==null||n.addEventListener("loadstart",()=>Qe(this,ke,Ns).call(this))}},D_=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ig=function(t){Object.assign(_e(this,Us),t),Qe(this,ke,Ns).call(this)},Ns=function(t={}){BT($T(Jw(this,{..._e(this,Us),...t})),this.shadowRoot)},M_=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(Rg.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},P_=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof K||(n=new K(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Oi(n),n.data&&Oi(`${n.name} data:`,n.data);return}let a=Fp(n,!1);a.message&&xp(a),Ut(n),n.data&&Ut(`${n.name} data:`,n.data),Qe(this,ke,Ig).call(this,{isDialogOpen:!0})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof K))return s;let n=Fp((o=this.media)==null?void 0:o.error,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new K(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},O_=function(){var r,s,n,a;let t=()=>Qe(this,ke,Ns).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},N_=function(){var d,u;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===Re.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(c,h,f=!1)=>{if(n())return;Array.from(c&&c.activeCues||[]).forEach(p=>{if(!(!p.snapToLines||p.line<-5||p.line>=0&&p.line<10))if(!h||this.paused){let g=p.text.split(`
2981
- `).length,E=-3;this.streamType===Re.LIVE&&(E=-2);let b=E-g;if(p.line===b&&!f)return;s.has(p)||s.set(p,p.line),p.line=b}else setTimeout(()=>{p.line=s.get(p)||"auto"},500)})},o=()=>{var c,h;a(r,(h=(c=this.mediaController)==null?void 0:c.hasAttribute(ve.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,m;let h=Array.from(((m=(f=this.mediaController)==null?void 0:f.media)==null?void 0:m.textTracks)||[]).filter(p=>["subtitles","captions"].includes(p.kind)&&p.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,_e(this,Mr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(u=this.textTracks)==null||u.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let c=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(ve.USER_INACTIVE))!=null?f:!0;_e(this,Mr)!==c&&($t(this,Mr,c),a(r,_e(this,Mr)))})};function Os(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}Ct.customElements.get("mux-player")||(Ct.customElements.define("mux-player",Io),Ct.MuxPlayerElement=Io);var GF=Io;})();
2980
+ `}return tD(i)};function iD(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=Ct.customElements.get(e);if(n!=null&&n.template)return n.template}}function rD(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function k_(i){let e=i.hasAttribute(U.TITLE)?{video_title:i.getAttribute(U.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var sD=Object.values(C),nD=Object.values(nr),aD=Object.values(U),C_=Au(),w_="mux-player",D_={isDialogOpen:!1},oD={redundant_streams:!0},Io,Lo,ko,Mr,Co,Us,Ce,Dr,M_,Cg,Ns,P_,O_,N_,U_,Ro=class extends Cp{constructor(){super();kt(this,Ce);kt(this,Io);kt(this,Lo,!1);kt(this,ko,{});kt(this,Mr,!0);kt(this,Co,new _u(this,"hotkeys"));kt(this,Us,{...D_,onCloseErrorDialog:t=>{var s;((s=t.composedPath()[0])==null?void 0:s.localName)==="media-error-dialog"&&Qe(this,Ce,Cg).call(this,{isDialogOpen:!1})},onFocusInErrorDialog:t=>{var n;if(((n=t.composedPath()[0])==null?void 0:n.localName)!=="media-error-dialog")return;Ip(this,Hs.activeElement)||t.preventDefault()}});$t(this,Io,eu()),this.attachShadow({mode:"open"}),Qe(this,Ce,M_).call(this),this.isConnected&&Qe(this,Ce,Dr).call(this)}static get NAME(){return w_}static get VERSION(){return C_}static get observedAttributes(){var t;return[...(t=Cp.observedAttributes)!=null?t:[],...nD,...sD,...aD]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=k_(this))}attributeChangedCallback(t,r,s){switch(Qe(this,Ce,Dr).call(this),super.attributeChangedCallback(t,r,s),t){case U.HOTKEYS:_e(this,Co).value=s;break;case U.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Oi(j("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time."));break}case U.THUMBNAIL_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.THUMBNAIL;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"thumbnail"}))}}break}case U.STORYBOARD_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.STORYBOARD;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"storyboard"}))}}break}case U.DRM_TOKEN:{if(s){let a=Ar(s);if(a){let{aud:o}=a,l=Rn.DRM;o!==l&&Oi(j("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:o,expectedAud:l,tokenNamePrefix:"drm"}))}}break}case C.PLAYBACK_ID:{s!=null&&s.includes("?token")&&Ut(j("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case C.STREAM_TYPE:s&&![Re.LIVE,Re.ON_DEMAND,Re.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:Lp({file:"invalid-stream-type.md",message:j("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===Re.LIVE?this.getAttribute(U.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[C.PLAYBACK_ID,nr.SRC,U.PLAYBACK_TOKEN].includes(t)&&r!==s&&$t(this,Us,{..._e(this,Us),...D_}),Qe(this,Ce,Ns).call(this,{[TT(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(C.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?In.includes(t)?this.setAttribute(C.PREFER_CMCD,t):Oi(`Invalid value for preferCmcd. Must be one of ${In.join()}`):this.removeAttribute(C.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(y.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(y.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(U.THEME))!=null?t:Jw}set theme(t){this.setAttribute(U.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(kg.includes(s))continue;let n=t.getAttribute(s);r[Tu(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;Qe(this,Ce,Dr).call(this);let r={...this.themeProps,...t};for(let a in r){if(kg.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(yu(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(yu(a),o)}}get playbackId(){var t;return(t=this.getAttribute(C.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(C.PLAYBACK_ID,t):this.removeAttribute(C.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=Os(this,nr.SRC))!=null?t:void 0:(r=this.getAttribute(nr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(nr.SRC,t):this.removeAttribute(nr.SRC)}get poster(){var s;let t=this.getAttribute(nr.POSTER);if(t!=null)return t;let{tokens:r}=this;if(r.playback&&!r.thumbnail){Oi("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return bT(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(s=this.thumbnailTime)!=null?s:this.startTime,programTime:this.programStartTime,token:r.thumbnail})}set poster(t){t||t===""?this.setAttribute(nr.POSTER,t):this.removeAttribute(nr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(U.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(U.STORYBOARD_SRC,t):this.removeAttribute(U.STORYBOARD_SRC)}get storyboard(){let{tokens:t}=this;if(this.storyboardSrc&&!t.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Re.LIVE,Re.UNKNOWN].includes(this.streamType)||t.playback&&!t.storyboard))return yT(this.playbackId,{customDomain:this.customDomain,token:t.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(U.AUDIO)}set audio(t){if(!t){this.removeAttribute(U.AUDIO);return}this.setAttribute(U.AUDIO,"")}get hotkeys(){return _e(this,Co)}get nohotkeys(){return this.hasAttribute(U.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(U.NOHOTKEYS);return}this.setAttribute(U.NOHOTKEYS,"")}get thumbnailTime(){return Rt(this.getAttribute(U.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(U.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(U.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(U.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=Os(this,U.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(U.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(U.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(U.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(U.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(U.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(U.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Ct.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(U.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(U.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(U.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(U.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(U.PLAYBACK_RATES))return this.getAttribute(U.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(U.PLAYBACK_RATES);return}this.setAttribute(U.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Rt(this.getAttribute(U.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(U.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Rt(this.getAttribute(U.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(U.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(U.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(U.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(U.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Rt(this.getAttribute(U.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute(U.DEFAULT_DURATION):this.setAttribute(U.DEFAULT_DURATION,`${t}`)}get playerInitTime(){return this.hasAttribute(C.PLAYER_INIT_TIME)?Rt(this.getAttribute(C.PLAYER_INIT_TIME)):_e(this,Io)}set playerInitTime(t){t!=this.playerInitTime&&(t==null?this.removeAttribute(C.PLAYER_INIT_TIME):this.setAttribute(C.PLAYER_INIT_TIME,`${+t}`))}get playerSoftwareName(){var t;return(t=this.getAttribute(C.PLAYER_SOFTWARE_NAME))!=null?t:w_}get playerSoftwareVersion(){var t;return(t=this.getAttribute(C.PLAYER_SOFTWARE_VERSION))!=null?t:C_}get beaconCollectionDomain(){var t;return(t=this.getAttribute(C.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(C.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(C.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(C.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(C.MAX_RESOLUTION,t):this.removeAttribute(C.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(C.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(C.MIN_RESOLUTION,t):this.removeAttribute(C.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(C.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(C.RENDITION_ORDER,t):this.removeAttribute(C.RENDITION_ORDER))}get programStartTime(){return Rt(this.getAttribute(C.PROGRAM_START_TIME))}set programStartTime(t){t==null?this.removeAttribute(C.PROGRAM_START_TIME):this.setAttribute(C.PROGRAM_START_TIME,`${t}`)}get programEndTime(){return Rt(this.getAttribute(C.PROGRAM_END_TIME))}set programEndTime(t){t==null?this.removeAttribute(C.PROGRAM_END_TIME):this.setAttribute(C.PROGRAM_END_TIME,`${t}`)}get assetStartTime(){return Rt(this.getAttribute(C.ASSET_START_TIME))}set assetStartTime(t){t==null?this.removeAttribute(C.ASSET_START_TIME):this.setAttribute(C.ASSET_START_TIME,`${t}`)}get assetEndTime(){return Rt(this.getAttribute(C.ASSET_END_TIME))}set assetEndTime(t){t==null?this.removeAttribute(C.ASSET_END_TIME):this.setAttribute(C.ASSET_END_TIME,`${t}`)}get extraSourceParams(){return this.hasAttribute(U.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(U.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):oD}set extraSourceParams(t){t==null?this.removeAttribute(U.EXTRA_SOURCE_PARAMS):this.setAttribute(U.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(C.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(C.CUSTOM_DOMAIN,t):this.removeAttribute(C.CUSTOM_DOMAIN))}get envKey(){var t;return(t=Os(this,C.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(C.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(U.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(U.NO_VOLUME_PREF,""):this.removeAttribute(U.NO_VOLUME_PREF)}get debug(){return Os(this,C.DEBUG)!=null}set debug(t){t?this.setAttribute(C.DEBUG,""):this.removeAttribute(C.DEBUG)}get disableTracking(){return Os(this,C.DISABLE_TRACKING)!=null}set disableTracking(t){this.toggleAttribute(C.DISABLE_TRACKING,!!t)}get disableCookies(){return Os(this,C.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(C.DISABLE_COOKIES,""):this.removeAttribute(C.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(C.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:Re.UNKNOWN}set streamType(t){this.setAttribute(C.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?s:Re.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(U.DEFAULT_STREAM_TYPE,t):this.removeAttribute(U.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(U.TARGET_LIVE_WINDOW)?+this.getAttribute(U.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute(U.TARGET_LIVE_WINDOW):this.setAttribute(U.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Rt(Os(this,C.START_TIME))}set startTime(t){this.setAttribute(C.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(C.PREFER_PLAYBACK);if(t===qt.MSE||t===qt.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===qt.MSE||t===qt.NATIVE?this.setAttribute(C.PREFER_PLAYBACK,t):this.removeAttribute(C.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(Qe(this,Ce,Dr).call(this),!this.media){Ut("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...k_(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(Qe(this,Ce,Dr).call(this),!this.media){Ut("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(Qe(this,Ce,Dr).call(this),!this.media){Ut("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}addChapters(t){var r;if(Qe(this,Ce,Dr).call(this),!this.media){Ut("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(r=this.media)==null?void 0:r.addChapters(t)}get activeChapter(){var t;return(t=this.media)==null?void 0:t.activeChapter}get chapters(){var t,r;return(r=(t=this.media)==null?void 0:t.chapters)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(U.PLAYBACK_TOKEN),r=this.getAttribute(U.DRM_TOKEN),s=this.getAttribute(U.THUMBNAIL_TOKEN),n=this.getAttribute(U.STORYBOARD_TOKEN);return{..._e(this,ko),...t!=null?{playback:t}:{},...r!=null?{drm:r}:{},...s!=null?{thumbnail:s}:{},...n!=null?{storyboard:n}:{}}}set tokens(t){$t(this,ko,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(U.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(U.PLAYBACK_TOKEN,`${t}`)}get drmToken(){var t;return(t=this.getAttribute(U.DRM_TOKEN))!=null?t:void 0}set drmToken(t){this.setAttribute(U.DRM_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(U.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(U.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(U.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(U.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return Jd(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return ky(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}get castReceiver(){var t;return(t=this.getAttribute(U.CAST_RECEIVER))!=null?t:void 0}set castReceiver(t){t!==this.castReceiver&&(t?this.setAttribute(U.CAST_RECEIVER,t):this.removeAttribute(U.CAST_RECEIVER))}get castCustomData(){var t;return(t=this.media)==null?void 0:t.castCustomData}set castCustomData(t){if(!this.media){Ut("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=t}get noTooltips(){return this.hasAttribute(U.NO_TOOLTIPS)}set noTooltips(t){if(!t){this.removeAttribute(U.NO_TOOLTIPS);return}this.setAttribute(U.NO_TOOLTIPS,"")}};Io=new WeakMap,Lo=new WeakMap,ko=new WeakMap,Mr=new WeakMap,Co=new WeakMap,Us=new WeakMap,Ce=new WeakSet,Dr=function(){var t,r,s,n;if(!_e(this,Lo)){$t(this,Lo,!0),Qe(this,Ce,Ns).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Ct.HTMLElement))throw""}catch{Ut("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof gT))throw""}catch{Ut("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Fc))throw""}catch{Ut("<media-controller> failed to upgrade!")}this.init(),Qe(this,Ce,P_).call(this),Qe(this,Ce,O_).call(this),Qe(this,Ce,N_).call(this),$t(this,Mr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(ve.USER_INACTIVE))!=null?r:!0),Qe(this,Ce,U_).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>Qe(this,Ce,Ns).call(this)),(n=this.media)==null||n.addEventListener("loadstart",()=>Qe(this,Ce,Ns).call(this))}},M_=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Cg=function(t){Object.assign(_e(this,Us),t),Qe(this,Ce,Ns).call(this)},Ns=function(t={}){$T(HT(eD(this,{..._e(this,Us),...t})),this.shadowRoot)},P_=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(kg.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},O_=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof K||(n=new K(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Oi(n),n.data&&Oi(`${n.name} data:`,n.data);return}let a=Hp(n,!1);a.message&&Lp(a),Ut(n),n.data&&Ut(`${n.name} data:`,n.data),Qe(this,Ce,Cg).call(this,{isDialogOpen:!0})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof K))return s;let n=Hp((o=this.media)==null?void 0:o.error,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new K(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},N_=function(){var r,s,n,a;let t=()=>Qe(this,Ce,Ns).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},U_=function(){var d,u;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===Re.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(c,h,f=!1)=>{if(n())return;Array.from(c&&c.activeCues||[]).forEach(p=>{if(!(!p.snapToLines||p.line<-5||p.line>=0&&p.line<10))if(!h||this.paused){let g=p.text.split(`
2981
+ `).length,E=-3;this.streamType===Re.LIVE&&(E=-2);let b=E-g;if(p.line===b&&!f)return;s.has(p)||s.set(p,p.line),p.line=b}else setTimeout(()=>{p.line=s.get(p)||"auto"},500)})},o=()=>{var c,h;a(r,(h=(c=this.mediaController)==null?void 0:c.hasAttribute(ve.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,m;let h=Array.from(((m=(f=this.mediaController)==null?void 0:f.media)==null?void 0:m.textTracks)||[]).filter(p=>["subtitles","captions"].includes(p.kind)&&p.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,_e(this,Mr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(u=this.textTracks)==null||u.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let c=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(ve.USER_INACTIVE))!=null?f:!0;_e(this,Mr)!==c&&($t(this,Mr,c),a(r,_e(this,Mr)))})};function Os(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}Ct.customElements.get("mux-player")||(Ct.customElements.define("mux-player",Ro),Ct.MuxPlayerElement=Ro);var KF=Ro;})();
2982
2982
  /*! Bundled license information:
2983
2983
 
2984
2984
  mux-embed/dist/mux.mjs: