@maveio/components 0.0.156 → 0.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-45FW5DBN.js → chunk-24TUG5TP.js} +1 -1
- package/dist/{chunk-Z5AM3NST.cjs → chunk-32WXLTTE.cjs} +2 -2
- package/dist/{chunk-4CDE2QCJ.js → chunk-6XR2OUZW.js} +1 -1
- package/dist/chunk-7ZRXZY5C.js +20 -0
- package/dist/{chunk-TVNAG7X4.cjs → chunk-B3QILQEE.cjs} +3 -3
- package/dist/{chunk-6MCTUE3H.js → chunk-CHHWULL2.js} +4 -4
- package/dist/chunk-DITZCOYN.cjs +379 -0
- package/dist/{chunk-MKZYI5TY.cjs → chunk-EOHKHSQ3.cjs} +1 -1
- package/dist/{chunk-KTGL4HLA.cjs → chunk-FUSQ4EZG.cjs} +2 -2
- package/dist/chunk-JHSFSCC2.cjs +1 -0
- package/dist/chunk-KA24PL7V.js +1 -0
- package/dist/{chunk-VZKW2VWI.js → chunk-KNAAIER3.js} +2 -2
- package/dist/{chunk-5KQJTT3P.cjs → chunk-KVMGCTLR.cjs} +1 -1
- package/dist/{chunk-4DCPDVPE.js → chunk-LT26CEMU.js} +57 -5
- package/dist/{chunk-JBRRVOTV.cjs → chunk-MLZIA6JO.cjs} +5 -5
- package/dist/chunk-MSWONVA7.cjs +20 -0
- package/dist/{chunk-4AYP3SUJ.js → chunk-NKEVN7FX.js} +1 -1
- package/dist/{chunk-PLCF3Z5Q.cjs → chunk-OTRPT6Y4.cjs} +4 -4
- package/dist/{chunk-MC6T46LX.cjs → chunk-PHGKLFNF.cjs} +1 -1
- package/dist/chunk-QSQE5WBN.js +35 -0
- package/dist/chunk-QZSLJNS4.js +7 -0
- package/dist/chunk-STJ6CEFZ.cjs +1468 -0
- package/dist/chunk-T2P4BAWY.js +379 -0
- package/dist/chunk-ULZI6OGL.js +1468 -0
- package/dist/chunk-W3KNVBI3.cjs +213 -0
- package/dist/{chunk-CUGRXOA2.js → chunk-XLUB3ATV.js} +1 -1
- package/dist/{chunk-6NWQAHZT.cjs → chunk-ZLS57S3I.cjs} +1 -1
- package/dist/components/audio-track-menu.cjs +1 -0
- package/dist/components/audio-track-menu.d.cts +27 -0
- package/dist/components/audio-track-menu.d.ts +27 -0
- package/dist/components/audio-track-menu.js +1 -0
- package/dist/components/clip.cjs +1 -1
- package/dist/components/clip.js +1 -1
- package/dist/components/files.cjs +1 -1
- package/dist/components/files.js +1 -1
- package/dist/components/img.cjs +1 -1
- package/dist/components/img.js +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/player.cjs +1 -1
- package/dist/components/player.d.cts +8 -0
- package/dist/components/player.d.ts +8 -0
- package/dist/components/player.js +1 -1
- package/dist/components/pop.cjs +1 -1
- package/dist/components/pop.js +1 -1
- package/dist/components/text.cjs +1 -1
- package/dist/components/text.js +1 -1
- package/dist/components/upload.cjs +1 -1
- package/dist/components/upload.d.cts +18 -1
- package/dist/components/upload.d.ts +18 -1
- package/dist/components/upload.js +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.js +1 -1
- package/dist/embed/api.cjs +1 -1
- package/dist/embed/api.d.cts +11 -1
- package/dist/embed/api.d.ts +11 -1
- package/dist/embed/api.js +1 -1
- package/dist/embed/caption.cjs +1 -1
- package/dist/embed/caption.js +1 -1
- package/dist/embed/controller.cjs +1 -1
- package/dist/embed/controller.js +1 -1
- package/dist/embed/socket.cjs +1 -1
- package/dist/embed/socket.d.cts +3 -5
- package/dist/embed/socket.d.ts +3 -5
- package/dist/embed/socket.js +1 -1
- package/dist/generated/locales/de.cjs +1 -1
- package/dist/generated/locales/de.d.cts +5 -0
- package/dist/generated/locales/de.d.ts +5 -0
- package/dist/generated/locales/de.js +1 -1
- package/dist/generated/locales/en.cjs +1 -1
- package/dist/generated/locales/en.d.cts +5 -0
- package/dist/generated/locales/en.d.ts +5 -0
- package/dist/generated/locales/en.js +1 -1
- package/dist/generated/locales/fr.cjs +1 -1
- package/dist/generated/locales/fr.d.cts +5 -0
- package/dist/generated/locales/fr.d.ts +5 -0
- package/dist/generated/locales/fr.js +1 -1
- package/dist/generated/locales/nl.cjs +1 -1
- package/dist/generated/locales/nl.d.cts +5 -0
- package/dist/generated/locales/nl.d.ts +5 -0
- package/dist/generated/locales/nl.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/themes/default.cjs +53 -1
- package/dist/themes/default.js +53 -1
- package/dist/themes/dolphin.cjs +1 -1
- package/dist/themes/dolphin.js +1 -1
- package/dist/themes/loader.cjs +1 -1
- package/dist/themes/loader.js +1 -1
- package/dist/themes/synthwave.cjs +1 -1
- package/dist/themes/synthwave.js +1 -1
- package/dist/utils/localization.cjs +1 -1
- package/dist/utils/localization.js +1 -1
- package/dist/utils/mave_element.cjs +1 -1
- package/dist/utils/mave_element.js +1 -1
- package/dist/utils/origin.cjs +1 -1
- package/dist/utils/origin.js +1 -1
- package/dist/utils/video_events.cjs +1 -1
- package/dist/utils/video_events.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-5IPIXU3O.js +0 -1807
- package/dist/chunk-DESQSXZF.cjs +0 -161
- package/dist/chunk-IBTJ5OMP.js +0 -35
- package/dist/chunk-IPA5Q26W.cjs +0 -1
- package/dist/chunk-LGWESJBJ.cjs +0 -20
- package/dist/chunk-NDDFZTBA.js +0 -1
- package/dist/chunk-SRXHXTDF.js +0 -7
- package/dist/chunk-ZMMJMM4X.cjs +0 -1807
- package/dist/chunk-ZT2E4EC7.js +0 -20
- /package/dist/{chunk-NI57YLPL.cjs → chunk-BVMU4ZXD.cjs} +0 -0
- /package/dist/{chunk-EXNM5EV2.js → chunk-DFLPNNA4.js} +0 -0
- /package/dist/{chunk-FSFJQ67W.js → chunk-FRPU6QLJ.js} +0 -0
package/dist/chunk-ZMMJMM4X.cjs
DELETED
|
@@ -1,1807 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkNI57YLPL_cjs=require('./chunk-NI57YLPL.cjs'),chunkQ22T22LT_cjs=require('./chunk-Q22T22LT.cjs'),chunk5KQJTT3P_cjs=require('./chunk-5KQJTT3P.cjs'),chunkSDKTBB4N_cjs=require('./chunk-SDKTBB4N.cjs'),chunkYT56YDUY_cjs=require('./chunk-YT56YDUY.cjs'),chunkMKZYI5TY_cjs=require('./chunk-MKZYI5TY.cjs'),chunkFUBUUA7Y_cjs=require('./chunk-FUBUUA7Y.cjs'),chunk5NSCV6C2_cjs=require('./chunk-5NSCV6C2.cjs'),chunk5STN56TL_cjs=require('./chunk-5STN56TL.cjs'),chunkIPA5Q26W_cjs=require('./chunk-IPA5Q26W.cjs');var F={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"},re={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Gl={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_LANG:"mediaLang",MEDIA_WIDTH:"mediaWidth"},Gh=Object.entries(Gl),T=Gh.reduce((s,[e,t])=>(s[e]=t.toLowerCase(),s),{}),w0={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Ki=Gh.reduce((s,[e,t])=>(s[e]=t.toLowerCase(),s),{...w0});Object.entries(Ki).reduce((s,[e,t])=>{let i=T[e];return i&&(s[t]=i),s},{userinactivechange:"userinactive"});var Hh=Object.entries(T).reduce((s,[e,t])=>{let i=Ki[e];return i&&(s[t]=i),s},{userinactive:"userinactivechange"}),ot={SUBTITLES:"subtitles",CAPTIONS:"captions",CHAPTERS:"chapters",METADATA:"metadata"},Ai={DISABLED:"disabled",SHOWING:"showing"};var Hl={MOUSE:"mouse",TOUCH:"touch"},pt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},kt={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Vh={FULLSCREEN:"fullscreen"};function Kh(s){return s?.map(O0).join(" ")}function Wh(s){return s?.split(/\s+/).map(N0)}function O0(s){if(s){let{id:e,width:t,height:i}=s;return [e,t,i].filter(r=>r!=null).join(":")}}function N0(s){if(s){let[e,t,i]=s.split(":");return {id:e,width:+t,height:+i}}}function qh(s){return s?.map(F0).join(" ")}function Yh(s){return s?.split(/\s+/).map(U0)}function F0(s){if(s){let{id:e,kind:t,language:i,label:r}=s;return [e,t,i,r].filter(n=>n!=null).join(":")}}function U0(s){if(s){let[e,t,i,r]=s.split(":");return {id:e,kind:t,language:i,label:r}}}function _s(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}var Qn=s=>new Promise(e=>setTimeout(e,s));var jh=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],B0=(s,e)=>{let t=s===1?jh[e].singular:jh[e].plural;return `${s} ${t}`},Wi=s=>{if(!_s(s))return "";let e=Math.abs(s),t=e!==s,i=new Date(0,0,0,0,0,e,0);return `${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,d)=>o&&B0(o,d)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ct(s,e){let t=false;s<0&&(t=true,s=0-s),s=s<0?0:s;let i=Math.floor(s%60),r=Math.floor(s/60%60),n=Math.floor(s/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return (isNaN(s)||s===1/0)&&(n=r=i="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",i=i<10?"0"+i:i,(t?"-":"")+n+r+i}var zh={"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute","chapter: {chapterName}":"chapter: {chapterName}",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","Source Not Supported":"Source Not Supported","Encryption Error":"Encryption Error","A network error caused the media download to fail.":"A network error caused the media download to fail.","A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.":"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.","An unsupported error occurred. The server or network failed, or your browser does not support this format.":"An unsupported error occurred. The server or network failed, or your browser does not support this format.","The media is encrypted and there are no keys to decrypt it.":"The media is encrypted and there are no keys to decrypt it."};var Qh,Vl={en:zh},Kl=((Qh=globalThis.navigator)==null?void 0:Qh.language)||"en",Xh=s=>{Kl=s;};var G0=s=>{var e,t,i;let[r]=Kl.split("-");return ((e=Vl[Kl])==null?void 0:e[s])||((t=Vl[r])==null?void 0:t[s])||((i=Vl.en)==null?void 0:i[s])||s},w=(s,e={})=>G0(s).replace(/\{(\w+)\}/g,(t,i)=>i in e?String(e[i]):`{${i}}`);var Xn=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return true}},Zn=class extends Xn{},Jn=class extends Zn{constructor(){super(...arguments),this.role=null;}},Wl=class{observe(){}unobserve(){}disconnect(){}},Zh={createElement:function(){return new Ar.HTMLElement},createElementNS:function(){return new Ar.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(s){return false}},Ar={ResizeObserver:Wl,document:Zh,Node:Zn,Element:Jn,HTMLElement:class extends Jn{constructor(){super(...arguments),this.innerHTML="";}get content(){return new Ar.DocumentFragment}},DocumentFragment:class extends Xn{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(s){return null},setItem(s,e){},removeItem(s){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return ""}},matchMedia(s){return {matches:false,media:s}},DOMParser:class{parseFromString(e,t){return {body:{textContent:e}}}}},Jh=typeof window>"u"||typeof window.customElements>"u",ef=Object.keys(Ar).every(s=>s in globalThis),A=Jh&&!ef?Ar:globalThis,Ce=Jh&&!ef?Zh:globalThis.document;var tf=new WeakMap,ql=s=>{let e=tf.get(s);return e||tf.set(s,e=new Set),e},sf=new A.ResizeObserver(s=>{for(let e of s)for(let t of ql(e.target))t(e);});function hi(s,e){ql(s).add(e),sf.observe(s);}function fi(s,e){let t=ql(s);t.delete(e),t.size||sf.unobserve(s);}function Le(s){let e={};for(let t of s)e[t.name]=t.value;return e}function Me(s){var e;return (e=ea(s))!=null?e:Ht(s,"media-controller")}function ea(s){var e;let{MEDIA_CONTROLLER:t}=re,i=s.getAttribute(t);if(i)return (e=qi(s))==null?void 0:e.getElementById(i)}var ta=(s,e,t=".value")=>{let i=s.querySelector(t);i&&(i.textContent=e);},H0=(s,e)=>{let t=`slot[name="${e}"]`,i=s.shadowRoot.querySelector(t);return i?i.children:[]},ia=(s,e)=>H0(s,e)[0],at=(s,e)=>!s||!e?false:s?.contains(e)?true:at(s,e.getRootNode().host),Ht=(s,e)=>{if(!s)return null;let t=s.closest(e);return t||Ht(s.getRootNode().host,e)};function _r(s=document){var e;let t=s?.activeElement;return t?(e=_r(t.shadowRoot))!=null?e:t:null}function qi(s){var e;let t=(e=s?.getRootNode)==null?void 0:e.call(s);return t instanceof ShadowRoot||t instanceof Document?t:null}function sa(s,{depth:e=3,checkOpacity:t=true,checkVisibilityCSS:i=true}={}){if(s.checkVisibility)return s.checkVisibility({checkOpacity:t,checkVisibilityCSS:i});let r=s;for(;r&&e>0;){let n=getComputedStyle(r);if(t&&n.opacity==="0"||i&&n.visibility==="hidden"||n.display==="none")return false;r=r.parentElement,e--;}return true}function rf(s,e,t,i){let r=i.x-t.x,n=i.y-t.y,a=r*r+n*n;if(a===0)return 0;let o=((s-t.x)*r+(e-t.y)*n)/a;return Math.max(0,Math.min(1,o))}function ye(s,e){let t=V0(s,i=>i===e);return t||Yl(s,e)}function V0(s,e){var t,i;let r;for(r of (t=s.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(i=r.sheet)==null?void 0:i.cssRules;}catch{continue}for(let a of n??[])if(e(a.selectorText))return a}}function Yl(s,e){var t,i;let r=(t=s.querySelectorAll("style:not([media])"))!=null?t:[],n=r?.[r.length-1];return n?.sheet?(n?.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(i=n.sheet.cssRules)==null?void 0:i[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",s),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function ae(s,e,t=Number.NaN){let i=s.getAttribute(e);return i!=null?+i:t}function he(s,e,t){let i=+t;if(t==null||Number.isNaN(i)){s.hasAttribute(e)&&s.removeAttribute(e);return}ae(s,e,void 0)!==i&&s.setAttribute(e,`${i}`);}function X(s,e){return s.hasAttribute(e)}function Z(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}X(s,e)!=t&&s.toggleAttribute(e,t);}function te(s,e,t=null){var i;return (i=s.getAttribute(e))!=null?i:t}function ie(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}let i=`${t}`;te(s,e,void 0)!==i&&s.setAttribute(e,i);}var nf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},_i=(s,e,t)=>(nf(s,e,"read from private field"),t?t.call(s):e.get(s)),K0=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},ra=(s,e,t,i)=>(nf(s,e,"write to private field"),e.set(s,t),t),lt;function W0(s){return `
|
|
2
|
-
<style>
|
|
3
|
-
:host {
|
|
4
|
-
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
5
|
-
box-sizing: border-box;
|
|
6
|
-
}
|
|
7
|
-
</style>
|
|
8
|
-
`}var Is=class extends A.HTMLElement{constructor(){if(super(),K0(this,lt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [re.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===re.MEDIA_CONTROLLER&&(t&&((n=(r=_i(this,lt))==null?void 0:r.unassociateElement)==null||n.call(r,this),ra(this,lt,null)),i&&this.isConnected&&(ra(this,lt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=_i(this,lt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),ra(this,lt,q0(this)),this.getAttribute(re.MEDIA_CONTROLLER)&&((t=(e=_i(this,lt))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=_i(this,lt))==null||i.addEventListener("pointerdown",this),(r=_i(this,lt))==null||r.addEventListener("click",this);}disconnectedCallback(){var e,t,i,r;this.getAttribute(re.MEDIA_CONTROLLER)&&((t=(e=_i(this,lt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=_i(this,lt))==null||i.removeEventListener("pointerdown",this),(r=_i(this,lt))==null||r.removeEventListener("click",this),ra(this,lt,null);}handleEvent(e){var t;let i=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(i?.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:d,width:l,height:c}=this.getBoundingClientRect(),u=n-o,h=a-d;if(u<0||h<0||u>l||h>c||l===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Hl.TOUCH){this.handleTap(e);return}else if(f===Hl.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return X(this,T.MEDIA_PAUSED)}set mediaPaused(e){Z(this,T.MEDIA_PAUSED,e);}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new A.CustomEvent(t,{composed:true,bubbles:true}));}};lt=new WeakMap;Is.shadowRootOptions={mode:"open"};Is.getTemplateHTML=W0;function q0(s){var e;let t=s.getAttribute(re.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):Ht(s,"media-controller")}A.customElements.get("media-gesture-receiver")||A.customElements.define("media-gesture-receiver",Is);var na=Is;var Xl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},vt=(s,e,t)=>(Xl(s,e,"read from private field"),t?t.call(s):e.get(s)),Et=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Yi=(s,e,t,i)=>(Xl(s,e,"write to private field"),e.set(s,t),t),_t=(s,e,t)=>(Xl(s,e,"access private method"),t),la,Ls,Lr,xs,aa,jl,af,Ir,oa,zl,of,Ql,lf,xr,da,ca,Zl,Rs,Rr,Q={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};function Y0(s){return `
|
|
9
|
-
<style>
|
|
10
|
-
|
|
11
|
-
:host([${T.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
12
|
-
outline: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:host {
|
|
16
|
-
box-sizing: border-box;
|
|
17
|
-
position: relative;
|
|
18
|
-
display: inline-block;
|
|
19
|
-
line-height: 0;
|
|
20
|
-
background-color: var(--media-background-color, #000);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
:host(:not([${Q.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 0;
|
|
26
|
-
left: 0;
|
|
27
|
-
bottom: 0;
|
|
28
|
-
right: 0;
|
|
29
|
-
display: flex;
|
|
30
|
-
flex-flow: column nowrap;
|
|
31
|
-
align-items: start;
|
|
32
|
-
pointer-events: none;
|
|
33
|
-
background: none;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
slot[name=media] {
|
|
37
|
-
display: var(--media-slot-display, contents);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
:host([${Q.AUDIO}]) slot[name=media] {
|
|
42
|
-
display: var(--media-slot-display, none);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
:host([${Q.AUDIO}]) [part~=layer][part~=gesture-layer] {
|
|
47
|
-
height: 0;
|
|
48
|
-
display: block;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
:host(:not([${Q.AUDIO}])[${Q.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
|
|
53
|
-
:host(:not([${Q.AUDIO}])[${Q.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
|
|
54
|
-
display: none;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([role=dialog]):not([hidden])) {
|
|
59
|
-
pointer-events: auto;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
:host(:not([${Q.AUDIO}])) *[part~=layer][part~=centered-layer] {
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
:host(:not([${Q.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
|
|
68
|
-
:host(:not([${Q.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
|
|
69
|
-
align-self: stretch;
|
|
70
|
-
flex-grow: 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
slot[name=middle-chrome] {
|
|
74
|
-
display: inline;
|
|
75
|
-
flex-grow: 1;
|
|
76
|
-
pointer-events: none;
|
|
77
|
-
background: none;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
::slotted([slot=media]),
|
|
82
|
-
::slotted([slot=poster]) {
|
|
83
|
-
width: 100%;
|
|
84
|
-
height: 100%;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
:host(:not([${Q.AUDIO}])) .spacer {
|
|
89
|
-
flex-grow: 1;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
:host(:-webkit-full-screen) {
|
|
94
|
-
|
|
95
|
-
width: 100% !important;
|
|
96
|
-
height: 100% !important;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
::slotted(:not([slot=media]):not([slot=poster]):not([${Q.NO_AUTOHIDE}]):not([hidden]):not([role=dialog])) {
|
|
101
|
-
opacity: 1;
|
|
102
|
-
transition: var(--media-control-transition-in, opacity 0.25s);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
:host([${Q.USER_INACTIVE}]:not([${T.MEDIA_PAUSED}]):not([${T.MEDIA_IS_AIRPLAYING}]):not([${T.MEDIA_IS_CASTING}]):not([${Q.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${Q.NO_AUTOHIDE}]):not([role=dialog])) {
|
|
107
|
-
opacity: 0;
|
|
108
|
-
transition: var(--media-control-transition-out, opacity 1s);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:host([${Q.USER_INACTIVE}]:not([${Q.NO_AUTOHIDE}]):not([${T.MEDIA_PAUSED}]):not([${T.MEDIA_IS_CASTING}]):not([${Q.AUDIO}])) ::slotted([slot=media]) {
|
|
112
|
-
cursor: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:host([${Q.USER_INACTIVE}][${Q.AUTOHIDE_OVER_CONTROLS}]:not([${Q.NO_AUTOHIDE}]):not([${T.MEDIA_PAUSED}]):not([${T.MEDIA_IS_CASTING}]):not([${Q.AUDIO}])) * {
|
|
116
|
-
--media-cursor: none;
|
|
117
|
-
cursor: none;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
::slotted(media-control-bar) {
|
|
122
|
-
align-self: stretch;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
:host(:not([${Q.AUDIO}])[${T.MEDIA_HAS_PLAYED}]) slot[name=poster] {
|
|
127
|
-
display: none;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
::slotted([role=dialog]) {
|
|
131
|
-
width: 100%;
|
|
132
|
-
height: 100%;
|
|
133
|
-
align-self: center;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
::slotted([role=menu]) {
|
|
137
|
-
align-self: end;
|
|
138
|
-
}
|
|
139
|
-
</style>
|
|
140
|
-
|
|
141
|
-
<slot name="media" part="layer media-layer"></slot>
|
|
142
|
-
<slot name="poster" part="layer poster-layer"></slot>
|
|
143
|
-
<slot name="gestures-chrome" part="layer gesture-layer">
|
|
144
|
-
<media-gesture-receiver slot="gestures-chrome">
|
|
145
|
-
<template shadowrootmode="${na.shadowRootOptions.mode}">
|
|
146
|
-
${na.getTemplateHTML({})}
|
|
147
|
-
</template>
|
|
148
|
-
</media-gesture-receiver>
|
|
149
|
-
</slot>
|
|
150
|
-
<span part="layer vertical-layer">
|
|
151
|
-
<slot name="top-chrome" part="top chrome"></slot>
|
|
152
|
-
<slot name="middle-chrome" part="middle chrome"></slot>
|
|
153
|
-
<slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>
|
|
154
|
-
|
|
155
|
-
<slot part="bottom chrome"></slot>
|
|
156
|
-
</span>
|
|
157
|
-
<slot name="dialog" part="layer dialog-layer"></slot>
|
|
158
|
-
`}var j0=Object.values(T),z0="sm:384 md:576 lg:768 xl:960";function Q0(s){df(s.target,s.contentRect.width);}function df(s,e){var t;if(!s.isConnected)return;let i=(t=s.getAttribute(Q.BREAKPOINTS))!=null?t:z0,r=X0(i),n=Z0(r,e),a=false;if(Object.keys(r).forEach(o=>{if(n.includes(o)){s.hasAttribute(`breakpoint${o}`)||(s.setAttribute(`breakpoint${o}`,""),a=true);return}s.hasAttribute(`breakpoint${o}`)&&(s.removeAttribute(`breakpoint${o}`),a=true);}),a){let o=new CustomEvent(Ki.BREAKPOINTS_CHANGE,{detail:n});s.dispatchEvent(o);}s.breakpointsComputed||(s.breakpointsComputed=true,s.dispatchEvent(new CustomEvent(Ki.BREAKPOINTS_COMPUTED,{bubbles:true,composed:true})));}function X0(s){let e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Z0(s,e){return Object.keys(s).filter(t=>e>=parseInt(s[t]))}var ji=class extends A.HTMLElement{constructor(){if(super(),Et(this,jl),Et(this,zl),Et(this,Ql),Et(this,xr),Et(this,ca),Et(this,Rs),Et(this,la,0),Et(this,Ls,null),Et(this,Lr,null),Et(this,xs,void 0),this.breakpointsComputed=false,Et(this,aa,new MutationObserver(_t(this,jl,af).bind(this))),Et(this,Ir,false),Et(this,oa,t=>{vt(this,Ir)||(setTimeout(()=>{Q0(t),Yi(this,Ir,false);},0),Yi(this,Ir,true));}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let t=Le(this.attributes),i=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(i):this.shadowRoot.innerHTML=i;}let e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:true}).length){vt(this,Ls)&&this.mediaUnsetCallback(vt(this,Ls));return}this.handleMediaUpdated(this.media);});}static get observedAttributes(){return [Q.AUTOHIDE,Q.GESTURES_DISABLED].concat(j0).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES,T.MEDIA_WIDTH,T.MEDIA_HEIGHT,T.MEDIA_ERROR,T.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==Q.AUTOHIDE&&(this.autohide=i);}get media(){let e=this.querySelector(":scope > [slot=media]");return e?.nodeName=="SLOT"&&(e=e.assignedElements({flatten:true})[0]),e}async handleMediaUpdated(e){e&&(Yi(this,Ls,e),e.localName.includes("-")&&await A.customElements.whenDefined(e.localName),this.mediaSetCallback(e));}connectedCallback(){var e;vt(this,aa).observe(this,{childList:true,subtree:true}),hi(this,vt(this,oa));let i=this.getAttribute(Q.AUDIO)!=null?w("audio player"):w("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(Q.USER_INACTIVE,""),df(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=A.window)==null||e.addEventListener("mouseup",this);}disconnectedCallback(){var e;vt(this,aa).disconnect(),fi(this,vt(this,oa)),this.media&&this.mediaUnsetCallback(this.media),(e=A.window)==null||e.removeEventListener("mouseup",this);}mediaSetCallback(e){}mediaUnsetCallback(e){Yi(this,Ls,null);}handleEvent(e){switch(e.type){case "pointerdown":Yi(this,la,e.timeStamp);break;case "pointermove":_t(this,zl,of).call(this,e);break;case "pointerup":_t(this,Ql,lf).call(this,e);break;case "mouseleave":_t(this,xr,da).call(this);break;case "mouseup":this.removeAttribute(Q.KEYBOARD_CONTROL);break;case "keyup":_t(this,Rs,Rr).call(this),this.setAttribute(Q.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);Yi(this,xs,isNaN(t)?0:t);}get autohide(){return (vt(this,xs)===void 0?2:vt(this,xs)).toString()}get breakpoints(){return te(this,Q.BREAKPOINTS)}set breakpoints(e){ie(this,Q.BREAKPOINTS,e);}get audio(){return X(this,Q.AUDIO)}set audio(e){Z(this,Q.AUDIO,e);}get gesturesDisabled(){return X(this,Q.GESTURES_DISABLED)}set gesturesDisabled(e){Z(this,Q.GESTURES_DISABLED,e);}get keyboardControl(){return X(this,Q.KEYBOARD_CONTROL)}set keyboardControl(e){Z(this,Q.KEYBOARD_CONTROL,e);}get noAutohide(){return X(this,Q.NO_AUTOHIDE)}set noAutohide(e){Z(this,Q.NO_AUTOHIDE,e);}get autohideOverControls(){return X(this,Q.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){Z(this,Q.AUTOHIDE_OVER_CONTROLS,e);}get userInteractive(){return X(this,Q.USER_INACTIVE)}set userInteractive(e){Z(this,Q.USER_INACTIVE,e);}};la=new WeakMap;Ls=new WeakMap;Lr=new WeakMap;xs=new WeakMap;aa=new WeakMap;jl=new WeakSet;af=function(s){let e=this.media;for(let t of s){if(t.type!=="childList")continue;let i=t.removedNodes;for(let r of i){if(r.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(r);else {let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=false);a&&this.mediaUnsetCallback(r);}}if(e)for(let r of t.addedNodes)r===e&&this.handleMediaUpdated(e);}};Ir=new WeakMap;oa=new WeakMap;zl=new WeakSet;of=function(s){if(s.pointerType!=="mouse"&&s.timeStamp-vt(this,la)<250)return;_t(this,ca,Zl).call(this),clearTimeout(vt(this,Lr));let e=this.hasAttribute(Q.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(s.target)||e)&&_t(this,Rs,Rr).call(this);};Ql=new WeakSet;lf=function(s){if(s.pointerType==="touch"){let e=!this.hasAttribute(Q.USER_INACTIVE);[this,this.media].includes(s.target)&&e?_t(this,xr,da).call(this):_t(this,Rs,Rr).call(this);}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&_t(this,Rs,Rr).call(this);};xr=new WeakSet;da=function(){if(vt(this,xs)<0||this.hasAttribute(Q.USER_INACTIVE))return;this.setAttribute(Q.USER_INACTIVE,"");let s=new A.CustomEvent(Ki.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:true});this.dispatchEvent(s);};ca=new WeakSet;Zl=function(){if(!this.hasAttribute(Q.USER_INACTIVE))return;this.removeAttribute(Q.USER_INACTIVE);let s=new A.CustomEvent(Ki.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:false});this.dispatchEvent(s);};Rs=new WeakSet;Rr=function(){_t(this,ca,Zl).call(this),clearTimeout(vt(this,Lr));let s=parseInt(this.autohide);s<0||Yi(this,Lr,setTimeout(()=>{_t(this,xr,da).call(this);},s*1e3));};ji.shadowRootOptions={mode:"open"};ji.getTemplateHTML=Y0;A.customElements.get("media-container")||A.customElements.define("media-container",ji);var cf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ye=(s,e,t)=>(cf(s,e,"read from private field"),t?t.call(s):e.get(s)),Dr=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},ua=(s,e,t,i)=>(cf(s,e,"write to private field"),e.set(s,t),t),Ds,ks,ha,zi,mi,Ii,Li=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Dr(this,mi),Dr(this,Ds,void 0),Dr(this,ks,void 0),Dr(this,ha,void 0),Dr(this,zi,new Set),ua(this,Ds,e),ua(this,ks,t),ua(this,ha,new Set(i));}[Symbol.iterator](){return Ye(this,mi,Ii).values()}get length(){return Ye(this,mi,Ii).size}get value(){var e;return (e=[...Ye(this,mi,Ii)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ua(this,zi,new Set),this.add(...(t=e?.split(" "))!=null?t:[]));}toString(){return this.value}item(e){return [...Ye(this,mi,Ii)][e]}values(){return Ye(this,mi,Ii).values()}forEach(e,t){Ye(this,mi,Ii).forEach(e,t);}add(...e){var t,i;e.forEach(r=>Ye(this,zi).add(r)),!(this.value===""&&!((t=Ye(this,Ds))!=null&&t.hasAttribute(`${Ye(this,ks)}`)))&&((i=Ye(this,Ds))==null||i.setAttribute(`${Ye(this,ks)}`,`${this.value}`));}remove(...e){var t;e.forEach(i=>Ye(this,zi).delete(i)),(t=Ye(this,Ds))==null||t.setAttribute(`${Ye(this,ks)}`,`${this.value}`);}contains(e){return Ye(this,mi,Ii).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),true):(this.remove(e),false):this.contains(e)?(this.remove(e),false):(this.add(e),true)}replace(e,t){return this.remove(e),this.add(t),e===t}};Ds=new WeakMap;ks=new WeakMap;ha=new WeakMap;zi=new WeakMap;mi=new WeakSet;Ii=function(){return Ye(this,zi).size?Ye(this,zi):Ye(this,ha)};var J0=(s="")=>s.split(/\s+/),uf=(s="")=>{let[e,t,i]=s.split(":"),r=i?decodeURIComponent(i):void 0;return {kind:e==="cc"?ot.CAPTIONS:ot.SUBTITLES,language:t,label:r}},Qi=(s="",e={})=>J0(s).map(t=>{let i=uf(t);return {...e,...i}}),Jl=s=>s?Array.isArray(s)?s.map(e=>typeof e=="string"?uf(e):e):typeof s=="string"?Qi(s):[s]:[],fa=({kind:s,label:e,language:t}={kind:"subtitles"})=>e?`${s==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,gi=(s=[])=>Array.prototype.map.call(s,fa).join(" "),eE=(s,e)=>t=>t[s]===e,hf=s=>{let e=Object.entries(s).map(([t,i])=>eE(t,i));return t=>e.every(i=>i(t))},Xi=(s,e=[],t=[])=>{let i=Jl(t).map(hf),r=n=>i.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=s;});},Zi=(s,e=()=>true)=>{if(!s?.textTracks)return [];let t=typeof e=="function"?e:hf(e);return Array.from(s.textTracks).filter(t)},ma=s=>{var e;return !!((e=s.mediaSubtitlesShowing)!=null&&e.length)||s.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)};var mf=s=>{var e;let{media:t,fullscreenElement:i}=s;try{let r=i&&"requestFullscreen"in i?"requestFullscreen":i&&"webkitRequestFullScreen"in i?"webkitRequestFullScreen":void 0;if(r){let n=(e=i[r])==null?void 0:e.call(i);if(n instanceof Promise)return n.catch(()=>{})}else t?.webkitEnterFullscreen?t.webkitEnterFullscreen():t?.requestFullscreen&&t.requestFullscreen();}catch(r){console.error(r);}},ff="exitFullscreen"in Ce?"exitFullscreen":"webkitExitFullscreen"in Ce?"webkitExitFullscreen":"webkitCancelFullScreen"in Ce?"webkitCancelFullScreen":void 0,gf=s=>{var e;let{documentElement:t}=s;if(ff){let i=(e=t?.[ff])==null?void 0:e.call(t);if(i instanceof Promise)return i.catch(()=>{})}},kr="fullscreenElement"in Ce?"fullscreenElement":"webkitFullscreenElement"in Ce?"webkitFullscreenElement":void 0,tE=s=>{let{documentElement:e,media:t}=s,i=e?.[kr];return !i&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===Vh.FULLSCREEN?t:i},pf=s=>{var e;let{media:t,documentElement:i,fullscreenElement:r=t}=s;if(!t||!i)return false;let n=tE(s);if(!n)return false;if(n===r||n===t)return true;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(kr in a))return at(n,r);for(;a?.[kr];){if(a[kr]===r)return true;a=(e=a[kr])==null?void 0:e.shadowRoot;}}return false},iE="fullscreenEnabled"in Ce?"fullscreenEnabled":"webkitFullscreenEnabled"in Ce?"webkitFullscreenEnabled":void 0,Ef=s=>{let{documentElement:e,media:t}=s;return !!e?.[iE]||t&&"webkitSupportsFullscreen"in t};var ga,ed=()=>{var s,e;return ga||(ga=(e=(s=Ce)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),ga)},vf=async(s=ed())=>{if(!s)return false;let e=s.volume;s.volume=e/2+.1;let t=new AbortController,i=await Promise.race([sE(s,t.signal),rE(s,e)]);return t.abort(),i},sE=(s,e)=>new Promise(t=>{s.addEventListener("volumechange",()=>t(true),{signal:e});}),rE=async(s,e)=>{for(let t=0;t<10;t++){if(s.volume===e)return false;await Qn(10);}return s.volume!==e},nE=/.*Version\/.*Safari\/.*/.test(A.navigator.userAgent),td=(s=ed())=>A.matchMedia("(display-mode: standalone)").matches&&nE?false:typeof s?.requestPictureInPicture=="function",id=(s=ed())=>Ef({documentElement:Ce,media:s}),Tf=id(),yf=td(),Sf=!!A.WebKitPlaybackTargetAvailabilityEvent,bf=!!A.chrome;var Cs=s=>Zi(s.media,e=>[ot.SUBTITLES,ot.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),sd=s=>Zi(s.media,e=>e.mode===Ai.SHOWING&&[ot.SUBTITLES,ot.CAPTIONS].includes(e.kind)),pa=(s,e)=>{let t=Cs(s),i=sd(s),r=!!i.length;if(t.length){if(e===false||r&&e!==true)Xi(Ai.DISABLED,t,i);else if(e===true||!r&&e!==false){let n=t[0],{options:a}=s;if(!a?.noSubtitlesLangPref){let c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let E=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),p=u.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return E-p});h[0]&&(n=h[0]);}let{language:o,label:d,kind:l}=n;Xi(Ai.DISABLED,t,i),Xi(Ai.SHOWING,t,[{language:o,label:d,kind:l}]);}}},Ea=(s,e)=>s===e?true:s==null||e==null||typeof s!=typeof e?false:typeof s=="number"&&Number.isNaN(s)&&Number.isNaN(e)?true:typeof s!="object"?false:Array.isArray(s)?aE(s,e):Object.entries(s).every(([t,i])=>t in e&&Ea(i,e[t])),aE=(s,e)=>{let t=Array.isArray(s),i=Array.isArray(e);return t!==i?false:t||i?s.length!==e.length?false:s.every((r,n)=>Ea(r,e[n])):true};var oE=Object.values(kt),va,lE=vf().then(s=>(va=s,va)),Af=async(...s)=>{await Promise.all(s.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof A.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=A.customElements.get(t);i&&e instanceof i||(await A.customElements.whenDefined(t),A.customElements.upgrade(e));}));},dE=new A.DOMParser,cE=s=>s&&(dE.parseFromString(s,"text/html").body.textContent||s),Ms={mediaError:{get(s,e){let{media:t}=s;if(e?.type!=="playing")return t?.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(s,e){var t;let{media:i}=s;if(e?.type!=="playing")return (t=i?.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(s,e){var t,i;let{media:r}=s;if(e?.type!=="playing")return (i=(t=r?.error)==null?void 0:t.message)!=null?i:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(s){var e;let{media:t}=s;return (e=t?.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(s){var e;let{media:t}=s;return (e=t?.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(s){var e;let{media:t}=s;return (e=t?.paused)!=null?e:true},set(s,e){var t;let{media:i}=e;i&&(s?i.pause():(t=i.play())==null||t.catch(()=>{}));},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(s,e){let{media:t}=s;return t?e?e.type==="playing":!t.paused:false},mediaEvents:["playing","emptied"]},mediaEnded:{get(s){var e;let{media:t}=s;return (e=t?.ended)!=null?e:false},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(s){var e;let{media:t}=s;return (e=t?.playbackRate)!=null?e:1},set(s,e){let{media:t}=e;t&&Number.isFinite(+s)&&(t.playbackRate=+s);},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(s){var e;let{media:t}=s;return (e=t?.muted)!=null?e:false},set(s,e){let{media:t}=e;if(t){try{A.localStorage.setItem("media-chrome-pref-muted",s?"true":"false");}catch(i){console.debug("Error setting muted pref",i);}t.muted=s;}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noMutedPref:t}}=e,{media:i}=e;if(!(!i||i.muted||t))try{let r=A.localStorage.getItem("media-chrome-pref-muted")==="true";Ms.mediaMuted.set(r,e),s(r);}catch(r){console.debug("Error getting muted pref",r);}}]},mediaVolume:{get(s){var e;let{media:t}=s;return (e=t?.volume)!=null?e:1},set(s,e){let{media:t}=e;if(t){try{s==null?A.localStorage.removeItem("media-chrome-pref-volume"):A.localStorage.setItem("media-chrome-pref-volume",s.toString());}catch(i){console.debug("Error setting volume pref",i);}Number.isFinite(+s)&&(t.volume=+s);}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let{media:i}=e;if(!i)return;let r=A.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;Ms.mediaVolume.set(+r,e),s(+r);}catch(i){console.debug("Error getting volume pref",i);}}]},mediaVolumeLevel:{get(s){let{media:e}=s;return typeof e?.volume>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(s){var e;let{media:t}=s;return (e=t?.currentTime)!=null?e:0},set(s,e){let{media:t}=e;!t||!_s(s)||(t.currentTime=s);},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(s){let{media:e,options:{defaultDuration:t}={}}=s;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e?.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(s){let{media:e}=s;return e?.readyState<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(s){var e;let{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;let i=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!i&&!r))return [Number(i.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(s){var e;let{media:t}=s,i=(e=t?.buffered)!=null?e:[];return Array.from(i).map((r,n)=>[Number(i.start(n).toFixed(3)),Number(i.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(s){let{media:e,options:{defaultStreamType:t}={}}=s,i=[kt.LIVE,kt.ON_DEMAND].includes(t)?t:void 0;if(!e)return i;let{streamType:r}=e;if(oE.includes(r))return r===kt.UNKNOWN?i:r;let n=e.duration;return n===1/0?kt.LIVE:Number.isFinite(n)?kt.ON_DEMAND:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(s){let{media:e}=s;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=Ms.mediaStreamType.get(s);return (t==null||Number.isNaN(t))&&i===kt.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(s){let{media:e,options:{liveEdgeOffset:t=10}={}}=s;if(!e)return false;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?false:e.currentTime>=e.liveEdgeStart;if(!(Ms.mediaStreamType.get(s)===kt.LIVE))return false;let r=e.seekable;if(!r)return true;if(!r.length)return false;let n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(s){return Cs(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(s){return sd(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t,i;let{media:r,options:n}=e;if(!r)return;let a=o=>{var d;!n.defaultSubtitles||o&&![ot.CAPTIONS,ot.SUBTITLES].includes((d=o?.track)==null?void 0:d.kind)||pa(e,true);};return r.addEventListener("loadstart",a),(t=r.textTracks)==null||t.addEventListener("addtrack",a),(i=r.textTracks)==null||i.addEventListener("removetrack",a),()=>{var o,d;r.removeEventListener("loadstart",a),(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(d=r.textTracks)==null||d.removeEventListener("removetrack",a);}}]},mediaChaptersCues:{get(s){var e;let{media:t}=s;if(!t)return [];let[i]=Zi(t,{kind:ot.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:cE(r),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;if(!i)return;let r=i.querySelector('track[kind="chapters"][default][src]'),n=(t=i.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return r?.addEventListener("load",s),n?.addEventListener("load",s),()=>{r?.removeEventListener("load",s),n?.removeEventListener("load",s);}}]},mediaIsPip:{get(s){var e,t;let{media:i,documentElement:r}=s;if(!i||!r||!r.pictureInPictureElement)return false;if(r.pictureInPictureElement===i)return true;if(r.pictureInPictureElement instanceof HTMLMediaElement)return (e=i.localName)!=null&&e.includes("-")?at(i,r.pictureInPictureElement):false;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n?.pictureInPictureElement;){if(n.pictureInPictureElement===i)return true;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot;}}return false},set(s,e){let{media:t}=e;if(t)if(s){if(!Ce.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 i=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.");};t.requestPictureInPicture().catch(r=>{if(r.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(i),n();};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&i(),n();},1e3);}else throw r}else throw r});}else Ce.pictureInPictureElement&&Ce.exitPictureInPicture();},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(s){var e;let{media:t}=s;return [...(e=t?.videoRenditions)!=null?e:[]].map(i=>({...i}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(s){var e,t,i;let{media:r}=s;return (i=(t=r?.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},set(s,e){let{media:t}=e;if(!t?.videoRenditions){console.warn("MediaController: Rendition selection not supported by this media.");return}let i=s,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==i);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r);},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(s){var e;let{media:t}=s;return [...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(s){var e,t;let{media:i}=s;return (t=[...(e=i?.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(s,e){let{media:t}=e;if(!t?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let i=s;for(let r of t.audioTracks)r.enabled=i==r.id;},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(s){return pf(s)},set(s,e){s?mf(e):gf(e);},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(s){var e;let{media:t}=s;return !t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?false:!!t.remote.state},set(s,e){var t,i;let{media:r}=e;if(r&&!(s&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!s&&((i=r.remote)==null?void 0:i.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{});}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return false},set(s,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&A.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker();}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(s){let{media:e}=s;if(!Tf||!id(e))return pt.UNSUPPORTED}},mediaPipUnavailable:{get(s){let{media:e}=s;if(!yf||!td(e))return pt.UNSUPPORTED}},mediaVolumeUnavailable:{get(s){let{media:e}=s;if(va===false||e?.volume==null)return pt.UNSUPPORTED},stateOwnersUpdateHandlers:[s=>{va==null&&lE.then(e=>s(e?void 0:pt.UNSUPPORTED));}]},mediaCastUnavailable:{get(s,{availability:e="not-available"}={}){var t;let{media:i}=s;if(!bf||!((t=i?.remote)!=null&&t.state))return pt.UNSUPPORTED;if(!(e==null||e==="available"))return pt.UNAVAILABLE},stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaAirplayUnavailable:{get(s,e){if(!Sf)return pt.UNSUPPORTED;if(e?.availability==="not-available")return pt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaRenditionUnavailable:{get(s){var e;let{media:t}=s;if(!t?.videoRenditions)return pt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return pt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(s){var e,t;let{media:i}=s;if(!i?.audioTracks)return pt.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return pt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(s){let{options:{mediaLang:e}={}}=s;return e??"en"}}};var _f={[F.MEDIA_PREVIEW_REQUEST](s,e,{detail:t}){var i,r,n;let{media:a}=e,o=t??void 0,d,l;if(a&&o!=null){let[f]=Zi(a,{kind:ot.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((i=f?.cues)!=null?i:[],(E,p,v)=>p===0?E.endTime>o:p===v.length-1?E.startTime<=o:E.startTime<=o&&E.endTime>o);if(m){let E=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(r=a?.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,p=new URL(m.text,E);l=new URLSearchParams(p.hash).get("#xywh").split(",").map(S=>+S),d=p.href;}}let c=s.mediaDuration.get(e),h=(n=s.mediaChaptersCues.get(e).find((f,m,E)=>m===E.length-1&&c===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:d,mediaPreviewCoords:l,mediaPreviewChapter:h}},[F.MEDIA_PAUSE_REQUEST](s,e){s["mediaPaused"].set(true,e);},[F.MEDIA_PLAY_REQUEST](s,e){var t,i,r,n;let a="mediaPaused",d=s.mediaStreamType.get(e)===kt.LIVE,l=!((t=e.options)!=null&&t.noAutoSeekToLive),c=s.mediaTargetLiveWindow.get(e)>0;if(d&&l&&!c){let u=(i=s.mediaSeekable.get(e))==null?void 0:i[1];if(u){let h=(n=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?n:0,f=u-h;s.mediaCurrentTime.set(f,e);}}s[a].set(false,e);},[F.MEDIA_PLAYBACK_RATE_REQUEST](s,e,{detail:t}){let i="mediaPlaybackRate",r=t;s[i].set(r,e);},[F.MEDIA_MUTE_REQUEST](s,e){s["mediaMuted"].set(true,e);},[F.MEDIA_UNMUTE_REQUEST](s,e){let t="mediaMuted";s.mediaVolume.get(e)||s.mediaVolume.set(.25,e),s[t].set(false,e);},[F.MEDIA_VOLUME_REQUEST](s,e,{detail:t}){let i="mediaVolume",r=t;r&&s.mediaMuted.get(e)&&s.mediaMuted.set(false,e),s[i].set(r,e);},[F.MEDIA_SEEK_REQUEST](s,e,{detail:t}){let i="mediaCurrentTime",r=t;s[i].set(r,e);},[F.MEDIA_SEEK_TO_LIVE_REQUEST](s,e){var t,i,r;let n="mediaCurrentTime",a=(t=s.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;let o=(r=(i=e.options)==null?void 0:i.seekToLiveOffset)!=null?r:0,d=a-o;s[n].set(d,e);},[F.MEDIA_SHOW_SUBTITLES_REQUEST](s,e,{detail:t}){var i;let{options:r}=e,n=Cs(e),a=Jl(t),o=(i=a[0])==null?void 0:i.language;o&&!r.noSubtitlesLangPref&&A.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Xi(Ai.SHOWING,n,a);},[F.MEDIA_DISABLE_SUBTITLES_REQUEST](s,e,{detail:t}){let i=Cs(e),r=t??[];Xi(Ai.DISABLED,i,r);},[F.MEDIA_TOGGLE_SUBTITLES_REQUEST](s,e,{detail:t}){pa(e,t);},[F.MEDIA_RENDITION_REQUEST](s,e,{detail:t}){let i="mediaRenditionSelected",r=t;s[i].set(r,e);},[F.MEDIA_AUDIO_TRACK_REQUEST](s,e,{detail:t}){let i="mediaAudioTrackEnabled",r=t;s[i].set(r,e);},[F.MEDIA_ENTER_PIP_REQUEST](s,e){let t="mediaIsPip";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[F.MEDIA_EXIT_PIP_REQUEST](s,e){s["mediaIsPip"].set(false,e);},[F.MEDIA_ENTER_FULLSCREEN_REQUEST](s,e){let t="mediaIsFullscreen";s.mediaIsPip.get(e)&&s.mediaIsPip.set(false,e),s[t].set(true,e);},[F.MEDIA_EXIT_FULLSCREEN_REQUEST](s,e){s["mediaIsFullscreen"].set(false,e);},[F.MEDIA_ENTER_CAST_REQUEST](s,e){let t="mediaIsCasting";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[F.MEDIA_EXIT_CAST_REQUEST](s,e){s["mediaIsCasting"].set(false,e);},[F.MEDIA_AIRPLAY_REQUEST](s,e){s["mediaIsAirplaying"].set(true,e);}};var If=({media:s,fullscreenElement:e,documentElement:t,stateMediator:i=Ms,requestMap:r=_f,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=true})=>{let o=[],d={options:{...n}},l=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),c=E=>{E!=null&&(Ea(E,l)||(l=Object.freeze({...l,...E}),o.forEach(p=>p(l))));},u=()=>{let E=Object.entries(i).reduce((p,[v,{get:S}])=>(p[v]=S(d),p),{});c(E);},h={},f,m=async(E,p)=>{var v,S,y,b,L,k,I,x,D,_,M,N,q,V,H,B;let j=!!f;if(f={...d,...f??{},...E},j)return;await Af(...Object.values(E));let P=o.length>0&&p===0&&a,z=d.media!==f.media,Y=((v=d.media)==null?void 0:v.textTracks)!==((S=f.media)==null?void 0:S.textTracks),U=((y=d.media)==null?void 0:y.videoRenditions)!==((b=f.media)==null?void 0:b.videoRenditions),O=((L=d.media)==null?void 0:L.audioTracks)!==((k=f.media)==null?void 0:k.audioTracks),se=((I=d.media)==null?void 0:I.remote)!==((x=f.media)==null?void 0:x.remote),oe=d.documentElement!==f.documentElement,me=!!d.media&&(z||P),ue=!!((D=d.media)!=null&&D.textTracks)&&(Y||P),Ie=!!((_=d.media)!=null&&_.videoRenditions)&&(U||P),tt=!!((M=d.media)!=null&&M.audioTracks)&&(O||P),Ge=!!((N=d.media)!=null&&N.remote)&&(se||P),it=!!d.documentElement&&(oe||P),Bt=me||ue||Ie||tt||Ge||it,bi=o.length===0&&p===1&&a,ys=!!f.media&&(z||bi),Ss=!!((q=f.media)!=null&&q.textTracks)&&(Y||bi),Nl=!!((V=f.media)!=null&&V.videoRenditions)&&(U||bi),fe=!!((H=f.media)!=null&&H.audioTracks)&&(O||bi),He=!!((B=f.media)!=null&&B.remote)&&(se||bi),nt=!!f.documentElement&&(oe||bi),$t=ys||Ss||Nl||fe||He||nt;if(!(Bt||$t)){Object.entries(f).forEach(([ge,mt])=>{d[ge]=mt;}),u(),f=void 0;return}Object.entries(i).forEach(([ge,{get:mt,mediaEvents:Wn=[],textTracksEvents:bs=[],videoRenditionsEvents:qn=[],audioTracksEvents:Vi=[],remoteEvents:Yn=[],rootEvents:Fl=[],stateOwnersUpdateHandlers:jn=[]}])=>{h[ge]||(h[ge]={});let st=Fe=>{let gt=mt(d,Fe);c({[ge]:gt});},ke;ke=h[ge].mediaEvents,Wn.forEach(Fe=>{ke&&me&&(d.media.removeEventListener(Fe,ke),h[ge].mediaEvents=void 0),ys&&(f.media.addEventListener(Fe,st),h[ge].mediaEvents=st);}),ke=h[ge].textTracksEvents,bs.forEach(Fe=>{var gt,Dt;ke&&ue&&((gt=d.media.textTracks)==null||gt.removeEventListener(Fe,ke),h[ge].textTracksEvents=void 0),Ss&&((Dt=f.media.textTracks)==null||Dt.addEventListener(Fe,st),h[ge].textTracksEvents=st);}),ke=h[ge].videoRenditionsEvents,qn.forEach(Fe=>{var gt,Dt;ke&&Ie&&((gt=d.media.videoRenditions)==null||gt.removeEventListener(Fe,ke),h[ge].videoRenditionsEvents=void 0),Nl&&((Dt=f.media.videoRenditions)==null||Dt.addEventListener(Fe,st),h[ge].videoRenditionsEvents=st);}),ke=h[ge].audioTracksEvents,Vi.forEach(Fe=>{var gt,Dt;ke&&tt&&((gt=d.media.audioTracks)==null||gt.removeEventListener(Fe,ke),h[ge].audioTracksEvents=void 0),fe&&((Dt=f.media.audioTracks)==null||Dt.addEventListener(Fe,st),h[ge].audioTracksEvents=st);}),ke=h[ge].remoteEvents,Yn.forEach(Fe=>{var gt,Dt;ke&&Ge&&((gt=d.media.remote)==null||gt.removeEventListener(Fe,ke),h[ge].remoteEvents=void 0),He&&((Dt=f.media.remote)==null||Dt.addEventListener(Fe,st),h[ge].remoteEvents=st);}),ke=h[ge].rootEvents,Fl.forEach(Fe=>{ke&&it&&(d.documentElement.removeEventListener(Fe,ke),h[ge].rootEvents=void 0),nt&&(f.documentElement.addEventListener(Fe,st),h[ge].rootEvents=st);});let Mh=h[ge].stateOwnersUpdateHandlers;jn.forEach(Fe=>{Mh&&Bt&&Mh(),$t&&(h[ge].stateOwnersUpdateHandlers=Fe(st,f));});}),Object.entries(f).forEach(([ge,mt])=>{d[ge]=mt;}),u(),f=void 0;};return m({media:s,fullscreenElement:e,documentElement:t,options:n}),{dispatch(E){let{type:p,detail:v}=E;if(r[p]&&l.mediaErrorCode==null){c(r[p](i,d,E));return}p==="mediaelementchangerequest"?m({media:v}):p==="fullscreenelementchangerequest"?m({fullscreenElement:v}):p==="documentelementchangerequest"?m({documentElement:v}):p==="optionschangerequest"&&(Object.entries(v??{}).forEach(([S,y])=>{d.options[S]=y;}),u());},getState(){return l},subscribe(E){return m({},o.length+1),o.push(E),E(l),()=>{let p=o.indexOf(E);p>=0&&(m({},o.length-1),o.splice(p,1));}}}};var ld=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},le=(s,e,t)=>(ld(s,e,"read from private field"),t?t.call(s):e.get(s)),pi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},xi=(s,e,t,i)=>(ld(s,e,"write to private field"),e.set(s,t),t),Ri=(s,e,t)=>(ld(s,e,"access private method"),t),es,Cr,Se,Mr,Vt,Ta,ya,rd,ws,wr,Sa,nd,kf=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Lf=10,G={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",SEEK_TO_LIVE_OFFSET:"seektoliveoffset",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",LANG:"lang"},ad=class extends ji{constructor(){super(),pi(this,ya),pi(this,ws),pi(this,Sa),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,pi(this,es,new Li(this,G.HOTKEYS)),pi(this,Cr,void 0),pi(this,Se,void 0),pi(this,Mr,void 0),pi(this,Vt,void 0),pi(this,Ta,t=>{var i;(i=le(this,Se))==null||i.dispatch(t);}),this.associateElement(this);let e={};xi(this,Mr,t=>{Object.entries(t).forEach(([i,r])=>{if(i in e&&e[i]===r)return;this.propagateMediaState(i,r);let n=i.toLowerCase(),a=new A.CustomEvent(Hh[n],{composed:true,detail:r});this.dispatchEvent(a);}),e=t;}),this.enableHotkeys();}static get observedAttributes(){return super.observedAttributes.concat(G.NO_HOTKEYS,G.HOTKEYS,G.DEFAULT_STREAM_TYPE,G.DEFAULT_SUBTITLES,G.DEFAULT_DURATION,G.LANG)}get mediaStore(){return le(this,Se)}set mediaStore(e){var t,i;if(le(this,Se)&&((t=le(this,Vt))==null||t.call(this),xi(this,Vt,void 0)),xi(this,Se,e),!le(this,Se)&&!this.hasAttribute(G.NO_DEFAULT_STORE)){Ri(this,ya,rd).call(this);return}xi(this,Vt,(i=le(this,Se))==null?void 0:i.subscribe(le(this,Mr)));}get fullscreenElement(){var e;return (e=le(this,Cr))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(G.FULLSCREEN_ELEMENT)&&this.removeAttribute(G.FULLSCREEN_ELEMENT),xi(this,Cr,e),(t=le(this,Se))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}get defaultSubtitles(){return X(this,G.DEFAULT_SUBTITLES)}set defaultSubtitles(e){Z(this,G.DEFAULT_SUBTITLES,e);}get defaultStreamType(){return te(this,G.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){ie(this,G.DEFAULT_STREAM_TYPE,e);}get defaultDuration(){return ae(this,G.DEFAULT_DURATION)}set defaultDuration(e){he(this,G.DEFAULT_DURATION,e);}get noHotkeys(){return X(this,G.NO_HOTKEYS)}set noHotkeys(e){Z(this,G.NO_HOTKEYS,e);}get keysUsed(){return te(this,G.KEYS_USED)}set keysUsed(e){ie(this,G.KEYS_USED,e);}get liveEdgeOffset(){return ae(this,G.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){he(this,G.LIVE_EDGE_OFFSET,e);}get noAutoSeekToLive(){return X(this,G.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){Z(this,G.NO_AUTO_SEEK_TO_LIVE,e);}get noVolumePref(){return X(this,G.NO_VOLUME_PREF)}set noVolumePref(e){Z(this,G.NO_VOLUME_PREF,e);}get noSubtitlesLangPref(){return X(this,G.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){Z(this,G.NO_SUBTITLES_LANG_PREF,e);}get noDefaultStore(){return X(this,G.NO_DEFAULT_STORE)}set noDefaultStore(e){Z(this,G.NO_DEFAULT_STORE,e);}attributeChangedCallback(e,t,i){var r,n,a,o,d,l,c,u,h;if(super.attributeChangedCallback(e,t,i),e===G.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(G.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===G.HOTKEYS)le(this,es).value=i;else if(e===G.DEFAULT_SUBTITLES&&i!==t)(r=le(this,Se))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(G.DEFAULT_SUBTITLES)}});else if(e===G.DEFAULT_STREAM_TYPE)(a=le(this,Se))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(G.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===G.LIVE_EDGE_OFFSET)(o=le(this,Se))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(G.LIVE_EDGE_OFFSET)?+this.getAttribute(G.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(G.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(G.LIVE_EDGE_OFFSET)}});else if(e===G.SEEK_TO_LIVE_OFFSET)(d=le(this,Se))==null||d.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(G.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(G.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===G.NO_AUTO_SEEK_TO_LIVE)(l=le(this,Se))==null||l.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(G.NO_AUTO_SEEK_TO_LIVE)}});else if(e===G.FULLSCREEN_ELEMENT){let f=i?(c=this.getRootNode())==null?void 0:c.getElementById(i):void 0;xi(this,Cr,f),(u=le(this,Se))==null||u.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}else e===G.LANG&&i!==t&&(Xh(i),(h=le(this,Se))==null||h.dispatch({type:"optionschangerequest",detail:{mediaLang:i}}));}connectedCallback(){var e,t;!le(this,Se)&&!this.hasAttribute(G.NO_DEFAULT_STORE)&&Ri(this,ya,rd).call(this),(e=le(this,Se))==null||e.dispatch({type:"documentelementchangerequest",detail:Ce}),super.connectedCallback(),le(this,Se)&&!le(this,Vt)&&xi(this,Vt,(t=le(this,Se))==null?void 0:t.subscribe(le(this,Mr))),this.enableHotkeys();}disconnectedCallback(){var e,t,i,r;(e=super.disconnectedCallback)==null||e.call(this),le(this,Se)&&((t=le(this,Se))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(i=le(this,Se))==null||i.dispatch({type:F.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:false})),le(this,Vt)&&((r=le(this,Vt))==null||r.call(this),xi(this,Vt,void 0));}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=le(this,Se))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1);}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=le(this,Se))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0});}propagateMediaState(e,t){Df(this.mediaStateReceivers,e,t);}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=pE(e,i,r);Object.values(F).forEach(a=>{e.addEventListener(a,le(this,Ta));}),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(F).forEach(r=>{e.removeEventListener(r,le(this,Ta));});}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),le(this,Se)&&Object.entries(le(this,Se).getState()).forEach(([r,n])=>{Df([e],r,n);}));}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1);}enableHotkeys(){this.addEventListener("keydown",Ri(this,Sa,nd));}disableHotkeys(){this.removeEventListener("keydown",Ri(this,Sa,nd)),this.removeEventListener("keyup",Ri(this,ws,wr));}get hotkeys(){return te(this,G.HOTKEYS)}set hotkeys(e){ie(this,G.HOTKEYS,e);}keyboardShortcutHandler(e){var t,i,r,n,a;let o=e.target;if(((r=(i=(t=o.getAttribute(G.KEYS_USED))==null?void 0:t.split(" "))!=null?i:o?.keysUsed)!=null?r:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let l,c,u;if(!le(this,es).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&le(this,es).contains("nospace")))switch(e.key){case " ":case "k":l=le(this,Se).getState().mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new A.CustomEvent(l,{composed:true,bubbles:true}));break;case "m":l=this.mediaStore.getState().mediaVolumeLevel==="off"?F.MEDIA_UNMUTE_REQUEST:F.MEDIA_MUTE_REQUEST,this.dispatchEvent(new A.CustomEvent(l,{composed:true,bubbles:true}));break;case "f":l=this.mediaStore.getState().mediaIsFullscreen?F.MEDIA_EXIT_FULLSCREEN_REQUEST:F.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new A.CustomEvent(l,{composed:true,bubbles:true}));break;case "c":this.dispatchEvent(new A.CustomEvent(F.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));break;case "ArrowLeft":{let h=this.hasAttribute(G.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(G.KEYBOARD_BACKWARD_SEEK_OFFSET):Lf;c=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),u=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:c}),this.dispatchEvent(u);break}case "ArrowRight":{let h=this.hasAttribute(G.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(G.KEYBOARD_FORWARD_SEEK_OFFSET):Lf;c=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),u=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:c}),this.dispatchEvent(u);break}}}};es=new WeakMap;Cr=new WeakMap;Se=new WeakMap;Mr=new WeakMap;Vt=new WeakMap;Ta=new WeakMap;ya=new WeakSet;rd=function(){var s;this.mediaStore=If({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(G.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(G.DEFAULT_DURATION)?+this.getAttribute(G.DEFAULT_DURATION):void 0,defaultStreamType:(s=this.getAttribute(G.DEFAULT_STREAM_TYPE))!=null?s:void 0,liveEdgeOffset:this.hasAttribute(G.LIVE_EDGE_OFFSET)?+this.getAttribute(G.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(G.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(G.SEEK_TO_LIVE_OFFSET):this.hasAttribute(G.LIVE_EDGE_OFFSET)?+this.getAttribute(G.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(G.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(G.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(G.NO_SUBTITLES_LANG_PREF)}});};ws=new WeakSet;wr=function(s){let{key:e}=s;if(!kf.includes(e)){this.removeEventListener("keyup",Ri(this,ws,wr));return}this.keyboardShortcutHandler(s);};Sa=new WeakSet;nd=function(s){let{metaKey:e,altKey:t,key:i}=s;if(e||t||!kf.includes(i)){this.removeEventListener("keyup",Ri(this,ws,wr));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(le(this,es).contains(`no${i.toLowerCase()}`)||i===" "&&le(this,es).contains("nospace"))&&s.preventDefault(),this.addEventListener("keyup",Ri(this,ws,wr),{once:true});};var uE=Object.values(T),hE=Object.values(Gl),Cf=s=>{var e,t,i,r;let{observedAttributes:n}=s.constructor;!n&&((e=s.nodeName)!=null&&e.includes("-"))&&(A.customElements.upgrade(s),{observedAttributes:n}=s.constructor);let a=(r=(i=(t=s?.getAttribute)==null?void 0:t.call(s,re.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:r.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>uE.includes(o)):[]},fE=s=>{var e,t;return (e=s.nodeName)!=null&&e.includes("-")&&A.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof A.customElements.get(s.nodeName.toLowerCase()))&&A.customElements.upgrade(s),hE.some(i=>i in s)},od=s=>fE(s)||!!Cf(s).length,xf=s=>{var e;return (e=s?.join)==null?void 0:e.call(s,":")},Rf={[T.MEDIA_SUBTITLES_LIST]:gi,[T.MEDIA_SUBTITLES_SHOWING]:gi,[T.MEDIA_SEEKABLE]:xf,[T.MEDIA_BUFFERED]:s=>s?.map(xf).join(" "),[T.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[T.MEDIA_RENDITION_LIST]:Kh,[T.MEDIA_AUDIO_TRACK_LIST]:qh},mE=async(s,e,t)=>{var i,r;if(s.isConnected||await Qn(0),typeof t=="boolean"||t==null)return Z(s,e,t);if(typeof t=="number")return he(s,e,t);if(typeof t=="string")return ie(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);let n=(r=(i=Rf[e])==null?void 0:i.call(Rf,t))!=null?r:t;return s.setAttribute(e,n)},gE=s=>{var e;return !!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},Ji=(s,e)=>{if(gE(s))return;let t=(r,n)=>{var a,o;od(r)&&n(r);let{children:d=[]}=r??{},l=(o=(a=r?.shadowRoot)==null?void 0:a.children)!=null?o:[];[...d,...l].forEach(u=>Ji(u,n));},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!od(s)){A.customElements.whenDefined(i).then(()=>{t(s,e);});return}t(s,e);},Df=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}let r=Cf(i),n=e.toLowerCase();r.includes(n)&&mE(i,n,t);});},pE=(s,e,t)=>{Ji(s,e);let i=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;e(h);},r=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;t(h);};s.addEventListener(F.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener(F.UNREGISTER_MEDIA_STATE_RECEIVER,r);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:E,attributeName:p}=u;m==="childList"?(Array.prototype.forEach.call(h,v=>Ji(v,e)),Array.prototype.forEach.call(f,v=>Ji(v,t))):m==="attributes"&&p===re.MEDIA_CHROME_ATTRIBUTES&&(od(E)?e(E):t(E));});},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Ji(h,t)),a=[...u.assignedElements({flatten:true})],a.forEach(h=>Ji(h,e)));};s.addEventListener("slotchange",o);let d=new MutationObserver(n);return d.observe(s,{childList:true,attributes:true,subtree:true}),()=>{Ji(s,t),s.removeEventListener("slotchange",o),d.disconnect(),s.removeEventListener(F.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener(F.UNREGISTER_MEDIA_STATE_RECEIVER,r);}};A.customElements.get("media-controller")||A.customElements.define("media-controller",ad);var Ps={PLACEMENT:"placement",BOUNDS:"bounds"};function EE(s){return `
|
|
159
|
-
<style>
|
|
160
|
-
:host {
|
|
161
|
-
--_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
|
|
162
|
-
--_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color));
|
|
163
|
-
--_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2);
|
|
164
|
-
--_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px);
|
|
165
|
-
--_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color));
|
|
166
|
-
position: relative;
|
|
167
|
-
pointer-events: none;
|
|
168
|
-
display: var(--media-tooltip-display, inline-flex);
|
|
169
|
-
justify-content: center;
|
|
170
|
-
align-items: center;
|
|
171
|
-
box-sizing: border-box;
|
|
172
|
-
z-index: var(--media-tooltip-z-index, 1);
|
|
173
|
-
background: var(--_tooltip-background);
|
|
174
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
175
|
-
font: var(--media-font,
|
|
176
|
-
var(--media-font-weight, 400)
|
|
177
|
-
var(--media-font-size, 13px) /
|
|
178
|
-
var(--media-text-content-height, var(--media-control-height, 18px))
|
|
179
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
180
|
-
padding: var(--media-tooltip-padding, .35em .7em);
|
|
181
|
-
border: var(--media-tooltip-border, none);
|
|
182
|
-
border-radius: var(--media-tooltip-border-radius, 5px);
|
|
183
|
-
filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2)));
|
|
184
|
-
white-space: var(--media-tooltip-white-space, nowrap);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
:host([hidden]) {
|
|
188
|
-
display: none;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
img, svg {
|
|
192
|
-
display: inline-block;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
#arrow {
|
|
196
|
-
position: absolute;
|
|
197
|
-
width: 0px;
|
|
198
|
-
height: 0px;
|
|
199
|
-
border-style: solid;
|
|
200
|
-
display: var(--media-tooltip-arrow-display, block);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
:host(:not([placement])),
|
|
204
|
-
:host([placement="top"]) {
|
|
205
|
-
position: absolute;
|
|
206
|
-
bottom: calc(100% + var(--media-tooltip-distance, 12px));
|
|
207
|
-
left: 50%;
|
|
208
|
-
transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);
|
|
209
|
-
}
|
|
210
|
-
:host(:not([placement])) #arrow,
|
|
211
|
-
:host([placement="top"]) #arrow {
|
|
212
|
-
top: 100%;
|
|
213
|
-
left: 50%;
|
|
214
|
-
border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width);
|
|
215
|
-
border-color: var(--_tooltip-arrow-background) transparent transparent transparent;
|
|
216
|
-
transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
:host([placement="right"]) {
|
|
220
|
-
position: absolute;
|
|
221
|
-
left: calc(100% + var(--media-tooltip-distance, 12px));
|
|
222
|
-
top: 50%;
|
|
223
|
-
transform: translate(0, -50%);
|
|
224
|
-
}
|
|
225
|
-
:host([placement="right"]) #arrow {
|
|
226
|
-
top: 50%;
|
|
227
|
-
right: 100%;
|
|
228
|
-
border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0;
|
|
229
|
-
border-color: transparent var(--_tooltip-arrow-background) transparent transparent;
|
|
230
|
-
transform: translate(0, -50%);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
:host([placement="bottom"]) {
|
|
234
|
-
position: absolute;
|
|
235
|
-
top: calc(100% + var(--media-tooltip-distance, 12px));
|
|
236
|
-
left: 50%;
|
|
237
|
-
transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);
|
|
238
|
-
}
|
|
239
|
-
:host([placement="bottom"]) #arrow {
|
|
240
|
-
bottom: 100%;
|
|
241
|
-
left: 50%;
|
|
242
|
-
border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width);
|
|
243
|
-
border-color: transparent transparent var(--_tooltip-arrow-background) transparent;
|
|
244
|
-
transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
:host([placement="left"]) {
|
|
248
|
-
position: absolute;
|
|
249
|
-
right: calc(100% + var(--media-tooltip-distance, 12px));
|
|
250
|
-
top: 50%;
|
|
251
|
-
transform: translate(0, -50%);
|
|
252
|
-
}
|
|
253
|
-
:host([placement="left"]) #arrow {
|
|
254
|
-
top: 50%;
|
|
255
|
-
left: 100%;
|
|
256
|
-
border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height);
|
|
257
|
-
border-color: transparent transparent transparent var(--_tooltip-arrow-background);
|
|
258
|
-
transform: translate(0, -50%);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
:host([placement="none"]) #arrow {
|
|
262
|
-
display: none;
|
|
263
|
-
}
|
|
264
|
-
</style>
|
|
265
|
-
<slot></slot>
|
|
266
|
-
<div id="arrow"></div>
|
|
267
|
-
`}var Os=class extends A.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!sa(this,{checkOpacity:false,checkVisibilityCSS:false}))return;let t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}let i=getComputedStyle(this),r=(e=Ht(this,"#"+this.bounds))!=null?e:Me(this);if(!r)return;let{x:n,width:a}=r.getBoundingClientRect(),{x:o,width:d}=this.getBoundingClientRect(),l=o+d,c=n+a,u=i.getPropertyValue("--media-tooltip-offset-x"),h=u?parseFloat(u.replace("px","")):0,f=i.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,E=o-n+h-m,p=l-c+h+m;if(E<0){this.style.setProperty("--media-tooltip-offset-x",`${E}px`);return}if(p>0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}this.style.removeProperty("--media-tooltip-offset-x");},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}if(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 [Ps.PLACEMENT,Ps.BOUNDS]}get placement(){return te(this,Ps.PLACEMENT)}set placement(e){ie(this,Ps.PLACEMENT,e);}get bounds(){return te(this,Ps.BOUNDS)}set bounds(e){ie(this,Ps.BOUNDS,e);}};Os.shadowRootOptions={mode:"open"};Os.getTemplateHTML=EE;A.customElements.get("media-tooltip")||A.customElements.define("media-tooltip",Os);var ba=Os;var cd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Be=(s,e,t)=>(cd(s,e,"read from private field"),t?t.call(s):e.get(s)),Ns=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Aa=(s,e,t,i)=>(cd(s,e,"write to private field"),e.set(s,t),t),vE=(s,e,t)=>(cd(s,e,"access private method"),t),Kt,Us,ki,Fs,_a,dd,Mf,Di={TOOLTIP_PLACEMENT:"tooltipplacement",DISABLED:"disabled",NO_TOOLTIP:"notooltip"};function TE(s,e={}){return `
|
|
268
|
-
<style>
|
|
269
|
-
:host {
|
|
270
|
-
position: relative;
|
|
271
|
-
font: var(--media-font,
|
|
272
|
-
var(--media-font-weight, bold)
|
|
273
|
-
var(--media-font-size, 14px) /
|
|
274
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
275
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
276
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
277
|
-
background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
|
|
278
|
-
padding: var(--media-button-padding, var(--media-control-padding, 10px));
|
|
279
|
-
justify-content: var(--media-button-justify-content, center);
|
|
280
|
-
display: inline-flex;
|
|
281
|
-
align-items: center;
|
|
282
|
-
vertical-align: middle;
|
|
283
|
-
box-sizing: border-box;
|
|
284
|
-
transition: background .15s linear;
|
|
285
|
-
pointer-events: auto;
|
|
286
|
-
cursor: var(--media-cursor, pointer);
|
|
287
|
-
-webkit-tap-highlight-color: transparent;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
:host(:focus-visible) {
|
|
292
|
-
box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
|
|
293
|
-
outline: 0;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
:host(:where(:focus)) {
|
|
297
|
-
box-shadow: none;
|
|
298
|
-
outline: 0;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
:host(:hover) {
|
|
302
|
-
background: var(--media-control-hover-background, rgba(50 50 70 / .7));
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
svg, img, ::slotted(svg), ::slotted(img) {
|
|
306
|
-
width: var(--media-button-icon-width);
|
|
307
|
-
height: var(--media-button-icon-height, var(--media-control-height, 24px));
|
|
308
|
-
transform: var(--media-button-icon-transform);
|
|
309
|
-
transition: var(--media-button-icon-transition);
|
|
310
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
311
|
-
vertical-align: middle;
|
|
312
|
-
max-width: 100%;
|
|
313
|
-
max-height: 100%;
|
|
314
|
-
min-width: 100%;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
media-tooltip {
|
|
318
|
-
|
|
319
|
-
max-width: 0;
|
|
320
|
-
overflow-x: clip;
|
|
321
|
-
opacity: 0;
|
|
322
|
-
transition: opacity .3s, max-width 0s 9s;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
:host(:hover) media-tooltip,
|
|
326
|
-
:host(:focus-visible) media-tooltip {
|
|
327
|
-
max-width: 100vw;
|
|
328
|
-
opacity: 1;
|
|
329
|
-
transition: opacity .3s;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
:host([notooltip]) slot[name="tooltip"] {
|
|
333
|
-
display: none;
|
|
334
|
-
}
|
|
335
|
-
</style>
|
|
336
|
-
|
|
337
|
-
${this.getSlotTemplateHTML(s,e)}
|
|
338
|
-
|
|
339
|
-
<slot name="tooltip">
|
|
340
|
-
<media-tooltip part="tooltip" aria-hidden="true">
|
|
341
|
-
<template shadowrootmode="${ba.shadowRootOptions.mode}">
|
|
342
|
-
${ba.getTemplateHTML({})}
|
|
343
|
-
</template>
|
|
344
|
-
<slot name="tooltip-content">
|
|
345
|
-
${this.getTooltipContentHTML(s)}
|
|
346
|
-
</slot>
|
|
347
|
-
</media-tooltip>
|
|
348
|
-
</slot>
|
|
349
|
-
`}function yE(s,e){return `
|
|
350
|
-
<slot></slot>
|
|
351
|
-
`}function SE(){return ""}var ve=class extends A.HTMLElement{constructor(){if(super(),Ns(this,dd),Ns(this,Kt,void 0),this.preventClick=false,this.tooltipEl=null,Ns(this,Us,e=>{this.preventClick||this.handleClick(e),setTimeout(Be(this,ki),0);}),Ns(this,ki,()=>{var e,t;(t=(e=this.tooltipEl)==null?void 0:e.updateXOffset)==null||t.call(e);}),Ns(this,Fs,e=>{let{key:t}=e;if(!this.keysUsed.includes(t)){this.removeEventListener("keyup",Be(this,Fs));return}this.preventClick||this.handleClick(e);}),Ns(this,_a,e=>{let{metaKey:t,altKey:i,key:r}=e;if(t||i||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Be(this,Fs));return}this.addEventListener("keyup",Be(this,Fs),{once:true});}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t;}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip");}static get observedAttributes(){return ["disabled",Di.TOOLTIP_PLACEMENT,re.MEDIA_CONTROLLER,T.MEDIA_LANG]}enable(){this.addEventListener("click",Be(this,Us)),this.addEventListener("keydown",Be(this,_a)),this.tabIndex=0;}disable(){this.removeEventListener("click",Be(this,Us)),this.removeEventListener("keydown",Be(this,_a)),this.removeEventListener("keyup",Be(this,Fs)),this.tabIndex=-1;}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===re.MEDIA_CONTROLLER?(t&&((n=(r=Be(this,Kt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Aa(this,Kt,null)),i&&this.isConnected&&(Aa(this,Kt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Be(this,Kt))==null?void 0:o.associateElement)==null||d.call(o,this))):e==="disabled"&&i!==t?i==null?this.enable():this.disable():e===Di.TOOLTIP_PLACEMENT&&this.tooltipEl&&i!==t?this.tooltipEl.placement=i:e===T.MEDIA_LANG&&(this.shadowRoot.querySelector('slot[name="tooltip-content"]').innerHTML=this.constructor.getTooltipContentHTML()),Be(this,ki).call(this);}connectedCallback(){var e,t,i;let{style:r}=ye(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")?this.disable():this.enable(),this.setAttribute("role","button");let n=this.getAttribute(re.MEDIA_CONTROLLER);n&&(Aa(this,Kt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=Be(this,Kt))==null?void 0:t.associateElement)==null||i.call(t,this)),A.customElements.whenDefined("media-tooltip").then(()=>vE(this,dd,Mf).call(this));}disconnectedCallback(){var e,t;this.disable(),(t=(e=Be(this,Kt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Aa(this,Kt,null),this.removeEventListener("mouseenter",Be(this,ki)),this.removeEventListener("focus",Be(this,ki)),this.removeEventListener("click",Be(this,Us));}get keysUsed(){return ["Enter"," "]}get tooltipPlacement(){return te(this,Di.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){ie(this,Di.TOOLTIP_PLACEMENT,e);}get mediaController(){return te(this,re.MEDIA_CONTROLLER)}set mediaController(e){ie(this,re.MEDIA_CONTROLLER,e);}get disabled(){return X(this,Di.DISABLED)}set disabled(e){Z(this,Di.DISABLED,e);}get noTooltip(){return X(this,Di.NO_TOOLTIP)}set noTooltip(e){Z(this,Di.NO_TOOLTIP,e);}handleClick(e){}};Kt=new WeakMap;Us=new WeakMap;ki=new WeakMap;Fs=new WeakMap;_a=new WeakMap;dd=new WeakSet;Mf=function(){this.addEventListener("mouseenter",Be(this,ki)),this.addEventListener("focus",Be(this,ki)),this.addEventListener("click",Be(this,Us));let s=this.tooltipPlacement;s&&this.tooltipEl&&(this.tooltipEl.placement=s);};ve.shadowRootOptions={mode:"open"};ve.getTemplateHTML=TE;ve.getSlotTemplateHTML=yE;ve.getTooltipContentHTML=SE;A.customElements.get("media-chrome-button")||A.customElements.define("media-chrome-button",ve);var wf=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
352
|
-
<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"/>
|
|
353
|
-
</svg>
|
|
354
|
-
`;function bE(s){return `
|
|
355
|
-
<style>
|
|
356
|
-
:host([${T.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
|
|
357
|
-
display: none !important;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
:host(:not([${T.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
|
|
362
|
-
display: none !important;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
:host([${T.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
|
|
366
|
-
:host(:not([${T.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
|
|
367
|
-
display: none;
|
|
368
|
-
}
|
|
369
|
-
</style>
|
|
370
|
-
|
|
371
|
-
<slot name="icon">
|
|
372
|
-
<slot name="enter">${wf}</slot>
|
|
373
|
-
<slot name="exit">${wf}</slot>
|
|
374
|
-
</slot>
|
|
375
|
-
`}function AE(){return `
|
|
376
|
-
<slot name="tooltip-enter">${w("start airplay")}</slot>
|
|
377
|
-
<slot name="tooltip-exit">${w("stop airplay")}</slot>
|
|
378
|
-
`}var Pf=s=>{let e=s.mediaIsAirplaying?w("stop airplay"):w("start airplay");s.setAttribute("aria-label",e);},Pr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Pf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_AIRPLAYING&&Pf(this);}get mediaIsAirplaying(){return X(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Z(this,T.MEDIA_IS_AIRPLAYING,e);}get mediaAirplayUnavailable(){return te(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ie(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e);}handleClick(){let e=new A.CustomEvent(F.MEDIA_AIRPLAY_REQUEST,{composed:true,bubbles:true});this.dispatchEvent(e);}};Pr.getSlotTemplateHTML=bE;Pr.getTooltipContentHTML=AE;A.customElements.get("media-airplay-button")||A.customElements.define("media-airplay-button",Pr);var _E=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
379
|
-
<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"/>
|
|
380
|
-
</svg>`,IE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
381
|
-
<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"/>
|
|
382
|
-
</svg>`;function LE(s){return `
|
|
383
|
-
<style>
|
|
384
|
-
:host([aria-checked="true"]) slot[name=off] {
|
|
385
|
-
display: none !important;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
:host(:not([aria-checked="true"])) slot[name=on] {
|
|
390
|
-
display: none !important;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
:host([aria-checked="true"]) slot[name=tooltip-enable],
|
|
394
|
-
:host(:not([aria-checked="true"])) slot[name=tooltip-disable] {
|
|
395
|
-
display: none;
|
|
396
|
-
}
|
|
397
|
-
</style>
|
|
398
|
-
|
|
399
|
-
<slot name="icon">
|
|
400
|
-
<slot name="on">${_E}</slot>
|
|
401
|
-
<slot name="off">${IE}</slot>
|
|
402
|
-
</slot>
|
|
403
|
-
`}function xE(){return `
|
|
404
|
-
<slot name="tooltip-enable">${w("Enable captions")}</slot>
|
|
405
|
-
<slot name="tooltip-disable">${w("Disable captions")}</slot>
|
|
406
|
-
`}var Of=s=>{s.setAttribute("aria-checked",ma(s).toString());},Or=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",w("closed captions")),Of(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_SUBTITLES_SHOWING&&Of(this);}get mediaSubtitlesList(){return Nf(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Ff(this,T.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return Nf(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Ff(this,T.MEDIA_SUBTITLES_SHOWING,e);}handleClick(){this.dispatchEvent(new A.CustomEvent(F.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));}};Or.getSlotTemplateHTML=LE;Or.getTooltipContentHTML=xE;var Nf=(s,e)=>{let t=s.getAttribute(e);return t?Qi(t):[]},Ff=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=gi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};A.customElements.get("media-captions-button")||A.customElements.define("media-captions-button",Or);var RE='<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>',DE='<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>';function kE(s){return `
|
|
407
|
-
<style>
|
|
408
|
-
:host([${T.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
|
|
409
|
-
display: none !important;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
:host(:not([${T.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {
|
|
414
|
-
display: none !important;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
:host([${T.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],
|
|
418
|
-
:host(:not([${T.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {
|
|
419
|
-
display: none;
|
|
420
|
-
}
|
|
421
|
-
</style>
|
|
422
|
-
|
|
423
|
-
<slot name="icon">
|
|
424
|
-
<slot name="enter">${RE}</slot>
|
|
425
|
-
<slot name="exit">${DE}</slot>
|
|
426
|
-
</slot>
|
|
427
|
-
`}function CE(){return `
|
|
428
|
-
<slot name="tooltip-enter">${w("Start casting")}</slot>
|
|
429
|
-
<slot name="tooltip-exit">${w("Stop casting")}</slot>
|
|
430
|
-
`}var Uf=s=>{let e=s.mediaIsCasting?w("stop casting"):w("start casting");s.setAttribute("aria-label",e);},Nr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Uf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_CASTING&&Uf(this);}get mediaIsCasting(){return X(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){Z(this,T.MEDIA_IS_CASTING,e);}get mediaCastUnavailable(){return te(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ie(this,T.MEDIA_CAST_UNAVAILABLE,e);}handleClick(){let e=this.mediaIsCasting?F.MEDIA_EXIT_CAST_REQUEST:F.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:true,bubbles:true}));}};Nr.getSlotTemplateHTML=kE;Nr.getTooltipContentHTML=CE;A.customElements.get("media-cast-button")||A.customElements.define("media-cast-button",Nr);var Ed=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},is=(s,e,t)=>(Ed(s,e,"read from private field"),e.get(s)),Ei=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},vd=(s,e,t,i)=>(Ed(s,e,"write to private field"),e.set(s,t),t),ts=(s,e,t)=>(Ed(s,e,"access private method"),t),La,Ur,ss,Ia,ud,hd,Bf,fd,$f,md,Gf,gd,Hf,pd,Vf;function ME(s){return `
|
|
431
|
-
<style>
|
|
432
|
-
:host {
|
|
433
|
-
font: var(--media-font,
|
|
434
|
-
var(--media-font-weight, normal)
|
|
435
|
-
var(--media-font-size, 14px) /
|
|
436
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
437
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
438
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
439
|
-
display: var(--media-dialog-display, inline-flex);
|
|
440
|
-
justify-content: center;
|
|
441
|
-
align-items: center;
|
|
442
|
-
|
|
443
|
-
transition-behavior: allow-discrete;
|
|
444
|
-
visibility: hidden;
|
|
445
|
-
opacity: 0;
|
|
446
|
-
transform: translateY(2px) scale(.99);
|
|
447
|
-
pointer-events: none;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
:host([open]) {
|
|
451
|
-
transition: display .2s, visibility 0s, opacity .2s ease-out, transform .15s ease-out;
|
|
452
|
-
visibility: visible;
|
|
453
|
-
opacity: 1;
|
|
454
|
-
transform: translateY(0) scale(1);
|
|
455
|
-
pointer-events: auto;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
#content {
|
|
459
|
-
display: flex;
|
|
460
|
-
position: relative;
|
|
461
|
-
box-sizing: border-box;
|
|
462
|
-
width: min(320px, 100%);
|
|
463
|
-
word-wrap: break-word;
|
|
464
|
-
max-height: 100%;
|
|
465
|
-
overflow: auto;
|
|
466
|
-
text-align: center;
|
|
467
|
-
line-height: 1.4;
|
|
468
|
-
}
|
|
469
|
-
</style>
|
|
470
|
-
${this.getSlotTemplateHTML(s)}
|
|
471
|
-
`}function wE(s){return `
|
|
472
|
-
<slot id="content"></slot>
|
|
473
|
-
`}var Fr={OPEN:"open",ANCHOR:"anchor"},Ci=class extends A.HTMLElement{constructor(){super(),Ei(this,Ia),Ei(this,hd),Ei(this,fd),Ei(this,md),Ei(this,gd),Ei(this,pd),Ei(this,La,false),Ei(this,Ur,null),Ei(this,ss,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this);}static get observedAttributes(){return [Fr.OPEN,Fr.ANCHOR]}get open(){return X(this,Fr.OPEN)}set open(e){Z(this,Fr.OPEN,e);}handleEvent(e){switch(e.type){case "invoke":ts(this,md,Gf).call(this,e);break;case "focusout":ts(this,gd,Hf).call(this,e);break;case "keydown":ts(this,pd,Vf).call(this,e);break}}connectedCallback(){ts(this,Ia,ud).call(this),this.role||(this.role="dialog");}attributeChangedCallback(e,t,i){ts(this,Ia,ud).call(this),e===Fr.OPEN&&i!==t&&(this.open?ts(this,hd,Bf).call(this):ts(this,fd,$f).call(this));}focus(){vd(this,Ur,_r());let e=!this.dispatchEvent(new Event("focus",{composed:true,cancelable:true})),t=!this.dispatchEvent(new Event("focusin",{composed:true,bubbles:true,cancelable:true}));if(e||t)return;let i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');i?.focus();}get keysUsed(){return ["Escape","Tab"]}};La=new WeakMap;Ur=new WeakMap;ss=new WeakMap;Ia=new WeakSet;ud=function(){if(!is(this,La)&&(vd(this,La,true),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let s=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(s),queueMicrotask(()=>{let{style:e}=ye(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in");});}};hd=new WeakSet;Bf=function(){var s;(s=is(this,ss))==null||s.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:true,bubbles:true})),this.addEventListener("transitionend",()=>this.focus(),{once:true});};fd=new WeakSet;$f=function(){var s;(s=is(this,ss))==null||s.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:true,bubbles:true}));};md=new WeakSet;Gf=function(s){vd(this,ss,s.relatedTarget),at(this,s.relatedTarget)||(this.open=!this.open);};gd=new WeakSet;Hf=function(s){var e;at(this,s.relatedTarget)||((e=is(this,Ur))==null||e.focus(),is(this,ss)&&is(this,ss)!==s.relatedTarget&&this.open&&(this.open=false));};pd=new WeakSet;Vf=function(s){var e,t,i,r,n;let{key:a,ctrlKey:o,altKey:d,metaKey:l}=s;o||d||l||this.keysUsed.includes(a)&&(s.preventDefault(),s.stopPropagation(),a==="Tab"?(s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(i=this.nextElementSibling)==null?void 0:i.focus)==null||r.call(i),this.blur()):a==="Escape"&&((n=is(this,Ur))==null||n.focus(),this.open=false));};Ci.shadowRootOptions={mode:"open"};Ci.getTemplateHTML=ME;Ci.getSlotTemplateHTML=wE;A.customElements.get("media-chrome-dialog")||A.customElements.define("media-chrome-dialog",Ci);var Id=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},we=(s,e,t)=>(Id(s,e,"read from private field"),t?t.call(s):e.get(s)),Je=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Mi=(s,e,t,i)=>(Id(s,e,"write to private field"),e.set(s,t),t),Mt=(s,e,t)=>(Id(s,e,"access private method"),t),Wt,Na,xa,Ra,wt,Pa,Da,ka,Ca,Ld,Kf,Ma,Td,wa,yd,Oa,xd,Sd,Wf,bd,qf,Ad,Yf,_d,jf;function PE(s){return `
|
|
474
|
-
<style>
|
|
475
|
-
:host {
|
|
476
|
-
--_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
477
|
-
--_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));
|
|
478
|
-
|
|
479
|
-
box-shadow: var(--_focus-visible-box-shadow, none);
|
|
480
|
-
background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
|
|
481
|
-
height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));
|
|
482
|
-
display: inline-flex;
|
|
483
|
-
align-items: center;
|
|
484
|
-
|
|
485
|
-
vertical-align: middle;
|
|
486
|
-
box-sizing: border-box;
|
|
487
|
-
position: relative;
|
|
488
|
-
width: 100px;
|
|
489
|
-
transition: background .15s linear;
|
|
490
|
-
cursor: var(--media-cursor, pointer);
|
|
491
|
-
pointer-events: auto;
|
|
492
|
-
touch-action: none;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
input[type=range]:focus {
|
|
497
|
-
outline: 0;
|
|
498
|
-
}
|
|
499
|
-
input[type=range]:focus::-webkit-slider-runnable-track {
|
|
500
|
-
outline: 0;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
:host(:hover) {
|
|
504
|
-
background: var(--media-control-hover-background, rgb(50 50 70 / .7));
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
#leftgap {
|
|
508
|
-
padding-left: var(--media-range-padding-left, var(--_media-range-padding));
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
#rightgap {
|
|
512
|
-
padding-right: var(--media-range-padding-right, var(--_media-range-padding));
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
#startpoint,
|
|
516
|
-
#endpoint {
|
|
517
|
-
position: absolute;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
#endpoint {
|
|
521
|
-
right: 0;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
#container {
|
|
525
|
-
|
|
526
|
-
width: var(--media-range-track-width, 100%);
|
|
527
|
-
transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
|
|
528
|
-
position: relative;
|
|
529
|
-
height: 100%;
|
|
530
|
-
display: flex;
|
|
531
|
-
align-items: center;
|
|
532
|
-
min-width: 40px;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
#range {
|
|
536
|
-
|
|
537
|
-
display: var(--media-time-range-hover-display, block);
|
|
538
|
-
bottom: var(--media-time-range-hover-bottom, -7px);
|
|
539
|
-
height: var(--media-time-range-hover-height, max(100% + 7px, 25px));
|
|
540
|
-
width: 100%;
|
|
541
|
-
position: absolute;
|
|
542
|
-
cursor: var(--media-cursor, pointer);
|
|
543
|
-
|
|
544
|
-
-webkit-appearance: none;
|
|
545
|
-
-webkit-tap-highlight-color: transparent;
|
|
546
|
-
background: transparent;
|
|
547
|
-
margin: 0;
|
|
548
|
-
z-index: 1;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
@media (hover: hover) {
|
|
552
|
-
#range {
|
|
553
|
-
bottom: var(--media-time-range-hover-bottom, -5px);
|
|
554
|
-
height: var(--media-time-range-hover-height, max(100% + 5px, 20px));
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
#range::-webkit-slider-thumb {
|
|
561
|
-
-webkit-appearance: none;
|
|
562
|
-
background: transparent;
|
|
563
|
-
width: .1px;
|
|
564
|
-
height: .1px;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
#range::-moz-range-thumb {
|
|
569
|
-
background: transparent;
|
|
570
|
-
border: transparent;
|
|
571
|
-
width: .1px;
|
|
572
|
-
height: .1px;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
#appearance {
|
|
576
|
-
height: var(--media-range-track-height, 4px);
|
|
577
|
-
display: flex;
|
|
578
|
-
flex-direction: column;
|
|
579
|
-
justify-content: center;
|
|
580
|
-
width: 100%;
|
|
581
|
-
position: absolute;
|
|
582
|
-
|
|
583
|
-
will-change: transform;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
#track {
|
|
587
|
-
background: var(--media-range-track-background, rgb(255 255 255 / .2));
|
|
588
|
-
border-radius: var(--media-range-track-border-radius, 1px);
|
|
589
|
-
border: var(--media-range-track-border, none);
|
|
590
|
-
outline: var(--media-range-track-outline);
|
|
591
|
-
outline-offset: var(--media-range-track-outline-offset);
|
|
592
|
-
backdrop-filter: var(--media-range-track-backdrop-filter);
|
|
593
|
-
-webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
|
|
594
|
-
box-shadow: var(--media-range-track-box-shadow, none);
|
|
595
|
-
position: absolute;
|
|
596
|
-
width: 100%;
|
|
597
|
-
height: 100%;
|
|
598
|
-
overflow: hidden;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
#progress,
|
|
602
|
-
#pointer {
|
|
603
|
-
position: absolute;
|
|
604
|
-
height: 100%;
|
|
605
|
-
will-change: width;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
#progress {
|
|
609
|
-
background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
|
|
610
|
-
transition: var(--media-range-track-transition);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
#pointer {
|
|
614
|
-
background: var(--media-range-track-pointer-background);
|
|
615
|
-
border-right: var(--media-range-track-pointer-border-right);
|
|
616
|
-
transition: visibility .25s, opacity .25s;
|
|
617
|
-
visibility: hidden;
|
|
618
|
-
opacity: 0;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
@media (hover: hover) {
|
|
622
|
-
:host(:hover) #pointer {
|
|
623
|
-
transition: visibility .5s, opacity .5s;
|
|
624
|
-
visibility: visible;
|
|
625
|
-
opacity: 1;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
#thumb,
|
|
630
|
-
::slotted([slot=thumb]) {
|
|
631
|
-
width: var(--media-range-thumb-width, 10px);
|
|
632
|
-
height: var(--media-range-thumb-height, 10px);
|
|
633
|
-
transition: var(--media-range-thumb-transition);
|
|
634
|
-
transform: var(--media-range-thumb-transform, none);
|
|
635
|
-
opacity: var(--media-range-thumb-opacity, 1);
|
|
636
|
-
translate: -50%;
|
|
637
|
-
position: absolute;
|
|
638
|
-
left: 0;
|
|
639
|
-
cursor: var(--media-cursor, pointer);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
#thumb {
|
|
643
|
-
border-radius: var(--media-range-thumb-border-radius, 10px);
|
|
644
|
-
background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));
|
|
645
|
-
box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);
|
|
646
|
-
border: var(--media-range-thumb-border, none);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
:host([disabled]) #thumb {
|
|
650
|
-
background-color: #777;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
.segments #appearance {
|
|
654
|
-
height: var(--media-range-segment-hover-height, 7px);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
#track {
|
|
658
|
-
clip-path: url(#segments-clipping);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
#segments {
|
|
662
|
-
--segments-gap: var(--media-range-segments-gap, 2px);
|
|
663
|
-
position: absolute;
|
|
664
|
-
width: 100%;
|
|
665
|
-
height: 100%;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
#segments-clipping {
|
|
669
|
-
transform: translateX(calc(var(--segments-gap) / 2));
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
#segments-clipping:empty {
|
|
673
|
-
display: none;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
#segments-clipping rect {
|
|
677
|
-
height: var(--media-range-track-height, 4px);
|
|
678
|
-
y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
|
|
679
|
-
transition: var(--media-range-segment-transition, transform .1s ease-in-out);
|
|
680
|
-
transform: var(--media-range-segment-transform, scaleY(1));
|
|
681
|
-
transform-origin: center;
|
|
682
|
-
}
|
|
683
|
-
</style>
|
|
684
|
-
<div id="leftgap"></div>
|
|
685
|
-
<div id="container">
|
|
686
|
-
<div id="startpoint"></div>
|
|
687
|
-
<div id="endpoint"></div>
|
|
688
|
-
<div id="appearance">
|
|
689
|
-
<div id="track" part="track">
|
|
690
|
-
<div id="pointer"></div>
|
|
691
|
-
<div id="progress" part="progress"></div>
|
|
692
|
-
</div>
|
|
693
|
-
<slot name="thumb">
|
|
694
|
-
<div id="thumb" part="thumb"></div>
|
|
695
|
-
</slot>
|
|
696
|
-
<svg id="segments"><clipPath id="segments-clipping"></clipPath></svg>
|
|
697
|
-
</div>
|
|
698
|
-
<input id="range" type="range" min="0" max="1" step="any" value="0">
|
|
699
|
-
</div>
|
|
700
|
-
<div id="rightgap"></div>
|
|
701
|
-
`}var qt=class extends A.HTMLElement{constructor(){if(super(),Je(this,Ld),Je(this,Ma),Je(this,wa),Je(this,Oa),Je(this,Sd),Je(this,bd),Je(this,Ad),Je(this,_d),Je(this,Wt,void 0),Je(this,Na,void 0),Je(this,xa,void 0),Je(this,Ra,void 0),Je(this,wt,{}),Je(this,Pa,[]),Je(this,Da,()=>{if(this.range.matches(":focus-visible")){let{style:e}=ye(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)");}}),Je(this,ka,()=>{let{style:e}=ye(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow");}),Je(this,Ca,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e);}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t;}this.container=this.shadowRoot.querySelector("#container"),Mi(this,xa,this.shadowRoot.querySelector("#startpoint")),Mi(this,Ra,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance");}static get observedAttributes(){return ["disabled","aria-disabled",re.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===re.MEDIA_CONTROLLER?(t&&((n=(r=we(this,Wt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Mi(this,Wt,null)),i&&this.isConnected&&(Mi(this,Wt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=we(this,Wt))==null?void 0:o.associateElement)==null||d.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?(this.range.removeAttribute(e),Mt(this,Ma,Td).call(this)):(this.range.setAttribute(e,i),Mt(this,wa,yd).call(this)));}connectedCallback(){var e,t,i;let{style:r}=ye(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),we(this,wt).pointer=ye(this.shadowRoot,"#pointer"),we(this,wt).progress=ye(this.shadowRoot,"#progress"),we(this,wt).thumb=ye(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),we(this,wt).activeSegment=ye(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let n=this.getAttribute(re.MEDIA_CONTROLLER);n&&(Mi(this,Wt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=we(this,Wt))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",we(this,Da)),this.shadowRoot.addEventListener("focusout",we(this,ka)),Mt(this,Ma,Td).call(this),hi(this.container,we(this,Ca));}disconnectedCallback(){var e,t;Mt(this,wa,yd).call(this),(t=(e=we(this,Wt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Mi(this,Wt,null),this.shadowRoot.removeEventListener("focusin",we(this,Da)),this.shadowRoot.removeEventListener("focusout",we(this,ka)),fi(this.container,we(this,Ca));}updatePointerBar(e){var t;(t=we(this,wt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`);}updateBar(){var e,t;let i=this.range.valueAsNumber*100;(e=we(this,wt).progress)==null||e.style.setProperty("width",`${i}%`),(t=we(this,wt).thumb)==null||t.style.setProperty("left",`${i}%`);}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!e?.length),!e?.length)return;let i=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Mi(this,Pa,[...i]);let r=i.pop();for(let[n,a]of i.entries()){let[o,d]=[n===0,n===i.length-1],l=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((d?r:i[n+1])-a)*100}%${o||d?"":" - var(--segments-gap)"})`,h=Ce.createElementNS("http://www.w3.org/2000/svg","rect"),f=ye(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",l),f.style.setProperty("width",u),t.append(h);}}getPointerRatio(e){return rf(e.clientX,e.clientY,we(this,xa).getBoundingClientRect(),we(this,Ra).getBoundingClientRect())}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case "pointermove":Mt(this,_d,jf).call(this,e);break;case "input":this.updateBar();break;case "pointerenter":Mt(this,Sd,Wf).call(this,e);break;case "pointerdown":Mt(this,Oa,xd).call(this,e);break;case "pointerup":Mt(this,bd,qf).call(this);break;case "pointerleave":Mt(this,Ad,Yf).call(this);break}}get keysUsed(){return ["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Wt=new WeakMap;Na=new WeakMap;xa=new WeakMap;Ra=new WeakMap;wt=new WeakMap;Pa=new WeakMap;Da=new WeakMap;ka=new WeakMap;Ca=new WeakMap;Ld=new WeakSet;Kf=function(s){let e=we(this,wt).activeSegment;if(!e)return;let t=this.getPointerRatio(s),r=`#segments-clipping rect:nth-child(${we(this,Pa).findIndex((n,a,o)=>{let d=o[a+1];return d!=null&&t>=n&&t<=d})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"));};Ma=new WeakSet;Td=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this));};wa=new WeakSet;yd=function(){var s,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(s=A.window)==null||s.removeEventListener("pointerup",this),(e=A.window)==null||e.removeEventListener("pointermove",this);};Oa=new WeakSet;xd=function(s){var e;Mi(this,Na,s.composedPath().includes(this.range)),(e=A.window)==null||e.addEventListener("pointerup",this);};Sd=new WeakSet;Wf=function(s){var e;s.pointerType!=="mouse"&&Mt(this,Oa,xd).call(this,s),this.addEventListener("pointerleave",this),(e=A.window)==null||e.addEventListener("pointermove",this);};bd=new WeakSet;qf=function(){var s;(s=A.window)==null||s.removeEventListener("pointerup",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled");};Ad=new WeakSet;Yf=function(){var s,e;this.removeEventListener("pointerleave",this),(s=A.window)==null||s.removeEventListener("pointermove",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled"),(e=we(this,wt).activeSegment)==null||e.style.removeProperty("transform");};_d=new WeakSet;jf=function(s){this.toggleAttribute("dragging",s.buttons===1||s.pointerType!=="mouse"),this.updatePointerBar(s),Mt(this,Ld,Kf).call(this,s),this.dragging&&(s.pointerType!=="mouse"||!we(this,Na))&&(this.range.disabled=true,this.range.valueAsNumber=this.getPointerRatio(s),this.range.dispatchEvent(new Event("input",{bubbles:true,composed:true})));};qt.shadowRootOptions={mode:"open"};qt.getTemplateHTML=PE;A.customElements.get("media-chrome-range")||A.customElements.define("media-chrome-range",qt);var zf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Fa=(s,e,t)=>(zf(s,e,"read from private field"),t?t.call(s):e.get(s)),OE=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Ua=(s,e,t,i)=>(zf(s,e,"write to private field"),e.set(s,t),t),Yt;function NE(s){return `
|
|
702
|
-
<style>
|
|
703
|
-
:host {
|
|
704
|
-
|
|
705
|
-
box-sizing: border-box;
|
|
706
|
-
display: var(--media-control-display, var(--media-control-bar-display, inline-flex));
|
|
707
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
708
|
-
--media-loading-indicator-icon-height: 44px;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
::slotted(media-time-range),
|
|
712
|
-
::slotted(media-volume-range) {
|
|
713
|
-
min-height: 100%;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
::slotted(media-time-range),
|
|
717
|
-
::slotted(media-clip-selector) {
|
|
718
|
-
flex-grow: 1;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
::slotted([role="menu"]) {
|
|
722
|
-
position: absolute;
|
|
723
|
-
}
|
|
724
|
-
</style>
|
|
725
|
-
|
|
726
|
-
<slot></slot>
|
|
727
|
-
`}var Br=class extends A.HTMLElement{constructor(){if(super(),OE(this,Yt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [re.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===re.MEDIA_CONTROLLER&&(t&&((n=(r=Fa(this,Yt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Ua(this,Yt,null)),i&&this.isConnected&&(Ua(this,Yt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Fa(this,Yt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(re.MEDIA_CONTROLLER);r&&(Ua(this,Yt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Fa(this,Yt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Fa(this,Yt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ua(this,Yt,null);}};Yt=new WeakMap;Br.shadowRootOptions={mode:"open"};Br.getTemplateHTML=NE;A.customElements.get("media-control-bar")||A.customElements.define("media-control-bar",Br);var Qf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ba=(s,e,t)=>(Qf(s,e,"read from private field"),t?t.call(s):e.get(s)),FE=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},$a=(s,e,t,i)=>(Qf(s,e,"write to private field"),e.set(s,t),t),jt;function UE(s,e={}){return `
|
|
728
|
-
<style>
|
|
729
|
-
:host {
|
|
730
|
-
font: var(--media-font,
|
|
731
|
-
var(--media-font-weight, normal)
|
|
732
|
-
var(--media-font-size, 14px) /
|
|
733
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
734
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
735
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
736
|
-
background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));
|
|
737
|
-
padding: var(--media-control-padding, 10px);
|
|
738
|
-
display: inline-flex;
|
|
739
|
-
justify-content: center;
|
|
740
|
-
align-items: center;
|
|
741
|
-
vertical-align: middle;
|
|
742
|
-
box-sizing: border-box;
|
|
743
|
-
text-align: center;
|
|
744
|
-
pointer-events: auto;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
:host(:focus-visible) {
|
|
749
|
-
box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
|
|
750
|
-
outline: 0;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
:host(:where(:focus)) {
|
|
755
|
-
box-shadow: none;
|
|
756
|
-
outline: 0;
|
|
757
|
-
}
|
|
758
|
-
</style>
|
|
759
|
-
|
|
760
|
-
${this.getSlotTemplateHTML(s,e)}
|
|
761
|
-
`}function BE(s,e){return `
|
|
762
|
-
<slot></slot>
|
|
763
|
-
`}var dt=class extends A.HTMLElement{constructor(){if(super(),FE(this,jt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [re.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===re.MEDIA_CONTROLLER&&(t&&((n=(r=Ba(this,jt))==null?void 0:r.unassociateElement)==null||n.call(r,this),$a(this,jt,null)),i&&this.isConnected&&($a(this,jt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Ba(this,jt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let{style:r}=ye(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(re.MEDIA_CONTROLLER);n&&($a(this,jt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=Ba(this,jt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Ba(this,jt))==null?void 0:e.unassociateElement)==null||t.call(e,this),$a(this,jt,null);}};jt=new WeakMap;dt.shadowRootOptions={mode:"open"};dt.getTemplateHTML=UE;dt.getSlotTemplateHTML=BE;A.customElements.get("media-text-display")||A.customElements.define("media-text-display",dt);var Zf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Xf=(s,e,t)=>(Zf(s,e,"read from private field"),t?t.call(s):e.get(s)),$E=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},GE=(s,e,t,i)=>(Zf(s,e,"write to private field"),e.set(s,t),t),$r;function HE(s,e){return `
|
|
764
|
-
<slot>${Ct(e.mediaDuration)}</slot>
|
|
765
|
-
`}var Ga=class extends dt{constructor(){var e;super(),$E(this,$r,void 0),GE(this,$r,this.shadowRoot.querySelector("slot")),Xf(this,$r).textContent=Ct((e=this.mediaDuration)!=null?e:0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===T.MEDIA_DURATION&&(Xf(this,$r).textContent=Ct(+i)),super.attributeChangedCallback(e,t,i);}get mediaDuration(){return ae(this,T.MEDIA_DURATION)}set mediaDuration(e){he(this,T.MEDIA_DURATION,e);}};$r=new WeakMap;Ga.getSlotTemplateHTML=HE;A.customElements.get("media-duration-display")||A.customElements.define("media-duration-display",Ga);var VE={2:w("Network Error"),3:w("Decode Error"),4:w("Source Not Supported"),5:w("Encryption Error")},KE={2:w("A network error caused the media download to fail."),3:w("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:w("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:w("The media is encrypted and there are no keys to decrypt it.")},Rd=s=>{var e,t;return s.code===1?null:{title:(e=VE[s.code])!=null?e:`Error ${s.code}`,message:(t=KE[s.code])!=null?t:s.message}};var em=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},WE=(s,e,t)=>(em(s,e,"read from private field"),t?t.call(s):e.get(s)),qE=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},YE=(s,e,t,i)=>(em(s,e,"write to private field"),e.set(s,t),t),Ha;function jE(s){return `
|
|
766
|
-
<style>
|
|
767
|
-
:host {
|
|
768
|
-
background: rgb(20 20 30 / .8);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
#content {
|
|
772
|
-
display: block;
|
|
773
|
-
padding: 1.2em 1.5em;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
h3,
|
|
777
|
-
p {
|
|
778
|
-
margin-block: 0 .3em;
|
|
779
|
-
}
|
|
780
|
-
</style>
|
|
781
|
-
<slot name="error-${s.mediaerrorcode}" id="content">
|
|
782
|
-
${tm({code:+s.mediaerrorcode,message:s.mediaerrormessage})}
|
|
783
|
-
</slot>
|
|
784
|
-
`}function zE(s){return s.code&&Rd(s)!==null}function tm(s){var e;let{title:t,message:i}=(e=Rd(s))!=null?e:{},r="";return t&&(r+=`<slot name="error-${s.code}-title"><h3>${t}</h3></slot>`),i&&(r+=`<slot name="error-${s.code}-message"><p>${i}</p></slot>`),r}var Jf=[T.MEDIA_ERROR_CODE,T.MEDIA_ERROR_MESSAGE],Gr=class extends Ci{constructor(){super(...arguments),qE(this,Ha,null);}static get observedAttributes(){return [...super.observedAttributes,...Jf]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!Jf.includes(e))return;let n=(r=this.mediaError)!=null?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=zE(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n));}get mediaError(){return WE(this,Ha)}set mediaError(e){YE(this,Ha,e);}get mediaErrorCode(){return ae(this,"mediaerrorcode")}set mediaErrorCode(e){he(this,"mediaerrorcode",e);}get mediaErrorMessage(){return te(this,"mediaerrormessage")}set mediaErrorMessage(e){ie(this,"mediaerrormessage",e);}};Ha=new WeakMap;Gr.getSlotTemplateHTML=jE;Gr.formatErrorMessage=tm;A.customElements.get("media-error-dialog")||A.customElements.define("media-error-dialog",Gr);var QE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
785
|
-
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
786
|
-
</svg>`,XE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
787
|
-
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
788
|
-
</svg>`;function ZE(s){return `
|
|
789
|
-
<style>
|
|
790
|
-
:host([${T.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
|
|
791
|
-
display: none !important;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
:host(:not([${T.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {
|
|
796
|
-
display: none !important;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
:host([${T.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],
|
|
800
|
-
:host(:not([${T.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {
|
|
801
|
-
display: none;
|
|
802
|
-
}
|
|
803
|
-
</style>
|
|
804
|
-
|
|
805
|
-
<slot name="icon">
|
|
806
|
-
<slot name="enter">${QE}</slot>
|
|
807
|
-
<slot name="exit">${XE}</slot>
|
|
808
|
-
</slot>
|
|
809
|
-
`}function JE(){return `
|
|
810
|
-
<slot name="tooltip-enter">${w("Enter fullscreen mode")}</slot>
|
|
811
|
-
<slot name="tooltip-exit">${w("Exit fullscreen mode")}</slot>
|
|
812
|
-
`}var im=s=>{let e=s.mediaIsFullscreen?w("exit fullscreen mode"):w("enter fullscreen mode");s.setAttribute("aria-label",e);},Hr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),im(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_FULLSCREEN&&im(this);}get mediaFullscreenUnavailable(){return te(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ie(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e);}get mediaIsFullscreen(){return X(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Z(this,T.MEDIA_IS_FULLSCREEN,e);}handleClick(){let e=this.mediaIsFullscreen?F.MEDIA_EXIT_FULLSCREEN_REQUEST:F.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:true,bubbles:true}));}};Hr.getSlotTemplateHTML=ZE;Hr.getTooltipContentHTML=JE;A.customElements.get("media-fullscreen-button")||A.customElements.define("media-fullscreen-button",Hr);var{MEDIA_TIME_IS_LIVE:Va,MEDIA_PAUSED:Vr}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:ev,MEDIA_PLAY_REQUEST:tv}=F,iv='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>';function sv(s){return `
|
|
813
|
-
<style>
|
|
814
|
-
:host { --media-tooltip-display: none; }
|
|
815
|
-
|
|
816
|
-
slot[name=indicator] > *,
|
|
817
|
-
:host ::slotted([slot=indicator]) {
|
|
818
|
-
|
|
819
|
-
min-width: auto;
|
|
820
|
-
fill: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
821
|
-
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
:host([${Va}]:not([${Vr}])) slot[name=indicator] > *,
|
|
825
|
-
:host([${Va}]:not([${Vr}])) ::slotted([slot=indicator]) {
|
|
826
|
-
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
827
|
-
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
:host([${Va}]:not([${Vr}])) {
|
|
831
|
-
cursor: var(--media-cursor, not-allowed);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
slot[name=text]{
|
|
835
|
-
text-transform: uppercase;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
</style>
|
|
839
|
-
|
|
840
|
-
<slot name="indicator">${iv}</slot>
|
|
841
|
-
|
|
842
|
-
<slot name="spacer"> </slot><slot name="text">${w("live")}</slot>
|
|
843
|
-
`}var sm=s=>{var e;let t=s.mediaPaused||!s.mediaTimeIsLive,i=t?w("seek to live"):w("playing live");s.setAttribute("aria-label",i);let r=(e=s.shadowRoot)==null?void 0:e.querySelector('slot[name="text"]');r&&(r.textContent=w("live")),t?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true");},Ka=class extends ve{static get observedAttributes(){return [...super.observedAttributes,Va,Vr]}connectedCallback(){super.connectedCallback(),sm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),sm(this);}get mediaPaused(){return X(this,T.MEDIA_PAUSED)}set mediaPaused(e){Z(this,T.MEDIA_PAUSED,e);}get mediaTimeIsLive(){return X(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Z(this,T.MEDIA_TIME_IS_LIVE,e);}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new A.CustomEvent(ev,{composed:true,bubbles:true})),this.hasAttribute(Vr)&&this.dispatchEvent(new A.CustomEvent(tv,{composed:true,bubbles:true})));}};Ka.getSlotTemplateHTML=sv;A.customElements.get("media-live-button")||A.customElements.define("media-live-button",Ka);var nm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Kr=(s,e,t)=>(nm(s,e,"read from private field"),t?t.call(s):e.get(s)),rm=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Wr=(s,e,t,i)=>(nm(s,e,"write to private field"),e.set(s,t),t),zt,qa,Wa={LOADING_DELAY:"loadingdelay",NO_AUTOHIDE:"noautohide"},am=500,rv=`
|
|
844
|
-
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
845
|
-
<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">
|
|
846
|
-
<animateTransform
|
|
847
|
-
attributeName="transform"
|
|
848
|
-
attributeType="XML"
|
|
849
|
-
type="rotate"
|
|
850
|
-
dur="1s"
|
|
851
|
-
from="0 50 50"
|
|
852
|
-
to="360 50 50"
|
|
853
|
-
repeatCount="indefinite" />
|
|
854
|
-
</path>
|
|
855
|
-
</svg>
|
|
856
|
-
`;function nv(s){return `
|
|
857
|
-
<style>
|
|
858
|
-
:host {
|
|
859
|
-
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
860
|
-
vertical-align: middle;
|
|
861
|
-
box-sizing: border-box;
|
|
862
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${am}ms);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
#status {
|
|
866
|
-
color: rgba(0,0,0,0);
|
|
867
|
-
width: 0px;
|
|
868
|
-
height: 0px;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
:host slot[name=icon] > *,
|
|
872
|
-
:host ::slotted([slot=icon]) {
|
|
873
|
-
opacity: var(--media-loading-indicator-opacity, 0);
|
|
874
|
-
transition: opacity 0.15s;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) slot[name=icon] > *,
|
|
878
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
|
|
879
|
-
opacity: var(--media-loading-indicator-opacity, 1);
|
|
880
|
-
transition: opacity 0.15s var(--_loading-indicator-delay);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
:host #status {
|
|
884
|
-
visibility: var(--media-loading-indicator-opacity, hidden);
|
|
885
|
-
transition: visibility 0.15s;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) #status {
|
|
889
|
-
visibility: var(--media-loading-indicator-opacity, visible);
|
|
890
|
-
transition: visibility 0.15s var(--_loading-indicator-delay);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
svg, img, ::slotted(svg), ::slotted(img) {
|
|
894
|
-
width: var(--media-loading-indicator-icon-width);
|
|
895
|
-
height: var(--media-loading-indicator-icon-height, 100px);
|
|
896
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
897
|
-
vertical-align: middle;
|
|
898
|
-
}
|
|
899
|
-
</style>
|
|
900
|
-
|
|
901
|
-
<slot name="icon">${rv}</slot>
|
|
902
|
-
<div id="status" role="status" aria-live="polite">${w("media loading")}</div>
|
|
903
|
-
`}var qr=class extends A.HTMLElement{constructor(){if(super(),rm(this,zt,void 0),rm(this,qa,am),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [re.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,Wa.LOADING_DELAY]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===Wa.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===re.MEDIA_CONTROLLER&&(t&&((n=(r=Kr(this,zt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Wr(this,zt,null)),i&&this.isConnected&&(Wr(this,zt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Kr(this,zt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(re.MEDIA_CONTROLLER);r&&(Wr(this,zt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Kr(this,zt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Kr(this,zt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Wr(this,zt,null);}get loadingDelay(){return Kr(this,qa)}set loadingDelay(e){Wr(this,qa,e);let{style:t}=ye(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`);}get mediaPaused(){return X(this,T.MEDIA_PAUSED)}set mediaPaused(e){Z(this,T.MEDIA_PAUSED,e);}get mediaLoading(){return X(this,T.MEDIA_LOADING)}set mediaLoading(e){Z(this,T.MEDIA_LOADING,e);}get mediaController(){return te(this,re.MEDIA_CONTROLLER)}set mediaController(e){ie(this,re.MEDIA_CONTROLLER,e);}get noAutohide(){return X(this,Wa.NO_AUTOHIDE)}set noAutohide(e){Z(this,Wa.NO_AUTOHIDE,e);}};zt=new WeakMap;qa=new WeakMap;qr.shadowRootOptions={mode:"open"};qr.getTemplateHTML=nv;A.customElements.get("media-loading-indicator")||A.customElements.define("media-loading-indicator",qr);var av=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
904
|
-
<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"/>
|
|
905
|
-
</svg>`,om=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
906
|
-
<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"/>
|
|
907
|
-
</svg>`,ov=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
908
|
-
<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"/>
|
|
909
|
-
</svg>`;function lv(s){return `
|
|
910
|
-
<style>
|
|
911
|
-
:host(:not([${T.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
|
|
912
|
-
:host([${T.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
|
|
913
|
-
display: none !important;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
:host([${T.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {
|
|
917
|
-
display: none !important;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
:host([${T.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {
|
|
921
|
-
display: none !important;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
:host([${T.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {
|
|
925
|
-
display: none !important;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
:host(:not([${T.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],
|
|
929
|
-
:host([${T.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {
|
|
930
|
-
display: none;
|
|
931
|
-
}
|
|
932
|
-
</style>
|
|
933
|
-
|
|
934
|
-
<slot name="icon">
|
|
935
|
-
<slot name="off">${av}</slot>
|
|
936
|
-
<slot name="low">${om}</slot>
|
|
937
|
-
<slot name="medium">${om}</slot>
|
|
938
|
-
<slot name="high">${ov}</slot>
|
|
939
|
-
</slot>
|
|
940
|
-
`}function dv(){return `
|
|
941
|
-
<slot name="tooltip-mute">${w("Mute")}</slot>
|
|
942
|
-
<slot name="tooltip-unmute">${w("Unmute")}</slot>
|
|
943
|
-
`}var lm=s=>{let t=s.mediaVolumeLevel==="off"?w("unmute"):w("mute");s.setAttribute("aria-label",t);},Yr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),lm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_VOLUME_LEVEL&&lm(this);}get mediaVolumeLevel(){return te(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ie(this,T.MEDIA_VOLUME_LEVEL,e);}handleClick(){let e=this.mediaVolumeLevel==="off"?F.MEDIA_UNMUTE_REQUEST:F.MEDIA_MUTE_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:true,bubbles:true}));}};Yr.getSlotTemplateHTML=lv;Yr.getTooltipContentHTML=dv;A.customElements.get("media-mute-button")||A.customElements.define("media-mute-button",Yr);var dm=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
944
|
-
<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"/>
|
|
945
|
-
</svg>`;function cv(s){return `
|
|
946
|
-
<style>
|
|
947
|
-
:host([${T.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
|
|
948
|
-
display: none !important;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
:host(:not([${T.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {
|
|
952
|
-
display: none !important;
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
:host([${T.MEDIA_IS_PIP}]) slot[name=tooltip-enter],
|
|
956
|
-
:host(:not([${T.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {
|
|
957
|
-
display: none;
|
|
958
|
-
}
|
|
959
|
-
</style>
|
|
960
|
-
|
|
961
|
-
<slot name="icon">
|
|
962
|
-
<slot name="enter">${dm}</slot>
|
|
963
|
-
<slot name="exit">${dm}</slot>
|
|
964
|
-
</slot>
|
|
965
|
-
`}function uv(){return `
|
|
966
|
-
<slot name="tooltip-enter">${w("Enter picture in picture mode")}</slot>
|
|
967
|
-
<slot name="tooltip-exit">${w("Exit picture in picture mode")}</slot>
|
|
968
|
-
`}var cm=s=>{let e=s.mediaIsPip?w("exit picture in picture mode"):w("enter picture in picture mode");s.setAttribute("aria-label",e);},jr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),cm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_PIP&&cm(this);}get mediaPipUnavailable(){return te(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ie(this,T.MEDIA_PIP_UNAVAILABLE,e);}get mediaIsPip(){return X(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){Z(this,T.MEDIA_IS_PIP,e);}handleClick(){let e=this.mediaIsPip?F.MEDIA_EXIT_PIP_REQUEST:F.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:true,bubbles:true}));}};jr.getSlotTemplateHTML=cv;jr.getTooltipContentHTML=uv;A.customElements.get("media-pip-button")||A.customElements.define("media-pip-button",jr);var hv=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Bs=(s,e,t)=>(hv(s,e,"read from private field"),t?t.call(s):e.get(s)),fv=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},wi,Dd={RATES:"rates"},kd=[1,1.2,1.5,1.7,2],rs=1;function mv(s){return `
|
|
969
|
-
<style>
|
|
970
|
-
:host {
|
|
971
|
-
min-width: 5ch;
|
|
972
|
-
padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
|
|
973
|
-
}
|
|
974
|
-
</style>
|
|
975
|
-
<slot name="icon">${s.mediaplaybackrate||rs}x</slot>
|
|
976
|
-
`}function gv(){return w("Playback rate")}var zr=class extends ve{constructor(){var e;super(),fv(this,wi,new Li(this,Dd.RATES,{defaultValue:kd})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:rs}x`;}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Dd.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===Dd.RATES&&(Bs(this,wi).value=i),e===T.MEDIA_PLAYBACK_RATE){let r=i?+i:Number.NaN,n=Number.isNaN(r)?rs:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",w("Playback rate {playbackRate}",{playbackRate:n}));}}get rates(){return Bs(this,wi)}set rates(e){e?Array.isArray(e)?Bs(this,wi).value=e.join(" "):typeof e=="string"&&(Bs(this,wi).value=e):Bs(this,wi).value="";}get mediaPlaybackRate(){return ae(this,T.MEDIA_PLAYBACK_RATE,rs)}set mediaPlaybackRate(e){he(this,T.MEDIA_PLAYBACK_RATE,e);}handleClick(){var e,t;let i=Array.from(Bs(this,wi).values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:rs,n=new A.CustomEvent(F.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:r});this.dispatchEvent(n);}};wi=new WeakMap;zr.getSlotTemplateHTML=mv;zr.getTooltipContentHTML=gv;A.customElements.get("media-playback-rate-button")||A.customElements.define("media-playback-rate-button",zr);var pv=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
977
|
-
<path d="m6 21 15-9L6 3v18Z"/>
|
|
978
|
-
</svg>`,Ev=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
979
|
-
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
980
|
-
</svg>`;function vv(s){return `
|
|
981
|
-
<style>
|
|
982
|
-
:host([${T.MEDIA_PAUSED}]) slot[name=pause],
|
|
983
|
-
:host(:not([${T.MEDIA_PAUSED}])) slot[name=play] {
|
|
984
|
-
display: none !important;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
:host([${T.MEDIA_PAUSED}]) slot[name=tooltip-pause],
|
|
988
|
-
:host(:not([${T.MEDIA_PAUSED}])) slot[name=tooltip-play] {
|
|
989
|
-
display: none;
|
|
990
|
-
}
|
|
991
|
-
</style>
|
|
992
|
-
|
|
993
|
-
<slot name="icon">
|
|
994
|
-
<slot name="play">${pv}</slot>
|
|
995
|
-
<slot name="pause">${Ev}</slot>
|
|
996
|
-
</slot>
|
|
997
|
-
`}function Tv(){return `
|
|
998
|
-
<slot name="tooltip-play">${w("Play")}</slot>
|
|
999
|
-
<slot name="tooltip-pause">${w("Pause")}</slot>
|
|
1000
|
-
`}var um=s=>{let e=s.mediaPaused?w("play"):w("pause");s.setAttribute("aria-label",e);},Qr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),um(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===T.MEDIA_PAUSED||e===T.MEDIA_LANG)&&um(this);}get mediaPaused(){return X(this,T.MEDIA_PAUSED)}set mediaPaused(e){Z(this,T.MEDIA_PAUSED,e);}handleClick(){let e=this.mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:true,bubbles:true}));}};Qr.getSlotTemplateHTML=vv;Qr.getTooltipContentHTML=Tv;A.customElements.get("media-play-button")||A.customElements.define("media-play-button",Qr);var Qt={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"};function yv(s){return `
|
|
1001
|
-
<style>
|
|
1002
|
-
:host {
|
|
1003
|
-
pointer-events: none;
|
|
1004
|
-
display: var(--media-poster-image-display, inline-block);
|
|
1005
|
-
box-sizing: border-box;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
img {
|
|
1009
|
-
max-width: 100%;
|
|
1010
|
-
max-height: 100%;
|
|
1011
|
-
min-width: 100%;
|
|
1012
|
-
min-height: 100%;
|
|
1013
|
-
background-repeat: no-repeat;
|
|
1014
|
-
background-position: var(--media-poster-image-background-position, var(--media-object-position, center));
|
|
1015
|
-
background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));
|
|
1016
|
-
object-fit: var(--media-object-fit, contain);
|
|
1017
|
-
object-position: var(--media-object-position, center);
|
|
1018
|
-
}
|
|
1019
|
-
</style>
|
|
1020
|
-
|
|
1021
|
-
<img part="poster img" aria-hidden="true" id="image"/>
|
|
1022
|
-
`}var Sv=s=>{s.style.removeProperty("background-image");},bv=(s,e)=>{s.style["background-image"]=`url('${e}')`;},Xr=class extends A.HTMLElement{static get observedAttributes(){return [Qt.PLACEHOLDER_SRC,Qt.SRC]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}this.image=this.shadowRoot.querySelector("#image");}attributeChangedCallback(e,t,i){e===Qt.SRC&&(i==null?this.image.removeAttribute(Qt.SRC):this.image.setAttribute(Qt.SRC,i)),e===Qt.PLACEHOLDER_SRC&&(i==null?Sv(this.image):bv(this.image,i));}get placeholderSrc(){return te(this,Qt.PLACEHOLDER_SRC)}set placeholderSrc(e){ie(this,Qt.SRC,e);}get src(){return te(this,Qt.SRC)}set src(e){ie(this,Qt.SRC,e);}};Xr.shadowRootOptions={mode:"open"};Xr.getTemplateHTML=yv;A.customElements.get("media-poster-image")||A.customElements.define("media-poster-image",Xr);var hm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Av=(s,e,t)=>(hm(s,e,"read from private field"),t?t.call(s):e.get(s)),_v=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Iv=(s,e,t,i)=>(hm(s,e,"write to private field"),e.set(s,t),t),Ya,Cd=class extends dt{constructor(){super(),_v(this,Ya,void 0),Iv(this,Ya,this.shadowRoot.querySelector("slot"));}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_LANG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===T.MEDIA_PREVIEW_CHAPTER||e===T.MEDIA_LANG)&&i!==t&&i!=null)if(Av(this,Ya).textContent=i,i!==""){let r=w("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",r);}else this.removeAttribute("aria-valuetext");}get mediaPreviewChapter(){return te(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ie(this,T.MEDIA_PREVIEW_CHAPTER,e);}};Ya=new WeakMap;A.customElements.get("media-preview-chapter-display")||A.customElements.define("media-preview-chapter-display",Cd);var fm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ja=(s,e,t)=>(fm(s,e,"read from private field"),t?t.call(s):e.get(s)),Lv=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},za=(s,e,t,i)=>(fm(s,e,"write to private field"),e.set(s,t),t),Xt;function xv(s){return `
|
|
1023
|
-
<style>
|
|
1024
|
-
:host {
|
|
1025
|
-
box-sizing: border-box;
|
|
1026
|
-
display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block));
|
|
1027
|
-
overflow: hidden;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
img {
|
|
1031
|
-
display: none;
|
|
1032
|
-
position: relative;
|
|
1033
|
-
}
|
|
1034
|
-
</style>
|
|
1035
|
-
<img crossorigin loading="eager" decoding="async">
|
|
1036
|
-
`}var $s=class extends A.HTMLElement{constructor(){if(super(),Lv(this,Xt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [re.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(re.MEDIA_CONTROLLER);r&&(za(this,Xt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=ja(this,Xt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=ja(this,Xt))==null?void 0:e.unassociateElement)==null||t.call(e,this),za(this,Xt,null);}attributeChangedCallback(e,t,i){var r,n,a,o,d;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===re.MEDIA_CONTROLLER&&(t&&((n=(r=ja(this,Xt))==null?void 0:r.unassociateElement)==null||n.call(r,this),za(this,Xt,null)),i&&this.isConnected&&(za(this,Xt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ja(this,Xt))==null?void 0:o.associateElement)==null||d.call(o,this)));}get mediaPreviewImage(){return te(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ie(this,T.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewCoords(){let e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "));}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[i,r,n,a]=e,o=t.split("#")[0],d=getComputedStyle(this),{maxWidth:l,maxHeight:c,minWidth:u,minHeight:h}=d,f=Math.min(parseInt(l)/n,parseInt(c)/a),m=Math.max(parseInt(u)/n,parseInt(h)/a),E=f<1,p=E?f:m>1?m:1,{style:v}=ye(this.shadowRoot,":host"),S=ye(this.shadowRoot,"img").style,y=this.shadowRoot.querySelector("img"),b=E?"min":"max";v.setProperty(`${b}-width`,"initial","important"),v.setProperty(`${b}-height`,"initial","important"),v.width=`${n*p}px`,v.height=`${a*p}px`;let L=()=>{S.width=`${this.imgWidth*p}px`,S.height=`${this.imgHeight*p}px`,S.display="block";};y.src!==o&&(y.onload=()=>{this.imgWidth=y.naturalWidth,this.imgHeight=y.naturalHeight,L();},y.src=o,L()),L(),S.transform=`translate(-${i*p}px, -${r*p}px)`;}};Xt=new WeakMap;$s.shadowRootOptions={mode:"open"};$s.getTemplateHTML=xv;A.customElements.get("media-preview-thumbnail")||A.customElements.define("media-preview-thumbnail",$s);var Qa=$s;var gm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},mm=(s,e,t)=>(gm(s,e,"read from private field"),t?t.call(s):e.get(s)),Rv=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Dv=(s,e,t,i)=>(gm(s,e,"write to private field"),e.set(s,t),t),Zr,Md=class extends dt{constructor(){super(),Rv(this,Zr,void 0),Dv(this,Zr,this.shadowRoot.querySelector("slot")),mm(this,Zr).textContent=Ct(0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_PREVIEW_TIME&&i!=null&&(mm(this,Zr).textContent=Ct(parseFloat(i)));}get mediaPreviewTime(){return ae(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){he(this,T.MEDIA_PREVIEW_TIME,e);}};Zr=new WeakMap;A.customElements.get("media-preview-time-display")||A.customElements.define("media-preview-time-display",Md);var Gs={SEEK_OFFSET:"seekoffset"},wd=30,kv=s=>`
|
|
1037
|
-
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1038
|
-
<defs>
|
|
1039
|
-
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
1040
|
-
</defs>
|
|
1041
|
-
<text class="text value" transform="translate(2.18 19.87)">${s}</text>
|
|
1042
|
-
<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"/>
|
|
1043
|
-
</svg>`;function Cv(s,e){return `
|
|
1044
|
-
<slot name="icon">${kv(e.seekOffset)}</slot>
|
|
1045
|
-
`}function Mv(){return w("Seek backward")}var wv=0,Jr=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_CURRENT_TIME,Gs.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=ae(this,Gs.SEEK_OFFSET,wd);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===Gs.SEEK_OFFSET&&(this.seekOffset=ae(this,Gs.SEEK_OFFSET,wd));}get seekOffset(){return ae(this,Gs.SEEK_OFFSET,wd)}set seekOffset(e){he(this,Gs.SEEK_OFFSET,e),this.setAttribute("aria-label",w("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),ta(ia(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return ae(this,T.MEDIA_CURRENT_TIME,wv)}set mediaCurrentTime(e){he(this,T.MEDIA_CURRENT_TIME,e);}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};Jr.getSlotTemplateHTML=Cv;Jr.getTooltipContentHTML=Mv;A.customElements.get("media-seek-backward-button")||A.customElements.define("media-seek-backward-button",Jr);var Hs={SEEK_OFFSET:"seekoffset"},Pd=30,Pv=s=>`
|
|
1046
|
-
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1047
|
-
<defs>
|
|
1048
|
-
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
1049
|
-
</defs>
|
|
1050
|
-
<text class="text value" transform="translate(8.9 19.87)">${s}</text>
|
|
1051
|
-
<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"/>
|
|
1052
|
-
</svg>`;function Ov(s,e){return `
|
|
1053
|
-
<slot name="icon">${Pv(e.seekOffset)}</slot>
|
|
1054
|
-
`}function Nv(){return w("Seek forward")}var Fv=0,en=class extends ve{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_CURRENT_TIME,Hs.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=ae(this,Hs.SEEK_OFFSET,Pd);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===Hs.SEEK_OFFSET&&(this.seekOffset=ae(this,Hs.SEEK_OFFSET,Pd));}get seekOffset(){return ae(this,Hs.SEEK_OFFSET,Pd)}set seekOffset(e){he(this,Hs.SEEK_OFFSET,e),this.setAttribute("aria-label",w("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),ta(ia(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return ae(this,T.MEDIA_CURRENT_TIME,Fv)}set mediaCurrentTime(e){he(this,T.MEDIA_CURRENT_TIME,e);}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};en.getSlotTemplateHTML=Ov;en.getTooltipContentHTML=Nv;A.customElements.get("media-seek-forward-button")||A.customElements.define("media-seek-forward-button",en);var vm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Od=(s,e,t)=>(vm(s,e,"read from private field"),t?t.call(s):e.get(s)),Uv=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Bv=(s,e,t,i)=>(vm(s,e,"write to private field"),e.set(s,t),t),Vs,ns={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},pm=[...Object.values(ns),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],Em=["Enter"," "],$v=" / ",Nd=(s,{timesSep:e=$v}={})=>{var t,i;let r=(t=s.mediaCurrentTime)!=null?t:0,[,n]=(i=s.mediaSeekable)!=null?i:[],a=0;Number.isFinite(s.mediaDuration)?a=s.mediaDuration:Number.isFinite(n)&&(a=n);let o=s.remaining?Ct(0-(a-r)):Ct(r);return s.showDuration?`${o}${e}${Ct(a)}`:o},Gv="video not loaded, unknown time.",Hv=s=>{var e;let t=s.mediaCurrentTime,[,i]=(e=s.mediaSeekable)!=null?e:[],r=null;if(Number.isFinite(s.mediaDuration)?r=s.mediaDuration:Number.isFinite(i)&&(r=i),t==null||r===null){s.setAttribute("aria-valuetext",Gv);return}let n=s.remaining?Wi(0-(r-t)):Wi(t);if(!s.showDuration){s.setAttribute("aria-valuetext",n);return}let a=Wi(r),o=`${n} of ${a}`;s.setAttribute("aria-valuetext",o);};function Vv(s,e){return `
|
|
1055
|
-
<slot>${Nd(e)}</slot>
|
|
1056
|
-
`}var Xa=class extends dt{constructor(){super(),Uv(this,Vs,void 0),Bv(this,Vs,this.shadowRoot.querySelector("slot")),Od(this,Vs).innerHTML=`${Nd(this)}`;}static get observedAttributes(){return [...super.observedAttributes,...pm,"disabled"]}connectedCallback(){let{style:e}=ye(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-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",w("playback time"));let t=i=>{let{key:r}=i;if(!Em.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay();};this.addEventListener("keydown",i=>{let{metaKey:r,altKey:n,key:a}=i;if(r||n||!Em.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,i){pm.includes(e)?this.update():e==="disabled"&&i!==t&&(i==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,i);}enable(){this.tabIndex=0;}disable(){this.tabIndex=-1;}get remaining(){return X(this,ns.REMAINING)}set remaining(e){Z(this,ns.REMAINING,e);}get showDuration(){return X(this,ns.SHOW_DURATION)}set showDuration(e){Z(this,ns.SHOW_DURATION,e);}get noToggle(){return X(this,ns.NO_TOGGLE)}set noToggle(e){Z(this,ns.NO_TOGGLE,e);}get mediaDuration(){return ae(this,T.MEDIA_DURATION)}set mediaDuration(e){he(this,T.MEDIA_DURATION,e);}get mediaCurrentTime(){return ae(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){he(this,T.MEDIA_CURRENT_TIME,e);}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"));}update(){let e=Nd(this);Hv(this),e!==Od(this,Vs).innerHTML&&(Od(this,Vs).innerHTML=e);}};Vs=new WeakMap;Xa.getSlotTemplateHTML=Vv;A.customElements.get("media-time-display")||A.customElements.define("media-time-display",Xa);var Tm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},je=(s,e,t)=>(Tm(s,e,"read from private field"),e.get(s)),Zt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Tt=(s,e,t,i)=>(Tm(s,e,"write to private field"),e.set(s,t),t),Kv=(s,e,t,i)=>({set _(r){Tt(s,e,r);},get _(){return je(s,e)}}),Ks,Za,Ws,tn,Ja,eo,to,qs,as,io,so=class{constructor(e,t,i){Zt(this,Ks,void 0),Zt(this,Za,void 0),Zt(this,Ws,void 0),Zt(this,tn,void 0),Zt(this,Ja,void 0),Zt(this,eo,void 0),Zt(this,to,void 0),Zt(this,qs,void 0),Zt(this,as,0),Zt(this,io,(r=performance.now())=>{Tt(this,as,requestAnimationFrame(je(this,io))),Tt(this,tn,performance.now()-je(this,Ws));let n=1e3/this.fps;if(je(this,tn)>n){Tt(this,Ws,r-je(this,tn)%n);let a=1e3/((r-je(this,Za))/++Kv(this,Ja)._),o=(r-je(this,eo))/1e3/this.duration,d=je(this,to)+o*this.playbackRate;d-je(this,Ks).valueAsNumber>0?Tt(this,qs,this.playbackRate/this.duration/a):(Tt(this,qs,.995*je(this,qs)),d=je(this,Ks).valueAsNumber+je(this,qs)),this.callback(d);}}),Tt(this,Ks,e),this.callback=t,this.fps=i;}start(){je(this,as)===0&&(Tt(this,Ws,performance.now()),Tt(this,Za,je(this,Ws)),Tt(this,Ja,0),je(this,io).call(this));}stop(){je(this,as)!==0&&(cancelAnimationFrame(je(this,as)),Tt(this,as,0));}update({start:e,duration:t,playbackRate:i}){let r=e-je(this,Ks).valueAsNumber,n=Math.abs(t-this.duration);(r>0||r<-0.03||n>=.5)&&this.callback(e),Tt(this,to,e),Tt(this,eo,performance.now()),this.duration=t,this.playbackRate=i;}};Ks=new WeakMap;Za=new WeakMap;Ws=new WeakMap;tn=new WeakMap;Ja=new WeakMap;eo=new WeakMap;to=new WeakMap;qs=new WeakMap;as=new WeakMap;io=new WeakMap;var $d=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ve=(s,e,t)=>($d(s,e,"read from private field"),t?t.call(s):e.get(s)),ze=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Jt=(s,e,t,i)=>($d(s,e,"write to private field"),e.set(s,t),t),rt=(s,e,t)=>($d(s,e,"access private method"),t),Ys,os,ao,rn,oo,no,nn,an,js,zs,sn,Gd,ym,Fd,lo,Hd,co,Vd,uo,Kd,Ud,Sm,on,ho,Bd,bm,Wv="video not loaded, unknown time.",qv=s=>{let e=s.range,t=Wi(+Am(s)),i=Wi(+s.mediaSeekableEnd),r=t&&i?`${t} of ${i}`:Wv;e.setAttribute("aria-valuetext",r);};function Yv(s){return `
|
|
1057
|
-
${qt.getTemplateHTML(s)}
|
|
1058
|
-
<style>
|
|
1059
|
-
:host {
|
|
1060
|
-
--media-box-border-radius: 4px;
|
|
1061
|
-
--media-box-padding-left: 10px;
|
|
1062
|
-
--media-box-padding-right: 10px;
|
|
1063
|
-
--media-preview-border-radius: var(--media-box-border-radius);
|
|
1064
|
-
--media-box-arrow-offset: var(--media-box-border-radius);
|
|
1065
|
-
--_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
|
|
1066
|
-
--_preview-background: var(--media-preview-background, var(--_control-background));
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
contain: layout;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
#buffered {
|
|
1073
|
-
background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));
|
|
1074
|
-
position: absolute;
|
|
1075
|
-
height: 100%;
|
|
1076
|
-
will-change: width;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
#preview-rail,
|
|
1080
|
-
#current-rail {
|
|
1081
|
-
width: 100%;
|
|
1082
|
-
position: absolute;
|
|
1083
|
-
left: 0;
|
|
1084
|
-
bottom: 100%;
|
|
1085
|
-
pointer-events: none;
|
|
1086
|
-
will-change: transform;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
[part~="box"] {
|
|
1090
|
-
width: min-content;
|
|
1091
|
-
|
|
1092
|
-
position: absolute;
|
|
1093
|
-
bottom: 100%;
|
|
1094
|
-
flex-direction: column;
|
|
1095
|
-
align-items: center;
|
|
1096
|
-
transform: translateX(-50%);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
[part~="current-box"] {
|
|
1100
|
-
display: var(--media-current-box-display, var(--media-box-display, flex));
|
|
1101
|
-
margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px));
|
|
1102
|
-
visibility: hidden;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
[part~="preview-box"] {
|
|
1106
|
-
display: var(--media-preview-box-display, var(--media-box-display, flex));
|
|
1107
|
-
margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px));
|
|
1108
|
-
transition-property: var(--media-preview-transition-property, visibility, opacity);
|
|
1109
|
-
transition-duration: var(--media-preview-transition-duration-out, .25s);
|
|
1110
|
-
transition-delay: var(--media-preview-transition-delay-out, 0s);
|
|
1111
|
-
visibility: hidden;
|
|
1112
|
-
opacity: 0;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
:host(:is([${T.MEDIA_PREVIEW_IMAGE}], [${T.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
|
|
1116
|
-
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
1117
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1118
|
-
visibility: visible;
|
|
1119
|
-
opacity: 1;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
@media (hover: hover) {
|
|
1123
|
-
:host(:is([${T.MEDIA_PREVIEW_IMAGE}], [${T.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
|
|
1124
|
-
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
1125
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1126
|
-
visibility: visible;
|
|
1127
|
-
opacity: 1;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
media-preview-thumbnail,
|
|
1132
|
-
::slotted(media-preview-thumbnail) {
|
|
1133
|
-
visibility: hidden;
|
|
1134
|
-
|
|
1135
|
-
transition: visibility 0s .25s;
|
|
1136
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
1137
|
-
background: var(--media-preview-thumbnail-background, var(--_preview-background));
|
|
1138
|
-
box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));
|
|
1139
|
-
max-width: var(--media-preview-thumbnail-max-width, 180px);
|
|
1140
|
-
max-height: var(--media-preview-thumbnail-max-height, 160px);
|
|
1141
|
-
min-width: var(--media-preview-thumbnail-min-width, 120px);
|
|
1142
|
-
min-height: var(--media-preview-thumbnail-min-height, 80px);
|
|
1143
|
-
border: var(--media-preview-thumbnail-border);
|
|
1144
|
-
border-radius: var(--media-preview-thumbnail-border-radius,
|
|
1145
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
|
|
1149
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
|
|
1150
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1151
|
-
visibility: visible;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
@media (hover: hover) {
|
|
1155
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
|
|
1156
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
|
|
1157
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1158
|
-
visibility: visible;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
:host([${T.MEDIA_PREVIEW_TIME}]:hover) {
|
|
1162
|
-
--media-time-range-hover-display: block;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
media-preview-chapter-display,
|
|
1167
|
-
::slotted(media-preview-chapter-display) {
|
|
1168
|
-
font-size: var(--media-font-size, 13px);
|
|
1169
|
-
line-height: 17px;
|
|
1170
|
-
min-width: 0;
|
|
1171
|
-
visibility: hidden;
|
|
1172
|
-
|
|
1173
|
-
transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s;
|
|
1174
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
1175
|
-
background: var(--media-preview-chapter-background, var(--_preview-background));
|
|
1176
|
-
border-radius: var(--media-preview-chapter-border-radius,
|
|
1177
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius)
|
|
1178
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
1179
|
-
padding: var(--media-preview-chapter-padding, 3.5px 9px);
|
|
1180
|
-
margin: var(--media-preview-chapter-margin, 0 0 5px);
|
|
1181
|
-
text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
|
|
1185
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
|
|
1186
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1187
|
-
border-radius: var(--media-preview-chapter-border-radius, 0);
|
|
1188
|
-
padding: var(--media-preview-chapter-padding, 3.5px 9px 0);
|
|
1189
|
-
margin: var(--media-preview-chapter-margin, 0);
|
|
1190
|
-
min-width: 100%;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
media-preview-chapter-display[${T.MEDIA_PREVIEW_CHAPTER}],
|
|
1194
|
-
::slotted(media-preview-chapter-display[${T.MEDIA_PREVIEW_CHAPTER}]) {
|
|
1195
|
-
visibility: visible;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
media-preview-chapter-display:not([aria-valuetext]),
|
|
1199
|
-
::slotted(media-preview-chapter-display:not([aria-valuetext])) {
|
|
1200
|
-
display: none;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
media-preview-time-display,
|
|
1204
|
-
::slotted(media-preview-time-display),
|
|
1205
|
-
media-time-display,
|
|
1206
|
-
::slotted(media-time-display) {
|
|
1207
|
-
font-size: var(--media-font-size, 13px);
|
|
1208
|
-
line-height: 17px;
|
|
1209
|
-
min-width: 0;
|
|
1210
|
-
|
|
1211
|
-
transition: min-width 0s, border-radius 0s;
|
|
1212
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
1213
|
-
background: var(--media-preview-time-background, var(--_preview-background));
|
|
1214
|
-
border-radius: var(--media-preview-time-border-radius,
|
|
1215
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius)
|
|
1216
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
1217
|
-
padding: var(--media-preview-time-padding, 3.5px 9px);
|
|
1218
|
-
margin: var(--media-preview-time-margin, 0);
|
|
1219
|
-
text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
1220
|
-
transform: translateX(min(
|
|
1221
|
-
max(calc(50% - var(--_box-width) / 2),
|
|
1222
|
-
calc(var(--_box-shift, 0))),
|
|
1223
|
-
calc(var(--_box-width) / 2 - 50%)
|
|
1224
|
-
));
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
|
|
1228
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
|
|
1229
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1230
|
-
border-radius: var(--media-preview-time-border-radius,
|
|
1231
|
-
0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
1232
|
-
min-width: 100%;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
:host([${T.MEDIA_PREVIEW_TIME}]:hover) {
|
|
1236
|
-
--media-time-range-hover-display: block;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
[part~="arrow"],
|
|
1240
|
-
::slotted([part~="arrow"]) {
|
|
1241
|
-
display: var(--media-box-arrow-display, inline-block);
|
|
1242
|
-
transform: translateX(min(
|
|
1243
|
-
max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)),
|
|
1244
|
-
calc(var(--_box-shift, 0))),
|
|
1245
|
-
calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset))
|
|
1246
|
-
));
|
|
1247
|
-
|
|
1248
|
-
border-color: transparent;
|
|
1249
|
-
border-top-color: var(--media-box-arrow-background, var(--_control-background));
|
|
1250
|
-
border-width: var(--media-box-arrow-border-width,
|
|
1251
|
-
var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0);
|
|
1252
|
-
border-style: solid;
|
|
1253
|
-
justify-content: center;
|
|
1254
|
-
height: 0;
|
|
1255
|
-
}
|
|
1256
|
-
</style>
|
|
1257
|
-
<div id="preview-rail">
|
|
1258
|
-
<slot name="preview" part="box preview-box">
|
|
1259
|
-
<media-preview-thumbnail>
|
|
1260
|
-
<template shadowrootmode="${Qa.shadowRootOptions.mode}">
|
|
1261
|
-
${Qa.getTemplateHTML({})}
|
|
1262
|
-
</template>
|
|
1263
|
-
</media-preview-thumbnail>
|
|
1264
|
-
<media-preview-chapter-display></media-preview-chapter-display>
|
|
1265
|
-
<media-preview-time-display></media-preview-time-display>
|
|
1266
|
-
<slot name="preview-arrow"><div part="arrow"></div></slot>
|
|
1267
|
-
</slot>
|
|
1268
|
-
</div>
|
|
1269
|
-
<div id="current-rail">
|
|
1270
|
-
<slot name="current" part="box current-box">
|
|
1271
|
-
|
|
1272
|
-
</slot>
|
|
1273
|
-
</div>
|
|
1274
|
-
`}var ro=(s,e=s.mediaCurrentTime)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;if(Number.isNaN(i))return 0;let r=(e-t)/(i-t);return Math.max(0,Math.min(r,1))},Am=(s,e=s.range.valueAsNumber)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;return Number.isNaN(i)?0:e*(i-t)+t},ln=class extends qt{constructor(){super(),ze(this,zs),ze(this,Gd),ze(this,lo),ze(this,co),ze(this,uo),ze(this,Ud),ze(this,on),ze(this,Bd),ze(this,Ys,void 0),ze(this,os,void 0),ze(this,ao,void 0),ze(this,rn,void 0),ze(this,oo,void 0),ze(this,no,void 0),ze(this,nn,void 0),ze(this,an,void 0),ze(this,js,void 0),ze(this,Fd,i=>{this.dragging||(_s(i)&&(this.range.valueAsNumber=i),this.updateBar());}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),Jt(this,ao,this.shadowRoot.querySelectorAll('[part~="box"]')),Jt(this,oo,this.shadowRoot.querySelector('[part~="preview-box"]')),Jt(this,no,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);Jt(this,nn,parseInt(t.getPropertyValue("--media-box-padding-left"))),Jt(this,an,parseInt(t.getPropertyValue("--media-box-padding-right"))),Jt(this,os,new so(this.range,Ve(this,Fd),60));}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",w("seek")),rt(this,zs,sn).call(this),Jt(this,Ys,this.getRootNode()),(e=Ve(this,Ys))==null||e.addEventListener("transitionstart",this);}disconnectedCallback(){var e;super.disconnectedCallback(),rt(this,zs,sn).call(this),(e=Ve(this,Ys))==null||e.removeEventListener("transitionstart",this),Jt(this,Ys,null);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(Ve(this,os).update({start:ro(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),rt(this,zs,sn).call(this),qv(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Ve(this,js),this.updateBar()));}get mediaChaptersCues(){return Ve(this,js)}set mediaChaptersCues(e){var t;Jt(this,js,e),this.updateSegments((t=Ve(this,js))==null?void 0:t.map(i=>({start:ro(this,i.startTime),end:ro(this,i.endTime)})));}get mediaPaused(){return X(this,T.MEDIA_PAUSED)}set mediaPaused(e){Z(this,T.MEDIA_PAUSED,e);}get mediaLoading(){return X(this,T.MEDIA_LOADING)}set mediaLoading(e){Z(this,T.MEDIA_LOADING,e);}get mediaDuration(){return ae(this,T.MEDIA_DURATION)}set mediaDuration(e){he(this,T.MEDIA_DURATION,e);}get mediaCurrentTime(){return ae(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){he(this,T.MEDIA_CURRENT_TIME,e);}get mediaPlaybackRate(){return ae(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){he(this,T.MEDIA_PLAYBACK_RATE,e);}get mediaBuffered(){let e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}let t=e.map(i=>i.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t);}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.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 te(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ie(this,T.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewTime(){return ae(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){he(this,T.MEDIA_PREVIEW_TIME,e);}get mediaEnded(){return X(this,T.MEDIA_ENDED)}set mediaEnded(e){Z(this,T.MEDIA_ENDED,e);}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox();}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let i;if(this.mediaEnded)i=1;else {let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,d])=>o<=n&&n<=d))!=null?e:[];i=ro(this,a);}let{style:r}=ye(this.shadowRoot,"#buffered");r.setProperty("width",`${i*100}%`);}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=ye(this.shadowRoot,"#current-rail"),i=ye(this.shadowRoot,'[part~="current-box"]'),r=rt(this,lo,Hd).call(this,Ve(this,no)),n=rt(this,co,Vd).call(this,r,this.range.valueAsNumber),a=rt(this,uo,Kd).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),i.style.setProperty("--_box-shift",`${a}`),i.style.setProperty("--_box-width",`${r.box.width}px`),i.style.setProperty("visibility","initial");}handleEvent(e){switch(super.handleEvent(e),e.type){case "input":rt(this,Bd,bm).call(this);break;case "pointermove":rt(this,Ud,Sm).call(this,e);break;case "pointerup":case "pointerleave":rt(this,on,ho).call(this,null);break;case "transitionstart":at(e.target,this)&&setTimeout(()=>rt(this,zs,sn).call(this),0);break}}};Ys=new WeakMap;os=new WeakMap;ao=new WeakMap;rn=new WeakMap;oo=new WeakMap;no=new WeakMap;nn=new WeakMap;an=new WeakMap;js=new WeakMap;zs=new WeakSet;sn=function(){rt(this,Gd,ym).call(this)?Ve(this,os).start():Ve(this,os).stop();};Gd=new WeakSet;ym=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&sa(this)};Fd=new WeakMap;lo=new WeakSet;Hd=function(s){var e;let i=((e=this.getAttribute("bounds")?Ht(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=s.offsetWidth,a=-(r.left-i.left-n/2),o=i.right-r.left-n/2;return {box:{width:n,min:a,max:o},bounds:i,range:r}};co=new WeakSet;Vd=function(s,e){let t=`${e*100}%`,{width:i,min:r,max:n}=s.box;if(!i)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + 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};uo=new WeakSet;Kd=function(s,e){let{width:t,min:i,max:r}=s.box,n=e*s.range.width;if(n<i+Ve(this,nn)){let a=s.range.left-s.bounds.left-Ve(this,nn);return `${n-t/2+a}px`}if(n>r-Ve(this,an)){let a=s.bounds.right-s.range.right-Ve(this,an);return `${n+t/2-a-s.range.width}px`}return 0};Ud=new WeakSet;Sm=function(s){let e=[...Ve(this,ao)].some(c=>s.composedPath().includes(c));if(!this.dragging&&(e||!s.composedPath().includes(this))){rt(this,on,ho).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let i=ye(this.shadowRoot,"#preview-rail"),r=ye(this.shadowRoot,'[part~="preview-box"]'),n=rt(this,lo,Hd).call(this,Ve(this,oo)),a=(s.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=rt(this,co,Vd).call(this,n,a),d=rt(this,uo,Kd).call(this,n,a);i.style.transform=`translateX(${o})`,i.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${d}`),r.style.setProperty("--_box-width",`${n.box.width}px`);let l=Math.round(Ve(this,rn))-Math.round(a*t);Math.abs(l)<1&&a>.01&&a<.99||(Jt(this,rn,a*t),rt(this,on,ho).call(this,Ve(this,rn)));};on=new WeakSet;ho=function(s){this.dispatchEvent(new A.CustomEvent(F.MEDIA_PREVIEW_REQUEST,{composed:true,bubbles:true,detail:s}));};Bd=new WeakSet;bm=function(){Ve(this,os).stop();let s=Am(this);this.dispatchEvent(new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:s}));};ln.shadowRootOptions={mode:"open"};ln.getTemplateHTML=Yv;A.customElements.get("media-time-range")||A.customElements.define("media-time-range",ln);var jv=1,zv=s=>s.mediaMuted?0:s.mediaVolume,Qv=s=>`${Math.round(s*100)}%`,Wd=class extends qt{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new A.CustomEvent(F.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);});}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",w("volume"));}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=zv(this),this.range.setAttribute("aria-valuetext",Qv(this.range.valueAsNumber)),this.updateBar());}get mediaVolume(){return ae(this,T.MEDIA_VOLUME,jv)}set mediaVolume(e){he(this,T.MEDIA_VOLUME,e);}get mediaMuted(){return X(this,T.MEDIA_MUTED)}set mediaMuted(e){Z(this,T.MEDIA_MUTED,e);}get mediaVolumeUnavailable(){return te(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ie(this,T.MEDIA_VOLUME_UNAVAILABLE,e);}};A.customElements.get("media-volume-range")||A.customElements.define("media-volume-range",Wd);function _m({anchor:s,floating:e,placement:t}){let i=Xv({anchor:s,floating:e}),{x:r,y:n}=Jv(i,t);return {x:r,y:n}}function Xv({anchor:s,floating:e}){return {anchor:Zv(s,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Zv(s,e){var t;let i=s.getBoundingClientRect(),r=(t=e?.getBoundingClientRect())!=null?t:{x:0,y:0};return {x:i.x-r.x,y:i.y-r.y,width:i.width,height:i.height}}function Jv({anchor:s,floating:e},t){let i=eT(t)==="x"?"y":"x",r=i==="y"?"height":"width",n=Im(t),a=s.x+s.width/2-e.width/2,o=s.y+s.height/2-e.height/2,d=s[r]/2-e[r]/2,l;switch(n){case "top":l={x:a,y:s.y-e.height};break;case "bottom":l={x:a,y:s.y+s.height};break;case "right":l={x:s.x+s.width,y:o};break;case "left":l={x:s.x-e.width,y:o};break;default:l={x:s.x,y:s.y};}switch(t.split("-")[1]){case "start":l[i]-=d;break;case "end":l[i]+=d;break}return l}function Im(s){return s.split("-")[0]}function eT(s){return ["top","bottom"].includes(Im(s))?"y":"x"}var Pi=class extends Event{constructor({action:e="auto",relatedTarget:t,...i}){super("invoke",i),this.action=e,this.relatedTarget=t;}},fo=class extends Event{constructor({newState:e,oldState:t,...i}){super("toggle",i),this.newState=e,this.oldState=t;}};var sc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},pe=(s,e,t)=>(sc(s,e,"read from private field"),t?t.call(s):e.get(s)),Ae=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},ei=(s,e,t,i)=>(sc(s,e,"write to private field"),e.set(s,t),t),xe=(s,e,t)=>(sc(s,e,"access private method"),t),ti,ds,Oi,mo,go,cs,un,qd,Lm,vo,po,Yd,jd,xm,zd,Rm,Qd,Dm,Qs,Xs,Zs,hn,To,rc,Xd,km,nc,Cm,Zd,Mm,ac,wm,Jd,Pm,ec,Om,dn,yo,tc,Nm,cn,So,Eo,ic;function ii({type:s,text:e,value:t,checked:i}){let r=Ce.createElement("media-chrome-menu-item");r.type=s,r.part.add("menu-item"),r.part.add(s),r.value=t,r.checked=i;let n=Ce.createElement("span");return n.textContent=e,r.append(n),r}function Pt(s,e){let t=s.querySelector(`:scope > [slot="${e}"]`);if(t?.nodeName=="SLOT"&&(t=t.assignedElements({flatten:true})[0]),t)return t=t.cloneNode(true),t;let i=s.shadowRoot.querySelector(`[name="${e}"] > svg`);return i?i.cloneNode(true):""}function tT(s){return `
|
|
1275
|
-
<style>
|
|
1276
|
-
:host {
|
|
1277
|
-
font: var(--media-font,
|
|
1278
|
-
var(--media-font-weight, normal)
|
|
1279
|
-
var(--media-font-size, 14px) /
|
|
1280
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
1281
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
1282
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
1283
|
-
--_menu-bg: rgb(20 20 30 / .8);
|
|
1284
|
-
background: var(--media-menu-background, var(--media-control-background, var(--media-secondary-color, var(--_menu-bg))));
|
|
1285
|
-
border-radius: var(--media-menu-border-radius);
|
|
1286
|
-
border: var(--media-menu-border, none);
|
|
1287
|
-
display: var(--media-menu-display, inline-flex);
|
|
1288
|
-
transition: var(--media-menu-transition-in,
|
|
1289
|
-
visibility 0s,
|
|
1290
|
-
opacity .2s ease-out,
|
|
1291
|
-
transform .15s ease-out,
|
|
1292
|
-
left .2s ease-in-out,
|
|
1293
|
-
min-width .2s ease-in-out,
|
|
1294
|
-
min-height .2s ease-in-out
|
|
1295
|
-
) !important;
|
|
1296
|
-
|
|
1297
|
-
visibility: var(--media-menu-visibility, visible);
|
|
1298
|
-
opacity: var(--media-menu-opacity, 1);
|
|
1299
|
-
max-height: var(--media-menu-max-height, var(--_menu-max-height, 300px));
|
|
1300
|
-
transform: var(--media-menu-transform-in, translateY(0) scale(1));
|
|
1301
|
-
flex-direction: column;
|
|
1302
|
-
|
|
1303
|
-
min-height: 0;
|
|
1304
|
-
position: relative;
|
|
1305
|
-
bottom: var(--_menu-bottom);
|
|
1306
|
-
box-sizing: border-box;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
@-moz-document url-prefix() {
|
|
1310
|
-
:host{
|
|
1311
|
-
--_menu-bg: rgb(20 20 30);
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
:host([hidden]) {
|
|
1316
|
-
transition: var(--media-menu-transition-out,
|
|
1317
|
-
visibility .15s ease-in,
|
|
1318
|
-
opacity .15s ease-in,
|
|
1319
|
-
transform .15s ease-in
|
|
1320
|
-
) !important;
|
|
1321
|
-
visibility: var(--media-menu-hidden-visibility, hidden);
|
|
1322
|
-
opacity: var(--media-menu-hidden-opacity, 0);
|
|
1323
|
-
max-height: var(--media-menu-hidden-max-height,
|
|
1324
|
-
var(--media-menu-max-height, var(--_menu-max-height, 300px)));
|
|
1325
|
-
transform: var(--media-menu-transform-out, translateY(2px) scale(.99));
|
|
1326
|
-
pointer-events: none;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
:host([slot="submenu"]) {
|
|
1330
|
-
background: none;
|
|
1331
|
-
width: 100%;
|
|
1332
|
-
min-height: 100%;
|
|
1333
|
-
position: absolute;
|
|
1334
|
-
bottom: 0;
|
|
1335
|
-
right: -100%;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
#container {
|
|
1339
|
-
display: flex;
|
|
1340
|
-
flex-direction: column;
|
|
1341
|
-
min-height: 0;
|
|
1342
|
-
transition: transform .2s ease-out;
|
|
1343
|
-
transform: translate(0, 0);
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
#container.has-expanded {
|
|
1347
|
-
transition: transform .2s ease-in;
|
|
1348
|
-
transform: translate(-100%, 0);
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
button {
|
|
1352
|
-
background: none;
|
|
1353
|
-
color: inherit;
|
|
1354
|
-
border: none;
|
|
1355
|
-
padding: 0;
|
|
1356
|
-
font: inherit;
|
|
1357
|
-
outline: inherit;
|
|
1358
|
-
display: inline-flex;
|
|
1359
|
-
align-items: center;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
slot[name="header"][hidden] {
|
|
1363
|
-
display: none;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
slot[name="header"] > *,
|
|
1367
|
-
slot[name="header"]::slotted(*) {
|
|
1368
|
-
padding: .4em .7em;
|
|
1369
|
-
border-bottom: 1px solid rgb(255 255 255 / .25);
|
|
1370
|
-
cursor: var(--media-cursor, default);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
slot[name="header"] > button[part~="back"],
|
|
1374
|
-
slot[name="header"]::slotted(button[part~="back"]) {
|
|
1375
|
-
cursor: var(--media-cursor, pointer);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
svg[part~="back"] {
|
|
1379
|
-
height: var(--media-menu-icon-height, var(--media-control-height, 24px));
|
|
1380
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
1381
|
-
display: block;
|
|
1382
|
-
margin-right: .5ch;
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
slot:not([name]) {
|
|
1386
|
-
gap: var(--media-menu-gap);
|
|
1387
|
-
flex-direction: var(--media-menu-flex-direction, column);
|
|
1388
|
-
overflow: var(--media-menu-overflow, hidden auto);
|
|
1389
|
-
display: flex;
|
|
1390
|
-
min-height: 0;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
:host([role="menu"]) slot:not([name]) {
|
|
1394
|
-
padding-block: .4em;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
slot:not([name])::slotted([role="menu"]) {
|
|
1398
|
-
background: none;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
media-chrome-menu-item > span {
|
|
1402
|
-
margin-right: .5ch;
|
|
1403
|
-
max-width: var(--media-menu-item-max-width);
|
|
1404
|
-
text-overflow: ellipsis;
|
|
1405
|
-
overflow: hidden;
|
|
1406
|
-
}
|
|
1407
|
-
</style>
|
|
1408
|
-
<style id="layout-row" media="width:0">
|
|
1409
|
-
|
|
1410
|
-
slot[name="header"] > *,
|
|
1411
|
-
slot[name="header"]::slotted(*) {
|
|
1412
|
-
padding: .4em .5em;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
slot:not([name]) {
|
|
1416
|
-
gap: var(--media-menu-gap, .25em);
|
|
1417
|
-
flex-direction: var(--media-menu-flex-direction, row);
|
|
1418
|
-
padding-inline: .5em;
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
media-chrome-menu-item {
|
|
1422
|
-
padding: .3em .5em;
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
media-chrome-menu-item[aria-checked="true"] {
|
|
1426
|
-
background: var(--media-menu-item-checked-background, rgb(255 255 255 / .2));
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
media-chrome-menu-item::part(checked-indicator) {
|
|
1431
|
-
display: var(--media-menu-item-checked-indicator-display, none);
|
|
1432
|
-
}
|
|
1433
|
-
</style>
|
|
1434
|
-
<div id="container">
|
|
1435
|
-
<slot name="header" hidden>
|
|
1436
|
-
<button part="back button" aria-label="Back to previous menu">
|
|
1437
|
-
<slot name="back-icon">
|
|
1438
|
-
<svg aria-hidden="true" viewBox="0 0 20 24" part="back indicator">
|
|
1439
|
-
<path d="m11.88 17.585.742-.669-4.2-4.665 4.2-4.666-.743-.669-4.803 5.335 4.803 5.334Z"/>
|
|
1440
|
-
</svg>
|
|
1441
|
-
</slot>
|
|
1442
|
-
<slot name="title"></slot>
|
|
1443
|
-
</button>
|
|
1444
|
-
</slot>
|
|
1445
|
-
<slot></slot>
|
|
1446
|
-
</div>
|
|
1447
|
-
<slot name="checked-indicator" hidden></slot>
|
|
1448
|
-
`}var ls={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},Qe=class extends A.HTMLElement{constructor(){if(super(),Ae(this,qd),Ae(this,po),Ae(this,jd),Ae(this,zd),Ae(this,Qd),Ae(this,Zs),Ae(this,To),Ae(this,Xd),Ae(this,nc),Ae(this,Zd),Ae(this,ac),Ae(this,Jd),Ae(this,ec),Ae(this,dn),Ae(this,tc),Ae(this,cn),Ae(this,Eo),Ae(this,ti,null),Ae(this,ds,null),Ae(this,Oi,null),Ae(this,mo,new Set),Ae(this,go,void 0),Ae(this,cs,false),Ae(this,un,null),Ae(this,vo,()=>{let e=pe(this,mo),t=new Set(this.items);for(let i of e)t.has(i)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:i}));for(let i of t)e.has(i)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:i}));ei(this,mo,t);}),Ae(this,Qs,()=>{xe(this,Zs,hn).call(this),xe(this,To,rc).call(this,false);}),Ae(this,Xs,()=>{xe(this,Zs,hn).call(this);}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),ei(this,go,new MutationObserver(pe(this,vo))),pe(this,go).observe(this.defaultSlot,{childList:true});}static get observedAttributes(){return [ls.DISABLED,ls.HIDDEN,ls.STYLE,ls.ANCHOR,re.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":xe(this,qd,Lm).call(this,e);break;case "invoke":xe(this,jd,xm).call(this,e);break;case "click":xe(this,Xd,km).call(this,e);break;case "toggle":xe(this,Zd,Mm).call(this,e);break;case "focusout":xe(this,Jd,Pm).call(this,e);break;case "keydown":xe(this,ec,Om).call(this,e);break}}connectedCallback(){var e,t;ei(this,un,Yl(this.shadowRoot,":host")),xe(this,po,Yd).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),ei(this,ti,ea(this)),(t=(e=pe(this,ti))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(hi(fn(this),pe(this,Qs)),hi(this,pe(this,Xs)));}disconnectedCallback(){var e,t;fi(fn(this),pe(this,Qs)),fi(this,pe(this,Xs)),this.disable(),(t=(e=pe(this,ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),ei(this,ti,null);}attributeChangedCallback(e,t,i){var r,n,a,o;e===ls.HIDDEN&&i!==t?(pe(this,cs)||ei(this,cs,true),this.hidden?xe(this,Qd,Dm).call(this):xe(this,zd,Rm).call(this),this.dispatchEvent(new fo({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:true}))):e===re.MEDIA_CONTROLLER?(t&&((n=(r=pe(this,ti))==null?void 0:r.unassociateElement)==null||n.call(r,this),ei(this,ti,null)),i&&this.isConnected&&(ei(this,ti,ea(this)),(o=(a=pe(this,ti))==null?void 0:a.associateElement)==null||o.call(a,this))):e===ls.DISABLED&&i!==t?i==null?this.enable():this.disable():e===ls.STYLE&&i!==t&&xe(this,po,Yd).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=qi(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:true}).filter(iT)}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(i=>i.value===e);t&&xe(this,Eo,ic).call(this,t);}focus(){if(ei(this,ds,_r()),this.items.length){xe(this,cn,So).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e?.focus();}handleSelect(e){var t;let i=xe(this,dn,yo).call(this,e);i&&(xe(this,Eo,ic).call(this,i,i.type==="checkbox"),pe(this,Oi)&&!this.hidden&&((t=pe(this,ds))==null||t.focus(),this.hidden=true));}get keysUsed(){return ["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,i;let{key:r}=e,n=this.items,a=(i=(t=xe(this,dn,yo).call(this,e))!=null?t:xe(this,tc,Nm).call(this))!=null?i:n[0],o=n.indexOf(a),d=Math.max(0,o);r==="ArrowDown"?d++:r==="ArrowUp"?d--:e.key==="Home"?d=0:e.key==="End"&&(d=n.length-1),d<0&&(d=n.length-1),d>n.length-1&&(d=0),xe(this,cn,So).call(this,n[d]),n[d].focus();}};ti=new WeakMap;ds=new WeakMap;Oi=new WeakMap;mo=new WeakMap;go=new WeakMap;cs=new WeakMap;un=new WeakMap;qd=new WeakSet;Lm=function(s){let e=s.target;for(let t of e.assignedNodes({flatten:true}))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||pe(this,vo).call(this);};vo=new WeakMap;po=new WeakSet;Yd=function(){var s;let e=this.shadowRoot.querySelector("#layout-row"),t=(s=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:s.trim();e.setAttribute("media",t==="row"?"":"width:0");};jd=new WeakSet;xm=function(s){ei(this,Oi,s.relatedTarget),at(this,s.relatedTarget)||(this.hidden=!this.hidden);};zd=new WeakSet;Rm=function(){var s;(s=pe(this,Oi))==null||s.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:true}),hi(fn(this),pe(this,Qs)),hi(this,pe(this,Xs));};Qd=new WeakSet;Dm=function(){var s;(s=pe(this,Oi))==null||s.setAttribute("aria-expanded","false"),fi(fn(this),pe(this,Qs)),fi(this,pe(this,Xs));};Qs=new WeakMap;Xs=new WeakMap;Zs=new WeakSet;hn=function(s){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=_m({anchor:this.anchorElement,floating:this,placement:"top-start"});s??(s=this.offsetWidth);let r=fn(this).getBoundingClientRect(),n=r.width-e-s,a=r.height-t-this.offsetHeight,{style:o}=pe(this,un);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);let d=getComputedStyle(this),c=o.getPropertyValue("--_menu-bottom")===d.bottom?a:parseFloat(d.bottom),u=r.height-c-parseFloat(d.marginBottom);this.style.setProperty("--_menu-max-height",`${u}px`);};To=new WeakSet;rc=function(s){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e?.querySelector('[role="menu"]'),{style:i}=pe(this,un);if(s||i.setProperty("--media-menu-transition-in","none"),t){let r=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${r}px`),xe(this,Zs,hn).call(this,n);}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),xe(this,Zs,hn).call(this);i.removeProperty("--media-menu-transition-in");};Xd=new WeakSet;km=function(s){var e;if(s.stopPropagation(),s.composedPath().includes(pe(this,nc,Cm))){(e=pe(this,ds))==null||e.focus(),this.hidden=true;return}let t=xe(this,dn,yo).call(this,s);!t||t.hasAttribute("disabled")||(xe(this,cn,So).call(this,t),this.handleSelect(s));};nc=new WeakSet;Cm=function(){var s;return (s=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:true}))==null?void 0:s.find(t=>t.matches('button[part~="back"]'))};Zd=new WeakSet;Mm=function(s){if(s.target===this)return;xe(this,ac,wm).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=s.target&&s.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Pi({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);xe(this,To,rc).call(this,true);};ac=new WeakSet;wm=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e);};Jd=new WeakSet;Pm=function(s){var e;at(this,s.relatedTarget)||(pe(this,cs)&&((e=pe(this,ds))==null||e.focus()),pe(this,Oi)&&pe(this,Oi)!==s.relatedTarget&&!this.hidden&&(this.hidden=true));};ec=new WeakSet;Om=function(s){var e,t,i,r,n;let{key:a,ctrlKey:o,altKey:d,metaKey:l}=s;if(!(o||d||l)&&this.keysUsed.includes(a))if(s.preventDefault(),s.stopPropagation(),a==="Tab"){if(pe(this,cs)){this.hidden=true;return}s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(i=this.nextElementSibling)==null?void 0:i.focus)==null||r.call(i),this.blur();}else a==="Escape"?((n=pe(this,ds))==null||n.focus(),pe(this,cs)&&(this.hidden=true)):a==="Enter"||a===" "?this.handleSelect(s):this.handleMove(s);};dn=new WeakSet;yo=function(s){return s.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};tc=new WeakSet;Nm=function(){return this.items.find(s=>s.tabIndex===0)};cn=new WeakSet;So=function(s){for(let e of this.items)e.tabIndex=e===s?0:-1;};Eo=new WeakSet;ic=function(s,e){let t=[...this.checkedItems];s.type==="radio"&&this.radioGroupItems.forEach(i=>i.checked=false),e?s.checked=!s.checked:s.checked=true,this.checkedItems.some((i,r)=>i!=t[r])&&this.dispatchEvent(new Event("change",{bubbles:true,composed:true}));};Qe.shadowRootOptions={mode:"open"};Qe.getTemplateHTML=tT;function iT(s){return ["menuitem","menuitemradio","menuitemcheckbox"].includes(s?.role)}function fn(s){var e;return (e=s.getAttribute("bounds")?Ht(s,`#${s.getAttribute("bounds")}`):Me(s)||s.parentElement)!=null?e:s}A.customElements.get("media-chrome-menu")||A.customElements.define("media-chrome-menu",Qe);var hc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ri=(s,e,t)=>(hc(s,e,"read from private field"),t?t.call(s):e.get(s)),vi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},oc=(s,e,t,i)=>(hc(s,e,"write to private field"),e.set(s,t),t),si=(s,e,t)=>(hc(s,e,"access private method"),t),bo,gn,lc,Fm,fc,Um,mc,Bm,ni,Js,pn,dc,$m,Ao,cc;function sT(s){return `
|
|
1449
|
-
<style>
|
|
1450
|
-
:host {
|
|
1451
|
-
transition: var(--media-menu-item-transition,
|
|
1452
|
-
background .15s linear,
|
|
1453
|
-
opacity .2s ease-in-out
|
|
1454
|
-
);
|
|
1455
|
-
outline: var(--media-menu-item-outline, 0);
|
|
1456
|
-
outline-offset: var(--media-menu-item-outline-offset, -1px);
|
|
1457
|
-
cursor: var(--media-cursor, pointer);
|
|
1458
|
-
display: flex;
|
|
1459
|
-
align-items: center;
|
|
1460
|
-
align-self: stretch;
|
|
1461
|
-
justify-self: stretch;
|
|
1462
|
-
white-space: nowrap;
|
|
1463
|
-
white-space-collapse: collapse;
|
|
1464
|
-
text-wrap: nowrap;
|
|
1465
|
-
padding: .4em .8em .4em 1em;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
:host(:focus-visible) {
|
|
1469
|
-
box-shadow: var(--media-menu-item-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
1470
|
-
outline: var(--media-menu-item-hover-outline, 0);
|
|
1471
|
-
outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px));
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
:host(:hover) {
|
|
1475
|
-
cursor: var(--media-cursor, pointer);
|
|
1476
|
-
background: var(--media-menu-item-hover-background, rgb(92 92 102 / .5));
|
|
1477
|
-
outline: var(--media-menu-item-hover-outline);
|
|
1478
|
-
outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px));
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
:host([aria-checked="true"]) {
|
|
1482
|
-
background: var(--media-menu-item-checked-background);
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
:host([hidden]) {
|
|
1486
|
-
display: none;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
:host([disabled]) {
|
|
1490
|
-
pointer-events: none;
|
|
1491
|
-
color: rgba(255, 255, 255, .3);
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
slot:not([name]) {
|
|
1495
|
-
width: 100%;
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
slot:not([name="submenu"]) {
|
|
1499
|
-
display: inline-flex;
|
|
1500
|
-
align-items: center;
|
|
1501
|
-
transition: inherit;
|
|
1502
|
-
opacity: var(--media-menu-item-opacity, 1);
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
slot[name="description"] {
|
|
1506
|
-
justify-content: end;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
slot[name="description"] > span {
|
|
1510
|
-
display: inline-block;
|
|
1511
|
-
margin-inline: 1em .2em;
|
|
1512
|
-
max-width: var(--media-menu-item-description-max-width, 100px);
|
|
1513
|
-
text-overflow: ellipsis;
|
|
1514
|
-
overflow: hidden;
|
|
1515
|
-
font-size: .8em;
|
|
1516
|
-
font-weight: 400;
|
|
1517
|
-
text-align: right;
|
|
1518
|
-
position: relative;
|
|
1519
|
-
top: .04em;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
slot[name="checked-indicator"] {
|
|
1523
|
-
display: none;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
:host(:is([role="menuitemradio"],[role="menuitemcheckbox"])) slot[name="checked-indicator"] {
|
|
1527
|
-
display: var(--media-menu-item-checked-indicator-display, inline-block);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
svg, img, ::slotted(svg), ::slotted(img) {
|
|
1532
|
-
height: var(--media-menu-item-icon-height, var(--media-control-height, 24px));
|
|
1533
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
1534
|
-
display: block;
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
[part~="indicator"],
|
|
1539
|
-
::slotted([part~="indicator"]) {
|
|
1540
|
-
fill: var(--media-menu-item-indicator-fill,
|
|
1541
|
-
var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))));
|
|
1542
|
-
height: var(--media-menu-item-indicator-height, 1.25em);
|
|
1543
|
-
margin-right: .5ch;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
[part~="checked-indicator"] {
|
|
1547
|
-
visibility: hidden;
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
:host([aria-checked="true"]) [part~="checked-indicator"] {
|
|
1551
|
-
visibility: visible;
|
|
1552
|
-
}
|
|
1553
|
-
</style>
|
|
1554
|
-
<slot name="checked-indicator">
|
|
1555
|
-
<svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">
|
|
1556
|
-
<path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
|
|
1557
|
-
</svg>
|
|
1558
|
-
</slot>
|
|
1559
|
-
<slot name="prefix"></slot>
|
|
1560
|
-
<slot></slot>
|
|
1561
|
-
<slot name="description"></slot>
|
|
1562
|
-
<slot name="suffix">
|
|
1563
|
-
${this.getSuffixSlotInnerHTML(s)}
|
|
1564
|
-
</slot>
|
|
1565
|
-
<slot name="submenu"></slot>
|
|
1566
|
-
`}function rT(s){return ""}var It={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},ai=class extends A.HTMLElement{constructor(){if(super(),vi(this,lc),vi(this,fc),vi(this,mc),vi(this,Js),vi(this,dc),vi(this,Ao),vi(this,bo,false),vi(this,gn,void 0),vi(this,ni,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let i=this.shadowRoot.querySelector('slot[name="description"]'),r=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=r?.dataset.description)!=null?t:r?.text,a=Ce.createElement("span");a.textContent=n??"",i.replaceChildren(a);}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=Le(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}this.shadowRoot.addEventListener("slotchange",this);}static get observedAttributes(){return [It.TYPE,It.DISABLED,It.CHECKED,It.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),mn(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":si(this,lc,Fm).call(this,e);break;case "click":this.handleClick(e);break;case "keydown":si(this,dc,$m).call(this,e);break;case "keyup":si(this,Js,pn).call(this,e);break}}attributeChangedCallback(e,t,i){e===It.CHECKED&&mn(this)&&!ri(this,bo)?this.setAttribute("aria-checked",i!=null?"true":"false"):e===It.TYPE&&i!==t?this.role="menuitem"+i:e===It.DISABLED&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){this.hasAttribute(It.DISABLED)||this.enable(),this.role="menuitem"+this.type,oc(this,gn,uc(this,this.parentNode)),si(this,Ao,cc).call(this);}disconnectedCallback(){this.disable(),si(this,Ao,cc).call(this),oc(this,gn,null);}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`);}get invokeTargetElement(){var e;return this.invokeTarget?(e=qi(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:true})[0]}get type(){var e;return (e=this.getAttribute(It.TYPE))!=null?e:""}set type(e){this.setAttribute(It.TYPE,`${e}`);}get value(){var e;return (e=this.getAttribute(It.VALUE))!=null?e:this.text}set value(e){this.setAttribute(It.VALUE,e);}get text(){var e;return ((e=this.textContent)!=null?e:"").trim()}get checked(){if(mn(this))return this.getAttribute("aria-checked")==="true"}set checked(e){mn(this)&&(oc(this,bo,true),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"));}handleClick(e){mn(this)||this.invokeTargetElement&&at(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Pi({relatedTarget:this}));}get keysUsed(){return ["Enter"," "]}};bo=new WeakMap;gn=new WeakMap;lc=new WeakSet;Fm=function(s){let e=s.target;if(!e?.name)for(let i of e.assignedNodes({flatten:true}))i instanceof Text&&i.textContent.trim()===""&&i.remove();e.name==="submenu"&&(this.submenuElement?si(this,fc,Um).call(this):si(this,mc,Bm).call(this));};fc=new WeakSet;Um=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",ri(this,ni)),this.submenuElement.addEventListener("addmenuitem",ri(this,ni)),this.submenuElement.addEventListener("removemenuitem",ri(this,ni)),ri(this,ni).call(this);};mc=new WeakSet;Bm=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",ri(this,ni)),this.submenuElement.removeEventListener("addmenuitem",ri(this,ni)),this.submenuElement.removeEventListener("removemenuitem",ri(this,ni)),ri(this,ni).call(this);};ni=new WeakMap;Js=new WeakSet;pn=function(s){let{key:e}=s;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",si(this,Js,pn));return}this.handleClick(s);};dc=new WeakSet;$m=function(s){let{metaKey:e,altKey:t,key:i}=s;if(e||t||!this.keysUsed.includes(i)){this.removeEventListener("keyup",si(this,Js,pn));return}this.addEventListener("keyup",si(this,Js,pn),{once:true});};Ao=new WeakSet;cc=function(){var s;let e=(s=ri(this,gn))==null?void 0:s.radioGroupItems;if(!e)return;let t=e.filter(i=>i.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let i of e)i.setAttribute("aria-checked","false");t?.setAttribute("aria-checked","true");};ai.shadowRootOptions={mode:"open"};ai.getTemplateHTML=sT;ai.getSuffixSlotInnerHTML=rT;function mn(s){return s.type==="radio"||s.type==="checkbox"}function uc(s,e){if(!s)return null;let{host:t}=s.getRootNode();return !e&&t?uc(s,t):e?.items?e:uc(e,e?.parentNode)}A.customElements.get("media-chrome-menu-item")||A.customElements.define("media-chrome-menu-item",ai);function nT(s){return `
|
|
1567
|
-
${Qe.getTemplateHTML(s)}
|
|
1568
|
-
<style>
|
|
1569
|
-
:host {
|
|
1570
|
-
--_menu-bg: rgb(20 20 30 / .8);
|
|
1571
|
-
background: var(--media-settings-menu-background,
|
|
1572
|
-
var(--media-menu-background,
|
|
1573
|
-
var(--media-control-background,
|
|
1574
|
-
var(--media-secondary-color, var(--_menu-bg)))));
|
|
1575
|
-
min-width: var(--media-settings-menu-min-width, 170px);
|
|
1576
|
-
border-radius: 2px 2px 0 0;
|
|
1577
|
-
overflow: hidden;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
@-moz-document url-prefix() {
|
|
1581
|
-
:host{
|
|
1582
|
-
--_menu-bg: rgb(20 20 30);
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
:host([role="menu"]) {
|
|
1587
|
-
|
|
1588
|
-
justify-content: end;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
slot:not([name]) {
|
|
1592
|
-
justify-content: var(--media-settings-menu-justify-content);
|
|
1593
|
-
flex-direction: var(--media-settings-menu-flex-direction, column);
|
|
1594
|
-
overflow: visible;
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
#container.has-expanded {
|
|
1598
|
-
--media-settings-menu-item-opacity: 0;
|
|
1599
|
-
}
|
|
1600
|
-
</style>
|
|
1601
|
-
`}var En=class extends Qe{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Me(this).querySelector("media-settings-menu-button")}};En.getTemplateHTML=nT;A.customElements.get("media-settings-menu")||A.customElements.define("media-settings-menu",En);function aT(s){return `
|
|
1602
|
-
${ai.getTemplateHTML.call(this,s)}
|
|
1603
|
-
<style>
|
|
1604
|
-
slot:not([name="submenu"]) {
|
|
1605
|
-
opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
:host([aria-expanded="true"]:hover) {
|
|
1609
|
-
background: transparent;
|
|
1610
|
-
}
|
|
1611
|
-
</style>
|
|
1612
|
-
`}function oT(s){return `
|
|
1613
|
-
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1614
|
-
<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"/>
|
|
1615
|
-
</svg>
|
|
1616
|
-
`}var us=class extends ai{};us.shadowRootOptions={mode:"open"};us.getTemplateHTML=aT;us.getSuffixSlotInnerHTML=oT;A.customElements.get("media-settings-menu-item")||A.customElements.define("media-settings-menu-item",us);var ct=class extends ve{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=qi(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new Pi({relatedTarget:this}));}};A.customElements.get("media-chrome-menu-button")||A.customElements.define("media-chrome-menu-button",ct);function lT(){return `
|
|
1617
|
-
<style>
|
|
1618
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1619
|
-
display: none;
|
|
1620
|
-
}
|
|
1621
|
-
</style>
|
|
1622
|
-
<slot name="icon">
|
|
1623
|
-
<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1624
|
-
<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"/>
|
|
1625
|
-
</svg>
|
|
1626
|
-
</slot>
|
|
1627
|
-
`}function dT(){return w("Settings")}var er=class extends ct{static get observedAttributes(){return [...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",w("settings"));}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Me(this).querySelector("media-settings-menu")}};er.getSlotTemplateHTML=lT;er.getTooltipContentHTML=dT;A.customElements.get("media-settings-menu-button")||A.customElements.define("media-settings-menu-button",er);var vc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Gm=(s,e,t)=>(vc(s,e,"read from private field"),t?t.call(s):e.get(s)),_o=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},gc=(s,e,t,i)=>(vc(s,e,"write to private field"),e.set(s,t),t),Io=(s,e,t)=>(vc(s,e,"access private method"),t),vn,Ro,Lo,pc,xo,Ec,Do=class extends Qe{constructor(){super(...arguments),_o(this,Lo),_o(this,xo),_o(this,vn,[]),_o(this,Ro,void 0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==i?this.value=i:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==i&&(gc(this,vn,Yh(i??"")),Io(this,Lo,pc).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Io(this,xo,Ec));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Io(this,xo,Ec));}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=Me(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return Gm(this,vn)}set mediaAudioTrackList(e){gc(this,vn,e),Io(this,Lo,pc).call(this);}get mediaAudioTrackEnabled(){var e;return (e=te(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ie(this,T.MEDIA_AUDIO_TRACK_ENABLED,e);}};vn=new WeakMap;Ro=new WeakMap;Lo=new WeakSet;pc=function(){if(Gm(this,Ro)===JSON.stringify(this.mediaAudioTrackList))return;gc(this,Ro,JSON.stringify(this.mediaAudioTrackList));let s=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of s){let t=this.formatMenuItemText(e.label,e),i=ii({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});i.prepend(Pt(this,"checked-indicator")),this.defaultSlot.append(i);}};xo=new WeakSet;Ec=function(){if(this.value==null)return;let s=new A.CustomEvent(F.MEDIA_AUDIO_TRACK_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};A.customElements.get("media-audio-track-menu")||A.customElements.define("media-audio-track-menu",Do);var cT=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1628
|
-
<path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
|
|
1629
|
-
<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"/>
|
|
1630
|
-
</svg>`;function uT(){return `
|
|
1631
|
-
<style>
|
|
1632
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1633
|
-
display: none;
|
|
1634
|
-
}
|
|
1635
|
-
</style>
|
|
1636
|
-
<slot name="icon">${cT}</slot>
|
|
1637
|
-
`}function hT(){return w("Audio")}var Hm=s=>{let e=w("Audio");s.setAttribute("aria-label",e);},tr=class extends ct{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Hm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_LANG&&Hm(this);}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=Me(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return (e=te(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ie(this,T.MEDIA_AUDIO_TRACK_ENABLED,e);}};tr.getSlotTemplateHTML=uT;tr.getTooltipContentHTML=hT;A.customElements.get("media-audio-track-menu-button")||A.customElements.define("media-audio-track-menu-button",tr);var Ac=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},fT=(s,e,t)=>(Ac(s,e,"read from private field"),e.get(s)),Tc=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},mT=(s,e,t,i)=>(Ac(s,e,"write to private field"),e.set(s,t),t),yc=(s,e,t)=>(Ac(s,e,"access private method"),t),Co,Sc,Wm,ko,bc,gT=`
|
|
1638
|
-
<svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
|
|
1639
|
-
<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"/>
|
|
1640
|
-
</svg>`;function pT(s){return `
|
|
1641
|
-
${Qe.getTemplateHTML(s)}
|
|
1642
|
-
<slot name="captions-indicator" hidden>${gT}</slot>
|
|
1643
|
-
`}var Tn=class extends Qe{constructor(){super(...arguments),Tc(this,Sc),Tc(this,ko),Tc(this,Co,void 0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_SUBTITLES_LIST&&t!==i?yc(this,Sc,Wm).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==i&&(this.value=i);}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yc(this,ko,bc));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yc(this,ko,bc));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Me(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return Vm(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Km(this,T.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return Vm(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Km(this,T.MEDIA_SUBTITLES_SHOWING,e);}};Co=new WeakMap;Sc=new WeakSet;Wm=function(){var s;if(fT(this,Co)===JSON.stringify(this.mediaSubtitlesList))return;mT(this,Co,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=ii({type:"radio",text:this.formatMenuItemText(w("Off")),value:"off",checked:e});t.prepend(Pt(this,"checked-indicator")),this.defaultSlot.append(t);let i=this.mediaSubtitlesList;for(let r of i){let n=ii({type:"radio",text:this.formatMenuItemText(r.label,r),value:fa(r),checked:this.value==fa(r)});n.prepend(Pt(this,"checked-indicator")),((s=r.kind)!=null?s:"subs")==="captions"&&n.append(Pt(this,"captions-indicator")),this.defaultSlot.append(n);}};ko=new WeakSet;bc=function(){let s=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(s?.length&&t&&this.dispatchEvent(new A.CustomEvent(F.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:s})),!this.value||!t)return;let i=new A.CustomEvent(F.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(i);};Tn.getTemplateHTML=pT;var Vm=(s,e)=>{let t=s.getAttribute(e);return t?Qi(t):[]},Km=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=gi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};A.customElements.get("media-captions-menu")||A.customElements.define("media-captions-menu",Tn);var ET=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1644
|
-
<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"/>
|
|
1645
|
-
</svg>`,vT=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1646
|
-
<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"/>
|
|
1647
|
-
</svg>`;function TT(){return `
|
|
1648
|
-
<style>
|
|
1649
|
-
:host([aria-checked="true"]) slot[name=off] {
|
|
1650
|
-
display: none !important;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
:host(:not([aria-checked="true"])) slot[name=on] {
|
|
1655
|
-
display: none !important;
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1659
|
-
display: none;
|
|
1660
|
-
}
|
|
1661
|
-
</style>
|
|
1662
|
-
|
|
1663
|
-
<slot name="icon">
|
|
1664
|
-
<slot name="on">${ET}</slot>
|
|
1665
|
-
<slot name="off">${vT}</slot>
|
|
1666
|
-
</slot>
|
|
1667
|
-
`}function yT(){return w("Captions")}var qm=s=>{s.setAttribute("aria-checked",ma(s).toString());},Ym=s=>{s.setAttribute("aria-label",w("closed captions"));},ir=class extends ct{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING,T.MEDIA_LANG]}connectedCallback(){super.connectedCallback(),Ym(this),qm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_SUBTITLES_SHOWING?qm(this):e===T.MEDIA_LANG&&Ym(this);}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=Me(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return jm(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){zm(this,T.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return jm(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){zm(this,T.MEDIA_SUBTITLES_SHOWING,e);}};ir.getSlotTemplateHTML=TT;ir.getTooltipContentHTML=yT;var jm=(s,e)=>{let t=s.getAttribute(e);return t?Qi(t):[]},zm=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=gi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};A.customElements.get("media-captions-menu-button")||A.customElements.define("media-captions-menu-button",ir);var Qm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},sr=(s,e,t)=>(Qm(s,e,"read from private field"),t?t.call(s):e.get(s)),_c=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},yn=(s,e,t)=>(Qm(s,e,"access private method"),t),Ni,Sn,Mo,wo,Lc,Ic={RATES:"rates"},Po=class extends Qe{constructor(){super(),_c(this,Sn),_c(this,wo),_c(this,Ni,new Li(this,Ic.RATES,{defaultValue:kd})),yn(this,Sn,Mo).call(this);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Ic.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_PLAYBACK_RATE&&t!=i?this.value=i:e===Ic.RATES&&t!=i&&(sr(this,Ni).value=i,yn(this,Sn,Mo).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yn(this,wo,Lc));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yn(this,wo,Lc));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Me(this).querySelector("media-playback-rate-menu-button")}get rates(){return sr(this,Ni)}set rates(e){e?Array.isArray(e)?sr(this,Ni).value=e.join(" "):typeof e=="string"&&(sr(this,Ni).value=e):sr(this,Ni).value="",yn(this,Sn,Mo).call(this);}get mediaPlaybackRate(){return ae(this,T.MEDIA_PLAYBACK_RATE,rs)}set mediaPlaybackRate(e){he(this,T.MEDIA_PLAYBACK_RATE,e);}};Ni=new WeakMap;Sn=new WeakSet;Mo=function(){this.defaultSlot.textContent="";for(let s of sr(this,Ni)){let e=ii({type:"radio",text:this.formatMenuItemText(`${s}x`,s),value:s,checked:this.mediaPlaybackRate===Number(s)});e.prepend(Pt(this,"checked-indicator")),this.defaultSlot.append(e);}};wo=new WeakSet;Lc=function(){if(!this.value)return;let s=new A.CustomEvent(F.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};A.customElements.get("media-playback-rate-menu")||A.customElements.define("media-playback-rate-menu",Po);var Oo=1;function ST(s){return `
|
|
1668
|
-
<style>
|
|
1669
|
-
:host {
|
|
1670
|
-
min-width: 5ch;
|
|
1671
|
-
padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1675
|
-
display: none;
|
|
1676
|
-
}
|
|
1677
|
-
</style>
|
|
1678
|
-
<slot name="icon">${s.mediaplaybackrate||Oo}x</slot>
|
|
1679
|
-
`}function bT(){return w("Playback rate")}var rr=class extends ct{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:Oo}x`;}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===T.MEDIA_PLAYBACK_RATE){let r=i?+i:Number.NaN,n=Number.isNaN(r)?Oo:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",w("Playback rate {playbackRate}",{playbackRate:n}));}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Me(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return ae(this,T.MEDIA_PLAYBACK_RATE,Oo)}set mediaPlaybackRate(e){he(this,T.MEDIA_PLAYBACK_RATE,e);}};rr.getSlotTemplateHTML=ST;rr.getTooltipContentHTML=bT;A.customElements.get("media-playback-rate-menu-button")||A.customElements.define("media-playback-rate-menu-button",rr);var Rc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},bn=(s,e,t)=>(Rc(s,e,"read from private field"),t?t.call(s):e.get(s)),No=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Xm=(s,e,t,i)=>(Rc(s,e,"write to private field"),e.set(s,t),t),nr=(s,e,t)=>(Rc(s,e,"access private method"),t),An,or,ar,_n,Fo,xc,Uo=class extends Qe{constructor(){super(...arguments),No(this,ar),No(this,Fo),No(this,An,[]),No(this,or,{});}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_RENDITION_SELECTED&&t!==i?(this.value=i??"auto",nr(this,ar,_n).call(this)):e===T.MEDIA_RENDITION_LIST&&t!==i?(Xm(this,An,Wh(i)),nr(this,ar,_n).call(this)):e===T.MEDIA_HEIGHT&&t!==i&&nr(this,ar,_n).call(this);}connectedCallback(){super.connectedCallback(),this.addEventListener("change",nr(this,Fo,xc));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",nr(this,Fo,xc));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Me(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return bn(this,An)}set mediaRenditionList(e){Xm(this,An,e),nr(this,ar,_n).call(this);}get mediaRenditionSelected(){return te(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ie(this,T.MEDIA_RENDITION_SELECTED,e);}get mediaHeight(){return ae(this,T.MEDIA_HEIGHT)}set mediaHeight(e){he(this,T.MEDIA_HEIGHT,e);}};An=new WeakMap;or=new WeakMap;ar=new WeakSet;_n=function(){if(bn(this,or).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&bn(this,or).mediaHeight===this.mediaHeight)return;bn(this,or).mediaRenditionList=JSON.stringify(this.mediaRenditionList),bn(this,or).mediaHeight=this.mediaHeight;let s=this.mediaRenditionList.sort((n,a)=>a.height-n.height);for(let n of s)n.selected=n.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let n of s){let a=this.formatMenuItemText(`${Math.min(n.width,n.height)}p`,n),o=ii({type:"radio",text:a,value:`${n.id}`,checked:n.selected&&!e});o.prepend(Pt(this,"checked-indicator")),this.defaultSlot.append(o);}let t=e?this.formatMenuItemText(`${w("Auto")} (${this.mediaHeight}p)`):this.formatMenuItemText(w("Auto")),i=ii({type:"radio",text:t,value:"auto",checked:e}),r=this.mediaHeight>0?`${w("Auto")} (${this.mediaHeight}p)`:w("Auto");i.dataset.description=r,i.prepend(Pt(this,"checked-indicator")),this.defaultSlot.append(i);};Fo=new WeakSet;xc=function(){if(this.value==null)return;let s=new A.CustomEvent(F.MEDIA_RENDITION_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};A.customElements.get("media-rendition-menu")||A.customElements.define("media-rendition-menu",Uo);var AT=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1680
|
-
<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" />
|
|
1681
|
-
</svg>`;function _T(){return `
|
|
1682
|
-
<style>
|
|
1683
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1684
|
-
display: none;
|
|
1685
|
-
}
|
|
1686
|
-
</style>
|
|
1687
|
-
<slot name="icon">${AT}</slot>
|
|
1688
|
-
`}function IT(){return w("Quality")}var lr=class extends ct{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",w("quality"));}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Me(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return te(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ie(this,T.MEDIA_RENDITION_SELECTED,e);}get mediaHeight(){return ae(this,T.MEDIA_HEIGHT)}set mediaHeight(e){he(this,T.MEDIA_HEIGHT,e);}};lr.getSlotTemplateHTML=_T;lr.getTooltipContentHTML=IT;A.customElements.get("media-rendition-menu-button")||A.customElements.define("media-rendition-menu-button",lr);var Kn=chunkIPA5Q26W_cjs.b(chunk5KQJTT3P_cjs.b(),1);var $=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},LT=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=xT},xT=Number.MAX_SAFE_INTEGER||9007199254740991,W=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),R=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s}({}),g=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s}({}),ce={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},K={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Bi=class{constructor(e,t=0,i=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_=i;}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*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_}},jc=class{constructor(e,t,i,r=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Bi(e),this.fast_=new Bi(t),this.defaultTTFB_=r,this.ttfb_=new Bi(e);}update(e,t){let{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new Bi(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Bi(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Bi(e,n.getEstimate(),n.getTotalWeight()));}sample(e,t){e=Math.max(e,this.minDelayMs_);let i=8*t,r=e/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n);}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,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_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}};function RT(s,e,t){return (e=kT(e))in s?Object.defineProperty(s,e,{value:t,enumerable:true,configurable:true,writable:true}):s[e]=t,s}function Te(){return Te=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i]);}return s},Te.apply(null,arguments)}function Zm(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,i);}return t}function be(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Zm(Object(t),true).forEach(function(i){RT(s,i,t[i]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Zm(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i));});}return s}function DT(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return (e==="string"?String:Number)(s)}function kT(s){var e=DT(s,"string");return typeof e=="symbol"?e:e+""}var bt=class{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;let i=`[${e}]:`;this.trace=$i,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i);}},$i=function(){},CT={trace:$i,debug:$i,log:$i,warn:$i,info:$i,error:$i};function zc(){return Te({},CT)}function MT(s,e){let t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):$i}function Jm(s,e,t){return e[s]?e[s].bind(e):MT(s,t)}var Qc=zc();function wT(s,e,t){let i=zc();if(typeof console=="object"&&s===true||typeof s=="object"){let r=["debug","log","info","warn","error"];r.forEach(n=>{i[n]=Jm(n,s,t);});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.7`);}catch{return zc()}r.forEach(n=>{Qc[n]=Jm(n,s);});}else Te(Qc,i);return i}var Ee=Qc;function Gi(s=true){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function PT(s){return typeof self<"u"&&s===self.ManagedMediaSource}function op(s,e){let t=Object.keys(s),i=Object.keys(e),r=t.length,n=i.length;return !r||!n||r===n&&!t.some(a=>i.indexOf(a)===-1)}function St(s,e=false){if(typeof TextDecoder<"u"){let l=new TextDecoder("utf-8").decode(s);if(e){let c=l.indexOf("\0");return c!==-1?l.substring(0,c):l}return l.replace(/\0/g,"")}let t=s.length,i,r,n,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=s[o++],a+=String.fromCharCode((i&31)<<6|r&63);break;case 14:r=s[o++],n=s[o++],a+=String.fromCharCode((i&15)<<12|(r&63)<<6|(n&63)<<0);break}}return a}var ms={hexDump:function(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i;}return e}};function lp(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function OT(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Dc={exports:{}},eg;function NT(){return eg||(eg=1,function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(d,l,c){if(c=c||{},d=d.trim(),l=l.trim(),!l){if(!c.alwaysNormalize)return d;var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):l;var f=o.parseURL(d);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=r.exec(f.path);f.netLoc=m[1],f.path=m[2];}f.netLoc&&!f.path&&(f.path="/");var E={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)E.path=f.path,h.params||(E.params=f.params,h.query||(E.query=f.query));else {var p=f.path,v=p.substring(0,p.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(v);}return E.path===null&&(E.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(d){var l=i.exec(d);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(n,"");d.length!==(d=d.replace(a,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}};s.exports=o;})();}(Dc)),Dc.exports}var uh=NT(),Cn=class{constructor(){this.aborted=false,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};}},_e={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},rl=class{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,FT(this,"stats");}setByteRange(e,t){let i=e.split("@",2),r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r];}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[_e.AUDIO]:null,[_e.VIDEO]:null,[_e.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e;}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Cn),this._stats}set stats(e){this._stats=e;}get url(){return !this._url&&this.baseurl&&this.relurl&&(this._url=uh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:true})),this._url||""}set url(e){this._url=e;}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[_e.AUDIO]=null,e[_e.VIDEO]=null,e[_e.AUDIOVIDEO]=null;}};function $e(s){return s.sn!=="initSegment"}var xn=class extends rl{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=false,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e;}get byteLength(){if(this.hasStats){let e=this.stats.total;if(e)return e}if(this.byteRange){let e=this.byteRange[0],t=this.byteRange[1];if($(e)&&$(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=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 i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;let e=$(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return true;if(this.levelkeys){let t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return true}return false}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!$(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e;}get ref(){return $e(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e);}setStart(e){this.start=e,this._ref&&(this._ref.start=e);}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e);}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,i,r,n,a=false){let{elementaryStreams:o}=this,d=o[e];if(!d){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:n,partial:a};return}d.startPTS=Math.min(d.startPTS,t),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,r),d.endDTS=Math.max(d.endDTS,n);}},Xc=class extends rl{constructor(e,t,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.gap=false,this.independent=false,this.relurl=void 0,this.fragment=void 0,this.index=void 0,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=r;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)}};function dp(s,e){let t=Object.getPrototypeOf(s);if(t){let i=Object.getOwnPropertyDescriptor(t,e);return i||dp(t,e)}}function FT(s,e){let t=dp(s,e);t&&(t.enumerable=true,Object.defineProperty(s,e,t));}var tg=Math.pow(2,32)-1,UT=[].push,cp={video:1,audio:2,id3:3,text:4};function Ze(s){return String.fromCharCode.apply(null,s)}function up(s,e){let t=s[e]<<8|s[e+1];return t<0?65536+t:t}function ee(s,e){let t=hp(s,e);return t<0?4294967296+t:t}function ig(s,e){let t=ee(s,e);return t*=Math.pow(2,32),t+=ee(s,e+4),t}function hp(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function BT(s){let e=s.byteLength;for(let t=0;t<e;){let i=ee(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return true;t=i>1?t+i:e;}return false}function de(s,e){let t=[];if(!e.length)return t;let i=s.byteLength;for(let r=0;r<i;){let n=ee(s,r),a=Ze(s.subarray(r+4,r+8)),o=n>1?r+n:i;if(a===e[0])if(e.length===1)t.push(s.subarray(r+8,o));else {let d=de(s.subarray(r+8,o),e.slice(1));d.length&&UT.apply(t,d);}r=o;}return t}function $T(s){let e=[],t=s[0],i=8,r=ee(s,i);i+=4;let n=0,a=0;t===0?(n=ee(s,i),a=ee(s,i+4),i+=8):(n=ig(s,i),a=ig(s,i+8),i+=16),i+=2;let o=s.length+a,d=up(s,i);i+=2;for(let l=0;l<d;l++){let c=i,u=ee(s,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return Ee.warn("SIDX has hierarchical references (not supported)"),null;let m=ee(s,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+h-1}}),o+=h,c+=4,i=c;}return {earliestPresentationTime:n,timescale:r,version:t,referencesCount:d,references:e}}function fp(s){let e=[],t=de(s,["moov","trak"]);for(let r=0;r<t.length;r++){let n=t[r],a=de(n,["tkhd"])[0];if(a){let o=a[0],d=ee(a,o===0?12:20),l=de(n,["mdia","mdhd"])[0];if(l){o=l[0];let c=ee(l,o===0?12:20),u=de(n,["mdia","hdlr"])[0];if(u){let h=Ze(u.subarray(8,12)),f={soun:_e.AUDIO,vide:_e.VIDEO}[h],m=de(n,["mdia","minf","stbl","stsd"])[0],E=GT(m);f?(e[d]={timescale:c,type:f,stsd:E},e[f]=be({timescale:c,id:d},E)):e[d]={timescale:c,type:h,stsd:E};}}}}return de(s,["moov","mvex","trex"]).forEach(r=>{let n=ee(r,4),a=e[n];a&&(a.default={duration:ee(r,12),flags:ee(r,20)});}),e}function GT(s){let e=s.subarray(8),t=e.subarray(86),i=Ze(e.subarray(4,8)),r=i,n,a=i==="enca"||i==="encv";if(a){let l=de(e,[i])[0].subarray(i==="enca"?28:78);de(l,["sinf"]).forEach(u=>{let h=de(u,["schm"])[0];if(h){let f=Ze(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){let m=de(u,["frma"])[0];m&&(r=Ze(m));}}});}let o=r;switch(r){case "avc1":case "avc2":case "avc3":case "avc4":{let d=de(t,["avcC"])[0];d&&d.length>3&&(r+="."+$o(d[1])+$o(d[2])+$o(d[3]),n=Bo(o==="avc1"?"dva1":"dvav",t));break}case "mp4a":{let d=de(e,[i])[0],l=de(d.subarray(28),["esds"])[0];if(l&&l.length>7){let c=4;if(l[c++]!==3)break;c=kc(l,c),c+=2;let u=l[c++];if(u&128&&(c+=2),u&64&&(c+=l[c++]),l[c++]!==4)break;c=kc(l,c);let h=l[c++];if(h===64)r+="."+$o(h);else break;if(c+=12,l[c++]!==5)break;c=kc(l,c);let f=l[c++],m=(f&248)>>3;m===31&&(m+=1+((f&7)<<3)+((l[c]&224)>>5)),r+="."+m;}break}case "hvc1":case "hev1":{let d=de(t,["hvcC"])[0];if(d&&d.length>12){let l=d[1],c=["","A","B","C"][l>>6],u=l&31,h=ee(d,2),f=(l&32)>>5?"H":"L",m=d[12],E=d.subarray(6,12);r+="."+c+u,r+="."+HT(h).toString(16).toUpperCase(),r+="."+f+m;let p="";for(let v=E.length;v--;){let S=E[v];(S||p)&&(p="."+S.toString(16).toUpperCase()+p);}r+=p;}n=Bo(o=="hev1"?"dvhe":"dvh1",t);break}case "dvh1":case "dvhe":case "dvav":case "dva1":case "dav1":{r=Bo(r,t)||r;break}case "vp09":{let d=de(t,["vpcC"])[0];if(d&&d.length>6){let l=d[4],c=d[5],u=d[6]>>4&15;r+="."+li(l)+"."+li(c)+"."+li(u);}break}case "av01":{let d=de(t,["av1C"])[0];if(d&&d.length>2){let l=d[1]>>>5,c=d[1]&31,u=d[2]>>>7?"H":"M",h=(d[2]&64)>>6,f=(d[2]&32)>>5,m=l===2&&h?f?12:10:h?10:8,E=(d[2]&16)>>4,p=(d[2]&8)>>3,v=(d[2]&4)>>2,S=d[2]&3;r+="."+l+"."+li(c)+u+"."+li(m)+"."+E+"."+p+v+S+"."+li(1)+"."+li(1)+"."+li(1)+"."+0,n=Bo("dav1",t);}break}}return {codec:r,encrypted:a,supplemental:n}}function Bo(s,e){let t=de(e,["dvvC"]),i=t.length?t[0]:de(e,["dvcC"])[0];if(i){let r=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return s+"."+li(r)+"."+li(n)}}function HT(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function kc(s,e){let t=e+5;for(;s[e++]&128&&e<t;);return e}function $o(s){return ("0"+s.toString(16).toUpperCase()).slice(-2)}function li(s){return (s<10?"0":"")+s}function VT(s,e){if(!s||!e)return s;let t=e.keyId;return t&&e.isCommonEncryption&&de(s,["moov","trak"]).forEach(r=>{let a=de(r,["mdia","minf","stbl","stsd"])[0].subarray(8),o=de(a,["enca"]),d=o.length>0;d||(o=de(a,["encv"])),o.forEach(l=>{let c=d?l.subarray(28):l.subarray(78);de(c,["sinf"]).forEach(h=>{let f=KT(h);if(f){let m=f.subarray(8,24);m.some(E=>E!==0)||(Ee.log(`[eme] Patching keyId in 'enc${d?"a":"v"}>sinf>>tenc' box: ${ms.hexDump(m)} -> ${ms.hexDump(t)}`),f.set(t,8));}});});}),s}function KT(s){let e=de(s,["schm"])[0];if(e){let t=Ze(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return de(s,["schi","tenc"])[0]}return null}function WT(s,e,t){let i={},r=de(s,["moof","traf"]);for(let n=0;n<r.length;n++){let a=r[n],o=de(a,["tfhd"])[0],d=ee(o,4),l=e[d];if(!l)continue;let c=i[d]||(i[d]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type}),u=de(a,["tfdt"])[0];if(u){let y=u[0],b=ee(u,4);y===1&&(b===tg?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(b*=tg+1,b+=ee(u,8))),$(b)&&(!$(c.start)||b<c.start)&&(c.start=b);}let h=l.default,f=ee(o,0)|h?.flags,m=h?.duration||0;f&8&&(f&2?m=ee(o,12):m=ee(o,8));let E=de(a,["trun"]),p=c.start||0,v=0,S=m;for(let y=0;y<E.length;y++){let b=E[y],L=ee(b,4),k=c.sampleCount;c.sampleCount+=L;let I=b[3]&1,x=b[3]&4,D=b[2]&1,_=b[2]&2,M=b[2]&4,N=b[2]&8,q=8,V=L;for(I&&(q+=4),x&&L&&(!(b[q+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=k),q+=4,D?(S=ee(b,q),q+=4):S=m,_&&(q+=4),N&&(q+=4),p+=S,v+=S,V--);V--;)D?(S=ee(b,q),q+=4):S=m,_&&(q+=4),M&&(b[q+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(V+1),c.keyFrameStart=p),q+=4),N&&(q+=4),p+=S,v+=S;!v&&m&&(v+=m*L);}c.duration+=v;}if(!Object.keys(i).some(n=>i[n].duration)){let n=1/0,a=0,o=de(s,["sidx"]);for(let d=0;d<o.length;d++){let l=$T(o[d]);if(l!=null&&l.references){n=Math.min(n,l.earliestPresentationTime/l.timescale);let c=l.references.reduce((u,h)=>u+h.info.duration||0,0);a=Math.max(a,c+l.earliestPresentationTime/l.timescale);}}a&&$(a)&&Object.keys(i).forEach(d=>{i[d].duration||(i[d].duration=a*i[d].timescale-i[d].start);});}return i}function qT(s){let e={valid:null,remainder:null},t=de(s,["moof"]);if(t.length<2)return e.remainder=s,e;let i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function Rt(s,e){let t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function sg(s,e){let t=[],i=e.samples,r=e.timescale,n=e.id,a=false;return de(i,["moof"]).map(d=>{let l=d.byteOffset-8;de(d,["traf"]).map(u=>{let h=de(u,["tfdt"]).map(f=>{let m=f[0],E=ee(f,4);return m===1&&(E*=Math.pow(2,32),E+=ee(f,8)),E/r})[0];return h!==void 0&&(s=h),de(u,["tfhd"]).map(f=>{let m=ee(f,4),E=ee(f,0)&16777215,p=(E&1)!==0,v=(E&2)!==0,S=(E&8)!==0,y=0,b=(E&16)!==0,L=0,k=(E&32)!==0,I=8;m===n&&(p&&(I+=8),v&&(I+=4),S&&(y=ee(f,I),I+=4),b&&(L=ee(f,I),I+=4),k&&(I+=4),e.type==="video"&&(a=Ml(e.codec)),de(u,["trun"]).map(x=>{let D=x[0],_=ee(x,0)&16777215,M=(_&1)!==0,N=0,q=(_&4)!==0,V=(_&256)!==0,H=0,B=(_&512)!==0,j=0,P=(_&1024)!==0,z=(_&2048)!==0,Y=0,U=ee(x,4),O=8;M&&(N=ee(x,O),O+=4),q&&(O+=4);let se=N+l;for(let oe=0;oe<U;oe++){if(V?(H=ee(x,O),O+=4):H=y,B?(j=ee(x,O),O+=4):j=L,P&&(O+=4),z&&(D===0?Y=ee(x,O):Y=hp(x,O),O+=4),e.type===_e.VIDEO){let me=0;for(;me<j;){let ue=ee(i,se);if(se+=4,YT(a,i[se])){let Ie=i.subarray(se,se+ue);hh(Ie,a?2:1,s+Y/r,t);}se+=ue,me+=ue+4;}}s+=H/r;}}));})});}),t}function Ml(s){if(!s)return false;let e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function YT(s,e){if(s){let t=e>>1&63;return t===39||t===40}else return (e&31)===6}function hh(s,e,t,i){let r=mp(s),n=0;n+=e;let a=0,o=0,d=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;d=r[n++],a+=d;}while(d===255);o=0;do{if(n>=r.length)break;d=r[n++],o+=d;}while(d===255);let l=r.length-n,c=n;if(o<l)n+=o;else if(o>l){Ee.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(a===4){if(r[c++]===181){let h=up(r,c);if(c+=2,h===49){let f=ee(r,c);if(c+=4,f===1195456820){let m=r[c++];if(m===3){let E=r[c++],p=31&E,v=64&E,S=v?2+p*3:0,y=new Uint8Array(S);if(v){y[0]=E;for(let b=1;b<S;b++)y[b]=r[c++];}i.push({type:m,payloadType:a,pts:t,bytes:y});}}}}}else if(a===5&&o>16){let u=[];for(let m=0;m<16;m++){let E=r[c++].toString(16);u.push(E.length==1?"0"+E:E),(m===3||m===5||m===7||m===9)&&u.push("-");}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=r[c++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:St(f),userDataBytes:f});}}}function mp(s){let e=s.byteLength,t=[],i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;let r=e-t.length,n=new Uint8Array(r),a=0;for(i=0;i<r;a++,i++)a===t[0]&&(a++,t.shift()),n[i]=s[a];return n}function jT(s){let e=s[0],t="",i="",r=0,n=0,a=0,o=0,d=0,l=0;if(e===0){for(;Ze(s.subarray(l,l+1))!=="\0";)t+=Ze(s.subarray(l,l+1)),l+=1;for(t+=Ze(s.subarray(l,l+1)),l+=1;Ze(s.subarray(l,l+1))!=="\0";)i+=Ze(s.subarray(l,l+1)),l+=1;i+=Ze(s.subarray(l,l+1)),l+=1,r=ee(s,12),n=ee(s,16),o=ee(s,20),d=ee(s,24),l=28;}else if(e===1){l+=4,r=ee(s,l),l+=4;let u=ee(s,l);l+=4;let h=ee(s,l);for(l+=4,a=2**32*u+h,LT(a)||(a=Number.MAX_SAFE_INTEGER,Ee.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ee(s,l),l+=4,d=ee(s,l),l+=4;Ze(s.subarray(l,l+1))!=="\0";)t+=Ze(s.subarray(l,l+1)),l+=1;for(t+=Ze(s.subarray(l,l+1)),l+=1;Ze(s.subarray(l,l+1))!=="\0";)i+=Ze(s.subarray(l,l+1)),l+=1;i+=Ze(s.subarray(l,l+1)),l+=1;}let c=s.subarray(l,s.byteLength);return {schemeIdUri:t,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:d,payload:c}}function zT(s,...e){let t=e.length,i=8,r=t;for(;r--;)i+=e[r].byteLength;let n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(s,4),r=0,i=8;r<t;r++)n.set(e[r],i),i+=e[r].byteLength;return n}function QT(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,r;i=0,r=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,false)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,false),zT([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t||new Uint8Array)}var gp=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),vr={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,dav1:.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 fh(s,e){let t=vr[e];return !!t&&!!t[s.slice(0,4)]}function Zc(s,e,t=true){return !s.split(",").some(i=>!mh(i,e,t))}function mh(s,e,t=true){var i;let r=Gi(t);return (i=r?.isTypeSupported(Mn(s,e)))!=null?i:false}function Mn(s,e){return `${e}/mp4;codecs=${s}`}function rg(s){if(s){let e=s.substring(0,4);return vr.video[e]}return 2}function nl(s){let e=gp();return s.split(",").reduce((t,i)=>{let n=e&&Ml(i)?9:vr.video[i];return n?(n*2+t)/(t?3:2):(vr.audio[i]+t)/(t?2:1)},0)}var Cc={};function XT(s,e=true){if(Cc[s])return Cc[s];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let r=0;r<t.length;r++){var i;if(mh(t[r],"audio",e))return Cc[s]=t[r],t[r];if(t[r]==="mp3"&&(i=Gi(e))!=null&&i.isTypeSupported("audio/mpeg"))return ""}return s}var ZT=/flac|opus|mp4a\.40\.34/i;function al(s,e=true){return s.replace(ZT,t=>XT(t.toLowerCase(),e))}function JT(s,e){let t=[];if(s){let i=s.split(",");for(let r=0;r<i.length;r++)fh(i[r],"video")||t.push(i[r]);}return e&&t.push(e),t.join(",")}function Xo(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(ng(s,"audio")||ng(s,"video")))return s;if(e){let t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function ng(s,e){return fh(s,e)&&mh(s,e)}function ey(s){let e=s.split(",");for(let t=0;t<e.length;t++){let i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`);}return e.join(",")}function ty(s){if(s.startsWith("av01.")){let e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function ag(s){let e=Gi(s)||{isTypeSupported:()=>false};return {mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Jc(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var pp={supported:true,configurations:[],decodingInfoResults:[{supported:true,powerEfficient:true,smooth:true}]};function Ep(s,e){return {supported:false,configurations:e,decodingInfoResults:[{supported:false,smooth:false,powerEfficient:false}],error:s}}function iy(s,e,t,i,r,n){let a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,d=n?.audioCodec,l=n?.channels,c=l?parseInt(l):d?1/0:2,u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){let m=e.groups[f];if(!m)throw new Error(`Audio track group ${f} not found`);Object.keys(m.channels).forEach(E=>{h[E]=(h[E]||0)+m.channels[E];});}return h},{2:0});}catch{return true}return a!==void 0&&(a.split(",").some(h=>Ml(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!u&&$(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function vp(s,e,t,i={}){let r=s.videoCodec;if(!r&&!s.audioCodec||!t)return Promise.resolve(pp);let n=[],a=sy(s),o=a.length,d=ry(s,e,o>0),l=d.length;for(let c=o||1*l||1;c--;){let u={type:"media-source"};if(o&&(u.video=a[c%o]),l){u.audio=d[c%l];let h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h);}n.push(u);}if(r){let c=navigator.userAgent;if(r.split(",").some(u=>Ml(u))&&gp())return Promise.resolve(Ep(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),n))}return Promise.all(n.map(c=>{let u=ay(c);return i[u]||(i[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:n,decodingInfoResults:c})).catch(c=>({supported:false,configurations:n,decodingInfoResults:[],error:c}))}function sy(s){var e;let t=(e=s.videoCodec)==null?void 0:e.split(","),i=Tp(s),r=s.width||640,n=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(d=>{let l={contentType:Mn(ty(d),"video"),width:r,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function ry(s,e,t){var i;let r=(i=s.audioCodec)==null?void 0:i.split(","),n=Tp(s);return r&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var d;let l=o?(d=e.groups[o])==null?void 0:d.tracks:null;return l?l.reduce((c,u)=>{if(u.groupId===o){let h=parseFloat(u.channels||"");r.forEach(f=>{let m={contentType:Mn(f,"audio"),bitrate:t?ny(f,n):n};h&&(m.channels=""+h),c.push(m);});}return c},a):a},[]):[]}function ny(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function Tp(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function ay(s){let e="",{audio:t,video:i}=s;if(i){let r=Jc(i.contentType);e+=`${r}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`;}if(t){let r=Jc(t.contentType);e+=`${i?"_":""}${r}_c${t.channels}`;}return e}var eu=["NONE","TYPE-0","TYPE-1",null];function oy(s){return eu.indexOf(s)>-1}var ol=["SDR","PQ","HLG"];function ly(s){return !!s&&ol.indexOf(s)>-1}var Zo={No:"",Yes:"YES",v2:"v2"};function og(s){let{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?Zo.v2:Zo.Yes:Zo.No}var ll=class{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i;}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}},vs=class{constructor(e){if(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.supplemental=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(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;let i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`);}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 lg(this._audioGroups,e)}hasSubtitleGroup(e){return lg(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t);}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.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 lg(s,e){return !e||!s?false:s.indexOf(e)!==-1}function dy(){if(typeof matchMedia=="function"){let s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===true}return false}function cy(s,e){let t=false,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||ol.slice(0);let r=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&dy(),t||(i=["SDR"]);}return {preferHDR:t,allowedVideoRanges:i}}var uy=s=>{let e=new WeakSet;return (t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i}},Re=(s,e)=>JSON.stringify(s,uy(e));function hy(s,e,t,i,r){let n=Object.keys(s),a=i?.channels,o=i?.audioCodec,d=r?.videoCodec,l=a&&parseInt(a)===2,c=false,u=false,h=1/0,f=1/0,m=1/0,E=1/0,p=0,v=[],{preferHDR:S,allowedVideoRanges:y}=cy(e,r);for(let x=n.length;x--;){let D=s[n[x]];c||(c=D.channels[2]>0),h=Math.min(h,D.minHeight),f=Math.min(f,D.minFramerate),m=Math.min(m,D.minBitrate),y.filter(M=>D.videoRanges[M]>0).length>0&&(u=true);}h=$(h)?h:0,f=$(f)?f:0;let b=Math.max(1080,h),L=Math.max(30,f);m=$(m)?m:t,t=Math.max(m,t),u||(e=void 0);let k=n.length>1;return {codecSet:n.reduce((x,D)=>{let _=s[D];if(D===x)return x;if(v=u?y.filter(M=>_.videoRanges[M]>0):[],k){if(_.minBitrate>t)return oi(D,`min bitrate of ${_.minBitrate} > current estimate of ${t}`),x;if(!_.hasDefaultAudio)return oi(D,"no renditions with default or auto-select sound found"),x;if(o&&D.indexOf(o.substring(0,4))%5!==0)return oi(D,`audio codec preference "${o}" not found`),x;if(a&&!l){if(!_.channels[a])return oi(D,`no renditions with ${a} channel sound found (channels options: ${Object.keys(_.channels)})`),x}else if((!o||l)&&c&&_.channels[2]===0)return oi(D,"no renditions with stereo sound found"),x;if(_.minHeight>b)return oi(D,`min resolution of ${_.minHeight} > maximum of ${b}`),x;if(_.minFramerate>L)return oi(D,`min framerate of ${_.minFramerate} > maximum of ${L}`),x;if(!v.some(M=>_.videoRanges[M]>0))return oi(D,`no variants with VIDEO-RANGE of ${Re(v)} found`),x;if(d&&D.indexOf(d.substring(0,4))%5!==0)return oi(D,`video codec preference "${d}" not found`),x;if(_.maxScore<p)return oi(D,`max score of ${_.maxScore} < selected max of ${p}`),x}return x&&(nl(D)>=nl(x)||_.fragmentError>s[x].fragmentError)?x:(E=_.minIndex,p=_.maxScore,D)},void 0),videoRanges:v,preferHDR:S,minFramerate:f,minBitrate:m,minIndex:E}}function oi(s,e){Ee.log(`[abr] start candidates with "${s}" ignored because ${e}`);}function yp(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:false,hasAutoSelect:false}),i.tracks.push(t);let r=t.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=true),i.hasAutoSelect&&(e.hasAutoSelectAudio=true),e},{hasDefaultAudio:false,hasAutoSelectAudio:false,groups:{}})}function fy(s,e,t,i){return s.slice(t,i+1).reduce((r,n,a)=>{if(!n.codecSet)return r;let o=n.audioGroups,d=r[n.codecSet];d||(r[n.codecSet]=d={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),d.minBitrate=Math.min(d.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return d.minHeight=Math.min(d.minHeight,l),d.minFramerate=Math.min(d.minFramerate,n.frameRate),d.minIndex=Math.min(d.minIndex,a),d.maxScore=Math.max(d.maxScore,n.score),d.fragmentError+=n.fragmentError,d.videoRanges[n.videoRange]=(d.videoRanges[n.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;let u=e.groups[c];u&&(d.hasDefaultAudio=d.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{d.channels[h]=(d.channels[h]||0)+u.channels[h];}));}),r},{})}function dg(s){if(!s)return s;let{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}=s;return {lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}}function ci(s,e,t){if("attrs"in s){let i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){let r=e[i];if(ps(s,r,t))return i}return -1}function ps(s,e,t){let{groupId:i,name:r,lang:n,assocLang:a,default:o}=s,d=s.forced;return (i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||my(n,e.lang))&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(d===void 0||e.forced===d)&&(!("characteristics"in s)||gy(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function my(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function gy(s,e=""){let t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function fs(s,e){let{audioCodec:t,channels:i}=s;return (t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function py(s,e,t,i,r){let n=e[i],o=e.reduce((h,f,m)=>{let E=f.uri;return (h[E]||(h[E]=[])).push(m),h},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));let d=n.videoRange,l=n.frameRate,c=n.codecSet.substring(0,4),u=cg(e,i,h=>{if(h.videoRange!==d||h.frameRate!==l||h.codecSet.substring(0,4)!==c)return false;let f=h.audioGroups,m=t.filter(E=>!f||f.indexOf(E.groupId)!==-1);return ci(s,m,r)>-1});return u>-1?u:cg(e,i,h=>{let f=h.audioGroups,m=t.filter(E=>!f||f.indexOf(E.groupId)!==-1);return ci(s,m,r)>-1})}function cg(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return -1}function dl(s,e){var t;return !!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}var tu=class extends bt{constructor(e){super("abr",e.logger),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.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;let{fragCurrent:r,partCurrent:n,hls:a}=this,{autoLevelEnabled:o,media:d}=a;if(!r||!d)return;let l=performance.now(),c=n?n.stats:r.stats,u=n?n.duration:r.duration,h=l-c.loading.start,f=a.minAutoLevel,m=r.level,E=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||m<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;let p=E>-1&&E!==m,v=!!t||p;if(!v&&(d.paused||!d.playbackRate||!d.readyState))return;let S=a.mainForwardBufferInfo;if(!v&&S===null)return;let y=this.bwEstimator.getEstimateTTFB(),b=Math.abs(d.playbackRate);if(h<=Math.max(y,1e3*(u/(b*2))))return;let L=S?S.len/b:0,k=c.loading.first?c.loading.first-c.loading.start:-1,I=c.loaded&&k>-1,x=this.getBwEstimate(),D=a.levels,_=D[m],M=Math.max(c.loaded,Math.round(u*(r.bitrate||_.averageBitrate)/8)),N=I?h-k:h;N<1&&I&&(N=Math.min(h,c.loaded*8/x));let q=I?c.loaded*1e3/N:0,V=y/1e3,H=q?(M-c.loaded)/q:M*8/x+V;if(H<=L)return;let B=q?q*8:x,j=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===true,P=this.hls.config.abrBandWidthUpFactor,z=Number.POSITIVE_INFINITY,Y;for(Y=m-1;Y>f;Y--){let oe=D[Y].maxBitrate,me=!D[Y].details||j;if(z=this.getTimeToLoadFrag(V,B,u*oe,me),z<Math.min(L,u+V))break}if(z>=H||z>u*10)return;I?this.bwEstimator.sample(h-Math.min(y,k),c.loaded):this.bwEstimator.sampleTTFB(h);let U=D[Y].maxBitrate;this.getBwEstimate()*P>U&&this.resetEstimator(U);let O=this.findBestLevel(U,f,Y,0,L,1,1);O>-1&&(Y=O),this.warn(`Fragment ${r.sn}${n?" part "+n.index:""} of level ${m} is loading too slowly;
|
|
1689
|
-
Fragment duration: ${r.duration.toFixed(3)}
|
|
1690
|
-
Time to underbuffer: ${L.toFixed(3)} s
|
|
1691
|
-
Estimated load time for current fragment: ${H.toFixed(3)} s
|
|
1692
|
-
Estimated load time for down switch fragment: ${z.toFixed(3)} s
|
|
1693
|
-
TTFB estimate: ${k|0} ms
|
|
1694
|
-
Current BW estimate: ${$(x)?x|0:"Unknown"} bps
|
|
1695
|
-
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
1696
|
-
Switching to level ${Y} @ ${U|0} bps`),a.nextLoadLevel=a.nextAutoLevel=Y,this.clearTimer();let se=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===Y&&Y>0){let oe=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${Y>0?"and switching down":""}
|
|
1697
|
-
Fragment duration: ${r.duration.toFixed(3)} s
|
|
1698
|
-
Time to underbuffer: ${oe.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,Y>f){let me=this.findBestLevel(this.hls.levels[f].bitrate,f,Y,0,oe,1,1);me===-1&&(me=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=me,this.resetEstimator(this.hls.levels[me].bitrate);}}};p||H>z*2?se():this.timer=self.setInterval(se,z*1e3),a.trigger(g.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:c});},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners();}resetEstimator(e){e&&(this.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 jc(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e&&(e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(g.ERROR,this.onError,this));}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null;}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},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 i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r: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 R.BUFFER_ADD_CODEC_ERROR:case R.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case R.FRAG_LOAD_TIMEOUT:{let i=t.frag,{fragCurrent:r,partCurrent:n}=this;if(i&&r&&i.sn===r.sn&&i.level===r.level){let a=performance.now(),o=n?n.stats:i.stats,d=a-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){let u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(u,l),o.loaded);}else this.bwEstimator.sampleTTFB(d);}break}}}getTimeToLoadFrag(e,t,i,r){let n=e+i/t,a=r?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,n=r.end-r.first;$(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo);}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===K.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=i?i.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,d=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:d},a.realBitrate=Math.round(8*o/d);}if(t.bitrateTest){let n={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(g.FRAG_BUFFERED,n),t.bitrateTest=false;}else this.lastLoadedFragLevel=t.level;}}onFragBuffered(e,t){let{frag:i,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:i.stats;if(n.aborted||this.ignoreFragment(i))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(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0;}ignoreFragment(e){return e.type!==K.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1);}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,r,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return this.warn(`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,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=i&&r?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:i}=this;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),l=this.getStarvationDelay(),c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(l){let p=this.findBestLevel(d,a,r,l,0,c,u);if(p>=0)return this.rebufferNotice=-1,p}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){let p=this.bitrateTestDelay;p&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-p,this.info(`bitrate test took ${Math.round(1e3*p)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1);}let f=this.findBestLevel(d,a,r,l,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;let m=i.levels[a],E=i.loadLevelObj;return E&&m?.bitrate<E.bitrate?a:i.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return (r?r.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,r,n,a,o){var d;let l=r+n,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:E,loadLevel:p,config:v}=this.hls;if(m.length===1)return 0;let S=m[u],y=!!((d=this.hls.latestLevelDetails)!=null&&d.live),b=p===-1||c===-1,L,k="SDR",I=S?.frameRate||0,{audioPreference:x,videoPreference:D}=v,_=this.audioTracksByGroup||(this.audioTracksByGroup=yp(E)),M=-1;if(b){if(this.firstSelection!==-1)return this.firstSelection;let j=this.codecTiers||(this.codecTiers=fy(m,_,t,i)),P=hy(j,k,e,x,D),{codecSet:z,videoRanges:Y,minFramerate:U,minBitrate:O,minIndex:se,preferHDR:oe}=P;M=se,L=z,k=oe?Y[Y.length-1]:Y[0],I=U,e=Math.max(e,O),this.log(`picked start tier ${Re(P)}`);}else L=S?.codecSet,k=S?.videoRange;let N=f?f.duration:h?h.duration:0,q=this.bwEstimator.getEstimateTTFB()/1e3,V=[];for(let j=i;j>=t;j--){var H,B;let P=m[j],z=j>u;if(!P)continue;if(v.useMediaCapabilities&&!P.supportedResult&&!P.supportedPromise){let ue=navigator.mediaCapabilities;typeof ue?.decodingInfo=="function"&&iy(P,_,k,I,e,x)?(P.supportedPromise=vp(P,_,ue,this.supportedCache),P.supportedPromise.then(Ie=>{if(!this.hls)return;P.supportedResult=Ie;let tt=this.hls.levels,Ge=tt.indexOf(P);Ie.error?this.warn(`MediaCapabilities decodingInfo error: "${Ie.error}" for level ${Ge} ${Re(Ie)}`):Ie.supported?Ie.decodingInfoResults.some(it=>it.smooth===false||it.powerEfficient===false)&&this.log(`MediaCapabilities decodingInfo for level ${Ge} not smooth or powerEfficient: ${Re(Ie)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Ge} ${Re(Ie)}`),Ge>-1&&tt.length>1&&(this.log(`Removing unsupported level ${Ge}`),this.hls.removeLevel(Ge),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)));})):P.supportedResult=pp;}if((L&&P.codecSet!==L||k&&P.videoRange!==k||z&&I>P.frameRate||!z&&I>0&&I<P.frameRate||(H=P.supportedResult)!=null&&(B=H.decodingInfoResults)!=null&&B.some(ue=>ue.smooth===false))&&(!b||j!==M)){V.push(j);continue}let Y=P.details,U=(f?Y?.partTarget:Y?.averagetargetduration)||N,O;z?O=o*e:O=a*e;let se=N&&r>=N*2&&n===0?P.averageBitrate:P.maxBitrate,oe=this.getTimeToLoadFrag(q,O,se*U,Y===void 0);if(O>=se&&(j===c||P.loadError===0&&P.fragmentError===0)&&(oe<=q||!$(oe)||y&&!this.bitrateTestDelay||oe<l)){let ue=this.forcedAutoLevel;return j!==p&&(ue===-1||ue!==p)&&(V.length&&this.trace(`Skipped level(s) ${V.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[V[0]].codecs}" ${m[V[0]].videoRange}; not compatible with "${L}" ${k}`),this.info(`switch candidate:${u}->${j} adjustedbw(${Math.round(O)})-bitrate=${Math.round(O-se)} ttfb:${q.toFixed(1)} avgDuration:${U.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${oe.toFixed(1)} firstSelection:${b} codecSet:${P.codecSet} videoRange:${P.videoRange} hls.loadLevel:${p}`)),b&&(this.firstSelection=j),j}}return -1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t);}deriveNextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},Sp={search:function(s,e){let t=0,i=s.length-1,r=null,n=null;for(;t<=i;){r=(t+i)/2|0,n=s[r];let a=e(n);if(a>0)t=r+1;else if(a<0)i=r-1;else return n}return null}};function Ey(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!$(e))return null;let i=s[0].programDateTime;if(e<(i||0))return null;let r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let n=0;n<s.length;++n){let a=s[n];if(Ty(e,t,a))return a}return null}function Ts(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[1+s.sn-e[0].sn]||null;let o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&s.level!==n.level&&n.end<=s.end&&(n=e[2+s.sn-e[0].sn]||null);}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&ug(t,i,n)===0||vy(n,s,Math.min(r,i))))return n;let a=Sp.search(e,ug.bind(null,t,i));return a&&(a!==s||!n)?a:n}function vy(s,e,t){if(e&&e.start===0&&e.level<s.level&&(e.endPTS||0)>0){let i=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return s.start<=i}return false}function ug(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function Ty(s,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return (t.endProgramDateTime||0)-i>s}function bp(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments,{fragmentHint:r}=s;r&&(i=i.concat(r));let n;return Sp.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function cl(s){switch(s.details){case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_TIMEOUT:case R.LEVEL_LOAD_TIMEOUT:case R.MANIFEST_LOAD_TIMEOUT:return true}return false}function hg(s,e){let t=cl(e);return s.default[`${t?"timeout":"error"}Retry`]}function gh(s,e){let t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function fg(s){return be(be({},s),{errorRetry:null,timeoutRetry:null})}function ul(s,e,t,i){if(!s)return false;let r=i?.code,n=e<s.maxNumRetry&&(yy(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function yy(s){return s===0&&navigator.onLine===false||!!s&&(s<400||s>499)}var et={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Nt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},iu=class extends bt{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.hls=e,this.registerListeners();}registerListeners(){let e=this.hls;e.on(g.ERROR,this.onError,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this);}unregisterListeners(){let e=this.hls;e&&(e.off(g.ERROR,this.onError,this),e.off(g.ERROR,this.onErrorOut,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this));}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={};}startLoad(e){}stopLoad(){this.playlistError=0;}getVariantLevelIndex(e){return e?.type===K.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={};}onLevelUpdated(){this.playlistError=0;}onError(e,t){var i;if(t.fatal)return;let r=this.hls,n=t.context;switch(t.details){case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case R.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=wn();return}case R.FRAG_GAP:case R.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=et.SendAlternateToPenaltyBox;return}case R.LEVEL_EMPTY_ERROR:case R.LEVEL_PARSING_ERROR:{var a,o;let l=t.parent===K.MAIN?t.level:r.loadLevel;t.details===R.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(o=a.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=false,t.errorAction=this.getLevelSwitchAction(t,l));}return;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case R.AUDIO_TRACK_LOAD_ERROR:case R.AUDIO_TRACK_LOAD_TIMEOUT:case R.SUBTITLE_LOAD_ERROR:case R.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){let l=r.loadLevelObj;if(l&&(n.type===ce.AUDIO_TRACK&&l.hasAudioGroup(n.groupId)||n.type===ce.SUBTITLE_TRACK&&l.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=et.SendAlternateToPenaltyBox,t.errorAction.flags=Nt.MoveAllAlternatesMatchingHost;return}}return;case R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let l=r.loadLevelObj,c=l?.attrs["HDCP-LEVEL"];c?t.errorAction={action:et.SendAlternateToPenaltyBox,flags:Nt.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t);}return;case R.BUFFER_ADD_CODEC_ERROR:case R.REMUX_ALLOC_ERROR:case R.BUFFER_APPEND_ERROR:if(!t.errorAction){var d;t.errorAction=this.getLevelSwitchAction(t,(d=t.level)!=null?d:r.loadLevel);}return;case R.INTERNAL_EXCEPTION:case R.BUFFER_APPENDING_ERROR:case R.BUFFER_FULL_ERROR:case R.LEVEL_SWITCH_ERROR:case R.BUFFER_STALLED_ERROR:case R.BUFFER_SEEK_OVER_HOLE:case R.BUFFER_NUDGE_ON_STALL:t.errorAction=wn();return}t.type===W.KEY_SYSTEM_ERROR&&this.keySystemError(t);}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=false,e.errorAction=this.getLevelSwitchAction(e,t);}getPlaylistRetryOrSwitchAction(e,t){let i=this.hls,r=hg(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(ul(r,n,cl(e),e.response))return {action:et.RetryRequest,flags:Nt.None,retryConfig:r,retryCount:n};let o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=hg(e.details.startsWith("key")?a:n,e),d=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==R.FRAG_GAP&&r.fragmentError++,ul(o,d,cl(e),e.response)))return {action:et.RetryRequest,flags:Nt.None,retryConfig:o,retryCount:d};let l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=d),l}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var n,a;let l=e.details;r.loadError++,l===R.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1,{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);let E=(n=e.frag)==null?void 0:n.type,v=(E===K.AUDIO&&l===R.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===R.BUFFER_ADD_CODEC_ERROR||l===R.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:k})=>r.audioCodec!==k),y=e.sourceBufferName==="video"&&(l===R.BUFFER_ADD_CODEC_ERROR||l===R.BUFFER_APPEND_ERROR)&&u.some(({codecSet:k,audioCodec:I})=>r.codecSet!==k&&r.audioCodec===I),{type:b,groupId:L}=(a=e.context)!=null?a:{};for(let k=u.length;k--;){let I=(k+h)%u.length;if(I!==h&&I>=f&&I<=m&&u[I].loadError===0){var o,d;let x=u[I];if(l===R.FRAG_GAP&&E===K.MAIN&&e.frag){let D=u[I].details;if(D){let _=Ts(e.frag,D.fragments,e.frag.start);if(_!=null&&_.gap)continue}}else {if(b===ce.AUDIO_TRACK&&x.hasAudioGroup(L)||b===ce.SUBTITLE_TRACK&&x.hasSubtitleGroup(L))continue;if(E===K.AUDIO&&(o=r.audioGroups)!=null&&o.some(D=>x.hasAudioGroup(D))||E===K.SUBTITLE&&(d=r.subtitleGroups)!=null&&d.some(D=>x.hasSubtitleGroup(D))||v&&r.audioCodec===x.audioCodec||!v&&r.audioCodec!==x.audioCodec||y&&r.codecSet===x.codecSet)continue}c=I;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=true,this.playlistError=0,{action:et.SendAlternateToPenaltyBox,flags:Nt.None,nextAutoLevel:c}}return {action:et.SendAlternateToPenaltyBox,flags:Nt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case et.DoNothing:break;case et.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==R.FRAG_GAP?t.fatal=true:/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;}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let{flags:r,hdcpLevel:n,nextAutoLevel:a}=i;switch(r){case Nt.None:this.switchLevel(e,a);break;case Nt.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=eu[eu.indexOf(n)-1],i.resolved=true),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,a);}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=true,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===R.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){let i=Jc(e.mimeType),r=this.hls.levels;for(let n=r.length;n--;)r[n][`${e.sourceBufferName}Codec`]===i&&this.hls.removeLevel(n);}}};function wn(s){let e={action:et.DoNothing,flags:Nt.None};return s&&(e.resolved=true),e}var Ke={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},su=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=false,this.hls=e,this._registerListeners();}_registerListeners(){let{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this);}_unregisterListeners(){let{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this);}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null;}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let r=i.length;r--;){let n=i[r];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){return this.getFragAtPos(e,t,true)}getFragAtPos(e,t,i){let{fragments:r}=this,n=Object.keys(r);for(let a=n.length;a--;){let o=r[n[a]];if(o?.body.type===t&&(!i||o.buffered)){let d=o.body;if(d.start<=e&&e<=d.end)return d}}return null}detectEvictedFragments(e,t,i,r,n){this.timeRanges&&(this.timeRanges[e]=t);let a=r?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{let d=this.fragments[o];if(!d||a>=d.body.sn)return;if(!d.buffered&&(!d.loaded||n)){d.body.type===i&&this.removeFragment(d.body);return}let l=d.range[e];if(l){if(l.time.length===0){this.removeFragment(d.body);return}l.time.some(c=>{let u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(d.body),u});}});}detectPartialFragments(e){let t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;let i=e.frag,r=dr(i),n=this.fragments[r];if(!n||n.buffered&&i.gap)return;let a=!i.relurl;Object.keys(t).forEach(o=>{let d=i.elementaryStreams[o];if(!d)return;let l=t[o],c=a||d.partial===true;n.range[o]=this.getBufferedTimes(i,e.part,c,l);}),n.loaded=null,Object.keys(n.range).length?(n.buffered=true,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),Go(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body);}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=mg(i,r=>r.fragment.sn>=e));}fragBuffered(e,t){let i=dr(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:false,range:Object.create(null)},e.gap&&(this.hasGaps=true)),r&&(r.loaded=null,r.buffered=true);}getBufferedTimes(e,t,i,r){let n={time:[],partial:i},a=e.start,o=e.end,d=e.minEndPTS||o,l=e.maxStartPTS||a;for(let c=0;c<r.length;c++){let u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(l>=u&&d<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){let f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=true,n.time.push({startPTS:f,endPTS:m}));}else if(o<=u)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0,{bufferPadding:o,fragments:d}=this;return Object.keys(d).forEach(l=>{let c=d[l];c&&Go(c)&&(r=c.body.start-o,n=c.body.end+o,e>=r&&e<=n&&(i=Math.min(e-r,n-e),a<=i&&(t=c.body,a=i)));}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Go(t))}getState(e){let t=dr(e),i=this.fragments[t];return i?i.buffered?Go(i)?Ke.PARTIAL:Ke.OK:Ke.APPENDING:Ke.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return true;if(t<=r)return false}return false}onManifestLoading(){this.removeAllFragments();}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,n=dr(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:false,range:Object.create(null)};}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:n,type:a}=t;if(i.sn==="initSegment")return;let o=i.type;if(r){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(r);}this.timeRanges=n;let d=n[a];this.detectEvictedFragments(a,d,o,r);}onFragBuffered(e,t){this.detectPartialFragments(t);}hasFragment(e){let t=dr(e);return !!this.fragments[t]}hasFragments(e){let{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){let n=t[i[r]];if(n?.body.type===e)return true}return false}hasParts(e){var t;return !!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let d=o.body;d.type!==i||r&&!d.gap||d.start<t&&d.end>e&&(o.buffered||n)&&this.removeFragment(d);});}removeFragment(e){let t=dr(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let r=e.sn;this.activePartLists[e.type]=mg(i,n=>n.fragment.sn!==r);}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type];}removeAllFragments(){var e,t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=false;let i=(e=this.hls)==null||(t=e.latestLevelDetails)==null?void 0:t.partList;i&&i.forEach(r=>r.clearElementaryStreamInfo());}};function Go(s){var e,t,i;return s.buffered&&(s.body.gap||((e=s.range.video)==null?void 0:e.partial)||((t=s.range.audio)==null?void 0:t.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function dr(s){return `${s.type}_${s.level}_${s.sn}`}function mg(s,e){return s.filter(t=>{let i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Hi={cbc:0,ctr:1},ru=class{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i;}decrypt(e,t){switch(this.aesMode){case Hi.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Hi.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}};function Sy(s){let e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}var nu=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),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],d=this.invSubMix,l=d[0],c=d[1],u=d[2],h=d[3],f=new Uint32Array(256),m=0,E=0,p=0;for(p=0;p<256;p++)p<128?f[p]=p<<1:f[p]=p<<1^283;for(p=0;p<256;p++){let v=E^E<<1^E<<2^E<<3^E<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;let S=f[m],y=f[S],b=f[y],L=f[v]*257^v*16843008;r[m]=L<<24|L>>>8,n[m]=L<<16|L>>>16,a[m]=L<<8|L>>>24,o[m]=L,L=b*16843009^y*65537^S*257^m*16843008,l[v]=L<<24|L>>>8,c[v]=L<<16|L>>>16,u[v]=L<<8|L>>>24,h[v]=L,m?(m=S^f[f[f[b^S]]],E^=f[f[E]]):m=E=1;}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=true,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)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,d,l=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],E=f[1],p=f[2],v=f[3],S,y;for(o=0;o<a;o++){if(o<n){S=l[o]=t[o];continue}y=S,o%n===0?(y=y<<8|y>>>24,y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[y&255],y^=h[o/n|0]<<24):n>6&&o%n===4&&(y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[y&255]),l[o]=S=(l[o-n]^y)>>>0;}for(d=0;d<a;d++)o=a-d,d&3?y=l[o]:y=l[o-4],d<4||o<=4?c[d]=y:c[d]=m[u[y>>>24]]^E[u[y>>>16&255]]^p[u[y>>>8&255]]^v[u[y&255]],c[d]=c[d]>>>0;}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){let r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,d=o[0],l=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(i),f=h[0],m=h[1],E=h[2],p=h[3],v=new Int32Array(e),S=new Int32Array(v.length),y,b,L,k,I,x,D,_,M,N,q,V,H,B,j=this.networkToHostOrderSwap;for(;t<v.length;){for(M=j(v[t]),N=j(v[t+1]),q=j(v[t+2]),V=j(v[t+3]),I=M^n[0],x=V^n[1],D=q^n[2],_=N^n[3],H=4,B=1;B<r;B++)y=d[I>>>24]^l[x>>16&255]^c[D>>8&255]^u[_&255]^n[H],b=d[x>>>24]^l[D>>16&255]^c[_>>8&255]^u[I&255]^n[H+1],L=d[D>>>24]^l[_>>16&255]^c[I>>8&255]^u[x&255]^n[H+2],k=d[_>>>24]^l[I>>16&255]^c[x>>8&255]^u[D&255]^n[H+3],I=y,x=b,D=L,_=k,H=H+4;y=a[I>>>24]<<24^a[x>>16&255]<<16^a[D>>8&255]<<8^a[_&255]^n[H],b=a[x>>>24]<<24^a[D>>16&255]<<16^a[_>>8&255]<<8^a[I&255]^n[H+1],L=a[D>>>24]<<24^a[_>>16&255]<<16^a[I>>8&255]<<8^a[x&255]^n[H+2],k=a[_>>>24]<<24^a[I>>16&255]<<16^a[x>>8&255]<<8^a[D&255]^n[H+3],S[t]=j(y^f),S[t+1]=j(k^m),S[t+2]=j(L^E),S[t+3]=j(b^p),f=M,m=N,E=q,p=V,t=t+4;}return S.buffer}},au=class{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i;}expandKey(){let e=by(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},false,["encrypt","decrypt"])}};function by(s){switch(s){case Hi.cbc:return "AES-CBC";case Hi.ctr:return "AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}var Ay=16,Pn=class{constructor(e,{removePKCS7Padding:t=true}={}){if(this.logEnabled=true,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.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let i=self.crypto;i&&(this.subtle=i.subtle||i.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 i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Sy(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null);}decrypt(e,t,i,r){return this.useSoftware?new Promise((n,a)=>{let o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,r);let d=this.flush();d?n(d.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"));}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:n,currentResult:a,remainderData:o}=this;if(r!==Hi.cbc||t.byteLength!==16)return Ee.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Rt(o,e),this.remainderData=null);let d=this.getValidChunk(e);if(!d.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new nu),l.expandKey(t);let c=a;return this.currentResult=l.decrypt(d.buffer,0,i),this.currentIV=d.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new au(this.subtle,t,r);}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new ru(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(Ee.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){let n=this.enableSoftwareAES;if(n){this.useSoftware=true,this.logEnabled=true,this.softwareDecrypt(e,t,i,r);let a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%Ay;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Ee.log(`[decrypter]: ${e}`),this.logEnabled=false);}},gg=Math.pow(2,17),ou=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 i=e.url;if(!i)return Promise.reject(new Ft({type:W.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:false,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();let r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){d(Eg(e));return}else e.gap=false;let l=this.loader=n?new n(r):new a(r),c=pg(e);e.loader=l;let u=fg(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:gg};e.stats=l.stats;let f={onSuccess:(m,E,p,v)=>{this.resetLoader(e,l);let S=m.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),o({frag:e,part:null,payload:S,networkDetails:v});},onError:(m,E,p,v)=>{this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:false,frag:e,response:be({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:p,stats:v}));},onAbort:(m,E,p)=>{this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:false,frag:e,error:new Error("Aborted"),networkDetails:p,stats:m}));},onTimeout:(m,E,p)=>{this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:m}));}};t&&(f.onProgress=(m,E,p,v)=>t({frag:e,part:null,payload:p,networkDetails:v})),l.load(c,h,f);})}loadPart(e,t,i){this.abort();let r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){d(Eg(e,t));return}let l=this.loader=n?new n(r):new a(r),c=pg(e,t);e.loader=l;let u=fg(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:gg};t.stats=l.stats,l.load(c,h,{onSuccess:(f,m,E,p)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);let v={frag:e,part:t,payload:f.data,networkDetails:p};i(v),o(v);},onError:(f,m,E,p)=>{this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:false,frag:e,part:t,response:be({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:p}));},onAbort:(f,m,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:false,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:f}));},onTimeout:(f,m,E)=>{this.resetLoader(e,l),d(new Ft({type:W.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}));}});})}updateStatsFromPart(e,t){let i=e.stats,r=t.stats,n=r.total;if(i.loaded+=r.loaded,n){let d=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/n),d),u=(d-l)*Math.round(i.loaded/l);i.total=i.loaded+u;}else i.total=Math.max(i.loaded,i.total);let a=i.loading,o=r.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 pg(s,e=null){let t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if($(r)&&$(n)){var a;let o=r,d=n;if(s.sn==="initSegment"&&_y((a=s.decryptdata)==null?void 0:a.method)){let l=n-r;l%16&&(d=n+(16-l%16)),r!==0&&(i.resetIV=true,o=r-16);}i.rangeStart=o,i.rangeEnd=d;}return i}function Eg(s,e){let t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:W.MEDIA_ERROR,details:R.FRAG_GAP,fatal:false,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=true,new Ft(i)}function _y(s){return s==="AES-128"||s==="AES-256"}var Ft=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e;}},hl=class extends bt{constructor(e,t){super(e,t),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?false:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),true)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,true):false}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,true):false}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(){}},On=class{constructor(e,t,i,r=0,n=-1,a=false){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=Ho(),this.buffering={audio:Ho(),video:Ho(),audiovideo:Ho()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a;}};function Ho(){return {start:0,executeStart:0,executeEnd:0,end:0}}var vg={length:0,start:()=>0,end:()=>0},ne=class s{static isBuffered(e,t){if(e){let i=s.getBuffered(e);for(let r=i.length;r--;)if(t>=i.start(r)&&t<=i.end(r))return true}return false}static bufferedRanges(e){if(e){let t=s.getBuffered(e);return s.timeRangesToArray(t)}return []}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let r=s.bufferedRanges(e);if(r.length)return s.bufferedInfo(r,t,i)}return {len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let r=-1,n=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(r=c);let u=n.length;if(u){let h=n[u-1].end;e[c].start-h<i?e[c].end>h&&(n[u-1].end=e[c].end):n.push(e[c]);}else n.push(e[c]);}else n=e;let a=0,o,d=t,l=t;for(let c=0;c<n.length;c++){let u=n[c].start,h=n[c].end;if(r===-1&&t>=u&&t<=h&&(r=c),t+i>=u&&t<h)d=u,l=h,a=l-t;else if(t+i<u){o=u;break}}return {len:a,start:d||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||vg}catch(t){return Ee.log("failed to get media.buffered",t),vg}}},Ap=/\{\$([a-zA-Z0-9-_]+)\}/g;function Tg(s){return Ap.test(s)}function lu(s,e){if(s.variableList!==null||s.hasVariableRefs){let t=s.variableList;return e.replace(Ap,i=>{let r=i.substring(2,i.length-1),n=t?.[r];return n===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):n})}return e}function yg(s,e,t){let i=s.variableList;i||(s.variableList=i={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`));}}else r=e.NAME,n=e.VALUE;r in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=n||"";}function Iy(s,e,t){let i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i];}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`));}var Ly=/^(\d+)x(\d+)$/,Sg=/(.+?)=(".*?"|.*?)(?:,|$)/g,Pe=class s{constructor(e,t){typeof e=="string"&&(e=s.parseAttrList(e,t)),Te(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 i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}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 i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return (i?i.split(/[ ,]+/):[]).reduce((r,n)=>(r[n.toLowerCase()]=true,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Ly.exec(this[e]);if(t!==null)return {width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i,r={},n='"';for(Sg.lastIndex=0;(i=Sg.exec(e))!==null;){let a=i[1].trim(),o=i[2],d=o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1,l=false;if(d)o=o.slice(1,-1);else switch(a){case "IV":case "SCTE35-CMD":case "SCTE35-IN":case "SCTE35-OUT":l=true;}if(t&&(d||l))o=lu(t,o);else if(!l&&!d)switch(a){case "CLOSED-CAPTIONS":if(o==="NONE")break;case "ALLOWED-CPC":case "CLASS":case "ASSOC-LANGUAGE":case "AUDIO":case "BYTERANGE":case "CHANNELS":case "CHARACTERISTICS":case "CODECS":case "DATA-ID":case "END-DATE":case "GROUP-ID":case "ID":case "IMPORT":case "INSTREAM-ID":case "KEYFORMAT":case "KEYFORMATVERSIONS":case "LANGUAGE":case "NAME":case "PATHWAY-ID":case "QUERYPARAM":case "RECENTLY-REMOVED-DATERANGES":case "SERVER-URI":case "STABLE-RENDITION-ID":case "STABLE-VARIANT-ID":case "START-DATE":case "SUBTITLES":case "SUPPLEMENTAL-CODECS":case "URI":case "VALUE":case "VIDEO":case "X-ASSET-LIST":case "X-ASSET-URI":Ee.warn(`${e}: attribute ${a} is missing quotes`);}r[a]=o;}return r}},xy="com.apple.hls.interstitial";function Ry(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Dy(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}var fl=class{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:i,t){let n=t.attr;for(let a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){Ee.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=Te(new Pe({}),n,e);}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let n=t?.endDate||new Date(this.attr["END-DATE"]);$(n.getTime())&&(this._endDate=n);}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){let e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:false,post:false,once:false}):e}get startTime(){let{tagAnchor:e}=this;return e===null||e.programDateTime===null?(Ee.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){let e=this._endDate||this._dateAtEnd;if(e)return e;let t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if($(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 isInterstitial(){return this.class===xy}get isValid(){return !!this.id&&!this._badValueForSameId&&$(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}},ky=10,du=class{constructor(e){this.PTSKnown=false,this.alignedSliding=false,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.dateRangeTagCount=0,this.live=true,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=true,this.advanced=true,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=false,this.canSkipUntil=0,this.canSkipDateRanges=false,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=false,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e;}reloaded(e){if(!e){this.advanced=true,this.updated=true;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1;}get hasProgramDateTime(){return this.fragments.length?$(this.fragments[this.fragments.length-1].programDateTime):false}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||ky}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 fragmentStart(){var e;return (e=this.fragments)!=null&&e.length?this.fragments[0].start: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 maxPartIndex(){let e=this.partList;if(e){let t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){let e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return false}};function gr(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function ph(s){switch(s){case "AES-128":case "AES-256":return Hi.cbc;case "AES-256-CTR":return Hi.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function _p(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function cu(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function Cy(s){let e=cu(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function My(s){let e=function(i,r,n){let a=i[r];i[r]=i[n],i[n]=a;};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7);}function wy(s){let e=s.split(":"),t=null;if(e[0]==="data"&&e.length===2){let i=e[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){let n=r[0]==="base64",a=r[1];n?(i.splice(-1,1),t=_p(a)):t=Cy(a);}}return t}var ml=typeof self<"u"?self:void 0,Ue={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ft={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function uu(s){switch(s){case ft.FAIRPLAY:return Ue.FAIRPLAY;case ft.PLAYREADY:return Ue.PLAYREADY;case ft.WIDEVINE:return Ue.WIDEVINE;case ft.CLEARKEY:return Ue.CLEARKEY}}function bg(s){switch(s){case Ue.FAIRPLAY:return ft.FAIRPLAY;case Ue.PLAYREADY:return ft.PLAYREADY;case Ue.WIDEVINE:return ft.WIDEVINE;case Ue.CLEARKEY:return ft.CLEARKEY}}function Jo(s){let{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[Ue.FAIRPLAY,Ue.WIDEVINE,Ue.PLAYREADY,Ue.CLEARKEY].filter(r=>!!e[r]):[];return !i[Ue.WIDEVINE]&&t&&i.push(Ue.WIDEVINE),i}var Ip=function(s){return ml!=null&&(s=ml.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Py(s,e,t,i){let r;switch(s){case Ue.FAIRPLAY:r=["cenc","sinf"];break;case Ue.WIDEVINE:case Ue.PLAYREADY:r=["cenc"];break;case Ue.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Oy(r,e,t,i)}function Oy(s,e,t,i){return [{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Ny(s){var e;return s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license"))}function Fy(s){let e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let d=_p(o).subarray(0,16);return My(d),d}}return null}var Vo={},gl=class s{static clearKeyUriToKeyIdMap(){Vo={};}constructor(e,t,i,r=[1],n=null,a){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=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":false,this.isCommonEncryption=this.encrypted&&!gr(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(lp(a)));}matches(e){var t,i;return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&e.keyFormatVersions.join(",")===this.keyFormatVersions.join(",")&&((t=e.iv)==null?void 0:t.join(","))===((i=this.iv)==null?void 0:i.join(","))}isSupported(){if(this.method){if(gr(this.method)||this.method==="NONE")return true;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ft.FAIRPLAY:case ft.WIDEVINE:case ft.PLAYREADY:case ft.CLEARKEY:return ["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return false}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(gr(this.method)&&this.uri&&!this.iv){typeof e!="number"&&(Ee.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let i=Uy(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.pssh&&this.keyId)return this;let t=wy(this.uri);if(t)switch(this.keyFormat){case ft.WIDEVINE:if(this.pssh=t,!this.keyId&&t.length>=22){let i=t.length-22;this.keyId=t.subarray(i,i+16);}break;case ft.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=QT(i,null,t),this.keyId=Fy(t);break}default:{let i=t.subarray(0,16);if(i.length!==16){let r=new Uint8Array(16);r.set(i,16-i.length),i=r;}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Vo[this.uri];if(!i){let r=Object.keys(Vo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,r),Vo[this.uri]=i;}this.keyId=i;}return this}};function Uy(s){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}var Ag=/#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,_g=/#EXT-X-MEDIA:(.*)/g,By=/^#EXT(?:INF|-X-TARGETDURATION):/m,Mc=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),$y=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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("|")),gs=class s{static findGroup(e,t){for(let i=0;i<e.length;i++){let r=e[i];if(r.id===t)return r}}static resolve(e,t){return uh.buildAbsoluteURL(t,e,{alwaysNormalize:true})}static isMediaPlaylist(e){return By.test(e)}static parseMasterPlaylist(e,t){let i=Tg(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];Ag.lastIndex=0;let a;for(;(a=Ag.exec(e))!=null;)if(a[1]){var o;let l=new Pe(a[1],r),c=lu(r,a[2]),u={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:s.resolve(c,t)},h=l.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),xg(l.CODECS,u);let f=l["SUPPLEMENTAL-CODECS"];f&&(u.supplemental={},xg(f,u.supplemental)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),r.levels.push(u);}else if(a[3]){let l=a[3],c=a[4];switch(l){case "SESSION-DATA":{let u=new Pe(c,r),h=u["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=u);break}case "SESSION-KEY":{let u=Ig(c,t,r);u.encrypted&&u.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(u)):Ee.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case "DEFINE":{{let u=new Pe(c,r);yg(r,u,t);}break}case "CONTENT-STEERING":{let u=new Pe(c,r);r.contentSteering={uri:s.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case "START":{r.startTimeOffset=Lg(c);break}}}let d=n.length>0&&n.length<r.levels.length;return r.levels=d?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r,n={},a=i.levels,o={AUDIO:a.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec})),SUBTITLES:a.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]},d=0;for(_g.lastIndex=0;(r=_g.exec(e))!==null;){let l=new Pe(r[1],i),c=l.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h;let f=l.LANGUAGE,m=l["ASSOC-LANGUAGE"],E=l.CHANNELS,p=l.CHARACTERISTICS,v=l["INSTREAM-ID"],S={attrs:l,bitrate:0,id:d++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:c,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?s.resolve(l.URI,t):""};if(m&&(S.assocLang=m),E&&(S.channels=E),p&&(S.characteristics=p),v&&(S.instreamId=v),u!=null&&u.length){let y=s.findGroup(u,S.groupId)||u[0];Rg(S,y,"audioCodec"),Rg(S,y,"textCodec");}h.push(S);}}return n}static parseLevelPlaylist(e,t,i,r,n,a){var o;let d={url:t},l=new du(t),c=l.fragments,u=[],h=null,f=0,m=0,E=0,p=0,v=0,S=null,y=new xn(r,d),b,L,k,I=-1,x=false,D=null,_;if(Mc.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Tg(e),((o=Mc.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(b=Mc.exec(e))!==null;){x&&(x=false,y=new xn(r,d),y.playlistOffset=E,y.start=E,y.sn=f,y.cc=p,v&&(y.bitrate=v),y.level=i,h&&(y.initSegment=h,h.rawProgramDateTime&&(y.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),D&&(y.setByteRange(D),D=null)));let V=b[1];if(V){y.duration=parseFloat(V);let H=(" "+b[2]).slice(1);y.title=H||null,y.tagList.push(H?["INF",V,H]:["INF",V]);}else if(b[3]){if($(y.duration)){y.playlistOffset=E,y.start=E,k&&kg(y,k,l),y.sn=f,y.level=i,y.cc=p,c.push(y);let H=(" "+b[3]).slice(1);y.relurl=lu(l,H),hu(y,S,u),S=y,E+=y.duration,f++,m=0,x=true;}}else {if(b=b[0].match($y),!b){Ee.warn("No matches on slow regex match for level playlist!");continue}for(L=1;L<b.length&&b[L]===void 0;L++);let H=(" "+b[L]).slice(1),B=(" "+b[L+1]).slice(1),j=b[L+2]?(" "+b[L+2]).slice(1):null;switch(H){case "BYTERANGE":S?y.setByteRange(B,S):y.setByteRange(B);break;case "PROGRAM-DATE-TIME":y.rawProgramDateTime=B,y.tagList.push(["PROGRAM-DATE-TIME",B]),I===-1&&(I=c.length);break;case "PLAYLIST-TYPE":l.type&&Ti(l,H,b),l.type=B.toUpperCase();break;case "MEDIA-SEQUENCE":l.startSN!==0?Ti(l,H,b):c.length>0&&Cg(l,H,b),f=l.startSN=parseInt(B);break;case "SKIP":{l.skippedSegments&&Ti(l,H,b);let P=new Pe(B,l),z=P.decimalInteger("SKIPPED-SEGMENTS");if($(z)){l.skippedSegments+=z;for(let U=z;U--;)c.push(null);f+=z;}let Y=P.enumeratedString("RECENTLY-REMOVED-DATERANGES");Y&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(Y.split(" ")));break}case "TARGETDURATION":l.targetduration!==0&&Ti(l,H,b),l.targetduration=Math.max(parseInt(B),1);break;case "VERSION":l.version!==null&&Ti(l,H,b),l.version=parseInt(B);break;case "INDEPENDENT-SEGMENTS":break;case "ENDLIST":l.live||Ti(l,H,b),l.live=false;break;case "#":(B||j)&&y.tagList.push(j?[B,j]:[B]);break;case "DISCONTINUITY":p++,y.tagList.push(["DIS"]);break;case "GAP":y.gap=true,y.tagList.push([H]);break;case "BITRATE":y.tagList.push([H,B]),v=parseInt(B)*1e3,$(v)?y.bitrate=v:v=0;break;case "DATERANGE":{let P=new Pe(B,l),z=new fl(P,l.dateRanges[P.ID],l.dateRangeTagCount);l.dateRangeTagCount++,z.isValid||l.skippedSegments?l.dateRanges[z.id]=z:Ee.warn(`Ignoring invalid DATERANGE tag: "${B}"`),y.tagList.push(["EXT-X-DATERANGE",B]);break}case "DEFINE":{{let P=new Pe(B,l);"IMPORT"in P?Iy(l,P,a):yg(l,P,t);}break}case "DISCONTINUITY-SEQUENCE":l.startCC!==0?Ti(l,H,b):c.length>0&&Cg(l,H,b),l.startCC=p=parseInt(B);break;case "KEY":{let P=Ig(B,t,l);if(P.isSupported()){if(P.method==="NONE"){k=void 0;break}k||(k={});let z=k[P.keyFormat];z!=null&&z.matches(P)||(z&&(k=Te({},k)),k[P.keyFormat]=P);}else Ee.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${B}"`);break}case "START":l.startTimeOffset=Lg(B);break;case "MAP":{let P=new Pe(B,l);if(y.duration){let z=new xn(r,d);Dg(z,P,i,k),h=z,y.initSegment=h,h.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=h.rawProgramDateTime);}else {let z=y.byteRangeEndOffset;if(z){let Y=y.byteRangeStartOffset;D=`${z-Y}@${Y}`;}else D=null;Dg(y,P,i,k),h=y,x=true;}h.cc=p;break}case "SERVER-CONTROL":{_&&Ti(l,H,b),_=new Pe(B),l.canBlockReload=_.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=_.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&_.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=_.optionalFloat("PART-HOLD-BACK",0),l.holdBack=_.optionalFloat("HOLD-BACK",0);break}case "PART-INF":{l.partTarget&&Ti(l,H,b);let P=new Pe(B);l.partTarget=P.decimalFloatingPoint("PART-TARGET");break}case "PART":{let P=l.partList;P||(P=l.partList=[]);let z=m>0?P[P.length-1]:void 0,Y=m++,U=new Pe(B,l),O=new Xc(U,y,d,Y,z);P.push(O),y.duration+=O.duration;break}case "PRELOAD-HINT":{let P=new Pe(B,l);l.preloadHint=P;break}case "RENDITION-REPORT":{let P=new Pe(B,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(P);break}default:Ee.warn(`line parsed but not handled: ${b}`);break}}}S&&!S.relurl?(c.pop(),E-=S.duration,l.partList&&(l.fragmentHint=S)):l.partList&&(hu(y,S,u),y.cc=p,l.fragmentHint=y,k&&kg(y,k,l)),l.targetduration||(l.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));let M=c.length,N=c[0],q=c[M-1];if(E+=l.skippedSegments*l.targetduration,E>0&&M&&q){l.averagetargetduration=E/M;let V=q.sn;l.endSN=V!=="initSegment"?V:0,l.live||(q.endList=true),N&&l.startCC===void 0&&(l.startCC=N.cc),I>0&&(Hy(c,I),N&&u.unshift(N));}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(E+=l.fragmentHint.duration),l.totalduration=E,u.length&&l.dateRangeTagCount&&N&&Lp(u,l),l.endCC=p,l}};function Lp(s,e){let t=s.length;if(!t)return;let i=s[t-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let a=n.length;a--;){let o=e.dateRanges[n[a]],d=o.startDate.getTime();o.tagAnchor=i.ref;for(let l=t;l--;){let c=Gy(e,d,s,l,r);if(c!==-1){o.tagAnchor=e.fragments[c].ref;break}}}}function Gy(s,e,t,i,r){let n=t[i];if(n){let o=n.programDateTime;if(e>=o||i===0){var a;let d=(((a=t[i+1])==null?void 0:a.start)||r)-n.start;if(e<=o+d*1e3){let l=t[i].sn-s.startSN,c=s.fragments;if(c.length>t.length){let h=(t[i+1]||c[c.length-1]).sn-s.startSN;for(let f=h;f>l;f--){let m=c[f].programDateTime;if(e>=m&&e<m+c[f].duration*1e3)return f}}return l}}}return -1}function Ig(s,e,t){var i,r;let n=new Pe(s,t),a=(i=n.METHOD)!=null?i:"",o=n.URI,d=n.hexadecimalInteger("IV"),l=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!d&&Ee.error(`Invalid IV: ${n.IV}`);let u=o?gs.resolve(o,e):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new gl(a,u,c,h,d,n.KEYID)}function Lg(s){let t=new Pe(s).decimalFloatingPoint("TIME-OFFSET");return $(t)?t:null}function xg(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{let r=t.filter(n=>fh(n,i));r.length&&(e[`${i}Codec`]=r.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>r.indexOf(n)===-1));}),e.unknownCodecs=t;}function Rg(s,e,t){let i=e[t];i&&(s[t]=i);}function Hy(s,e){let t=s[e];for(let i=e;i--;){let r=s[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r;}}function hu(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime);}function Dg(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null;}function kg(s,e,t){s.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s);}function Ti(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`);}function Cg(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`);}function wc(s,e){let t=e.startPTS;if($(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&r.setDuration(i);}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0));}function xp(s,e,t,i,r,n){i-t<=0&&(Ee.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let o=t,d=i,l=e.startPTS,c=e.endPTS;if($(l)){let p=Math.abs(l-t);$(e.deltaPTS)?e.deltaPTS=Math.max(p,e.deltaPTS):e.deltaPTS=p,o=Math.max(t,l),t=Math.min(t,l),r=Math.min(r,e.startDTS),d=Math.min(i,c),i=Math.max(i,c),n=Math.max(n,e.endDTS);}let u=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=i,e.minEndPTS=d,e.endDTS=n;let h=e.sn;if(!s||h<s.startSN||h>s.endSN)return 0;let f,m=h-s.startSN,E=s.fragments;for(E[m]=e,f=m;f>0;f--)wc(E[f],E[f-1]);for(f=m;f<E.length-1;f++)wc(E[f],E[f+1]);return s.fragmentHint&&wc(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=true,u}function Vy(s,e){if(s===e)return;let t=null,i=s.fragments;for(let l=i.length-1;l>=0;l--){let c=i[l].initSegment;if(c){t=c;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r;qy(s,e,(l,c,u,h)=>{if((!e.startCC||e.skippedSegments)&&c.cc!==l.cc){let f=l.cc-c.cc;for(let m=u;m<h.length;m++)h[m].cc+=f;e.endCC=h[h.length-1].cc;}$(l.startPTS)&&$(l.endPTS)&&(c.setStart(c.startPTS=l.startPTS),c.startDTS=l.startDTS,c.maxStartPTS=l.maxStartPTS,c.endPTS=l.endPTS,c.endDTS=l.endDTS,c.minEndPTS=l.minEndPTS,c.setDuration(l.endPTS-l.startPTS),c.duration&&(r=c),e.PTSKnown=e.alignedSliding=true),l.hasStreams&&(c.elementaryStreams=l.elementaryStreams),c.loader=l.loader,l.hasStats&&(c.stats=l.stats),l.initSegment&&(c.initSegment=l.initSegment,t=l.initSegment);});let n=e.fragments,a=e.fragmentHint?n.concat(e.fragmentHint):n;if(t&&a.forEach(l=>{var c;l&&(!l.initSegment||l.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(l.initSegment=t);}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(l=>!l),e.deltaUpdateFailed){Ee.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)n.shift();e.startSN=n[0].sn;}else {e.canSkipDateRanges&&(e.dateRanges=Ky(s.dateRanges,e));let l=s.fragments.filter(c=>c.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let c=1;c<a.length;c++)a[c].programDateTime===null&&hu(a[c],a[c-1],l);Lp(l,e);}e.endCC=n[n.length-1].cc;}if(!e.startCC){var o;let l=kp(s,e.startSN-1);e.startCC=(o=l?.cc)!=null?o:n[0].cc;}Wy(s.partList,e.partList,(l,c)=>{c.elementaryStreams=l.elementaryStreams,c.stats=l.stats;}),r?xp(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Rp(s,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;let d=e.advancedDateTime;if(e.advanced&&d){let l=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=l),e.driftEndTime=d,e.driftEnd=l;}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled);}function Ky(s,e){let{dateRanges:t,recentlyRemovedDateranges:i}=e,r=Te({},s);i&&i.forEach(o=>{delete r[o];});let a=Object.keys(r).length;return a&&Object.keys(t).forEach(o=>{let d=r[o],l=new fl(t[o].attr,d);l.isValid?(r[o]=l,d||(l.tagOrder+=a)):Ee.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Re(t[o].attr)}"`);}),r}function Wy(s,e,t){if(s&&e){let i=0;for(let r=0,n=s.length;r<=n;r++){let a=s[r],o=e[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--;}}}function qy(s,e,t){let i=e.skippedSegments,r=Math.max(s.startSN,e.startSN)-e.startSN,n=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let l=r;l<=n;l++){let c=d[a+l],u=o[l];if(i&&!u&&c&&(u=e.fragments[l]=c),c&&u){if(t(c,u,l,o),c.url&&c.url!==u.url){e.playlistParsingError=Mg(`media sequence mismatch ${u.sn}:`,s,e,c,u);return}else if(c.cc!==u.cc){e.playlistParsingError=Mg(`discontinuity sequence mismatch (${c.cc}!=${u.cc})`,s,e,c,u);return}}}}function Mg(s,e,t,i,r){return new Error(`${s} ${r.url}
|
|
1699
|
-
Playlist starting @${e.startSN}
|
|
1700
|
-
${e.m3u8}
|
|
1701
|
-
|
|
1702
|
-
Playlist starting @${t.startSN}
|
|
1703
|
-
${t.m3u8}`)}function Rp(s,e,t=true){let i=e.startSN+e.skippedSegments-s.startSN,r=s.fragments,n=i>=0,a=0;if(n&&i<r.length)a=r[i].start;else if(n&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(n&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;fu(e,a);}function fu(s,e){if(e){let t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e);}}function Dp(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){let i=s.fragments;if(i.length&&t*4>e){let n=i[i.length-1].duration*1e3;n<t&&(t=n);}}else t/=2;return Math.round(t)}function kp(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function wg(s,e,t){return s?Cp(s.partList,e,t):null}function Cp(s,e,t){if(s)for(let i=s.length;i--;){let r=s[i];if(r.index===t&&r.fragment.sn===e)return r}return null}function Mp(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t);});});}function Rn(s,e){for(let i=0,r=s.length;i<r;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function Yy(s,e){return !!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function Pg(s,e){if(s){let t=s.start+e;s.start=s.startPTS=t,s.endPTS=t+s.duration;}}function wp(s,e){let t=e.fragments;for(let i=0,r=t.length;i<r;i++)Pg(t[i],s);e.fragmentHint&&Pg(e.fragmentHint,s),e.alignedSliding=true;}function jy(s,e){s&&(Pp(e,s),!e.alignedSliding&&s&&pl(e,s),!e.alignedSliding&&s&&!e.skippedSegments&&Rp(s,e,false));}function Pp(s,e){if(!Yy(e,s))return;let t=Math.min(e.endCC,s.endCC),i=Rn(e.fragments,t),r=Rn(s.fragments,t);if(!i||!r)return;Ee.log(`Aligning playlist at start of dicontinuity sequence ${t}`);let n=i.start-r.start;wp(n,s);}function pl(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;let t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;let r,n,a=Math.min(e.endCC,s.endCC);e.startCC<a&&s.startCC<a&&(r=Rn(i,a),n=Rn(t,a)),(!r||!n)&&(r=i[Math.floor(i.length/2)],n=Rn(t,r.cc)||t[Math.floor(t.length/2)]);let o=r.programDateTime,d=n.programDateTime;if(!o||!d)return;let l=(d-o)/1e3-(n.start-r.start);wp(l,s);}var zy={toString:function(s){let e="",t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},C={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"},Nn=class extends hl{constructor(e,t,i,r,n){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=C.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=false,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=false,this.decrypter=void 0,this.initPTS=[],this.buffering=true,this.loadingParts=false,this.loopSn=void 0,this.onMediaSeeking=()=>{let{config:a,fragCurrent:o,media:d,mediaBuffer:l,state:c}=this,u=d?d.currentTime:0,h=ne.bufferInfo(l||d,u,a.maxBufferHole),f=!h.len;if(this.log(`Media seeking to ${$(u)?u.toFixed(3):u}, state: ${c}, ${f?"out of":"in"} buffer`),this.state===C.ENDED)this.resetLoadingState();else if(o){let m=a.maxFragLookUpTolerance,E=o.start-m,p=o.start+o.duration+m;if(f||p<h.start||E>h.end){let v=u>p;(u<E||v)&&(v&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null);}}if(d){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,true);let m=this.lastCurrentTime;if(u>m&&(this.lastCurrentTime=u),!this.loadingParts){let E=Math.max(h.end,u),p=this.shouldLoadParts(this.getLevelDetails(),E);p&&(this.log(`LL-Part loading ON after seeking to ${u.toFixed(2)} with buffer @${E.toFixed(2)}`),this.loadingParts=p);}}this.hls.hasEnoughToStart||(this.log(`Setting ${f?"startPosition":"nextLoadPosition"} to ${u} for seek without enough to start`),this.nextLoadPosition=u,f&&(this.startPosition=u)),this.tickImmediate();},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0;},this.playlistType=n,this.hls=e,this.fragmentLoader=new ou(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Pn(e.config);}registerListeners(){let{hls:e}=this;e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.ERROR,this.onError,this);}doTick(){this.onTickEnd();}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===C.STOPPED)return;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=C.STOPPED;}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=false;}resumeBuffering(){this.buffering=true;}get inFlightFrag(){return {frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return false;let i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return false;let n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=ne.bufferedInfo(n,e.start,0));let a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return false;let d=t.partList;if(d!=null&&d.length){let c=d[d.length-1];return ne.isBuffered(this.media,c.start+c.duration/2)}let l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return (e=this.levelLastLoaded)==null?void 0:e.details}}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return ((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;i.removeEventListener("seeking",this.onMediaSeeking),i.removeEventListener("ended",this.onMediaEnded),i.addEventListener("seeking",this.onMediaSeeking),i.addEventListener("ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===C.STOPPED&&this.startLoad(r.startPosition);}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r.removeEventListener("seeking",this.onMediaSeeking),r.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=false,this.fragmentTracker.removeAllFragments(),this.stopLoad();}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=false;}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset;}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null;}onHandlerDestroyed(){this.state=C.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,i){this.startFragRequested=true,this._loadFragForPlayback(e,t,i);}_loadFragForPlayback(e,t,i){let r=n=>{let a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,false,n.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(n);};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;let a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===C.FRAG_LOADING||!this.fragCurrent&&a===C.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=C.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(g.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n);}).catch(n=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(`Frag error: ${n?.message||n}`),this.resetFragmentLoading(e));});}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===Ke.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),d=this.backtrackFragment;((d?e.sn-d.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e);}else ((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Ke.PARTIAL&&i.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=true);}waitForLive(e){let t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(g.BUFFER_FLUSHING,r);}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{let r=i?.frag;if(!r||this.fragContextChanged(r)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:r}=this,{frag:n,payload:a}=i,o=n.decryptdata;if(a&&a.byteLength>0&&o!=null&&o.key&&o.iv&&gr(o.method)){let d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer,ph(o.method)).catch(l=>{throw r.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:false,error:l,reason:l.message,frag:n}),l}).then(l=>{let c=self.performance.now();return r.trigger(g.FRAG_DECRYPTED,{frag:n,payload:l,stats:{tstart:d,tdecrypt:c}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let i=e.frag.stats;this.state!==C.STOPPED&&(this.state=C.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.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){let i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)} > buffer:${i?zy.toString(ne.getBuffered(i)):"(detached)"})`),$e(e)){var r;if(e.type!==K.SUBTITLE){let a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=C.IDLE;return}}let n=(r=this.levels)==null?void 0:r[e.level];n!=null&&n.fragmentError&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0);}this.state=C.IDLE;}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(d=>!d),o=new On(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o);}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var n;this.fragCurrent=e;let a=t?.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=C.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(g.KEY_LOADED,u),this.state===C.KEY_LOADING&&(this.state=C.IDLE),u}),this.hls.trigger(g.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));let d=this.fragPrevious;if($e(e)&&(!d||e.sn!==d.sn)){let u=this.shouldLoadParts(t.details,e.end);u!==this.loadingParts&&(this.log(`LL-Part loading ${u?"ON":"OFF"} loading sn ${d?.sn}->${e.sn}`),this.loadingParts=u);}if(i=Math.max(e.start,i||0),this.loadingParts&&$e(e)){let u=a.partList;if(u&&r){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);let h=this.getNextPart(u,e,i);if(h>-1){let f=u[h];e=this.fragCurrent=f.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${f.index} (${h}/${u.length-1}) of ${this.fragInfo(e,false,f)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=f.start+f.duration,this.state=C.FRAG_LOADING;let m;return o?m=o.then(E=>!E||this.fragContextChanged(E.frag)?null:this.doFragPartsLoad(e,f,t,r)).catch(E=>this.handleFragLoadError(E)):m=this.doFragPartsLoad(e,f,t,r).catch(E=>this.handleFragLoadError(E)),this.hls.trigger(g.FRAG_LOADING,{frag:e,part:f,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!e.url||this.loadedEndOfParts(u,i))return Promise.resolve(null)}}if($e(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)}`),this.loadingParts=false;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,false)}) cc: ${e.cc} ${a?"["+a.startSN+"-"+a.endSN+"]":""}, target: ${parseFloat(i.toFixed(3))}`),$(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=C.FRAG_LOADING;let l=this.config.progressive,c;return l&&o?c=o.then(u=>!u||this.fragContextChanged(u?.frag)?null:this.fragmentLoader.load(e,r)).catch(u=>this.handleFragLoadError(u)):c=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([u])=>(!l&&u&&r&&r(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(g.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;let d=[],l=(o=i.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,r).then(h=>{d[u.index]=h;let f=h.part;this.hls.trigger(g.FRAG_LOADED,h);let m=wg(i.details,e.sn,u.index+1)||Cp(l,e.sn,u.index+1);if(m)c(m);else return n({frag:e,part:f,partsLoaded:d})}).catch(a);};c(t);})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===R.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(g.ERROR,t);}else this.hls.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,err:e,error:e,fatal:true});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==C.PARSING){!this.fragCurrent&&this.state!==C.STOPPED&&this.state!==C.ERROR&&(this.state=C.IDLE);return}let{frag:i,part:r,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);let o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,r,n,e.partial);}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e!=null&&e.partList){var i;let n=e.partList[0],a=n.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var r;if((this.hls.hasEnoughToStart?((r=this.media)==null?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return true}}}return false}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;let o=t[r],d=o.details,l=a>-1?wg(d,n,a):null,c=l?l.fragment:kp(d,n,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,i,r,n){var a;if(!e||this.state!==C.PARSING)return;let{data1:o,data2:d}=e,l=o;if(o&&d&&(l=Rt(o,d)),!((a=l)!=null&&a.length))return;let c=this.initPTS[t.cc],u=c?-c.baseTime/c.timescale:void 0,h={type:e.type,frag:t,part:i,chunkMeta:r,offset:u,parent:t.type,data:l};if(this.hls.trigger(g.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t);}}flushBufferGap(e){let t=this.media;if(!t)return;if(!ne.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,r=ne.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start);}getFwdBufferInfo(e,t){var i;let r=this.getLoadPosition();if(!$(r))return null;let a=this.lastCurrentTime>r||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){let n=ne.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){let o=Math.max(Math.min(n.nextStart,a.end)-t,r);return ne.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),true):false}getAppendedFrag(e,t=K.MAIN){var i;let r=(i=this.fragmentTracker)==null?void 0:i.getAppendedFrag(e,t);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let i=t.fragments,r=i.length;if(!r)return null;let{config:n}=this,a=i[0].start,o=n.lowLatencyMode&&!!t.partList,d=null;if(t.live){let u=n.initialLiveManifestSize;if(r<u)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=true),d=this.getInitialLiveFragment(t);let h=this.hls.startPosition,f=this.hls.liveSyncPosition,m=d?(h!==-1&&h>=a?h:f)||d.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${h} liveSyncPosition: ${f} frag.start: ${(l=d)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=m;}}else e<=a&&(d=i[0]);if(!d){let u=this.loadingParts?t.partEnd:t.fragmentEnd;d=this.getFragmentAtPosition(e,u,t);}let c=this.filterReplacedPrimary(d,t);if(!c&&d){let u=d.sn-t.startSN;c=this.filterReplacedPrimary(i[u+1]||null,t);}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return (i===Ke.OK||i===Ke.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){let o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(o!==null&&i.len+o.len>=n){let d=a.sn;return this.loopSn!==d&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${d}`),this.loopSn=d),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(Og(this.hls.config)){var e,t;if((e=this.hls.interstitialsManager)==null||(t=e.playingItem)==null?void 0:t.event)return true}return false}filterReplacedPrimary(e,t){if(!e)return e;if(Og(this.hls.config)&&e.type!==K.SUBTITLE){let i=this.hls.interstitialsManager,r=i?.bufferingItem;if(r){let a=r.event;if(a){if(a.appendInPlace||Math.abs(e.start-r.start)>1||r.start===0)return null}else if(e.end<=r.start&&t?.live===false||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}let n=i?.playerQueue;if(n)for(let a=n.length;a--;){let o=n[a].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let r=-1,n=false,a=true;for(let o=0,d=e.length;o<d;o++){let l=e[o];if(a=a&&!l.independent,r>-1&&i<l.start)break;let c=l.loaded;c?r=-1:(n||l.independent||a)&&l.fragment===t&&(r=o),n=c;}return r}loadedEndOfParts(e,t){let i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=Ey(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){let n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`));}r||(r=bp(e,i.cc,i.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`));}}else {let n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e));}return r}getFragmentAtPosition(e,t,i){let{config:r}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:d}=i,{maxFragLookUpTolerance:l}=r,c=i.partList,u=!!(this.loadingParts&&c!=null&&c.length&&d);u&&d&&!this.bitrateTest&&c[c.length-1].fragment.sn===d.sn&&(a=a.concat(d),o=d.sn);let h;if(e<t){var f;let E=e<this.lastCurrentTime||e>t-l||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:l;h=Ts(n,a,e,E);}else h=a[a.length-1];if(h){let m=h.sn-i.startSN,E=this.fragmentTracker.getState(h);if((E===Ke.OK||E===Ke.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn||!i.live&&!u)&&n&&h.level===n.level){let v=a[m+1];h.sn<o&&this.fragmentTracker.getState(v)!==Ke.OK?h=v:h=null;}}return h}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let n=e.fragmentStart,a=!t,o=e.alignedSliding&&$(n);if(a||!o&&!n){jy(i,e);let d=e.fragmentStart;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),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 i=this.startPosition;i<t&&(i=-1);let r=this.timelineOffset;if(i===-1){let n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&$(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+r;}this.nextLoadPosition=i+r;}getLoadPosition(){var e;let{media:t}=this,i=0;return (e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&$e(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e));}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==C.FRAG_LOADING_WAITING_RETRY)&&(this.state=C.IDLE);}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let m=this.getCurrentContext(t.chunkMeta);m&&(t.frag=m.frag);}let i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var r;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}let n=t.details===R.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,true);let a=t.errorAction,{action:o,flags:d,retryCount:l=0,retryConfig:c}=a||{},u=!!a&&!!c,h=u&&o===et.RetryRequest,f=u&&!a.resolved&&d===Nt.MoveAllAlternatesMatchingHost;if(!h&&f&&$e(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=true;else if((h||f)&&l<c.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);let m=gh(c,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${m}ms`),a.resolved=true,this.retryDate=self.performance.now()+m,this.state=C.FRAG_LOADING_WAITING_RETRY;}else if(c&&a)if(this.resetFragmentErrors(e),l<c.maxNumRetry)!n&&o!==et.RemoveAlternatePermanently&&(a.resolved=true);else {this.warn(`${t.details} reached or exceeded max retry (${l})`);return}else o===et.SendAlternateToPenaltyBox?this.state=C.WAITING_LEVEL:this.state=C.ERROR;this.tickImmediate();}reduceLengthAndFlushBuffer(e){if(this.state===C.PARSING||this.state===C.PARSED){let t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len,t?.duration||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return false}resetFragmentErrors(e){e===K.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=false),this.state!==C.STOPPED&&(this.state=C.IDLE);}afterBufferFlushed(e,t,i){if(!e)return;let r=ne.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===C.ENDED&&this.resetLoadingState();}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==C.STOPPED&&(this.state=C.IDLE);}resetStartWhenNotLoaded(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=false;let t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition;}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of ${this.playlistLabel()} ${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,false,true);}updateLevelTiming(e,t,i,r){let n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((d,l)=>{let c=e.elementaryStreams[l];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${u})`),d||false;let h=r?0:xp(n,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(g.LEVEL_PTS_UPDATED,{details:n,level:i,drift:h,type:l,frag:e,start:c.startPTS,end:c.endPTS}),true}return d},false)){var o;if(i.fragmentError===0&&this.treatAsGap(e,i),((o=this.transmuxer)==null?void 0:o.error)===null){let d=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(d.message),this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:false,error:d,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer();}}this.state=C.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)})`),this.hls.trigger(g.FRAG_PARSED,{frag:e,part:t});}playlistLabel(){return this.playlistType===K.MAIN?"level":"track"}fragInfo(e,t=true,i){var r,n;return `${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((r=t&&!i?e.startPTS:(i||e).start)!=null?r:NaN).toFixed(3)}-${((n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=true,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,true);}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset();}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),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}};function Og(s){return !!s.interstitialsController&&s.enableInterstitialPlayback!==false}var El=class{constructor(){this.chunks=[],this.dataLength=0;}push(e){this.chunks.push(e),this.dataLength+=e.length;}flush(){let{chunks:e,dataLength:t}=this,i;if(e.length)e.length===1?i=e[0]:i=Qy(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0;}};function Qy(s,e){let t=new Uint8Array(e),i=0;for(let r=0;r<s.length;r++){let n=s[r];t.set(n,i),i+=n.length;}return t}var Pc={exports:{}},Ng;function Xy(){return Ng||(Ng=1,function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=false));function r(d,l,c){this.fn=d,this.context=l,this.once=c||false;}function n(d,l,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||d,h),m=t?t+l:l;return d._events[m]?d._events[m].fn?d._events[m]=[d._events[m],f]:d._events[m].push(f):(d._events[m]=f,d._eventsCount++),d}function a(d,l){--d._eventsCount===0?d._events=new i:delete d._events[l];}function o(){this._events=new i,this._eventsCount=0;}o.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)e.call(c,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=t?t+l:l,u=this._events[c];if(!u)return [];if(u.fn)return [u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(l){var c=t?t+l:l,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,c,u,h,f,m){var E=t?t+l:l;if(!this._events[E])return false;var p=this._events[E],v=arguments.length,S,y;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,true),v){case 1:return p.fn.call(p.context),true;case 2:return p.fn.call(p.context,c),true;case 3:return p.fn.call(p.context,c,u),true;case 4:return p.fn.call(p.context,c,u,h),true;case 5:return p.fn.call(p.context,c,u,h,f),true;case 6:return p.fn.call(p.context,c,u,h,f,m),true}for(y=1,S=new Array(v-1);y<v;y++)S[y-1]=arguments[y];p.fn.apply(p.context,S);}else {var b=p.length,L;for(y=0;y<b;y++)switch(p[y].once&&this.removeListener(l,p[y].fn,void 0,true),v){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,c);break;case 3:p[y].fn.call(p[y].context,c,u);break;case 4:p[y].fn.call(p[y].context,c,u,h);break;default:if(!S)for(L=1,S=new Array(v-1);L<v;L++)S[L-1]=arguments[L];p[y].fn.apply(p[y].context,S);}}return true},o.prototype.on=function(l,c,u){return n(this,l,c,u,false)},o.prototype.once=function(l,c,u){return n(this,l,c,u,true)},o.prototype.removeListener=function(l,c,u,h){var f=t?t+l:l;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else {for(var E=0,p=[],v=m.length;E<v;E++)(m[E].fn!==c||h&&!m[E].once||u&&m[E].context!==u)&&p.push(m[E]);p.length?this._events[f]=p.length===1?p[0]:p:a(this,f);}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+l:l,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o;}(Pc)),Pc.exports}var Zy=Xy(),Eh=OT(Zy),Fn="1.6.7",Tr={};function Jy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function eS(){let s=Tr[Fn];if(s)return s.clientCount++,s;let e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return Tr[Fn]=r,r}function tS(s){let e=Tr[s];if(e)return e.clientCount++,e;let t=new self.URL(s,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Tr[s]=r,r}function iS(s){let e=Tr[s||Fn];if(e&&e.clientCount--===1){let{worker:i,objectURL:r}=e;delete Tr[s||Fn],r&&self.URL.revokeObjectURL(r),i.terminate();}}function Op(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function vh(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function wl(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function Un(s,e){let t=e,i=0;for(;vh(s,e);){i+=10;let r=wl(s,e+6);i+=r,Op(s,e+10)&&(i+=10),e+=i;}if(i>0)return s.subarray(t,t+i)}function sS(s,e,t,i){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){let f=new Error(`invalid ADTS sampling index:${a}`);s.emit(g.ERROR,g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:true,error:f,reason:f.message});return}let o=(n>>6&3)+1,d=e[t+3]>>6&3|(n&1)<<2,l="mp4a.40."+o,c=r[a],u=a;(o===5||o===29)&&(u-=3);let h=[o<<3|(u&14)>>1,(u&1)<<7|d<<3];return Ee.log(`manifest codec:${i}, parsed codec:${l}, channels:${d}, rate:${c} (ADTS object type:${o} sampling index:${a})`),{config:h,samplerate:c,channelCount:d,codec:l,parsedCodec:l,manifestCodec:i}}function Np(s,e){return s[e]===255&&(s[e+1]&246)===240}function Fp(s,e){return s[e+1]&1?7:9}function Th(s,e){return (s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function rS(s,e){return e+5<s.length}function vl(s,e){return e+1<s.length&&Np(s,e)}function nS(s,e){return rS(s,e)&&Np(s,e)&&Th(s,e)<=s.length-e}function aS(s,e){if(vl(s,e)){let t=Fp(s,e);if(e+t>=s.length)return false;let i=Th(s,e);if(i<=t)return false;let r=e+i;return r===s.length||vl(s,r)}return false}function Up(s,e,t,i,r){if(!s.samplerate){let n=sS(e,t,i,r);if(!n)return;Te(s,n);}}function Bp(s){return 1024*9e4/s}function oS(s,e){let t=Fp(s,e);if(e+t<=s.length){let i=Th(s,e)-t;if(i>0)return {headerLength:t,frameLength:i}}}function $p(s,e,t,i,r){let n=Bp(s.samplerate),a=i+r*n,o=oS(e,t),d;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(d=new Uint8Array(f-h),d.set(e.subarray(t+h,e.length),0)):d=e.subarray(t+h,t+f);let E={unit:d,pts:a};return m||s.samples.push(E),{sample:E,length:f,missing:m}}let l=e.length-t;return d=new Uint8Array(l),d.set(e.subarray(t,e.length),0),{sample:{unit:d,pts:a},length:l,missing:-1}}function lS(s,e){return vh(s,e)&&wl(s,e+6)+10<=s.length-e}function dS(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function Oc(s,e=0,t=1/0){return cS(s,e,t,Uint8Array)}function cS(s,e,t,i){let r=uS(s),n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);let a=hS(s)?s.byteOffset:0,o=(a+s.byteLength)/n,d=(a+e)/n,l=Math.floor(Math.max(0,Math.min(d,o))),c=Math.floor(Math.min(l+Math.max(t,0),o));return new i(r,l,c-l)}function uS(s){return s instanceof ArrayBuffer?s:s.buffer}function hS(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function fS(s){let e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}let i=s.data.subarray(1).indexOf(0);if(i===-1)return;let r=St(Oc(s.data,1,i)),n=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;let o=St(Oc(s.data,3+i,a)),d;return r==="-->"?d=St(Oc(s.data,4+i+a)):d=dS(s.data.subarray(4+i+a)),e.mimeType=r,e.pictureType=n,e.description=o,e.data=d,e}function mS(s){if(s.size<2)return;let e=St(s.data,true),t=new Uint8Array(s.data.subarray(e.length+1));return {key:s.type,info:e,data:t.buffer}}function gS(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1,i=St(s.data.subarray(t),true);t+=i.length+1;let r=St(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=St(s.data.subarray(1));return {key:s.type,info:"",data:e}}function pS(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1,i=St(s.data.subarray(t),true);t+=i.length+1;let r=St(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=St(s.data);return {key:s.type,info:"",data:e}}function ES(s){return s.type==="PRIV"?mS(s):s.type[0]==="W"?pS(s):s.type==="APIC"?fS(s):gS(s)}function vS(s){let e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=wl(s,4),i=10;return {type:e,size:t,data:s.subarray(i,i+t)}}var Ko=10,TS=10;function Gp(s){let e=0,t=[];for(;vh(s,e);){let i=wl(s,e+6);s[e+5]>>6&1&&(e+=Ko),e+=Ko;let r=e+i;for(;e+TS<r;){let n=vS(s.subarray(e)),a=ES(n);a&&t.push(a),e+=n.size+Ko;}Op(s,e)&&(e+=Ko);}return t}function Hp(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function yS(s){if(s.data.byteLength===8){let e=new Uint8Array(s.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function yh(s){let e=Gp(s);for(let t=0;t<e.length;t++){let i=e[t];if(Hp(i))return yS(i)}}var yt=function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s}({});function di(s="",e=9e4){return {type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Bn=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,i,r){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 false}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=Rt(this.cachedData,e),this.cachedData=null);let i=Un(e,0),r=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,d=i?yh(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&$(d))&&(this.basePTS=SS(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(e,r)){let c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=l;}else lS(e,r)?(i=Un(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===l&&n!==l){let c=e.slice(n);this.cachedData?this.cachedData=Rt(this.cachedData,c):this.cachedData=c;}}return {audioTrack:a,videoTrack:di(),id3Track:o,textTrack:di()}}demuxSampleAes(e,t,i){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:di(),id3Track:this._id3Track,textTrack:di()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0;}},SS=(s,e,t)=>{if($(s))return s*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i},Wo=null,bS=[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],AS=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_S=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],IS=[0,1,1,4];function Vp(s,e,t,i,r){if(t+24>e.length)return;let n=Kp(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,d={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=n.channelCount,s.samplerate=n.sampleRate,s.samples.push(d),{sample:d,length:n.frameLength,missing:0}}}function Kp(s,e){let t=s[e+1]>>3&3,i=s[e+1]>>1&3,r=s[e+2]>>4&15,n=s[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){let a=s[e+2]>>1&1,o=s[e+3]>>6,d=t===3?3-i:i===3?3:4,l=bS[d*14+r-1]*1e3,u=AS[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=_S[t][i],m=IS[i],E=f*8*m,p=Math.floor(f*l/u+a)*m;if(Wo===null){let y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Wo=y?parseInt(y[1]):0;}return !!Wo&&Wo<=87&&i===2&&l>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:u,channelCount:h,frameLength:p,samplesPerFrame:E}}}function Sh(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Wp(s,e){return e+1<s.length&&Sh(s,e)}function LS(s,e){return Sh(s,e)&&4<=s.length-e}function qp(s,e){if(e+1<s.length&&Sh(s,e)){let i=Kp(s,e),r=4;i!=null&&i.frameLength&&(r=i.frameLength);let n=e+r;return n===s.length||Wp(s,n)}return false}var mu=class extends Bn{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e,t){if(!e)return false;let i=Un(e,0),r=i?.length||0;if(qp(e,r))return false;for(let n=e.length;r<n;r++)if(aS(e,r))return t.log("ADTS sync word found !"),true;return false}canParse(e,t){return nS(e,t)}appendFrame(e,t,i){Up(e,this.observer,t,i,e.manifestCodec);let r=$p(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}},Yp=(s,e)=>{let t=0,i=5;e+=i;let r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];let o=Math.min(i,8),d=8-o;n[0]=4278190080>>>24+d<<d,r[0]=(a[0]&n[0])>>d,t=t?t<<o|r[0]:r[0],e+=1,i-=o;}return t},gu=class extends Bn{constructor(e){super(),this.observer=void 0,this.observer=e;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){let r=jp(e,t,i,this.basePTS,this.frameIndex);if(r!==-1)return {sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return false;let t=Un(e,0);if(!t)return false;let i=t.length;return e[i]===11&&e[i+1]===119&&yh(t)!==void 0&&Yp(e,i)<16}};function jp(s,e,t,i,r){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],d=e[t+4]&63,c=[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][d*3+n]*2;if(t+c>e.length)return -1;let u=e[t+6]>>5,h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,E=[2,1,2,3,3,4,4,5][u]+f,p=e[t+5]>>3,v=e[t+5]&7,S=new Uint8Array([n<<6|p<<1|v>>2,(v&3)<<6|u<<3|f<<2|d>>4,d<<4&224]),y=1536/o*9e4,b=i+r*y,L=e.subarray(t,t+c);return s.config=S,s.channelCount=E,s.samplerate=o,s.samples.push({unit:L,pts:b}),c}var pu=class extends Bn{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e){if(!e)return false;let t=Un(e,0),i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&yh(t)!==void 0&&Yp(e,i)<=16)return false;for(let r=e.length;i<r;i++)if(qp(e,i))return Ee.log("MPEG Audio sync word found !"),true;return false}canParse(e,t){return LS(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Vp(e,t,i,this.basePTS,this.frameIndex)}},xS=/\/emsg[-/]ID3/i,Eu=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,i,r){let n=this.videoTrack=di("video",1),a=this.audioTrack=di("audio",1),o=this.txtTrack=di("text",1);if(this.id3Track=di("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let d=fp(e);if(d.video){let{id:l,timescale:c,codec:u,supplemental:h}=d.video;n.id=l,n.timescale=o.timescale=c,n.codec=u,n.supplemental=h;}if(d.audio){let{id:l,timescale:c,codec:u}=d.audio;a.id=l,a.timescale=c,a.codec=u;}o.id=cp.text,n.sampleDuration=0,n.duration=a.duration=r;}resetContiguity(){this.remainderData=null;}static probe(e){return BT(e)}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Rt(this.remainderData,e));let o=qT(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array;}else r.samples=i;let a=this.extractID3Track(r,t);return n.samples=sg(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let r=this.extractID3Track(t,this.timeOffset);return i.samples=sg(e,t),{videoTrack:t,audioTrack:di(),id3Track:r,textTrack:di()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=de(e.samples,["emsg"]);r&&r.forEach(n=>{let a=jT(n);if(xS.test(a.schemeIdUri)){let o=Fg(a,t),d=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);let l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:yt.emsg,duration:d});}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){let o=Fg(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:o,pts:o,type:yt.misbklv,duration:Number.POSITIVE_INFINITY});}});}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0;}};function Fg(s,e){return $(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}var vu=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Pn(t,{removePKCS7Padding:false});}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Hi.cbc)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let d=new Uint8Array(o);r.set(d,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i);});}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t),r=0;for(let n=32;n<e.length-16;n+=160,r+=16)i.set(e.subarray(n,n+16),r);return i}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(i.subarray(r,r+16),n);return e}decryptAvcSample(e,t,i,r,n){let a=mp(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(d=>{n.data=this.getAvcDecryptedUnit(a,d),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r);});}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){r();return}let n=e[t].units;for(;!(i>=n.length);i++){let a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,r,a),!this.decrypter.isSync()))return}}}},Tl=class{constructor(){this.VideoSample=null;}createVideoSample(e,t,i){return {key:e,frame:false,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;r=n[n.length-1];}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let i=t.samples,r=i.length;if(r){let n=i[r-1];e.pts=n.pts,e.dts=n.dts;}else {t.dropped++;return}}t.samples.push(e);}}parseNALu(e,t,i){let r=t.byteLength,n=e.naluState||0,a=n,o=[],d=0,l,c,u,h=-1,f=0;for(n===-1&&(h=0,f=this.getNALuType(t,0),n=0,d=1);d<r;){if(l=t[d++],!n){n=l?0:1;continue}if(n===1){n=l?0:2;continue}if(!l)n=3;else if(l===1){if(c=d-n-1,h>=0){let m={data:t.subarray(h,c),type:f};o.push(m);}else {let m=this.getLastNalUnit(e.samples);m&&(a&&d<=4-a&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-a)),c>0&&(m.data=Rt(m.data,t.subarray(0,c)),m.state=0));}d<r?(u=this.getNALuType(t,d),h=d,f=u,n=0):n=-1;}else n=0;}if(h>=0&&n>=0){let m={data:t.subarray(h,r),type:f,state:n};o.push(m);}if(o.length===0){let m=this.getLastNalUnit(e.samples);m&&(m.data=Rt(m.data,t));}return e.naluState=n,o}},Es=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,i=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(i,i+n)),this.word=new DataView(r.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),i=this.word>>>32-t;if(e>32&&Ee.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?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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)}},yl=class extends Tl{parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,d=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(l=>{var c,u;switch(l.type){case 1:{let E=false;o=true;let p=l.data;if(d&&p.length>4){let v=this.readSliceType(p);(v===2||v===4||v===7||v===9)&&(E=true);}if(E){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.frame=true,a.key=E;break}case 5:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 6:{o=true,hh(l.data,1,i.pts,t.samples);break}case 7:{var f,m;o=true,d=true;let E=l.data,p=this.readSPS(E);if(!e.sps||e.width!==p.width||e.height!==p.height||((f=e.pixelRatio)==null?void 0:f[0])!==p.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[E];let v=E.subarray(1,4),S="avc1.";for(let y=0;y<3;y++){let b=v[y].toString(16);b.length<2&&(b="0"+b),S+=b;}e.codec=S;}break}case 8:o=true,e.pps=[l.data];break;case 9:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;case 12:o=true;break;default:o=false;break}a&&o&&a.units.push(l);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}getNALuType(e,t){return e[t]&31}readSliceType(e){let t=new Es(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8,n;for(let a=0;a<e;a++)r!==0&&(n=t.readEG(),r=(i+n+256)%256),i=r===0?i:r;}readSPS(e){let t=new Es(e),i=0,r=0,n=0,a=0,o,d,l,c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),m=t.skipBits.bind(t),E=t.skipEG.bind(t),p=t.skipUEG.bind(t),v=this.skipScalingList.bind(this);c();let S=c();if(u(5),m(3),c(),p(),S===100||S===110||S===122||S===244||S===44||S===83||S===86||S===118||S===128){let x=h();if(x===3&&m(1),p(),p(),m(1),f())for(d=x!==3?8:12,l=0;l<d;l++)f()&&(l<6?v(16,t):v(64,t));}p();let y=h();if(y===0)h();else if(y===1)for(m(1),E(),E(),o=h(),l=0;l<o;l++)E();p(),m(1);let b=h(),L=h(),k=u(1);k===0&&m(1),m(1),f()&&(i=h(),r=h(),n=h(),a=h());let I=[1,1];if(f()&&f())switch(c()){case 1:I=[1,1];break;case 2:I=[12,11];break;case 3:I=[10,11];break;case 4:I=[16,11];break;case 5:I=[40,33];break;case 6:I=[24,11];break;case 7:I=[20,11];break;case 8:I=[32,11];break;case 9:I=[80,33];break;case 10:I=[18,11];break;case 11:I=[15,11];break;case 12:I=[64,33];break;case 13:I=[160,99];break;case 14:I=[4,3];break;case 15:I=[3,2];break;case 16:I=[2,1];break;case 255:{I=[c()<<8|c(),c()<<8|c()];break}}return {width:Math.ceil((b+1)*16-i*2-r*2),height:(2-k)*(L+1)*16-(k?2:4)*(n+a),pixelRatio:I}}},Sl=class extends Tl{constructor(...e){super(...e),this.initVPS=null;}parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,d=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(l=>{var c,u;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),a.frame=true,o=true;break;case 16:case 17:case 18:case 21:if(o=true,d){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 19:case 20:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 39:o=true,hh(l.data,2,i.pts,t.samples);break;case 32:o=true,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Te(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=true,d=true,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let f=this.readSPS(l.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(let m in f.params)e.params[m]=f.params[m];}this.pushParameterSet(e.sps,l.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true;break;case 34:if(o=true,typeof e.params=="object"){if(!e.pps){e.pps=[];let f=this.readPPS(l.data);for(let m in f)e.params[m]=f[m];}this.pushParameterSet(e.pps,l.data,e.vps);}break;case 35:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;default:o=false;break}a&&o&&a.units.push(l);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t);}getNALuType(e,t){return (e[t]&126)>>>1}ebsp2rbsp(e){let t=new Uint8Array(e.byteLength),i=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null);}readVPS(e){let t=new Es(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);let i=t.readBits(3),r=t.readBoolean();return {numTemporalLayers:i+1,temporalIdNested:r}}readSPS(e){let t=new Es(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),d=t.readUByte(),l=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),m=t.readUByte(),E=t.readUByte(),p=t.readUByte(),v=t.readUByte(),S=[],y=[];for(let fe=0;fe<i;fe++)S.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(let fe=i;fe<8;fe++)t.readBits(2);for(let fe=0;fe<i;fe++)S[fe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[fe]&&t.readUByte();t.readUEG();let b=t.readUEG();b==3&&t.skipBits(1);let L=t.readUEG(),k=t.readUEG(),I=t.readBoolean(),x=0,D=0,_=0,M=0;I&&(x+=t.readUEG(),D+=t.readUEG(),_+=t.readUEG(),M+=t.readUEG());let N=t.readUEG(),q=t.readUEG(),V=t.readUEG(),H=t.readBoolean();for(let fe=H?0:i;fe<=i;fe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let He=0;He<4;He++)for(let nt=0;nt<(He===3?2:6);nt++)if(!t.readBoolean())t.readUEG();else {let At=Math.min(64,1<<4+(He<<1));He>1&&t.readEG();for(let ge=0;ge<At;ge++)t.readEG();}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let P=t.readUEG(),z=0;for(let fe=0;fe<P;fe++){let He=false;if(fe!==0&&(He=t.readBoolean()),He){fe===P&&t.readUEG(),t.readBoolean(),t.readUEG();let nt=0;for(let $t=0;$t<=z;$t++){let At=t.readBoolean(),ge=false;At||(ge=t.readBoolean()),(At||ge)&&nt++;}z=nt;}else {let nt=t.readUEG(),$t=t.readUEG();z=nt+$t;for(let At=0;At<nt;At++)t.readUEG(),t.readBoolean();for(let At=0;At<$t;At++)t.readUEG(),t.readBoolean();}}if(t.readBoolean()){let fe=t.readUEG();for(let He=0;He<fe;He++){for(let nt=0;nt<V+4;nt++)t.readBits(1);t.readBits(1);}}let U=0,O=1,se=1,oe=true,me=1,ue=0;t.readBoolean(),t.readBoolean();let Ie=false;if(t.readBoolean()){if(t.readBoolean()){let mt=t.readUByte(),Wn=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],bs=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];mt>0&&mt<16?(O=Wn[mt-1],se=bs[mt-1]):mt===255&&(O=t.readBits(16),se=t.readBits(16));}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Ie=t.readBoolean(),Ie&&(x+=t.readUEG(),D+=t.readUEG(),_+=t.readUEG(),M+=t.readUEG()),t.readBoolean()&&(me=t.readBits(32),ue=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let bs=t.readBoolean(),qn=t.readBoolean(),Vi=false;(bs||qn)&&(Vi=t.readBoolean(),Vi&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Vi&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Yn=0;Yn<=i;Yn++){oe=t.readBoolean();let Fl=oe||t.readBoolean(),jn=false;Fl?t.readEG():jn=t.readBoolean();let st=jn?1:t.readUEG()+1;if(bs)for(let ke=0;ke<st;ke++)t.readUEG(),t.readUEG(),Vi&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(qn)for(let ke=0;ke<st;ke++)t.readUEG(),t.readUEG(),Vi&&(t.readUEG(),t.readUEG()),t.skipBits(1);}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),U=t.readUEG());}let Ge=L,it=k;if(I||Ie){let fe=1,He=1;b===1?fe=He=2:b==2&&(fe=2),Ge=L-fe*D-fe*x,it=k-He*M-He*_;}let Bt=r?["A","B","C"][r]:"",bi=o<<24|d<<16|l<<8|c,ys=0;for(let fe=0;fe<32;fe++)ys=(ys|(bi>>fe&1)<<31-fe)>>>0;let Ss=ys.toString(16);return a===1&&Ss==="2"&&(Ss="6"),{codecString:`hvc1.${Bt}${a}.${Ss}.${n?"H":"L"}${v}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[o,d,l,c],general_constraint_indicator_flags:[u,h,f,m,E,p],general_level_idc:v,bit_depth:N+8,bit_depth_luma_minus8:N,bit_depth_chroma_minus8:q,min_spatial_segmentation_idc:U,chroma_format_idc:b,frame_rate:{fixed:oe,fps:ue/me}},width:Ge,height:it,pixelRatio:[O,se]}}readPPS(e){let t=new Es(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);let r=t.readBoolean(),n=t.readBoolean(),a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}},Xe=188,Tu=class s{constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=false,this.audioCodec=void 0,this.videoCodec=void 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=i,this.logger=r,this.videoParser=null;}static probe(e,t){let i=s.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){let t=e.length,i=Math.min(Xe*5,t-Xe)+1,r=0;for(;r<i;){let n=false,a=-1,o=0;for(let d=r;d<t;d+=Xe)if(e[d]===71&&(t-d===Xe||e[d+Xe]===71)){if(o++,a===-1&&(a=d,a!==0&&(i=Math.min(a+Xe*99,e.length-Xe)+1)),n||(n=yu(e,d)===0),n&&o>1&&(a===0&&o>2||d+Xe>i))return a}else {if(o)return -1;break}r++;}return -1}static createTrack(e,t){return {container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:cp[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=false,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=s.createTrack("audio",r),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i;}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null;}demux(e,t,i=false,r=false){i||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,d=this._id3Track,l=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=d.pid,m=o.pesData,E=d.pesData,p=null,v=this.pmtParsed,S=this._pmtId,y=e.length;if(this.remainderData&&(e=Rt(this.remainderData,e),y=e.length,this.remainderData=null),y<Xe&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};let b=Math.max(0,s.syncOffset(e));y-=(y-b)%Xe,y<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let L=0;for(let I=b;I<y;I+=Xe)if(e[I]===71){let x=!!(e[I+1]&64),D=yu(e,I),_=(e[I+3]&48)>>4,M;if(_>1){if(M=I+5+e[I+4],M===I+Xe)continue}else M=I+4;switch(D){case c:if(x){if(u&&(n=cr(u,this.logger))){if(this.videoParser===null)switch(a.segmentCodec){case "avc":this.videoParser=new yl;break;case "hevc":this.videoParser=new Sl;break}this.videoParser!==null&&this.videoParser.parsePES(a,l,n,false);}u={data:[],size:0};}u&&(u.data.push(e.subarray(M,I+Xe)),u.size+=I+Xe-M);break;case h:if(x){if(m&&(n=cr(m,this.logger)))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(M,I+Xe)),m.size+=I+Xe-M);break;case f:x&&(E&&(n=cr(E,this.logger))&&this.parseID3PES(d,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(M,I+Xe)),E.size+=I+Xe-M);break;case 0:x&&(M+=e[M]+1),S=this._pmtId=RS(e,M);break;case S:{x&&(M+=e[M]+1);let N=DS(e,M,this.typeSupported,i,this.observer,this.logger);c=N.videoPid,c>0&&(a.pid=c,a.segmentCodec=N.segmentVideoCodec),h=N.audioPid,h>0&&(o.pid=h,o.segmentCodec=N.segmentAudioCodec),f=N.id3Pid,f>0&&(d.pid=f),p!==null&&!v&&(this.logger.warn(`MPEG-TS PMT found at ${I} after unknown PID '${p}'. Backtracking to sync byte @${b} to parse all TS packets.`),p=null,I=b-188),v=this.pmtParsed=true;break}case 17:case 8191:break;default:p=D;break}}else L++;L>0&&Su(this.observer,new Error(`Found ${L} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=u,o.pesData=m,d.pesData=E;let k={audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};return r&&this.extractRemainingSamples(k),k}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,false,true):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:i,id3Track:r,textTrack:n}=e,a=i.pesData,o=t.pesData,d=r.pesData,l;if(a&&(l=cr(a,this.logger))){if(this.videoParser===null)switch(i.segmentCodec){case "avc":this.videoParser=new yl;break;case "hevc":this.videoParser=new Sl;break}this.videoParser!==null&&(this.videoParser.parsePES(i,n,l,true),i.pesData=null);}else i.pesData=a;if(o&&(l=cr(o,this.logger))){switch(t.segmentCodec){case "aac":this.parseAACPES(t,l);break;case "mp3":this.parseMPEGPES(t,l);break;case "ac3":this.parseAC3PES(t,l);break}t.pesData=null;}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;d&&(l=cr(d,this.logger))?(this.parseID3PES(r,l),r.pesData=null):r.pesData=d;}demuxSampleAes(e,t,i){let r=this.demux(e,i,true,!this.config.progressive),n=this.sampleAes=new vu(this.observer,this.config,t);return this.decrypt(r,n)}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e);}):i(e);}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e);});})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0;}parseAACPES(e,t){let i=0,r=this.aacOverFlow,n=t.data;if(r){this.aacOverFlow=null;let u=r.missing,h=r.sample.unit.byteLength;if(u===-1)n=Rt(r.sample.unit,n);else {let f=h-u;r.sample.unit.set(n.subarray(0,u),f),e.samples.push(r.sample),i=r.missing;}}let a,o;for(a=i,o=n.length;a<o-1&&!vl(n,a);a++);if(a!==i){let u,h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",Su(this.observer,new Error(u),h,this.logger),!h)return}Up(e,this.observer,n,a,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(r){let u=Bp(e.samplerate);d=r.sample.pts+u;}else {this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,c;for(;a<o;)if(c=$p(e,n,a,d,l),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(l++;a<o-1&&!vl(n,a);a++);}parseMPEGPES(e,t){let i=t.data,r=i.length,n=0,a=0,o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Wp(i,a)){let d=Vp(e,i,a,o,n);if(d)a+=d.length,n++;else break}else a++;}parseAC3PES(e,t){{let i=t.data,r=t.pts;if(r===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=i.length,a=0,o=0,d;for(;o<n&&(d=jp(e,i,o,r,a++))>0;)o+=d;}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=Te({},t,{type:this._videoTrack?yt.emsg:yt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i);}};function yu(s,e){return ((s[e+1]&31)<<8)+s[e+2]}function RS(s,e){return (s[e+10]&31)<<8|s[e+11]}function DS(s,e,t,i,r,n){let a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[e+1]&15)<<8|s[e+2],d=e+3+o-4,l=(s[e+10]&15)<<8|s[e+11];for(e+=12+l;e<d;){let c=yu(s,e),u=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){Nc("ADTS AAC",n);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!i){Nc("H.264",n);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!i){Nc("AC-3",n);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&u>0){let h=e+5,f=u;for(;f>2;){switch(s[h]){case 106:t.ac3!==true?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=c,a.segmentAudioCodec="ac3");break}let E=s[h+1]+2;h+=E,f-=E;}}break;case 194:case 135:return Su(r,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:a.videoPid===-1&&(a.videoPid=c,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=u+5;}return a}function Su(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(g.ERROR,g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:false,levelRetry:t,error:e,reason:e.message});}function Nc(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`);}function cr(s,e){let t=0,i,r,n,a,o,d=s.data;if(!s||s.size===0)return null;for(;d[0].length<19&&d.length>1;)d[0]=Rt(d[0],d[1]),d.splice(1,1);if(i=d[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>s.size-6)return null;let c=i[7];c&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let u=n+9;if(s.size<=u)return null;s.size-=u;let h=new Uint8Array(s.size);for(let f=0,m=d.length;f<m;f++){i=d[f];let E=i.byteLength;if(u)if(u>E){u-=E;continue}else i=i.subarray(u),E-=u,u=0;h.set(i,t),t+=E;}return r&&(r-=n+3),{data:h,pts:a,dts:o,len:r}}return null}var bu=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}}},Fi=Math.pow(2,32)-1,We=class s{static init(){s.types={avc1:[],avcC:[],hvc1:[],hvcC:[],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 s.types)s.types.hasOwnProperty(e)&&(s.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]),i=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]);s.HDLR_TYPES={video:t,audio:i};let r=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]);s.STTS=s.STSC=s.STCO=n,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.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]),d=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,d,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r));}static box(e,...t){let i=8,r=t.length,n=r;for(;r--;)i+=t[r].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),r=0,i=8;r<n;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return s.box(s.types.hdlr,s.HDLR_TYPES[e])}static mdat(e){return s.box(s.types.mdat,e)}static mdhd(e,t){t*=e;let i=Math.floor(t/(Fi+1)),r=Math.floor(t%(Fi+1));return s.box(s.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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return s.box(s.types.mdia,s.mdhd(e.timescale||0,e.duration||0),s.hdlr(e.type),s.minf(e))}static mfhd(e){return s.box(s.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"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(e)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(e))}static moof(e,t,i){return s.box(s.types.moof,s.mfhd(e),s.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=s.trak(e[t]);return s.box.apply(null,[s.types.moov,s.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(s.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=s.trex(e[t]);return s.box.apply(null,[s.types.mvex,...i])}static mvhd(e,t){t*=e;let i=Math.floor(t/(Fi+1)),r=Math.floor(t%(Fi+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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&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 s.box(s.types.mvhd,n)}static sdtp(e){let t=e.samples||[],i=new Uint8Array(4+t.length),r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return s.box(s.types.sdtp,i)}static stbl(e){return s.box(s.types.stbl,s.stsd(e),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));let o=s.box(s.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),d=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return s.box(s.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,d>>8&255,d&255,l>>8&255,l&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,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){let t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return s.box(s.types.mp4a,s.audioStsd(e),s.box(s.types.esds,s.esds(e)))}static mp3(e){return s.box(s.types[".mp3"],s.audioStsd(e))}static ac3(e){return s.box(s.types["ac-3"],s.audioStsd(e),s.box(s.types.dac3,e.config))}static stsd(e){let{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return s.box(s.types.stsd,s.STSD,s.mp4a(e));if(t==="ac3"&&e.config)return s.box(s.types.stsd,s.STSD,s.ac3(e));if(t==="mp3"&&e.codec==="mp3")return s.box(s.types.stsd,s.STSD,s.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return s.box(s.types.stsd,s.STSD,s.avc1(e));if(t==="hevc"&&e.vps)return s.box(s.types.stsd,s.STSD,s.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,n=e.height||0,a=Math.floor(i/(Fi+1)),o=Math.floor(i%(Fi+1));return s.box(s.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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let i=s.sdtp(e),r=e.id,n=Math.floor(t/(Fi+1)),a=Math.floor(t%(Fi+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.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])),s.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,s.box(s.types.trak,s.tkhd(e),s.mdia(e))}static trex(e){let t=e.id;return s.box(s.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 i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n),o,d,l,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)d=i[o],l=d.duration,c=d.size,u=d.flags,h=d.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return s.box(s.types.trun,a)}static initSegment(e){s.types||s.init();let t=s.moov(e);return Rt(s.FTYP,t)}static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],r=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]),a=n.length;for(let m=0;m<i.length;m+=1){a+=3;for(let E=0;E<i[m].length;E+=1)a+=2+i[m][E].length;}let o=new Uint8Array(a);o.set(n,0),a=n.length;let d=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===d?128:0),0,i[m].length]),a),a+=3;for(let E=0;E<i[m].length;E+=1)o.set(new Uint8Array([i[m][E].length>>8,i[m][E].length&255]),a),a+=2,o.set(i[m][E],a),a+=i[m][E].length;}let l=s.box(s.types.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return s.box(s.types.hvc1,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,c>>8&255,c&255,u>>8&255,u&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]),l,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}};We.types=void 0;We.HDLR_TYPES=void 0;We.STTS=void 0;We.STSC=void 0;We.STCO=void 0;We.STSZ=void 0;We.VMHD=void 0;We.SMHD=void 0;We.STSD=void 0;We.FTYP=void 0;We.DINF=void 0;var zp=9e4;function bh(s,e,t=1,i=false){let r=s*e*t;return i?Math.round(r):r}function kS(s,e,t=1,i=false){return bh(s,e,1/t,i)}function In(s,e=false){return bh(s,1e3,1/zp,e)}function CS(s,e=1){return bh(s,zp,1/e)}var MS=10*1e3,wS=1024,PS=1152,OS=1536,ur=null,Fc=null;function Ug(s,e,t,i){return {duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}var pr=class extends bt{constructor(e,t,i,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=false,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=false,this.isVideoContiguous=false,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=false,ur===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ur=a?parseInt(a[1]):0;}if(Fc===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);Fc=n?parseInt(n[1]):0;}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null;}resetTimeStamp(e){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=e;}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=false,this.isAudioContiguous=false;}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=false,this.videoTrackConfig=void 0;}getVideoStartPts(e){let t=false,i=e[0].pts,r=e.reduce((n,a)=>{let o=a.pts,d=o-n;return d<-4294967296&&(t=true,o=Lt(o,i),d=o-n),d>0?n:o},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,n,a,o,d){let l,c,u,h,f,m,E=n,p=n,v=e.pid>-1,S=t.pid>-1,y=t.samples.length,b=e.samples.length>0,L=o&&y>0||y>1;if((!v||b)&&(!S||L)||this.ISGenerated||o){if(this.ISGenerated){var I,x,D,_;let V=this.videoTrackConfig;(V&&(t.width!==V.width||t.height!==V.height||((I=t.pixelRatio)==null?void 0:I[0])!==((x=V.pixelRatio)==null?void 0:x[0])||((D=t.pixelRatio)==null?void 0:D[1])!==((_=V.pixelRatio)==null?void 0:_[1]))||!V&&L||this.nextAudioTs===null&&b)&&this.resetInitSegment();}this.ISGenerated||(u=this.generateIS(e,t,n,a));let M=this.isVideoContiguous,N=-1,q;if(L&&(N=NS(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=true,N>0){this.warn(`Dropped ${N} out of ${y} video samples due to a missing keyframe`);let V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(N),t.dropped+=N,p+=(t.samples[0].pts-V)/t.inputTimeScale,q=p;}else N===-1&&(this.warn(`No keyframe found out of ${y} video samples`),m=false);if(this.ISGenerated){if(b&&L){let V=this.getVideoStartPts(t.samples),B=(Lt(e.samples[0].pts,V)-V)/t.inputTimeScale;E+=Math.max(0,B),p+=Math.max(0,-B);}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,S||L||d===K.AUDIO?p:void 0),L){let V=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,p,M,V);}}else L&&(l=this.remuxVideo(t,p,M,0));l&&(l.firstKeyFrame=N,l.independent=N!==-1,l.firstKeyFramePTS=q);}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Qp(i,n,this._initPTS,this._initDTS)),r.samples.length&&(h=Xp(r,n,this._initPTS))),{audio:c,video:l,initSegment:u,independent:m,text:h,id3:f}}generateIS(e,t,i,r){let n=e.samples,a=t.samples,o=this.typeSupported,d={},l=this._initPTS,c=!l||r,u="audio/mp4",h,f,m,E;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case "mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case "ac3":e.codec="ac-3";break}d.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):We.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(E=e.id,m=e.inputTimeScale,!l||m!==l.timescale?h=f=n[0].pts-Math.round(m*i):c=false);}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:We.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(E=t.id,m=t.inputTimeScale,!l||m!==l.timescale){let p=this.getVideoStartPts(a),v=Math.round(m*i);f=Math.min(f,Lt(a[0].dts,p)-v),h=Math.min(h,p-v);}else c=false;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio};}if(Object.keys(d).length)return this.ISGenerated=true,c?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:d,initPTS:h,timescale:m,trackId:E}}remuxVideo(e,t,i,r){let n=e.inputTimeScale,a=e.samples,o=[],d=a.length,l=this._initPTS,c=l.baseTime*n/l.timescale,u=this.nextVideoTs,h=8,f=this.videoSampleDuration,m,E,p=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,S=false;if(!i||u===null){let U=c+t*n,O=a[0].pts-Lt(a[0].dts,a[0].pts);ur&&u!==null&&Math.abs(U-O-(u+c))<15e3?i=true:u=U-O-c;}let y=u+c;for(let U=0;U<d;U++){let O=a[U];O.pts=Lt(O.pts,y),O.dts=Lt(O.dts,y),O.dts<a[U>0?U-1:U].dts&&(S=true);}S&&a.sort(function(U,O){let se=U.dts-O.dts,oe=U.pts-O.pts;return se||oe}),m=a[0].dts,E=a[a.length-1].dts;let b=E-m,L=b?Math.round(b/(d-1)):f||e.inputTimeScale/30;if(i){let U=m-y,O=U>L,se=U<-1;if((O||se)&&(O?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${In(U,true)} ms (${U}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${In(-U,true)} ms (${U}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!se||y>=a[0].pts||ur)){m=y;let oe=a[0].pts-U;if(O)a[0].dts=m,a[0].pts=oe;else {let me=true;for(let ue=0;ue<a.length&&!(a[ue].dts>oe&&me);ue++){let Ie=a[ue].pts;if(a[ue].dts-=U,a[ue].pts-=U,ue<a.length-1){let tt=a[ue+1].pts,Ge=a[ue].pts,it=tt<=Ge,Bt=tt<=Ie;me=it==Bt;}}}this.log(`Video: Initial PTS/DTS adjusted: ${In(oe,true)}/${In(m,true)}, delta: ${In(U,true)} ms`);}}m=Math.max(0,m);let k=0,I=0,x=m;for(let U=0;U<d;U++){let O=a[U],se=O.units,oe=se.length,me=0;for(let ue=0;ue<oe;ue++)me+=se[ue].data.length;I+=me,k+=oe,O.length=me,O.dts<x?(O.dts=x,x+=L/4|0||1):x=O.dts,p=Math.min(O.pts,p),v=Math.max(O.pts,v);}E=a[d-1].dts;let D=I+4*k+8,_;try{_=new Uint8Array(D);}catch(U){this.observer.emit(g.ERROR,g.ERROR,{type:W.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:false,error:U,bytes:D,reason:`fail allocating video mdat ${D}`});return}let M=new DataView(_.buffer);M.setUint32(0,D),_.set(We.types.mdat,4);let N=false,q=Number.POSITIVE_INFINITY,V=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,B=Number.NEGATIVE_INFINITY;for(let U=0;U<d;U++){let O=a[U],se=O.units,oe=0;for(let Ie=0,tt=se.length;Ie<tt;Ie++){let Ge=se[Ie],it=Ge.data,Bt=Ge.data.byteLength;M.setUint32(h,Bt),h+=4,_.set(it,h),h+=Bt,oe+=4+Bt;}let me;if(U<d-1)f=a[U+1].dts-O.dts,me=a[U+1].pts-O.pts;else {let Ie=this.config,tt=U>0?O.dts-a[U-1].dts:L;if(me=U>0?O.pts-a[U-1].pts:L,Ie.stretchShortVideoTrack&&this.nextAudioTs!==null){let Ge=Math.floor(Ie.maxBufferHole*n),it=(r?p+r*n:this.nextAudioTs+c)-O.pts;it>Ge?(f=it-tt,f<0?f=tt:N=true,this.log(`It is approximately ${it/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=tt;}else f=tt;}let ue=Math.round(O.pts-O.dts);q=Math.min(q,f),H=Math.max(H,f),V=Math.min(V,me),B=Math.max(B,me),o.push(Ug(O.key,f,oe,ue));}if(o.length){if(ur){if(ur<70){let U=o[0].flags;U.dependsOn=2,U.isNonSync=0;}}else if(Fc&&B-V<H-q&&L/H<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=m;for(let O=0,se=o.length;O<se;O++){let oe=U+o[O].duration,me=U+o[O].cts;if(O<se-1){let ue=oe+o[O+1].cts;o[O].duration=ue-me;}else o[O].duration=O?o[O-1].duration:L;o[O].cts=0,U=oe;}}}f=N||!f?L:f;let j=E+f;this.nextVideoTs=u=j-c,this.videoSampleDuration=f,this.isVideoContiguous=true;let Y={data1:We.moof(e.sequenceNumber++,m,Te(e,{samples:o})),data2:_,startPTS:(p-c)/n,endPTS:(v+f-c)/n,startDTS:(m-c)/n,endDTS:u/n,type:"video",hasAudio:false,hasVideo:true,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Y}getSamplesPerFrame(e){switch(e.segmentCodec){case "mp3":return PS;case "ac3":return OS;default:return wS}}remuxAudio(e,t,i,r,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,d=a/o,l=this.getSamplesPerFrame(e),c=l*d,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,E=e.samples,p=h?0:8,v=this.nextAudioTs||-1,S=u.baseTime*a/u.timescale,y=S+t*a;if(this.isAudioContiguous=i=i||E.length&&v>0&&(r&&Math.abs(y-(v+S))<9e3||Math.abs(Lt(E[0].pts,y)-(v+S))<20*c),E.forEach(function(B){B.pts=Lt(B.pts,y);}),!i||v<0){if(E=E.filter(B=>B.pts>=0),!E.length)return;n===0?v=0:r&&!m?v=Math.max(0,y-S):v=E[0].pts-S;}if(e.segmentCodec==="aac"){let B=this.config.maxAudioFramesDrift;for(let j=0,P=v+S;j<E.length;j++){let z=E[j],Y=z.pts,U=Y-P,O=Math.abs(1e3*U/a);if(U<=-B*c&&m)j===0&&(this.warn(`Audio frame @ ${(Y/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*U/a)} ms.`),this.nextAudioTs=v=Y-S,P=Y);else if(U>=B*c&&O<MS&&m){let se=Math.round(U/c);for(P=Y-se*c;P<0&&se&&c;)se--,P+=c;j===0&&(this.nextAudioTs=v=P-S),this.warn(`Injecting ${se} audio frames @ ${((P-S)/a).toFixed(3)}s due to ${Math.round(1e3*U/a)} ms gap.`);for(let oe=0;oe<se;oe++){let me=bu.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);me||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),me=z.unit.subarray()),E.splice(j,0,{unit:me,pts:P}),P+=c,j++;}}z.pts=P,P+=c;}}let b=null,L=null,k,I=0,x=E.length;for(;x--;)I+=E[x].unit.byteLength;for(let B=0,j=E.length;B<j;B++){let P=E[B],z=P.unit,Y=P.pts;if(L!==null){let O=f[B-1];O.duration=Math.round((Y-L)/d);}else if(i&&e.segmentCodec==="aac"&&(Y=v+S),b=Y,I>0){I+=p;try{k=new Uint8Array(I);}catch(O){this.observer.emit(g.ERROR,g.ERROR,{type:W.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:false,error:O,bytes:I,reason:`fail allocating audio mdat ${I}`});return}h||(new DataView(k.buffer).setUint32(0,I),k.set(We.types.mdat,4));}else return;k.set(z,p);let U=z.byteLength;p+=U,f.push(Ug(true,l,U,0)),L=Y;}let D=f.length;if(!D)return;let _=f[f.length-1];v=L-S,this.nextAudioTs=v+d*_.duration;let M=h?new Uint8Array(0):We.moof(e.sequenceNumber++,b/d,Te({},e,{samples:f}));e.samples=[];let N=(b-S)/a,q=v/a,H={data1:M,data2:k,startPTS:N,endPTS:q,startDTS:N,endDTS:q,type:"audio",hasAudio:true,hasVideo:false,nb:D};return this.isAudioContiguous=true,H}};function Lt(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function NS(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return -1}function Qp(s,e,t,i){let r=s.samples.length;if(!r)return;let n=s.inputTimeScale;for(let o=0;o<r;o++){let d=s.samples[o];d.pts=Lt(d.pts-t.baseTime*n/t.timescale,e*n)/n,d.dts=Lt(d.dts-i.baseTime*n/i.timescale,e*n)/n;}let a=s.samples;return s.samples=[],{samples:a}}function Xp(s,e,t){let i=s.samples.length;if(!i)return;let r=s.inputTimeScale;for(let a=0;a<i;a++){let o=s.samples[a];o.pts=Lt(o.pts-t.baseTime*r/t.timescale,e*r)/r;}s.samples.sort((a,o)=>a.pts-o.pts);let n=s.samples;return s.samples=[],{samples:n}}var Au=class extends bt{constructor(e,t,i,r){super("passthrough-remuxer",r),this.emitInitSegment=false,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=false;}destroy(){}resetTimeStamp(e){this.lastEndTime=null;let t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e);}resetNextTimestamp(){this.isVideoContiguous=false,this.lastEndTime=null;}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(VT(e,r)),this.emitInitSegment=true;}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let r=this.initData=fp(e);r.audio&&(t=Bg(r.audio,_e.AUDIO,this)),r.video&&(i=Bg(r.video,_e.VIDEO,this));let n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+i,supplemental:r.video.supplemental,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:i,supplemental:r.video.supplemental,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=n;}remux(e,t,i,r,n,a){var o,d;let{initPTS:l,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};$(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let f={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((d=m)!=null&&d.length))return this.warn("Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=false);let E=WT(h,m,this),p=m.audio?E[m.audio.id]:null,v=m.video?E[m.video.id]:null,S=qo(v,1/0),y=qo(p,1/0),b=qo(v,0,true),L=qo(p,0,true),k,I=n,x=0;if(p&&(!v||!l&&y<S||l&&l.trackId===m.audio.id)?(f.trackId=m.audio.id,k=p,x=L-y):v&&(f.trackId=m.video.id,k=v,x=b-S),k){let B=k.timescale;I=k.start/B,f.initPTS=k.start-n*B,f.timescale=B,l||(this.initPTS=l={baseTime:f.initPTS,timescale:B,trackId:f.trackId});}(a||!l)&&(FS(l,I,n,x)||f.timescale!==l.timescale)&&(f.initPTS=I-n,f.timescale=1,l&&l.timescale===1&&this.warn(`Adjusting initPTS @${n} from ${l.baseTime/l.timescale} to ${f.initPTS}`),this.initPTS=l={baseTime:f.initPTS,timescale:1});let D=e?I-l.baseTime/l.timescale:c,_=D+x;x>0?this.lastEndTime=_:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let M=!!m.audio,N=!!m.video,q="";M&&(q+="audio"),N&&(q+="video");let V={data1:h,startPTS:D,startDTS:D,endPTS:_,endDTS:_,type:q,hasAudio:M,hasVideo:N,nb:1,dropped:0};u.audio=M&&!N?V:void 0,u.video=N?V:void 0;let H=v?.sampleCount;if(H){let B=v.keyFrameIndex,j=B!==-1;V.nb=H,V.dropped=B===0||this.isVideoContiguous?0:j?B:H,V.independent=j,V.firstKeyFrame=B,j&&v.keyFrameStart&&(V.firstKeyFramePTS=(v.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(u.independent=j),this.isVideoContiguous||(this.isVideoContiguous=j),V.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${B}/${H} dropped: ${V.dropped} start: ${V.firstKeyFramePTS||"NA"}`);}return u.initSegment=f,u.id3=Qp(i,n,l,l),r.samples.length&&(u.text=Xp(r,n,l)),u}};function qo(s,e,t=false){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function FS(s,e,t,i){if(s===null)return true;let r=Math.max(i,1),n=e-s.baseTime/s.timescale;return Math.abs(n-t)>r}function Bg(s,e,t){let i=s?.codec;return i&&i.length>4?i:e===_e.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?al(i,false):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}var Si;try{Si=self.performance.now.bind(self.performance);}catch{Si=Date.now;}var el=[{demux:Eu,remux:Au},{demux:Tu,remux:pr},{demux:mu,remux:pr},{demux:pu,remux:pr}];el.splice(2,0,{demux:gu,remux:pr});var bl=class{constructor(e,t,i,r,n,a){this.asyncResult=false,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=i,this.id=n,this.logger=a;}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset();}push(e,t,i,r){let n=i.transmuxing;n.executeStart=Si();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:d}=this;r&&(this.currentTransmuxState=r);let{contiguous:l,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:E,videoCodec:p,defaultInitPts:v,duration:S,initSegmentData:y}=d,b=US(a,t);if(b&&gr(b.method)){let x=this.getDecrypter(),D=ph(b.method);if(x.isSync()){let _=x.softwareDecrypt(a,b.key.buffer,b.iv.buffer,D);if(i.part>-1){let N=x.flush();_=N&&N.buffer;}if(!_)return n.executeEnd=Si(),Uc(i);a=new Uint8Array(_);}else return this.asyncResult=true,this.decryptionPromise=x.webCryptoDecrypt(a,b.key.buffer,b.iv.buffer,D).then(_=>{let M=this.push(_,null,i);return this.decryptionPromise=null,M}),this.decryptionPromise}let L=this.needsProbing(c,u);if(L){let x=this.configureTransmuxer(a);if(x)return this.logger.warn(`[transmuxer] ${x.message}`),this.observer.emit(g.ERROR,g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:false,error:x,reason:x.message}),n.executeEnd=Si(),Uc(i)}(c||u||m||L)&&this.resetInitSegment(y,E,p,S,t),(c||m||L)&&this.resetInitialTimestamp(v),l||this.resetContiguity();let k=this.transmux(a,b,f,h,i);this.asyncResult=$n(k);let I=this.currentTransmuxState;return I.contiguous=true,I.discontinuity=false,I.trackSwitch=false,n.executeEnd=Si(),k}flush(e){let t=e.transmuxing;t.executeStart=Si();let{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return this.asyncResult=true,n.then(()=>this.flush(e));let a=[],{timeOffset:o}=r;if(i){let u=i.flush();u&&a.push(this.push(u.buffer,null,e));}let{demuxer:d,remuxer:l}=this;if(!d||!l){t.executeEnd=Si();let u=[Uc(e)];return this.asyncResult?Promise.resolve(u):u}let c=d.flush(o);return $n(c)?(this.asyncResult=true,c.then(u=>(this.flushRemux(a,u,e),a))):(this.flushRemux(a,c,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){let{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:d,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===K.MAIN?"level":"track"} ${i.level}`);let c=this.remuxer.remux(r,n,a,o,l,d,true,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=Si();}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e));}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp());}resetInitSegment(e,t,i,r,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,r),o.resetInitSegment(e,t,i,n));}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0);}transmux(e,t,i,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,r,n):a=this.transmuxUnencrypted(e,i,r,n),a}transmuxUnencrypted(e,t,i,r){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:d}=this.demuxer.demux(e,t,false,!this.config.progressive);return {remuxResult:this.remuxer.remux(n,a,o,d,t,i,false,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,false,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:r}=this,n;for(let u=0,h=el.length;u<h;u++){var a;if((a=el[u].demux)!=null&&a.probe(e,this.logger)){n=el[u];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,d=this.remuxer,l=n.remux,c=n.demux;(!d||!(d instanceof l))&&(this.remuxer=new l(i,t,r,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,t,r,this.logger),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 Pn(this.config)),e}};function US(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Uc=s=>({remuxResult:{},chunkMeta:s});function $n(s){return "then"in s&&s.then instanceof Function}var _u=class{constructor(e,t,i,r,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=i,this.duration=r,this.defaultInitPts=n||null;}},Iu=class{constructor(e,t,i,r,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=i,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=a;}},$g=0,Al=class{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=$g++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=d=>{let l=d.data,c=this.hls;if(!(!c||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case "init":{var u;let h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case "transmuxComplete":{this.handleTransmuxComplete(l.data);break}case "flush":{this.onFlush(l.data);break}case "workerLog":{c.logger[l.data.logType]&&c.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,c.trigger(l.event,l.data);break}}},this.onWorkerError=d=>{if(!this.hls)return;let l=new Error(`${d.message} (${d.filename}:${d.lineno})`);this.hls.config.enableWorker=false,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:false,event:"demuxerWorker",error:l});};let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let a=(d,l)=>{l=l||{},l.frag=this.frag||void 0,d===g.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(d,l);};this.observer=new Eh,this.observer.on(g.FRAG_DECRYPTED,a),this.observer.on(g.ERROR,a);let o=ag(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){let d=this.hls.logger;if(n.workerPath||Jy()){try{n.workerPath?(d.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=tS(n.workerPath)):(d.log(`injecting Web Worker for "${t}"`),this.workerContext=eS());let{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Re(n)});}catch(c){d.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new bl(this.observer,o,n,"",t,e.logger);}return}}this.transmuxer=new bl(this.observer,o,n,"",t,e.logger);}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=$g++;let t=this.hls.config,i=ag(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Re(t)});}}terminateWorker(){if(this.workerContext){let{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),iS(this.hls.config.workerPath);}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else {let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null);}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null;}push(e,t,i,r,n,a,o,d,l,c){var u,h;l.transmuxing.start=self.performance.now();let{instanceNo:f,transmuxer:m}=this,E=a?a.start:n.start,p=n.decryptdata,v=this.frag,S=!(v&&n.cc===v.cc),y=!(v&&l.level===v.level),b=v?l.sn-v.sn:-1,L=this.part?l.part-this.part.index:-1,k=b===0&&l.id>1&&l.id===v?.stats.chunkCount,I=!y&&(b===1||b===0&&(L===1||k&&L<=0)),x=self.performance.now();(y||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=x),a&&(L||!I)&&(a.stats.parsing.start=x);let D=!(v&&((u=n.initSegment)==null?void 0:u.url)===((h=v.initSegment)==null?void 0:h.url)),_=new Iu(S,I,d,y,E,D);if(!I||S||D){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===K.MAIN?"level":"track"}: ${l.level} id: ${l.id}
|
|
1704
|
-
discontinuity: ${S}
|
|
1705
|
-
trackSwitch: ${y}
|
|
1706
|
-
contiguous: ${I}
|
|
1707
|
-
accurateTimeOffset: ${d}
|
|
1708
|
-
timeOffset: ${E}
|
|
1709
|
-
initSegmentChange: ${D}`);let M=new _u(i,r,t,o,c);this.configureTransmuxer(M);}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:_},e instanceof ArrayBuffer?[e]:[]);else if(m){let M=m.push(e,p,l,_);$n(M)?M.then(N=>{this.handleTransmuxComplete(N);}).catch(N=>{this.transmuxerError(N,l,"transmuxer-interface push error");}):this.handleTransmuxComplete(M);}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let r=i.flush(e);$n(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,i){this.hls&&(this.error=e,this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:false,error:e,err:e,reason:i}));}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i);}),this.onFlush(t);}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e);}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e);}},Gg=100,Lu=class extends Nn{constructor(e,t,i){super(e,t,i,"audio-stream-controller",K.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=false,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=false,this.bufferFlushed=false,this.cachedTrackLoadedData=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem();}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(g.BUFFER_RESET,this.onBufferReset,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(g.BUFFER_RESET,this.onBufferReset,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this));}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n}){if(i===K.MAIN){let a=t.cc,o=this.fragCurrent;if(this.initPTS[a]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${r}/${n}`),this.mainAnchor=t,this.state===C.WAITING_INIT_PTS){let d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==a)&&this.syncWithAnchor(t,d?.frag);}else !this.hls.hasEnoughToStart&&o&&o.cc!==a?(o.abortRequests(),this.syncWithAnchor(t,o)):this.state===C.IDLE&&this.tick();}}getLoadPosition(){return !this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;let r=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&r?.cc===t.cc)return;let n=(r||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),d=bp(a,n,o);d&&(this.log(`Syncing with main frag at ${d.start} cc ${d.cc}`),this.startFragRequested=false,this.nextLoadPosition=d.start,this.resetLoadingState(),this.state===C.IDLE&&this.doTickIdle());}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=C.STOPPED;return}let i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Gg),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=C.IDLE):this.state=C.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}doTick(){switch(this.state){case C.IDLE:this.doTickIdle();break;case C.WAITING_TRACK:{let{levels:t,trackId:i}=this,r=t?.[i],n=r?.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=C.WAITING_INIT_PTS;}break}case C.FRAG_LOADING_WAITING_RETRY:{var e;let t=performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){let{levels:r,trackId:n}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(r?.[n]||null),this.state=C.IDLE;}break}case C.WAITING_INIT_PTS:{let t=this.waitingData;if(t){let{frag:i,part:r,cache:n,complete:a}=t,o=this.mainAnchor;if(this.initPTS[i.cc]!==void 0){this.waitingData=null,this.state=C.FRAG_LOADING;let d=n.flush().buffer,l={frag:i,part:r,payload:d,networkDetails:null};this._handleFragmentLoadProgress(l),a&&super._handleFragmentLoadComplete(l);}else o&&o.cc!==t.frag.cc&&this.syncWithAnchor(o,t.frag);}else this.state=C.IDLE;}}this.onTickEnd();}resetLoadingState(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState();}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime);}doTickIdle(){var e;let{hls:t,levels:i,media:r,trackId:n}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;let o=i[n],d=o.details;if(!d||this.waitForLive(o)||this.waitForCdnTuneIn(d)){this.state=C.WAITING_TRACK,this.startFragRequested=false;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=false,this.afterBufferFlushed(l,_e.AUDIO,K.AUDIO));let c=this.getFwdBufferInfo(l,K.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,d)){t.trigger(g.BUFFER_EOS,{type:"audio"}),this.state=C.ENDED;return}let u=c.len,h=t.maxBufferLength,f=d.fragments,m=f[0].start,E=this.getLoadPosition(),p=this.flushing?E:c.end;if(this.switchingTrack&&r){let y=E;d.PTSKnown&&y<m&&(c.end>m||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05);}if(u>=h&&!this.switchingTrack&&p<f[f.length-1].start)return;let v=this.getNextFragment(p,d);if(v&&this.isLoopLoading(v,p)&&(v=this.getNextFragmentLoopLoading(v,d,c,K.MAIN,h)),!v){this.bufferFlushed=true;return}let S=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&S&&$e(v)&&!v.endList&&(!d.live||!this.loadingParts&&p<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(S)===Ke.OK&&(this.mainFragLoading=S=null),S&&$e(S))){if(v.start>S.end){let b=this.fragmentTracker.getFragAtPos(p,K.MAIN);b&&b.end>S.end&&(S=b,this.mainFragLoading={frag:b,targetBufferTime:null});}if(v.start>S.end)return}this.loadFragment(v,o,p);}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=false,super.onMediaDetaching(e,t);}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new vs(i));}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==C.STOPPED&&(this.setInterval(Gg),this.state=C.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval());}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=false,this.resetItem(),this.trackId=-1;}onLevelLoaded(e,t){this.mainDetails=t.details;let i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(g.AUDIO_TRACK_LOADED,i));}onAudioTrackLoaded(e,t){var i;let{levels:r}=this,{details:n,id:a,groupId:o,track:d}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${d.name}" of "${o}"`);return}let l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==C.STOPPED&&(this.state=C.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${d.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let c=r[a],u=0;if(n.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details);}n.alignedSliding||(Pp(n,l),n.alignedSliding||pl(n,l),u=n.fragmentStart);}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,u),this.hls.trigger(g.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===C.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=C.IDLE),this.tick();}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{config:a,trackId:o,levels:d}=this;if(!d){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let l=d[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}let c=l.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let u=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Al(this.hls,K.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[i.cc],m=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){let p=r?r.index:-1,v=p!==-1,S=new On(i.level,i.sn,i.stats.chunkCount,n.byteLength,p,v);h.push(n,m,u,"",i,r,c.totalduration,false,S,f);}else {this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new El,complete:false};E.push(new Uint8Array(n)),this.state!==C.STOPPED&&(this.state=C.WAITING_INIT_PTS);}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=true;return}super._handleFragmentLoadComplete(e);}onBufferReset(){this.mediaBuffer=null;}onBufferCreated(e,t){this.bufferFlushed=this.flushing=false;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null);}onFragLoading(e,t){!this.audioOnly&&t.frag.type===K.MAIN&&$e(t.frag)&&(this.mainFragLoading=t,this.state===C.IDLE&&this.tick());}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==K.AUDIO){!this.audioOnly&&i.type===K.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=true,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if($e(i)){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(g.AUDIO_TRACK_SWITCHED,be({},n)));}this.fragBufferedComplete(i,r),this.media&&this.tick();}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case R.FRAG_GAP:case R.FRAG_PARSING_ERROR:case R.FRAG_DECRYPT_ERROR:case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(K.AUDIO,t);break;case R.AUDIO_TRACK_LOAD_ERROR:case R.AUDIO_TRACK_LOAD_TIMEOUT:case R.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ce.AUDIO_TRACK&&(this.state=C.IDLE);break;case R.BUFFER_ADD_CODEC_ERROR:case R.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case R.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case R.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==_e.VIDEO&&(this.flushing=true);}onBufferFlushed(e,{type:t}){if(t!==_e.VIDEO){this.flushing=false,this.bufferFlushed=true,this.state===C.ENDED&&(this.state=C.IDLE);let i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,K.AUDIO),this.tick());}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:d,part:l,level:c}=o,{details:u}=c,{audio:h,text:f,id3:m,initSegment:E}=n;if(this.fragContextChanged(d)||!u){this.fragmentTracker.removeFragment(d);return}if(this.state=C.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let p=d.initSegment||d;this._bufferInitSegment(c,E.tracks,p,a),r.trigger(g.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:i,tracks:E.tracks});}if(h){let{startPTS:p,endPTS:v,startDTS:S,endDTS:y}=h;l&&(l.elementaryStreams[_e.AUDIO]={startPTS:p,endPTS:v,startDTS:S,endDTS:y}),d.setElementaryStreamInfo(_e.AUDIO,p,v,S,y),this.bufferFragmentData(h,d,l,a);}if(m!=null&&(t=m.samples)!=null&&t.length){let p=Te({id:i,frag:d,details:u},m);r.trigger(g.FRAG_PARSING_METADATA,p);}if(f){let p=Te({id:i,frag:d,details:u},f);r.trigger(g.FRAG_PARSING_USERDATA,p);}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let n=t.audio;n.id=K.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(g.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let d={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:o};this.hls.trigger(g.BUFFER_APPENDING,d);}this.tickImmediate();}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===Ke.NOT_LOADED||r===Ke.PARTIAL){var n;if(!$e(e))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=C.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&pl(t.details,a);}else super.loadFragment(e,t,i);}else this.clearTrackerIfNeeded(e);}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;ps({name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e,fs)||(dl(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e);}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(g.AUDIO_TRACK_SWITCHED,be({},e));}},Gn=class extends bt{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=false,this.timer=-1,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=true,this.loadPlaylist();}stopLoad(){this.canLoad=false,this.clearTimer();}switchParams(e,t,i){let r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){let o=r[a],d;try{d=new self.URL(o.URI,t.url).href;}catch(l){this.warn(`Could not construct new URL for Rendition Report: ${l}`),d=o.URI||"";}if(d===e){n=a;break}else d===e.substring(0,d.length)&&(n=a);}if(n!==-1){let a=r[n],o=parseInt(a["LAST-MSN"])||t?.lastPartSn,d=parseInt(a["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){let c=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&c>t.partTarget&&(d+=1);}let l=i&&og(i);return new ll(o,d>=0?d:void 0,l)}}}loadPlaylist(e){this.clearTimer();}loadingPlaylist(e,t){this.clearTimer();}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`);}return e}playlistLoaded(e,t,i){let{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;r.advancedDateTime=Date.now()-o;let d=this.hls.config.timelineOffset;if(d!==r.appliedTimelineOffset){let c=Math.max(d||0,0);r.appliedTimelineOffset=c,r.fragments.forEach(u=>{u.start=u.playlistOffset+c;});}if(r.live||i!=null&&i.live){let c="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){Vy(i,r);let S=r.playlistParsingError;if(S){this.warn(S);let y=this.hls;if(!y.config.ignorePlaylistParsingErrors){var l;let{networkDetails:b}=t;y.trigger(g.ERROR,{type:W.NETWORK_ERROR,details:R.LEVEL_PARSING_ERROR,fatal:false,url:r.url,error:S,reason:S.message,level:t.level||void 0,parent:(l=r.fragments[0])==null?void 0:l.type,networkDetails:b,stats:n});return}r.playlistParsingError=null;}}r.requestScheduled===-1&&(r.requestScheduled=n.loading.start);let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(r.edge-h)*1e3,m=Dp(r,f);if(r.requestScheduled+m<a?r.requestScheduled=a:r.requestScheduled+=m,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let E,p,v;if(r.canBlockReload&&r.endSN&&r.advanced){let S=this.hls.config.lowLatencyMode,y=r.lastPartSn,b=r.endSN,L=r.lastPartIndex,k=L!==-1,I=y===b;k?I?(p=b+1,v=S?0:L):(p=y,v=S?L+1:r.maxPartIndex):p=b+1;let x=r.age,D=x+r.ageHeader,_=Math.min(D-r.partTarget,r.targetduration*1.5);if(_>0){if(D>r.targetduration*3)this.log(`Playlist last advanced ${x.toFixed(2)}s ago. Omitting segment and part directives.`),p=void 0,v=void 0;else if(i!=null&&i.tuneInGoal&&D-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${_} with playlist age: ${r.age}`),_=0;else {let M=Math.floor(_/r.targetduration);if(p+=M,v!==void 0){let N=Math.round(_%r.targetduration/r.partTarget);v+=N;}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${x.toFixed(2)}s goal: ${_} skip sn ${M} to part ${v}`);}r.tuneInGoal=_;}if(E=this.getDeliveryDirectives(r,t.deliveryDirectives,p,v),S||!I){r.requestScheduled=a,this.loadingPlaylist(c,E);return}}else (r.canBlockReload||r.canSkipUntil)&&(E=this.getDeliveryDirectives(r,t.deliveryDirectives,p,v));E&&p!==void 0&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(c,E,r);}else this.clearTimer();}scheduleLoading(e,t,i){let r=i||e.details;if(!r){this.loadingPlaylist(e,t);return}let n=self.performance.now(),a=r.requestScheduled;if(n>=a){this.loadingPlaylist(e,t);return}let o=a-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o);}getDeliveryDirectives(e,t,i,r){let n=og(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=Zo.No),new ll(i,r,n)}checkRetry(e){let t=e.details,i=cl(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},d=!!r&&!!o&&(n===et.RetryRequest||!r.resolved&&n===et.SendAlternateToPenaltyBox);if(d){var l;if(a>=o.maxNumRetry)return false;if(i&&(l=e.context)!=null&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else {let c=gh(o,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`);}e.levelRetry=true,r.resolved=true;}return d}};function Zp(s,e){if(s.length!==e.length)return false;for(let t=0;t<s.length;t++)if(!Hn(s[t].attrs,e[t].attrs))return false;return true}function Hn(s,e,t){let i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>s[r]!==e[r])}function xu(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}var Ru=class extends Gn{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true,this.registerListeners();}registerListeners(){let{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(g.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=true;}onManifestParsed(e,t){this.tracks=t.audioTracks||[];}onAudioTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Audio track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.audioGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(o=>r?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!i||i.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=false),o.forEach((h,f)=>{h.id=f;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let d=this.hls.config.audioPreference;if(!n&&d){let h=ci(d,o,fs);if(h>-1)n=o[h];else {let f=ci(d,this.tracks);n=this.tracks[f];}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(g.AUDIO_TRACKS_UPDATED,c);let u=this.trackId;if(l!==-1&&u===-1)this.setAudioTrack(l);else if(o.length&&u===-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(g.ERROR,{type:W.MEDIA_ERROR,details:R.AUDIO_TRACK_LOAD_ERROR,fatal:true,error:h});}}}onError(e,t){t.fatal||!t.context||t.context.type===ce.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=false,this.setAudioTrack(e);}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let i=this.allAudioTracks;if(this.selectDefaultTrack=false,i.length){let r=this.currentTrack;if(r&&ps(e,r,fs))return r;let n=ci(e,this.tracksInGroup,fs);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=py(e,t.levels,i,a,fs);if(o===-1)return null;t.nextLoadLevel=o;}if(e.channels||e.audioCodec){let a=ci(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===i&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(g.AUDIO_TRACK_SWITCHING,be({},r)),n))return;let a=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(a);}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if(!(this.selectDefaultTrack&&!r.default)&&(!e||ps(e,r,fs)))return i}if(e){let{name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:d}=e;for(let l=0;l<t.length;l++){let c=t[l];if(ps({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:d},c,fs))return l}for(let l=0;l<t.length;l++){let c=t[l];if(Hn(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){let c=t[l];if(Hn(e.attrs,c.attrs,["LANGUAGE"]))return l}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&dl(t.url,this.hls)&&this.scheduleLoading(t,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(g.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}},Du=class{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e;}destroy(){this.tracks=this.queues=null;}append(e,t,i){if(this.queues===null||this.tracks===null)return;let r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t);}appendBlocker(e){return new Promise(t=>{let i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e);})}prependBlocker(e){return new Promise(t=>{if(this.queues){let i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i);}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;let i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1));});}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio");}executeNext(e){if(this.queues===null||this.tracks===null)return;let t=this.queues[e];if(t.length){let r=t[0];try{r.execute();}catch(n){var i;if(r.onError(n),this.queues===null||this.tracks===null)return;let a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e);}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e));}current(e){var t;return ((t=this.queues)==null?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
|
|
1710
|
-
${this.list("video")}
|
|
1711
|
-
${this.list("audio")}
|
|
1712
|
-
${this.list("audiovideo")}}`}list(e){var t,i;return (t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=(t=this.tracks)==null?void 0:t[e],r=i?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return ((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}},Hg=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Jp="HlsJsTrackRemovedError",ku=class extends Error{constructor(e){super(e),this.name=Jp;}},Cu=class extends bt{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var r;this.hls&&((r=this.mediaSource)==null?void 0:r.readyState)==="open"&&this.hls.pauseBuffering();},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering();},this._onMediaSourceOpen=i=>{let{media:r,mediaSource:n}=this;i&&this.log("Media source opened"),!(!r||!n)&&(n.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(g.MEDIA_ATTACHED,{media:r,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks());},this._onMediaSourceClose=()=>{this.log("Media source closed");},this._onMediaSourceEnded=()=>{this.log("Media source ended");},this._onMediaEmptied=()=>{let{mediaSrc:i,_objectUrl:r}=this;i!==r&&this.error(`Media element src was set while attaching MediaSource (${r} > ${i})`);},this.hls=e,this.fragmentTracker=t,this.appendSource=PT(Gi(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners();}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null;}registerListeners(){let{hls:e}=this;e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.BUFFER_RESET,this.onBufferReset,this),e.on(g.BUFFER_APPENDING,this.onBufferAppending,this),e.on(g.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.BUFFER_EOS,this.onBufferEos,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.FRAG_PARSED,this.onFragParsed,this),e.on(g.FRAG_CHANGED,this.onFragChanged,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.BUFFER_RESET,this.onBufferReset,this),e.off(g.BUFFER_APPENDING,this.onBufferAppending,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.BUFFER_EOS,this.onBufferEos,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.FRAG_PARSED,this.onFragParsed,this),e.off(g.FRAG_CHANGED,this.onFragChanged,this),e.off(g.ERROR,this.onError,this);}transferMedia(){let{media:e,mediaSource:t}=this;if(!e)return null;let i={};if(this.operationQueue){let n=this.isUpdating();n||this.operationQueue.removeBlockers();let a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy();}let r=this.transferData;return !this.sourceBufferCount&&r&&r.mediaSource===t?Te(i,r.tracks):this.sourceBuffers.forEach(n=>{let[a]=n;a&&(i[a]=Te({},this.tracks[a]),this.removeBuffer(a)),n[0]=n[1]=null;}),{media:e,mediaSource:t,tracks:i}}initTracks(){let e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0;}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null;}onManifestParsed(e,t){var i;let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(`${r} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated();}onMediaAttaching(e,t){let i=this.media=t.media,r=Gi(this.appendSource);if(this.transferData=this.overrides=void 0,i&&r){let n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else {let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");let d=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||d&&a instanceof d,Vg(i),BS(i,o),i.load();}catch{i.src=o;}else i.src=o;}i.addEventListener("emptied",this._onMediaEmptied);}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming));}attachTransferred(){let e=this.media,t=this.transferData;if(!t||!e)return;let i=this.tracks,r=t.tracks,n=r?Object.keys(r):null,a=n?n.length:0,o=()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen();};if(r&&n&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=true,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
|
|
1713
|
-
required tracks: ${Re(i,(d,l)=>d==="initSegment"?void 0:l)};
|
|
1714
|
-
transfer tracks: ${Re(r,(d,l)=>d==="initSegment"?void 0:l)}}`),!op(r,i)){t.mediaSource=null,t.tracks=void 0;let d=e.currentTime,l=this.details,c=Math.max(d,l?.fragments[0].start||0);if(c-d>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${d} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${d}`),this.onMediaDetaching(g.MEDIA_DETACHING,{}),this.onMediaAttaching(g.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,n.forEach(d=>{let l=d,c=r[l];if(c){let u=c.buffer;if(u){let h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){let p=ne.getBuffered(u);h.detectEvictedFragments(l,p,f,null,true);}let m=Bc(l),E=[l,u];this.sourceBuffers[m]=E,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,c);}}}),o(),this.bufferCreated();}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o();}get mediaSourceOpenOrEnded(){var e;let t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:r,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o);}),this.resetQueue();else {if(this.mediaSourceOpenOrEnded){let o=n.readyState==="open";try{let d=n.sourceBuffers;for(let l=d.length;l--;)o&&d[l].abort(),n.removeSourceBuffer(d[l]);o&&n.endOfStream();}catch(d){this.warn(`onMediaDetaching: ${d.message} while calling endOfStream`);}}this.sourceBufferCount&&this.onBufferReset();}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null;}r&&(r.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&Vg(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(g.MEDIA_DETACHED,t);}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e);}),this.initTracks();}resetBuffer(e){var t;let i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i);}catch(n){this.warn(`onBufferReset ${e}`,n);}delete this.tracks[e];}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Bc(e)]=[null,null];let t=this.tracks[e];t&&(t.buffer=void 0);}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Du(this.tracks);}onBufferCodecs(e,t){let i=this.tracks,r=Object.keys(t);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);let n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!n&&this.sourceBufferCount&&this.media&&r.some(o=>!i[o]);if(n||a){this.warn(`Unsupported transition between "${Object.keys(i)}" and "${r}" SourceBuffers`);return}r.forEach(o=>{var d,l,c;let u=t[o],{id:h,codec:f,levelCodec:m,container:E,metadata:p,supplemental:v}=u,S=i[o],y=(d=this.transferData)==null||(l=d.tracks)==null?void 0:l[o],b=y!=null&&y.buffer?y:S,L=b?.pendingCodec||b?.codec,k=b?.levelCodec;S||(S=i[o]={buffer:void 0,listeners:[],codec:f,supplemental:v,container:E,levelCodec:m,metadata:p,id:h});let I=Xo(L,k),x=I?.replace(Hg,"$1"),D=Xo(f,m),_=(c=D)==null?void 0:c.replace(Hg,"$1");D&&I&&x!==_&&(o.slice(0,5)==="audio"&&(D=al(D,this.appendSource)),this.log(`switching codec ${L} to ${D}`),D!==(S.pendingCodec||S.codec)&&(S.pendingCodec=D),S.container=E,this.appendChangeType(o,E,D));}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks();}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let r=`${t};codecs=${i}`,n={label:`change-type=${r}`,execute:()=>{let a=this.tracks[e];if(a){let o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),o.changeType(r),a.codec=i,a.container=t);}this.shiftAndExecuteNext(e);},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a);}};this.append(n,e,this.isPending(this.tracks[e]));}blockAudio(e){var t;let i=e.start,r=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,K.MAIN))==null?void 0:t.gap)===true)return;let a={label:"block-audio",execute:()=>{var o;let d=this.tracks.video;(this.lastVideoAppendEnd>r||d!=null&&d.buffer&&ne.isBuffered(d.buffer,r)||((o=this.fragmentTracker.getAppendedFrag(r,K.MAIN))==null?void 0:o.gap)===true)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"));},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o);}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",true);}unblockAudio(){let{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op));}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:n,parent:a,frag:o,part:d,chunkMeta:l,offset:c}=t,u=l.buffering[n],{sn:h,cc:f}=o,m=self.performance.now();u.start=m;let E=o.stats.buffering,p=d?d.stats.buffering:null;E.start===0&&(E.start=m),p&&p.start===0&&(p.start=m);let v=i.audio,S=false;n==="audio"&&v?.container==="audio/mpeg"&&(S=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);let y=i.video,b=y?.buffer;if(b&&h!=="initSegment"){let I=d||o,x=this.blockedAudioAppend;if(n==="audio"&&a!=="main"&&!this.blockedAudioAppend){let _=I.start+I.duration*.05,M=b.buffered,N=this.currentOp("video");!M.length&&!N?this.blockAudio(I):!N&&!ne.isBuffered(b,_)&&this.lastVideoAppendEnd<_&&this.blockAudio(I);}else if(n==="video"){let D=I.end;if(x){let _=x.frag.start;(D>_||D<this.lastVideoAppendEnd||ne.isBuffered(b,_))&&this.unblockAudio();}this.lastVideoAppendEnd=D;}}let L=(d||o).start,k={label:`append-${n}`,execute:()=>{var I;u.executeStart=self.performance.now();let x=(I=this.tracks[n])==null?void 0:I.buffer;x&&(S?this.updateTimestampOffset(x,L,.1,n,h,f):c!==void 0&&$(c)&&this.updateTimestampOffset(x,c,1e-6,n,h,f)),this.appendExecutor(r,n);},onStart:()=>{},onComplete:()=>{let I=self.performance.now();u.executeEnd=u.end=I,E.first===0&&(E.first=I),p&&p.first===0&&(p.first=I);let x={};this.sourceBuffers.forEach(([D,_])=>{D&&(x[D]=ne.getBuffered(_));}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(g.BUFFER_APPENDED,{type:n,frag:o,part:d,chunkMeta:l,parent:o.type,timeRanges:x});},onError:I=>{var x;let D={type:W.MEDIA_ERROR,parent:o.type,details:R.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:d,chunkMeta:l,error:I,err:I,fatal:false},_=(x=this.media)==null?void 0:x.error;if(I.code===DOMException.QUOTA_EXCEEDED_ERR||I.name=="QuotaExceededError"||"quota"in I)D.details=R.BUFFER_FULL_ERROR;else if(I.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!_)D.errorAction=wn(true);else if(I.name===Jp&&this.sourceBufferCount===0)D.errorAction=wn(true);else {let M=++this.appendErrors[n];this.warn(`Failed ${M}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${_||"no media error"})`),(M>=this.hls.config.appendErrorMaxRetry||_)&&(D.fatal=true);}this.hls.trigger(g.ERROR,D);}};this.append(k,n,this.isPending(this.tracks[n]));}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i);},onStart:()=>{},onComplete:()=>{this.hls.trigger(g.BUFFER_FLUSHED,{type:e});},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r);}}}onBufferFlushing(e,t){let{type:i,startOffset:r,endOffset:n}=t;i?this.append(this.getFlushOp(i,r,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,n),a);});}onFragParsed(e,t){let{frag:i,part:r}=t,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[_e.AUDIOVIDEO]?n.push("audiovideo"):(a[_e.AUDIO]&&n.push("audio"),a[_e.VIDEO]&&n.push("video"));let o=()=>{let d=self.performance.now();i.stats.buffering.end=d,r&&(r.stats.buffering.end=d);let l=r?r.stats:i.stats;this.hls.trigger(g.FRAG_BUFFERED,{frag:i,part:r,stats:l,id:i.type});};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n).catch(d=>{this.warn(`Fragment buffered callback ${d}`),this.stepOperationQueue(this.sourceBufferTypes);});}onFragChanged(e,t){this.trimBuffers();}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t,i;return e&&(!((t=this.tracks[e])!=null&&t.ended)||((i=this.tracks[e])==null?void 0:i.ending))})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){let o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=true,o.ended||(o.ended=true,this.log(`${a} buffer reached EOS`)));}});let r=((i=this.overrides)==null?void 0:i.endOfStream)!==false;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})&&(r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(g.BUFFERED_TO_END,void 0);})):(this.tracksEnded(),this.hls.trigger(g.BUFFERED_TO_END,void 0)));}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){let t=this.tracks[e];t&&(t.ending=false);}});}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration());}updateDuration(){this.blockUntilOpen(()=>{let e=this.getDurationAndRange();e&&this.updateMediaSource(e);});}onError(e,t){if(t.details===R.BUFFER_APPEND_ERROR&&t.frag){var i;let r=(i=t.errorAction)==null?void 0:i.nextAutoLevel;$(r)&&r!==t.frag.level&&this.resetAppendErrors();}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0};}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;let r=e.config,n=i.currentTime,a=t.levelTargetDuration,o=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if($(o)&&o>=0){let d=Math.max(o,a),l=Math.floor(n/a)*a-d;this.flushBackBuffer(n,a,l);}if($(r.frontBufferFlushThreshold)&&r.frontBufferFlushThreshold>0){let d=Math.max(r.maxBufferLength,r.frontBufferFlushThreshold),l=Math.max(d,a),c=Math.floor(n/a)*a+l;this.flushFrontBuffer(n,a,c);}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let o=ne.getBuffered(n);if(o.length>0&&i>o.start(0)){var a;this.hls.trigger(g.BACK_BUFFER_REACHED,{bufferEnd:i});let d=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(g.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(d!=null&&d.ended){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:r});}}});}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let a=ne.getBuffered(n),o=a.length;if(o<2)return;let d=a.start(o-1),l=a.end(o-1);if(i>d||e>=d&&e<=l)return;this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:r});}});}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;let r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&t.live&&i.setLiveSeekableRange){let l=Math.max(0,t.fragmentStart),c=Math.max(l,r);return {duration:1/0,start:l,end:c}}return {duration:1/0}}let n=(e=this.overrides)==null?void 0:e.duration;if(n)return $(n)?{duration:n}:null;let a=this.media.duration,o=$(i.duration)?i.duration:0;return r>o&&r>a||!$(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;!this.media||!r||r.readyState!=="open"||(r.duration!==e&&($(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)));}get tracksReady(){let e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){let{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Re(i)}`),this.tracksReady){var r;let n=(r=this.transferData)==null?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers();}}bufferCreated(){if(this.sourceBufferCount){let e={};this.sourceBuffers.forEach(([t,i])=>{if(t){let r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata};}}),this.hls.trigger(g.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t);});}else {let e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,error:e,reason:e.message});}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(let n in e){let a=n,o=e[a];if(this.isPending(o)){let d=this.getTrackCodec(o,a),l=`${o.container};codecs=${d}`;o.codec=d,this.log(`creating sourceBuffer(${l})${this.currentOp(a)?" Queued":""} ${Re(o)}`);try{let c=i.addSourceBuffer(l),u=Bc(a),h=[a,c];t[u]=h,o.buffer=c;}catch(c){var r;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_ADD_CODEC_ERROR,fatal:false,error:c,sourceBufferName:a,mimeType:l,parent:o.id});return}this.trackSourceBuffer(a,o);}}this.bufferCreated();}getTrackCodec(e,t){let i=e.supplemental,r=e.codec;i&&(t==="video"||t==="audiovideo")&&Zc(i,"video")&&(r=JT(r,i));let n=Xo(r,e.levelCodec);return n?t.slice(0,5)==="audio"?al(n,this.appendSource):n:""}trackSourceBuffer(e,t){let i=t.buffer;if(!i)return;let r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{let o=a.removedRanges;o!=null&&o.length&&this.hls.trigger(g.BUFFER_FLUSHED,{type:n});});}get mediaSrc(){var e,t;let i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){let t=this.currentOp(e);t&&t.onStart();}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e));}onSBUpdateError(e,t){var i;let r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:false});let n=this.currentOp(e);n&&n.onError(r);}updateTimestampOffset(e,t,i,r,n,a){let o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t);}removeExecutor(e,t,i){let{media:r,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!r||!n||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}let d=$(r.duration)?r.duration:1/0,l=$(n.duration)?n.duration:1/0,c=Math.max(0,t),u=Math.min(i,d,l);u>c&&(!a.ending||a.ended)?(a.ended=false,this.log(`Removing [${c},${u}] from the ${e} SourceBuffer`),o.remove(c,u)):this.shiftAndExecuteNext(e);}appendExecutor(e,t){let i=this.tracks[t],r=i?.buffer;if(!r)throw new ku(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=false,i.ended=false,r.appendBuffer(e);}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes);});else try{e();}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`);}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return !!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);let{operationQueue:i}=this,r=t.map(a=>this.appendBlocker(a));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes));})}stepOperationQueue(e){e.forEach(t=>{var i;let r=(i=this.tracks[t])==null?void 0:i.buffer;!r||r.updating||this.shiftAndExecuteNext(t);});}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i);}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e);}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e);}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let r=this.tracks[e];if(!r)return;let n=r.buffer;if(!n)return;let a=i.bind(this,e);r.listeners.push({event:t,listener:a}),n.addEventListener(t,a);}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(r=>{i.removeEventListener(r.event,r.listener);}),t.listeners.length=0);}};function Vg(s){let e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t);});}function BS(s,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t);}function Bc(s){return s==="audio"?1:0}var Mu=class s{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(g.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this);}unregisterListener(){let{hls:e}=this;e.off(g.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this);}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.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 i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onLevelsUpdated(e,t){this.timer&&$(this.autoLevelCapping)&&this.detectPlayerSize();}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onMediaDetaching(){this.stopCapping(),this.media=null;}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,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&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 i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,s.getMaxLevelByMediaSize(i,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 i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.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 Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return !this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return -1;let r=(o,d)=>d?o.width!==d.width||o.height!==d.height:true,n=e.length-1,a=Math.max(t,i);for(let o=0;o<e.length;o+=1){let d=e[o];if((d.width>=a||d.height>=a)&&r(d,e[o+1])){n=o;break}}return n}},$S={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ut=$S,GS={HLS:"h"},HS=GS,VS="CMCD-Object",KS="CMCD-Request",WS="CMCD-Session",qS="CMCD-Status",Ln={OBJECT:VS,REQUEST:KS,SESSION:WS,STATUS:qS},YS={[Ln.OBJECT]:["br","ab","d","ot","tb","tpb","lb","tab","lab","url"],[Ln.REQUEST]:["pb","bl","tbl","dl","ltc","mtp","nor","nrr","rc","sn","sta","su","ttfb","ttfbb","ttlb","cmsdd","cmsds","smrt","df","cs"],[Ln.SESSION]:["cid","pr","sf","sid","st","v","msd"],[Ln.STATUS]:["bs","bsd","cdn","rtp","bg","pt","ec","e"]},Vn=class s{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof s?i:new s(i))),this.value=e,this.params=t;}},jS="Dict";function zS(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function QS(s,e,t,i){return new Error(`failed to ${s} "${zS(e)}" as ${t}`,{cause:i})}function ui(s,e,t){return QS("serialize",s,e,t)}var _l=class{constructor(e){this.description=e;}},Kg="Bare Item",XS="Boolean";function ZS(s){if(typeof s!="boolean")throw ui(s,XS);return s?"?1":"?0"}function JS(s){return btoa(String.fromCharCode(...s))}var eb="Byte Sequence";function tb(s){if(ArrayBuffer.isView(s)===false)throw ui(s,eb);return `:${JS(s)}:`}var ib="Integer";function sb(s){return s<-999999999999999||999999999999999<s}function e0(s){if(sb(s))throw ui(s,ib);return s.toString()}function rb(s){return `@${e0(s.getTime()/1e3)}`}function t0(s,e){if(s<0)return -t0(-s,e);let t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){let r=Math.floor(s*t);return (r%2===0?r:r+1)/t}else return Math.round(s*t)/t}var nb="Decimal";function ab(s){let e=t0(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ui(s,nb);let t=e.toString();return t.includes(".")?t:`${t}.0`}var ob="String",lb=/[\x00-\x1f\x7f]+/;function db(s){if(lb.test(s))throw ui(s,ob);return `"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function cb(s){return s.description||s.toString().slice(7,-1)}var ub="Token";function Wg(s){let e=cb(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===false)throw ui(e,ub);return e}function wu(s){switch(typeof s){case "number":if(!$(s))throw ui(s,Kg);return Number.isInteger(s)?e0(s):ab(s);case "string":return db(s);case "symbol":return Wg(s);case "boolean":return ZS(s);case "object":if(s instanceof Date)return rb(s);if(s instanceof Uint8Array)return tb(s);if(s instanceof _l)return Wg(s);default:throw ui(s,Kg)}}var hb="Key";function Pu(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===false)throw ui(s,hb);return s}function Ah(s){return s==null?"":Object.entries(s).map(([e,t])=>t===true?`;${Pu(e)}`:`;${Pu(e)}=${wu(t)}`).join("")}function i0(s){return s instanceof Vn?`${wu(s.value)}${Ah(s.params)}`:wu(s)}function fb(s){return `(${s.value.map(i0).join(" ")})${Ah(s.params)}`}function mb(s,e={whitespace:true}){if(typeof s!="object")throw ui(s,jS);let t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Vn||(n=new Vn(n));let a=Pu(r);return n.value===true?a+=Ah(n.params):(a+="=",Array.isArray(n.value)?a+=fb(n):a+=i0(n)),a}).join(`,${i}`)}function gb(s,e){return mb(s,e)}function pb(s){return ["ot","sf","st","e","sta"].includes(s)}function Eb(s){return typeof s=="number"?$(s):s!=null&&s!==""&&s!==false}function vb(s,e){let t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;let r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}var tl=s=>Math.round(s),Tb=(s,e)=>(e?.baseUrl&&(s=vb(s,e.baseUrl)),encodeURIComponent(s)),Yo=s=>tl(s/100)*100,yb={br:tl,d:tl,bl:Yo,dl:Yo,mtp:Yo,nor:Tb,rtp:Yo,tb:tl};function Sb(s,e){let t={};if(s==null||typeof s!="object")return t;let i=Object.keys(s).sort(),r=Te({},yb,e?.formatters),n=e?.filter;return i.forEach(a=>{if(n?.(a)===false)return;let o=s[a],d=r[a];d&&(o=d(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||Eb(o)&&(pb(a)&&typeof o=="string"&&(o=new _l(o)),t[a]=o));}),t}function s0(s,e={}){return s?gb(Sb(s,e),Te({whitespace:false},e)):""}function bb(s,e={}){let t={};if(!s)return t;let i=Object.entries(s),r=Object.entries(YS).concat(Object.entries(e?.customHeaderMap||{})),n=i.reduce((a,o)=>{var d,l;let[c,u]=o,h=((d=r.find(f=>f[1].includes(c)))===null||d===void 0?void 0:d[0])||Ln.REQUEST;return (l=a[h])!==null&&l!==void 0||(a[h]={}),a[h][c]=u,a},{});return Object.entries(n).reduce((a,[o,d])=>(a[o]=s0(d,e),a),t)}function Ab(s,e,t){return Te(s,bb(e,t))}var _b="CMCD";function Ib(s,e={}){if(!s)return "";let t=s0(s,e);return `${_b}=${encodeURIComponent(t)}`}var qg=/CMCD=[^&#]+/;function Lb(s,e,t){let i=Ib(e,t);if(!i)return s;if(qg.test(s))return s.replace(qg,i);let r=s.includes("?")?"&":"?";return `${s}${r}${i}`}var Ou=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=false,this.includeKeys=void 0,this.initialized=false,this.starved=false,this.buffering=true,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=true),this.buffering=true;},this.onPlaying=()=>{this.initialized||(this.initialized=true),this.buffering=false;},this.applyPlaylistData=r=>{try{this.apply(r,{ot:ut.MANIFEST,su:!this.initialized});}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n);}},this.applyFragmentData=r=>{try{let{frag:n,part:a}=r,o=this.hls.levels[n.level],d=this.getObjectType(n),l={d:(a||n).duration*1e3,ot:d};(d===ut.VIDEO||d===ut.AUDIO||d==ut.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(d)/1e3,l.bl=this.getBufferLength(d));let c=a?this.getNextPart(a):this.getNextFrag(n);c!=null&&c.url&&c.url!==n.url&&(l.nor=c.url),this.apply(r,l);}catch(n){this.hls.logger.warn("Could not generate segment CMCD data.",n);}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===true,this.includeKeys=i.includeKeys,this.registerListeners());}registerListeners(){let e=this.hls;e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHED,this.onMediaDetached,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this);}unregisterListeners(){let e=this.hls;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHED,this.onMediaDetached,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this);}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=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 i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer;}createData(){var e;return {v:1,sf:HS.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Te(t,this.createData());let i=t.ot===ut.INIT||t.ot===ut.VIDEO||t.ot===ut.MUXED;this.starved&&i&&(t.bs=true,t.su=true,this.starved=false),t.su==null&&(t.su=this.buffering);let{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((a,o)=>(r.includes(o)&&(a[o]=t[o]),a),{}));let n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Ab(e.headers,t,n)):e.url=Lb(e.url,t,n);}getNextFrag(e){var t;let i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){let r=e.sn-i.startSN;return i.fragments[r+1]}}getNextPart(e){var t,i;let{index:r,fragment:n}=e,a=(t=this.hls.levels[n.level])==null||(i=t.details)==null?void 0:i.partList;if(a){let{sn:o}=n;for(let d=a.length-1;d>=0;d--){let l=a[d];if(l.index===r&&l.fragment.sn===o)return a[d+1]}}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return ut.TIMED_TEXT;if(e.sn==="initSegment")return ut.INIT;if(t==="audio")return ut.AUDIO;if(t==="main")return this.hls.audioTracks.length?ut.VIDEO:ut.MUXED}getTopBandwidth(e){let t=0,i,r=this.hls;if(e===ut.AUDIO)i=r.audioTracks;else {let n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a);}return i.forEach(n=>{n.bitrate>t&&(t=n.bitrate);}),t>0?t:NaN}getBufferLength(e){let t=this.media,i=e===ut.AUDIO?this.audioBuffer:this.videoBuffer;return !i||!t?NaN:ne.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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);}}}},xb=3e5,Nu=class extends bt{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=false,this.enabled=true,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners();}registerListeners(){let e=this.hls;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let e=this.hls;e&&(e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.ERROR,this.onError,this));}pathways(){return (this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e);}startLoad(){if(this.started=true,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=false,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(i=>i!==e));}onManifestLoading(){this.stopLoad(),this.enabled=true,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null;}onManifestLoaded(e,t){let{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad());}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks;}onError(e,t){let{errorAction:i}=t;if(i?.action===et.SendAlternateToPenaltyBox&&i.flags===Nt.MoveAllAlternatesMatchingHost){let r=this.levels,n=this._pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:d,type:l}=t.context;o&&r?a=this.getPathwayForGroupId(o,l,a):d&&(a=d);}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),t.details===R.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=true:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${Re(n)} penalized: ${Re(this.penalizedPathways)}`);}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i;}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,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>xb&&delete i[n];});for(let n=0;n<e.length;n++){let a=e[n];if(a in i)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,d=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Mp(t),this.hls.trigger(g.LEVELS_UPDATED,{levels:t});let l=this.hls.levels[o];d&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==d.bitrate&&this.log(`Unstable Pathways change from bitrate ${d.bitrate} to ${l.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ce.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ce.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){let t=this.levels;if(!t)return;let i={},r={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":d}=n;if(t.some(c=>c.pathwayId===a))return;let l=this.getLevelsForPathway(o).map(c=>{let u=new Pe(c.attrs);u["PATHWAY-ID"]=a;let h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(i[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);let m=r0(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d),E=new vs({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let p=1;p<c.audioGroups.length;p++)E.addGroupId("audio",`${c.audioGroups[p]}_clone_${a}`);if(c.subtitleGroups)for(let p=1;p<c.subtitleGroups.length;p++)E.addGroupId("text",`${c.subtitleGroups[p]}_clone_${a}`);return E});t.push(...l),Yg(this.audioTracks,i,d,a),Yg(this.subtitleTracks,r,d,a);});}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e);}catch{this.enabled=false,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c);}let n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},d={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);let m=c.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":E,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":v}=m;if(E)try{this.uri=new self.URL(E,r).href;}catch{this.enabled=false,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),p&&this.clonePathways(p);let S={steeringManifest:m,url:r.toString()};this.hls.trigger(g.STEERING_MANIFEST_LOADED,S),v&&this.updatePathwayPriority(v);},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=false,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){let E=this.loader;if(typeof E?.getResponseHeader=="function"){let p=E.getResponseHeader("Retry-After");p&&(m=parseFloat(p)*1e3);}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m);},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url);}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,d,l);}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;let r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3);},t);}};function Yg(s,e,t,i){s&&Object.keys(e).forEach(r=>{let n=s.filter(a=>a.groupId===r).map(a=>{let o=Te({},a);return o.details=void 0,o.attrs=new Pe(o.attrs),o.url=o.attrs.URI=r0(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n);});}function r0(s,e,t,i){let{HOST:r,PARAMS:n,[t]:a}=i,o;e&&(o=a?.[e],o&&(s=o));let d=new self.URL(s);return r&&!o&&(d.host=r),n&&Object.keys(n).sort().forEach(l=>{l&&d.searchParams.set(l,n[l]);}),d.href}function xt(s,e,t){Ut(s,e,t),s.addEventListener(e,t);}function Ut(s,e,t){s.removeEventListener(e,t);}var Il=class s extends bt{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.onWaitingForKey=t=>{this.log(`"${t.type}" event`);},this.hls=e,this.config=e.config,this.registerListeners();}destroy(){this.onDestroying(),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.onWaitingForKey=null;}registerListeners(){this.hls.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(g.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(g.DESTROYING,this.onDestroying,this);}unregisterListeners(){this.hls.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(g.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(g.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(g.DESTROYING,this.onDestroying,this);}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===Ue.WIDEVINE&&i)return i}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,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`);}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,d)=>!!a&&d.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let d=l=>{let c=l.shift();this.getMediaKeysPromise(c,r,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{l.length?d(l):u instanceof ht?o(u):o(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_ACCESS,error:u,fatal:true},u.message));});};d(e);})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Ip===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){let r=Py(e,t,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n?.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Re(r)}`),a=this.requestMediaKeySystemAccess(e,r);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`);}),a.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);let l=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=d.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),o.hasMediaKeys=true,l.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`);}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${ms.hexDump(e.keyId||[])}`);let r=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh.buffer,"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 ms.hexDump(e.keyId)}updateKeySession(e,t){var i;let r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${ms.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
1715
|
-
} (data length: ${t&&t.byteLength})`),r.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>bg(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>this.getKeySystemSelectionPromise(e).then(({keySystem:r})=>{let n=bg(r);n?t(n):i(new Error(`Unable to find format for key-system "${r}"`));}).catch(i))}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){let t=Jo(this.config),i=e.map(uu).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(i)}loadKey(e){let t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.getKeySystemForKeyPromise(t).then(({keySystem:o,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(o,d).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:o,mediaKeys:d,decryptdata:t}))))),(this.keyIdToKeySessionPromise[i]=n.then(o=>{let d="cenc",l=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(o,d,l,"playlist-key")})).catch(o=>this.handleError(o))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof ht?this.hls.trigger(g.ERROR,e.data):this.hls.trigger(g.ERROR,{type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_KEYS,error:e,fatal:true}));}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){let r=uu(e.keyFormat),n=r?[r]:Jo(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Jo(this.config)),e.length===0)throw new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:true},`Missing key-system license configuration options ${Re({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaKeys===t)return Promise.resolve();let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=Promise.all(i).then(()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1);})}generateRequestWithPreferredKeySession(e,t,i,r){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,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=m.initData?m.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null;}catch(m){var d;if(this.warn(m.message),(d=this.hls)!=null&&d.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);let l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${l} (init data type: ${t} length: ${i?i.byteLength:null})`);let c=new Eh,u=e._onmessage=m=>{let E=e.mediaKeysSession;if(!E){c.emit("error",new Error("invalid state"));return}let{messageType:p,message:v}=m;this.log(`"${p}" message event for session "${E.sessionId}" message size: ${v.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(e,v).catch(S=>{c.eventNames().length?c.emit("error",S):this.handleError(S);}):p==="license-release"?e.keySystem===Ue.FAIRPLAY&&(this.updateKeySession(e,cu("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${p}"`);},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let p=e.keyStatus;c.emit("keyStatus",p),p==="expired"&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e));};xt(e.mediaKeysSession,"message",u),xt(e.mediaKeysSession,"keystatuseschange",h);let f=new Promise((m,E)=>{c.on("error",E),c.on("keyStatus",p=>{p.startsWith("usable")?m():p==="output-restricted"?E(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:false},"HDCP level output restricted")):p==="internal-error"?E(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:true},`key status changed to "${p}"`)):p==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`);});});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${l}`);}).catch(m=>{throw new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_SESSION,error:m,fatal:false},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw c.removeAllListeners(),this.removeSession(e),m}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{if(typeof i=="string"&&typeof t=="object"){let r=i;i=t,t=r;}this.log(`key status change "${t}" for keyStatuses keyId: ${ms.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${ms.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t;});}fetchServerCertificate(e){let t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let d={responseType:"arraybuffer",url:n},l=t.certLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,E)=>{a(h.data);},onError:(h,f,m,E)=>{o(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:be({url:d.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`));},onTimeout:(h,f,m)=>{o(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:{url:d.url,data:void 0}},`"${e}" certificate request timed out (${n})`));},onAbort:(h,f,m)=>{o(new Error("aborted"));}};r.load(d,c,u);})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i?.byteLength}) on "${t}"`),r(e);}).catch(a=>{n(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:true},a.message));});})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:true},r.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];let f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m);}}let d=r.querySelector("Challenge"),l=d?.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return cu(atob(l))}setupLicenseXHR(e,t,i,r){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,true),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,true),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,true),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((r,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 d=o.response;this.log(`License received ${d instanceof ArrayBuffer?d.byteLength:d}`);let l=this.config.licenseResponseCallback;if(l)try{d=l.call(this.hls,o,a,e);}catch(c){this.error(c);}r(d);}else {let d=i.errorRetry,l=d?d.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)n(new ht({type:W.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true,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 c=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(r,n);}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:d,licenseChallenge:l})=>{e.keySystem==Ue.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(d,l)),d.send(l);});})}onDestroying(){this.unregisterListeners(),this._clear();}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,xt(i,"waitingforkey",this.onWaitingForKey);}onMediaDetached(){let e=this.media;e&&(Ut(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null);}_clear(){var e;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},!this.mediaKeys&&!this.mediaKeySessions.length)return;let t=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,gl.clearKeyUriToKeyIdMap();let r=i.length;s.CDMCleanupPromise=Promise.all(i.map(n=>this.removeSession(n)).concat(t==null||(e=t.setMediaKeys(null))==null?void 0:e.catch(n=>{var a;this.log(`Could not clear media keys: ${n}`),(a=this.hls)==null||a.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:false,error:new Error(`Could not clear media keys: ${n}`)});}))).catch(n=>{var a;this.log(`Could not close sessions and clear media keys: ${n}`),(a=this.hls)==null||a.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close sessions and clear media keys: ${n}`)});}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys");});}onManifestLoading(){this.keyFormatPromise=null;}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i);}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i}=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),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);let{drmSystemOptions:n}=this.config;return (Ny(n)?new Promise((o,d)=>{self.setTimeout(()=>d(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(o);}):Promise.resolve()).catch(o=>{var d;this.log(`Could not remove session: ${o}`),(d=this.hls)==null||d.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:false,error:new Error(`Could not remove session: ${o}`)});}).then(()=>t.close()).catch(o=>{var d;this.log(`Could not close session: ${o}`),(d=this.hls)==null||d.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close session: ${o}`)});})}}};Il.CDMCleanupPromise=void 0;var ht=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;}},Fu=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=false,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(g.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(g.MEDIA_DETACHING,this.onMediaDetaching,this);}unregisterListeners(){this.hls.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(g.MEDIA_DETACHING,this.onMediaDetaching,this);}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=false,this.media=null;}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=true),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod);}}onMediaDetaching(){this.media=null;}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,d=1e3*a/n,l=this.hls;if(l.trigger(g.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),d>0&&a>l.config.fpsDroppedMonitoringThreshold*o){let c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)&&(c=c-1,l.trigger(g.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch());}}this.lastTime=r,this.lastDroppedFrames=i,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);}};function n0(s,e){let t;try{t=new Event("addtrack");}catch{t=document.createEvent("Event"),t.initEvent("addtrack",false,false);}t.track=s,e.dispatchEvent(t);}function a0(s,e){let t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){Ee.debug(`[texttrack-utils]: ${i}`);try{let r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,s.addCue(r);}catch(r){Ee.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`);}}t==="disabled"&&(s.mode=t);}function fr(s,e){let t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t);}function Uu(s,e,t,i){let r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){let n=Db(s.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&s.removeCue(n[a]);}r==="disabled"&&(s.mode=r);}function Rb(s,e){if(e<=s[0].startTime)return 0;let t=s.length-1;if(e>s[t].endTime)return -1;let i=0,r=t,n;for(;i<=r;)if(n=Math.floor((r+i)/2),e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n;return s[i].startTime-e<e-s[r].startTime?i:r}function Db(s,e,t){let i=[],r=Rb(s,e);if(r>-1)for(let n=r,a=s.length;n<a;n++){let o=s[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function il(s){let e=[];for(let t=0;t<s.length;t++){let i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t]);}return e}var Bu=class extends Gn{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=true,this.queuedDefaultTrack=-1,this.useTextTrackPolling=false,this.subtitlePollingInterval=-1,this._subtitleDisplay=true,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,i=il(this.media.textTracks);for(let n=0;n<i.length;n++)if(i[n].mode==="hidden")t=i[n];else if(i[n].mode==="showing"){t=i[n];break}let r=this.findTrackForTextTrack(t);this.subtitleTrack!==r&&this.setSubtitleTrack(r);},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(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(g.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(g.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(e,t){let i=this.media;if(!i)return;let r=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r)return;il(i.textTracks).forEach(a=>{fr(a);});}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true;}onManifestParsed(e,t){this.tracks=t.subtitleTracks;}onSubtitleTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=false),a.forEach((c,u)=>{c.id=u;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=false;let c=ci(o,a);if(c>-1)n=a[c];else {let u=ci(o,this.tracks);n=this.tracks[u];}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let l={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(g.SUBTITLE_TRACKS_UPDATED,l),d!==-1&&this.trackId===-1&&this.setSubtitleTrack(d);}}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){let n=t[r];if(!(i&&!n.default||!i&&!e)&&(!e||ps(n,e)))return r}if(e){for(let r=0;r<t.length;r++){let n=t[r];if(Hn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let n=t[r];if(Hn(e.attrs,n.attrs,["LANGUAGE"]))return r}}return -1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if(xu(r,e))return i}}return -1}onError(e,t){t.fatal||!t.context||t.context.type===ce.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=false,this.setSubtitleTrack(e);}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=false,t.length){let i=this.currentTrack;if(i&&ps(e,i))return i;let r=ci(e,this.tracksInGroup);if(r>-1){let n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else {if(i)return null;{let n=ci(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(g.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=il(e.textTracks),i=this.currentTrack,r;if(i&&(r=t.filter(n=>xu(i,n))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==r&&(n.mode="disabled");}),r){let n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n);}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!$(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(g.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!r.details&&!r.details.live;if(e===this.trackId&&r===i&&n)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));let{id:a,groupId:o="",name:d,type:l,url:c}=r;this.hls.trigger(g.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:d,type:l,url:c});let u=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(u);}};function kb(){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,r=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}function Dn(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return (e>>>0).toString()}var Er=.025,Ll=function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s}({});function Cb(s,e,t){return `${s.identifier}-${t+1}-${Dn(e)}`}var $u=class{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=false,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:false,jump:false},this.snapOptions={out:false,in:false},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e);}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions);}reset(){var e;this.appendInPlaceStarted=false,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null);}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return true;let i=this.playoutLimit;return e<=0||isNaN(i)?false:i===0?true:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){let e=this.dateRange.startTime;if(this.snapOptions.out){let t=this.dateRange.tagAnchor;if(t)return $c(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return true;let e=this.dateRange.tagAnchor;if(e){let t=this.dateRange.startTime,i=$c(t,e);return t-i<.1}return false}get resumptionOffset(){let e=this.resumeOffset,t=$(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){let e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){let t=this.resumeAnchor;if(t)return $c(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?true:this.appendInPlaceDisabled?false:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Er))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e;}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e;}get duration(){let e=this.playoutLimit,t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e;}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Ll.Range:Ll.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return Mb(this)}};function $c(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<Er)?e.start:e.start+e.duration}function o0(s,e,t){let i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Gc(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function Mb(s){return `["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function hr(s){let e=s.timelineStart,t=s.duration||0;return `["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}var Gu=class{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=false,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls.trigger(g.PLAYOUT_LIMIT_REACHED,{});};let n=this.hls=new e(t);this.interstitial=i,this.assetItem=r;let a=r.uri;try{a=o0(a,t.primarySessionId).href;}catch{}n.loadSource(a);let o=()=>{this.hasDetails=true;};n.once(g.LEVEL_LOADED,o),n.once(g.AUDIO_TRACK_LOADED,o),n.once(g.SUBTITLE_TRACK_LOADED,o),n.on(g.MEDIA_ATTACHING,(d,{media:l})=>{this.removeMediaListeners(),this.mediaAttached=l,this.interstitial.playoutLimit&&(l.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(g.BUFFER_APPENDED,()=>{let u=this.bufferedEnd;this.reachedPlayout(u)&&(this._bufferedEosTime=u,n.trigger(g.BUFFERED_TO_END,void 0));}));});}get appendInPlace(){var e;return ((e=this.interstitial)==null?void 0:e.appendInPlace)||false}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return false;if((t=this.hls)!=null&&t.bufferedToEnd)return true;if(!e||!this._bufferedEosTime)return false;let i=this.timelineOffset,r=ne.bufferInfo(e,i,0);return this.getAssetTime(r.end)>=this._bufferedEosTime-.02}reachedPlayout(e){let i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return !((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return ((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){let e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;let t=ne.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;return e||0}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return ((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t){let i=e-t;if(Math.abs(i)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e;}}}getAssetTime(e){let t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout));}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd);}}destroy(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null;}attachMedia(e){this.hls.attachMedia(e);}detachMedia(){this.removeMediaListeners(),this.mediaAttached=null,this.hls.detachMedia();}resumeBuffering(){this.hls.resumeBuffering();}pauseBuffering(){this.hls.pauseBuffering();}transferMedia(){return this.bufferSnapShot(),this.hls.transferMedia()}resetDetails(){let e=this.hls;if(this.hasDetails){e.stopLoad();let t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=false;}}on(e,t,i){this.hls.on(e,t);}once(e,t,i){this.hls.once(e,t);}off(e,t,i){this.hls.off(e,t);}toString(){var e;return `HlsAssetPlayer: ${hr(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}},jg=.033,Hu=class extends bt{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e;}destroy(){this.reset(),this.onScheduleUpdate=null;}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null;}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let r=this.items;if(r)for(r[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=r[i])!=null&&n.event;){var n;i--;}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let r=0;r<i.length;r++){let n=i[r];if(t&&t!=="primary"&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return r}return -1}findJumpRestrictedIndex(e,t){let i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){let n=i[r].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return r}return -1}findEventIndex(e){let t=this.items;if(t)for(let r=t.length;r--;){var i;if(((i=t[r].event)==null?void 0:i.identifier)===e)return r}return -1}findAssetIndex(e,t){let i=e.assetList,r=i.length;if(r>1)for(let n=0;n<r;n++){let a=i[n];if(!a.error){let o=a.timelineStart;if(t===o||t>o&&t<o+(a.duration||0))return n}}return 0}get assetIdAtEnd(){var e,t;let i=(e=this.items)==null||(t=e[this.length-1])==null?void 0:t.event;if(i){let r=i.assetList,n=r[r.length-1];if(n)return n.identifier}return null}parseInterstitialDateRanges(e,t){let i=e.main.details,{dateRanges:r}=i,n=this.events,a=this.parseDateRanges(r,{url:i.url},t),o=Object.keys(r),d=n?n.filter(l=>!o.includes(l.identifier)):[];a.length&&a.sort((l,c)=>{let u=l.cue.pre,h=l.cue.post,f=c.cue.pre,m=c.cue.post;if(u&&!f)return -1;if(f&&!u||h&&!m)return 1;if(m&&!h)return -1;if(!u&&!f&&!h&&!m){let E=l.startTime,p=c.startTime;if(E!==p)return E-p}return l.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=a,d.forEach(l=>{this.removeEvent(l);}),this.updateSchedule(e,d);}updateSchedule(e,t=[]){let i=this.events||[];if(i.length||t.length||this.length<2){let r=this.items,n=this.parseSchedule(i,e);(t.length||r?.length!==n.length||n.some((o,d)=>Math.abs(o.playout.start-r[d].playout.start)>.005||Math.abs(o.playout.end-r[d].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,r));}}parseDateRanges(e,t,i){let r=[],n=Object.keys(e);for(let a=0;a<n.length;a++){let o=n[a],d=e[o];if(d.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(d):(l=new $u(d,t),this.eventMap[o]=l,i===false&&(l.appendInPlace=i)),r.push(l);}}return r}parseSchedule(e,t){let i=[],r=t.main.details,n=r.live?1/0:r.edge,a=0;if(e=e.filter(d=>!d.error&&!(d.cue.once&&d.hasPlayed)),e.length){this.resolveOffsets(e,t);let d=0,l=0;if(e.forEach((c,u)=>{let h=c.cue.pre,f=c.cue.post,m=e[u-1]||null,E=c.appendInPlace,p=f?n:c.startOffset,v=c.duration,S=c.timelineOccupancy===Ll.Range?v:0,y=c.resumptionOffset,b=m?.startTime===p,L=p+c.cumulativeDuration,k=E?L+v:p+y;if(h||!f&&p<=0){let x=l;l+=S,c.timelineStart=L;let D=a;a+=v,i.push({event:c,start:L,end:k,playout:{start:D,end:a},integrated:{start:x,end:l}});}else if(p<=n){if(!b){let _=p-d;if(_>jg){let M=d,N=l;l+=_;let q=a;a+=_;let V={previousEvent:e[u-1]||null,nextEvent:c,start:M,end:M+_,playout:{start:q,end:a},integrated:{start:N,end:l}};i.push(V);}else _>0&&m&&(m.cumulativeDuration+=_,i[i.length-1].end=p);}f&&(k=L),c.timelineStart=L;let x=l;l+=S;let D=a;a+=v,i.push({event:c,start:L,end:k,playout:{start:D,end:a},integrated:{start:x,end:l}});}else return;let I=c.resumeTime;f||I>n?d=n:d=I;}),d<n){var o;let c=d,u=l,h=n-d;l+=h;let f=a;a+=h,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:d,end:c+h,playout:{start:f,end:a},integrated:{start:u,end:l}});}this.setDurations(n,a,l);}else i.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i};}resolveOffsets(e,t){let i=t.main.details,r=i.live?1/0:i.edge,n=0,a=-1;e.forEach((o,d)=>{let l=o.cue.pre,c=o.cue.post,u=l?0:c?r:o.startTime;this.updateAssetDurations(o),a===u?o.cumulativeDuration=n:(n=0,a=u),!c&&o.snapOptions.in&&(o.resumeAnchor=Ts(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=false)),!o.appendInPlace&&d+1<e.length&&e[d+1].startTime-e[d].resumeTime<jg&&(e[d+1].appendInPlace=false,e[d+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));let f=$(o.resumeOffset)?o.resumeOffset:o.duration;n+=f;});}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>Er?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),false):t?!Object.keys(t).some(a=>{let o=t[a].details,d=o.edge;if(i>=d)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${d}`),false;let l=Ts(null,o.fragments,i);if(!l)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),true;let c=a==="audio"?.175:0;return Math.abs(l.start-i)<Er+c||Math.abs(l.end-i)<Er+c?false:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),true)}):(this.log(`"${e.identifier}" resumption ${i} can not be aligned with media (none selected)`),false)}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=false,n=false;e.assetList.forEach((a,o)=>{let d=t+i;a.startOffset=i,a.timelineStart=d,r||(r=a.duration===null),n||(n=!!a.error);let l=a.error?0:a.duration||0;i+=l;}),r&&!n?e.duration=Math.max(i,e.duration):e.duration=i;}removeEvent(e){e.reset(),delete this.eventMap[e.identifier];}};function Ui(s){return `[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}var Vu=class{constructor(e){this.hls=void 0,this.hls=e;}destroy(){this.hls=null;}loadAssetList(e,t){let i=e.assetListUrl,r;try{r=o0(i,this.hls.sessionId,e.baseUrl);}catch(h){let f=this.assignAssetListError(e,R.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(g.ERROR,f);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);let n=this.hls.config,a=n.loader,o=new a(n),d={responseType:"json",url:r.href},l=n.interstitialAssetListLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,E)=>{let p=h.data,v=p?.ASSETS;if(!Array.isArray(v)){let S=this.assignAssetListError(e,R.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,f,E);this.hls.trigger(g.ERROR,S);return}e.assetListResponse=p,this.hls.trigger(g.ASSET_LIST_LOADED,{event:e,assetListResponse:p,networkDetails:E});},onError:(h,f,m,E)=>{let p=this.assignAssetListError(e,R.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,E,m);this.hls.trigger(g.ERROR,p);},onTimeout:(h,f,m)=>{let E=this.assignAssetListError(e,R.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,m);this.hls.trigger(g.ERROR,E);}};return o.load(d,c,u),this.hls.trigger(g.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,r,n,a){return e.error=i,{type:W.NETWORK_ERROR,details:t,fatal:false,interstitial:e,url:r,error:i,networkDetails:a,stats:n}}};function zg(s){s?.play().catch(()=>{});}var Ku=class extends bt{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=false,this.onPlay=()=>{this.shouldPlay=true;},this.onPause=()=>{this.shouldPlay=false;},this.onSeeking=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled)return;let r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;let a=r<=-0.01;this.timelinePos=i,this.bufferedPos=i;let o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(),this.checkBuffer(),a&&i<o.start||i>=o.end){var d;let h=this.schedule.findItemIndexAtTime(this.timelinePos);if(!this.isInterstitial(o)&&(d=this.media)!=null&&d.paused&&(this.shouldPlay=false),!a){let f=this.findItemIndex(o);if(h>f){let m=this.schedule.findJumpRestrictedIndex(f+1,h);if(m>f){this.setSchedulePosition(m);return}}}this.setSchedulePosition(h);return}let l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){let h=o.event.assetList[0];h&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,h));}return}let c=l.timelineStart,u=l.duration||0;(a&&i<c||i>=c+u)&&this.setScheduleToAssetAtTime(i,l);},this.onTimeupdate=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;let r=this.playingItem;if(!r||this.playingLastItem)return;if(i>=r.end){this.timelinePos=r.end;let o=this.findItemIndex(r);this.setSchedulePosition(o+1);}let n=this.playingAsset;if(!n)return;let a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n);},this.onScheduleUpdate=(i,r)=>{let n=this.schedule,a=this.playingItem,o=n.events||[],d=n.items||[],l=n.durations,c=i.map(m=>m.identifier),u=!!(o.length||c.length);(u||r)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
|
|
1716
|
-
Schedule: ${d.map(m=>Ui(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`),this.playerQueue.forEach(m=>{if(m.interstitial.appendInPlace){let E=m.assetItem.timelineStart,p=m.timelineOffset-E;if(p)try{m.timelineOffset=E;}catch(v){Math.abs(p)>Er&&this.warn(`${v} ("${m.assetId}" ${m.timelineOffset}->${E})`);}}});let h=null;if(a){let m=this.updateItem(a,this.timelinePos);this.itemsMatch(a,m)&&(this.playingItem=m,this.waitingItem=this.endedItem=null,h=()=>this.trimInPlace(m,a));}else this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);let f=this.bufferingItem;if(f){let m=this.updateItem(f,this.bufferedPos);this.itemsMatch(f,m)?(this.bufferingItem=m,h||(h=()=>this.trimInPlace(m,f))):f.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(f.event,null));}if(i.forEach(m=>{m.assetList.forEach(E=>{this.clearAssetPlayer(E.identifier,null);});}),u||r){if(this.hls.trigger(g.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:d.slice(0),durations:l,removedIds:c}),this.isInterstitial(a)&&c.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}h&&h(),this.checkBuffer();}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Vu(e),this.schedule=new Hu(this.onScheduleUpdate,e.logger),this.registerListeners();}registerListeners(){let e=this.hls;e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(g.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(g.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(g.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(g.MEDIA_ENDED,this.onMediaEnded,this),e.on(g.ERROR,this.onError,this),e.on(g.DESTROYING,this.onDestroying,this);}unregisterListeners(){let e=this.hls;e&&(e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(g.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(g.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(g.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(g.MEDIA_ENDED,this.onMediaEnded,this),e.off(g.ERROR,this.onError,this),e.off(g.DESTROYING,this.onDestroying,this));}startLoad(){this.resumeBuffering();}stopLoad(){this.pauseBuffering();}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering();}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering();}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null;}onDestroying(){let e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e);}removeMediaListeners(e){Ut(e,"play",this.onPlay),Ut(e,"pause",this.onPause),Ut(e,"seeking",this.onSeeking),Ut(e,"timeupdate",this.onTimeupdate);}onMediaAttaching(e,t){let i=this.media=t.media;xt(i,"seeking",this.onSeeking),xt(i,"timeupdate",this.onTimeupdate),xt(i,"play",this.onPlay),xt(i,"pause",this.onPause);}onMediaAttached(e,t){let i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!r){this.clearScheduleState();let n=this.findItemIndex(i);this.setSchedulePosition(n);}}clearScheduleState(){this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null;}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){let n=this.getBufferingPlayer();n&&(this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=false;}}get interstitialsManager(){if(!this.manager){if(!this.hls)return null;let e=this,t=()=>e.bufferingItem||e.waitingItem,i=u=>u&&e.getAssetPlayer(u.identifier),r=(u,h,f,m,E)=>{if(u){let p=u[h].start,v=u.event;if(v){if(h==="playout"||v.timelineOccupancy!==Ll.Point){let S=i(f);S?.interstitial===v&&(p+=S.assetItem.startOffset+S[E]);}}else {let S=m==="bufferedPos"?a():e[m];p+=S-u.start;}return p}return 0},n=(u,h)=>{if(u!==0&&h!=="primary"&&e.schedule.length){var f;let m=e.schedule.findItemIndexAtTime(u),E=(f=e.schedule.items)==null?void 0:f[m];if(E){let p=E[h].start-E.start;return u+p}}return u},a=()=>{let u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h;return (h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:e.schedule.durations[u]},d=(u,h)=>{var f,m;let E=e.effectivePlayingItem;if(E!=null&&(f=E.event)!=null&&f.restrictions.skip)return;e.log(`seek to ${u} "${h}"`);let p=e.effectivePlayingItem,v=e.schedule.findItemIndexAtTime(u,h),S=(m=e.schedule.items)==null?void 0:m[v],y=e.getBufferingPlayer(),b=y?.interstitial,L=b?.appendInPlace,k=p&&e.itemsMatch(p,S);if(p&&(L||k)){let x=i(e.playingAsset),D=x?.media||e.primaryMedia;if(D){let _=h==="primary"?D.currentTime:r(p,h,e.playingAsset,"timelinePos","currentTime"),M=u-_,N=(L?_:D.currentTime)+M;if(N>=0&&(!x||L||N<=x.duration)){D.currentTime=N;return}}}if(S){let x=u;if(h!=="primary"){let _=S[h].start,M=u-_;x=S.start+M;}let D=!e.isInterstitial(S);if((!e.isInterstitial(p)||p.event.appendInPlace)&&(D||S.event.appendInPlace)){let _=e.media||(L?y?.media:null);_&&(_.currentTime=x);}else if(p){let _=e.findItemIndex(p);if(v>_){let N=e.schedule.findJumpRestrictedIndex(_+1,v);if(N>_){e.setSchedulePosition(N);return}}let M=0;if(D)e.timelinePos=x,e.checkBuffer();else {var I;let N=S==null||(I=S.event)==null?void 0:I.assetList;if(N){let q=u-(S[h]||S).start;for(let V=N.length;V--;){let H=N[V];if(H.duration&&q>=H.startOffset&&q<H.startOffset+H.duration){M=V;break}}}}e.setSchedulePosition(v,M);}}},l=()=>{let u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;let h=t();return e.isInterstitial(h)?h:null},c={get currentTime(){let u=l(),h=e.effectivePlayingItem;return h&&h===u?r(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){let h=l(),f=e.effectivePlayingItem;f&&f===h&&d(u+f.playout.start,"playout");},get duration(){let u=l();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;let h=(u=l())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;let h=(u=l())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};this.manager={get events(){var u,h;return ((u=e.schedule)==null||(h=u.events)==null?void 0:h.slice(0))||[]},get schedule(){var u,h;return ((u=e.schedule)==null||(h=u.items)==null?void 0:h.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){let u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return a()},get currentTime(){let u=e.timelinePos;return u>0?u:0},set currentTime(u){d(u,"primary");},get duration(){return o("primary")},get seekableStart(){var u;return ((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){d(u,"integrated");},get duration(){return o("integrated")},get seekableStart(){var u;return n(((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0,"integrated")}},skip:()=>{let u=e.effectivePlayingItem,h=u?.event;if(h&&!h.restrictions.skip){let f=e.findItemIndex(u);if(h.appendInPlace){let m=u.playout.start+u.event.duration;d(m+.001,"playout");}else e.advanceAfterAssetEnded(h,f,1/0);}}};}return this.manager}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return !this.playbackStarted||!t||!i?false:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t,i;if(this.mediaSelection===null)return;let r=this.waitingItem||this.playingItem;if(this.isInterstitial(r)&&!r.event.appendInPlace)return;let n=this.media;!n&&(e=this.bufferingItem)!=null&&(t=e.event)!=null&&t.appendInPlace&&(n=this.primaryMedia);let a=(i=n)==null?void 0:i.currentTime;if(!(a===void 0||!$(a)))return a}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return !!(e!=null&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t);}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}let n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Re(n)}`),this.detachedData=n;}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused));}transferMediaTo(e,t){var i,r;if(e.media===t)return;let n=null,a=this.hls,o=e!==a,d=o&&e.interstitial.appendInPlace,l=(i=this.detachedData)==null?void 0:i.mediaSource,c;if(a.media)d&&(n=a.transferMedia(),this.detachedData=n),c="Primary";else if(l){let f=this.getBufferingPlayer();f?(n=f.transferMedia(),c=`${f}`):c="detached MediaSource";}else c="detached media";if(!n){if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Re(n)}`);else if(!this.detachedData||a.media===t){let f=this.playerQueue;f.length>1&&f.forEach(m=>{if(o&&m.interstitial.appendInPlace!==d){let E=m.interstitial;this.clearInterstitial(m.interstitial,null),E.appendInPlace=false,E.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${E}`);}}),this.hls.detachMedia(),this.detachedData={media:t};}}let u=n&&"mediaSource"in n&&((r=n.mediaSource)==null?void 0:r.readyState)!=="closed",h=u&&n?n:t;if(this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c}`),h===n){let f=o&&e.assetId===this.schedule.assetIdAtEnd;h.overrides={duration:this.schedule.duration,endOfStream:!o||f,cueRemoval:!o};}e.attachMedia(h);}onInterstitialCueEnter(){this.onTimeupdate();}checkStart(){let e=this.schedule,t=e.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);let i=this.timelinePos,r=this.effectivePlayingItem;if(i===-1){let n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){let a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a);}else if(n>=0||!this.primaryLive){let a=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(a);this.setSchedulePosition(o);}}else if(r&&!this.playingItem){let n=e.findItemIndex(r);this.setSchedulePosition(n);}}advanceAfterAssetEnded(e,t,i){let r=Gc(e,i);if(!e.isAssetPastPlayoutLimit(r))this.setSchedulePosition(t,r);else {let n=this.schedule.items;if(n){let a=t+1,o=n.length;if(a>=o){this.setSchedulePosition(-1);return}let d=e.resumeTime;this.timelinePos<d&&(this.timelinePos=d,this.checkBuffer()),this.setSchedulePosition(a);}}}setScheduleToAssetAtTime(e,t){let i=this.schedule,r=t.parentIdentifier,n=i.getEvent(r);if(n){let a=i.findEventIndex(r),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1);}}setSchedulePosition(e,t){let i=this.schedule.items;if(!i||this.playbackDisabled)return;this.log(`setSchedulePosition ${e}, ${t}`);let r=e>=0?i[e]:null,n=this.playingItem,a=this.playingLastItem;if(this.isInterstitial(n)){var o;let l=n.event,c=this.playingAsset,u=c?.identifier,h=u?this.getAssetPlayer(u):null;if(h&&u&&(!this.eventItemsMatch(n,r)||t!==void 0&&u!==((o=l.assetList)==null?void 0:o[t].identifier))){var d;let f=l.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${f+1}/${l.assetList.length} ${hr(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(g.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:f,event:l,schedule:i.slice(0),scheduleIndex:e,player:h}),n!==this.playingItem){this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(l,this.findItemIndex(this.playingItem),f);return}this.retreiveMediaSource(u,r),h.media&&!((d=this.detachedData)!=null&&d.mediaSource)&&h.detachMedia();}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${l} ${Ui(n)}`),l.hasPlayed=true,this.hls.trigger(g.INTERSTITIAL_ENDED,{event:l,schedule:i.slice(0),scheduleIndex:e}),l.cue.once)){this.updateSchedule();let f=this.schedule.items;if(r&&f){let m=this.findItemIndex(r);this.advanceSchedule(m,f,t,n,a);}return}}this.advanceSchedule(e,i,t,n,a);}advanceSchedule(e,t,i,r,n){let a=e>=0?t[e]:null,o=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(l=>{let c=l.interstitial,u=this.schedule.findEventIndex(c.identifier);(u<e||u>e+1)&&this.clearInterstitial(c,a);}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);let l=a.event;if(i===void 0){i=this.schedule.findAssetIndex(l,this.timelinePos);let f=Gc(l,i-1);if(l.isAssetPastPlayoutLimit(f)){this.advanceAfterAssetEnded(l,e,i);return}i=f;}let c=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let u=this.preloadAssets(l,i);if(this.eventItemsMatch(a,c||r)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${Ui(a)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(g.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${l}`);return}if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!o){this.log(`Waiting for attachMedia to start Interstitial ${l}`);return}this.waitingItem=this.endedItem=null,this.playingItem=a;let h=l.assetList[i];if(!h){let f=t[e+1],m=this.media;f&&m&&!this.isInterstitial(f)&&m.currentTime<f.start&&(m.currentTime=this.timelinePos=f.start),this.advanceAfterAssetEnded(l,e,i||0);return}if(u||(u=this.getAssetPlayer(h.identifier)),u===null||u.destroyed){let f=l.assetList.length;this.warn(`asset ${i+1}/${f} player destroyed ${l}`),u=this.createAssetPlayer(l,h,i);}if(!this.eventItemsMatch(a,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(u,i,t,e,o),this.shouldPlay&&zg(u.media);}else a!==null?(this.resumePrimary(a,e,r),this.shouldPlay&&zg(this.hls.media)):n&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(this.schedule.durations.primary,null));}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===false}get primaryDetails(){var e,t;return (e=this.mediaSelection)==null||(t=e.main)==null?void 0:t.details}get primaryLive(){var e;return !!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Ui(e)}`),!((r=this.detachedData)!=null&&r.mediaSource)){let a=this.timelinePos;(a<e.start||a>=e.end)&&(a=this.getPrimaryResumption(e,t),this.timelinePos=a),this.attachPrimary(a,e);}if(!i)return;let n=this.schedule.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Ui(e)}`),this.hls.trigger(g.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer());}getPrimaryResumption(e,t){let i=e.start;if(this.primaryLive){let r=this.primaryDetails;if(t===0)return this.hls.startPosition;if(r&&(i<r.fragmentStart||i>r.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ne.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;let r=this.primaryMedia;if(!r)return;let n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.timelinePos=e,this.startLoadingPrimaryAt(e,i));}startLoadingPrimaryAt(e,t){var i;let r=this.hls;!r.loadingEnabled||!r.media||Math.abs((((i=r.mainForwardBufferInfo)==null?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering();}onManifestLoading(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=false,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(g.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(g.BUFFER_CODECS,this.onBufferCodecs,this);}onLevelUpdated(e,t){if(t.level===-1)return;let i=this.hls.levels[t.level],r=be(be({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart();}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=be(be({},this.altSelection),{},{audio:i});return}let n=be(be({},r),{},{audio:i});this.mediaSelection=n;}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=be(be({},this.altSelection),{},{subtitles:i});return}let n=be(be({},r),{},{subtitles:i});this.mediaSelection=n;}onAudioTrackSwitching(e,t){let i=dg(t);this.playerQueue.forEach(r=>r.hls.setAudioOption(t)||r.hls.setAudioOption(i));}onSubtitleTrackSwitch(e,t){let i=dg(t);this.playerQueue.forEach(r=>r.hls.setSubtitleOption(t)||t.id!==-1&&r.hls.setSubtitleOption(i));}onBufferCodecs(e,t){let i=t.tracks;i&&(this.requiredTracks=i);}onBufferAppended(e,t){this.checkBuffer();}onBufferFlushed(e,t){let i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){let r=this.timelinePos;this.bufferedPos=r,this.checkBuffer();}}onBufferedToEnd(e){let t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let r=0;r<t.length;r++){let n=t[r];if(n.cue.post){var i;let a=this.schedule.findEventIndex(n.identifier),o=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE;}}onMediaEnded(e){let t=this.playingItem;if(!this.playingLastItem&&t){let i=this.findItemIndex(t);this.setSchedulePosition(i+1);}else this.shouldPlay=false;}updateItem(e,t){let i=this.schedule.items;if(e&&i){let r=this.findItemIndex(e,t);return i[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null);});let i=e.end+.25,r=ne.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.attachPrimary(i,null),this.flushFrontBuffer(i));}}itemsMatch(e,t){return !!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return !!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e?this.schedule.findItemIndex(e,t):-1}updateSchedule(){let e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[]);}checkBuffer(e){let t=this.schedule.items;if(!t)return;let i=ne.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,t,e);}updateBufferedPos(e,t,i){let r=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}let a=this.playingItem,o=this.findItemIndex(a),d=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,c;let u=this.findItemIndex(n),h=Math.min(u+1,t.length-1),f=t[h];if((d===-1&&n&&e>=n.end||(l=f.event)!=null&&l.appendInPlace&&e+.01>=f.start)&&(d=h),h-o>1&&(n==null||(c=n.event)==null?void 0:c.appendInPlace)===false)return;if(this.bufferedPos=e,d>u&&d>o)this.bufferedToItem(f);else {let m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&f.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(f)&&this.preloadAssets(f.event,0);}}else i&&a&&!this.itemsMatch(a,n)&&(d===o?this.bufferedToItem(a):d===o+1&&this.bufferedToItem(t[d]));}assetsBuffered(e,t){return e.event.assetList.length===0?false:!e.event.assetList.some(r=>{let n=this.getAssetPlayer(r.identifier);return !(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(this.itemsMatch(e,t))this.bufferingItem!==e&&(this.bufferingItem=e);else {let{items:r,events:n}=i;if(!r||!n)return t;let a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let d=o?o.remaining:t?t.end-this.timelinePos:0;this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Ui(e)}`+(t?` (${d.toFixed(2)} remaining)`:"")),this.playbackDisabled||(a?e.event.assetList.forEach(l=>{let c=this.getAssetPlayer(l.identifier);c&&c.resumeBuffering();}):(this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering()))),this.hls.trigger(g.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)});}return t}bufferedToItem(e,t=0){let i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;let r=this.detachedData;r?r.mediaSource?this.attachPrimary(e.start,e,true):this.preloadPrimary(e):this.preloadPrimary(e);}}}preloadPrimary(e){let t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i);}bufferedToEvent(e,t){let i=e.event,r=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(r||!n){let a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){let o=i.assetList[t],d=this.primaryMedia;o&&d&&this.bufferAssetPlayer(a,d);}}}preloadAssets(e,t){let i=e.assetUrl,r=e.assetList.length,n=r===0&&!e.assetListLoader,a=e.cue.once;if(n){let d=e.timelineStart;if(e.appendInPlace){var o;let h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(d+.25);}let l,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){let h=c-d;h>0&&(l=Math.round(h*1e3)/1e3);}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${l?` live-start: ${c} start-offset: ${l}`:""}`),i)return this.createAsset(e,0,0,d,e.duration,i);let u=this.assetListLoader.loadAssetList(e,l);u&&(e.assetListLoader=u);}else if(!a&&r){for(let d=t;d<r;d++){let l=e.assetList[d],c=this.getAssetPlayerQueueIndex(l.identifier);(c===-1||this.playerQueue[c].destroyed)&&!l.error&&this.createAssetPlayer(e,l,d);}return this.getAssetPlayer(e.assetList[t].identifier)}return null}flushFrontBuffer(e){let t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(r=>{this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r});});}getAssetPlayerQueueIndex(e){let t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return -1}getAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){let{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,n,a){let o={parentIdentifier:e.identifier,identifier:Cb(e,a,t),duration:n,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){let r=this.hls,n=r.userConfig,a=n.videoPreference,o=r.loadLevelObj||r.levels[r.currentLevel];(a||o)&&(a=Te({},a),o.videoCodec&&(a.videoCodec=o.videoCodec),o.videoRange&&(a.allowedVideoRanges=[o.videoRange]));let d=r.audioTracks[r.audioTrack],l=r.subtitleTracks[r.subtitleTrack],c=0;if(this.primaryLive||e.appendInPlace){let y=this.timelinePos-t.timelineStart;if(y>1){let b=t.duration;b&&y<b&&(c=y);}}let u=t.identifier,h=be(be({},n),{},{autoStartLoad:true,startFragPrefetch:true,primarySessionId:r.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:false,testBandwidth:false,videoPreference:a,audioPreference:d||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=true,t.timelineStart&&(h.timelineOffset=t.timelineStart));let f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=Te({},f,{contentId:Dn(t.uri)})),this.getAssetPlayer(u)&&this.warn(`Duplicate date range identifier ${e} and asset ${u}`);let m=new Gu(this.HlsPlayerClass,h,e,t);this.playerQueue.push(m),e.assetList[i]=t;let E=y=>{if(y.live){let k=new Error(`Interstitials MUST be VOD assets ${e}`),I={fatal:true,type:W.OTHER_ERROR,details:R.INTERSTITIAL_ASSET_ITEM_ERROR,error:k};this.handleAssetItemError(I,e,this.schedule.findEventIndex(e.identifier),i,k.message);return}let b=y.edge-y.fragmentStart,L=t.duration;(L===null||b>L)&&(this.log(`Interstitial asset "${u}" duration change ${L} > ${b}`),t.duration=b,this.updateSchedule());};m.on(g.LEVEL_UPDATED,(y,{details:b})=>E(b)),m.on(g.LEVEL_PTS_UPDATED,(y,{details:b})=>E(b));let p=(y,b)=>{let L=this.getAssetPlayer(u);if(L&&b.tracks){L.off(g.BUFFER_CODECS,p),L.tracks=b.tracks;let k=this.primaryMedia;this.bufferingAsset===L.assetItem&&k&&!L.media&&this.bufferAssetPlayer(L,k);}};m.on(g.BUFFER_CODECS,p);let v=()=>{var y;let b=this.getAssetPlayer(u);if(this.log(`buffered to end of asset ${b}`),!b)return;let L=this.schedule.findEventIndex(e.identifier),k=(y=this.schedule.items)==null?void 0:y[L];if(this.isInterstitial(k)){let x=e.findAssetIndex(t),D=Gc(e,x);if(!e.isAssetPastPlayoutLimit(D))this.bufferedToItem(k,D);else {var I;let _=(I=this.schedule.items)==null?void 0:I[L+1];_&&this.bufferedToItem(_);}}};m.on(g.BUFFERED_TO_END,v);let S=y=>()=>{if(!this.getAssetPlayer(u))return;this.shouldPlay=true;let L=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,L,y);};return m.once(g.MEDIA_ENDED,S(i)),m.once(g.PLAYOUT_LIMIT_REACHED,S(1/0)),m.on(g.ERROR,(y,b)=>{let L=this.getAssetPlayer(u);if(b.details===R.BUFFER_STALLED_ERROR){if(L!=null&&L.media){let k=L.currentTime,I=L.duration-k;k&&e.appendInPlace&&I/L.media.playbackRate<.5?(this.log(`Advancing buffer past end of asset ${u} ${e} at ${L.media.currentTime}`),v()):(this.warn(`Stalled at ${k} of ${k+I} in asset ${u} ${e}`),this.onTimeupdate(),this.checkBuffer(true));}return}this.handleAssetItemError(b,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${b.error} ${e}`);}),m.on(g.DESTROYING,()=>{if(!this.getAssetPlayer(u))return;let b=new Error(`Asset player destroyed unexpectedly ${u}`),L={fatal:true,type:W.OTHER_ERROR,details:R.INTERSTITIAL_ASSET_ITEM_ERROR,error:b};this.handleAssetItemError(L,e,this.schedule.findEventIndex(e.identifier),i,b.message);}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${hr(t)}`),this.hls.trigger(g.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t);}),e.reset();}resetAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);let i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails();}}clearAssetPlayer(e,t){let i=this.getAssetPlayerQueueIndex(e);if(i!==-1){this.log(`clear asset player "${e}" toSegment: ${t&&Ui(t)}`);let r=this.playerQueue[i];this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy();}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[];}startAssetPlayer(e,t,i,r,n){let{interstitial:a,assetItem:o,assetId:d}=e,l=a.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==d)&&(c&&(this.clearAssetPlayer(c.identifier,i[r]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${hr(o)}`),this.hls.trigger(g.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n);}bufferAssetPlayer(e,t){var i,r;let{interstitial:n,assetItem:a}=e,o=this.schedule.findEventIndex(n.identifier),d=(i=this.schedule.items)==null?void 0:i[o];if(!d)return;this.setBufferingItem(d),this.bufferingAsset=a;let l=this.getBufferingPlayer();if(l===e)return;let c=n.appendInPlace;if(c&&l?.interstitial.appendInPlace===false)return;let u=l?.tracks||((r=this.detachedData)==null?void 0:r.tracks)||this.requiredTracks;if(c&&a!==this.playingAsset){if(!e.tracks)return;if(u&&!op(u,e.tracks)){let h=new Error(`Asset ${hr(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),f={fatal:true,type:W.OTHER_ERROR,details:R.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=n.findAssetIndex(a);this.handleAssetItemError(f,n,o,m,h.message);return}}this.transferMediaTo(e,t);}handleAssetItemError(e,t,i,r,n){if(e.details===R.BUFFER_STALLED_ERROR)return;let a=t.assetList[r];this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&hr(a)} ${e.error}`);let o=a?.identifier,d=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[d]||null,c=this.schedule.items,u=Te({},e,{fatal:false,errorAction:wn(true),asset:a,assetListIndex:r,event:t,schedule:c,scheduleIndex:i,player:l});if(this.hls.trigger(g.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;let h=this.playingAsset,f=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=f),!t.assetList.some(m=>!m.error))t.error=f;else {for(let m=r;m<t.assetList.length;m++)this.resetAssetPlayer(t.assetList[m].identifier);this.updateSchedule();}t.error?this.primaryFallback(t):h&&h.identifier===o&&this.advanceAfterAssetEnded(t,i,r);}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem;if(this.updateSchedule(),i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${i?Ui(i):"<none>"} error: ${e.error}`);let r=this.timelinePos;r===-1&&(r=this.hls.startPosition);let n=this.updateItem(i,r);this.itemsMatch(i,n)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));let a=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(a);}else this.checkStart();}onAssetListLoaded(e,t){var i;let r=t.event,n=r.identifier,a=t.assetListResponse.ASSETS;if(!this.schedule.hasEvent(n))return;let o=r.timelineStart,d=r.duration,l=0;a.forEach((m,E)=>{let p=parseFloat(m.DURATION);this.createAsset(r,E,l,o+l,p,m.URI),l+=p;}),r.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${d}) ${r}`);let c=this.waitingItem,u=c?.event.identifier===n;this.updateSchedule();let h=(i=this.bufferingItem)==null?void 0:i.event;if(u){var f;let m=this.schedule.findEventIndex(n),E=(f=this.schedule.items)==null?void 0:f[m];if(E){if(!this.playingItem&&this.timelinePos>E.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==m){r.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${r}`),this.primaryFallback(r);return}this.setBufferingItem(E);}this.setSchedulePosition(m);}else if(h?.identifier===n&&h.appendInPlace){let m=r.assetList[0],E=this.getAssetPlayer(m.identifier),p=this.primaryMedia;m&&E&&p&&this.bufferAssetPlayer(E,p);}}onError(e,t){switch(t.details){case R.ASSET_LIST_PARSING_ERROR:case R.ASSET_LIST_LOAD_ERROR:case R.ASSET_LIST_LOAD_TIMEOUT:{let i=t.interstitial;i&&this.primaryFallback(i);break}case R.BUFFER_STALLED_ERROR:{this.onTimeupdate(),this.checkBuffer(true);break}}}},Qg=500,Wu=class extends Nn{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",K.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(g.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(g.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this);}startLoad(e,t){this.stopLoad(),this.state=C.IDLE,this.setInterval(Qg),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null;}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t);}onLevelLoaded(e,t){this.mainDetails=t.details;}onSubtitleFragProcessed(e,t){let{frag:i,success:r}=t;if(this.fragContextChanged(i)||($e(i)&&(this.fragPrevious=i),this.state=C.IDLE),!r)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let l=0;l<n.length;l++)if(o>=n[l].start&&o<=n[l].end){a=n[l];break}let d=i.start+i.duration;a?a.end=d:(a={start:o,end:d},n.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick();}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){let n=r-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(i,n,K.SUBTITLE);}}onError(e,t){let i=t.frag;i?.type===K.SUBTITLE&&(t.details===R.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,true),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==C.STOPPED&&(this.state=C.IDLE));}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Zp(this.levels,t)){this.levels=t.map(i=>new vs(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let r=new vs(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,K.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null;}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==C.STOPPED&&this.setInterval(Qg);}onSubtitleTrackLoaded(e,t){var i;let{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let d=n[o];if(o>=n.length||!d)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 l=0;if(a.live||(i=d.details)!=null&&i.live){if(a.deltaUpdateFailed)return;let u=this.mainDetails;if(!u){this.startFragRequested=false;return}let h=u.fragments[0];if(!d.details)a.hasProgramDateTime&&u.hasProgramDateTime?(pl(a,u),l=a.fragmentStart):h&&(l=h.start,fu(a,l));else {var c;l=this.alignPlaylists(a,d.details,(c=this.levelLastLoaded)==null?void 0:c.details),l===0&&h&&(l=h.start,fu(a,l));}u&&!this.startFragRequested&&this.setStartPosition(u,l);}d.details=a,this.levelLastLoaded=d,o===r&&(this.hls.trigger(g.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===C.IDLE&&(Ts(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)));}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&r!=null&&r.key&&r.iv&&gr(r.method)){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,ph(r.method)).catch(o=>{throw n.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:false,error:o,reason:o.message,frag:t}),o}).then(o=>{let d=performance.now();n.trigger(g.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:d}});}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=C.IDLE;});}}doTick(){if(!this.media){this.state=C.IDLE;return}if(this.state===C.IDLE){let{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;let{config:r}=this,n=this.getLoadPosition(),a=ne.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:d}=a,l=i.details,c=this.hls.maxBufferLength+l.levelTargetDuration;if(d>c)return;let u=l.fragments,h=u.length,f=l.edge,m=null,E=this.fragPrevious;if(o<f){let S=r.maxFragLookUpTolerance,y=o>f-S?0:S;m=Ts(E,u,Math.max(u[0].start,o),y),!m&&E&&E.start<u[0].start&&(m=u[0]);}else m=u[h-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;let p=m.sn-l.startSN,v=u[p-1];if(v&&v.cc===m.cc&&this.fragmentTracker.getState(v)===Ke.NOT_LOADED&&(m=v),this.fragmentTracker.getState(m)===Ke.NOT_LOADED){let S=this.mapToInitFragWhenRequired(m);S&&this.loadFragment(S,i,o);}}}loadFragment(e,t,i){$e(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t);}get mediaBufferTimeRanges(){return new qu(this.tracksBuffered[this.currentTrackId]||[])}},qu=class{constructor(e){this.buffered=void 0;let t=(i,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}};}},wb={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},l0=s=>String.fromCharCode(wb[s]||s),Ot=15,yi=100,Pb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ob={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Nb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Fb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ub=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Yu=class{constructor(){this.time=null,this.verboseLevel=0;}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;Ee.log(`${this.time} [${e}] ${i}`);}}},hs=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},xl=class{constructor(){this.foreground="white",this.underline=false,this.italics=false,this.background="black",this.flash=false;}reset(){this.foreground="white",this.underline=false,this.italics=false,this.background="black",this.flash=false;}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){let r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r]);}}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}},ju=class{constructor(){this.uchar=" ",this.penState=new xl;}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()}},zu=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new xl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<yi;t++)this.chars.push(new ju);this.logger=e;}equals(e){for(let t=0;t<yi;t++)if(!this.chars[t].equals(e.chars[t]))return false;return true}copy(e){for(let t=0;t<yi;t++)this.chars[t].copy(e.chars[t]);}isEmpty(){let e=true;for(let t=0;t<yi;t++)if(!this.chars[t].isEmpty()){e=false;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>yi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=yi);}moveCursor(e){let t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].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=l0(e);if(this.pos>=yi){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<yi;t++)this.chars[t].reset();}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset();}clearToEndOfRow(){this.clearFromPos(this.pos);}getTextString(){let e=[],t=true;for(let i=0;i<yi;i++){let r=this.chars[i].uchar;r!==" "&&(t=false),e.push(r);}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState);}},kn=class{constructor(e){this.rows=[],this.currRow=Ot-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ot;t++)this.rows.push(new zu(e));this.logger=e;}reset(){for(let e=0;e<Ot;e++)this.rows[e].clear();this.currRow=Ot-1;}equals(e){let t=true;for(let i=0;i<Ot;i++)if(!this.rows[i].equals(e.rows[i])){t=false;break}return t}copy(e){for(let t=0;t<Ot;t++)this.rows[t].copy(e.rows[t]);}isEmpty(){let e=true;for(let t=0;t<Ot;t++)if(!this.rows[t].isEmpty()){e=false;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 = "+Re(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<Ot;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,d=this.logger.time;if(o!==null&&d!==null&&o<d)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l]);}}this.currRow=t;let i=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground;}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:false};this.setPen(r);}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Re(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||false;let t=[],i="",r=-1;for(let n=0;n<Ot;n++){let a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()));}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
|
|
1717
|
-
`)),i}getTextAndFormat(){return this.rows}},Rl=class{constructor(e,t,i){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 kn(i),this.nonDisplayedMemory=new kn(i),this.lastOutputScreen=new kn(i),this.currRollUpRow=this.displayedMemory.rows[Ot-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i;}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ot-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(true)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(true)),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:true});}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(true);}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(true);}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(true);}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e);}ccMIDROW(e){let t={flash:false};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else {let i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i];}this.logger.log(2,"MIDROW: "+Re(t)),this.writeScreen.setPen(t);}outputDataUpdate(e=false){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));}},Dl=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=$b(),this.logger=void 0;let r=this.logger=new Yu;this.channels=[null,new Rl(e,t,r),new Rl(e+1,i,r)];}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t);}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){let r=t[i]&127,n=t[i+1]&127,a=false,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+hs([t[i],t[i+1]])+"] -> ("+hs([r,n])+")");let d=this.cmdHistory;if(r>=16&&r<=31){if(Bb(r,n,d)){jo(null,null,d),this.logger.log(3,()=>"Repeated command ("+hs([r,n])+") is dropped");continue}jo(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n));}else jo(null,null,d);if(!a&&(o=this.parseChars(r,n),o)){let c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?");}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+hs([r,n])+" orig: "+hs([t[i],t[i+1]]));}}parseCmd(e,t){let i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(i||r))return false;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,true}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),false;let r=this.channels[i];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+hs([e,t])+")"),true):false}return false}parsePAC(e,t){let i,r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return false;let a=e<=23?1:2;t>=64&&t<=95?i=a===1?Pb[e]:Nb[e]:i=a===1?Ob[e]:Fb[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,true):false}interpretPAC(e,t){let i,r={color:null,italics:false,indent:null,underline:false,row:e};return t>95?i=t-96:i=t-64,r.underline=(i&1)===1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=true,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(e,t){let i,r=null,n=null;if(e>=25?(i=2,n=e-8):(i=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 '"+l0(a)+"' in channel "+i),r=[a];}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+hs(r).join(",")),r}parseBackgroundAttributes(e,t){let i=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(i||r))return false;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=Ub[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=true));let o=e<=23?1:2;return this.channels[o].setBkgData(a),true}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset();}jo(null,null,this.cmdHistory);}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e);}}};function jo(s,e,t){t.a=s,t.b=e;}function Bb(s,e,t){return t.a===s&&t.b===e}function $b(){return {a:null,b:null}}var _h=function(){if(ml!=null&&ml.VTTCue)return self.VTTCue;let s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,d){if(typeof d!="string"||!Array.isArray(o))return false;let l=d.toLowerCase();return ~o.indexOf(l)?l:false}function i(o){return t(s,o)}function r(o){return t(e,o)}function n(o,...d){let l=1;for(;l<arguments.length;l++){let c=arguments[l];for(let u in c)o[u]=c[u];}return o}function a(o,d,l){let c=this,u={enumerable:true};c.hasBeenReset=false;let h="",f=false,m=o,E=d,p=l,v=null,S="",y=true,b="auto",L="start",k=50,I="middle",x=50,D="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(_){h=""+_;}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(_){f=!!_;}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return m},set:function(_){if(typeof _!="number")throw new TypeError("Start time must be set to a number.");m=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return E},set:function(_){if(typeof _!="number")throw new TypeError("End time must be set to a number.");E=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"text",n({},u,{get:function(){return p},set:function(_){p=""+_,this.hasBeenReset=true;}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(_){v=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return S},set:function(_){let M=i(_);if(M===false)throw new SyntaxError("An invalid or illegal string was specified.");S=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return y},set:function(_){y=!!_,this.hasBeenReset=true;}})),Object.defineProperty(c,"line",n({},u,{get:function(){return b},set:function(_){if(typeof _!="number"&&_!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");b=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return L},set:function(_){let M=r(_);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");L=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"position",n({},u,{get:function(){return k},set:function(_){if(_<0||_>100)throw new Error("Position must be between 0 and 100.");k=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return I},set:function(_){let M=r(_);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");I=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"size",n({},u,{get:function(){return x},set:function(_){if(_<0||_>100)throw new Error("Size must be between 0 and 100.");x=_,this.hasBeenReset=true;}})),Object.defineProperty(c,"align",n({},u,{get:function(){return D},set:function(_){let M=r(_);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");D=M,this.hasBeenReset=true;}})),c.displayState=void 0;}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Qu=class{decode(e,t){if(!e)return "";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function d0(s){function e(i,r,n,a){return (i|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}let t=s.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 Xu=class{constructor(){this.values=Object.create(null);}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t);}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){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 i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),true}return false}};function c0(s,e,t,i){let r=i?s.split(i):[s];for(let n in r){if(typeof r[n]!="string")continue;let a=r[n].split(t);if(a.length!==2)continue;let o=a[0],d=a[1];e(o,d);}}var Zu=new _h(0,0,""),zo=Zu.align==="middle"?"middle":"center";function Gb(s,e,t){let i=s;function r(){let o=d0(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,d){let l=new Xu;c0(o,function(h,f){let m;switch(h){case "region":for(let E=t.length-1;E>=0;E--)if(t[E].id===f){l.set(h,t[E].region);break}break;case "vertical":l.alt(h,f,["rl","lr"]);break;case "line":m=f.split(","),l.integer(h,m[0]),l.percent(h,m[0])&&l.set("snapToLines",false),l.alt(h,m[0],["auto"]),m.length===2&&l.alt("lineAlign",m[1],["start",zo,"end"]);break;case "position":m=f.split(","),l.percent(h,m[0]),m.length===2&&l.alt("positionAlign",m[1],["start",zo,"end","line-left","line-right","auto"]);break;case "size":l.percent(h,f);break;case "align":l.alt(h,f,["start",zo,"end","left","right"]);break}},/:/,/\s/),d.region=l.get("region",null),d.vertical=l.get("vertical","");let c=l.get("line","auto");c==="auto"&&Zu.line===-1&&(c=-1),d.line=c,d.lineAlign=l.get("lineAlign","start"),d.snapToLines=l.get("snapToLines",true),d.size=l.get("size",100),d.align=l.get("align",zo);let u=l.get("position","auto");u==="auto"&&Zu.position===50&&(u=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=u;}function a(){s=s.replace(/^\s+/,"");}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e);}function u0(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
1718
|
-
`)}var Ju=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Qu,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:true}));function i(){let n=t.buffer,a=0;for(n=u0(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
1719
|
-
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
1720
|
-
`&&++a,t.buffer=n.slice(a),o}function r(n){c0(n,function(a,o){},/:/);}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();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=i(),t.state){case "HEADER":/:/.test(n)?r(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 _h(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case "CUE":if(!t.cue){t.state="BADCUE";continue}try{Gb(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+=`
|
|
1721
|
-
`),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+=`
|
|
1722
|
-
|
|
1723
|
-
`,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}},Hb=/\r\n|\n\r|\n|\r/g,Hc=function(e,t,i=0){return e.slice(i,i+t.length)===t},Vb=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!$(t)||!$(i)||!$(r)||!$(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=60*60*1e3*n,t};function Ih(s,e,t){return Dn(s.toString())+Dn(e.toString())+Dn(t)}var Kb=function(e,t,i){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=false;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=r.start-n.start,r.new=false,r=n,n=e[r.prevCC];}e.presentationOffset=i;};function Wb(s,e,t,i,r,n,a){let o=new Ju,d=St(new Uint8Array(s)).trim().replace(Hb,`
|
|
1724
|
-
`).split(`
|
|
1725
|
-
`),l=[],c=e?CS(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,m,E=true;o.oncue=function(p){let v=t[i],S=t.ccOffset,y=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?S=t.ccOffset=v.start:Kb(t,i,y)),y){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}S=y-t.presentationOffset;}let b=p.endTime-p.startTime,L=Lt((p.startTime+S-f)*9e4,r*9e4)/9e4;p.startTime=Math.max(L,0),p.endTime=Math.max(L+b,0);let k=p.text.trim();p.text=decodeURIComponent(encodeURIComponent(k)),p.id||(p.id=Ih(p.startTime,p.endTime,k)),p.endTime>0&&l.push(p);},o.onparsingerror=function(p){m=p;},o.onflush=function(){if(m){a(m);return}n(l);},d.forEach(p=>{if(E)if(Hc(p,"X-TIMESTAMP-MAP=")){E=false,p.slice(16).split(",").forEach(v=>{Hc(v,"LOCAL:")?u=v.slice(6):Hc(v,"MPEGTS:")&&(h=parseInt(v.slice(7)));});try{f=Vb(u)/1e3;}catch(v){m=v;}return}else p===""&&(E=false);o.parse(p+`
|
|
1726
|
-
`);}),o.flush();}var Vc="stpp.ttml.im1t",h0=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,f0=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,qb={left:"start",center:"center",right:"end",start:"start",end:"end"};function Xg(s,e,t,i){let r=de(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=r.map(o=>St(o)),a=kS(e.baseTime,1,e.timescale);try{n.forEach(o=>t(Yb(o,a)));}catch(o){i(o);}}function Yb(s,e){let r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",d=Zg(Kc(r,"styling","style")),l=Zg(Kc(r,"layout","region")),c=Kc(r,"body","[begin]");return [].map.call(c,u=>{let h=m0(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=qc(u.getAttribute("begin"),a),m=qc(u.getAttribute("dur"),a),E=qc(u.getAttribute("end"),a);if(f===null)throw Jg(u);if(E===null){if(m===null)throw Jg(u);E=f+m;}let p=new _h(f-e,E-e,h);p.id=Ih(p.startTime,p.endTime,p.text);let v=l[u.getAttribute("region")],S=d[u.getAttribute("style")],y=jb(v,S,d),{textAlign:b}=y;if(b){let L=qb[b];L&&(p.lineAlign=L),p.align=b;}return Te(p,y),p}).filter(u=>u!==null)}function Kc(s,e,t){let i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Zg(s){return s.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function m0(s,e){return [].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
|
|
1727
|
-
`:(n=i.childNodes)!=null&&n.length?m0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function jb(s,e,t){let i="http://www.w3.org/ns/ttml#styling",r=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,d)=>{let l=Wc(e,i,d)||Wc(s,i,d)||Wc(r,i,d);return l&&(o[d]=l),o},{})}function Wc(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Jg(s){return new Error(`Could not parse ttml timestamp ${s}`)}function qc(s,e){if(!s)return null;let t=d0(s);return t===null&&(h0.test(s)?t=zb(s,e):f0.test(s)&&(t=Qb(s,e))),t}function zb(s,e){let t=h0.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return (t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function Qb(s,e){let t=f0.exec(s),i=Number(t[1]);switch(t[2]){case "h":return i*3600;case "m":return i*60;case "ms":return i*1e3;case "f":return i/e.frameRate;case "t":return i/e.tickRate}return i}var mr=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,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName);}reset(){this.cueRanges=[],this.startTime=null;}},eh=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=true,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=tp(),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(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this),e.on(g.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(g.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this);}destroy(){let{hls:e}=this;e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this),e.off(g.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(g.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){let e=new mr(this,"textTrack1"),t=new mr(this,"textTrack2"),i=new mr(this,"textTrack3"),r=new mr(this,"textTrack4");this.cea608Parser1=new Dl(1,e,t),this.cea608Parser2=new Dl(3,i,r);}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let d=n[o],l=Xb(d[0],d[1],t,i);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=true,l/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r);}else {let o=this.Cues.newCue(null,t,i,r);this.hls.trigger(g.CUES_PARSED,{type:"captions",cues:o,track:e});}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n}){let{unparsedVttFrags:a}=this;i===K.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.initPTS[o.frag.cc]?this.onFragLoaded(g.FRAG_LOADED,o):this.hls.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:false,frag:o.frag,error:new Error("Subtitle discontinuity domain does not match main")});}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if(ep(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))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:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,fr(i[e]),n0(i[e],r);else {let d=this.createTextTrack("captions",n,a);d&&(d[e]=true,i[e]=d);}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:false,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(g.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]});}createTextTrack(e,t,i){let r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks();}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(n=>{fr(r[n]),delete r[n];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=tp(),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 i=0;i<t.length;i++)fr(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===Vc);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Zp(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?il(a.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&ep(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u);}if(c)fr(c);else {let u=g0(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled");}c&&this.textTracks.push(c);}),o!=null&&o.length){let d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${d.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(g.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a});}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;let n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i);});}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===K.MAIN){var i,r;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c;}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===K.SUBTITLE)if(r.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:true},this.prevCC=i.cc),o&&o.textCodec===Vc?this._parseIMSC1(i,r):this._parseVTTs(t);}}else this.hls.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:new Error("Empty subtitle payload")});}_parseIMSC1(e,t){let i=this.hls;Xg(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{i.logger.log(`Failed to parse IMSC1: ${r}`),i.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:false,frag:e,error:r});});}_parseVTTs(e){var t;let{frag:i,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}let d=this.hls,l=(t=i.initSegment)!=null&&t.data?Rt(i.initSegment.data,new Uint8Array(r)).buffer:r;Wb(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),d.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i});},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,r),d.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&d.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:c});});}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||Xg(t,this.initPTS[e.cc],()=>{i.textCodec=Vc,this._parseIMSC1(e,t);},()=>{i.textCodec="wvtt";});}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>a0(r,n));}else {let r=this.tracks[t];if(!r)return;let n=r.default?"default":"subtitles"+t;i.trigger(g.CUES_PARSED,{type:"subtitles",cues:e,track:n});}}onFragDecrypted(e,t){let{frag:i}=t;i.type===K.SUBTITLE&&this.onFragLoaded(g.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(!(i.type===K.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){let a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();let o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1]);}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(d=>Uu(o[d],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(d=>Uu(o[d],t,r));}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,r=2;for(let n=0;n<i;n++){let a=e[r++],o=127&e[r++],d=127&e[r++];if(o===0&&d===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(d));}}return t}};function g0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function ep(s,e){return !!s&&s.kind===g0(e)&&xu(e,s)}function Xb(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function tp(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var Zb=/\s/,Jb={newCue(s,e,t,i){let r=[],n,a,o,d,l,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=true,d=0,l="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)Zb.test(n.chars[E].uchar)&&o?d++:(l+=n.chars[E].uchar,o=false);n.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;let f=u0(l.trim()),m=Ih(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(d*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>a0(s,h))),r}};function eA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var tA=/(\d+)-(\d+)\/(\d+)/,kl=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||nA,this.controller=new self.AbortController,this.stats=new Cn;}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=true,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,i){let r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();let n=iA(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&$(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},t.timeout),($n(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;let f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},l-(f-r.loading.start)),!u.ok){let{status:E,statusText:p}=u;throw new th(p||"fetch, bad network response",E,u)}r.loading.first=f,r.total=rA(u.headers)||r.total;let m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&$(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;let m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let E=u[o];E&&(r.loaded=r.total=E);let p={url:m.url,data:u,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!$(t.highWaterMark)&&v(r,e,u,m),(f=this.callbacks)==null||f.onSuccess(p,r,e,m);}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;let f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,r);});}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,i,r=0,n){let a=new El,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let c=l.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}};function iA(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Te({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function sA(s){let e=tA.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function rA(s){let e=s.get("Content-Range");if(e){let i=sA(e);if($(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function nA(s,e){return new self.Request(s.url,e)}var th=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},aA=/^age:\s*[\d.]+\s*$/im,Cl=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 Cn,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=true,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,i){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=i,this.loadInternal();}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=false;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,true),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e);}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r);}):this.openAndSendXhr(i,t,e);}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,true);let r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[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),i.timeout=n&&$(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send();}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.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-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){let m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);let E=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=E,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);let p=(a=this.callbacks)==null?void 0:a.onProgress;p&&p(i,e,m,t);let v={url:t.responseURL,data:m,code:l};(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}let u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(ul(u,h,false,f))this.retry(u);else {var d;Ee.error(`${l} while loading ${e.url}`),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,i);}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(ul(e,t,true))this.retry(e);else {var i;Ee.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);let r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader));}}retry(e){let{context:t,stats:i}=this;this.retryDelay=gh(e,i.retry),i.retry++,Ee.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.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&&aA.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}},oA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},lA=be(be({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:false,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:true,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:false,loader:Cl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:tu,bufferController:Cu,capLevelController:Mu,errorController:iu,fpsController:Fu,stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Ip,requireKeySystemAccessOnStart:false,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableEmsgKLVMetadata:false,enableID3MetadataCues:true,enableInterstitialPlayback:true,interstitialAppendInPlace:true,interstitialLiveLookAhead:10,useMediaCapabilities:true,preserveManualLevelOnError:false,certLoadPolicy:{default:oA},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},dA()),{},{subtitleStreamController:Wu,subtitleTrackController:Bu,timelineController:eh,audioStreamController:Lu,audioTrackController:Ru,emeController:Il,cmcdController:Ou,contentSteeringController:Nu,interstitialsController:Ku});function dA(){return {cueHandler:Jb,enableWebVTT:true,enableIMSC1:true,enableCEA708Captions:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function cA(s,e,t){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 i=ih(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{let o=`${a==="level"?"playlist":a}LoadPolicy`,d=e[o]===void 0,l=[];n.forEach(c=>{let u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&d){l.push(u);let f=i[o].default;switch(e[o]={default:f},c){case "TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case "MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${Re(e[o])}`);}),be(be({},i),e)}function ih(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(ih):Object.keys(s).reduce((e,t)=>(e[t]=ih(s[t]),e),{}):s}function uA(s,e){let t=s.loader;t!==kl&&t!==Cl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):eA()&&(s.loader=kl,s.progressive=true,s.enableSoftwareAES=true,e.log("[config]: Progressive streaming enabled, using FetchLoader"));}var sl=2,hA=.1,fA=.05,mA=100,sh=class extends hl{constructor(e,t){super("gap-controller",e.logger),this.hls=null,this.fragmentTracker=null,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0;},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick());},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:false});}},this.hls=e,this.fragmentTracker=t,this.registerListeners();}registerListeners(){let{hls:e}=this;e&&(e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this));}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0;}onMediaAttached(e,t){this.setInterval(mA),this.mediaSource=t.mediaSource;let i=this.media=t.media;xt(i,"playing",this.onMediaPlaying),xt(i,"waiting",this.onMediaWaiting),xt(i,"ended",this.onMediaEnded);}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(Ut(i,"playing",this.onMediaPlaying),Ut(i,"waiting",this.onMediaWaiting),Ut(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0;}onBufferAppended(e,t){this.buffered=t.timeRanges;}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t;}poll(e,t){var i,r;let n=(i=this.hls)==null?void 0:i.config;if(!n)return;let a=this.media;if(!a)return;let{seeking:o}=a,d=this.seeking&&!o,l=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=true,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:false}));return}if(!ne.getBuffered(a).length){this.nudgeRetry=0;return}let u=ne.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){let k=ip(this.hls.inFlightFragments,e),I=u.len>sl,x=!h||k||h-e>sl&&!f.getPartialFragment(e);if(I||x)return;this.moved=false;}let m=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;let I=Math.max(h,u.start||0)-e,D=!!(m!=null&&m.live)?m.targetduration*2:sl,_=f.getPartialFragment(e);if(I>0&&(I<=D||_)){a.paused||this._trySkipBufferHole(_);return}}let E=n.detectStallWithCurrentTimeMs,p=self.performance.now(),v=this.waiting,S=this.stalled;if(S===null)if(v>0&&p-v<E)S=this.stalled=v;else {this.stalled=p;return}let y=p-S;if(!o&&(y>=E||v)&&this.hls){var b;if(((b=this.mediaSource)==null?void 0:b.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:true});return}if(this._reportStall(u),!this.media||!this.hls)return}let L=ne.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(L,y,e);}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=false,this.waiting=0,this.hls.trigger(g.STALL_RESOLVED,{});}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){let n=ne.bufferedInfo(ne.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){let a=ne.timeRangesToArray(r),o=ne.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){let d=ne.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,c=a[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){let u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${d}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=this.fragmentTracker.getPartialFragment(e)||void 0,f=ne.bufferInfo(this.media,e,0);this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f});}}}}}_tryFixBufferStall(e,t,i){var r,n;let{fragmentTracker:a,media:o}=this,d=(r=this.hls)==null?void 0:r.config;if(!o||!a||!d)return;let l=(n=this.hls)==null?void 0:n.latestLevelDetails,c=a.getPartialFragment(i);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-i<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e));}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let n=i.getFragAtPos(t,K.MAIN),a=i.getFragAtPos(r,K.MAIN);if(n&&a)return a.sn-n.sn<2}return false}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=true;let a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Re(e)})`);this.warn(a.message),t.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,fatal:false,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}});}}_trySkipBufferHole(e){var t;let{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;let a=r.currentTime,o=ne.bufferInfo(r,a,0),d=a<o.start?o.start:o.nextStart;if(d&&this.hls){let c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&r.readyState<3,h=d-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let m=false;if(a===0){let E=i.getAppendedFrag(0,K.MAIN);E&&d<E.end&&(m=true);}if(!m){let E=e||i.getAppendedFrag(a,K.MAIN);if(E){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||ip(this.hls.inFlightFragments,d))return 0;let v=false,S=E.end;for(;S<d;){let y=i.getAppendedFrag(S,K.MAIN)||i.getPartialFragment(S);if(y)S+=y.duration;else {v=true;break}}if(v)return 0}}}let f=Math.max(d+fA,a+hA);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=true,r.currentTime=f,!(e!=null&&e.gap)){let m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`);this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_SEEK_OVER_HOLE,fatal:false,error:m,reason:m.message,frag:e||void 0,buffer:o.len,bufferInfo:o});}return f}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){let o=a+(r+1)*n.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(d.message),i.currentTime=o,t.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_NUDGE_ON_STALL,error:d,fatal:false,buffer:e.len,bufferInfo:e});}else {let o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,error:o,fatal:true,buffer:e.len,bufferInfo:e});}}};function ip(s,e){let t=sp(s.main);if(t&&t.start<=e)return t;let i=sp(s.audio);return i&&i.start<=e?i:null}function sp(s){if(!s)return null;switch(s.state){case C.IDLE:case C.STOPPED:case C.ENDED:case C.ERROR:return null}return s.frag}var gA=.25;function rh(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function rp(s,e,t,i,r){let n=new s(e,t,"");try{n.value=i,r&&(n.type=r);}catch{n=new s(e,t,Re(r?be({type:r},i):i));}return n}var Qo=(()=>{let s=rh();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),nh=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=true,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(g.EVENT_CUE_ENTER,{});},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null;}_registerListeners(){let{hls:e}=this;e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this);}_unregisterListeners(){let{hls:e}=this;e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this);}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===false&&(this.removeCues=false);}onMediaAttached(){let e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e);}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&fr(this.id3Track,this.onEventCueEnter),this.id3Track=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 i=e[t];if(i.kind==="metadata"&&i.label==="id3")return n0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:r}}}=this;if(!i&&!r)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=rh();if(a)for(let o=0;o<n.length;o++){let d=n[o].type;if(d===yt.emsg&&!i||!r)continue;let l=Gp(n[o].data);if(l){let c=n[o].pts,u=c+n[o].duration;u>Qo&&(u=Qo),u-c<=0&&(u=c+gA);for(let f=0;f<l.length;f++){let m=l[f];if(!Hp(m)){this.updateId3CueEnds(c,d);let E=rp(a,c,u,m,d);E&&this.id3Track.addCue(E);}}}}}updateId3CueEnds(e,t){var i;let r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let n=r.length;n--;){let a=r[n];a.type===t&&a.startTime<e&&a.endTime===Qo&&(a.endTime=e);}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=a;if(n&&(o||d)){let l;r==="audio"?l=c=>c.type===yt.audioId3&&d:r==="video"?l=c=>c.type===yt.emsg&&o:l=c=>c.type===yt.audioId3&&d||c.type===yt.emsg&&o,Uu(n,t,i,l);}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,true);}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details);}updateDateRangeCues(e,t){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{id3Track:i}=this,{dateRanges:r}=e,n=Object.keys(r),a=this.dateRangeCuesAppended;if(i&&t){var o;if((o=i.cues)!=null&&o.length){let c=Object.keys(a).filter(u=>!n.includes(u));for(let u=c.length;u--;){let h=c[u],f=a[h].cues;delete a[h],Object.keys(f).forEach(m=>{try{let E=f[m];E.removeEventListener("enter",this.onEventCueEnter),i.removeCue(E);}catch{}});}}else a=this.dateRangeCuesAppended={};}let d=e.fragments[e.fragments.length-1];if(n.length===0||!$(d?.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=rh();for(let c=0;c<n.length;c++){let u=n[c],h=r[u],f=h.startTime,m=a[u],E=m?.cues||{},p=m?.durationKnown||false,v=Qo,{duration:S,endDate:y}=h;if(y&&S!==null)v=f+S,p=true;else if(h.endOnNext&&!p){let L=n.reduce((k,I)=>{if(I!==h.id){let x=r[I];if(x.class===h.class&&x.startDate>h.startDate&&(!k||h.startDate<k.startDate))return x}return k},null);L&&(v=L.startTime,p=true);}let b=Object.keys(h.attr);for(let L=0;L<b.length;L++){let k=b[L];if(!Ry(k))continue;let I=E[k];if(I)p&&!m.durationKnown?I.endTime=v:Math.abs(I.startTime-f)>.01&&(I.startTime=f,I.endTime=v);else if(l){let x=h.attr[k];Dy(k)&&(x=lp(x));let _=rp(l,f,v,{key:k,data:x},yt.dateRange);_&&(_.id=u,this.id3Track.addCue(_),E[k]=_,this.hls.config.interstitialsController&&(k==="X-ASSET-LIST"||k==="X-ASSET-URL")&&_.addEventListener("enter",this.onEventCueEnter));}}a[u]={cues:E,dateRange:h,durationKnown:p};}}},ah=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=false,this.onTimeupdate=()=>{let{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;let o=this.targetLatency;if(o===null)return;let d=r-o,l=Math.min(this.maxLatency,o+i.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-0.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f);}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1);},this.hls=e,this.config=e.config,this.registerListeners();}get levelDetails(){var e;return ((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(e===null||this.hls===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,d=this.hls.userConfig,l=o&&i||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:a*r);let c=r;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=true;}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;let i=this.levelDetails;if(i===null)return null;let r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){let e=this.levelDetails;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}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null;}registerListeners(){let{hls:e}=this;e&&(e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.ERROR,this.onError,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.ERROR,this.onError,this));}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null);}onManifestLoading(){this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate);}onError(e,t){var i;t.details===R.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"));}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t);}estimateLiveEdge(){let e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},oh=class extends Gn{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(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.ERROR,this.onError,this);}_unregisterListeners(){let{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.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 i=this.hls.config.preferManagedMediaSource,r=[],n={},a={},o=false,d=false,l=false;t.levels.forEach(c=>{let u=c.attrs,{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=al(h,i)||void 0),f&&(f=c.videoCodec=ey(f));let{width:m,height:E,unknownCodecs:p}=c,v=p?p.length:0;if(p)for(let _=v;_--;){let M=p[_];this.isAudioSupported(M)?(c.audioCodec=h=h?`${h},${M}`:M,v--,vr.audio[h.substring(0,4)]=2):this.isVideoSupported(M)&&(c.videoCodec=f=f?`${f},${M}`:M,v--,vr.video[f.substring(0,4)]=2);}if(o||(o=!!(m&&E)),d||(d=!!f),l||(l=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}let{CODECS:S,"FRAME-RATE":y,"HDCP-LEVEL":b,"PATHWAY-ID":L,RESOLUTION:k,"VIDEO-RANGE":I}=u,D=`${`${L||"."}-`}${c.bitrate}-${k}-${y}-${S}-${I}-${b}`;if(n[D])if(n[D].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let _=a[D]+=1;c.attrs["PATHWAY-ID"]=new Array(_+1).join(".");let M=this.createLevel(c);n[D]=M,r.push(M);}else n[D].addGroupId("audio",u.AUDIO),n[D].addGroupId("text",u.SUBTITLES);else {let _=this.createLevel(c);n[D]=_,a[D]=1,r.push(_);}}),this.filterAndSortMediaOptions(r,t,o,d,l);}createLevel(e){let t=new vs(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=Ep(r,[]);}return t}isAudioSupported(e){return Zc(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Zc(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){let a=[],o=[],d=e;if((i||r)&&n&&(d=d.filter(({videoCodec:p,videoRange:v,width:S,height:y})=>(!!p||!!(S&&y))&&ly(v))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let p="no level with compatible codecs found in manifest",v=p;t.levels.length&&(v=`one or more CODECS in variant not supported: ${Re(t.levels.map(y=>y.attrs.CODECS).filter((y,b,L)=>L.indexOf(y)===b))}`,this.warn(v),p+=` (${v})`);let S=new Error(p);this.hls.trigger(g.ERROR,{type:W.MEDIA_ERROR,details:R.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:S,reason:v});}});return}t.audioTracks&&(a=t.audioTracks.filter(p=>!p.audioCodec||this.isAudioSupported(p.audioCodec)),np(a)),t.subtitles&&(o=t.subtitles,np(o));let l=d.slice(0);d.sort((p,v)=>{if(p.attrs["HDCP-LEVEL"]!==v.attrs["HDCP-LEVEL"])return (p.attrs["HDCP-LEVEL"]||"")>(v.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&p.height!==v.height)return p.height-v.height;if(p.frameRate!==v.frameRate)return p.frameRate-v.frameRate;if(p.videoRange!==v.videoRange)return ol.indexOf(p.videoRange)-ol.indexOf(v.videoRange);if(p.videoCodec!==v.videoCodec){let S=rg(p.videoCodec),y=rg(v.videoCodec);if(S!==y)return y-S}if(p.uri===v.uri&&p.codecSet!==v.codecSet){let S=nl(p.codecSet),y=nl(v.codecSet);if(S!==y)return y-S}return p.averageBitrate!==v.averageBitrate?p.averageBitrate-v.averageBitrate:0});let c=l[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==l.length)){for(let p=0;p<l.length;p++)if(l[p].pathwayId===d[0].pathwayId){c=l[p];break}}this._levels=d;for(let p=0;p<d.length;p++)if(d[p]===c){var u;this._firstLevel=p;let v=c.bitrate,S=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${v}`),((u=this.hls.userConfig)==null?void 0:u.abrEwmaDefaultEstimate)===void 0){let y=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);y>S&&S===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y);}break}let h=n&&!r,f=this.hls.config,m=!!(f.audioStreamController&&f.audioTrackController),E={levels:d,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:m&&!h&&a.some(p=>!!p.url)};this.hls.trigger(g.MANIFEST_PARSED,E);}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1);}let i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&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 ${i}${n?" with Pathway "+n:""}`);let d={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(g.LEVEL_SWITCHING,d);let l=a.details;if(!l||l.live){let c=this.switchParams(a.uri,r?.details,l);this.loadPlaylist(c);}}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;}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i;}}onError(e,t){t.fatal||!t.context||t.context.type===ce.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===K.MAIN){let i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;let r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0);}}onLevelLoaded(e,t){var i;let{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let d=a.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(r,t,d);}else (i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(g.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||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;if(this._levels.length===1)return;let i=this._levels.filter((n,a)=>a!==e?true:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),false));Mp(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(g.LEVELS_UPDATED,{levels:i});}onLevelsUpdated(e,{levels:t}){this._levels=t;}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(g.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}));}};function np(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}function p0(){return self.SourceBuffer||self.WebKitSourceBuffer}function E0(){if(!Gi())return false;let e=p0();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function pA(){if(!E0())return false;let s=Gi();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Mn(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Mn(e,"audio"))))}function EA(){var s;let e=p0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var vA=100,lh=class extends Nn{constructor(e,t,i){super(e,t,i,"stream-controller",K.MAIN),this.audioCodecSwap=false,this.level=-1,this._forceStartLoad=false,this._hasEnoughToStart=false,this.altAudio=0,this.audioOnly=false,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick();},this.onMediaSeeked=()=>{let r=this.media,n=r?r.currentTime:null;if(n===null||!$(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;let a=this.getFwdBufferInfoAtPos(r,n,K.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick();},this.registerListeners();}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this);}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying();}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(vA),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=true):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t;}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=C.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}else this._forceStartLoad=true,this.state=C.STOPPED;}stopLoad(){this._forceStartLoad=false,super.stopLoad();}doTick(){switch(this.state){case C.WAITING_LEVEL:{let{levels:t,level:i}=this,r=t?.[i],n=r?.details;if(n&&(!n.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(n))break;this.state=C.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=C.IDLE;break}break}case C.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){let{levels:r,level:n}=this,a=r?.[n];this.resetStartWhenNotLoaded(a||null),this.state=C.IDLE;}}break}this.state===C.IDLE&&this.doTickIdle(),this.onTickEnd();}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===false&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){let E={};this.altAudio===2&&(E.type="video"),this.hls.trigger(g.BUFFER_EOS,E),this.state=C.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 l=a.details;if(!l||this.state===C.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=C.WAITING_LEVEL,this.startFragRequested=false;return}let c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&$e(f)&&this.fragmentTracker.getState(f)!==Ke.OK){var m;let p=((m=this.backtrackFragment)!=null?m:f).sn-l.startSN,v=l.fragments[p-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v));}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let p=this.audioOnly&&!this.altAudio?_e.AUDIO:_e.VIDEO,v=(p===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,p,K.MAIN);}f=this.getNextFragmentLoopLoading(f,l,o,K.MAIN,u);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===Ke.NOT_LOADED||r===Ke.PARTIAL?$e(e)?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)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,K.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 i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.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,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:i=0;}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(a.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,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 C.KEY_LOADING:case C.FRAG_LOADING:case C.FRAG_LOADING_WAITING_RETRY:case C.PARSING:case C.PARSED:this.state=C.IDLE;break}this.nextLoadPosition=this.getLoadPosition();}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;xt(i,"playing",this.onMediaPlaying),xt(i,"seeked",this.onMediaSeeked);}onMediaDetaching(e,t){let{media:i}=this;i&&(Ut(i,"playing",this.onMediaPlaying),Ut(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=false);}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(g.BUFFER_RESET,void 0),this.couldBacktrack=false,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=false;}onManifestParsed(e,t){let i=false,r=false;t.levels.forEach(n=>{let a=n.audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1);}),this.audioCodecSwitch=i&&r&&!EA(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=false;}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==C.IDLE)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=C.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,d=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${d}`);let l=t.levelInfo,c=this.fragCurrent;c&&(this.state===C.FRAG_LOADING||this.state===C.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,u),this.hls.trigger(g.LEVEL_UPDATED,{details:o,level:a}),this.state===C.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=C.IDLE;}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick();}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,d=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!d)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;let u=ne.bufferInfo(i,r,0);if(!(u!=null&&(l=u.buffered)!=null&&l.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}let{nextStart:f}=ne.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f);}else i.currentTime=r;}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}let d=o.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Al(this.hls,K.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,E=m!==-1,p=new On(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,E),v=this.initPTS[i.cc];f.push(n,u,h,l,i,r,d.totalduration,c,p,v);}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio===2;if(dl(t.url,i))this.altAudio=1;else {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();if(r){this.fragmentTracker.removeAllFragments(),i.once(g.BUFFER_FLUSHED,()=>{var a;(a=this.hls)==null||a.trigger(g.AUDIO_TRACK_SWITCHED,t);}),i.trigger(g.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(g.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=dl(t.url,this.hls);if(i){let r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r);}this.altAudio=i?2:0,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let d=i[o];if(d.id==="main"){if(n=o,r=d,o==="video"){let l=i[o];l&&(this.videoBuffer=l.buffer);}}else a=true;}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media;}onFragBuffered(e,t){let{frag:i,part:r}=t,n=i.type===K.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===C.PARSED&&(this.state=C.IDLE);return}let o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),$e(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}let a=this.media;a&&(!this._hasEnoughToStart&&ne.getBuffered(a).length&&(this._hasEnoughToStart=true,this.seekToStartPos()),n&&this.tick());}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case R.FRAG_GAP:case R.FRAG_PARSING_ERROR:case R.FRAG_DECRYPT_ERROR:case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(K.MAIN,t);break;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:case R.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ce.LEVEL&&(this.state=C.IDLE);break;case R.BUFFER_ADD_CODEC_ERROR:case R.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case R.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case R.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=C.IDLE,this._hasEnoughToStart||(this.startFragRequested=false,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==_e.AUDIO||!this.altAudio){let i=(t===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,K.MAIN),this.tick());}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=this.timelineOffset;r&&i&&(i+=r);let n=this.getLevelDetails(),a=ne.getBuffered(e),o=a.length?a.start(0):0,d=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${d} to match buffer start`),i+=d,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i);}}_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=true,this._doFragLoad(e,t).then(i=>{let{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=C.IDLE,this.startFragRequested=false,this.bitrateTest=false;let a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(g.FRAG_LOADED,i),n.bitrateTest=false;});}_handleTransmuxComplete(e){var t;let i=this.playlistType,{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:d,part:l,level:c}=o,{video:u,text:h,id3:f,initSegment:m}=n,{details:E}=c,p=this.altAudio?void 0:n.audio;if(this.fragContextChanged(d)){this.fragmentTracker.removeFragment(d);return}if(this.state=C.PARSING,m){if(m!=null&&m.tracks){let b=d.initSegment||d;this._bufferInitSegment(c,m.tracks,b,a),r.trigger(g.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:i,tracks:m.tracks});}let v=m.initPTS,S=m.timescale,y=this.initPTS[d.cc];$(v)&&(!y||y.baseTime!==v||y.timescale!==S)&&(this.initPTS[d.cc]={baseTime:v,timescale:S},r.trigger(g.INIT_PTS_FOUND,{frag:d,id:i,initPTS:v,timescale:S}));}if(u&&E){p&&u.type==="audiovideo"&&this.logMuxedErr(d);let v=E.fragments[d.sn-1-E.startSN],S=d.sn===E.startSN,y=!v||d.cc>v.cc;if(n.independent!==false){let{startPTS:b,endPTS:L,startDTS:k,endDTS:I}=u;if(l)l.elementaryStreams[u.type]={startPTS:b,endPTS:L,startDTS:k,endDTS:I};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!y&&(this.couldBacktrack=true),u.dropped&&u.independent){let x=this.getMainFwdBufferInfo(),D=(x?x.end:this.getLoadPosition())+this.config.maxBufferHole,_=u.firstKeyFramePTS?u.firstKeyFramePTS:b;if(!S&&D<_-this.config.maxBufferHole&&!y){this.backtrack(d);return}else y&&(d.gap=true);d.setElementaryStreamInfo(u.type,d.start,L,d.start,I,true);}else S&&b-(E.appliedTimelineOffset||0)>sl&&(d.gap=true);d.setElementaryStreamInfo(u.type,b,L,k,I),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(u,d,l,a,S||y);}else if(S||y)d.gap=true;else {this.backtrack(d);return}}if(p){let{startPTS:v,endPTS:S,startDTS:y,endDTS:b}=p;l&&(l.elementaryStreams[_e.AUDIO]={startPTS:v,endPTS:S,startDTS:y,endDTS:b}),d.setElementaryStreamInfo(_e.AUDIO,v,S,y,b),this.bufferFragmentData(p,d,l,a);}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let v={id:i,frag:d,details:E,samples:f.samples};r.trigger(g.FRAG_PARSING_METADATA,v);}if(E&&h){let v={id:i,frag:d,details:E,samples:h.samples};r.trigger(g.FRAG_PARSING_USERDATA,v);}}logMuxedErr(e){this.warn(`${$e(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`);}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,c=Xo(n.codec,l);c==="mp4a"&&(c="mp4a.40.5");let u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");let h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5");}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),n.levelCodec=c,n.id=K.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${n.codec}]`),delete t.audiovideo;}if(a){a.levelCodec=e.videoCodec,a.id=K.MAIN;let l=a.codec;if(l?.length===4)switch(l){case "hvc1":case "hev1":a.codec="hvc1.1.6.L120.90";break;case "av01":a.codec="av01.0.04M.08";break;case "avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo;}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);let d=Object.keys(t);if(d.length){if(this.hls.trigger(g.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(g.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type});});}this.tickImmediate();}getMainFwdBufferInfo(){let e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,K.MAIN)}get maxBufferLength(){let{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=true,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=C.IDLE;}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===false){let i=e.currentTime;if(ne.isBuffered(e,i)?t=this.getAppendedFrag(i):ne.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(g.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(g.LEVEL_SWITCHED,{level:n}));}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return $(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if($(t)){let i=this.getLevelDetails(),r=this.currentFrag||(i?Ts(null,i.fragments,t):null);if(r){let n=r.programDateTime;if(n!==null){let a=n+(t-r.start)*1e3;return new Date(a)}}}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}},dh=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e;}abort(e){for(let i in this.keyUriToKeyInfo){let r=this.keyUriToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.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=R.KEY_LOAD_ERROR,i,r,n){return new Ft({type:W.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){let a=t[r];if(e.cc<=a.cc&&(!$e(e)||!$e(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);let d=uu(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){let r=Jo(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}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 i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let l=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,R.KEY_LOAD_ERROR,l))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,R.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var d;switch((d=o.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case "status-pending":case "usable":case "usable-in-future":return o.keyLoadPromise.then(l=>(n.key=l.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":case "AES-256":case "AES-256-CTR":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,R.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let r=this.emeController.loadKey(i);if(r)return (e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,E)=>{let{frag:p,keyInfo:v,url:S}=m;if(!p.decryptdata||v!==this.keyUriToKeyInfo[S])return o(this.createKeyLoadError(p,R.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));v.decryptdata.key=p.decryptdata.key=new Uint8Array(h.data),p.keyLoader=null,v.loader=null,a({frag:p,keyInfo:v});},onError:(h,f,m,E)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,be({url:d.url,data:void 0},h)));},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(d,c,u);})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy();}};function ap(s){let{type:e}=s;switch(e){case ce.AUDIO_TRACK:return K.AUDIO;case ce.SUBTITLE_TRACK:return K.SUBTITLE;default:return K.MAIN}}function Yc(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var ch=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(g.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this);}unregisterListeners(){let{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(g.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this);}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,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:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ce.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:d}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ce.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:d});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ce.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ce.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onLevelsUpdated(e,t){let i=this.loaders[ce.LEVEL];if(i){let r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ce.LEVEL]);}}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let l=this.hls.logger,c=r.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===ce.MANIFEST?n=i.manifestLoadPolicy.default:n=Te({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),$((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===ce.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===ce.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===ce.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){let c=l.partTarget,u=l.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=Te({},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},d={onSuccess:(l,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let m=l.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(l,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),gs.isMediaPlaylist(m)||u.type!==ce.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h);},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,false,l,h);},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,true,void 0,l);}};r.load(e,o,d);}checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t));}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=Yc(e,i),d=gs.parseMasterPlaylist(a,o);if(d.playlistParsingError){this.handleManifestParsingError(e,i,d.playlistParsingError,r,t);return}let{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=d;this.variableList=m;let{AUDIO:E=[],SUBTITLES:p,"CLOSED-CAPTIONS":v}=gs.parseMasterPlaylistMedia(a,o,d);E.length&&!E.some(y=>!y.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new Pe({}),bitrate:0,url:""})),n.trigger(g.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:p,captions:v,contentSteering:l,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:d,type:l}=i,c=Yc(e,i),u=$(d)?d:$(o)?o:0,h=ap(i),f=gs.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===ce.MANIFEST){let m={attrs:new Pe({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+Dp(f,0),a.trigger(g.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(g.ERROR,{type:W.NETWORK_ERROR,details:R.MANIFEST_PARSING_ERROR,fatal:t.type===ce.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:n});}handleNetworkError(e,t,i=false,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ce.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ce.AUDIO_TRACK||e.type===ce.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let d=R.UNKNOWN,l=false,c=this.getInternalLoader(e);switch(e.type){case ce.MANIFEST:d=i?R.MANIFEST_LOAD_TIMEOUT:R.MANIFEST_LOAD_ERROR,l=true;break;case ce.LEVEL:d=i?R.LEVEL_LOAD_TIMEOUT:R.LEVEL_LOAD_ERROR,l=false;break;case ce.AUDIO_TRACK:d=i?R.AUDIO_TRACK_LOAD_TIMEOUT:R.AUDIO_TRACK_LOAD_ERROR,l=false;break;case ce.SUBTITLE_TRACK:d=i?R.SUBTITLE_TRACK_LOAD_TIMEOUT:R.SUBTITLE_LOAD_ERROR,l=false;break}c&&this.resetInternalLoader(e.type);let u={type:W.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=t?.url||e.url;u.response=be({url:h,data:void 0},r);}this.hls.trigger(g.ERROR,u);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:d,level:l,id:c,groupId:u,deliveryDirectives:h}=r,f=Yc(t,r),m=ap(r),E=typeof r.level=="number"&&m===K.MAIN?l:void 0;if(!e.fragments.length){let v=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(g.ERROR,{type:W.NETWORK_ERROR,details:R.LEVEL_EMPTY_ERROR,fatal:false,url:f,error:v,reason:v.message,response:t,context:r,level:E,parent:m,networkDetails:n,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let p=e.playlistParsingError;if(p){if(this.hls.logger.warn(p),!o.config.ignorePlaylistParsingErrors){o.trigger(g.ERROR,{type:W.NETWORK_ERROR,details:R.LEVEL_PARSING_ERROR,fatal:false,url:f,error:p,reason:p.message,response:t,context:r,level:E,parent:m,networkDetails:n,stats:i});return}e.playlistParsingError=null;}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case ce.MANIFEST:case ce.LEVEL:o.trigger(g.LEVEL_LOADED,{details:e,levelInfo:r.levelOrTrack||o.levels[0],level:E||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:d===ce.MANIFEST});break;case ce.AUDIO_TRACK:o.trigger(g.AUDIO_TRACK_LOADED,{details:e,track:r.levelOrTrack,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break;case ce.SUBTITLE_TRACK:o.trigger(g.SUBTITLE_TRACK_LOADED,{details:e,track:r.levelOrTrack,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break}}},yr=class s{static get version(){return Fn}static isMSESupported(){return E0()}static isSupported(){return pA()}static getMediaSource(){return Gi()}static get Events(){return g}static get MetadataSchema(){return yt}static get ErrorTypes(){return W}static get ErrorDetails(){return R}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:lA}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Eh,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=false;let t=this.logger=wT(e.debug||false,"Hls instance",e.assetPlayerId),i=this.config=cA(s.DefaultConfig,e,t);this.userConfig=e,i.progressive&&uA(i,t);let{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:d}=i,l=new o(this),c=this.abrController=new r(this),u=new su(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,s):null,m=this.bufferController=new n(this,u),E=this.capLevelController=new a(this),p=new d(this),v=new ch(this),S=i.contentSteeringController,y=S?new S(this):null,b=this.levelController=new oh(this,y),L=new nh(this),k=new dh(this.config),I=this.streamController=new lh(this,u,k),x=this.gapController=new sh(this,u);E.setStreamController(I),p.setStreamController(I);let D=[v,b,I];f&&D.splice(1,0,f),y&&D.splice(1,0,y),this.networkControllers=D;let _=[c,m,x,E,p,L,u];this.audioTrackController=this.createController(i.audioTrackController,D);let M=i.audioStreamController;M&&D.push(this.audioStreamController=new M(this,u,k)),this.subtitleTrackController=this.createController(i.subtitleTrackController,D);let N=i.subtitleStreamController;N&&D.push(this.subtititleStreamController=new N(this,u,k)),this.createController(i.timelineController,_),k.emeController=this.emeController=this.createController(i.emeController,_),this.cmcdController=this.createController(i.cmcdController,_),this.latencyController=this.createController(ah,_),this.coreComponents=_,D.push(l);let q=l.onErrorOut;typeof q=="function"&&this.on(g.ERROR,q,l),this.on(g.MANIFEST_LOADED,v.onManifestLoaded,v);}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i);}once(e,t,i=this){this._emitter.once(e,t,i);}removeAllListeners(e){this._emitter.removeAllListeners(e);}off(e,t,i=this,r){this._emitter.off(e,t,i,r);}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=true;let r=e===g.ERROR;this.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=false;}}return false}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(g.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){if(!e||"media"in e&&!e.media){let n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(g.ERROR,{type:W.OTHER_ERROR,details:R.ATTACH_MEDIA_ERROR,fatal:true,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(g.MEDIA_ATTACHING,r);}detachMedia(){this.logger.log("detachMedia"),this.trigger(g.MEDIA_DETACHING,{}),this._media=null;}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(g.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=uh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(g.MANIFEST_LOADING,{url:e});}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=true,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=false;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering();}));}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering();}));}get inFlightFragments(){let e={[K.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[K.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[K.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t));}removeLevel(e){this.levelController.removeLevel(e);}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=kb()),e}get levels(){let e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.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){this.logger.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){this.logger.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 abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){oy(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 i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}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()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return ((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return ((t=this.subtitleTrackController)==null?void 0: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:false}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}set targetLatency(e){this.latencyController.targetLatency=e;}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e;}get bufferedToEnd(){var e;return !!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return ((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){let i=yp(t);return vp(e,i,navigator.mediaCapabilities)}};yr.defaultConfig=void 0;var T0=Symbol.for(""),TA=s=>{if(s?.r===T0)return s?._$litStatic$},Lh=s=>({_$litStatic$:s,r:T0});var v0=new Map,y0=s=>(e,...t)=>{let i=t.length,r,n,a=[],o=[],d,l=0,c=false;for(;l<i;){for(d=e[l];l<i&&(n=t[l],(r=TA(n))!==void 0);)d+=r+e[++l],c=true;l!==i&&o.push(n),a.push(d),l++;}if(l===i&&a.push(e[i]),c){let u=a.join("$$lit$$");(e=v0.get(u))===void 0&&(a.raw=a,v0.set(u,e=a)),t=o;}return s(e,...t)},S0=y0(chunk5NSCV6C2_cjs.c);var J,b0,A0,Pl,_0,I0,L0,x0,xh,Rh,Dh,Ol,R0,kh,Sr,Ch,D0,k0,De=class extends chunkMKZYI5TY_cjs.a{constructor(){super(...arguments);chunkIPA5Q26W_cjs.e(this,J);this._controls=["play","time","seek","volume","fullscreen","subtitles"];this.popped=false;this._startedPlaying=false;this._intersectionObserver=new chunk5KQJTT3P_cjs.a(this,{callback:chunkIPA5Q26W_cjs.f(this,J,L0).bind(this)});this.embedController=new chunkYT56YDUY_cjs.b(this);this._intersected=false;this._queue=[];}get embed(){return this._embedId}set embed(t){this._embedId!=t&&(this._embedId=t,this.embedController.embed=this.embed,this.updateStylePoster(),this.loadTheme());}get token(){return this._token}set token(t){this._token!=t&&(this._token=t,this.requestUpdate("token"),this.embedController.token=this._token);}set loop(t){this._loop=(t===""||t=="true"||t==true)??false;}get loop(){return this._loop}get controls(){return this._controls}set controls(t){typeof t=="string"?this._controls=t.split(" "):this._controls=t;}get cache(){return this._cache}set cache(t){this._cache!=t&&(typeof t=="string"?this._cache=t==="true"||t==="":this._cache=false,this.requestUpdate("caching"),this.embedController.caching=this._cache);}get quality(){return this._quality}set quality(t){this._quality!=t&&(this._quality=t);}get theme(){return this._theme||"default"}set theme(t){this._theme!=t&&(this._theme=t,this.requestUpdate("theme"),this.loadTheme());}get poster(){return !this.embed||!this._embedObj?"":this._poster&&this._poster=="custom"?this.embedController.embedFile(chunkIPA5Q26W_cjs.f(this,J,Pl).call(this,"custom_thumbnail")):this._poster&&(!Number.isNaN(parseFloat(this._poster))||!Number.isNaN(parseInt(this._poster)))?this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(t=>t.type=="custom_thumbnail")?this.embedController.embedFile(chunkIPA5Q26W_cjs.f(this,J,Pl).call(this,"custom_thumbnail")):`https://image.mave.io/${this.embedController.spaceId}${this.embedController.embedId}.jpg?time=${this._poster}`:this._poster?this._poster:this.embedController.embedFile(chunkIPA5Q26W_cjs.f(this,J,Pl).call(this,"thumbnail"))}set poster(t){t&&(this._poster=t,this.requestUpdate("poster"));}pop(){this.popped=true;}close(){this.popped=false;}set muted(t){let i=(t===""||t=="true"||t==true)??false;this._videoElement?this._videoElement.muted=i:this._queue.push(()=>this._videoElement.muted=i);}get muted(){return this._videoElement?.muted||false}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this._queue.push(()=>this._videoElement.currentTime=t);}get currentTime(){return this._videoElement?this._videoElement?.currentTime:0}get duration(){return new Promise((t,i)=>{if(this._videoElement&&!isNaN(this._videoElement.duration))return t(this._videoElement.duration);let r=()=>{this._videoElement?.addEventListener("loadedmetadata",()=>{this._videoElement&&t(this._videoElement.duration);}),this._videoElement?.addEventListener("error",()=>{i(new Error("Failed to load video metadata."));});};this._videoElement?r():this.addEventListener("mave:video_element_ready",()=>{r();});})}get paused(){return this._videoElement?this._videoElement.paused:true}play(){this._videoElement&&!this.embedController.loading?chunkIPA5Q26W_cjs.f(this,J,Ol).call(this):this._queue.push(()=>chunkIPA5Q26W_cjs.f(this,J,Ol).call(this));}restart(){this._videoElement&&(this.pause(),this._videoElement.currentTime=0,this.play());}pause(){this._videoElement?this._videoElement.pause():this._queue.push(()=>this._videoElement?.pause());}updateStylePoster(){this.style.setProperty("background",`center / contain no-repeat url(${this.poster})`);}connectedCallback(){super.connectedCallback(),this.loadTheme(),this.addEventListener("mave:video_element_ready",chunkIPA5Q26W_cjs.f(this,J,A0).bind(this));}disconnectedCallback(){super.disconnectedCallback(),this._metricsInstance?.demonitor();}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(this.theme&&this.theme.endsWith(".js")?chunkNI57YLPL_cjs.a.external(this.theme):chunkNI57YLPL_cjs.a.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=chunkNI57YLPL_cjs.a.getTheme());}updateEmbed(t){this._embedObj=t,this.updateStylePoster(),this.poster=this._embedObj.settings.poster,this.attributes.getNamedItem("color")||(this.color=this._embedObj.settings.color),this.attributes.getNamedItem("opacity")||(this.opacity=this._embedObj.settings.opacity?this._embedObj.settings.opacity:void 0),this.attributes.getNamedItem("aspect-ratio")||(this.aspect_ratio=this._embedObj.settings.aspect_ratio),this.attributes.getNamedItem("width")||(this.width=this._embedObj.settings.width),this.attributes.getNamedItem("height")||(this.height=this._embedObj.settings.height),this.attributes.getNamedItem("autoplay")||(this.autoplay=this._embedObj.settings.autoplay=="on_show"?"lazy":this._embedObj.settings.autoplay),this.attributes.getNamedItem("controls")||(this.controls=this._embedObj.settings.controls),this.attributes.getNamedItem("loop")||(this.loop=this._embedObj.settings.loop);}get styles(){let t={},i=!!this._embedObj?.subtitles?.length,r=this.subtitles==="none"||this.subtitles==="off"||!i,n=this.controls.includes("volume")||this.controls.includes("full");return (this.color||this._embedObj?.settings.color)&&(t["--primary-color"]=`${this.color||this._embedObj?.settings.color}${this.opacity||this._embedObj?.settings.opacity?this._embedObj?.settings.opacity:""}`),this.aspect_ratio=="auto"||this._embedObj?.settings.aspect_ratio=="auto"&&!this.aspect_ratio?t["--aspect-ratio"]=this._embedObj?.video.aspect_ratio:t["--aspect-ratio"]=this.aspect_ratio||this._embedObj?.settings.aspect_ratio,(this.width||this._embedObj?.settings.width)&&(t["--width"]=this.width||this._embedObj?.settings.width),(this.height||this._embedObj?.settings.height)&&(t["--height"]=this.height||this._embedObj?.settings.height),!this.controls.includes("full")&&!this.controls.includes("big")&&!this.controls.includes("none")&&(t["--play-display"]=this.controls.includes("play")?"flex":"none",t["--time-display"]=this.controls.includes("time")?"flex":"none",t["--seek-bar-visibility"]=this.controls.includes("seek")?"visible":"hidden",t["--volume-display"]=this.controls.includes("volume")?"flex":"none",t["--fullscreen-display"]=this.controls.includes("fullscreen")?"flex":"none",t["--media-captions-menu-button-display"]=this.controls.includes("subtitles")?"flex":"none"),t["--playbackrate-display"]=this.controls.includes("rate")?"flex":"none",(r||this._embedObj?.created_at<1740674988&&!this.subtitles&&!this.active_subtitle)&&(t["--media-captions-menu-button-display"]="none"),this.controls.includes("full")||this._embedObj?.settings.controls=="full"&&!this.controls.includes("big")&&!this.controls.includes("none")?t["--media-control-bar-display"]="flex":t["--media-control-bar-display"]="none",this.controls.includes("big")||this._embedObj?.settings.controls=="big"&&!this.controls.includes("full")&&!this.controls.includes("none")?t["--big-button-display"]="flex":t["--big-button-display"]="none",this._embedObj?.video.audio===false?t["--media-mute-button-display"]="none":n?t["--media-mute-button-display"]="flex":t["--media-mute-button-display"]="none",chunkQ22T22LT_cjs.a(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return chunk5NSCV6C2_cjs.c`
|
|
1728
|
-
<slot
|
|
1729
|
-
name="video"
|
|
1730
|
-
style=${chunkQ22T22LT_cjs.a({display:t&&!this._startedPlaying?"none":"block"})}
|
|
1731
|
-
>
|
|
1732
|
-
${this.embedController.render({complete:i=>{if(this._embed||(this._embedObj=i,this.updateEmbed(this._embedObj)),!!i)return S0`<theme-${Lh(this._themeLoaded)} style=${this.styles}>
|
|
1733
|
-
<video
|
|
1734
|
-
@click=${chunkIPA5Q26W_cjs.f(this,J,Ol)}
|
|
1735
|
-
playsinline
|
|
1736
|
-
?loop=${this.loop||this._embedObj.settings.loop}
|
|
1737
|
-
poster=${this.poster}
|
|
1738
|
-
${chunk5KQJTT3P_cjs.c(chunkIPA5Q26W_cjs.f(this,J,I0))}
|
|
1739
|
-
slot="media"
|
|
1740
|
-
crossorigin="anonymous"
|
|
1741
|
-
>
|
|
1742
|
-
${chunkIPA5Q26W_cjs.d(this,J,k0)}
|
|
1743
|
-
${chunkIPA5Q26W_cjs.d(this,J,D0)}
|
|
1744
|
-
</video>
|
|
1745
|
-
</theme-${Lh(this._themeLoaded)}>`}})}
|
|
1746
|
-
</slot>
|
|
1747
|
-
<slot name="start-screen"></slot>
|
|
1748
|
-
<slot name="end-screen"></slot>
|
|
1749
|
-
<slot name="hover-screen"></slot>
|
|
1750
|
-
`}};J=new WeakSet,b0=function(t,i){let r=new URL(i);if(this.token&&!r.searchParams.get("token")){let n=new URLSearchParams;n.append("token",this.token),r.search=n.toString();}t.open("GET",r.toString());},A0=function(){this._videoElement?.addEventListener("webkitbeginfullscreen",()=>{this.style.setProperty("--subtitle-opacity","1");}),this._videoElement?.addEventListener("webkitendfullscreen",()=>{this.style.setProperty("--subtitle-opacity","0");});},Pl=function(t){let r=(a=>this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(o=>o.container===a&&o.type===t))("jpg"),n=t=="custom_thumbnail"?"thumbnail":t;return r?`${n}.jpg${r&&r.date?`?e=${r.date}`:""}`:`${n}.jpg`},_0=function(){let t=[{name:"sd",width:640},{name:"hd",width:1280},{name:"fhd",width:1920},{name:"qhd",width:2560},{name:"uhd",width:3840}],i=t.find(r=>r.name==this.quality);return i?t.indexOf(i):2},I0=function(t){if(t&&t.tagName=="VIDEO"&&(chunkIPA5Q26W_cjs.d(this,J,Sr)||chunkIPA5Q26W_cjs.d(this,J,Ch))){this._videoElement=t,this.dispatchEvent(new CustomEvent("mave:video_element_ready",{detail:this._videoElement,bubbles:true,composed:true})),this._intersectionObserver.observe(this._videoElement),chunkSDKTBB4N_cjs.a.forEach(n=>{this._videoElement?.addEventListener(n,a=>{if(n=="play"&&chunkIPA5Q26W_cjs.f(this,J,x0).call(this),n=="ended"&&chunkIPA5Q26W_cjs.f(this,J,xh).call(this),n=="timeupdate"&&this._videoElement&&this._videoElement.duration-this._videoElement.currentTime<5){let o=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(o&&o.getAttribute("x-mave-end-shows")=="near_end"){chunkIPA5Q26W_cjs.f(this,J,xh).call(this);let d=this.querySelector("[name='mave-time-remaining']");if(d){let c=Math.floor(this._videoElement.duration-this._videoElement.currentTime);d.innerHTML=c<=0?"0":c.toString();}if(this._videoElement?.duration-this._videoElement?.currentTime<=0&&o.getAttribute("x-mave-list-trigger-next")=="true"){let c=[...document.querySelectorAll("mave-list")].find(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);u&&this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id});}}let l=this.querySelector("[name='mave-list-next-image']");if(l){let c=[...document.querySelectorAll("mave-list")].find(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);if(u){let h=document.createElement("mave-img");h.setAttribute("embed",u.id),h.addEventListener("click",()=>{this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id}),l.innerHTML="";}),l.appendChild(h);}else l.innerHTML="";}}}}this.dispatchEvent(new CustomEvent(n,{detail:a,bubbles:true,composed:true}));});}),Kn.Metrics.config={socketPath:chunk5STN56TL_cjs.a.metrics.socket,apiKey:this._embedObj.metrics_key};let i={component:"player",video_id:this._embedObj.video.id,space_id:this._embedObj.space_id},r=/iPhone|iPad/.test(navigator.userAgent);yr.isSupported()&&chunkIPA5Q26W_cjs.d(this,J,Sr)&&!r?(this.hls=new yr({startLevel:chunkIPA5Q26W_cjs.f(this,J,_0).call(this),capLevelToPlayerSize:true,xhrSetup:chunkIPA5Q26W_cjs.f(this,J,b0).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(chunkIPA5Q26W_cjs.d(this,J,Sr)),this.hls?.attachMedia(this._videoElement),chunk5STN56TL_cjs.a.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this.hls,this.embed,i))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&chunkIPA5Q26W_cjs.d(this,J,Sr)?(this._videoElement.src=chunkIPA5Q26W_cjs.d(this,J,Sr),chunk5STN56TL_cjs.a.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))):(this._videoElement.src=chunkIPA5Q26W_cjs.d(this,J,Ch),chunk5STN56TL_cjs.a.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),chunkIPA5Q26W_cjs.f(this,J,Dh).call(this),chunkIPA5Q26W_cjs.f(this,J,Rh).call(this);}},L0=function(t){for(let{isIntersecting:i}of t)t.length&&(t[0].target.tagName=="VIDEO"||t[0].target.tagName=="MAVE-PLAYER")&&(this._intersected=i,chunkIPA5Q26W_cjs.f(this,J,Dh).call(this));},x0=function(){if(this.active_subtitle&&!this._startedPlaying){let i;if(this.active_subtitle=="original"||this.subtitles=="original"){let r=this._embedObj.video.language;i=this._videoElement?.querySelector(`track[srclang="${r}"]`);}else i=this._videoElement?.querySelector(`track[srclang="${this.active_subtitle}"]`);i&&(i.track.mode="showing");}this._startedPlaying=true,chunkIPA5Q26W_cjs.f(this,J,Rh).call(this),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');t&&((this.shadowRoot?.querySelector("slot[name='video']")).removeAttribute("style"),this.startScreenElement.style.display="none",t.style.display="none");},xh=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(t){if(t.tagName==="TEMPLATE"){let i=t,r=i.parentElement,n=document.createElement("div");for(let a of i.attributes)n.setAttribute(a.name,a.value);n.style.display="block",n.innerHTML=i.innerHTML,r?.replaceChild(n,i);}this.endScreenElement.style.display="block",t.style.display="block",this._previousControls||(this._previousControls=this.controls),this.controls="none";}},Rh=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');t&&(this.endScreenElement.style.display="none",t.style.display="none"),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);},Dh=function(){this._embedObj&&this.autoplay=="always"&&this._videoElement?.paused&&(this._metricsInstance?.monitor(),this._videoElement.muted=true,this._videoElement?.play()),this._embedObj&&(this.autoplay==="lazy"||this.autoplay==="true"||this._embedObj.settings.autoplay=="on_show")&&(this._intersected?this._videoElement?.paused&&(this._metricsInstance?.monitor(),this._videoElement.muted=true,this._videoElement?.play()):this._videoElement&&!this._videoElement.paused&&this._videoElement.readyState>2&&this._videoElement?.pause());},Ol=function(){this._videoElement?.paused?(this._metricsInstance?.monitor(),this._videoElement?.play()):this._videoElement?.pause();},R0=function(t){let i=t.target.track,r=i.activeCues;if(i.mode=="showing"&&(this._currentTrackLanguage=i.language),!this._subtitlesText){let n=this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot?.querySelector("#subtitles_text");n&&(this._subtitlesText=n);}if(r.length){let n=r[0];this._subtitlesText.style.opacity="1",this._subtitlesText.style.transform="scale(1)",this._subtitlesText.innerHTML=n.text.replace(/\n/g,"<br>");}else this._subtitlesText.style.opacity="0",this._subtitlesText.style.transform="scale(0.99)";},kh=function(t){let i=this._embedObj.video.renditions.filter(a=>a.container==t),r=["sd","hd","fhd","qhd","uhd"];return !i||!i.length?void 0:i.reduce((a,o)=>r.indexOf(o.size)>r.indexOf(a.size)?o:a)},Sr=function(){let t=chunkIPA5Q26W_cjs.f(this,J,kh).call(this,"hls");if(t){let i=new URLSearchParams;return i.append("quality",t.size),this.embedController.embedFile("playlist.m3u8",i)}},Ch=function(){let t=chunkIPA5Q26W_cjs.f(this,J,kh).call(this,"mp4");return t?this.embedController.embedFile(`h264_${t?.size}.mp4`):this._embedObj.video.original},D0=function(){if(this._embedObj.subtitles.length>0){let t=this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot?.querySelector("media-captions-menu");return t&&new MutationObserver(r=>{r.forEach(()=>{this._subtitlesText&&t.getAttribute("mediasubtitlesshowing")&&(this._subtitlesText.style.opacity="0");});}).observe(t,{attributes:true}),this._embedObj.subtitles.map(i=>{if(this.subtitles&&this.subtitles.includes(i.language)||this.active_subtitle&&this.active_subtitle==i.language||this.subtitles=="all"||(this.subtitles=="original"||this.active_subtitle=="original")&&this._embedObj.video.language==i.language||!this.subtitles)return chunk5NSCV6C2_cjs.c`
|
|
1751
|
-
<track mode="hidden" @cuechange=${chunkIPA5Q26W_cjs.f(this,J,R0)} label=${i.label} kind="subtitles" srclang=${i.language} src=${i.path}></track>
|
|
1752
|
-
`})}},k0=function(){return chunk5NSCV6C2_cjs.c`<track
|
|
1753
|
-
label="thumbnails"
|
|
1754
|
-
default
|
|
1755
|
-
kind="metadata"
|
|
1756
|
-
src=${this.embedController.embedFile("storyboard.vtt")}></track>`},De.styles=chunk5NSCV6C2_cjs.h`
|
|
1757
|
-
:host {
|
|
1758
|
-
display: block;
|
|
1759
|
-
position: relative;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
video::cue {
|
|
1763
|
-
font-family: Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial,
|
|
1764
|
-
sans-serif;
|
|
1765
|
-
font-weight: 500;
|
|
1766
|
-
display: var(--subtitle-display, initial);
|
|
1767
|
-
opacity: var(--subtitle-opacity, 0);
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
video::-webkit-media-text-track-display {
|
|
1771
|
-
transform: var(--subtitle-transform, initial);
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
video:focus-visible {
|
|
1775
|
-
outline: 0;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
:host,
|
|
1779
|
-
media-controller,
|
|
1780
|
-
theme-default,
|
|
1781
|
-
video {
|
|
1782
|
-
width: 100%;
|
|
1783
|
-
max-height: 100vh;
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
slot[name='start-screen'],
|
|
1787
|
-
slot[name='end-screen'] {
|
|
1788
|
-
position: absolute;
|
|
1789
|
-
width: 100%;
|
|
1790
|
-
height: 100%;
|
|
1791
|
-
z-index: 99;
|
|
1792
|
-
top: 0;
|
|
1793
|
-
left: 0;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
slot[name='end-screen'] {
|
|
1797
|
-
display: none;
|
|
1798
|
-
}
|
|
1799
|
-
`,chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"embed",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"token",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a({attribute:"aspect-ratio"})],De.prototype,"aspect_ratio",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"width",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"subtitles",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a({attribute:"active-subtitle"})],De.prototype,"active_subtitle",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"height",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"autoplay",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"color",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"opacity",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"loop",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"controls",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"cache",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"quality",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"theme",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"poster",1),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.b()],De.prototype,"popped",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.c("slot[name='end-screen']")],De.prototype,"endScreenElement",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.c("slot[name='start-screen']")],De.prototype,"startScreenElement",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.b()],De.prototype,"_embedObj",2),chunkIPA5Q26W_cjs.c([chunkFUBUUA7Y_cjs.a()],De.prototype,"muted",1);typeof window<"u"&&window.customElements&&(window.customElements.get("mave-player")||window.customElements.define("mave-player",De));/*! Bundled license information:
|
|
1800
|
-
|
|
1801
|
-
lit-html/static.js:
|
|
1802
|
-
(**
|
|
1803
|
-
* @license
|
|
1804
|
-
* Copyright 2020 Google LLC
|
|
1805
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1806
|
-
*)
|
|
1807
|
-
*/exports.a=De;
|