@maveio/components 0.0.155-beta.0 → 0.0.156

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.
Files changed (41) hide show
  1. package/dist/{chunk-6NE3LOKU.js → chunk-4AYP3SUJ.js} +1 -1
  2. package/dist/{chunk-7MHSKSE5.js → chunk-4DCPDVPE.js} +6 -6
  3. package/dist/{chunk-ESQT2PPF.js → chunk-5IPIXU3O.js} +3 -3
  4. package/dist/{chunk-4M7XLFOJ.cjs → chunk-DESQSXZF.cjs} +4 -4
  5. package/dist/chunk-LGWESJBJ.cjs +20 -0
  6. package/dist/chunk-PLCF3Z5Q.cjs +7 -0
  7. package/dist/chunk-SRXHXTDF.js +7 -0
  8. package/dist/{chunk-ALY7UTZA.cjs → chunk-Z5AM3NST.cjs} +2 -2
  9. package/dist/{chunk-M3UFDMO6.cjs → chunk-ZMMJMM4X.cjs} +3 -3
  10. package/dist/chunk-ZT2E4EC7.js +20 -0
  11. package/dist/components/files.cjs +1 -1
  12. package/dist/components/files.js +1 -1
  13. package/dist/components/list.cjs +1 -1
  14. package/dist/components/list.js +1 -1
  15. package/dist/components/player.cjs +1 -1
  16. package/dist/components/player.js +1 -1
  17. package/dist/components/pop.cjs +1 -1
  18. package/dist/components/pop.js +1 -1
  19. package/dist/components/upload.cjs +1 -1
  20. package/dist/components/upload.d.cts +13 -8
  21. package/dist/components/upload.d.ts +13 -8
  22. package/dist/components/upload.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/react.cjs +1 -1
  26. package/dist/react.js +1 -1
  27. package/dist/themes/dolphin.cjs +2 -2
  28. package/dist/themes/dolphin.js +2 -2
  29. package/dist/themes/loader.cjs +1 -1
  30. package/dist/themes/loader.js +1 -1
  31. package/dist/themes/synthwave.cjs +2 -2
  32. package/dist/themes/synthwave.js +2 -2
  33. package/dist/vue.cjs +1 -1
  34. package/dist/vue.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-3MEOYLCV.cjs +0 -20
  37. package/dist/chunk-7WWUNKRI.js +0 -7
  38. package/dist/chunk-OTDMHX6X.js +0 -20
  39. package/dist/chunk-RFBU3KXA.cjs +0 -7
  40. /package/dist/{chunk-ZOWJYZSD.js → chunk-EXNM5EV2.js} +0 -0
  41. /package/dist/{chunk-2ELUELDT.cjs → chunk-NI57YLPL.cjs} +0 -0
@@ -1,4 +1,4 @@
1
- import {a as a$3}from'./chunk-ZOWJYZSD.js';import {a as a$4}from'./chunk-MS5NFI3Q.js';import {b as b$1,a as a$2,c as c$2}from'./chunk-CUGRXOA2.js';import {a as a$5}from'./chunk-MK4VIJT3.js';import {b as b$3}from'./chunk-HX6F65VL.js';import {a as a$1}from'./chunk-45FW5DBN.js';import {a,b as b$2,c as c$1}from'./chunk-HMISRRKC.js';import {h,c as c$3}from'./chunk-A4GZBQEB.js';import {a as a$6}from'./chunk-JBV2AYRP.js';import {b,c,e,f,d}from'./chunk-NDDFZTBA.js';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 `
1
+ import {a as a$3}from'./chunk-EXNM5EV2.js';import {a as a$4}from'./chunk-MS5NFI3Q.js';import {b as b$1,a as a$2,c as c$2}from'./chunk-CUGRXOA2.js';import {a as a$5}from'./chunk-MK4VIJT3.js';import {b as b$3}from'./chunk-HX6F65VL.js';import {a as a$1}from'./chunk-45FW5DBN.js';import {a,b as b$2,c as c$1}from'./chunk-HMISRRKC.js';import {h,c as c$3}from'./chunk-A4GZBQEB.js';import {a as a$6}from'./chunk-JBV2AYRP.js';import {b,c,e,f,d}from'./chunk-NDDFZTBA.js';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
2
  <style>
3
3
  :host {
4
4
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
@@ -1724,7 +1724,7 @@ Schedule: ${d.map(m=>Ui(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Remo
1724
1724
  `).split(`
1725
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
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(c$3);var J,b0,A0,Pl,_0,I0,L0,x0,xh,Rh,Dh,Ol,R0,kh,Sr,Ch,D0,k0,De=class extends a$1{constructor(){super(...arguments);e(this,J);this._controls=["play","time","seek","volume","fullscreen","subtitles"];this.popped=false;this._startedPlaying=false;this._intersectionObserver=new a$2(this,{callback:f(this,J,L0).bind(this)});this.embedController=new b$3(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(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(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(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?f(this,J,Ol).call(this):this._queue.push(()=>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",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")?a$3.external(this.theme):a$3.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=a$3.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={};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",((this.subtitles=="none"||this.subtitles=="off"||this._embedObj?.subtitles.length==0)&&!this.active_subtitle||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":t["--media-mute-button-display"]="flex",a$4(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"]');return c$3`
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(c$3);var J,b0,A0,Pl,_0,I0,L0,x0,xh,Rh,Dh,Ol,R0,kh,Sr,Ch,D0,k0,De=class extends a$1{constructor(){super(...arguments);e(this,J);this._controls=["play","time","seek","volume","fullscreen","subtitles"];this.popped=false;this._startedPlaying=false;this._intersectionObserver=new a$2(this,{callback:f(this,J,L0).bind(this)});this.embedController=new b$3(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(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(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(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?f(this,J,Ol).call(this):this._queue.push(()=>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",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")?a$3.external(this.theme):a$3.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=a$3.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",a$4(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return c$3`
1728
1728
  <slot
1729
1729
  name="video"
1730
1730
  style=${a$4({display:t&&!this._startedPlaying?"none":"block"})}
@@ -1747,7 +1747,7 @@ Schedule: ${d.map(m=>Ui(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Remo
1747
1747
  <slot name="start-screen"></slot>
1748
1748
  <slot name="end-screen"></slot>
1749
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"&&(d(this,J,Sr)||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),a$5.forEach(n=>{this._videoElement?.addEventListener(n,a=>{if(n=="play"&&f(this,J,x0).call(this),n=="ended"&&f(this,J,xh).call(this),n=="timeupdate"&&this._videoElement&&this._videoElement.duration-this._videoElement.currentTime<5){let o=this.querySelector('[slot="end-screen"]');if(o&&o.getAttribute("x-mave-end-shows")=="near_end"){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:a$6.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()&&d(this,J,Sr)&&!r?(this.hls=new yr({startLevel:f(this,J,_0).call(this),capLevelToPlayerSize:true,xhrSetup:f(this,J,b0).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(d(this,J,Sr)),this.hls?.attachMedia(this._videoElement),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this.hls,this.embed,i))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&d(this,J,Sr)?(this._videoElement.src=d(this,J,Sr),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))):(this._videoElement.src=d(this,J,Ch),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),f(this,J,Dh).call(this),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,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,f(this,J,Rh).call(this),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);let t=this.querySelector('[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"]');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"]');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=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=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 c$3`
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"&&(d(this,J,Sr)||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),a$5.forEach(n=>{this._videoElement?.addEventListener(n,a=>{if(n=="play"&&f(this,J,x0).call(this),n=="ended"&&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"){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:a$6.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()&&d(this,J,Sr)&&!r?(this.hls=new yr({startLevel:f(this,J,_0).call(this),capLevelToPlayerSize:true,xhrSetup:f(this,J,b0).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(d(this,J,Sr)),this.hls?.attachMedia(this._videoElement),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this.hls,this.embed,i))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&d(this,J,Sr)?(this._videoElement.src=d(this,J,Sr),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))):(this._videoElement.src=d(this,J,Ch),a$6.metrics.enabled&&(this._metricsInstance=new Kn.Metrics(this._videoElement,this.embed,i))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),f(this,J,Dh).call(this),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,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,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=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=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 c$3`
1751
1751
  <track mode="hidden" @cuechange=${f(this,J,R0)} label=${i.label} kind="subtitles" srclang=${i.language} src=${i.path}></track>
1752
1752
  `})}},k0=function(){return c$3`<track
1753
1753
  label="thumbnails"